WorkOrder.php 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use Monolog\Handler\IFTTTHandler;
  5. use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
  6. use think\Db;
  7. use think\Request;
  8. use PhpOffice\PhpSpreadsheet\IOFactory;
  9. /**
  10. * 工单资料管理
  11. */
  12. class WorkOrder extends Api
  13. {
  14. protected $noNeedLogin = ['*'];
  15. protected $noNeedRight = ['*'];
  16. /**
  17. * 工单资料菜单列表
  18. *
  19. * @ApiMethod (GET)
  20. * @return false|string
  21. * @throws \think\Exception
  22. */
  23. public function DataList()
  24. {
  25. if ($this->request->isGet() === false){
  26. $this->error('请求错误');
  27. }
  28. //获取总计划中数量和总生产中数量
  29. $productingAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','2-生产中')->cache(true)->count();
  30. $progressAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','3-计划中')->cache(true)->count();
  31. $data = [
  32. 'productingAll' => $productingAll,
  33. 'progressAll' => $progressAll
  34. ];
  35. // $sql = "SELECT
  36. // SUBSTRING( `成品代号`, 1, 4 ) AS prefix,
  37. // rtrim( Gd_khmc ) AS khmc,
  38. // RTRIM( `Gd_客户名称` ) AS 客户名称
  39. // FROM
  40. // `工单_基本资料`
  41. // WHERE
  42. // `成品代号` <> ''
  43. // AND ( `Gd_客户名称` <> '' OR Gd_khmc <> '' )
  44. // GROUP BY
  45. // prefix
  46. // ORDER BY
  47. // prefix";
  48. $sql = "SELECT DISTINCT
  49. (客户编号),rtrim(客户名称 ) as 客户名称
  50. FROM
  51. `产品_基本资料`
  52. GROUP BY
  53. 客户编号
  54. order by
  55. 客户编号";
  56. $list = \db()->query($sql);
  57. if (empty($list)){
  58. $this->success('',[]);
  59. }
  60. foreach ($list as $key=>$value){
  61. $value['客户编号'] = rtrim($value['客户编号']);
  62. if ($value['客户编号'] == '1098'){
  63. $value['客户名称'] = '打样专用';
  64. }
  65. //这条sql查出来的数据可能不对,试一下以下sql
  66. //SELECT COUNT(*) FROM `工单_基本资料` WHERE (SUBSTRING( `成品代号`, 1, 4 ) = '1001' OR (`Gd_客户名称`='浙江中烟' AND `Gd_客户代号` = '1001')) AND gd_statu = '2-生产中' AND `行号` = '1'
  67. $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
  68. $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
  69. $string = '';
  70. if ($productIng != 0){
  71. $string = $string."生产中:".$productIng;
  72. }
  73. if ($proGress != 0){
  74. $string = $string."计划中:".$proGress;
  75. }
  76. if ($string !== ''){
  77. // $data[$key] = $value['prefix'].'【'.$string.'】'.($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
  78. $data[$key] = $value['客户编号'].'【'.$string.'】'.$value['客户名称'];
  79. }else{
  80. // $data[$key] = $value['prefix'].($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
  81. $data[$key] = $value['客户编号'].$value['客户名称'];
  82. }
  83. }
  84. $this->success('成功',$data);
  85. }
  86. /**
  87. * 工单基本资料列表
  88. * @ApiMethod (GET)
  89. * @param string $limit 查询长度
  90. * @param string $Gd_khdh 客户代号
  91. * @param string $startTime 接单日期开始时间
  92. * @param string $endTime 接单日期结束时间
  93. * @return \think\response\Json
  94. * @throws \think\exception\DbException
  95. */
  96. public function WorkList()
  97. {
  98. if ($this->request->isGet() === false){
  99. $this->error('请求错误');
  100. }
  101. $search = input('search');
  102. $clientNumber = input('Gd_khdh');
  103. $startTime = input('start');
  104. $endTime = input('end');
  105. $page = input('page');
  106. $limit = input('limit');
  107. $where = [];
  108. if (!empty($clientNumber)){
  109. $where['成品代号'] = ['like',$clientNumber.'%'];
  110. }
  111. if (!empty($workOrder)){
  112. $where['Gd_gdbh'] = $workOrder;
  113. }
  114. if (!empty($productCode)){
  115. $where['Gd_cpdh'] = $productCode;
  116. }
  117. if (!empty($search)){
  118. $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$search.'%'];
  119. }
  120. if (!empty($startTime) && !empty($endTime)){
  121. $where['接单日期'] = ['between',[$startTime,$endTime]];
  122. }
  123. $total = \db('工单_基本资料')->where($where)->count();
  124. $list = \db('工单_基本资料')
  125. ->where($where)
  126. ->order('Gd_statu desc')
  127. ->limit(($page-1)*$limit,$limit)
  128. ->select();
  129. //工单基本资料数据整理
  130. $data = [];
  131. foreach ($list as $key=>$value){
  132. $data[$key] = [
  133. '工单编号' => rtrim($value['Gd_gdbh']),
  134. '生产分类' => rtrim($value['Gd_生产分类']),
  135. '销售订单号' => rtrim($value['销售订单号']),
  136. '产品代号' => rtrim($value['Gd_cpdh']),
  137. '产品名称' => rtrim($value['Gd_cpmc']),
  138. '订单数量' => floatval($value['订单数量']),
  139. '单位' => rtrim($value['计量单位']),
  140. '折合大箱' => rtrim((int)$value['投料大箱']),
  141. '投料率' => rtrim($value['投料率']),
  142. '平均合格率' => '',
  143. '开单日期' => date('Y-m-d',strtotime(rtrim($value['接单日期']))),
  144. '交货日期' => date('Y-m-d',strtotime(rtrim($value['交货日期']))),
  145. '工单类型' => rtrim($value['Gd_lx']),
  146. '工单状态' => rtrim($value['gd_statu']),
  147. '当前生产工序' => '',
  148. '产量提交时间' => '',
  149. '建档用户' => rtrim($value['Sys_id']),
  150. '建档时间' => rtrim($value['Sys_rq']),
  151. '更新时间' => rtrim($value['Mod_rq']),
  152. 'Uniqid' => rtrim($value['Uniqid'])
  153. ];
  154. $number = \db('工单_工艺资料')->where('Gy0_gdbh',$data[$key]['工单编号'])->count();
  155. if ($number === 0){
  156. $data[$key]['status'] = '*';
  157. }else{
  158. $data[$key]['status'] = '';
  159. }
  160. }
  161. $this->success('成功',['data'=>$data,'total'=>$total]);
  162. }
  163. /**
  164. * 工单详情
  165. * @ApiMethod (GET)
  166. * @param void
  167. * @return void
  168. * @throws \think\db\exception\DataNotFoundException
  169. * @throws \think\db\exception\ModelNotFoundException
  170. * @throws \think\exception\DbException
  171. */
  172. public function workOrderListDetail()
  173. {
  174. if ($this->request->isGet() === false){
  175. $this->error('请求错误');
  176. }
  177. $Gd_gdbh = input('Gd_gdbh');
  178. if (empty($Gd_gdbh)){
  179. $this->error('参数错误');
  180. }
  181. $data = [];
  182. //印件资料
  183. $printList = \db('工单_印件资料')
  184. ->where('Yj_Gdbh',$Gd_gdbh)
  185. ->select();
  186. if (!empty($printList)){
  187. foreach ($printList as $key=>$value){
  188. $data['printList'][$key] = [
  189. '印件号' => rtrim($value['yj_Yjno']),
  190. '印件代号' => rtrim($value['yj_Yjdh']),
  191. '印件名称' => rtrim($value['yj_yjmc']),
  192. '纸张代号' => rtrim($value['yj_zzdh']),
  193. '纸张名称' => rtrim($value['yj_zzmc']),
  194. '投料规格' => rtrim($value['yj_tlgg']),
  195. '平张投料' => rtrim($value['yj_平张投料']),
  196. '开料规格' => rtrim($value['yj_klgg']),
  197. '开数*联数' => rtrim($value['yj_ks']).'*'.rtrim($value['yj_ls']),
  198. '建档用户' => rtrim($value['Sys_id']),
  199. '建档时间' => rtrim($value['Sys_rq']),
  200. '更新时间' => rtrim($value['Mod_rq']),
  201. 'zzdh1' => rtrim($value['yj_zzdh1']),
  202. 'zzdh2' => rtrim($value['yj_zzdh2']),
  203. 'zzdh3' => rtrim($value['yj_zzdh3']),
  204. 'zzdh4' => rtrim($value['yj_zzdh4']),
  205. 'zzmc1' => rtrim($value['yj_zzmc1']),
  206. 'zzmc2' => rtrim($value['yj_zzmc2']),
  207. 'zzmc3' => rtrim($value['yj_zzmc3']),
  208. 'zzmc4' => rtrim($value['yj_zzmc4']),
  209. '订单数量' => rtrim($value['yj_成品数量']),
  210. '万小张' => rtrim($value['yj_实际投料']),
  211. '开数' => rtrim($value['yj_ks']),
  212. '联数' => rtrim($value['yj_ls']),
  213. '核算规格' => rtrim($value['Yj_核算规格']),
  214. '备注' => rtrim($value['yj_desc']),
  215. 'Uniqid' => rtrim($value['Uniqid'])
  216. ];
  217. }
  218. }else{
  219. $data['printList'] = [];
  220. }
  221. //工艺资料
  222. $processList = \db('工单_工艺资料')
  223. ->where('Gy0_gdbh',$Gd_gdbh)
  224. ->order('Gy0_yjno,Gy0_gxh')
  225. ->select();
  226. if (!empty($processList)){
  227. foreach ($processList as $key=>$value){
  228. if ($value['Gy0_yjno']<10){
  229. $value['Gy0_yjno'] = '0'.$value['Gy0_yjno'];
  230. }
  231. if ($value['Gy0_gxh']<10){
  232. $value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
  233. }
  234. if ((int)$value['Gy0_ms'] === 0){
  235. $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']);
  236. }else{
  237. $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']*$value['Gy0_ms']);
  238. }
  239. if (rtrim($value['Gy0_sbbh']) == '' || $value['Gy0_计划接货数'] == 0){
  240. $number = 0;
  241. }else{
  242. $number = round(($scrap/((int)($value['Gy0_计划接货数']/$value['Gy0_ls'])))*100,2).'%';
  243. }
  244. if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
  245. $status = '已完工';
  246. }else{
  247. $status = '未完工';
  248. }
  249. $data['processList'][$key] = [
  250. '重点工序' => rtrim($value['重点工序']),
  251. '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
  252. '备选工序' => rtrim($value['备选工序']),
  253. '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
  254. '计划产量' => (int)($value['Gy0_计划接货数']/$value['Gy0_ls']),
  255. '基础损耗' => rtrim($value['Gy0_Rate0']),
  256. '损耗率' => rtrim($value['Gy0_Rate1']),
  257. '机台编号' => rtrim($value['Gy0_sbbh']),
  258. '报废定额' => $scrap,
  259. '允损比例' => $number,
  260. '难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
  261. '损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
  262. '人工检_次品板' => (int)$value['人工检_次品板']=0?'':$value['人工检_次品板'],
  263. '人工检_废检' => (int)$value['人工检_废检']=0?'':$value['人工检_废检'],
  264. '机检_正品板' => (int)$value['机检_正品板']=0?'':$value['机检_正品板'],
  265. '机检_次品板' => (int)$value['机检_次品板']=0?'':$value['机检_次品板'],
  266. '机检_废检' => (int)$value['机检_废检']=0?'':$value['机检_废检'],
  267. '开数*联数' => rtrim($value['Gy0_ks']).'*'.rtrim($value['Gy0_ls']),
  268. '备注' => isset($value['工序备注'])?rtrim($value['工序备注']):'',
  269. '印刷方式' => isset($value['印刷方式'])?rtrim($value['印刷方式']):'',
  270. '版距' => isset($value['版距'])?rtrim($value['版距']):'',
  271. '建档用户' => rtrim($value['Sys_id']),
  272. '建档日期' => isset($value['Sys_rq'])?rtrim($value['Sys_rq']):'',
  273. '更新时间' => isset($value['Mod_rq'])?rtrim($value['Mod_rq']):'',
  274. '车间名称' => rtrim($value['Gy0_SITE']),
  275. '质量要求' => rtrim($value['质量要求']),
  276. '质量隐患' => rtrim($value['质量隐患']),
  277. '开数' => rtrim($value['Gy0_ks']),
  278. '联数' => rtrim($value['Gy0_ls']),
  279. 'UniqId' => rtrim($value['UniqId']),
  280. 'shdh' => rtrim($value['Gy0_shdh']),
  281. '辅助工时' => rtrim($value['Gy0_辅助工时']),
  282. '小时产能' => rtrim($value['Gy0_小时产能']),
  283. 'status' => $status
  284. ];
  285. }
  286. }else{
  287. $data['processList'] = [];
  288. }
  289. //BOM资料
  290. $field = 'rtrim(BOM_方案) as 方案,rtrim(BOM_物料编码) as 物料编号,rtrim(BOM_物料名称) as 物料名称,BOM_投料单位,
  291. BOM_投入数,BOM_产出数,BOM_产出单位,rtrim(BOM_计划用量) as 计划用量,rtrim(Sys_ID) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间';
  292. $bomList = \db('工单_bom资料')
  293. ->where('BOM_工单编号',$Gd_gdbh)
  294. ->field($field)
  295. ->select();
  296. if (!empty($bomList)){
  297. foreach ($bomList as $key=>$value){
  298. $bomList[$key]['消耗定量'] = rtrim($value['BOM_投入数']).rtrim($value['BOM_投料单位']).'/'.rtrim($value['BOM_产出数']).rtrim($value['BOM_产出单位']);
  299. unset($bomList[$key]['BOM_投料单位'],$bomList[$key]['BOM_投入数'],$bomList[$key]['BOM_产出数'],$bomList[$key]['BOM_产出单位']);
  300. $bomList[$key]['计划用量'] = rtrim((float)$value['计划用量']);
  301. }
  302. $data['BOM'] = $bomList;
  303. }else{
  304. $data['BOM'] = [];
  305. }
  306. //工单附件资料
  307. $jsRes = db('工单_相关附件')
  308. ->where('关联编号','like','%'.$Gd_gdbh.'%')
  309. ->select();
  310. if (!empty($jsRes)){
  311. foreach ($jsRes as $key=>&$value){
  312. if(mb_detect_encoding($value['附件内容'])!='ASCII'){
  313. $value['附件内容'] = '';
  314. }
  315. }
  316. $data['jsData'] = $jsRes;
  317. }else{
  318. $data['jsData'] = [];
  319. }
  320. $this->success('成功',$data);
  321. }
  322. /**
  323. * 编辑页面展示
  324. * @ApiMethod (GET)
  325. * @param string $workOrder 工单编号
  326. * @return void
  327. * @throws \think\db\exception\DataNotFoundException
  328. * @throws \think\db\exception\ModelNotFoundException
  329. * @throws \think\exception\DbException
  330. */
  331. public function DataCorrection()
  332. {
  333. if ($this->request->isGet() === false){
  334. $this->error('请求错误');
  335. }
  336. $workOrder = input('Gd_gdbh');
  337. if (empty($workOrder)){
  338. $this->error('参数错误');
  339. }
  340. $field = 'rtrim(Gd_lx) as 重点工单,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_生产分类) as 生产类型,rtrim(Gd_khdh) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
  341. rtrim(Gd_cpdh) as 印件代号,rtrim(Gd_cpmc) as 印件名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称,rtrim(接单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
  342. rtrim(投料率) as 投料率,rtrim(实际投料) as 万小张,rtrim(计量单位) as 单位,rtrim(投料大箱) as 投料大箱,rtrim(排产时库存) as 库存大箱,rtrim(警语版面) as 警语版面,
  343. rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注,rtrim(Uniqid) as Uniqid';
  344. $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
  345. if (empty($list)){
  346. $this->error('未找到该工单信息');
  347. }
  348. $printData = \db('工单_印件资料')
  349. ->where('Yj_Gdbh',$workOrder)
  350. ->field('rtrim(yj_yjmc) as 印件名称,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_平张投料) as 平张投料,rtrim(Uniqid) as id')
  351. ->cache(true,84600)
  352. ->find();
  353. if (empty($printData)){
  354. $list['印件名称'] = '';
  355. $list['印件代号'] = '';
  356. $list['平张投料'] = '';
  357. $list['印件ID'] = '';
  358. }else{
  359. $list['印件名称'] = $printData['印件名称'];
  360. $list['印件代号'] = $printData['印件代号'];
  361. $list['平张投料'] = $printData['平张投料'];
  362. $list['印件ID'] = $printData['id'];
  363. }
  364. $this->success('成功',$list);
  365. }
  366. /**
  367. * 工单资料修改
  368. * @ApiMethod (POST)
  369. * @param void
  370. * @return void
  371. * @throws \think\Exception
  372. * @throws \think\exception\PDOException
  373. */
  374. public function WorkOrderEdit()
  375. {
  376. if (Request::instance()->isPost() === false){
  377. $this->error('请求错误');
  378. }
  379. $param = Request::instance()->post();
  380. if (empty($param) || isset($param['Uniqid']) === false){
  381. $this->error('参数错误');
  382. }
  383. $row = [
  384. 'Gd_lx' => isset($param['lx'])?$param['lx']:'',
  385. '开单日期' => isset($param['kdrq'])?$param['kdrq']:'',
  386. 'Gd_gdbh' => isset($param['gdbh'])?$param['gdbh']:'',
  387. 'Gd_生产分类' => isset($param['scfl'])?$param['scfl']:'',
  388. 'Gd_客户代号' => isset($param['khdh'])?$param['khdh']:'',
  389. 'Gd_客户名称' => isset($param['khmc'])?$param['khmc']:'',
  390. '成品代号' => isset($param['cpdh'])?$param['cpdh']:'',
  391. '成品名称' => isset($param['cpmc'])?$param['cpmc']:'',
  392. '订单数量' => isset($param['ddsl'])?$param['ddsl']:'',
  393. '交货日期' => isset($param['jhrq'])?$param['jhrq']:'',
  394. '投料率' => isset($param['tll'])?$param['tll']:'',
  395. '计划投料' => isset($param['jhtl'])?$param['jhtl']:'',
  396. '实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
  397. '计量单位' => isset($param['jldw'])?$param['jldw']:'',
  398. '投料大箱' => isset($param['tldx'])?$param['tldx']:'',
  399. '销售订单号' => isset($param['xsddh'])?$param['xsddh']:'',
  400. '警语版面' => isset($param['jymb'])?$param['jymb']:'',
  401. '产品版本号' => isset($param['bbh'])?$param['bbh']:'',
  402. '客户ERP编码' => isset($param['erp'])?$param['erp']:'',
  403. '码源数量' => isset($param['ymsl'])?$param['ymsl']:'',
  404. '进程备注' => isset($param['jcbz'])?$param['jcbz']:'',
  405. 'Gd_desc' => isset($param['desc'])?$param['desc']:'',
  406. '排产时库存' => isset($param['kc'])?$param['kc']:'',
  407. '平均合格率' => isset($param['avg'])?$param['avg']:'',
  408. ];
  409. $sql = \db('工单_基本资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($row);
  410. $res = Db::query($sql);
  411. $printSql = \db('工单_印件资料')
  412. ->where('Uniqid',$param['printID'])
  413. ->fetchSql(true)
  414. ->update(['yj_yjmc'=>$param['yjmc'],'yj_Yjdh'=>$param['yjdh'],'yj_平张投料'=>$param['jhtl']]);
  415. $printRes = Db::query($printSql);
  416. if ($res !== false && $printRes !== false){
  417. $this->success('成功');
  418. }else{
  419. $this->error('失败');
  420. }
  421. }
  422. /**
  423. * U8投料试算
  424. * @ApiMethod (GET)
  425. * @param string $processCode 产品编号
  426. * @return void
  427. * @throws \think\db\exception\DataNotFoundException
  428. * @throws \think\db\exception\ModelNotFoundException
  429. * @throws \think\exception\DbException
  430. */
  431. public function U8Trial()
  432. {
  433. if ($this->request->isGet() === false)
  434. {
  435. $this->error('请求错误');
  436. }
  437. $productCode = input('productCode');
  438. if (empty($productCode)){
  439. $this->error('参数错误');
  440. }
  441. $field = 'rtrim(Gy0_cpdh) as 产品代号,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  442. rtrim(Gy0_Ms) as 墨色数,rtrim(Gy0_shdh) as 损耗代号,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as 加工联数';
  443. $list = \db('产品_工艺资料')->where('Gy0_cpdh',$productCode)->field($field)->select();
  444. if (empty($list)){
  445. $this->success('未找到该产品工序');
  446. }
  447. foreach ($list as $key=>$value){
  448. $data = \db('dic_lzsh')->where('sys_bh',$value['损耗代号'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->cache(true)->find();
  449. $list[$key]['调机损耗'] = isset($data['rate0'])?$data['rate0']:'';
  450. $list[$key]['运行损耗率'] = isset($data['rate1'])?$data['rate1']:'';
  451. if ($value['add_gxmc'] !== ''){
  452. $list[$key]['工序名称'] = $value['gxmc'].'【'.$value['add_gxmc'].'】';
  453. }else{
  454. $list[$key]['工序名称'] = $value['gxmc'];
  455. }
  456. unset($list[$key]['gxmc'],$list[$key]['add_gxmc']);
  457. }
  458. $this->success('成功',$list);
  459. }
  460. /**
  461. * 引用产品资料->获取产品资料
  462. * @ApiMethod (GET)
  463. * @param string $workOrder 工单编号
  464. * @return void
  465. * @throws \think\db\exception\DataNotFoundException
  466. * @throws \think\db\exception\ModelNotFoundException
  467. * @throws \think\exception\DbException
  468. */
  469. public function ProductInformation()
  470. {
  471. if ($this->request->isGet() === false)
  472. {
  473. $this->error('请求错误');
  474. }
  475. $workOrder = input('workOrder');
  476. if (empty($workOrder)){
  477. $this->error('参数错误');
  478. }
  479. $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_客户名称) as 客户名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称';
  480. $Detail = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
  481. if (empty($Detail)){
  482. $this->success('未找到工单信息');
  483. }
  484. $Detail['客户代号'] = substr($Detail['产品代号'],0,4);
  485. $this->success('成功',$Detail);
  486. }
  487. /**
  488. * 引用产品资料->复制产品工艺资料
  489. * @ApiMethod (POST)
  490. * @param string $oldWorkOrder 被复制工单编号
  491. * @param string $newWorkOrder 复制工单编号
  492. * @return void
  493. * @throws \think\Exception
  494. * @throws \think\db\exception\DataNotFoundException
  495. * @throws \think\db\exception\ModelNotFoundException
  496. * @throws \think\exception\DbException
  497. * @throws \think\exception\PDOException
  498. */
  499. public function ProductInformationEdit()
  500. {
  501. if (Request::instance()->isPost() === false)
  502. {
  503. $this->error('请求错误');
  504. }
  505. $oldWorkOrder = input('oldWorkOrder');
  506. $newWorkOrder = input('newWorkOrder');
  507. if (empty($oldWorkOrder) || empty($newWorkOrder))
  508. {
  509. $this->error('参数错误');
  510. }
  511. $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
  512. if ($lastId<10000000){
  513. $lastId = 10000000;
  514. }else{
  515. $lastId = $lastId + 1;
  516. }
  517. //获取原工单工艺资料
  518. $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->select();
  519. $ProsessUniqId = \db('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
  520. foreach ($oldProcessData as $k=>$v){
  521. $oldProcessData[$k]['Gy0_gdbh'] = $oldWorkOrder;
  522. $oldProcessData[$k]['Sys_id'] = '';
  523. $oldProcessData[$k]['Gy0_sj1'] = '1900-01-01 00:00:00';
  524. $oldProcessData[$k]['Gy0_sj2'] = '1900-01-01 00:00:00';
  525. $oldProcessData[$k]['UniqId'] = $lastId + $k;
  526. $oldProcessData[$k]['PD_WG'] = '1900-01-01 00:00:00';
  527. }
  528. if (\db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->find()){
  529. \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->delete();
  530. }
  531. //获取原工单印件资料
  532. $lastUniqId = \db('工单_印件资料')->order('UniqId desc')->value('UniqId');
  533. if ($lastUniqId<1000000){
  534. $lastUniqId = 1000000;
  535. }else{
  536. $lastUniqId = $lastUniqId + 1;
  537. }
  538. $oldPrintData = \db('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->select();
  539. $PrintUniqId = \db('工单_印件资料')->field('Uniqid')->order('Uniqid desc')->find();
  540. foreach ($oldPrintData as $k=>$v){
  541. $oldPrintData[$k]['Yj_Gdbh'] = $oldWorkOrder;
  542. $oldPrintData[$k]['Sys_id'] = '';
  543. $oldPrintData[$k]['Uniqid'] = $lastUniqId +$k +1;
  544. }
  545. if (\db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->find()){
  546. \db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->delete();
  547. }
  548. //复制印件、工艺资料
  549. $ProcessSQL = \db('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
  550. $ProcessRes = Db::query($ProcessSQL);
  551. $PrintSQL = \db('工单_印件资料')->fetchSql(true)->insertAll($oldPrintData);
  552. $PrintRes = Db::query($PrintSQL);
  553. if ($ProcessRes !== false && $PrintRes !== false){
  554. $this->success('成功');
  555. }else{
  556. $this->error('失败');
  557. }
  558. }
  559. /**
  560. * 工艺流程调成->获取当前工单工艺资料
  561. * @ApiMethod (GET)
  562. * @param string $workorder 当前工单编号
  563. * @return void
  564. * @throws \think\db\exception\DataNotFoundException
  565. * @throws \think\db\exception\ModelNotFoundException
  566. * @throws \think\exception\DbException
  567. */
  568. public function ProcessFlow()
  569. {
  570. if ($this->request->isGet() === false){
  571. $this->error('请求错误');
  572. }
  573. $workOrder = input('workOrder');
  574. if (empty($workOrder)){
  575. $this->error('参数错误');
  576. }
  577. $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(成品代号) as 成品编号,rtrim(成品名称) as 成品名称')->find();
  578. if (empty($list)){
  579. $this->success('未找到工单信息');
  580. }
  581. $filed = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  582. rtrim(工价系数) as 工价系数,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ks) as ks,rtrim(Gy0_ls) as ls,rtrim(工序备注) as 备注,rtrim(Gy0_SITE) as 车间,
  583. rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_sbmc) as 设备名称,rtrim(Sys_id) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间,rtrim(UniqId) as UniqId';
  584. $process = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->cache(true,84600)->field($filed)->select();
  585. if (empty($process)){
  586. $this->error('未找到该工单工艺资料');
  587. }
  588. foreach ($process as $key=>$value){
  589. if (isset($value['add_gxmc'])){
  590. $process[$key]['工序名称'] = $value['gxmc'] . '【'.$value['add_gxmc'].'】';
  591. }else{
  592. $process[$key]['工序名称'] = $value['gxmc'];
  593. }
  594. $process[$key]['工价系数'] = (float)$value['工价系数'];
  595. $process[$key]['损耗系数'] = (float)$value['损耗系数'];
  596. $process[$key]['开数*联数'] = $value['ks'].'*'.$value['ls'];
  597. }
  598. $list['process'] = $process;
  599. $this->success('成功',$list);
  600. }
  601. /**
  602. * 参照工单列表获取
  603. * @ApiMethod (GET)
  604. * @param string $workOrder 工单编号
  605. * @param string $productCode 产品代号
  606. * @return void
  607. */
  608. public function ReferenceWorkOrder()
  609. {
  610. if ($this->request->isGet() === false){
  611. $this->error('请求错误');
  612. }
  613. $productCode = input('productCode');
  614. $workOrder = input('workOrder');
  615. if (empty($productCode) || empty($workOrder)){
  616. $this->error('参数错误');
  617. }
  618. $list = \db('工单_基本资料')->where('成品代号',$productCode)->distinct(true)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
  619. if (empty($list)){
  620. $this->success('未获取该产品其他工单信息');
  621. }
  622. $this->success('成功',$list);
  623. }
  624. /**
  625. * 工艺资料复制
  626. * @ApiMethod (POST)
  627. * @param string $oldWorkOrder 被复制工单编号
  628. * @param string $newWorkOrder 复制工单编号
  629. * @return void
  630. * @throws \think\Exception
  631. * @throws \think\db\exception\DataNotFoundException
  632. * @throws \think\db\exception\ModelNotFoundException
  633. * @throws \think\exception\DbException
  634. * @throws \think\exception\PDOException
  635. *
  636. */
  637. public function ProcessCopy()
  638. {
  639. if (Request::instance()->isPost() === false){
  640. $this->error('请求错误');
  641. }
  642. $param = Request::instance()->post();
  643. if (empty($param)){
  644. $this->error('参数错误');
  645. }
  646. $UniqId = [];
  647. $lastId = \db('工单_工艺资料')->field('rtrim(UniqId) as id')->order('UniqId desc')->find();
  648. if ($lastId['id']>10000000){
  649. $lastUniqId = $lastId['id'];
  650. }else{
  651. $lastUniqId = 10000000;
  652. }
  653. foreach ($param as $key=>$value){
  654. $UniqId[$key] = $value['UniqId'];
  655. }
  656. $processList = \db('工单_工艺资料')->where('UniqId','in',$UniqId)->select();
  657. if (empty($processList)){
  658. $this->success('未找到工艺资料');
  659. }
  660. $data = [];
  661. foreach ($param as $key=>$value){
  662. foreach ($processList as $k=>$v){
  663. if ($value['UniqId'] = $v['UniqId']){
  664. $data[$key] = $v;
  665. $data[$key]['Gy0_gxh'] = $value['gxh'];
  666. $data[$key]['Gy0_gdbh'] = $value['workOrder'];
  667. $data[$key]['UniqId'] = $lastUniqId + $key + 1;
  668. }
  669. }
  670. }
  671. $res = \db('工单_工艺资料')->where(['Gy0_gdbh'=>$param[0]['workOrder']])->delete();
  672. if ($res !== false){
  673. $result = \db('工单_工艺资料')->insertAll($data);
  674. if ($result !== false){
  675. $this->success('成功');
  676. }else{
  677. $this->error('失败');
  678. }
  679. }else{
  680. $this->error('失败');
  681. }
  682. }
  683. /**
  684. * U8工单列表
  685. * @ApiMethod (GET)
  686. * @param void
  687. * @return void
  688. * @throws \think\db\exception\DataNotFoundException
  689. * @throws \think\db\exception\ModelNotFoundException
  690. * @throws \think\exception\DbException
  691. */
  692. public function U8workOrder()
  693. {
  694. if ($this->request->isGet() === false){
  695. $this->error('请求错误');
  696. }
  697. $param = $this->request->param();
  698. if (empty($param)){
  699. $this->error('参数错误');
  700. }
  701. $filed = 'rtrim(Gd_gdbh) as 工单编号,rtrim(行号) as 行号,rtrim(Gd_客户代号) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
  702. rtrim(成品代号) as 成品代号,rtrim(成品名称) as 成品名称,rtrim(Mod_rq) as 获取日期,rtrim(Uniqid) as 序号';
  703. $list = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field($filed)->select();
  704. if (empty($list)){
  705. $this->success('未找到工单');
  706. }
  707. $this->success('成功',$list);
  708. }
  709. /**
  710. * U8工单资料删除
  711. * @param string $workOrder 工单编号
  712. * @return void
  713. * @throws \think\Exception
  714. * @throws \think\exception\PDOException
  715. */
  716. public function U8DataCorrection()
  717. {
  718. if($this->request->isGet() === false){
  719. $this->error('请求错误');
  720. }
  721. $workOrder = input('Uniqid');
  722. if (empty($workOrder)){
  723. $this->error('参数错误');
  724. }
  725. $data = [];
  726. if (strpos($workOrder,',')){
  727. $data = explode(',',$workOrder);
  728. }else{
  729. $data[0] = $workOrder;
  730. }
  731. $res = \db('工单_基本资料')->where('Uniqid','in',$data)->delete();
  732. if ($res !== false){
  733. $this->success('成功');
  734. }else{
  735. $this->error('失败');
  736. }
  737. }
  738. /**
  739. * 产品废检系数调整->质检工艺数据获取
  740. * @ApiMethod (GET)
  741. * @param string $workOrder 工单编号
  742. * @return void
  743. * @throws \think\db\exception\DataNotFoundException
  744. * @throws \think\db\exception\ModelNotFoundException
  745. * @throws \think\exception\DbException
  746. */
  747. public function TestCoefficient()
  748. {
  749. if ($this->request->isGet() === false){
  750. $this->error('请求错误');
  751. }
  752. $workOrder = input('workOrder');
  753. if (empty($workOrder)){
  754. $this->error('参数错误');
  755. }
  756. $where = [
  757. 'Gy0_gdbh' => $workOrder,
  758. 'Gy0_gxmc' => ['like','%检%']
  759. ];
  760. $filed = 'rtrim(Gy0_gdbh) as gdbh,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(人工检_正品板) as 人工正品板,
  761. rtrim(人工检_次品板) as 人工次品板,rtrim(人工检_废检) as 人工废检,rtrim(机检_正品板) as 机检正品板,rtrim(机检_次品板) as 机检次品板,
  762. rtrim(机检_废检) as 机检废检,rtrim(Gy0_sbbh) as 设备编号,rtrim(Uniqid) as Uniqid';
  763. $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
  764. if (empty($list)){
  765. $this->success('未找到该工单工艺');
  766. }
  767. $name = \db('工单_基本资料')
  768. ->where('Gd_gdbh',$workOrder)
  769. ->field('rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_khmc) as 客户名称,rtrim(Gd_cpmc) as 产品名称')
  770. ->find();
  771. if (empty($name)){
  772. $this->success('未找到该工单');
  773. }
  774. foreach ($list as $key=>$value){
  775. if ($value['yjno']<10){
  776. $value['yjno'] = '0'.$value['yjno'];
  777. }
  778. if ($value['gxh']<10){
  779. $value['gxh'] = '0'.$value['gxh'];
  780. }
  781. $list[$key]['印件工序及工艺'] = $value['gdbh'].'-'.$value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
  782. unset($list[$key]['gdbh'],$list[$key]['yjno'],$list[$key]['gxmc']);
  783. $list[$key]['产品编号'] = $name['产品代号'];
  784. $list[$key]['产品名称'] = $name['产品名称'];
  785. $list[$key]['客户名称'] = $name['客户名称'];
  786. }
  787. $this->success('成功',$list);
  788. }
  789. /**
  790. * 产品质检系数调整->系数修改
  791. * @ApiMethod (GET)
  792. * @param string $workorder 工单编号
  793. * @param string $processCode 工序号
  794. * @param float $code1 人工正品板
  795. * @param float $code2 人工次品板
  796. * @param float $code3 人工废检
  797. * @param float $code4 机检正品板
  798. * @param float $code5 机检次品板
  799. * @param float $code6 机检废检
  800. * @return void
  801. * @throws \think\Exception
  802. * @throws \think\exception\PDOException
  803. */
  804. public function TestCoefficientEdit()
  805. {
  806. if (Request::instance()->isPost() === false){
  807. $this->error('请求错误');
  808. }
  809. $workOrder = input('workOrder');
  810. $processCode = input('processCode');
  811. $row = [
  812. '人工检_正品板' => input('code1'),
  813. '人工检_次品板' => input('code2'),
  814. '人工检_废检' => input('code3'),
  815. '机检_正品板' => input('code4'),
  816. '机检_次品板' => input('code5'),
  817. '机检_废检' => input('code6'),
  818. ];
  819. if (empty($workOrder) || empty($processCode)){
  820. $this->error('参数错误');
  821. }
  822. $where = [
  823. 'Gy0_gdbh' => $workOrder,
  824. 'Gy0_gxh' => $processCode
  825. ];
  826. $sql = \db('工单_工艺资料')->where($where)->fetchSql(true)->update($row);
  827. $res = Db::query($sql);
  828. if ($res !== false){
  829. $this->success('成功');
  830. }else{
  831. $this->error('失败');
  832. }
  833. }
  834. /**
  835. * 修正工单核算参数->数据获取
  836. * @ApiMethod (GET)
  837. * @param string $workOrder 工单编号
  838. * @return void
  839. * @throws \think\db\exception\DataNotFoundException
  840. * @throws \think\db\exception\ModelNotFoundException
  841. * @throws \think\exception\DbException
  842. */
  843. public function AccountingParameter()
  844. {
  845. if ($this->request->isGet() === false){
  846. $this->error('请求错误');
  847. }
  848. $workOrder = input('workOrder');
  849. if (empty($workOrder)){
  850. $this->error('参数错误');
  851. }
  852. $field = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  853. rtrim(Gy0_sbbh) as 参照设备,rtrim(工价系数) as 难度系数,rtrim(Gy0_shdh) as 损耗代号,rtrim(Gy0_Rate0) as 基础损耗,rtrim(Gy0_Rate1) as 损耗率,
  854. rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Gy0_ms) as 计损色数,rtrim(损耗系数) as 损耗系数,rtrim(UniqId) as UniqId';
  855. $list = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->field($field)->select();
  856. if (empty($list)){
  857. $this->success('未找到该工单工艺资料');
  858. }
  859. foreach ($list as $key=>$value){
  860. if ($value['yjno']<10){
  861. $value['yjno'] = '0'.$value['yjno'];
  862. }
  863. if ($value['gxh']<10){
  864. $value['gxh'] = '0'.$value['gxh'];
  865. }
  866. $list[$key]['印件号及工序名称'] = $value['yjno'].'-'.$value['gxh'].$value['gxmc'].'('.$value['add_gxmc'].')';
  867. unset($list[$key]['yjno'],$list[$key]['gxmc'],$list[$key]['add_gxmc']);
  868. }
  869. $this->success('成功',$list);
  870. }
  871. /**
  872. * 修正工单核算参数->参数修改
  873. * @ApiMethod (POST)
  874. * @param void
  875. * @return void
  876. * @throws \think\Exception
  877. * @throws \think\db\exception\DataNotFoundException
  878. * @throws \think\db\exception\ModelNotFoundException
  879. * @throws \think\exception\DbException
  880. * @throws \think\exception\PDOException
  881. */
  882. public function AccountingParameterEdit()
  883. {
  884. if (Request::instance()->isPost() === false){
  885. $this->error('请求错误');
  886. }
  887. $param = Request::instance()->post();
  888. if (empty($param) || isset($param[0]['Uniqid']) === false){
  889. $this->error('参数错误');
  890. }
  891. $i = 0;
  892. foreach ($param as $key=>$value){
  893. if (!empty($value['loss'])){
  894. $data = \db('dic_lzsh')->where('sys_bh',$value['loss'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
  895. }
  896. $row = [
  897. '工价系数' => $value['difficulty']?:'',
  898. 'Gy0_shdh' => $value['loss']?:'',
  899. '印刷方式' => $value['printMode']?:'',
  900. '版距' => $value['plate']?:'',
  901. 'Gy0_ms' => $value['chromatic']?:'',
  902. '损耗系数' => $value['wastage']?:'',
  903. 'Gy0_Rate0' => $data['rate0'],
  904. 'Gy0_Rate1' => $data['rate1']
  905. ];
  906. $sql = \db('工单_工艺资料')->where('Uniqid',$value['Uniqid'])->fetchSql(true)->update($row);
  907. $res = Db::query($sql);
  908. if ($res !== false){
  909. $i++;
  910. }
  911. }
  912. if ($i !== 0){
  913. $this->success('成功');
  914. }else{
  915. $this->error('失败');
  916. }
  917. }
  918. /**
  919. * 印件资料修改
  920. * @ApiMethod (POST)
  921. * @param void
  922. * @return void
  923. * @throws \think\Exception
  924. * @throws \think\exception\PDOException
  925. */
  926. public function PrintedEdit()
  927. {
  928. if (Request::instance()->isPost() === false){
  929. $this->error('请求错误');
  930. }
  931. $param = Request::instance()->post();
  932. if (empty($param) || isset($param['Uniqid']) === false){
  933. $this->error('参数错误');
  934. }
  935. $data = [
  936. 'yj_Yjno' => isset($param['yjno'])?$param['yjno']:'',
  937. 'yj_Yjdh' => isset($param['yjdh'])?$param['yjdh']:'',
  938. 'yj_yjmc' => isset($param['yjmc'])?$param['yjmc']:'',
  939. 'yj_zzdh' => isset($param['zzdh'])?$param['zzdh']:'',
  940. 'yj_zzdh1' => isset($param['zzdh1'])?$param['zzdh1']:'',
  941. 'yj_zzdh2' => isset($param['zzdh2'])?$param['zzdh2']:'',
  942. 'yj_zzdh3' => isset($param['zzdh3'])?$param['zzdh3']:'',
  943. 'yj_zzdh4' => isset($param['zzdh4'])?$param['zzdh4']:'',
  944. 'yj_zzmc' => isset($param['zzmc'])?$param['zzmc']:'',
  945. 'yj_zzmc1' => isset($param['zzmc1'])?$param['zzmc1']:'',
  946. 'yj_zzmc2' => isset($param['zzmc2'])?$param['zzmc2']:'',
  947. 'yj_zzmc3' => isset($param['zzmc3'])?$param['zzmc3']:'',
  948. 'yj_zzmc4' => isset($param['zzmc4'])?$param['zzmc4']:'',
  949. 'yj_成品数量' => isset($param['cpsl'])?$param['cpsl']:'',
  950. 'yj_实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
  951. 'yj_平张投料' => isset($param['pztl'])?$param['pztl']:'',
  952. 'yj_tlgg' => isset($param['tlgg'])?$param['tlgg']:'',
  953. 'yj_klgg' => isset($param['klgg'])?$param['klgg']:'',
  954. 'Yj_核算规格' => isset($param['hsgg'])?$param['hsgg']:'',
  955. 'yj_ks' => isset($param['ks'])?$param['ks']:'',
  956. 'yj_ls' => isset($param['ls'])?$param['ls']:'',
  957. 'yj_desc' => isset($param['desc'])?$param['desc']:'',
  958. ];
  959. $sql = \db('工单_印件资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($data);
  960. $res = Db::query($sql);
  961. if ($res !== false){
  962. $this->success('成功');
  963. }else{
  964. $this->error('失败');
  965. }
  966. }
  967. /**
  968. * 工艺资料修改
  969. * @ApiMethod (POST)
  970. * @param void
  971. * @return void
  972. * @throws \think\Exception
  973. * @throws \think\db\exception\DataNotFoundException
  974. * @throws \think\db\exception\ModelNotFoundException
  975. * @throws \think\exception\DbException
  976. * @throws \think\exception\PDOException
  977. */
  978. public function ProcessDetailEdit()
  979. {
  980. if (Request::instance()->isPost() === false){
  981. $this->error('请求错误');
  982. }
  983. $param = Request::instance()->post();
  984. if (empty($param) || isset($param['UniqId']) === false){
  985. $this->error('参数错误');
  986. }
  987. if (empty($param['shdh'])){
  988. $rate['rate0'] = 0;
  989. $rate['rate1'] = 0;
  990. }else{
  991. $rate = \db('dic_lzsh')->where('sys_bh',$param['shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
  992. }
  993. $data = [
  994. '重点工序' => isset($param['zdgx'])?$param['zdgx']:'',
  995. '备选工序' => isset($param['bxgx'])?$param['bxgx']:'',
  996. 'Gy0_sbbh' => isset($param['sbbh'])?$param['sbbh']:'',
  997. 'Gy0_Rate0' => isset($rate['rate0'])?$rate['rate0']:0,
  998. 'Gy0_Rate1' => isset($rate['rate1'])?$rate['rate1']:0,
  999. 'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
  1000. '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
  1001. '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
  1002. 'Gy0_小时产能' => $param['xscn'],
  1003. 'Mod_rq' => date('Y-m-d H:i:s',time()),
  1004. ];
  1005. $sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
  1006. $res = Db::query($sql);
  1007. $status = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
  1008. if ($status['status'] !== '2-生产中'){
  1009. $statusSql = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
  1010. Db::query($statusSql);
  1011. }
  1012. if ($res !== false){
  1013. $this->success('成功');
  1014. }else{
  1015. $this->error('失败');
  1016. }
  1017. }
  1018. /**
  1019. * 工艺资料编辑->机台列表获取
  1020. * @return void
  1021. * @throws \think\db\exception\DataNotFoundException
  1022. * @throws \think\db\exception\ModelNotFoundException
  1023. * @throws \think\exception\DbException
  1024. */
  1025. public function MachineList()
  1026. {
  1027. if ($this->request->isGet() === false){
  1028. $this->error('请求错误');
  1029. }
  1030. $param = $this->request->param();
  1031. if (empty($param)){
  1032. $this->error('参数错误');
  1033. }
  1034. $list = \db('设备_基本资料')
  1035. ->where('存放地点',$param['address'])
  1036. ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')
  1037. ->select();
  1038. if (empty($list)){
  1039. $this->success('未找到该车间机台');
  1040. }
  1041. $data = [];
  1042. foreach ($list as $key=>$value){
  1043. $data[$key] = $value['设备编号'].'-->'.$value['设备名称'];
  1044. }
  1045. $this->success('成功',$data);
  1046. }
  1047. /**
  1048. * 打印作业通知单->工单印件和工序获取
  1049. * @ApiMethod (GET)
  1050. * @return void
  1051. * @throws \think\db\exception\DataNotFoundException
  1052. * @throws \think\db\exception\ModelNotFoundException
  1053. * @throws \think\exception\DbException
  1054. */
  1055. public function PrintCodeList()
  1056. {
  1057. if ($this->request->isGet() === false){
  1058. $this->error('请求错误');
  1059. }
  1060. $param = $this->request->param();
  1061. if (empty($param)){
  1062. $this->error('参数错误');
  1063. }
  1064. $list = \db('工单_印件资料')
  1065. ->field([
  1066. 'rtrim(yj_Yjno)' => '印件号',
  1067. 'rtrim(yj_yjmc)' => '印件名称'
  1068. ])
  1069. ->where('Yj_Gdbh',$param['workOrder'])
  1070. ->select();
  1071. $this->success('成功',$list);
  1072. }
  1073. /**
  1074. * 打印作业通知单->工艺编号获取
  1075. * @ApiMethod (GET)
  1076. * @return void
  1077. * @throws \think\db\exception\DataNotFoundException
  1078. * @throws \think\db\exception\ModelNotFoundException
  1079. * @throws \think\exception\DbException
  1080. */
  1081. public function ProcessCodeList()
  1082. {
  1083. if ($this->request->isGet() === false){
  1084. $this->error('请求错误');
  1085. }
  1086. $param = $this->request->param();
  1087. if (empty($param)){
  1088. $this->error('参数错误');
  1089. }
  1090. $list = \db('工单_工艺资料')
  1091. ->field('rtrim(Gy0_gxh) as 工序号')
  1092. ->where([
  1093. 'Gy0_gdbh' => $param['workOrder'],
  1094. 'Gy0_yjno' => $param['yjno']
  1095. ])
  1096. ->select();
  1097. $this->success('成功',$list);
  1098. }
  1099. /**
  1100. * 打印作业通知单
  1101. * @ApiMethod (POST)
  1102. * @param void
  1103. * @return void
  1104. * @throws \think\db\exception\DataNotFoundException
  1105. * @throws \think\db\exception\ModelNotFoundException
  1106. * @throws \think\exception\DbException
  1107. */
  1108. public function PrintJobOrder()
  1109. {
  1110. if ($this->request->isGet() === false) {
  1111. $this->error('请求错误');
  1112. }
  1113. $param = $this->request->param();
  1114. if (empty($param)){
  1115. $this->error('参数错误');
  1116. }
  1117. $data = $this->workOrderDetailGet($param['workOrder'],$param['yjno']);
  1118. if (empty($data)){
  1119. $this->success('未找到工单信息');
  1120. }
  1121. $materiel = $this->MaterielDetailGet($param['workOrder']);
  1122. if (empty($materiel)){
  1123. $this->success('未找到物料信息');
  1124. }
  1125. $printDetail = $this->PrintDetailGet($param['workOrder'],$param['yjno'],$param['gxh']);
  1126. if (empty($printDetail)){
  1127. $this->success('未找到工艺信息');
  1128. }
  1129. $number = 0;
  1130. foreach ($printDetail as $key=>$value){
  1131. $value['允损比例'] = (float)substr($value['允损比例'],0,-1);
  1132. $number = $number+$value['允损比例'];
  1133. }
  1134. $data['制单'] = $param['PrepareDocument'];
  1135. $data['审核'] = $param['examine'];
  1136. $data['目标合格率'] = 100-$number.'%';
  1137. $data['materiel'] = $materiel;
  1138. $data['printDetail'] = $printDetail;
  1139. $this->success('成功',$data);
  1140. }
  1141. /**
  1142. * 打印作业通知单->工单及印件资料获取
  1143. * @param $workOrder
  1144. * @return mixed
  1145. */
  1146. public function workOrderDetailGet($workOrder,$yjno)
  1147. {
  1148. $sql = "SELECT
  1149. RTRIM( a.Gd_lx) AS 工单类型,
  1150. RTRIM( a.Gd_gdbh ) AS 生产批次号,
  1151. RTRIM( a.销售订单号 ) AS 销售订单号,
  1152. RTRIM( a.Gd_客户代号 ) AS 客户代号,
  1153. RTRIM( a.Gd_客户名称 ) AS 客户名称,
  1154. RTRIM( a.成品代号 ) AS 产品代码,
  1155. RTRIM( a.成品名称 ) AS 产品名称,
  1156. RTRIM( a.产品版本号 ) AS 版本号,
  1157. RTRIM( a.警语版面 ) AS 警语版面,
  1158. RTRIM( a.码源数量 ) AS 码源数量,
  1159. RTRIM( a.客户ERP编码 ) AS 客户ERP编码,
  1160. RTRIM( a.接单日期 ) AS 开单日期,
  1161. RTRIM( a.交货日期 ) AS 交货日期,
  1162. RTRIM( a.Gd_desc ) AS 工单说明,
  1163. RTRIM( a.投料率 ) AS 投料率,
  1164. RTRIM( a.平均合格率 ) AS 平均合格率,
  1165. RTRIM( a.投料大箱 ) AS 订货数量,
  1166. RTRIM( a.排产时库存 ) AS 排产时库存,
  1167. RTRIM( b.yj_Yjno ) AS 印件,
  1168. RTRIM( b.yj_Yjdh ) AS 印件代号,
  1169. RTRIM( b.yj_yjmc ) AS 印件名称,
  1170. RTRIM( b.yj_平张投料 ) AS 平张投料量,
  1171. RTRIM( b.yj_zzmc ) AS 纸张名称,
  1172. RTRIM( b.yj_tlgg ) AS 投料规格,
  1173. RTRIM( b.yj_ks ) AS 开数,
  1174. RTRIM( b.yj_ls ) AS 联数,
  1175. RTRIM( b.yj_desc ) AS 印件备注
  1176. FROM
  1177. `工单_基本资料` AS a
  1178. JOIN `工单_印件资料` AS b ON b.Yj_Gdbh = a.Gd_gdbh
  1179. WHERE
  1180. a.Gd_gdbh = '{$workOrder}' AND a.行号 = 1 AND b.yj_Yjno = '{$yjno}'";
  1181. $list = Db::query($sql);
  1182. if (empty($list)){
  1183. $this->success('未找到订单数据');
  1184. }
  1185. $list[0]['开单日期'] = date('Y-m-d',strtotime($list[0]['开单日期']));
  1186. $list[0]['交货日期'] = date('Y-m-d',strtotime($list[0]['交货日期']));
  1187. $list[0]['订货数量'] = (int)$list[0]['订货数量'];
  1188. $list[0]['联数'] = (int)$list[0]['联数'];
  1189. $list[0]['印件代号及名称'] = $list[0]['印件代号'].' '.$list[0]['印件名称'];
  1190. $list[0]['投料数量'] = $list[0]['订货数量'];
  1191. unset($list[0]['印件代号'],$list[0]['印件名称']);
  1192. return($list[0]);
  1193. }
  1194. /**打印作业流程单->物料资料获取
  1195. * @param $workOrder
  1196. * @return bool|\PDOStatement|string|\think\Collection
  1197. * @throws \think\db\exception\DataNotFoundException
  1198. * @throws \think\db\exception\ModelNotFoundException
  1199. * @throws \think\exception\DbException
  1200. */
  1201. public function MaterielDetailGet($workOrder)
  1202. {
  1203. $where = [
  1204. 'BOM_工单编号' => $workOrder,
  1205. ];
  1206. $filed = 'rtrim(BOM_物料编码) as 物料编码,rtrim(BOM_物料名称) as 物料名称,rtrim(BOM_投料单位) as 投料单位,rtrim(BOM_计划用量) as 计划用量';
  1207. $list = \db('工单_bom资料')->where($where)->field($filed)->select();
  1208. if (empty($list)){
  1209. $this->success('未找到物料资料信息');
  1210. }
  1211. foreach ($list as $key=>$value){
  1212. $list[$key]['物料代码及名称'] = $value['物料编码'].' '.$value['物料名称'];
  1213. $list[$key]['计划用量'] = (float)$value['计划用量'];
  1214. unset($list[$key]['物料编码'],$list[$key]['物料名称']);
  1215. }
  1216. return $list;
  1217. }
  1218. /**
  1219. * 打印作业流程单->工艺资料获取
  1220. * @param $workOrder
  1221. * @return bool|\PDOStatement|string|\think\Collection
  1222. * @throws \think\db\exception\DataNotFoundException
  1223. * @throws \think\db\exception\ModelNotFoundException
  1224. * @throws \think\exception\DbException
  1225. */
  1226. public function PrintDetailGet($workOrder,$yjno,$gxh)
  1227. {
  1228. $where = [
  1229. 'Gy0_gdbh' => $workOrder,
  1230. 'Gy0_yjno' => $yjno,
  1231. 'Gy0_gxh' => ['<=',$gxh]
  1232. ];
  1233. $filed = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  1234. rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as ls,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_计划损耗) as 计划损耗,
  1235. rtrim(Gy0_辅助工时) as 装版工时,rtrim(Gy0_小时产能) as 小时定额,rtrim(Gy0_生产工时) as 生产工时,rtrim(工序备注) as 工序备注';
  1236. $list = \db('工单_工艺资料')
  1237. ->where($where)
  1238. ->field($filed)
  1239. ->select();
  1240. if (empty($list)){
  1241. $this->success('工单工艺为空');
  1242. }
  1243. foreach ($list as $key=>$value){
  1244. if ($value['yjno']<10){
  1245. $value['yjno'] = '0'.$value['yjno'];
  1246. }
  1247. if ($value['gxh']<10){
  1248. $value['gxh'] = '0'.$value['gxh'];
  1249. }
  1250. if ($value['add_gxmc'] !== null){
  1251. $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  1252. }else{
  1253. $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
  1254. }
  1255. $list[$key]['转序数'] = (int)($value['计划接货数']/$value['ls']);
  1256. $list[$key]['报废定额'] = (int)($value['计划损耗']/$value['ls']);
  1257. if ((int)$value['计划接货数'] === 0){
  1258. $list[$key]['允损比例'] = 0;
  1259. }else{
  1260. $list[$key]['允损比例'] = round(($value['计划损耗']/$value['计划接货数'])*100,2).'%';
  1261. }
  1262. unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['add_gxmc'],$list[$key]['计划接货数'],$list[$key]['计划损耗']);
  1263. }
  1264. return $list;
  1265. }
  1266. /**
  1267. * 获取小时产能
  1268. * @ApiMethod (GET)
  1269. * @param void
  1270. * @return void
  1271. * @throws \think\db\exception\DataNotFoundException
  1272. * @throws \think\db\exception\ModelNotFoundException
  1273. * @throws \think\exception\DbException
  1274. */
  1275. public function capacityList()
  1276. {
  1277. if ($this->request->isGet() === false){
  1278. $this->error('请求错误');
  1279. }
  1280. $param = $this->request->param();
  1281. if (empty($param)){
  1282. $this->error('参数错误');
  1283. }
  1284. $machine = explode(' ',$param['machine'])[0];
  1285. $number = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(排单小时定额) as 小时产能')->find();
  1286. if (empty($number)){
  1287. $this->error('未找到小时产能');
  1288. }
  1289. $this->success('成功',$number['小时产能']);
  1290. }
  1291. /**
  1292. * 新增工单->添加工单
  1293. * @ApiMethod (POST)
  1294. * @param
  1295. * @return void
  1296. * @throws \think\Exception
  1297. * @throws \think\db\exception\BindParamException
  1298. * @throws \think\db\exception\DataNotFoundException
  1299. * @throws \think\db\exception\ModelNotFoundException
  1300. * @throws \think\exception\DbException
  1301. * @throws \think\exception\PDOException
  1302. */
  1303. public function WorkOrderAdd()
  1304. {
  1305. if (Request::instance()->isPost() === false){
  1306. $this->error('请求错误');
  1307. }
  1308. $param = Request::instance()->post();
  1309. if (empty($param)){
  1310. $this->error('参数错误');
  1311. }
  1312. $num = \db('工单_基本资料')->where('Gd_gdbh',$param['gdbh'])->count();
  1313. $productDetail = \db('产品_基本资料')->where('产品编号',$param['cpdh'])->find();
  1314. if (empty($productDetail)){
  1315. $productDetail['客户料号'] = '';
  1316. }
  1317. $lastId = \db('工单_基本资料')->order('Uniqid desc')->value('Uniqid');
  1318. if ($lastId<1000000000){
  1319. $lastId = 1000000000;
  1320. }
  1321. $data = [
  1322. 'Gd_lx' =>$param['zdgd'],
  1323. 'Gd_生产分类' =>$param['sclx'],
  1324. '成本处理类别' =>'',
  1325. 'Gd_gdbh' =>$param['gdbh'],
  1326. '行号' =>$num+1 ,
  1327. 'Gd_客户代号' =>$param['khdh'],
  1328. 'Gd_客户名称' =>$param['khmc'],
  1329. 'Gd_khdh' =>$param['khdh'],
  1330. 'Gd_khmc' =>$param['khmc'],
  1331. '客户料号' =>rtrim($productDetail['客户料号']),
  1332. '客户ERP编码' =>$param['erp'],
  1333. 'Gd_cpdh' =>$param['cpdh'],
  1334. 'Gd_cpmc' =>$param['cpmc'],
  1335. '成品代号' =>$param['cpdh'],
  1336. '成品名称' =>$param['cpmc'],
  1337. '产品版本号' =>$param['bbh'],
  1338. '销售订单号' =>$param['xsddh'],
  1339. '警语版面' =>$param['jybm'],
  1340. '码源数量' =>$param['mysl'],
  1341. '排产时库存' =>$param['kcdx'],
  1342. '投料大箱' =>$param['tldx'],
  1343. '投料率' =>$param['tll'],
  1344. '平均合格率' =>$param['hgl'],
  1345. '进程备注' =>$param['jcbz'],
  1346. 'Gd_desc' =>$param['remark'],
  1347. '开单日期' =>date('Y-m-d H:i:s',time()),
  1348. '接单日期' =>$param['start'],
  1349. '交货日期' =>$param['end'],
  1350. '订单数量' =>$param['number'],
  1351. '计量单位' =>$param['tldw'],
  1352. '计划投料' =>$param['pztl'],
  1353. '实际投料' =>$param['wxz'],
  1354. '产品单价' =>0,
  1355. '入仓日期' =>'1900-01-01 00:00:00',
  1356. '工单入仓数量' =>0,
  1357. '工单制程废品' => 0,
  1358. '工单质检废品' => 0,
  1359. '工单无形损' => 0,
  1360. '工单计划损耗' => 0,
  1361. '工单完工日期' => $param['end'],
  1362. '投料确认' => '',
  1363. 'gd_statu' => '3-计划中',
  1364. '直接人工' => 0,
  1365. '分摊人工' => 0,
  1366. '直接材料' => 0,
  1367. '考核直接材料' => 0,
  1368. '分摊材料' => 0,
  1369. '考核分摊材料' => 0,
  1370. '直接折旧' => 0,
  1371. '水电气费' => 0,
  1372. '分摊空调' => 0,
  1373. '分摊锅炉' => 0,
  1374. '分摊废气处理' => 0,
  1375. '分摊空压机' => 0,
  1376. '分摊鼓风机' => 0,
  1377. '分摊其他' => 0,
  1378. '待摊人工' => 0,
  1379. '待摊折旧' => 0,
  1380. '待摊场地租金' => 0,
  1381. '待摊其他费用' => 0,
  1382. '加工费' => 0,
  1383. '加工费单价' => 0,
  1384. '成本考核_胶印' => 0,
  1385. '成本考核_凹印' => 0,
  1386. '成本考核_丝印' => 0,
  1387. '成本考核_模切' => 0,
  1388. '成本考核_检验' => 0,
  1389. '印版费' => 0,
  1390. 'V23制造成本' => 0,
  1391. 'Prt_rq' => date('Y-m-d H:i:s',time()),
  1392. 'Sys_id' => '',
  1393. 'Sys_rq' => date('Y-m-d H:i:s',time()),
  1394. 'Mod_rq' => date('Y-m-d H:i:s',time()),
  1395. 'U8UID' => '',
  1396. 'Uniqid' => $lastId+1,
  1397. '工序加工费' => 0,
  1398. ];
  1399. $sql= \db('工单_基本资料')->fetchSql(true)->insert($data);
  1400. $res = \db()->query($sql);
  1401. if ($res !== false){
  1402. $this->success('成功');
  1403. }else{
  1404. $this->error('失败');
  1405. }
  1406. }
  1407. /**
  1408. * 新增工单->客户代号列表获取
  1409. * @return void
  1410. * @throws \think\db\exception\BindParamException
  1411. * @throws \think\exception\PDOException
  1412. */
  1413. public function ClientList()
  1414. {
  1415. if ($this->request->isGet() === false){
  1416. $this->error('请求错误');
  1417. }
  1418. $param = $this->request->param();
  1419. if (isset($param['search'])){
  1420. $where = $param['search'].'%';
  1421. $sql = "SELECT DISTINCT
  1422. (客户编号),rtrim(客户名称 ) as 客户名称
  1423. FROM
  1424. `产品_基本资料`
  1425. WHERE
  1426. 客户编号 LIKE "."'".$where."'"."
  1427. OR
  1428. 客户名称 LIKE "."'".$where."'"."
  1429. GROUP BY
  1430. 客户编号
  1431. order by
  1432. 客户编号";
  1433. }else{
  1434. $sql = "SELECT DISTINCT
  1435. (客户编号),rtrim(客户名称 ) as 客户名称
  1436. FROM
  1437. `产品_基本资料`
  1438. GROUP BY
  1439. 客户编号
  1440. order by
  1441. 客户编号";
  1442. }
  1443. $list = \db()->query($sql);
  1444. if (empty($list)){
  1445. $this->success('未找到客户列表');
  1446. }
  1447. foreach ($list as $key=>$value){
  1448. if (empty($value['客户编号'])){
  1449. unset($list[$key]);
  1450. }else{
  1451. $list[$key]['客户编号'] = rtrim($value['客户编号']);
  1452. $list[$key]['name'] = rtrim($value['客户编号']).'【'.$value['客户名称'].'】';
  1453. if ($value['客户编号'] == '1098'){
  1454. $list[$key]['客户名称'] = '打样专用';
  1455. }
  1456. }
  1457. }
  1458. $list = array_values($list);
  1459. $this->success('成功',$list);
  1460. }
  1461. /**
  1462. * 新增工单->产品代号获取
  1463. * @ApiMethod (GET)
  1464. * @param void
  1465. * @return void
  1466. * @throws \think\db\exception\DataNotFoundException
  1467. * @throws \think\db\exception\ModelNotFoundException
  1468. * @throws \think\exception\DbException
  1469. */
  1470. public function ProductCodeList()
  1471. {
  1472. if ($this->request->isGet() === false){
  1473. $this->error('请求错误');
  1474. }
  1475. $param = $this->request->param();
  1476. if (isset($param['cilent']) === false){
  1477. $this->error('参数错误');
  1478. }
  1479. $where = ['产品编号'=>['like',$param['cilent'].'%']];
  1480. $list = \db('产品_基本资料')
  1481. ->where($where)
  1482. ->field('rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称')
  1483. ->select();
  1484. if (empty($list)){
  1485. $this->success('未获取到产品数据');
  1486. }
  1487. foreach ($list as $key=>$value){
  1488. $list[$key]['name'] = $value['产品编号'].'【'.$value['产品名称'].'】';
  1489. }
  1490. $this->success('成功',$list);
  1491. }
  1492. /**
  1493. * 新增印件资料->印件资料添加
  1494. * @return void
  1495. * @throws \think\db\exception\BindParamException
  1496. * @throws \think\exception\PDOException
  1497. */
  1498. public function PrintDetailAdd()
  1499. {
  1500. if (Request::instance()->isPost() === false){
  1501. $this->error('请求错误');
  1502. }
  1503. $param = Request::instance()->post();
  1504. if (empty($param)){
  1505. $this->error('参数错误');
  1506. }
  1507. $lastId = \db('工单_印件资料')->order('Uniqid desc')->value('Uniqid');
  1508. if ($lastId<1000000){
  1509. $lastId = 1000000;
  1510. }else{
  1511. $lastId = $lastId + 1;
  1512. }
  1513. $param['Uniqid'] = $lastId;
  1514. $param['Sys_rq'] = date('Y-m-d H:i:s',time());
  1515. $param['Mod_rq'] = date('Y-m-d H:i:s',time());
  1516. $sql = \db('工单_印件资料')->fetchSql(true)->insert($param);
  1517. $res = \db()->query($sql);
  1518. if ($res !== false){
  1519. $this->success('成功');
  1520. }else{
  1521. $this->error('失败');
  1522. }
  1523. }
  1524. /**
  1525. * 新增工艺资料->工艺资料添加
  1526. * @return void
  1527. * @throws \think\db\exception\BindParamException
  1528. * @throws \think\exception\PDOException
  1529. */
  1530. public function ProcessDetailAdd()
  1531. {
  1532. if (Request::instance()->isPost() === false){
  1533. $this->error('请求错误');
  1534. }
  1535. $param = Request::instance()->post();
  1536. if (empty($param)){
  1537. $this->error('参数错误');
  1538. }
  1539. $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
  1540. if ($lastId<100000000){
  1541. $lastId = 100000000;
  1542. }else{
  1543. $lastId = $lastId + 1;
  1544. }
  1545. if (empty($param['Gy0_shdh'])){
  1546. $param['Gy0_Rate0'] = 0;
  1547. $param['Gy0_Rate1'] = 0;
  1548. }else{
  1549. $detail = \db('dic_lzsh')->field('sys_rate0,sys_rate1')->where('sys_bh',$param['Gy0_shdh'])->find();
  1550. $param['Gy0_Rate0'] = $detail['sys_rate0'];
  1551. $param['Gy0_Rate1'] = $detail['sys_rate1'];
  1552. }
  1553. $param['Sys_rq'] = date('Y-m-d H:i:s',time());
  1554. $param['Mod_rq'] = '1900-01-01 00:00:00';
  1555. $param['Gy0_sj1'] = '1900-01-01 00:00:00';
  1556. $param['Gy0_sj2'] = '1900-01-01 00:00:00';
  1557. $param['PD_WG'] = '1900-01-01 00:00:00';
  1558. $param['UniqId'] = $lastId;
  1559. $sql = \db('工单_工艺资料')
  1560. ->fetchSql(true)
  1561. ->insert($param);
  1562. $res = \db()->query($sql);
  1563. if ($res !== false){
  1564. $this->success('成功');
  1565. }else{
  1566. $this->error('失败');
  1567. }
  1568. }
  1569. /**
  1570. * 新增工艺资料->印件编号获取
  1571. * @return void
  1572. * @throws \think\db\exception\DataNotFoundException
  1573. * @throws \think\db\exception\ModelNotFoundException
  1574. * @throws \think\exception\DbException
  1575. */
  1576. public function PrintDetailList()
  1577. {
  1578. if ($this->request->isGet() === false){
  1579. $this->error('请求错误');
  1580. }
  1581. $param = $this->request->param();
  1582. if (empty($param)){
  1583. $this->error('参数错误');
  1584. }
  1585. $printList = \db('工单_印件资料')
  1586. ->where('Yj_Gdbh',$param['workOrder'])
  1587. ->order('yj_Yjno')
  1588. ->select();
  1589. if (empty($printList)){
  1590. $this->success('未找到该工单印件资料');
  1591. }
  1592. $list = [];
  1593. foreach ($printList as $key=>$value){
  1594. $list[$key]['name'] = rtrim($value['yj_Yjno']).'-->'.rtrim($value['yj_yjmc']);
  1595. $list[$key]['no'] = rtrim($value['yj_Yjno']);
  1596. }
  1597. $this->success('成功',$list);
  1598. }
  1599. /**
  1600. * 工单资料管理->印件资料删除
  1601. * @return void
  1602. * @throws \think\Exception
  1603. * @throws \think\exception\PDOException
  1604. */
  1605. public function PrintDetailDel()
  1606. {
  1607. if ($this->request->isGet() === false){
  1608. $this->error('请求错误');
  1609. }
  1610. $param = $this->request->param();
  1611. if (isset($param['UniqId']) === false){
  1612. $this->error('参数错误');
  1613. }
  1614. $printId = explode(',',$param['UniqId']);
  1615. $i = 0;
  1616. foreach ($printId as $value){
  1617. $res = \db('工单_印件资料')
  1618. ->where('Uniqid',$value)
  1619. ->delete();
  1620. if ($res === false){
  1621. $i++;
  1622. }
  1623. }
  1624. if ($i === 0){
  1625. $this->success('删除成功');
  1626. }else{
  1627. $this->error('删除失败');
  1628. }
  1629. }
  1630. /**
  1631. * 工单资料管理->工艺资料删除
  1632. * @return void
  1633. * @throws \think\Exception
  1634. * @throws \think\exception\PDOException
  1635. */
  1636. public function ProcessDetailDel()
  1637. {
  1638. if ($this->request->isGet() === false){
  1639. $this->error('请求错误');
  1640. }
  1641. $param = $this->request->param();
  1642. if (isset($param['UniqId']) === false){
  1643. $this->error('参数错误');
  1644. }
  1645. $printId = explode(',',$param['UniqId']);
  1646. $i = 0;
  1647. foreach ($printId as $value){
  1648. $res = \db('工单_工艺资料')
  1649. ->where('UniqId',$value)
  1650. ->delete();
  1651. if ($res === false){
  1652. $i++;
  1653. }
  1654. }
  1655. if ($i === 0){
  1656. $this->success('删除成功');
  1657. }else{
  1658. $this->error('删除失败');
  1659. }
  1660. }
  1661. /**
  1662. * 工艺资料添加->工序损耗代码
  1663. * @return void
  1664. * @throws \think\db\exception\DataNotFoundException
  1665. * @throws \think\db\exception\ModelNotFoundException
  1666. * @throws \think\exception\DbException
  1667. */
  1668. public function WastageList()
  1669. {
  1670. if ($this->request->isGet() === false){
  1671. $this->error('请求错误');
  1672. }
  1673. $param = $this->request->param();
  1674. if (isset($param['search']) === false){
  1675. $this->error('参数错误');
  1676. }
  1677. $order = \db('dic_lzsh')
  1678. ->where('sys_mc','like',substr($param['search'],0,6).'%')
  1679. ->value('rtrim(sys_bh) as 编号');
  1680. $list = \db('dic_lzsh')
  1681. ->where('sys_bh','like',$order.'%')
  1682. ->where('sys_bh','<>',$order)
  1683. ->field('rtrim(sys_bh) as 编号,rtrim(sys_mc) as 名称,rtrim(UniqId) as UniqId')
  1684. ->select();
  1685. $this->success('成功',$list);
  1686. }
  1687. /**
  1688. * 获取产品附件列表
  1689. */
  1690. public function getAnnexTable(){
  1691. if(!$this->request->isGet()){
  1692. $this->error('请求方式错误');
  1693. }
  1694. $req = $this->request->param();
  1695. if (isset($req['cpdh']) && !empty($req['cpdh'])){
  1696. $where['关联产品'] = ['LIKE','%'.$req['cpdh'].'%'];
  1697. }else{
  1698. $this->error('参数错误');
  1699. }
  1700. $rows = db('产品_技术附件')
  1701. ->where($where)
  1702. ->select();
  1703. foreach ($rows as $key=>&$value){
  1704. if(mb_detect_encoding($value['附件内容'])!='ASCII'){
  1705. $value['附件内容'] = '';
  1706. }
  1707. }
  1708. $this->success('成功',$rows);
  1709. }
  1710. /**
  1711. * 产品附件新增
  1712. */
  1713. public function annexAdd(){
  1714. if(!$this->request->isPost()){
  1715. $this->error('请求方式错误');
  1716. }
  1717. $req = $this->request->param();
  1718. $arr = [
  1719. 'sys_id',
  1720. '序号',
  1721. '附件备注',
  1722. '附件内容',
  1723. '附件类型',
  1724. '适用工序',
  1725. '关联产品'
  1726. ];
  1727. $data = [];
  1728. foreach ($arr as $key => $value){
  1729. if (!isset($req[$value])){
  1730. $this->error('参数错误',$value,$key+1);
  1731. }
  1732. $data[$value] = $req[$value];
  1733. }
  1734. $data['sys_rq'] = date('Y-m-d H:i:s');
  1735. //查询UniqId
  1736. $UniqId = db('产品_技术附件')->max('UniqId');
  1737. $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
  1738. //开启事务
  1739. db()->startTrans();
  1740. try{
  1741. $sql = db('产品_技术附件')->fetchSql(true)->insert($data);
  1742. $bool = db()->query($sql);
  1743. // 提交事务
  1744. db()->commit();
  1745. } catch (\Exception $e) {
  1746. // 回滚事务
  1747. db()->rollback();
  1748. $this->error($e->getMessage());
  1749. }
  1750. if($bool===false) $this->error('失败');
  1751. $this->success('成功');
  1752. }
  1753. /**
  1754. * 产品附件修改
  1755. * @ApiMethod (GET)
  1756. * @param string 'UniqId'
  1757. */
  1758. public function annexDel()
  1759. {
  1760. if(!$this->request->isGet()){
  1761. $this->error('请求方式错误');
  1762. }
  1763. $req = $this->request->param();
  1764. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  1765. $this->error('参数错误','UniqId',100);
  1766. }
  1767. //开启事务
  1768. db()->startTrans();
  1769. try{
  1770. $bool = db('产品_技术附件')->where('UniqId',$req['UniqId'])->delete();
  1771. // 提交事务
  1772. db()->commit();
  1773. } catch (\Exception $e) {
  1774. // 回滚事务
  1775. db()->rollback();
  1776. $this->error($e->getMessage());
  1777. }
  1778. if($bool===false) $this->error('失败');
  1779. $this->success('成功');
  1780. }
  1781. /**
  1782. * 获取产品附件列表
  1783. */
  1784. public function getGdAnnexTable(){
  1785. if(!$this->request->isGet()){
  1786. $this->error('请求方式错误');
  1787. }
  1788. $req = $this->request->param();
  1789. if (isset($req['gdbh']) && !empty($req['gdbh'])){
  1790. $where['关联编号'] = ['LIKE','%'.$req['gdbh'].'%'];
  1791. }else{
  1792. $this->error('参数错误');
  1793. }
  1794. $rows = db('工单_相关附件')
  1795. ->where($where)
  1796. ->select();
  1797. foreach ($rows as $key=>&$value){
  1798. if(mb_detect_encoding($value['附件内容'])!='ASCII'){
  1799. $value['附件内容'] = '';
  1800. }
  1801. }
  1802. $this->success('成功',$rows);
  1803. }
  1804. /**
  1805. * 产品附件新增
  1806. */
  1807. public function gdAnnexAdd(){
  1808. if(!$this->request->isPost()){
  1809. $this->error('请求方式错误');
  1810. }
  1811. $req = $this->request->param();
  1812. $arr = [
  1813. 'sys_id',
  1814. '附件备注',
  1815. '附件内容',
  1816. '附件类型',
  1817. '关联编号'
  1818. ];
  1819. $data = [];
  1820. foreach ($arr as $key => $value){
  1821. if (!isset($req[$value])){
  1822. $this->error('参数错误',$value,$key+1);
  1823. }
  1824. $data[$value] = $req[$value];
  1825. }
  1826. $data['sys_rq'] = date('Y-m-d H:i:s');
  1827. //查询UniqId
  1828. $UniqId = db('工单_相关附件')->max('UniqId');
  1829. $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
  1830. //开启事务
  1831. db()->startTrans();
  1832. try{
  1833. $sql = db('工单_相关附件')->fetchSql(true)->insert($data);
  1834. $bool = db()->query($sql);
  1835. // 提交事务
  1836. db()->commit();
  1837. } catch (\Exception $e) {
  1838. // 回滚事务
  1839. db()->rollback();
  1840. $this->error($e->getMessage());
  1841. }
  1842. if($bool===false) $this->error('失败');
  1843. $this->success('成功');
  1844. }
  1845. /**
  1846. * 产品附件修改
  1847. * @ApiMethod (GET)
  1848. * @param string 'UniqId'
  1849. */
  1850. public function gdAnnexDel()
  1851. {
  1852. if(!$this->request->isGet()){
  1853. $this->error('请求方式错误');
  1854. }
  1855. $req = $this->request->param();
  1856. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  1857. $this->error('参数错误','UniqId',100);
  1858. }
  1859. //开启事务
  1860. db()->startTrans();
  1861. try{
  1862. $bool = db('工单_相关附件')->where('UniqId',$req['UniqId'])->delete();
  1863. // 提交事务
  1864. db()->commit();
  1865. } catch (\Exception $e) {
  1866. // 回滚事务
  1867. db()->rollback();
  1868. $this->error($e->getMessage());
  1869. }
  1870. if($bool===false) $this->error('失败');
  1871. $this->success('成功');
  1872. }
  1873. /**
  1874. * 引用工单资料数据查询
  1875. * @return void
  1876. * @throws \think\db\exception\DataNotFoundException
  1877. * @throws \think\db\exception\ModelNotFoundException
  1878. * @throws \think\exception\DbException
  1879. */
  1880. public function WorkOrderDetailCope()
  1881. {
  1882. if ($this->request->isGet() === false){
  1883. $this->error('请求错误');
  1884. }
  1885. $param = $this->request->param();
  1886. if (empty($param['search'])){
  1887. $this->error('参数错误');
  1888. }
  1889. $list = \db('工单_基本资料')
  1890. ->alias('a')
  1891. ->field([
  1892. 'rtrim(a.Gd_gdbh)' => '工单编号',
  1893. 'rtrim(b.客户编号)' => '客户编号',
  1894. 'rtrim(b.客户名称)' => '客户名称',
  1895. 'rtrim(b.产品编号)' => '产品编号',
  1896. 'rtrim(b.产品名称)' => '产品名称'
  1897. ])
  1898. ->join('产品_基本资料 b','a.成品代号 = b.产品编号')
  1899. ->where('a.Gd_gdbh','like','%'.$param['search'].'%')
  1900. ->whereOr('a.成品名称','like','%'.$param['search'].'%')
  1901. ->group('a.Gd_gdbh')
  1902. ->order('a.Uniqid desc')
  1903. ->select();
  1904. if (empty($list)){
  1905. $this->success('未找到工单资料');
  1906. }else{
  1907. $this->success('成功',$list);
  1908. }
  1909. }
  1910. /**
  1911. * 引用产品印件、工艺资料
  1912. * @return void
  1913. * @throws \think\db\exception\BindParamException
  1914. * @throws \think\db\exception\DataNotFoundException
  1915. * @throws \think\db\exception\ModelNotFoundException
  1916. * @throws \think\exception\DbException
  1917. * @throws \think\exception\PDOException
  1918. */
  1919. public function WorkOrderDetailListCope()
  1920. {
  1921. if (Request::instance()->isPost() === false){
  1922. $this->error('请求错误');
  1923. }
  1924. $param = Request::instance()->post();
  1925. if (empty($param['workorder']) || empty($param['productCode']) || empty($param['option'])){
  1926. $this->error('参数错误');
  1927. }
  1928. //引用印件资料
  1929. $processWhere = [
  1930. 'Gy0_方案' => $param['option'],
  1931. 'Gy0_cpdh' => $param['productCode']
  1932. ];
  1933. $ProcessList = \db('产品_工艺资料')
  1934. ->where($processWhere)
  1935. ->select();
  1936. if (empty($ProcessList)){
  1937. $this->error('未找到产品工艺资料');
  1938. }
  1939. $ProcesslastId = \db('工单_工艺资料')->order('UniqId desc')->value('rtrim(UniqId)');
  1940. foreach ($ProcessList as $key=>$value){
  1941. $ProcessList[$key]['Gy0_gdbh'] = $param['workorder'];
  1942. $ProcessList[$key]['Gy0_gxmc'] = $value['gy0_gxmc'];
  1943. $ProcessList[$key]['Gy0_SITE'] = $value['Gy0_site'];
  1944. $ProcessList[$key]['Gy0_ks'] = $value['Gy0_Ks'];
  1945. $ProcessList[$key]['Gy0_ms'] = $value['Gy0_Ms'];
  1946. $ProcessList[$key]['Gy0_oil'] = $value['Gy0_Oil'];
  1947. $ProcessList[$key]['UniqId'] = $ProcesslastId + $key + 1;
  1948. $ProcessList[$key]['PD_WG'] = '1900-01-01 00:00:00';
  1949. $ProcessList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
  1950. $ProcessList[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
  1951. unset($ProcessList[$key]['Gy0_Oil'],$ProcessList[$key]['Gy0_Ms'],$ProcessList[$key]['Gy0_Ks'],$ProcessList[$key]['UniqID'],$ProcessList[$key]['Gy0_cpdh'],$ProcessList[$key]['gy0_gxmc'],$ProcessList[$key]['Gy0_site']);
  1952. }
  1953. //引用印件资料
  1954. $PrintList = \db('产品_印件资料')
  1955. ->where('yj_cpdh',$param['productCode'])
  1956. ->select();
  1957. if (empty($PrintList)){
  1958. $this->error('未找到印件资料');
  1959. }
  1960. $PrintLastId = \db('工单_印件资料')->order('Uniqid desc')->value('rtrim(Uniqid)');
  1961. foreach ($PrintList as $key => $value){
  1962. $PrintList[$key]['Yj_Gdbh'] = $param['workorder'];
  1963. $PrintList[$key]['yj_Yjno'] = $value['yj_yjno'];
  1964. $PrintList[$key]['yj_Yjdh'] = $value['yj_yjdh'];
  1965. $PrintList[$key]['Sys_id'] = $value['sys_id'];
  1966. $PrintList[$key]['Uniqid'] = $PrintLastId + $key + 1;
  1967. $PrintList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
  1968. $PrintList[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
  1969. unset($PrintList[$key]['mod_rq'],$PrintList[$key]['sys_rq'],$PrintList[$key]['sys_id'],$PrintList[$key]['KgToPages'],$PrintList[$key]['yj_tll'],$PrintList[$key]['yj_yjdh'],$PrintList[$key]['yj_yjno'],$PrintList[$key]['UniqId']);
  1970. }
  1971. //插入数据
  1972. $processSql = \db('工单_工艺资料')->fetchSql(true)->insertAll($ProcessList);
  1973. $processRes = \db()->query($processSql);
  1974. if ($processRes === false){
  1975. $this->error('插入工艺资料失败');
  1976. }
  1977. $printSql = \db('工单_印件资料')->fetchSql(true)->insertAll($PrintList);
  1978. $printRes = \db()->query($printSql);
  1979. if ($printRes === false){
  1980. $this->error('插入印件资料失败');
  1981. }
  1982. $this->success('成功');
  1983. }
  1984. /**
  1985. * 引用产品印件、工艺资料->信息获取
  1986. * @return void
  1987. * @throws \think\db\exception\DataNotFoundException
  1988. * @throws \think\db\exception\ModelNotFoundException
  1989. * @throws \think\exception\DbException
  1990. */
  1991. public function ProductCopeDetail()
  1992. {
  1993. if ($this->request->isGet() === false){
  1994. $this->error('请求错误');
  1995. }
  1996. $param = $this->request->param();
  1997. if (empty($param['workorder'])){
  1998. $this->error('参数错误');
  1999. }
  2000. $list = \db('工单_基本资料')
  2001. ->alias('a')
  2002. ->field([
  2003. 'rtrim(a.Gd_gdbh)' => '工单编号',
  2004. 'rtrim(b.客户编号)' => '客户编号',
  2005. 'rtrim(b.客户名称)' => '客户名称',
  2006. 'rtrim(b.产品编号)' => '产品编号',
  2007. 'rtrim(b.产品名称)' => '产品名称'
  2008. ])
  2009. ->join('产品_基本资料 b','a.成品代号 = b.产品编号')
  2010. ->where('a.Gd_gdbh',$param['workorder'])
  2011. ->find();
  2012. if (empty($list)){
  2013. $this->error('未找到工单信息');
  2014. }
  2015. $option = \db('产品_工艺资料')
  2016. ->field('rtrim(Gy0_方案) as 方案')
  2017. ->where('Gy0_cpdh',$list['产品编号'])
  2018. ->group('Gy0_方案')
  2019. ->select();
  2020. $list['方案'] = $option;
  2021. $this->success('成功',$list);
  2022. }
  2023. }