WorkOrder.php 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123
  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. '糊盒工单' => []
  36. ];
  37. $sql = "SELECT DISTINCT
  38. (客户编号),rtrim(客户名称 ) as 客户名称
  39. FROM
  40. `产品_基本资料`
  41. WHERE
  42. 客户编号 <> ''
  43. GROUP BY
  44. 客户编号
  45. order by
  46. 客户编号";
  47. $list = \db()->query($sql);
  48. if (empty($list)){
  49. $this->success('',[]);
  50. }
  51. foreach ($list as $key=>$value){
  52. $value['客户编号'] = rtrim($value['客户编号']);
  53. //这条sql查出来的数据可能不对,试一下以下sql
  54. $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
  55. $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
  56. $string = '';
  57. if ($productIng != 0){
  58. $string = $string."生产中:".$productIng;
  59. }
  60. if ($proGress != 0){
  61. $string = $string."计划中:".$proGress;
  62. }
  63. if ($string !== ''){
  64. $name = $value['客户编号'].'【'.$string.'】'.$value['客户名称'];
  65. if (strpos($value['客户编号'],'J') !== false){
  66. array_push($data['糊盒工单'],$name);
  67. }else{
  68. array_push($data['印刷工单'],$name);
  69. }
  70. }else{
  71. $name = $value['客户编号'].$value['客户名称'];
  72. if (strpos($value['客户编号'],'J') !== false){
  73. array_push($data['糊盒工单'],$name);
  74. }else{
  75. array_push($data['印刷工单'],$name);
  76. }
  77. }
  78. }
  79. $this->success('成功',$data);
  80. }
  81. /**
  82. * 工单基本资料列表
  83. * @ApiMethod (GET)
  84. * @param string $limit 查询长度
  85. * @param string $Gd_khdh 客户代号
  86. * @param string $startTime 接单日期开始时间
  87. * @param string $endTime 接单日期结束时间
  88. * @return \think\response\Json
  89. * @throws \think\exception\DbException
  90. */
  91. public function WorkList()
  92. {
  93. if ($this->request->isGet() === false){
  94. $this->error('请求错误');
  95. }
  96. $search = input('search');
  97. $clientNumber = input('Gd_khdh');
  98. $startTime = input('start');
  99. $endTime = input('end');
  100. $page = input('page');
  101. $limit = input('limit');
  102. $where = [];
  103. if (!empty($clientNumber)){
  104. $where['成品代号'] = ['like',$clientNumber.'%'];
  105. }
  106. if (!empty($workOrder)){
  107. $where['Gd_gdbh'] = $workOrder;
  108. }
  109. if (!empty($productCode)){
  110. $where['Gd_cpdh'] = $productCode;
  111. }
  112. if (!empty($search)){
  113. $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$search.'%'];
  114. }
  115. if (!empty($startTime) && !empty($endTime)){
  116. $where['接单日期'] = ['between',[$startTime,$endTime]];
  117. }
  118. $total = \db('工单_基本资料')->where($where)->count();
  119. $list = \db('工单_基本资料')
  120. ->where($where)
  121. ->order('Gd_statu desc')
  122. ->limit(($page-1)*$limit,$limit)
  123. ->select();
  124. //工单基本资料数据整理
  125. $data = [];
  126. foreach ($list as $key=>$value){
  127. $data[$key] = [
  128. '工单编号' => rtrim($value['Gd_gdbh']),
  129. '生产分类' => rtrim($value['Gd_生产分类']),
  130. '销售订单号' => rtrim($value['销售订单号']),
  131. '产品代号' => rtrim($value['Gd_cpdh']),
  132. '产品名称' => rtrim($value['Gd_cpmc']),
  133. '订单数量' => floatval($value['订单数量']),
  134. '单位' => rtrim($value['计量单位']),
  135. '折合大箱' => rtrim((int)$value['投料大箱']),
  136. '投料率' => rtrim($value['投料率']),
  137. '平均合格率' => '',
  138. '开单日期' => date('Y-m-d',strtotime(rtrim($value['接单日期']))),
  139. '交货日期' => date('Y-m-d',strtotime(rtrim($value['交货日期']))),
  140. '工单类型' => rtrim($value['Gd_lx']),
  141. '工单状态' => rtrim($value['gd_statu']),
  142. '当前生产工序' => '',
  143. '产量提交时间' => '',
  144. '建档用户' => rtrim($value['Sys_id']),
  145. '建档时间' => rtrim($value['Sys_rq']),
  146. '更新时间' => rtrim($value['Mod_rq']),
  147. 'Uniqid' => rtrim($value['Uniqid'])
  148. ];
  149. $number = \db('工单_工艺资料')->where('Gy0_gdbh',$data[$key]['工单编号'])->count();
  150. if ($number === 0){
  151. $data[$key]['status'] = '*';
  152. }else{
  153. $data[$key]['status'] = '';
  154. }
  155. }
  156. $this->success('成功',['data'=>$data,'total'=>$total]);
  157. }
  158. /**
  159. * 工单详情
  160. * @ApiMethod (GET)
  161. * @param void
  162. * @return void
  163. * @throws \think\db\exception\DataNotFoundException
  164. * @throws \think\db\exception\ModelNotFoundException
  165. * @throws \think\exception\DbException
  166. */
  167. public function workOrderListDetail()
  168. {
  169. if ($this->request->isGet() === false){
  170. $this->error('请求错误');
  171. }
  172. $Gd_gdbh = input('Gd_gdbh');
  173. if (empty($Gd_gdbh)){
  174. $this->error('参数错误');
  175. }
  176. $data = [];
  177. //印件资料
  178. $printList = \db('工单_印件资料')
  179. ->where('Yj_Gdbh',$Gd_gdbh)
  180. ->select();
  181. if (!empty($printList)){
  182. foreach ($printList as $key=>$value){
  183. $data['printList'][$key] = [
  184. '印件号' => rtrim($value['yj_Yjno']),
  185. '印件代号' => rtrim($value['yj_Yjdh']),
  186. '印件名称' => rtrim($value['yj_yjmc']),
  187. '纸张代号' => rtrim($value['yj_zzdh']),
  188. '纸张名称' => rtrim($value['yj_zzmc']),
  189. '投料规格' => rtrim($value['yj_tlgg']),
  190. '平张投料' => rtrim($value['yj_平张投料']),
  191. '开料规格' => rtrim($value['yj_klgg']),
  192. '开数*联数' => rtrim($value['yj_ks']).'*'.rtrim($value['yj_ls']),
  193. '建档用户' => rtrim($value['Sys_id']),
  194. '建档时间' => rtrim($value['Sys_rq']),
  195. '更新时间' => rtrim($value['Mod_rq']),
  196. 'zzdh1' => rtrim($value['yj_zzdh1']),
  197. 'zzdh2' => rtrim($value['yj_zzdh2']),
  198. 'zzdh3' => rtrim($value['yj_zzdh3']),
  199. 'zzdh4' => rtrim($value['yj_zzdh4']),
  200. 'zzmc1' => rtrim($value['yj_zzmc1']),
  201. 'zzmc2' => rtrim($value['yj_zzmc2']),
  202. 'zzmc3' => rtrim($value['yj_zzmc3']),
  203. 'zzmc4' => rtrim($value['yj_zzmc4']),
  204. '订单数量' => rtrim($value['yj_成品数量']),
  205. '万小张' => rtrim($value['yj_实际投料']),
  206. '开数' => rtrim($value['yj_ks']),
  207. '联数' => rtrim($value['yj_ls']),
  208. '核算规格' => rtrim($value['Yj_核算规格']),
  209. '备注' => rtrim($value['yj_desc']),
  210. 'Uniqid' => rtrim($value['Uniqid'])
  211. ];
  212. }
  213. }else{
  214. $data['printList'] = [];
  215. }
  216. //工艺资料
  217. $processList = \db('工单_工艺资料')
  218. ->where('Gy0_gdbh',$Gd_gdbh)
  219. ->order('Gy0_yjno,Gy0_gxh')
  220. ->select();
  221. if (!empty($processList)){
  222. foreach ($processList as $key=>$value){
  223. if ($value['Gy0_yjno']<10){
  224. $value['Gy0_yjno'] = '0'.$value['Gy0_yjno'];
  225. }
  226. if ($value['Gy0_gxh']<10){
  227. $value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
  228. }
  229. if ((int)$value['Gy0_ms'] === 0){
  230. $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']);
  231. }else{
  232. $scrap = ceil(($value['Gy0_Rate0']+((int)($value['Gy0_计划接货数']/$value['Gy0_ls']))*$value['Gy0_Rate1'])*$value['损耗系数']*$value['Gy0_ms']);
  233. }
  234. if (rtrim($value['Gy0_sbbh']) == '' || $value['Gy0_计划接货数'] == 0){
  235. $number = 0;
  236. }else{
  237. $number = round(($scrap/((int)($value['Gy0_计划接货数']/$value['Gy0_ls'])))*100,2).'%';
  238. }
  239. if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
  240. $status = '已完工';
  241. }else{
  242. $status = '未完工';
  243. }
  244. $data['processList'][$key] = [
  245. '重点工序' => rtrim($value['重点工序']),
  246. '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
  247. '备选工序' => rtrim($value['备选工序']),
  248. '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
  249. '计划产量' => (int)($value['Gy0_计划接货数']/$value['Gy0_ls']),
  250. '基础损耗' => rtrim($value['Gy0_Rate0']),
  251. '损耗率' => rtrim($value['Gy0_Rate1']),
  252. '机台编号' => rtrim($value['Gy0_sbbh']),
  253. '报废定额' => $scrap,
  254. '允损比例' => $number,
  255. '难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
  256. '损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
  257. '人工检_次品板' => (int)$value['人工检_次品板']=0?'':$value['人工检_次品板'],
  258. '人工检_废检' => (int)$value['人工检_废检']=0?'':$value['人工检_废检'],
  259. '机检_正品板' => (int)$value['机检_正品板']=0?'':$value['机检_正品板'],
  260. '机检_次品板' => (int)$value['机检_次品板']=0?'':$value['机检_次品板'],
  261. '机检_废检' => (int)$value['机检_废检']=0?'':$value['机检_废检'],
  262. '开数*联数' => rtrim($value['Gy0_ks']).'*'.rtrim($value['Gy0_ls']),
  263. '备注' => isset($value['工序备注'])?rtrim($value['工序备注']):'',
  264. '印刷方式' => isset($value['印刷方式'])?rtrim($value['印刷方式']):'',
  265. '版距' => isset($value['版距'])?rtrim($value['版距']):'',
  266. '建档用户' => rtrim($value['Sys_id']),
  267. '建档日期' => isset($value['Sys_rq'])?rtrim($value['Sys_rq']):'',
  268. '更新时间' => isset($value['Mod_rq'])?rtrim($value['Mod_rq']):'',
  269. '车间名称' => rtrim($value['Gy0_SITE']),
  270. '质量要求' => rtrim($value['质量要求']),
  271. '质量隐患' => rtrim($value['质量隐患']),
  272. '开数' => rtrim($value['Gy0_ks']),
  273. '联数' => rtrim($value['Gy0_ls']),
  274. 'UniqId' => rtrim($value['UniqId']),
  275. 'shdh' => rtrim($value['Gy0_shdh']),
  276. '辅助工时' => rtrim($value['Gy0_辅助工时']),
  277. '小时产能' => rtrim($value['Gy0_小时产能']),
  278. 'status' => $status
  279. ];
  280. }
  281. }else{
  282. $data['processList'] = [];
  283. }
  284. //BOM资料
  285. $field = 'rtrim(BOM_方案) as 方案,rtrim(BOM_物料编码) as 物料编号,rtrim(BOM_物料名称) as 物料名称,BOM_投料单位,
  286. BOM_投入数,BOM_产出数,BOM_产出单位,rtrim(BOM_计划用量) as 计划用量,rtrim(Sys_ID) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间';
  287. $bomList = \db('工单_bom资料')
  288. ->where('BOM_工单编号',$Gd_gdbh)
  289. ->field($field)
  290. ->select();
  291. if (!empty($bomList)){
  292. foreach ($bomList as $key=>$value){
  293. $bomList[$key]['消耗定量'] = rtrim($value['BOM_投入数']).rtrim($value['BOM_投料单位']).'/'.rtrim($value['BOM_产出数']).rtrim($value['BOM_产出单位']);
  294. unset($bomList[$key]['BOM_投料单位'],$bomList[$key]['BOM_投入数'],$bomList[$key]['BOM_产出数'],$bomList[$key]['BOM_产出单位']);
  295. $bomList[$key]['计划用量'] = rtrim((float)$value['计划用量']);
  296. }
  297. $data['BOM'] = $bomList;
  298. }else{
  299. $data['BOM'] = [];
  300. }
  301. //工单附件资料
  302. $jsRes = db('工单_相关附件')
  303. ->where('关联编号','like','%'.$Gd_gdbh.'%')
  304. ->select();
  305. if (!empty($jsRes)){
  306. foreach ($jsRes as $key=>&$value){
  307. if(mb_detect_encoding($value['附件内容'])!='ASCII'){
  308. $value['附件内容'] = '';
  309. }
  310. }
  311. $data['jsData'] = $jsRes;
  312. }else{
  313. $data['jsData'] = [];
  314. }
  315. $this->success('成功',$data);
  316. }
  317. /**
  318. * 编辑页面展示
  319. * @ApiMethod (GET)
  320. * @param string $workOrder 工单编号
  321. * @return void
  322. * @throws \think\db\exception\DataNotFoundException
  323. * @throws \think\db\exception\ModelNotFoundException
  324. * @throws \think\exception\DbException
  325. */
  326. public function DataCorrection()
  327. {
  328. if ($this->request->isGet() === false){
  329. $this->error('请求错误');
  330. }
  331. $workOrder = input('Gd_gdbh');
  332. if (empty($workOrder)){
  333. $this->error('参数错误');
  334. }
  335. $field = 'rtrim(Gd_lx) as 重点工单,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_生产分类) as 生产类型,rtrim(Gd_khdh) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
  336. rtrim(Gd_cpdh) as 印件代号,rtrim(Gd_cpmc) as 印件名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称,rtrim(接单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
  337. rtrim(投料率) as 投料率,rtrim(实际投料) as 万小张,rtrim(计量单位) as 单位,rtrim(投料大箱) as 投料大箱,rtrim(排产时库存) as 库存大箱,rtrim(警语版面) as 警语版面,
  338. rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注,rtrim(Uniqid) as Uniqid';
  339. $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
  340. if (empty($list)){
  341. $this->error('未找到该工单信息');
  342. }
  343. $printData = \db('工单_印件资料')
  344. ->where('Yj_Gdbh',$workOrder)
  345. ->field('rtrim(yj_yjmc) as 印件名称,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_平张投料) as 平张投料,rtrim(Uniqid) as id')
  346. ->cache(true,84600)
  347. ->find();
  348. if (empty($printData)){
  349. $list['印件名称'] = '';
  350. $list['印件代号'] = '';
  351. $list['平张投料'] = '';
  352. $list['印件ID'] = '';
  353. }else{
  354. $list['印件名称'] = $printData['印件名称'];
  355. $list['印件代号'] = $printData['印件代号'];
  356. $list['平张投料'] = $printData['平张投料'];
  357. $list['印件ID'] = $printData['id'];
  358. }
  359. $this->success('成功',$list);
  360. }
  361. /**
  362. * 工单资料修改
  363. * @ApiMethod (POST)
  364. * @param void
  365. * @return void
  366. * @throws \think\Exception
  367. * @throws \think\exception\PDOException
  368. */
  369. public function WorkOrderEdit()
  370. {
  371. if (Request::instance()->isPost() === false){
  372. $this->error('请求错误');
  373. }
  374. $param = Request::instance()->post();
  375. if (empty($param) || isset($param['Uniqid']) === false){
  376. $this->error('参数错误');
  377. }
  378. $row = [
  379. 'Gd_lx' => isset($param['lx'])?$param['lx']:'',
  380. '开单日期' => isset($param['kdrq'])?$param['kdrq']:'',
  381. 'Gd_gdbh' => isset($param['gdbh'])?$param['gdbh']:'',
  382. 'Gd_生产分类' => isset($param['scfl'])?$param['scfl']:'',
  383. 'Gd_客户代号' => isset($param['khdh'])?$param['khdh']:'',
  384. 'Gd_客户名称' => isset($param['khmc'])?$param['khmc']:'',
  385. '成品代号' => isset($param['cpdh'])?$param['cpdh']:'',
  386. '成品名称' => isset($param['cpmc'])?$param['cpmc']:'',
  387. '订单数量' => isset($param['ddsl'])?$param['ddsl']:'',
  388. '交货日期' => isset($param['jhrq'])?$param['jhrq']:'',
  389. '投料率' => isset($param['tll'])?$param['tll']:'',
  390. '计划投料' => isset($param['jhtl'])?$param['jhtl']:'',
  391. '实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
  392. '计量单位' => isset($param['jldw'])?$param['jldw']:'',
  393. '投料大箱' => isset($param['tldx'])?$param['tldx']:'',
  394. '销售订单号' => isset($param['xsddh'])?$param['xsddh']:'',
  395. '警语版面' => isset($param['jymb'])?$param['jymb']:'',
  396. '产品版本号' => isset($param['bbh'])?$param['bbh']:'',
  397. '客户ERP编码' => isset($param['erp'])?$param['erp']:'',
  398. '码源数量' => isset($param['ymsl'])?$param['ymsl']:'',
  399. '进程备注' => isset($param['jcbz'])?$param['jcbz']:'',
  400. 'Gd_desc' => isset($param['desc'])?$param['desc']:'',
  401. '排产时库存' => isset($param['kc'])?$param['kc']:'',
  402. '平均合格率' => isset($param['avg'])?$param['avg']:'',
  403. ];
  404. $sql = \db('工单_基本资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($row);
  405. $res = Db::query($sql);
  406. $printSql = \db('工单_印件资料')
  407. ->where('Uniqid',$param['printID'])
  408. ->fetchSql(true)
  409. ->update(['yj_yjmc'=>$param['yjmc'],'yj_Yjdh'=>$param['yjdh'],'yj_平张投料'=>$param['jhtl']]);
  410. $printRes = Db::query($printSql);
  411. if ($res !== false && $printRes !== false){
  412. $this->success('成功');
  413. }else{
  414. $this->error('失败');
  415. }
  416. }
  417. /**
  418. * U8投料试算
  419. * @ApiMethod (GET)
  420. * @param string $processCode 产品编号
  421. * @return void
  422. * @throws \think\db\exception\DataNotFoundException
  423. * @throws \think\db\exception\ModelNotFoundException
  424. * @throws \think\exception\DbException
  425. */
  426. public function U8Trial()
  427. {
  428. if ($this->request->isGet() === false)
  429. {
  430. $this->error('请求错误');
  431. }
  432. $productCode = input('productCode');
  433. if (empty($productCode)){
  434. $this->error('参数错误');
  435. }
  436. $field = 'rtrim(Gy0_cpdh) as 产品代号,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  437. rtrim(Gy0_Ms) as 墨色数,rtrim(Gy0_shdh) as 损耗代号,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as 加工联数';
  438. $list = \db('产品_工艺资料')->where('Gy0_cpdh',$productCode)->field($field)->select();
  439. if (empty($list)){
  440. $this->success('未找到该产品工序');
  441. }
  442. foreach ($list as $key=>$value){
  443. $data = \db('dic_lzsh')->where('sys_bh',$value['损耗代号'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->cache(true)->find();
  444. $list[$key]['调机损耗'] = isset($data['rate0'])?$data['rate0']:'';
  445. $list[$key]['运行损耗率'] = isset($data['rate1'])?$data['rate1']:'';
  446. if ($value['add_gxmc'] !== ''){
  447. $list[$key]['工序名称'] = $value['gxmc'].'【'.$value['add_gxmc'].'】';
  448. }else{
  449. $list[$key]['工序名称'] = $value['gxmc'];
  450. }
  451. unset($list[$key]['gxmc'],$list[$key]['add_gxmc']);
  452. }
  453. $this->success('成功',$list);
  454. }
  455. /**
  456. * 引用产品资料->获取产品资料
  457. * @ApiMethod (GET)
  458. * @param string $workOrder 工单编号
  459. * @return void
  460. * @throws \think\db\exception\DataNotFoundException
  461. * @throws \think\db\exception\ModelNotFoundException
  462. * @throws \think\exception\DbException
  463. */
  464. public function ProductInformation()
  465. {
  466. if ($this->request->isGet() === false)
  467. {
  468. $this->error('请求错误');
  469. }
  470. $workOrder = input('workOrder');
  471. if (empty($workOrder)){
  472. $this->error('参数错误');
  473. }
  474. $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_客户名称) as 客户名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称';
  475. $Detail = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
  476. if (empty($Detail)){
  477. $this->success('未找到工单信息');
  478. }
  479. $Detail['客户代号'] = substr($Detail['产品代号'],0,4);
  480. $this->success('成功',$Detail);
  481. }
  482. /**
  483. * 引用产品资料->复制产品工艺资料
  484. * @ApiMethod (POST)
  485. * @param string $oldWorkOrder 被复制工单编号
  486. * @param string $newWorkOrder 复制工单编号
  487. * @return void
  488. * @throws \think\Exception
  489. * @throws \think\db\exception\DataNotFoundException
  490. * @throws \think\db\exception\ModelNotFoundException
  491. * @throws \think\exception\DbException
  492. * @throws \think\exception\PDOException
  493. */
  494. public function ProductInformationEdit()
  495. {
  496. if (Request::instance()->isPost() === false)
  497. {
  498. $this->error('请求错误');
  499. }
  500. $oldWorkOrder = input('oldWorkOrder');
  501. $newWorkOrder = input('newWorkOrder');
  502. if (empty($oldWorkOrder) || empty($newWorkOrder))
  503. {
  504. $this->error('参数错误');
  505. }
  506. $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
  507. if ($lastId<10000000){
  508. $lastId = 10000000;
  509. }else{
  510. $lastId = $lastId + 1;
  511. }
  512. //获取原工单工艺资料
  513. $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->select();
  514. $ProsessUniqId = \db('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
  515. foreach ($oldProcessData as $k=>$v){
  516. $oldProcessData[$k]['Gy0_gdbh'] = $oldWorkOrder;
  517. $oldProcessData[$k]['Sys_id'] = '';
  518. $oldProcessData[$k]['Gy0_sj1'] = '1900-01-01 00:00:00';
  519. $oldProcessData[$k]['Gy0_sj2'] = '1900-01-01 00:00:00';
  520. $oldProcessData[$k]['UniqId'] = $lastId + $k;
  521. $oldProcessData[$k]['PD_WG'] = '1900-01-01 00:00:00';
  522. }
  523. if (\db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->find()){
  524. \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->delete();
  525. }
  526. //获取原工单印件资料
  527. $lastUniqId = \db('工单_印件资料')->order('UniqId desc')->value('UniqId');
  528. if ($lastUniqId<1000000){
  529. $lastUniqId = 1000000;
  530. }else{
  531. $lastUniqId = $lastUniqId + 1;
  532. }
  533. $oldPrintData = \db('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->select();
  534. $PrintUniqId = \db('工单_印件资料')->field('Uniqid')->order('Uniqid desc')->find();
  535. foreach ($oldPrintData as $k=>$v){
  536. $oldPrintData[$k]['Yj_Gdbh'] = $oldWorkOrder;
  537. $oldPrintData[$k]['Sys_id'] = '';
  538. $oldPrintData[$k]['Uniqid'] = $lastUniqId +$k +1;
  539. }
  540. if (\db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->find()){
  541. \db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->delete();
  542. }
  543. //复制印件、工艺资料
  544. $ProcessSQL = \db('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
  545. $ProcessRes = Db::query($ProcessSQL);
  546. $PrintSQL = \db('工单_印件资料')->fetchSql(true)->insertAll($oldPrintData);
  547. $PrintRes = Db::query($PrintSQL);
  548. if ($ProcessRes !== false && $PrintRes !== false){
  549. $this->success('成功');
  550. }else{
  551. $this->error('失败');
  552. }
  553. }
  554. /**
  555. * 工艺流程调成->获取当前工单工艺资料
  556. * @ApiMethod (GET)
  557. * @param string $workorder 当前工单编号
  558. * @return void
  559. * @throws \think\db\exception\DataNotFoundException
  560. * @throws \think\db\exception\ModelNotFoundException
  561. * @throws \think\exception\DbException
  562. */
  563. public function ProcessFlow()
  564. {
  565. if ($this->request->isGet() === false){
  566. $this->error('请求错误');
  567. }
  568. $workOrder = input('workOrder');
  569. if (empty($workOrder)){
  570. $this->error('参数错误');
  571. }
  572. $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(成品代号) as 成品编号,rtrim(成品名称) as 成品名称')->find();
  573. if (empty($list)){
  574. $this->success('未找到工单信息');
  575. }
  576. $filed = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  577. rtrim(工价系数) as 工价系数,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ks) as ks,rtrim(Gy0_ls) as ls,rtrim(工序备注) as 备注,rtrim(Gy0_SITE) as 车间,
  578. rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_sbmc) as 设备名称,rtrim(Sys_id) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间,rtrim(UniqId) as UniqId';
  579. $process = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->cache(true,84600)->field($filed)->select();
  580. if (empty($process)){
  581. $this->error('未找到该工单工艺资料');
  582. }
  583. foreach ($process as $key=>$value){
  584. if (isset($value['add_gxmc'])){
  585. $process[$key]['工序名称'] = $value['gxmc'] . '【'.$value['add_gxmc'].'】';
  586. }else{
  587. $process[$key]['工序名称'] = $value['gxmc'];
  588. }
  589. $process[$key]['工价系数'] = (float)$value['工价系数'];
  590. $process[$key]['损耗系数'] = (float)$value['损耗系数'];
  591. $process[$key]['开数*联数'] = $value['ks'].'*'.$value['ls'];
  592. }
  593. $list['process'] = $process;
  594. $this->success('成功',$list);
  595. }
  596. /**
  597. * 参照工单列表获取
  598. * @ApiMethod (GET)
  599. * @param string $workOrder 工单编号
  600. * @param string $productCode 产品代号
  601. * @return void
  602. */
  603. public function ReferenceWorkOrder()
  604. {
  605. if ($this->request->isGet() === false){
  606. $this->error('请求错误');
  607. }
  608. $productCode = input('productCode');
  609. $workOrder = input('workOrder');
  610. if (empty($productCode) || empty($workOrder)){
  611. $this->error('参数错误');
  612. }
  613. $list = \db('工单_基本资料')->where('成品代号',$productCode)->distinct(true)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
  614. if (empty($list)){
  615. $this->success('未获取该产品其他工单信息');
  616. }
  617. $this->success('成功',$list);
  618. }
  619. /**
  620. * 工艺资料复制
  621. * @ApiMethod (POST)
  622. * @param string $oldWorkOrder 被复制工单编号
  623. * @param string $newWorkOrder 复制工单编号
  624. * @return void
  625. * @throws \think\Exception
  626. * @throws \think\db\exception\DataNotFoundException
  627. * @throws \think\db\exception\ModelNotFoundException
  628. * @throws \think\exception\DbException
  629. * @throws \think\exception\PDOException
  630. *
  631. */
  632. public function ProcessCopy()
  633. {
  634. if (Request::instance()->isPost() === false){
  635. $this->error('请求错误');
  636. }
  637. $param = Request::instance()->post();
  638. if (empty($param)){
  639. $this->error('参数错误');
  640. }
  641. $UniqId = [];
  642. $lastId = \db('工单_工艺资料')->field('rtrim(UniqId) as id')->order('UniqId desc')->find();
  643. if ($lastId['id']>10000000){
  644. $lastUniqId = $lastId['id'];
  645. }else{
  646. $lastUniqId = 10000000;
  647. }
  648. foreach ($param as $key=>$value){
  649. $UniqId[$key] = $value['UniqId'];
  650. }
  651. $processList = \db('工单_工艺资料')->where('UniqId','in',$UniqId)->select();
  652. if (empty($processList)){
  653. $this->success('未找到工艺资料');
  654. }
  655. $data = [];
  656. foreach ($param as $key=>$value){
  657. foreach ($processList as $k=>$v){
  658. if ($value['UniqId'] = $v['UniqId']){
  659. $data[$key] = $v;
  660. $data[$key]['Gy0_gxh'] = $value['gxh'];
  661. $data[$key]['Gy0_gdbh'] = $value['workOrder'];
  662. $data[$key]['UniqId'] = $lastUniqId + $key + 1;
  663. }
  664. }
  665. }
  666. $res = \db('工单_工艺资料')->where(['Gy0_gdbh'=>$param[0]['workOrder']])->delete();
  667. if ($res !== false){
  668. $result = \db('工单_工艺资料')->insertAll($data);
  669. if ($result !== false){
  670. $this->success('成功');
  671. }else{
  672. $this->error('失败');
  673. }
  674. }else{
  675. $this->error('失败');
  676. }
  677. }
  678. /**
  679. * U8工单列表
  680. * @ApiMethod (GET)
  681. * @param void
  682. * @return void
  683. * @throws \think\db\exception\DataNotFoundException
  684. * @throws \think\db\exception\ModelNotFoundException
  685. * @throws \think\exception\DbException
  686. */
  687. public function U8workOrder()
  688. {
  689. if ($this->request->isGet() === false){
  690. $this->error('请求错误');
  691. }
  692. $param = $this->request->param();
  693. if (empty($param)){
  694. $this->error('参数错误');
  695. }
  696. $filed = 'rtrim(Gd_gdbh) as 工单编号,rtrim(行号) as 行号,rtrim(Gd_客户代号) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
  697. rtrim(成品代号) as 成品代号,rtrim(成品名称) as 成品名称,rtrim(Mod_rq) as 获取日期,rtrim(Uniqid) as 序号';
  698. $list = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field($filed)->select();
  699. if (empty($list)){
  700. $this->success('未找到工单');
  701. }
  702. $this->success('成功',$list);
  703. }
  704. /**
  705. * U8工单资料删除
  706. * @param string $workOrder 工单编号
  707. * @return void
  708. * @throws \think\Exception
  709. * @throws \think\exception\PDOException
  710. */
  711. public function U8DataCorrection()
  712. {
  713. if($this->request->isGet() === false){
  714. $this->error('请求错误');
  715. }
  716. $workOrder = input('Uniqid');
  717. if (empty($workOrder)){
  718. $this->error('参数错误');
  719. }
  720. $data = [];
  721. if (strpos($workOrder,',')){
  722. $data = explode(',',$workOrder);
  723. }else{
  724. $data[0] = $workOrder;
  725. }
  726. $res = \db('工单_基本资料')->where('Uniqid','in',$data)->delete();
  727. if ($res !== false){
  728. $this->success('成功');
  729. }else{
  730. $this->error('失败');
  731. }
  732. }
  733. /**
  734. * 产品废检系数调整->质检工艺数据获取
  735. * @ApiMethod (GET)
  736. * @param string $workOrder 工单编号
  737. * @return void
  738. * @throws \think\db\exception\DataNotFoundException
  739. * @throws \think\db\exception\ModelNotFoundException
  740. * @throws \think\exception\DbException
  741. */
  742. public function TestCoefficient()
  743. {
  744. if ($this->request->isGet() === false){
  745. $this->error('请求错误');
  746. }
  747. $workOrder = input('workOrder');
  748. if (empty($workOrder)){
  749. $this->error('参数错误');
  750. }
  751. $where = [
  752. 'Gy0_gdbh' => $workOrder,
  753. 'Gy0_gxmc' => ['like','%检%']
  754. ];
  755. $filed = 'rtrim(Gy0_gdbh) as gdbh,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(人工检_正品板) as 人工正品板,
  756. rtrim(人工检_次品板) as 人工次品板,rtrim(人工检_废检) as 人工废检,rtrim(机检_正品板) as 机检正品板,rtrim(机检_次品板) as 机检次品板,
  757. rtrim(机检_废检) as 机检废检,rtrim(Gy0_sbbh) as 设备编号,rtrim(Uniqid) as Uniqid';
  758. $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
  759. if (empty($list)){
  760. $this->success('未找到该工单工艺');
  761. }
  762. $name = \db('工单_基本资料')
  763. ->where('Gd_gdbh',$workOrder)
  764. ->field('rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_khmc) as 客户名称,rtrim(Gd_cpmc) as 产品名称')
  765. ->find();
  766. if (empty($name)){
  767. $this->success('未找到该工单');
  768. }
  769. foreach ($list as $key=>$value){
  770. if ($value['yjno']<10){
  771. $value['yjno'] = '0'.$value['yjno'];
  772. }
  773. if ($value['gxh']<10){
  774. $value['gxh'] = '0'.$value['gxh'];
  775. }
  776. $list[$key]['印件工序及工艺'] = $value['gdbh'].'-'.$value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
  777. unset($list[$key]['gdbh'],$list[$key]['yjno'],$list[$key]['gxmc']);
  778. $list[$key]['产品编号'] = $name['产品代号'];
  779. $list[$key]['产品名称'] = $name['产品名称'];
  780. $list[$key]['客户名称'] = $name['客户名称'];
  781. }
  782. $this->success('成功',$list);
  783. }
  784. /**
  785. * 产品质检系数调整->系数修改
  786. * @ApiMethod (GET)
  787. * @param string $workorder 工单编号
  788. * @param string $processCode 工序号
  789. * @param float $code1 人工正品板
  790. * @param float $code2 人工次品板
  791. * @param float $code3 人工废检
  792. * @param float $code4 机检正品板
  793. * @param float $code5 机检次品板
  794. * @param float $code6 机检废检
  795. * @return void
  796. * @throws \think\Exception
  797. * @throws \think\exception\PDOException
  798. */
  799. public function TestCoefficientEdit()
  800. {
  801. if (Request::instance()->isPost() === false){
  802. $this->error('请求错误');
  803. }
  804. $workOrder = input('workOrder');
  805. $processCode = input('processCode');
  806. $row = [
  807. '人工检_正品板' => input('code1'),
  808. '人工检_次品板' => input('code2'),
  809. '人工检_废检' => input('code3'),
  810. '机检_正品板' => input('code4'),
  811. '机检_次品板' => input('code5'),
  812. '机检_废检' => input('code6'),
  813. ];
  814. if (empty($workOrder) || empty($processCode)){
  815. $this->error('参数错误');
  816. }
  817. $where = [
  818. 'Gy0_gdbh' => $workOrder,
  819. 'Gy0_gxh' => $processCode
  820. ];
  821. $sql = \db('工单_工艺资料')->where($where)->fetchSql(true)->update($row);
  822. $res = Db::query($sql);
  823. if ($res !== false){
  824. $this->success('成功');
  825. }else{
  826. $this->error('失败');
  827. }
  828. }
  829. /**
  830. * 修正工单核算参数->数据获取
  831. * @ApiMethod (GET)
  832. * @param string $workOrder 工单编号
  833. * @return void
  834. * @throws \think\db\exception\DataNotFoundException
  835. * @throws \think\db\exception\ModelNotFoundException
  836. * @throws \think\exception\DbException
  837. */
  838. public function AccountingParameter()
  839. {
  840. if ($this->request->isGet() === false){
  841. $this->error('请求错误');
  842. }
  843. $workOrder = input('workOrder');
  844. if (empty($workOrder)){
  845. $this->error('参数错误');
  846. }
  847. $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,
  848. rtrim(Gy0_sbbh) as 参照设备,rtrim(工价系数) as 难度系数,rtrim(Gy0_shdh) as 损耗代号,rtrim(Gy0_Rate0) as 基础损耗,rtrim(Gy0_Rate1) as 损耗率,
  849. rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Gy0_ms) as 计损色数,rtrim(损耗系数) as 损耗系数,rtrim(UniqId) as UniqId';
  850. $list = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->field($field)->select();
  851. if (empty($list)){
  852. $this->success('未找到该工单工艺资料');
  853. }
  854. foreach ($list as $key=>$value){
  855. if ($value['yjno']<10){
  856. $value['yjno'] = '0'.$value['yjno'];
  857. }
  858. if ($value['gxh']<10){
  859. $value['gxh'] = '0'.$value['gxh'];
  860. }
  861. $list[$key]['印件号及工序名称'] = $value['yjno'].'-'.$value['gxh'].$value['gxmc'].'('.$value['add_gxmc'].')';
  862. unset($list[$key]['yjno'],$list[$key]['gxmc'],$list[$key]['add_gxmc']);
  863. }
  864. $this->success('成功',$list);
  865. }
  866. /**
  867. * 修正工单核算参数->参数修改
  868. * @ApiMethod (POST)
  869. * @param void
  870. * @return void
  871. * @throws \think\Exception
  872. * @throws \think\db\exception\DataNotFoundException
  873. * @throws \think\db\exception\ModelNotFoundException
  874. * @throws \think\exception\DbException
  875. * @throws \think\exception\PDOException
  876. */
  877. public function AccountingParameterEdit()
  878. {
  879. if (Request::instance()->isPost() === false){
  880. $this->error('请求错误');
  881. }
  882. $param = Request::instance()->post();
  883. if (empty($param) || isset($param[0]['Uniqid']) === false){
  884. $this->error('参数错误');
  885. }
  886. $i = 0;
  887. foreach ($param as $key=>$value){
  888. if (!empty($value['loss'])){
  889. $data = \db('dic_lzsh')->where('sys_bh',$value['loss'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
  890. }
  891. $row = [
  892. '工价系数' => $value['difficulty']?:'',
  893. 'Gy0_shdh' => $value['loss']?:'',
  894. '印刷方式' => $value['printMode']?:'',
  895. '版距' => $value['plate']?:'',
  896. 'Gy0_ms' => $value['chromatic']?:'',
  897. '损耗系数' => $value['wastage']?:'',
  898. 'Gy0_Rate0' => $data['rate0'],
  899. 'Gy0_Rate1' => $data['rate1']
  900. ];
  901. $sql = \db('工单_工艺资料')->where('Uniqid',$value['Uniqid'])->fetchSql(true)->update($row);
  902. $res = Db::query($sql);
  903. if ($res !== false){
  904. $i++;
  905. }
  906. }
  907. if ($i !== 0){
  908. $this->success('成功');
  909. }else{
  910. $this->error('失败');
  911. }
  912. }
  913. /**
  914. * 印件资料修改
  915. * @ApiMethod (POST)
  916. * @param void
  917. * @return void
  918. * @throws \think\Exception
  919. * @throws \think\exception\PDOException
  920. */
  921. public function PrintedEdit()
  922. {
  923. if (Request::instance()->isPost() === false){
  924. $this->error('请求错误');
  925. }
  926. $param = Request::instance()->post();
  927. if (empty($param) || isset($param['Uniqid']) === false){
  928. $this->error('参数错误');
  929. }
  930. $data = [
  931. 'yj_Yjno' => isset($param['yjno'])?$param['yjno']:'',
  932. 'yj_Yjdh' => isset($param['yjdh'])?$param['yjdh']:'',
  933. 'yj_yjmc' => isset($param['yjmc'])?$param['yjmc']:'',
  934. 'yj_zzdh' => isset($param['zzdh'])?$param['zzdh']:'',
  935. 'yj_zzdh1' => isset($param['zzdh1'])?$param['zzdh1']:'',
  936. 'yj_zzdh2' => isset($param['zzdh2'])?$param['zzdh2']:'',
  937. 'yj_zzdh3' => isset($param['zzdh3'])?$param['zzdh3']:'',
  938. 'yj_zzdh4' => isset($param['zzdh4'])?$param['zzdh4']:'',
  939. 'yj_zzmc' => isset($param['zzmc'])?$param['zzmc']:'',
  940. 'yj_zzmc1' => isset($param['zzmc1'])?$param['zzmc1']:'',
  941. 'yj_zzmc2' => isset($param['zzmc2'])?$param['zzmc2']:'',
  942. 'yj_zzmc3' => isset($param['zzmc3'])?$param['zzmc3']:'',
  943. 'yj_zzmc4' => isset($param['zzmc4'])?$param['zzmc4']:'',
  944. 'yj_成品数量' => isset($param['cpsl'])?$param['cpsl']:'',
  945. 'yj_实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
  946. 'yj_平张投料' => isset($param['pztl'])?$param['pztl']:'',
  947. 'yj_tlgg' => isset($param['tlgg'])?$param['tlgg']:'',
  948. 'yj_klgg' => isset($param['klgg'])?$param['klgg']:'',
  949. 'Yj_核算规格' => isset($param['hsgg'])?$param['hsgg']:'',
  950. 'yj_ks' => isset($param['ks'])?$param['ks']:'',
  951. 'yj_ls' => isset($param['ls'])?$param['ls']:'',
  952. 'yj_desc' => isset($param['desc'])?$param['desc']:'',
  953. ];
  954. $sql = \db('工单_印件资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($data);
  955. $res = Db::query($sql);
  956. if ($res !== false){
  957. $this->success('成功');
  958. }else{
  959. $this->error('失败');
  960. }
  961. }
  962. /**
  963. * 工艺资料修改
  964. * @ApiMethod (POST)
  965. * @param void
  966. * @return void
  967. * @throws \think\Exception
  968. * @throws \think\db\exception\DataNotFoundException
  969. * @throws \think\db\exception\ModelNotFoundException
  970. * @throws \think\exception\DbException
  971. * @throws \think\exception\PDOException
  972. */
  973. public function ProcessDetailEdit()
  974. {
  975. if (Request::instance()->isPost() === false){
  976. $this->error('请求错误');
  977. }
  978. $param = Request::instance()->post();
  979. if (empty($param) || isset($param['UniqId']) === false){
  980. $this->error('参数错误');
  981. }
  982. if (empty($param['shdh'])){
  983. $rate['rate0'] = 0;
  984. $rate['rate1'] = 0;
  985. }else{
  986. $rate = \db('dic_lzsh')->where('sys_bh',$param['shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
  987. }
  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']:0,
  993. 'Gy0_Rate1' => isset($rate['rate1'])?$rate['rate1']:0,
  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. ->join('产品_工艺资料 c', 'a.成品代号 = c.Gy0_cpdh')
  1895. ->join('产品_印件资料 d', 'a.成品代号 = d.yj_cpdh')
  1896. ->where(function($query) use ($param) {
  1897. $query->where('a.Gd_gdbh', 'like', '%'.$param['search'].'%')
  1898. ->whereOr('a.成品名称', 'like', '%'.$param['search'].'%');
  1899. })
  1900. ->where(function($query) {
  1901. $query->where('c.Gy0_cpdh', '<>', '')
  1902. ->where('d.yj_cpdh', '<>', '')
  1903. ->where('b.状态', 'not like', '%停用%')
  1904. ->where('b.产品名称', 'not like', '%停用%');
  1905. })
  1906. ->group('a.Gd_gdbh')
  1907. ->order('a.Uniqid desc')
  1908. ->select();
  1909. if (empty($list)){
  1910. $this->success('未找到工单资料');
  1911. }else{
  1912. $this->success('成功',$list);
  1913. }
  1914. }
  1915. /**
  1916. * 引用产品印件、工艺资料
  1917. * @return void
  1918. * @throws \think\db\exception\BindParamException
  1919. * @throws \think\db\exception\DataNotFoundException
  1920. * @throws \think\db\exception\ModelNotFoundException
  1921. * @throws \think\exception\DbException
  1922. * @throws \think\exception\PDOException
  1923. */
  1924. public function WorkOrderDetailListCope()
  1925. {
  1926. if (Request::instance()->isPost() === false){
  1927. $this->error('请求错误');
  1928. }
  1929. $param = Request::instance()->post();
  1930. if (empty($param['workorder']) || empty($param['productCode']) || empty($param['option'])){
  1931. $this->error('参数错误');
  1932. }
  1933. //引用工艺资料
  1934. $processWhere = [
  1935. 'Gy0_方案' => $param['option'],
  1936. 'Gy0_cpdh' => $param['productCode']
  1937. ];
  1938. $ProcessList = \db('产品_工艺资料')
  1939. ->where($processWhere)
  1940. ->select();
  1941. if (empty($ProcessList)){
  1942. $this->error('未找到产品工艺资料');
  1943. }
  1944. $ProcesslastId = \db('工单_工艺资料')->order('UniqId desc')->value('rtrim(UniqId)');
  1945. foreach ($ProcessList as $key=>$value){
  1946. $ProcessList[$key]['Gy0_gdbh'] = $param['workorder'];
  1947. $ProcessList[$key]['Gy0_gxmc'] = $value['gy0_gxmc'];
  1948. $ProcessList[$key]['Gy0_SITE'] = $value['Gy0_site'];
  1949. $ProcessList[$key]['Gy0_ks'] = $value['Gy0_Ks'];
  1950. $ProcessList[$key]['Gy0_ms'] = $value['Gy0_Ms'];
  1951. $ProcessList[$key]['Gy0_oil'] = $value['Gy0_Oil'];
  1952. $ProcessList[$key]['Gy0_sj1'] = '1900-01-01 00:00:00';
  1953. $ProcessList[$key]['Gy0_sj2'] = '1900-01-01 00:00:00';
  1954. $ProcessList[$key]['UniqId'] = $ProcesslastId + $key + 1;
  1955. $ProcessList[$key]['PD_WG'] = '1900-01-01 00:00:00';
  1956. $ProcessList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
  1957. $ProcessList[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
  1958. 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']);
  1959. }
  1960. //引用印件资料
  1961. $PrintList = \db('产品_印件资料')
  1962. ->where('yj_cpdh',$param['productCode'])
  1963. ->select();
  1964. if (empty($PrintList)){
  1965. $this->error('未找到印件资料');
  1966. }
  1967. $PrintLastId = \db('工单_印件资料')->order('Uniqid desc')->value('rtrim(Uniqid)');
  1968. foreach ($PrintList as $key => $value){
  1969. $PrintList[$key]['Yj_Gdbh'] = $param['workorder'];
  1970. $PrintList[$key]['yj_Yjno'] = $value['yj_yjno'];
  1971. $PrintList[$key]['yj_Yjdh'] = $value['yj_yjdh'];
  1972. $PrintList[$key]['Sys_id'] = $value['sys_id'];
  1973. $PrintList[$key]['Uniqid'] = $PrintLastId + $key + 1;
  1974. $PrintList[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
  1975. $PrintList[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
  1976. 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']);
  1977. }
  1978. //插入数据
  1979. $processSql = \db('工单_工艺资料')->fetchSql(true)->insertAll($ProcessList);
  1980. $processRes = \db()->query($processSql);
  1981. if ($processRes === false){
  1982. $this->error('插入工艺资料失败');
  1983. }
  1984. $printSql = \db('工单_印件资料')->fetchSql(true)->insertAll($PrintList);
  1985. $printRes = \db()->query($printSql);
  1986. if ($printRes === false){
  1987. $this->error('插入印件资料失败');
  1988. }
  1989. $this->success('成功');
  1990. }
  1991. /**
  1992. * 引用产品印件、工艺资料->信息获取
  1993. * @return void
  1994. * @throws \think\db\exception\DataNotFoundException
  1995. * @throws \think\db\exception\ModelNotFoundException
  1996. * @throws \think\exception\DbException
  1997. */
  1998. public function ProductCopeDetail()
  1999. {
  2000. if ($this->request->isGet() === false){
  2001. $this->error('请求错误');
  2002. }
  2003. $param = $this->request->param();
  2004. if (empty($param['workorder'])){
  2005. $this->error('参数错误');
  2006. }
  2007. $list = \db('工单_基本资料')
  2008. ->alias('a')
  2009. ->field([
  2010. 'rtrim(a.Gd_gdbh)' => '工单编号',
  2011. 'rtrim(b.客户编号)' => '客户编号',
  2012. 'rtrim(b.客户名称)' => '客户名称',
  2013. 'rtrim(b.产品编号)' => '产品编号',
  2014. 'rtrim(b.产品名称)' => '产品名称'
  2015. ])
  2016. ->join('产品_基本资料 b','a.成品代号 = b.产品编号')
  2017. ->where('a.Gd_gdbh',$param['workorder'])
  2018. ->find();
  2019. if (empty($list)){
  2020. $this->error('未找到工单信息');
  2021. }
  2022. $option = \db('产品_工艺资料')
  2023. ->field('rtrim(Gy0_方案) as 方案')
  2024. ->where('Gy0_cpdh',$list['产品编号'])
  2025. ->group('Gy0_方案')
  2026. ->select();
  2027. $list['方案'] = $option;
  2028. $this->success('成功',$list);
  2029. }
  2030. }