WorkOrder.php 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110
  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. $rate = \db('dic_lzsh')->where('sys_bh',$param['shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
  988. $data = [
  989. '重点工序' => isset($param['zdgx'])?$param['zdgx']:'',
  990. '备选工序' => isset($param['bxgx'])?$param['bxgx']:'',
  991. 'Gy0_sbbh' => isset($param['sbbh'])?$param['sbbh']:'',
  992. 'Gy0_Rate0' => isset($rate['rate0'])?$rate['rate0']:'',
  993. 'Gy0_Rate1' => isset($rate['rate1'])?$rate['rate1']:'',
  994. 'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
  995. '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
  996. '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
  997. 'Gy0_小时产能' => $param['xscn'],
  998. 'Mod_rq' => date('Y-m-d H:i:s',time()),
  999. ];
  1000. $sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
  1001. $res = Db::query($sql);
  1002. $status = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
  1003. if ($status['status'] !== '2-生产中'){
  1004. $statusSql = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
  1005. Db::query($statusSql);
  1006. }
  1007. if ($res !== false){
  1008. $this->success('成功');
  1009. }else{
  1010. $this->error('失败');
  1011. }
  1012. }
  1013. /**
  1014. * 工艺资料编辑->机台列表获取
  1015. * @return void
  1016. * @throws \think\db\exception\DataNotFoundException
  1017. * @throws \think\db\exception\ModelNotFoundException
  1018. * @throws \think\exception\DbException
  1019. */
  1020. public function MachineList()
  1021. {
  1022. if ($this->request->isGet() === false){
  1023. $this->error('请求错误');
  1024. }
  1025. $param = $this->request->param();
  1026. if (empty($param)){
  1027. $this->error('参数错误');
  1028. }
  1029. $list = \db('设备_基本资料')
  1030. ->where('存放地点',$param['address'])
  1031. ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')
  1032. ->select();
  1033. if (empty($list)){
  1034. $this->success('未找到该车间机台');
  1035. }
  1036. $data = [];
  1037. foreach ($list as $key=>$value){
  1038. $data[$key] = $value['设备编号'].'-->'.$value['设备名称'];
  1039. }
  1040. $this->success('成功',$data);
  1041. }
  1042. /**
  1043. * 打印作业通知单->工单印件和工序获取
  1044. * @ApiMethod (GET)
  1045. * @return void
  1046. * @throws \think\db\exception\DataNotFoundException
  1047. * @throws \think\db\exception\ModelNotFoundException
  1048. * @throws \think\exception\DbException
  1049. */
  1050. public function PrintCodeList()
  1051. {
  1052. if ($this->request->isGet() === false){
  1053. $this->error('请求错误');
  1054. }
  1055. $param = $this->request->param();
  1056. if (empty($param)){
  1057. $this->error('参数错误');
  1058. }
  1059. $list = \db('工单_印件资料')
  1060. ->field([
  1061. 'rtrim(yj_Yjno)' => '印件号',
  1062. 'rtrim(yj_yjmc)' => '印件名称'
  1063. ])
  1064. ->where('Yj_Gdbh',$param['workOrder'])
  1065. ->select();
  1066. $this->success('成功',$list);
  1067. }
  1068. /**
  1069. * 打印作业通知单->工艺编号获取
  1070. * @ApiMethod (GET)
  1071. * @return void
  1072. * @throws \think\db\exception\DataNotFoundException
  1073. * @throws \think\db\exception\ModelNotFoundException
  1074. * @throws \think\exception\DbException
  1075. */
  1076. public function ProcessCodeList()
  1077. {
  1078. if ($this->request->isGet() === false){
  1079. $this->error('请求错误');
  1080. }
  1081. $param = $this->request->param();
  1082. if (empty($param)){
  1083. $this->error('参数错误');
  1084. }
  1085. $list = \db('工单_工艺资料')
  1086. ->field('rtrim(Gy0_gxh) as 工序号')
  1087. ->where([
  1088. 'Gy0_gdbh' => $param['workOrder'],
  1089. 'Gy0_yjno' => $param['yjno']
  1090. ])
  1091. ->select();
  1092. $this->success('成功',$list);
  1093. }
  1094. /**
  1095. * 打印作业通知单
  1096. * @ApiMethod (POST)
  1097. * @param void
  1098. * @return void
  1099. * @throws \think\db\exception\DataNotFoundException
  1100. * @throws \think\db\exception\ModelNotFoundException
  1101. * @throws \think\exception\DbException
  1102. */
  1103. public function PrintJobOrder()
  1104. {
  1105. if ($this->request->isGet() === false) {
  1106. $this->error('请求错误');
  1107. }
  1108. $param = $this->request->param();
  1109. if (empty($param)){
  1110. $this->error('参数错误');
  1111. }
  1112. $data = $this->workOrderDetailGet($param['workOrder'],$param['yjno']);
  1113. if (empty($data)){
  1114. $this->success('未找到工单信息');
  1115. }
  1116. $materiel = $this->MaterielDetailGet($param['workOrder']);
  1117. if (empty($materiel)){
  1118. $this->success('未找到物料信息');
  1119. }
  1120. $printDetail = $this->PrintDetailGet($param['workOrder'],$param['yjno'],$param['gxh']);
  1121. if (empty($printDetail)){
  1122. $this->success('未找到工艺信息');
  1123. }
  1124. $number = 0;
  1125. foreach ($printDetail as $key=>$value){
  1126. $value['允损比例'] = (float)substr($value['允损比例'],0,-1);
  1127. $number = $number+$value['允损比例'];
  1128. }
  1129. $data['制单'] = $param['PrepareDocument'];
  1130. $data['审核'] = $param['examine'];
  1131. $data['目标合格率'] = 100-$number.'%';
  1132. $data['materiel'] = $materiel;
  1133. $data['printDetail'] = $printDetail;
  1134. $this->success('成功',$data);
  1135. }
  1136. /**
  1137. * 打印作业通知单->工单及印件资料获取
  1138. * @param $workOrder
  1139. * @return mixed
  1140. */
  1141. public function workOrderDetailGet($workOrder,$yjno)
  1142. {
  1143. $sql = "SELECT
  1144. RTRIM( a.Gd_lx) AS 工单类型,
  1145. RTRIM( a.Gd_gdbh ) AS 生产批次号,
  1146. RTRIM( a.销售订单号 ) AS 销售订单号,
  1147. RTRIM( a.Gd_客户代号 ) AS 客户代号,
  1148. RTRIM( a.Gd_客户名称 ) AS 客户名称,
  1149. RTRIM( a.成品代号 ) AS 产品代码,
  1150. RTRIM( a.成品名称 ) AS 产品名称,
  1151. RTRIM( a.产品版本号 ) AS 版本号,
  1152. RTRIM( a.警语版面 ) AS 警语版面,
  1153. RTRIM( a.码源数量 ) AS 码源数量,
  1154. RTRIM( a.客户ERP编码 ) AS 客户ERP编码,
  1155. RTRIM( a.接单日期 ) AS 开单日期,
  1156. RTRIM( a.交货日期 ) AS 交货日期,
  1157. RTRIM( a.Gd_desc ) AS 工单说明,
  1158. RTRIM( a.投料率 ) AS 投料率,
  1159. RTRIM( a.平均合格率 ) AS 平均合格率,
  1160. RTRIM( a.投料大箱 ) AS 订货数量,
  1161. RTRIM( a.排产时库存 ) AS 排产时库存,
  1162. RTRIM( b.yj_Yjno ) AS 印件,
  1163. RTRIM( b.yj_Yjdh ) AS 印件代号,
  1164. RTRIM( b.yj_yjmc ) AS 印件名称,
  1165. RTRIM( b.yj_平张投料 ) AS 平张投料量,
  1166. RTRIM( b.yj_zzmc ) AS 纸张名称,
  1167. RTRIM( b.yj_tlgg ) AS 投料规格,
  1168. RTRIM( b.yj_ks ) AS 开数,
  1169. RTRIM( b.yj_ls ) AS 联数,
  1170. RTRIM( b.yj_desc ) AS 印件备注
  1171. FROM
  1172. `工单_基本资料` AS a
  1173. JOIN `工单_印件资料` AS b ON b.Yj_Gdbh = a.Gd_gdbh
  1174. WHERE
  1175. a.Gd_gdbh = '{$workOrder}' AND a.行号 = 1 AND b.yj_Yjno = '{$yjno}'";
  1176. $list = Db::query($sql);
  1177. if (empty($list)){
  1178. $this->success('未找到订单数据');
  1179. }
  1180. $list[0]['开单日期'] = date('Y-m-d',strtotime($list[0]['开单日期']));
  1181. $list[0]['交货日期'] = date('Y-m-d',strtotime($list[0]['交货日期']));
  1182. $list[0]['订货数量'] = (int)$list[0]['订货数量'];
  1183. $list[0]['联数'] = (int)$list[0]['联数'];
  1184. $list[0]['印件代号及名称'] = $list[0]['印件代号'].' '.$list[0]['印件名称'];
  1185. $list[0]['投料数量'] = $list[0]['订货数量'];
  1186. unset($list[0]['印件代号'],$list[0]['印件名称']);
  1187. return($list[0]);
  1188. }
  1189. /**打印作业流程单->物料资料获取
  1190. * @param $workOrder
  1191. * @return bool|\PDOStatement|string|\think\Collection
  1192. * @throws \think\db\exception\DataNotFoundException
  1193. * @throws \think\db\exception\ModelNotFoundException
  1194. * @throws \think\exception\DbException
  1195. */
  1196. public function MaterielDetailGet($workOrder)
  1197. {
  1198. $where = [
  1199. 'BOM_工单编号' => $workOrder,
  1200. ];
  1201. $filed = 'rtrim(BOM_物料编码) as 物料编码,rtrim(BOM_物料名称) as 物料名称,rtrim(BOM_投料单位) as 投料单位,rtrim(BOM_计划用量) as 计划用量';
  1202. $list = \db('工单_bom资料')->where($where)->field($filed)->select();
  1203. if (empty($list)){
  1204. $this->success('未找到物料资料信息');
  1205. }
  1206. foreach ($list as $key=>$value){
  1207. $list[$key]['物料代码及名称'] = $value['物料编码'].' '.$value['物料名称'];
  1208. $list[$key]['计划用量'] = (float)$value['计划用量'];
  1209. unset($list[$key]['物料编码'],$list[$key]['物料名称']);
  1210. }
  1211. return $list;
  1212. }
  1213. /**
  1214. * 打印作业流程单->工艺资料获取
  1215. * @param $workOrder
  1216. * @return bool|\PDOStatement|string|\think\Collection
  1217. * @throws \think\db\exception\DataNotFoundException
  1218. * @throws \think\db\exception\ModelNotFoundException
  1219. * @throws \think\exception\DbException
  1220. */
  1221. public function PrintDetailGet($workOrder,$yjno,$gxh)
  1222. {
  1223. $where = [
  1224. 'Gy0_gdbh' => $workOrder,
  1225. 'Gy0_yjno' => $yjno,
  1226. 'Gy0_gxh' => ['<=',$gxh]
  1227. ];
  1228. $filed = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  1229. rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as ls,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_计划损耗) as 计划损耗,
  1230. rtrim(Gy0_辅助工时) as 装版工时,rtrim(Gy0_小时产能) as 小时定额,rtrim(Gy0_生产工时) as 生产工时,rtrim(工序备注) as 工序备注';
  1231. $list = \db('工单_工艺资料')
  1232. ->where($where)
  1233. ->field($filed)
  1234. ->select();
  1235. if (empty($list)){
  1236. $this->success('工单工艺为空');
  1237. }
  1238. foreach ($list as $key=>$value){
  1239. if ($value['yjno']<10){
  1240. $value['yjno'] = '0'.$value['yjno'];
  1241. }
  1242. if ($value['gxh']<10){
  1243. $value['gxh'] = '0'.$value['gxh'];
  1244. }
  1245. if ($value['add_gxmc'] !== null){
  1246. $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  1247. }else{
  1248. $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
  1249. }
  1250. $list[$key]['转序数'] = (int)($value['计划接货数']/$value['ls']);
  1251. $list[$key]['报废定额'] = (int)($value['计划损耗']/$value['ls']);
  1252. if ((int)$value['计划接货数'] === 0){
  1253. $list[$key]['允损比例'] = 0;
  1254. }else{
  1255. $list[$key]['允损比例'] = round(($value['计划损耗']/$value['计划接货数'])*100,2).'%';
  1256. }
  1257. unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['add_gxmc'],$list[$key]['计划接货数'],$list[$key]['计划损耗']);
  1258. }
  1259. return $list;
  1260. }
  1261. /**
  1262. * 获取小时产能
  1263. * @ApiMethod (GET)
  1264. * @param void
  1265. * @return void
  1266. * @throws \think\db\exception\DataNotFoundException
  1267. * @throws \think\db\exception\ModelNotFoundException
  1268. * @throws \think\exception\DbException
  1269. */
  1270. public function capacityList()
  1271. {
  1272. if ($this->request->isGet() === false){
  1273. $this->error('请求错误');
  1274. }
  1275. $param = $this->request->param();
  1276. if (empty($param)){
  1277. $this->error('参数错误');
  1278. }
  1279. $machine = explode(' ',$param['machine'])[0];
  1280. $number = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(排单小时定额) as 小时产能')->find();
  1281. if (empty($number)){
  1282. $this->error('未找到小时产能');
  1283. }
  1284. $this->success('成功',$number['小时产能']);
  1285. }
  1286. /**
  1287. * 新增工单->添加工单
  1288. * @ApiMethod (POST)
  1289. * @param
  1290. * @return void
  1291. * @throws \think\Exception
  1292. * @throws \think\db\exception\BindParamException
  1293. * @throws \think\db\exception\DataNotFoundException
  1294. * @throws \think\db\exception\ModelNotFoundException
  1295. * @throws \think\exception\DbException
  1296. * @throws \think\exception\PDOException
  1297. */
  1298. public function WorkOrderAdd()
  1299. {
  1300. if (Request::instance()->isPost() === false){
  1301. $this->error('请求错误');
  1302. }
  1303. $param = Request::instance()->post();
  1304. if (empty($param)){
  1305. $this->error('参数错误');
  1306. }
  1307. $num = \db('工单_基本资料')->where('Gd_gdbh',$param['gdbh'])->count();
  1308. $productDetail = \db('产品_基本资料')->where('产品编号',$param['cpdh'])->find();
  1309. if (empty($productDetail)){
  1310. $productDetail['客户料号'] = '';
  1311. }
  1312. $lastId = \db('工单_基本资料')->order('Uniqid desc')->value('Uniqid');
  1313. if ($lastId<1000000000){
  1314. $lastId = 1000000000;
  1315. }
  1316. $data = [
  1317. 'Gd_lx' =>$param['zdgd'],
  1318. 'Gd_生产分类' =>$param['sclx'],
  1319. '成本处理类别' =>'',
  1320. 'Gd_gdbh' =>$param['gdbh'],
  1321. '行号' =>$num+1 ,
  1322. 'Gd_客户代号' =>$param['khdh'],
  1323. 'Gd_客户名称' =>$param['khmc'],
  1324. 'Gd_khdh' =>$param['khdh'],
  1325. 'Gd_khmc' =>$param['khmc'],
  1326. '客户料号' =>rtrim($productDetail['客户料号']),
  1327. '客户ERP编码' =>$param['erp'],
  1328. 'Gd_cpdh' =>$param['cpdh'],
  1329. 'Gd_cpmc' =>$param['cpmc'],
  1330. '成品代号' =>$param['cpdh'],
  1331. '成品名称' =>$param['cpmc'],
  1332. '产品版本号' =>$param['bbh'],
  1333. '销售订单号' =>$param['xsddh'],
  1334. '警语版面' =>$param['jybm'],
  1335. '码源数量' =>$param['mysl'],
  1336. '排产时库存' =>$param['kcdx'],
  1337. '投料大箱' =>$param['tldx'],
  1338. '投料率' =>$param['tll'],
  1339. '平均合格率' =>$param['hgl'],
  1340. '进程备注' =>$param['jcbz'],
  1341. 'Gd_desc' =>$param['remark'],
  1342. '开单日期' =>date('Y-m-d H:i:s',time()),
  1343. '接单日期' =>$param['start'],
  1344. '交货日期' =>$param['end'],
  1345. '订单数量' =>$param['number'],
  1346. '计量单位' =>$param['tldw'],
  1347. '计划投料' =>$param['pztl'],
  1348. '实际投料' =>$param['wxz'],
  1349. '产品单价' =>0,
  1350. '入仓日期' =>'1900-01-01 00:00:00',
  1351. '工单入仓数量' =>0,
  1352. '工单制程废品' => 0,
  1353. '工单质检废品' => 0,
  1354. '工单无形损' => 0,
  1355. '工单计划损耗' => 0,
  1356. '工单完工日期' => $param['end'],
  1357. '投料确认' => '',
  1358. 'gd_statu' => '3-计划中',
  1359. '直接人工' => 0,
  1360. '分摊人工' => 0,
  1361. '直接材料' => 0,
  1362. '考核直接材料' => 0,
  1363. '分摊材料' => 0,
  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. 'V23制造成本' => 0,
  1386. 'Prt_rq' => date('Y-m-d H:i:s',time()),
  1387. 'Sys_id' => '',
  1388. 'Sys_rq' => date('Y-m-d H:i:s',time()),
  1389. 'Mod_rq' => date('Y-m-d H:i:s',time()),
  1390. 'U8UID' => '',
  1391. 'Uniqid' => $lastId+1,
  1392. '工序加工费' => 0,
  1393. ];
  1394. $sql= \db('工单_基本资料')->fetchSql(true)->insert($data);
  1395. $res = \db()->query($sql);
  1396. if ($res !== false){
  1397. $this->success('成功');
  1398. }else{
  1399. $this->error('失败');
  1400. }
  1401. }
  1402. /**
  1403. * 新增工单->客户代号列表获取
  1404. * @return void
  1405. * @throws \think\db\exception\BindParamException
  1406. * @throws \think\exception\PDOException
  1407. */
  1408. public function ClientList()
  1409. {
  1410. if ($this->request->isGet() === false){
  1411. $this->error('请求错误');
  1412. }
  1413. $param = $this->request->param();
  1414. if (isset($param['search'])){
  1415. $where = $param['search'].'%';
  1416. $sql = "SELECT DISTINCT
  1417. (客户编号),rtrim(客户名称 ) as 客户名称
  1418. FROM
  1419. `产品_基本资料`
  1420. WHERE
  1421. 客户编号 LIKE "."'".$where."'"."
  1422. OR
  1423. 客户名称 LIKE "."'".$where."'"."
  1424. GROUP BY
  1425. 客户编号
  1426. order by
  1427. 客户编号";
  1428. }else{
  1429. $sql = "SELECT DISTINCT
  1430. (客户编号),rtrim(客户名称 ) as 客户名称
  1431. FROM
  1432. `产品_基本资料`
  1433. GROUP BY
  1434. 客户编号
  1435. order by
  1436. 客户编号";
  1437. }
  1438. $list = \db()->query($sql);
  1439. if (empty($list)){
  1440. $this->success('未找到客户列表');
  1441. }
  1442. foreach ($list as $key=>$value){
  1443. if (empty($value['客户编号'])){
  1444. unset($list[$key]);
  1445. }else{
  1446. $list[$key]['客户编号'] = rtrim($value['客户编号']);
  1447. $list[$key]['name'] = rtrim($value['客户编号']).'【'.$value['客户名称'].'】';
  1448. if ($value['客户编号'] == '1098'){
  1449. $list[$key]['客户名称'] = '打样专用';
  1450. }
  1451. }
  1452. }
  1453. $list = array_values($list);
  1454. $this->success('成功',$list);
  1455. }
  1456. /**
  1457. * 新增工单->产品代号获取
  1458. * @ApiMethod (GET)
  1459. * @param void
  1460. * @return void
  1461. * @throws \think\db\exception\DataNotFoundException
  1462. * @throws \think\db\exception\ModelNotFoundException
  1463. * @throws \think\exception\DbException
  1464. */
  1465. public function ProductCodeList()
  1466. {
  1467. if ($this->request->isGet() === false){
  1468. $this->error('请求错误');
  1469. }
  1470. $param = $this->request->param();
  1471. if (isset($param['cilent']) === false){
  1472. $this->error('参数错误');
  1473. }
  1474. $where = ['产品编号'=>['like',$param['cilent'].'%']];
  1475. $list = \db('产品_基本资料')
  1476. ->where($where)
  1477. ->field('rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称')
  1478. ->select();
  1479. if (empty($list)){
  1480. $this->success('未获取到产品数据');
  1481. }
  1482. foreach ($list as $key=>$value){
  1483. $list[$key]['name'] = $value['产品编号'].'【'.$value['产品名称'].'】';
  1484. }
  1485. $this->success('成功',$list);
  1486. }
  1487. /**
  1488. * 新增印件资料->印件资料添加
  1489. * @return void
  1490. * @throws \think\db\exception\BindParamException
  1491. * @throws \think\exception\PDOException
  1492. */
  1493. public function PrintDetailAdd()
  1494. {
  1495. if (Request::instance()->isPost() === false){
  1496. $this->error('请求错误');
  1497. }
  1498. $param = Request::instance()->post();
  1499. if (empty($param)){
  1500. $this->error('参数错误');
  1501. }
  1502. $lastId = \db('工单_印件资料')->order('Uniqid desc')->value('Uniqid');
  1503. if ($lastId<1000000){
  1504. $lastId = 1000000;
  1505. }else{
  1506. $lastId = $lastId + 1;
  1507. }
  1508. $param['Uniqid'] = $lastId;
  1509. $param['Sys_rq'] = date('Y-m-d H:i:s',time());
  1510. $param['Mod_rq'] = date('Y-m-d H:i:s',time());
  1511. $sql = \db('工单_印件资料')->fetchSql(true)->insert($param);
  1512. $res = \db()->query($sql);
  1513. if ($res !== false){
  1514. $this->success('成功');
  1515. }else{
  1516. $this->error('失败');
  1517. }
  1518. }
  1519. /**
  1520. * 新增工艺资料->工艺资料添加
  1521. * @return void
  1522. * @throws \think\db\exception\BindParamException
  1523. * @throws \think\exception\PDOException
  1524. */
  1525. public function ProcessDetailAdd()
  1526. {
  1527. if (Request::instance()->isPost() === false){
  1528. $this->error('请求错误');
  1529. }
  1530. $param = Request::instance()->post();
  1531. if (empty($param)){
  1532. $this->error('参数错误');
  1533. }
  1534. $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
  1535. if ($lastId<100000000){
  1536. $lastId = 100000000;
  1537. }else{
  1538. $lastId = $lastId + 1;
  1539. }
  1540. if (empty($param['Gy0_shdh'])){
  1541. $param['Gy0_Rate0'] = 0;
  1542. $param['Gy0_Rate1'] = 0;
  1543. }else{
  1544. $detail = \db('dic_lzsh')->field('sys_rate0,sys_rate1')->where('sys_bh',$param['Gy0_shdh'])->find();
  1545. $param['Gy0_Rate0'] = $detail['sys_rate0'];
  1546. $param['Gy0_Rate1'] = $detail['sys_rate1'];
  1547. }
  1548. $param['Sys_rq'] = date('Y-m-d H:i:s',time());
  1549. $param['Mod_rq'] = '1900-01-01 00:00:00';
  1550. $param['Gy0_sj1'] = '1900-01-01 00:00:00';
  1551. $param['Gy0_sj2'] = '1900-01-01 00:00:00';
  1552. $param['PD_WG'] = '1900-01-01 00:00:00';
  1553. $param['UniqId'] = $lastId;
  1554. $sql = \db('工单_工艺资料')
  1555. ->fetchSql(true)
  1556. ->insert($param);
  1557. $res = \db()->query($sql);
  1558. if ($res !== false){
  1559. $this->success('成功');
  1560. }else{
  1561. $this->error('失败');
  1562. }
  1563. }
  1564. /**
  1565. * 新增工艺资料->印件编号获取
  1566. * @return void
  1567. * @throws \think\db\exception\DataNotFoundException
  1568. * @throws \think\db\exception\ModelNotFoundException
  1569. * @throws \think\exception\DbException
  1570. */
  1571. public function PrintDetailList()
  1572. {
  1573. if ($this->request->isGet() === false){
  1574. $this->error('请求错误');
  1575. }
  1576. $param = $this->request->param();
  1577. if (empty($param)){
  1578. $this->error('参数错误');
  1579. }
  1580. $printList = \db('工单_印件资料')
  1581. ->where('Yj_Gdbh',$param['workOrder'])
  1582. ->order('yj_Yjno')
  1583. ->select();
  1584. if (empty($printList)){
  1585. $this->success('未找到该工单印件资料');
  1586. }
  1587. $list = [];
  1588. foreach ($printList as $key=>$value){
  1589. $list[$key]['name'] = rtrim($value['yj_Yjno']).'-->'.rtrim($value['yj_yjmc']);
  1590. $list[$key]['no'] = rtrim($value['yj_Yjno']);
  1591. }
  1592. $this->success('成功',$list);
  1593. }
  1594. /**
  1595. * 工单资料管理->印件资料删除
  1596. * @return void
  1597. * @throws \think\Exception
  1598. * @throws \think\exception\PDOException
  1599. */
  1600. public function PrintDetailDel()
  1601. {
  1602. if ($this->request->isGet() === false){
  1603. $this->error('请求错误');
  1604. }
  1605. $param = $this->request->param();
  1606. if (isset($param['UniqId']) === false){
  1607. $this->error('参数错误');
  1608. }
  1609. $printId = explode(',',$param['UniqId']);
  1610. $i = 0;
  1611. foreach ($printId as $value){
  1612. $res = \db('工单_印件资料')
  1613. ->where('Uniqid',$value)
  1614. ->delete();
  1615. if ($res === false){
  1616. $i++;
  1617. }
  1618. }
  1619. if ($i === 0){
  1620. $this->success('删除成功');
  1621. }else{
  1622. $this->error('删除失败');
  1623. }
  1624. }
  1625. /**
  1626. * 工单资料管理->工艺资料删除
  1627. * @return void
  1628. * @throws \think\Exception
  1629. * @throws \think\exception\PDOException
  1630. */
  1631. public function ProcessDetailDel()
  1632. {
  1633. if ($this->request->isGet() === false){
  1634. $this->error('请求错误');
  1635. }
  1636. $param = $this->request->param();
  1637. if (isset($param['UniqId']) === false){
  1638. $this->error('参数错误');
  1639. }
  1640. $printId = explode(',',$param['UniqId']);
  1641. $i = 0;
  1642. foreach ($printId as $value){
  1643. $res = \db('工单_工艺资料')
  1644. ->where('UniqId',$value)
  1645. ->delete();
  1646. if ($res === false){
  1647. $i++;
  1648. }
  1649. }
  1650. if ($i === 0){
  1651. $this->success('删除成功');
  1652. }else{
  1653. $this->error('删除失败');
  1654. }
  1655. }
  1656. /**
  1657. * 工艺资料添加->工序损耗代码
  1658. * @return void
  1659. * @throws \think\db\exception\DataNotFoundException
  1660. * @throws \think\db\exception\ModelNotFoundException
  1661. * @throws \think\exception\DbException
  1662. */
  1663. public function WastageList()
  1664. {
  1665. if ($this->request->isGet() === false){
  1666. $this->error('请求错误');
  1667. }
  1668. $param = $this->request->param();
  1669. if (isset($param['search']) === false){
  1670. $this->error('参数错误');
  1671. }
  1672. $order = \db('dic_lzsh')
  1673. ->where('sys_mc','like',substr($param['search'],0,6).'%')
  1674. ->value('rtrim(sys_bh) as 编号');
  1675. $list = \db('dic_lzsh')
  1676. ->where('sys_bh','like',$order.'%')
  1677. ->where('sys_bh','<>',$order)
  1678. ->field('rtrim(sys_bh) as 编号,rtrim(sys_mc) as 名称,rtrim(UniqId) as UniqId')
  1679. ->select();
  1680. $this->success('成功',$list);
  1681. }
  1682. /**
  1683. * 获取产品附件列表
  1684. */
  1685. public function getAnnexTable(){
  1686. if(!$this->request->isGet()){
  1687. $this->error('请求方式错误');
  1688. }
  1689. $req = $this->request->param();
  1690. if (isset($req['cpdh']) && !empty($req['cpdh'])){
  1691. $where['关联产品'] = ['LIKE','%'.$req['cpdh'].'%'];
  1692. }else{
  1693. $this->error('参数错误');
  1694. }
  1695. $rows = db('产品_技术附件')
  1696. ->where($where)
  1697. ->select();
  1698. foreach ($rows as $key=>&$value){
  1699. if(mb_detect_encoding($value['附件内容'])!='ASCII'){
  1700. $value['附件内容'] = '';
  1701. }
  1702. }
  1703. $this->success('成功',$rows);
  1704. }
  1705. /**
  1706. * 产品附件新增
  1707. */
  1708. public function annexAdd(){
  1709. if(!$this->request->isPost()){
  1710. $this->error('请求方式错误');
  1711. }
  1712. $req = $this->request->param();
  1713. $arr = [
  1714. 'sys_id',
  1715. '序号',
  1716. '附件备注',
  1717. '附件内容',
  1718. '附件类型',
  1719. '适用工序',
  1720. '关联产品'
  1721. ];
  1722. $data = [];
  1723. foreach ($arr as $key => $value){
  1724. if (!isset($req[$value])){
  1725. $this->error('参数错误',$value,$key+1);
  1726. }
  1727. $data[$value] = $req[$value];
  1728. }
  1729. $data['sys_rq'] = date('Y-m-d H:i:s');
  1730. //查询UniqId
  1731. $UniqId = db('产品_技术附件')->max('UniqId');
  1732. $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
  1733. //开启事务
  1734. db()->startTrans();
  1735. try{
  1736. $sql = db('产品_技术附件')->fetchSql(true)->insert($data);
  1737. $bool = db()->query($sql);
  1738. // 提交事务
  1739. db()->commit();
  1740. } catch (\Exception $e) {
  1741. // 回滚事务
  1742. db()->rollback();
  1743. $this->error($e->getMessage());
  1744. }
  1745. if($bool===false) $this->error('失败');
  1746. $this->success('成功');
  1747. }
  1748. /**
  1749. * 产品附件修改
  1750. * @ApiMethod (GET)
  1751. * @param string 'UniqId'
  1752. */
  1753. public function annexDel()
  1754. {
  1755. if(!$this->request->isGet()){
  1756. $this->error('请求方式错误');
  1757. }
  1758. $req = $this->request->param();
  1759. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  1760. $this->error('参数错误','UniqId',100);
  1761. }
  1762. //开启事务
  1763. db()->startTrans();
  1764. try{
  1765. $bool = db('产品_技术附件')->where('UniqId',$req['UniqId'])->delete();
  1766. // 提交事务
  1767. db()->commit();
  1768. } catch (\Exception $e) {
  1769. // 回滚事务
  1770. db()->rollback();
  1771. $this->error($e->getMessage());
  1772. }
  1773. if($bool===false) $this->error('失败');
  1774. $this->success('成功');
  1775. }
  1776. /**
  1777. * 获取产品附件列表
  1778. */
  1779. public function getGdAnnexTable(){
  1780. if(!$this->request->isGet()){
  1781. $this->error('请求方式错误');
  1782. }
  1783. $req = $this->request->param();
  1784. if (isset($req['gdbh']) && !empty($req['gdbh'])){
  1785. $where['关联编号'] = ['LIKE','%'.$req['gdbh'].'%'];
  1786. }else{
  1787. $this->error('参数错误');
  1788. }
  1789. $rows = db('工单_相关附件')
  1790. ->where($where)
  1791. ->select();
  1792. foreach ($rows as $key=>&$value){
  1793. if(mb_detect_encoding($value['附件内容'])!='ASCII'){
  1794. $value['附件内容'] = '';
  1795. }
  1796. }
  1797. $this->success('成功',$rows);
  1798. }
  1799. /**
  1800. * 产品附件新增
  1801. */
  1802. public function gdAnnexAdd(){
  1803. if(!$this->request->isPost()){
  1804. $this->error('请求方式错误');
  1805. }
  1806. $req = $this->request->param();
  1807. $arr = [
  1808. 'sys_id',
  1809. '附件备注',
  1810. '附件内容',
  1811. '附件类型',
  1812. '关联编号'
  1813. ];
  1814. $data = [];
  1815. foreach ($arr as $key => $value){
  1816. if (!isset($req[$value])){
  1817. $this->error('参数错误',$value,$key+1);
  1818. }
  1819. $data[$value] = $req[$value];
  1820. }
  1821. $data['sys_rq'] = date('Y-m-d H:i:s');
  1822. //查询UniqId
  1823. $UniqId = db('工单_相关附件')->max('UniqId');
  1824. $data['UniqId'] = $UniqId < 10000000 ? 10000000 : $UniqId + 1;
  1825. //开启事务
  1826. db()->startTrans();
  1827. try{
  1828. $sql = db('工单_相关附件')->fetchSql(true)->insert($data);
  1829. $bool = db()->query($sql);
  1830. // 提交事务
  1831. db()->commit();
  1832. } catch (\Exception $e) {
  1833. // 回滚事务
  1834. db()->rollback();
  1835. $this->error($e->getMessage());
  1836. }
  1837. if($bool===false) $this->error('失败');
  1838. $this->success('成功');
  1839. }
  1840. /**
  1841. * 产品附件修改
  1842. * @ApiMethod (GET)
  1843. * @param string 'UniqId'
  1844. */
  1845. public function gdAnnexDel()
  1846. {
  1847. if(!$this->request->isGet()){
  1848. $this->error('请求方式错误');
  1849. }
  1850. $req = $this->request->param();
  1851. if (!(isset($req['UniqId']) && trim($req['UniqId'])!='')){
  1852. $this->error('参数错误','UniqId',100);
  1853. }
  1854. //开启事务
  1855. db()->startTrans();
  1856. try{
  1857. $bool = db('工单_相关附件')->where('UniqId',$req['UniqId'])->delete();
  1858. // 提交事务
  1859. db()->commit();
  1860. } catch (\Exception $e) {
  1861. // 回滚事务
  1862. db()->rollback();
  1863. $this->error($e->getMessage());
  1864. }
  1865. if($bool===false) $this->error('失败');
  1866. $this->success('成功');
  1867. }
  1868. /**
  1869. * 引用工单资料数据查询
  1870. * @return void
  1871. * @throws \think\db\exception\DataNotFoundException
  1872. * @throws \think\db\exception\ModelNotFoundException
  1873. * @throws \think\exception\DbException
  1874. */
  1875. public function WorkOrderDetailCope()
  1876. {
  1877. if ($this->request->isGet() === false){
  1878. $this->error('请求错误');
  1879. }
  1880. $param = $this->request->param();
  1881. if (empty($param['search'])){
  1882. $this->error('参数错误');
  1883. }
  1884. $list = \db('工单_基本资料')
  1885. ->alias('a')
  1886. ->field([
  1887. 'rtrim(a.Gd_gdbh)' => '工单编号',
  1888. 'rtrim(b.客户编号)' => '客户编号',
  1889. 'rtrim(b.客户名称)' => '客户名称',
  1890. 'rtrim(b.产品编号)' => '产品编号',
  1891. 'rtrim(b.产品名称)' => '产品名称'
  1892. ])
  1893. ->join('产品_基本资料 b','a.成品代号 = b.产品编号')
  1894. ->where('a.Gd_gdbh','like','%'.$param['search'].'%')
  1895. ->whereOr('a.成品名称','like','%'.$param['search'].'%')
  1896. ->group('a.Gd_gdbh')
  1897. ->order('a.Uniqid desc')
  1898. ->select();
  1899. if (empty($list)){
  1900. $this->success('未找到工单资料');
  1901. }else{
  1902. $this->success('成功',$list);
  1903. }
  1904. }
  1905. /**
  1906. * 引用产品印件、工艺资料
  1907. * @return void
  1908. * @throws \think\db\exception\BindParamException
  1909. * @throws \think\db\exception\DataNotFoundException
  1910. * @throws \think\db\exception\ModelNotFoundException
  1911. * @throws \think\exception\DbException
  1912. * @throws \think\exception\PDOException
  1913. */
  1914. public function WorkOrderDetailListCope()
  1915. {
  1916. if (Request::instance()->isPost() === false){
  1917. $this->error('请求错误');
  1918. }
  1919. $param = Request::instance()->post();
  1920. if (empty($param['workorder']) || empty($param['productCode']) || empty($param['option'])){
  1921. $this->error('参数错误');
  1922. }
  1923. //引用印件资料
  1924. $processWhere = [
  1925. 'Gy0_方案' => $param['option'],
  1926. 'Gy0_cpdh' => $param['productCode']
  1927. ];
  1928. $ProcessList = \db('产品_工艺资料')
  1929. ->where($processWhere)
  1930. ->select();
  1931. if (empty($ProcessList)){
  1932. $this->error('未找到产品工艺资料');
  1933. }
  1934. $ProcesslastId = \db('工单_工艺资料')->order('UniqId desc')->value('rtrim(UniqId)');
  1935. foreach ($ProcessList as $key=>$value){
  1936. $ProcessList[$key]['Gy0_gdbh'] = $param['workorder'];
  1937. $ProcessList[$key]['Gy0_gxmc'] = $value['gy0_gxmc'];
  1938. $ProcessList[$key]['Gy0_SITE'] = $value['Gy0_site'];
  1939. $ProcessList[$key]['Gy0_ks'] = $value['Gy0_Ks'];
  1940. $ProcessList[$key]['Gy0_ms'] = $value['Gy0_Ms'];
  1941. $ProcessList[$key]['Gy0_oil'] = $value['Gy0_Oil'];
  1942. $ProcessList[$key]['UniqId'] = $ProcesslastId + $key + 1;
  1943. $ProcessList[$key]['PD_WG'] = '1900-01-01 00:00:00';
  1944. $ProcessList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
  1945. $ProcessList[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
  1946. 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']);
  1947. }
  1948. //引用印件资料
  1949. $PrintList = \db('产品_印件资料')
  1950. ->where('yj_cpdh',$param['productCode'])
  1951. ->select();
  1952. if (empty($PrintList)){
  1953. $this->error('未找到印件资料');
  1954. }
  1955. $PrintLastId = \db('工单_印件资料')->order('Uniqid desc')->value('rtrim(Uniqid)');
  1956. foreach ($PrintList as $key => $value){
  1957. $PrintList[$key]['Yj_Gdbh'] = $param['workorder'];
  1958. $PrintList[$key]['yj_Yjno'] = $value['yj_yjno'];
  1959. $PrintList[$key]['yj_Yjdh'] = $value['yj_yjdh'];
  1960. $PrintList[$key]['Sys_id'] = $value['sys_id'];
  1961. $PrintList[$key]['Uniqid'] = $PrintLastId + $key + 1;
  1962. $PrintList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
  1963. $PrintList[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
  1964. 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']);
  1965. }
  1966. //插入数据
  1967. $processSql = \db('工单_工艺资料')->fetchSql(true)->insertAll($ProcessList);
  1968. $processRes = \db()->query($processSql);
  1969. if ($processRes === false){
  1970. $this->error('插入工艺资料失败');
  1971. }
  1972. $printSql = \db('工单_印件资料')->fetchSql(true)->insertAll($PrintList);
  1973. $printRes = \db()->query($printSql);
  1974. if ($printRes === false){
  1975. $this->error('插入印件资料失败');
  1976. }
  1977. $this->success('成功');
  1978. }
  1979. /**
  1980. * 引用产品印件、工艺资料->信息获取
  1981. * @return void
  1982. * @throws \think\db\exception\DataNotFoundException
  1983. * @throws \think\db\exception\ModelNotFoundException
  1984. * @throws \think\exception\DbException
  1985. */
  1986. public function ProductCopeDetail()
  1987. {
  1988. if ($this->request->isGet() === false){
  1989. $this->error('请求错误');
  1990. }
  1991. $param = $this->request->param();
  1992. if (empty($param['workorder'])){
  1993. $this->error('参数错误');
  1994. }
  1995. $list = \db('工单_基本资料')
  1996. ->alias('a')
  1997. ->field([
  1998. 'rtrim(a.Gd_gdbh)' => '工单编号',
  1999. 'rtrim(b.客户编号)' => '客户编号',
  2000. 'rtrim(b.客户名称)' => '客户名称',
  2001. 'rtrim(b.产品编号)' => '产品编号',
  2002. 'rtrim(b.产品名称)' => '产品名称'
  2003. ])
  2004. ->join('产品_基本资料 b','a.成品代号 = b.产品编号')
  2005. ->where('a.Gd_gdbh',$param['workorder'])
  2006. ->find();
  2007. if (empty($list)){
  2008. $this->error('未找到工单信息');
  2009. }
  2010. $option = \db('产品_工艺资料')
  2011. ->field('rtrim(Gy0_方案) as 方案')
  2012. ->where('Gy0_cpdh',$list['产品编号'])
  2013. ->group('Gy0_方案')
  2014. ->select();
  2015. $list['方案'] = $option;
  2016. $this->success('成功',$list);
  2017. }
  2018. }