WorkOrder.php 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use Monolog\Handler\IFTTTHandler;
  5. use think\Db;
  6. use think\Request;
  7. /**
  8. * 工单资料管理
  9. */
  10. class WorkOrder extends Api
  11. {
  12. protected $noNeedLogin = ['*'];
  13. protected $noNeedRight = ['*'];
  14. /**
  15. * 工单资料菜单列表
  16. *
  17. * @ApiMethod (GET)
  18. * @return false|string
  19. * @throws \think\Exception
  20. */
  21. public function DataList()
  22. {
  23. if ($this->request->isGet() === false){
  24. $this->error('请求错误');
  25. }
  26. //获取总计划中数量和总生产中数量
  27. $productingAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','2-生产中')->cache(true)->count();
  28. $progressAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','3-计划中')->cache(true)->count();
  29. $data = [
  30. 'productingAll' => $productingAll,
  31. 'progressAll' => $progressAll
  32. ];
  33. // $sql = "SELECT
  34. // SUBSTRING( `成品代号`, 1, 4 ) AS prefix,
  35. // rtrim( Gd_khmc ) AS khmc,
  36. // RTRIM( `Gd_客户名称` ) AS 客户名称
  37. // FROM
  38. // `工单_基本资料`
  39. // WHERE
  40. // `成品代号` <> ''
  41. // AND ( `Gd_客户名称` <> '' OR Gd_khmc <> '' )
  42. // GROUP BY
  43. // prefix
  44. // ORDER BY
  45. // prefix";
  46. $sql = "SELECT DISTINCT
  47. (客户编号),rtrim(客户名称 ) as 客户名称
  48. FROM
  49. `产品_基本资料`
  50. GROUP BY
  51. 客户编号
  52. order by
  53. 客户编号";
  54. $list = \db()->query($sql);
  55. if (empty($list)){
  56. $this->success('',[]);
  57. }
  58. foreach ($list as $key=>$value){
  59. $value['客户编号'] = rtrim($value['客户编号']);
  60. if ($value['客户编号'] == '1098'){
  61. $value['客户名称'] = '打样专用';
  62. }
  63. //这条sql查出来的数据可能不对,试一下以下sql
  64. //SELECT COUNT(*) FROM `工单_基本资料` WHERE (SUBSTRING( `成品代号`, 1, 4 ) = '1001' OR (`Gd_客户名称`='浙江中烟' AND `Gd_客户代号` = '1001')) AND gd_statu = '2-生产中' AND `行号` = '1'
  65. $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
  66. $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
  67. $string = '';
  68. if ($productIng != 0){
  69. $string = $string."生产中:".$productIng;
  70. }
  71. if ($proGress != 0){
  72. $string = $string."计划中:".$proGress;
  73. }
  74. if ($string !== ''){
  75. // $data[$key] = $value['prefix'].'【'.$string.'】'.($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
  76. $data[$key] = $value['客户编号'].'【'.$string.'】'.$value['客户名称'];
  77. }else{
  78. // $data[$key] = $value['prefix'].($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
  79. $data[$key] = $value['客户编号'].$value['客户名称'];
  80. }
  81. }
  82. $this->success('成功',$data);
  83. }
  84. /**
  85. * 工单基本资料列表
  86. * @ApiMethod (GET)
  87. * @param string $limit 查询长度
  88. * @param string $Gd_khdh 客户代号
  89. * @param string $startTime 接单日期开始时间
  90. * @param string $endTime 接单日期结束时间
  91. * @return \think\response\Json
  92. * @throws \think\exception\DbException
  93. */
  94. public function WorkList()
  95. {
  96. if ($this->request->isGet() === false){
  97. $this->error('请求错误');
  98. }
  99. $search = input('search');
  100. $clientNumber = input('Gd_khdh');
  101. $startTime = input('start');
  102. $endTime = input('end');
  103. $page = input('page');
  104. $limit = input('limit');
  105. $where = [];
  106. if (!empty($clientNumber)){
  107. $where['成品代号'] = ['like',$clientNumber.'%'];
  108. }
  109. if (!empty($workOrder)){
  110. $where['Gd_gdbh'] = $workOrder;
  111. }
  112. if (!empty($productCode)){
  113. $where['Gd_cpdh'] = $productCode;
  114. }
  115. if (!empty($search)){
  116. $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$search.'%'];
  117. }
  118. if (!empty($startTime) && !empty($endTime)){
  119. $where['接单日期'] = ['between',[$startTime,$endTime]];
  120. }
  121. $total = \db('工单_基本资料')->where($where)->count();
  122. $list = \db('工单_基本资料')
  123. ->where($where)
  124. ->order('Gd_statu desc')
  125. ->limit(($page-1)*$limit,$limit)
  126. ->select();
  127. //工单基本资料数据整理
  128. $data = [];
  129. foreach ($list as $key=>$value){
  130. $data[$key] = [
  131. '工单编号' => rtrim($value['Gd_gdbh']),
  132. '生产分类' => rtrim($value['Gd_生产分类']),
  133. '销售订单号' => rtrim($value['销售订单号']),
  134. '产品代号' => rtrim($value['Gd_cpdh']),
  135. '产品名称' => rtrim($value['Gd_cpmc']),
  136. '订单数量' => rtrim($value['订单数量']),
  137. '单位' => rtrim($value['计量单位']),
  138. '折合大箱' => rtrim((int)$value['投料大箱']),
  139. '投料率' => rtrim($value['投料率']),
  140. '平均合格率' => '',
  141. '开单日期' => date('Y-m-d',strtotime(rtrim($value['接单日期']))),
  142. '交货日期' => date('Y-m-d',strtotime(rtrim($value['交货日期']))),
  143. '工单类型' => rtrim($value['Gd_lx']),
  144. '工单状态' => rtrim($value['gd_statu']),
  145. '当前生产工序' => '',
  146. '产量提交时间' => '',
  147. '建档用户' => rtrim($value['Sys_id']),
  148. '建档时间' => rtrim($value['Sys_rq']),
  149. '更新时间' => rtrim($value['Mod_rq']),
  150. 'Uniqid' => rtrim($value['Uniqid'])
  151. ];
  152. $number = \db('工单_工艺资料')->where('Gy0_gdbh',$data[$key]['工单编号'])->count();
  153. if ($number === 0){
  154. $data[$key]['status'] = '*';
  155. }else{
  156. $data[$key]['status'] = '';
  157. }
  158. }
  159. $this->success('成功',['data'=>$data,'total'=>$total]);
  160. }
  161. /**
  162. * 工单详情
  163. * @ApiMethod (GET)
  164. * @param void
  165. * @return void
  166. * @throws \think\db\exception\DataNotFoundException
  167. * @throws \think\db\exception\ModelNotFoundException
  168. * @throws \think\exception\DbException
  169. */
  170. public function workOrderListDetail()
  171. {
  172. if ($this->request->isGet() === false){
  173. $this->error('请求错误');
  174. }
  175. $Gd_gdbh = input('Gd_gdbh');
  176. if (empty($Gd_gdbh)){
  177. $this->error('参数错误');
  178. }
  179. $data = [];
  180. //印件资料
  181. $printList = \db('工单_印件资料')
  182. ->where('Yj_Gdbh',$Gd_gdbh)
  183. // ->cache(true,84600)
  184. ->select();
  185. if (!empty($printList)){
  186. foreach ($printList as $key=>$value){
  187. $data['printList'][$key] = [
  188. '印件号' => rtrim($value['yj_Yjno']),
  189. '印件代号' => rtrim($value['yj_Yjdh']),
  190. '印件名称' => rtrim($value['yj_yjmc']),
  191. '纸张代号' => rtrim($value['yj_zzdh']),
  192. '纸张名称' => rtrim($value['yj_zzmc']),
  193. '投料规格' => rtrim($value['yj_tlgg']),
  194. '平张投料' => rtrim($value['yj_平张投料']),
  195. '开料规格' => rtrim($value['yj_klgg']),
  196. '开数*联数' => rtrim($value['yj_ks']).'*'.rtrim($value['yj_ls']),
  197. '建档用户' => rtrim($value['Sys_id']),
  198. '建档时间' => rtrim($value['Sys_rq']),
  199. '更新时间' => rtrim($value['Mod_rq']),
  200. 'zzdh1' => rtrim($value['yj_zzdh1']),
  201. 'zzdh2' => rtrim($value['yj_zzdh2']),
  202. 'zzdh3' => rtrim($value['yj_zzdh3']),
  203. 'zzdh4' => rtrim($value['yj_zzdh4']),
  204. 'zzmc1' => rtrim($value['yj_zzmc1']),
  205. 'zzmc2' => rtrim($value['yj_zzmc2']),
  206. 'zzmc3' => rtrim($value['yj_zzmc3']),
  207. 'zzmc4' => rtrim($value['yj_zzmc4']),
  208. '订单数量' => rtrim($value['yj_成品数量']),
  209. '万小张' => rtrim($value['yj_实际投料']),
  210. '开数' => rtrim($value['yj_ks']),
  211. '联数' => rtrim($value['yj_ls']),
  212. '核算规格' => rtrim($value['Yj_核算规格']),
  213. '备注' => rtrim($value['yj_desc']),
  214. 'Uniqid' => rtrim($value['Uniqid'])
  215. ];
  216. }
  217. }else{
  218. $data['printList'] = [];
  219. }
  220. //工艺资料
  221. $processList = \db('工单_工艺资料')
  222. ->where('Gy0_gdbh',$Gd_gdbh)
  223. // ->cache(true,84600)
  224. ->select();
  225. if (!empty($processList)){
  226. foreach ($processList as $key=>$value){
  227. if ($value['Gy0_yjno']<10){
  228. $value['Gy0_yjno'] = '0'.$value['Gy0_yjno'];
  229. }
  230. if ($value['Gy0_gxh']<10){
  231. $value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
  232. }
  233. if ((int)$value['Gy0_计划损耗'] !== 0){
  234. $number = round(((int)$value['Gy0_计划损耗']/(int)($value['Gy0_计划接货数']/$value['Gy0_ls'])),2).'%';
  235. }else{
  236. $number = 0;
  237. }
  238. if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
  239. $status = '已完工';
  240. }else{
  241. $status = '未完工';
  242. }
  243. $data['processList'][$key] = [
  244. '重点工序' => rtrim($value['重点工序']),
  245. '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
  246. '备选工序' => rtrim($value['备选工序']),
  247. '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
  248. '计划产量' => (int)($value['Gy0_计划接货数']/$value['Gy0_ls']),
  249. '基础损耗' => rtrim($value['Gy0_Rate0']),
  250. '损耗率' => rtrim($value['Gy0_Rate1']),
  251. '报废定额' => rtrim($value['Gy0_计划损耗']),
  252. '允损比例' => $number,
  253. '难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
  254. '损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
  255. '人工检_次品板' => (int)$value['人工检_次品板']=0?'':$value['人工检_次品板'],
  256. '人工检_废检' => (int)$value['人工检_废检']=0?'':$value['人工检_废检'],
  257. '机检_正品板' => (int)$value['机检_正品板']=0?'':$value['机检_正品板'],
  258. '机检_次品板' => (int)$value['机检_次品板']=0?'':$value['机检_次品板'],
  259. '机检_废检' => (int)$value['机检_废检']=0?'':$value['机检_废检'],
  260. '开数*联数' => rtrim($value['Gy0_ks']).'*'.rtrim($value['Gy0_ls']),
  261. '备注' => isset($value['工序备注'])?rtrim($value['工序备注']):'',
  262. '印刷方式' => isset($value['印刷方式'])?rtrim($value['印刷方式']):'',
  263. '版距' => isset($value['版距'])?rtrim($value['版距']):'',
  264. '建档用户' => rtrim($value['Sys_id']),
  265. '建档日期' => isset($value['Sys_rq'])?rtrim($value['Sys_rq']):'',
  266. '更新时间' => isset($value['Mod_rq'])?rtrim($value['Mod_rq']):'',
  267. '车间名称' => rtrim($value['Gy0_SITE']),
  268. '质量要求' => rtrim($value['质量要求']),
  269. '质量隐患' => rtrim($value['质量隐患']),
  270. '开数' => rtrim($value['Gy0_ks']),
  271. '联数' => rtrim($value['Gy0_ls']),
  272. 'UniqId' => rtrim($value['UniqId']),
  273. 'shdh' => rtrim($value['Gy0_shdh']),
  274. '辅助工时' => rtrim($value['Gy0_辅助工时']),
  275. '小时产能' => rtrim($value['Gy0_小时产能']),
  276. 'status' => $status
  277. ];
  278. }
  279. }else{
  280. $data['processList'] = [];
  281. }
  282. //BOM资料
  283. $field = 'rtrim(BOM_方案) as 方案,rtrim(BOM_物料编码) as 物料编号,rtrim(BOM_物料名称) as 物料名称,BOM_投料单位,
  284. BOM_投入数,BOM_产出数,BOM_产出单位,rtrim(BOM_计划用量) as 计划用量,rtrim(Sys_ID) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间';
  285. $bomList = \db('工单_bom资料')
  286. ->where('BOM_工单编号',$Gd_gdbh)
  287. ->field($field)
  288. // ->cache(true,84600)
  289. ->select();
  290. if (!empty($bomList)){
  291. foreach ($bomList as $key=>$value){
  292. $bomList[$key]['消耗定量'] = rtrim($value['BOM_投入数']).rtrim($value['BOM_投料单位']).'/'.rtrim($value['BOM_产出数']).rtrim($value['BOM_产出单位']);
  293. unset($bomList[$key]['BOM_投料单位'],$bomList[$key]['BOM_投入数'],$bomList[$key]['BOM_产出数'],$bomList[$key]['BOM_产出单位']);
  294. $bomList[$key]['计划用量'] = rtrim((float)$value['计划用量']);
  295. }
  296. $data['BOM'] = $bomList;
  297. }else{
  298. $data['BOM'] = [];
  299. }
  300. $this->success('成功',$data);
  301. }
  302. /**
  303. * 编辑页面展示
  304. * @ApiMethod (GET)
  305. * @param string $workOrder 工单编号
  306. * @return void
  307. * @throws \think\db\exception\DataNotFoundException
  308. * @throws \think\db\exception\ModelNotFoundException
  309. * @throws \think\exception\DbException
  310. */
  311. public function DataCorrection()
  312. {
  313. if ($this->request->isGet() === false){
  314. $this->error('请求错误');
  315. }
  316. $workOrder = input('Gd_gdbh');
  317. if (empty($workOrder)){
  318. $this->error('参数错误');
  319. }
  320. $field = 'rtrim(Gd_lx) as 重点工单,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_生产分类) as 生产类型,rtrim(Gd_khdh) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
  321. rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(开单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
  322. rtrim(投料率) as 投料率,rtrim(实际投料) as 万小张,rtrim(计量单位) as 单位,rtrim(投料大箱) as 投料大箱,rtrim(排产时库存) as 库存大箱,rtrim(警语版面) as 警语版面,
  323. rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注,rtrim(Uniqid) as Uniqid';
  324. $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
  325. if (empty($list)){
  326. $this->error('未找到该工单信息');
  327. }
  328. $printData = \db('工单_印件资料')
  329. ->where('Yj_Gdbh',$workOrder)
  330. ->field('rtrim(yj_yjmc) as 印件名称,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_平张投料) as 平张投料,rtrim(Uniqid) as id')
  331. ->cache(true,84600)
  332. ->find();
  333. if (empty($printData)){
  334. $this->error('未找到该工单印件资料');
  335. }
  336. $list['印件名称'] = $printData['印件名称'];
  337. $list['印件代号'] = $printData['印件代号'];
  338. $list['平张投料'] = $printData['平张投料'];
  339. $list['印件ID'] = $printData['id'];
  340. $this->success('成功',$list);
  341. }
  342. /**
  343. * 工单资料修改
  344. * @ApiMethod (POST)
  345. * @param void
  346. * @return void
  347. * @throws \think\Exception
  348. * @throws \think\exception\PDOException
  349. */
  350. public function WorkOrderEdit()
  351. {
  352. if (Request::instance()->isPost() === false){
  353. $this->error('请求错误');
  354. }
  355. $param = Request::instance()->post();
  356. if (empty($param) || isset($param['Uniqid']) === false){
  357. $this->error('参数错误');
  358. }
  359. $row = [
  360. 'Gd_lx' => isset($param['lx'])?$param['lx']:'',
  361. '开单日期' => isset($param['kdrq'])?$param['kdrq']:'',
  362. 'Gd_gdbh' => isset($param['gdbh'])?$param['gdbh']:'',
  363. 'Gd_生产分类' => isset($param['scfl'])?$param['scfl']:'',
  364. 'Gd_客户代号' => isset($param['khdh'])?$param['khdh']:'',
  365. 'Gd_客户名称' => isset($param['khmc'])?$param['khmc']:'',
  366. '成品代号' => isset($param['cpdh'])?$param['cpdh']:'',
  367. '成品名称' => isset($param['cpmc'])?$param['cpmc']:'',
  368. '订单数量' => isset($param['ddsl'])?$param['ddsl']:'',
  369. '交货日期' => isset($param['jhrq'])?$param['jhrq']:'',
  370. '投料率' => isset($param['tll'])?$param['tll']:'',
  371. '计划投料' => isset($param['jhtl'])?$param['jhtl']:'',
  372. '实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
  373. '计量单位' => isset($param['jldw'])?$param['jldw']:'',
  374. '投料大箱' => isset($param['tldx'])?$param['tldx']:'',
  375. '销售订单号' => isset($param['xsddh'])?$param['xsddh']:'',
  376. '警语版面' => isset($param['jymb'])?$param['jymb']:'',
  377. '产品版本号' => isset($param['bbh'])?$param['bbh']:'',
  378. '客户ERP编码' => isset($param['erp'])?$param['erp']:'',
  379. '码源数量' => isset($param['ymsl'])?$param['ymsl']:'',
  380. '进程备注' => isset($param['jcbz'])?$param['jcbz']:'',
  381. 'Gd_desc' => isset($param['desc'])?$param['desc']:'',
  382. '排产时库存' => isset($param['kc'])?$param['kc']:'',
  383. '平均合格率' => isset($param['avg'])?$param['avg']:'',
  384. ];
  385. $sql = \db('工单_基本资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($row);
  386. $res = Db::query($sql);
  387. $printSql = \db('工单_印件资料')
  388. ->where('Uniqid',$param['printID'])
  389. ->fetchSql(true)
  390. ->update(['yj_yjmc'=>$param['yjmc'],'yj_Yjdh'=>$param['yjdh'],'yj_平张投料'=>$param['jhtl']]);
  391. $printRes = Db::query($printSql);
  392. if ($res !== false && $printRes !== false){
  393. $this->success('成功');
  394. }else{
  395. $this->error('失败');
  396. }
  397. }
  398. /**
  399. * U8投料试算
  400. * @ApiMethod (GET)
  401. * @param string $processCode 产品编号
  402. * @return void
  403. * @throws \think\db\exception\DataNotFoundException
  404. * @throws \think\db\exception\ModelNotFoundException
  405. * @throws \think\exception\DbException
  406. */
  407. public function U8Trial()
  408. {
  409. if ($this->request->isGet() === false)
  410. {
  411. $this->error('请求错误');
  412. }
  413. $productCode = input('productCode');
  414. if (empty($productCode)){
  415. $this->error('参数错误');
  416. }
  417. $field = 'rtrim(Gy0_cpdh) as 产品代号,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  418. rtrim(Gy0_Ms) as 墨色数,rtrim(Gy0_shdh) as 损耗代号,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as 加工联数';
  419. $list = \db('产品_工艺资料')->where('Gy0_cpdh',$productCode)->field($field)->select();
  420. if (empty($list)){
  421. $this->success('未找到该产品工序');
  422. }
  423. foreach ($list as $key=>$value){
  424. $data = \db('dic_lzsh')->where('sys_bh',$value['损耗代号'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->cache(true)->find();
  425. $list[$key]['调机损耗'] = isset($data['rate0'])?$data['rate0']:'';
  426. $list[$key]['运行损耗率'] = isset($data['rate1'])?$data['rate1']:'';
  427. if ($value['add_gxmc'] !== ''){
  428. $list[$key]['工序名称'] = $value['gxmc'].'【'.$value['add_gxmc'].'】';
  429. }else{
  430. $list[$key]['工序名称'] = $value['gxmc'];
  431. }
  432. unset($list[$key]['gxmc'],$list[$key]['add_gxmc']);
  433. }
  434. $this->success('成功',$list);
  435. }
  436. /**
  437. * 引用产品资料->获取产品资料
  438. * @ApiMethod (GET)
  439. * @param string $workOrder 工单编号
  440. * @return void
  441. * @throws \think\db\exception\DataNotFoundException
  442. * @throws \think\db\exception\ModelNotFoundException
  443. * @throws \think\exception\DbException
  444. */
  445. public function ProductInformation()
  446. {
  447. if ($this->request->isGet() === false)
  448. {
  449. $this->error('请求错误');
  450. }
  451. $workOrder = input('workOrder');
  452. if (empty($workOrder)){
  453. $this->error('参数错误');
  454. }
  455. $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_客户名称) as 客户名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称';
  456. $Detail = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();
  457. if (empty($Detail)){
  458. $this->success('未找到工单信息');
  459. }
  460. $Detail['客户代号'] = substr($Detail['产品代号'],0,4);
  461. $this->success('成功',$Detail);
  462. }
  463. /**
  464. * 引用产品资料->复制产品工艺资料
  465. * @ApiMethod (POST)
  466. * @param string $oldWorkOrder 被复制工单编号
  467. * @param string $newWorkOrder 复制工单编号
  468. * @return void
  469. * @throws \think\Exception
  470. * @throws \think\db\exception\DataNotFoundException
  471. * @throws \think\db\exception\ModelNotFoundException
  472. * @throws \think\exception\DbException
  473. * @throws \think\exception\PDOException
  474. */
  475. public function ProductInformationEdit()
  476. {
  477. if (Request::instance()->isPost() === false)
  478. {
  479. $this->error('请求错误');
  480. }
  481. $oldWorkOrder = input('oldWorkOrder');
  482. $newWorkOrder = input('newWorkOrder');
  483. if (empty($oldWorkOrder) || empty($newWorkOrder))
  484. {
  485. $this->error('参数错误');
  486. }
  487. $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
  488. if ($lastId<10000000){
  489. $lastId = 10000000;
  490. }else{
  491. $lastId = $lastId + 1;
  492. }
  493. //获取原工单工艺资料
  494. $oldProcessData = \db('工单_工艺资料')->where('Gy0_gdbh',$newWorkOrder)->select();
  495. $ProsessUniqId = \db('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
  496. foreach ($oldProcessData as $k=>$v){
  497. $oldProcessData[$k]['Gy0_gdbh'] = $oldWorkOrder;
  498. $oldProcessData[$k]['Sys_id'] = '';
  499. $oldProcessData[$k]['UniqId'] = $lastId + $k;
  500. }
  501. if (\db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->find()){
  502. \db('工单_工艺资料')->where('Gy0_gdbh',$oldWorkOrder)->delete();
  503. }
  504. //获取原工单印件资料
  505. $lastUniqId = \db('工单_印件资料')->order('UniqId desc')->value('UniqId');
  506. if ($lastUniqId<1000000){
  507. $lastUniqId = 1000000;
  508. }else{
  509. $lastUniqId = $lastUniqId + 1;
  510. }
  511. $oldPrintData = \db('工单_印件资料')->where('Yj_Gdbh',$newWorkOrder)->select();
  512. $PrintUniqId = \db('工单_印件资料')->field('Uniqid')->order('Uniqid desc')->find();
  513. foreach ($oldPrintData as $k=>$v){
  514. $oldPrintData[$k]['Yj_Gdbh'] = $oldWorkOrder;
  515. $oldPrintData[$k]['Sys_id'] = '';
  516. $oldPrintData[$k]['Uniqid'] = $lastUniqId +$k +1;
  517. }
  518. if (\db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->find()){
  519. \db('工单_印件资料')->where('Yj_Gdbh',$oldWorkOrder)->delete();
  520. }
  521. //复制印件、工艺资料
  522. $ProcessSQL = \db('工单_工艺资料')->fetchSql(true)->insertAll($oldProcessData);
  523. $ProcessRes = Db::query($ProcessSQL);
  524. $PrintSQL = \db('工单_印件资料')->fetchSql(true)->insertAll($oldPrintData);
  525. $PrintRes = Db::query($PrintSQL);
  526. if ($ProcessRes !== false && $PrintRes !== false){
  527. $this->success('成功');
  528. }else{
  529. $this->error('失败');
  530. }
  531. }
  532. /**
  533. * 工艺流程调成->获取当前工单工艺资料
  534. * @ApiMethod (GET)
  535. * @param string $workorder 当前工单编号
  536. * @return void
  537. * @throws \think\db\exception\DataNotFoundException
  538. * @throws \think\db\exception\ModelNotFoundException
  539. * @throws \think\exception\DbException
  540. */
  541. public function ProcessFlow()
  542. {
  543. if ($this->request->isGet() === false){
  544. $this->error('请求错误');
  545. }
  546. $workOrder = input('workOrder');
  547. if (empty($workOrder)){
  548. $this->error('参数错误');
  549. }
  550. $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(成品代号) as 成品编号,rtrim(成品名称) as 成品名称')->find();
  551. if (empty($list)){
  552. $this->success('未找到工单信息');
  553. }
  554. $filed = 'rtrim(Gy0_方案) as 方案,rtrim(Gy0_yjno) as 印件号,rtrim(Gy0_gxh) as 工序号,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  555. rtrim(工价系数) as 工价系数,rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ks) as ks,rtrim(Gy0_ls) as ls,rtrim(工序备注) as 备注,rtrim(Gy0_SITE) as 车间,
  556. rtrim(Gy0_sbbh) as 设备编号,rtrim(Gy0_sbmc) as 设备名称,rtrim(Sys_id) as 建档用户,rtrim(Sys_rq) as 建档时间,rtrim(Mod_rq) as 更新时间,rtrim(UniqId) as UniqId';
  557. $process = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->cache(true,84600)->field($filed)->select();
  558. if (empty($process)){
  559. $this->error('未找到该工单工艺资料');
  560. }
  561. foreach ($process as $key=>$value){
  562. if (isset($value['add_gxmc'])){
  563. $process[$key]['工序名称'] = $value['gxmc'] . '【'.$value['add_gxmc'].'】';
  564. }else{
  565. $process[$key]['工序名称'] = $value['gxmc'];
  566. }
  567. $process[$key]['工价系数'] = (float)$value['工价系数'];
  568. $process[$key]['损耗系数'] = (float)$value['损耗系数'];
  569. $process[$key]['开数*联数'] = $value['ks'].'*'.$value['ls'];
  570. }
  571. $list['process'] = $process;
  572. $this->success('成功',$list);
  573. }
  574. /**
  575. * 参照工单列表获取
  576. * @ApiMethod (GET)
  577. * @param string $workOrder 工单编号
  578. * @param string $productCode 产品代号
  579. * @return void
  580. */
  581. public function ReferenceWorkOrder()
  582. {
  583. if ($this->request->isGet() === false){
  584. $this->error('请求错误');
  585. }
  586. $productCode = input('productCode');
  587. $workOrder = input('workOrder');
  588. if (empty($productCode) || empty($workOrder)){
  589. $this->error('参数错误');
  590. }
  591. $list = \db('工单_基本资料')->where('成品代号',$productCode)->distinct(true)->where('Gd_gdbh','<>',$workOrder)->column('Gd_gdbh');
  592. if (empty($list)){
  593. $this->success('未获取该产品其他工单信息');
  594. }
  595. $this->success('成功',$list);
  596. }
  597. /**
  598. * 工艺资料复制
  599. * @ApiMethod (POST)
  600. * @param string $oldWorkOrder 被复制工单编号
  601. * @param string $newWorkOrder 复制工单编号
  602. * @return void
  603. * @throws \think\Exception
  604. * @throws \think\db\exception\DataNotFoundException
  605. * @throws \think\db\exception\ModelNotFoundException
  606. * @throws \think\exception\DbException
  607. * @throws \think\exception\PDOException
  608. *
  609. */
  610. public function ProcessCopy()
  611. {
  612. if (Request::instance()->isPost() === false){
  613. $this->error('请求错误');
  614. }
  615. $param = Request::instance()->post();
  616. if (empty($param)){
  617. $this->error('参数错误');
  618. }
  619. $UniqId = [];
  620. $lastId = \db('工单_工艺资料')->field('rtrim(UniqId) as id')->order('UniqId desc')->find();
  621. if ($lastId['id']>10000000){
  622. $lastUniqId = $lastId['id'];
  623. }else{
  624. $lastUniqId = 10000000;
  625. }
  626. foreach ($param as $key=>$value){
  627. $UniqId[$key] = $value['UniqId'];
  628. }
  629. $processList = \db('工单_工艺资料')->where('UniqId','in',$UniqId)->select();
  630. if (empty($processList)){
  631. $this->success('未找到工艺资料');
  632. }
  633. $data = [];
  634. foreach ($param as $key=>$value){
  635. foreach ($processList as $k=>$v){
  636. if ($value['UniqId'] = $v['UniqId']){
  637. $data[$key] = $v;
  638. $data[$key]['Gy0_gxh'] = $value['gxh'];
  639. $data[$key]['Gy0_gdbh'] = $value['workOrder'];
  640. $data[$key]['UniqId'] = $lastUniqId + $key + 1;
  641. }
  642. }
  643. }
  644. $res = \db('工单_工艺资料')->where(['Gy0_gdbh'=>$param[0]['workOrder']])->delete();
  645. if ($res !== false){
  646. $result = \db('工单_工艺资料')->insertAll($data);
  647. if ($result !== false){
  648. $this->success('成功');
  649. }else{
  650. $this->error('失败');
  651. }
  652. }else{
  653. $this->error('失败');
  654. }
  655. }
  656. /**
  657. * U8工单列表
  658. * @ApiMethod (GET)
  659. * @param void
  660. * @return void
  661. * @throws \think\db\exception\DataNotFoundException
  662. * @throws \think\db\exception\ModelNotFoundException
  663. * @throws \think\exception\DbException
  664. */
  665. public function U8workOrder()
  666. {
  667. if ($this->request->isGet() === false){
  668. $this->error('请求错误');
  669. }
  670. $param = $this->request->param();
  671. if (empty($param)){
  672. $this->error('参数错误');
  673. }
  674. $filed = 'rtrim(Gd_gdbh) as 工单编号,rtrim(行号) as 行号,rtrim(Gd_客户代号) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
  675. rtrim(成品代号) as 成品代号,rtrim(成品名称) as 成品名称,rtrim(Mod_rq) as 获取日期,rtrim(Uniqid) as 序号';
  676. $list = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field($filed)->select();
  677. if (empty($list)){
  678. $this->success('未找到工单');
  679. }
  680. $this->success('成功',$list);
  681. }
  682. /**
  683. * U8工单资料删除
  684. * @param string $workOrder 工单编号
  685. * @return void
  686. * @throws \think\Exception
  687. * @throws \think\exception\PDOException
  688. */
  689. public function U8DataCorrection()
  690. {
  691. if($this->request->isGet() === false){
  692. $this->error('请求错误');
  693. }
  694. $workOrder = input('Uniqid');
  695. if (empty($workOrder)){
  696. $this->error('参数错误');
  697. }
  698. $data = [];
  699. if (strpos($workOrder,',')){
  700. $data = explode(',',$workOrder);
  701. }else{
  702. $data[0] = $workOrder;
  703. }
  704. $res = \db('工单_基本资料')->where('Uniqid','in',$data)->delete();
  705. if ($res !== false){
  706. $this->success('成功');
  707. }else{
  708. $this->error('失败');
  709. }
  710. }
  711. /**
  712. * 产品废检系数调整->质检工艺数据获取
  713. * @ApiMethod (GET)
  714. * @param string $workOrder 工单编号
  715. * @return void
  716. * @throws \think\db\exception\DataNotFoundException
  717. * @throws \think\db\exception\ModelNotFoundException
  718. * @throws \think\exception\DbException
  719. */
  720. public function TestCoefficient()
  721. {
  722. if ($this->request->isGet() === false){
  723. $this->error('请求错误');
  724. }
  725. $workOrder = input('workOrder');
  726. if (empty($workOrder)){
  727. $this->error('参数错误');
  728. }
  729. $where = [
  730. 'Gy0_gdbh' => $workOrder,
  731. 'Gy0_gxmc' => ['like','%检%']
  732. ];
  733. $filed = 'rtrim(Gy0_gdbh) as gdbh,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(人工检_正品板) as 人工正品板,
  734. rtrim(人工检_次品板) as 人工次品板,rtrim(人工检_废检) as 人工废检,rtrim(机检_正品板) as 机检正品板,rtrim(机检_次品板) as 机检次品板,
  735. rtrim(机检_废检) as 机检废检,rtrim(Gy0_sbbh) as 设备编号,rtrim(Uniqid) as Uniqid';
  736. $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
  737. if (empty($list)){
  738. $this->success('未找到该工单工艺');
  739. }
  740. $name = \db('工单_基本资料')
  741. ->where('Gd_gdbh',$workOrder)
  742. ->field('rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_khmc) as 客户名称,rtrim(Gd_cpmc) as 产品名称')
  743. ->find();
  744. if (empty($name)){
  745. $this->success('未找到该工单');
  746. }
  747. foreach ($list as $key=>$value){
  748. if ($value['yjno']<10){
  749. $value['yjno'] = '0'.$value['yjno'];
  750. }
  751. if ($value['gxh']<10){
  752. $value['gxh'] = '0'.$value['gxh'];
  753. }
  754. $list[$key]['印件工序及工艺'] = $value['gdbh'].'-'.$value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
  755. unset($list[$key]['gdbh'],$list[$key]['yjno'],$list[$key]['gxmc']);
  756. $list[$key]['产品编号'] = $name['产品代号'];
  757. $list[$key]['产品名称'] = $name['产品名称'];
  758. $list[$key]['客户名称'] = $name['客户名称'];
  759. }
  760. $this->success('成功',$list);
  761. }
  762. /**
  763. * 产品质检系数调整->系数修改
  764. * @ApiMethod (GET)
  765. * @param string $workorder 工单编号
  766. * @param string $processCode 工序号
  767. * @param float $code1 人工正品板
  768. * @param float $code2 人工次品板
  769. * @param float $code3 人工废检
  770. * @param float $code4 机检正品板
  771. * @param float $code5 机检次品板
  772. * @param float $code6 机检废检
  773. * @return void
  774. * @throws \think\Exception
  775. * @throws \think\exception\PDOException
  776. */
  777. public function TestCoefficientEdit()
  778. {
  779. if (Request::instance()->isPost() === false){
  780. $this->error('请求错误');
  781. }
  782. $workOrder = input('workOrder');
  783. $processCode = input('processCode');
  784. $row = [
  785. '人工检_正品板' => input('code1'),
  786. '人工检_次品板' => input('code2'),
  787. '人工检_废检' => input('code3'),
  788. '机检_正品板' => input('code4'),
  789. '机检_次品板' => input('code5'),
  790. '机检_废检' => input('code6'),
  791. ];
  792. if (empty($workOrder) || empty($processCode)){
  793. $this->error('参数错误');
  794. }
  795. $where = [
  796. 'Gy0_gdbh' => $workOrder,
  797. 'Gy0_gxh' => $processCode
  798. ];
  799. $sql = \db('工单_工艺资料')->where($where)->fetchSql(true)->update($row);
  800. $res = Db::query($sql);
  801. if ($res !== false){
  802. $this->success('成功');
  803. }else{
  804. $this->error('失败');
  805. }
  806. }
  807. /**
  808. * 修正工单核算参数->数据获取
  809. * @ApiMethod (GET)
  810. * @param string $workOrder 工单编号
  811. * @return void
  812. * @throws \think\db\exception\DataNotFoundException
  813. * @throws \think\db\exception\ModelNotFoundException
  814. * @throws \think\exception\DbException
  815. */
  816. public function AccountingParameter()
  817. {
  818. if ($this->request->isGet() === false){
  819. $this->error('请求错误');
  820. }
  821. $workOrder = input('workOrder');
  822. if (empty($workOrder)){
  823. $this->error('参数错误');
  824. }
  825. $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,
  826. rtrim(Gy0_sbbh) as 参照设备,rtrim(工价系数) as 难度系数,rtrim(Gy0_shdh) as 损耗代号,rtrim(Gy0_Rate0) as 基础损耗,rtrim(Gy0_Rate1) as 损耗率,
  827. rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Gy0_ms) as 计损色数,rtrim(损耗系数) as 损耗系数,rtrim(UniqId) as UniqId';
  828. $list = \db('工单_工艺资料')->where('Gy0_gdbh',$workOrder)->field($field)->select();
  829. if (empty($list)){
  830. $this->success('未找到该工单工艺资料');
  831. }
  832. foreach ($list as $key=>$value){
  833. if ($value['yjno']<10){
  834. $value['yjno'] = '0'.$value['yjno'];
  835. }
  836. if ($value['gxh']<10){
  837. $value['gxh'] = '0'.$value['gxh'];
  838. }
  839. $list[$key]['印件号及工序名称'] = $value['yjno'].'-'.$value['gxh'].$value['gxmc'].'('.$value['add_gxmc'].')';
  840. unset($list[$key]['yjno'],$list[$key]['gxmc'],$list[$key]['add_gxmc']);
  841. }
  842. $this->success('成功',$list);
  843. }
  844. /**
  845. * 修正工单核算参数->参数修改
  846. * @ApiMethod (POST)
  847. * @param void
  848. * @return void
  849. * @throws \think\Exception
  850. * @throws \think\db\exception\DataNotFoundException
  851. * @throws \think\db\exception\ModelNotFoundException
  852. * @throws \think\exception\DbException
  853. * @throws \think\exception\PDOException
  854. */
  855. public function AccountingParameterEdit()
  856. {
  857. if (Request::instance()->isPost() === false){
  858. $this->error('请求错误');
  859. }
  860. $param = Request::instance()->post();
  861. if (empty($param) || isset($param[0]['Uniqid']) === false){
  862. $this->error('参数错误');
  863. }
  864. $i = 0;
  865. foreach ($param as $key=>$value){
  866. if (!empty($value['loss'])){
  867. $data = \db('dic_lzsh')->where('sys_bh',$value['loss'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
  868. }
  869. $row = [
  870. '工价系数' => $value['difficulty']?:'',
  871. 'Gy0_shdh' => $value['loss']?:'',
  872. '印刷方式' => $value['printMode']?:'',
  873. '版距' => $value['plate']?:'',
  874. 'Gy0_ms' => $value['chromatic']?:'',
  875. '损耗系数' => $value['wastage']?:'',
  876. 'Gy0_Rate0' => $data['rate0'],
  877. 'Gy0_Rate1' => $data['rate1']
  878. ];
  879. $sql = \db('工单_工艺资料')->where('Uniqid',$value['Uniqid'])->fetchSql(true)->update($row);
  880. $res = Db::query($sql);
  881. if ($res !== false){
  882. $i++;
  883. }
  884. }
  885. if ($i !== 0){
  886. $this->success('成功');
  887. }else{
  888. $this->error('失败');
  889. }
  890. }
  891. /**
  892. * 印件资料修改
  893. * @ApiMethod (POST)
  894. * @param void
  895. * @return void
  896. * @throws \think\Exception
  897. * @throws \think\exception\PDOException
  898. */
  899. public function PrintedEdit()
  900. {
  901. if (Request::instance()->isPost() === false){
  902. $this->error('请求错误');
  903. }
  904. $param = Request::instance()->post();
  905. if (empty($param) || isset($param['Uniqid']) === false){
  906. $this->error('参数错误');
  907. }
  908. $data = [
  909. 'yj_Yjno' => isset($param['yjno'])?$param['yjno']:'',
  910. 'yj_Yjdh' => isset($param['yjdh'])?$param['yjdh']:'',
  911. 'yj_yjmc' => isset($param['yjmc'])?$param['yjmc']:'',
  912. 'yj_zzdh' => isset($param['zzdh'])?$param['zzdh']:'',
  913. 'yj_zzdh1' => isset($param['zzdh1'])?$param['zzdh1']:'',
  914. 'yj_zzdh2' => isset($param['zzdh2'])?$param['zzdh2']:'',
  915. 'yj_zzdh3' => isset($param['zzdh3'])?$param['zzdh3']:'',
  916. 'yj_zzdh4' => isset($param['zzdh4'])?$param['zzdh4']:'',
  917. 'yj_zzmc' => isset($param['zzmc'])?$param['zzmc']:'',
  918. 'yj_zzmc1' => isset($param['zzmc1'])?$param['zzmc1']:'',
  919. 'yj_zzmc2' => isset($param['zzmc2'])?$param['zzmc2']:'',
  920. 'yj_zzmc3' => isset($param['zzmc3'])?$param['zzmc3']:'',
  921. 'yj_zzmc4' => isset($param['zzmc4'])?$param['zzmc4']:'',
  922. 'yj_成品数量' => isset($param['cpsl'])?$param['cpsl']:'',
  923. 'yj_实际投料' => isset($param['sjtl'])?$param['sjtl']:'',
  924. 'yj_平张投料' => isset($param['pztl'])?$param['pztl']:'',
  925. 'yj_tlgg' => isset($param['tlgg'])?$param['tlgg']:'',
  926. 'yj_klgg' => isset($param['klgg'])?$param['klgg']:'',
  927. 'Yj_核算规格' => isset($param['hsgg'])?$param['hsgg']:'',
  928. 'yj_ks' => isset($param['ks'])?$param['ks']:'',
  929. 'yj_ls' => isset($param['ls'])?$param['ls']:'',
  930. 'yj_desc' => isset($param['desc'])?$param['desc']:'',
  931. ];
  932. $sql = \db('工单_印件资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($data);
  933. $res = Db::query($sql);
  934. if ($res !== false){
  935. $this->success('成功');
  936. }else{
  937. $this->error('失败');
  938. }
  939. }
  940. /**
  941. * 工艺资料修改
  942. * @ApiMethod (POST)
  943. * @param void
  944. * @return void
  945. * @throws \think\Exception
  946. * @throws \think\db\exception\DataNotFoundException
  947. * @throws \think\db\exception\ModelNotFoundException
  948. * @throws \think\exception\DbException
  949. * @throws \think\exception\PDOException
  950. */
  951. public function ProcessDetailEdit()
  952. {
  953. if (Request::instance()->isPost() === false){
  954. $this->error('请求错误');
  955. }
  956. $param = Request::instance()->post();
  957. if (empty($param) || isset($param['UniqId']) === false){
  958. $this->error('参数错误');
  959. }
  960. $rate = \db('dic_lzsh')->where('sys_bh',$param['shdh'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
  961. $data = [
  962. '重点工序' => isset($param['zdgx'])?$param['zdgx']:'',
  963. '备选工序' => isset($param['bxgx'])?$param['bxgx']:'',
  964. 'Gy0_sbbh' => isset($param['sbbh'])?$param['sbbh']:'',
  965. 'Gy0_Rate0' => isset($rate['rate0'])?$rate['rate0']:'',
  966. 'Gy0_Rate1' => isset($rate['rate1'])?$rate['rate1']:'',
  967. 'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
  968. '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
  969. '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
  970. 'Gy0_小时产能' => $param['xscn'],
  971. 'Mod_rq' => date('Y-m-d H:i:s',time()),
  972. ];
  973. $sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
  974. $res = Db::query($sql);
  975. $status = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->field('rtrim(gd_statu) as status')->find();
  976. if ($status['status'] !== '2-生产中'){
  977. $statusSql = \db('工单_基本资料')->where('Gd_gdbh',$param['workOrder'])->fetchSql(true)->update(['gd_statu'=>'2-生产中']);
  978. Db::query($statusSql);
  979. }
  980. if ($res !== false){
  981. $this->success('成功');
  982. }else{
  983. $this->error('失败');
  984. }
  985. }
  986. /**
  987. * 工艺资料编辑->机台列表获取
  988. * @return void
  989. * @throws \think\db\exception\DataNotFoundException
  990. * @throws \think\db\exception\ModelNotFoundException
  991. * @throws \think\exception\DbException
  992. */
  993. public function MachineList()
  994. {
  995. if ($this->request->isGet() === false){
  996. $this->error('请求错误');
  997. }
  998. $param = $this->request->param();
  999. if (empty($param)){
  1000. $this->error('参数错误');
  1001. }
  1002. $list = \db('设备_基本资料')
  1003. ->where('存放地点',$param['address'])
  1004. ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')
  1005. ->select();
  1006. if (empty($list)){
  1007. $this->success('未找到该车间机台');
  1008. }
  1009. $data = [];
  1010. foreach ($list as $key=>$value){
  1011. $data[$key] = $value['设备编号'].'-->'.$value['设备名称'];
  1012. }
  1013. $this->success('成功',$data);
  1014. }
  1015. /**
  1016. * 打印作业通知单->工单印件和工序获取
  1017. * @ApiMethod (GET)
  1018. * @return void
  1019. * @throws \think\db\exception\DataNotFoundException
  1020. * @throws \think\db\exception\ModelNotFoundException
  1021. * @throws \think\exception\DbException
  1022. */
  1023. public function PrintCodeList()
  1024. {
  1025. if ($this->request->isGet() === false){
  1026. $this->error('请求错误');
  1027. }
  1028. $param = $this->request->param();
  1029. if (empty($param)){
  1030. $this->error('参数错误');
  1031. }
  1032. $list = \db('工单_印件资料')
  1033. ->field([
  1034. 'rtrim(yj_Yjno)' => '印件号',
  1035. 'rtrim(yj_yjmc)' => '印件名称'
  1036. ])
  1037. ->where('Yj_Gdbh',$param['workOrder'])
  1038. ->select();
  1039. $this->success('成功',$list);
  1040. }
  1041. /**
  1042. * 打印作业通知单->工艺编号获取
  1043. * @ApiMethod (GET)
  1044. * @return void
  1045. * @throws \think\db\exception\DataNotFoundException
  1046. * @throws \think\db\exception\ModelNotFoundException
  1047. * @throws \think\exception\DbException
  1048. */
  1049. public function ProcessCodeList()
  1050. {
  1051. if ($this->request->isGet() === false){
  1052. $this->error('请求错误');
  1053. }
  1054. $param = $this->request->param();
  1055. if (empty($param)){
  1056. $this->error('参数错误');
  1057. }
  1058. $list = \db('工单_工艺资料')
  1059. ->field('rtrim(Gy0_gxh) as 工序号')
  1060. ->where([
  1061. 'Gy0_gdbh' => $param['workOrder'],
  1062. 'Gy0_yjno' => $param['yjno']
  1063. ])
  1064. ->select();
  1065. $this->success('成功',$list);
  1066. }
  1067. /**
  1068. * 打印作业通知单
  1069. * @ApiMethod (POST)
  1070. * @param void
  1071. * @return void
  1072. * @throws \think\db\exception\DataNotFoundException
  1073. * @throws \think\db\exception\ModelNotFoundException
  1074. * @throws \think\exception\DbException
  1075. */
  1076. public function PrintJobOrder()
  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. $data = $this->workOrderDetailGet($param['workOrder'],$param['yjno']);
  1086. if (empty($data)){
  1087. $this->success('未找到工单信息');
  1088. }
  1089. $materiel = $this->MaterielDetailGet($param['workOrder']);
  1090. if (empty($materiel)){
  1091. $this->success('未找到物料信息');
  1092. }
  1093. $printDetail = $this->PrintDetailGet($param['workOrder'],$param['yjno'],$param['gxh']);
  1094. if (empty($printDetail)){
  1095. $this->success('未找到工艺信息');
  1096. }
  1097. $number = 0;
  1098. foreach ($printDetail as $key=>$value){
  1099. $value['允损比例'] = (float)substr($value['允损比例'],0,-1);
  1100. $number = $number+$value['允损比例'];
  1101. }
  1102. $data['制单'] = $param['PrepareDocument'];
  1103. $data['审核'] = $param['examine'];
  1104. $data['目标合格率'] = 100-$number.'%';
  1105. $data['materiel'] = $materiel;
  1106. $data['printDetail'] = $printDetail;
  1107. $this->success('成功',$data);
  1108. }
  1109. /**
  1110. * 打印作业通知单->工单及印件资料获取
  1111. * @param $workOrder
  1112. * @return mixed
  1113. */
  1114. public function workOrderDetailGet($workOrder,$yjno)
  1115. {
  1116. $sql = "SELECT
  1117. RTRIM( a.Gd_lx) AS 工单类型,
  1118. RTRIM( a.Gd_gdbh ) AS 生产批次号,
  1119. RTRIM( a.销售订单号 ) AS 销售订单号,
  1120. RTRIM( a.Gd_客户代号 ) AS 客户代号,
  1121. RTRIM( a.Gd_客户名称 ) AS 客户名称,
  1122. RTRIM( a.成品代号 ) AS 产品代码,
  1123. RTRIM( a.成品名称 ) AS 产品名称,
  1124. RTRIM( a.产品版本号 ) AS 版本号,
  1125. RTRIM( a.警语版面 ) AS 警语版面,
  1126. RTRIM( a.码源数量 ) AS 码源数量,
  1127. RTRIM( a.客户ERP编码 ) AS 客户ERP编码,
  1128. RTRIM( a.接单日期 ) AS 开单日期,
  1129. RTRIM( a.交货日期 ) AS 交货日期,
  1130. RTRIM( a.Gd_desc ) AS 工单说明,
  1131. RTRIM( a.投料率 ) AS 投料率,
  1132. RTRIM( a.平均合格率 ) AS 平均合格率,
  1133. RTRIM( a.投料大箱 ) AS 订货数量,
  1134. RTRIM( a.排产时库存 ) AS 排产时库存,
  1135. RTRIM( b.yj_Yjno ) AS 印件,
  1136. RTRIM( b.yj_Yjdh ) AS 印件代号,
  1137. RTRIM( b.yj_yjmc ) AS 印件名称,
  1138. RTRIM( b.yj_平张投料 ) AS 平张投料量,
  1139. RTRIM( b.yj_zzmc ) AS 纸张名称,
  1140. RTRIM( b.yj_tlgg ) AS 投料规格,
  1141. RTRIM( b.yj_ks ) AS 开数,
  1142. RTRIM( b.yj_ls ) AS 联数,
  1143. RTRIM( b.yj_desc ) AS 印件备注
  1144. FROM
  1145. `工单_基本资料` AS a
  1146. JOIN `工单_印件资料` AS b ON b.Yj_Gdbh = a.Gd_gdbh
  1147. WHERE
  1148. a.Gd_gdbh = '{$workOrder}' AND a.行号 = 1 AND b.yj_Yjno = '{$yjno}'";
  1149. $list = Db::query($sql);
  1150. if (empty($list)){
  1151. $this->success('未找到订单数据');
  1152. }
  1153. $list[0]['开单日期'] = date('Y-m-d',strtotime($list[0]['开单日期']));
  1154. $list[0]['交货日期'] = date('Y-m-d',strtotime($list[0]['交货日期']));
  1155. $list[0]['订货数量'] = (int)$list[0]['订货数量'];
  1156. $list[0]['联数'] = (int)$list[0]['联数'];
  1157. $list[0]['印件代号及名称'] = $list[0]['印件代号'].' '.$list[0]['印件名称'];
  1158. $list[0]['投料数量'] = $list[0]['订货数量'];
  1159. unset($list[0]['印件代号'],$list[0]['印件名称']);
  1160. return($list[0]);
  1161. }
  1162. /**打印作业流程单->物料资料获取
  1163. * @param $workOrder
  1164. * @return bool|\PDOStatement|string|\think\Collection
  1165. * @throws \think\db\exception\DataNotFoundException
  1166. * @throws \think\db\exception\ModelNotFoundException
  1167. * @throws \think\exception\DbException
  1168. */
  1169. public function MaterielDetailGet($workOrder)
  1170. {
  1171. $where = [
  1172. 'BOM_工单编号' => $workOrder,
  1173. ];
  1174. $filed = 'rtrim(BOM_物料编码) as 物料编码,rtrim(BOM_物料名称) as 物料名称,rtrim(BOM_投料单位) as 投料单位,rtrim(BOM_计划用量) as 计划用量';
  1175. $list = \db('工单_bom资料')->where($where)->field($filed)->select();
  1176. if (empty($list)){
  1177. $this->success('未找到物料资料信息');
  1178. }
  1179. foreach ($list as $key=>$value){
  1180. $list[$key]['物料代码及名称'] = $value['物料编码'].' '.$value['物料名称'];
  1181. $list[$key]['计划用量'] = (float)$value['计划用量'];
  1182. unset($list[$key]['物料编码'],$list[$key]['物料名称']);
  1183. }
  1184. return $list;
  1185. }
  1186. /**
  1187. * 打印作业流程单->工艺资料获取
  1188. * @param $workOrder
  1189. * @return bool|\PDOStatement|string|\think\Collection
  1190. * @throws \think\db\exception\DataNotFoundException
  1191. * @throws \think\db\exception\ModelNotFoundException
  1192. * @throws \think\exception\DbException
  1193. */
  1194. public function PrintDetailGet($workOrder,$yjno,$gxh)
  1195. {
  1196. $where = [
  1197. 'Gy0_gdbh' => $workOrder,
  1198. 'Gy0_yjno' => $yjno,
  1199. 'Gy0_gxh' => ['<=',$gxh]
  1200. ];
  1201. $filed = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
  1202. rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as ls,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_计划损耗) as 计划损耗,
  1203. rtrim(Gy0_辅助工时) as 装版工时,rtrim(Gy0_小时产能) as 小时定额,rtrim(Gy0_生产工时) as 生产工时,rtrim(工序备注) as 工序备注';
  1204. $list = \db('工单_工艺资料')
  1205. ->where($where)
  1206. ->field($filed)
  1207. ->select();
  1208. if (empty($list)){
  1209. $this->success('工单工艺为空');
  1210. }
  1211. foreach ($list as $key=>$value){
  1212. if ($value['yjno']<10){
  1213. $value['yjno'] = '0'.$value['yjno'];
  1214. }
  1215. if ($value['gxh']<10){
  1216. $value['gxh'] = '0'.$value['gxh'];
  1217. }
  1218. if ($value['add_gxmc'] !== null){
  1219. $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  1220. }else{
  1221. $list[$key]['印件及工序名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
  1222. }
  1223. $list[$key]['转序数'] = (int)($value['计划接货数']/$value['ls']);
  1224. $list[$key]['报废定额'] = (int)($value['计划损耗']/$value['ls']);
  1225. $list[$key]['允损比例'] = round(($value['计划损耗']/$value['计划接货数'])*100,2).'%';
  1226. unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['add_gxmc'],$list[$key]['计划接货数'],$list[$key]['计划损耗']);
  1227. }
  1228. return $list;
  1229. }
  1230. /**
  1231. * 获取小时产能
  1232. * @ApiMethod (GET)
  1233. * @param void
  1234. * @return void
  1235. * @throws \think\db\exception\DataNotFoundException
  1236. * @throws \think\db\exception\ModelNotFoundException
  1237. * @throws \think\exception\DbException
  1238. */
  1239. public function capacityList()
  1240. {
  1241. if ($this->request->isGet() === false){
  1242. $this->error('请求错误');
  1243. }
  1244. $param = $this->request->param();
  1245. if (empty($param)){
  1246. $this->error('参数错误');
  1247. }
  1248. $machine = explode(' ',$param['machine'])[0];
  1249. $number = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(排单小时定额) as 小时产能')->find();
  1250. if (empty($number)){
  1251. $this->error('未找到小时产能');
  1252. }
  1253. $this->success('成功',$number['小时产能']);
  1254. }
  1255. /**
  1256. * 新增工单->添加工单
  1257. * @ApiMethod (POST)
  1258. * @param
  1259. * @return void
  1260. * @throws \think\Exception
  1261. * @throws \think\db\exception\BindParamException
  1262. * @throws \think\db\exception\DataNotFoundException
  1263. * @throws \think\db\exception\ModelNotFoundException
  1264. * @throws \think\exception\DbException
  1265. * @throws \think\exception\PDOException
  1266. */
  1267. public function WorkOrderAdd()
  1268. {
  1269. if (Request::instance()->isPost() === false){
  1270. $this->error('请求错误');
  1271. }
  1272. $param = Request::instance()->post();
  1273. if (empty($param)){
  1274. $this->error('参数错误');
  1275. }
  1276. $num = \db('工单_基本资料')->where('Gd_gdbh',$param['gdbh'])->count();
  1277. $productDetail = \db('产品_基本资料')->where('产品编号',$param['cpdh'])->find();
  1278. $lastId = \db('工单_基本资料')->order('Uniqid desc')->value('Uniqid');
  1279. if ($lastId<1000000000){
  1280. $lastId = 1000000000;
  1281. }
  1282. $data = [
  1283. 'Gd_lx' =>$param['zdgd'],
  1284. 'Gd_生产分类' =>$param['sclx'],
  1285. '成本处理类别' =>'',
  1286. 'Gd_gdbh' =>$param['gdbh'],
  1287. '行号' =>$num+1 ,
  1288. 'Gd_客户代号' =>$param['khdh'],
  1289. 'Gd_客户名称' =>$param['khmc'],
  1290. 'Gd_khdh' =>$param['khdh'],
  1291. 'Gd_khmc' =>$param['khmc'],
  1292. '客户料号' =>rtrim($productDetail['客户料号']),
  1293. '客户ERP编码' =>$param['erp'],
  1294. 'Gd_cpdh' =>$param['cpdh'],
  1295. 'Gd_cpmc' =>$param['cpmc'],
  1296. '成品代号' =>$param['cpdh'],
  1297. '成品名称' =>$param['cpmc'],
  1298. '产品版本号' =>$param['bbh'],
  1299. '销售订单号' =>$param['xsddh'],
  1300. '警语版面' =>$param['jybm'],
  1301. '码源数量' =>$param['mysl'],
  1302. '排产时库存' =>$param['kcdx'],
  1303. '投料大箱' =>$param['tldx'],
  1304. '投料率' =>$param['tll'],
  1305. '平均合格率' =>$param['hgl'],
  1306. '进程备注' =>$param['jcbz'],
  1307. 'Gd_desc' =>$param['remark'],
  1308. '开单日期' =>date('Y-m-d H:i:s',time()),
  1309. '接单日期' =>$param['start'],
  1310. '交货日期' =>$param['end'],
  1311. '订单数量' =>$param['number'],
  1312. '计量单位' =>$param['tldw'],
  1313. '计划投料' =>$param['pztl'],
  1314. '实际投料' =>$param['wxz'],
  1315. '产品单价' =>0,
  1316. '入仓日期' =>'1900-01-01 00:00:00',
  1317. '工单入仓数量' =>0,
  1318. '工单制程废品' => 0,
  1319. '工单质检废品' => 0,
  1320. '工单无形损' => 0,
  1321. '工单计划损耗' => 0,
  1322. '工单完工日期' => $param['end'],
  1323. '投料确认' => '',
  1324. 'gd_statu' => '3-计划中',
  1325. '直接人工' => 0,
  1326. '分摊人工' => 0,
  1327. '直接材料' => 0,
  1328. '考核直接材料' => 0,
  1329. '分摊材料' => 0,
  1330. '考核分摊材料' => 0,
  1331. '直接折旧' => 0,
  1332. '水电气费' => 0,
  1333. '分摊空调' => 0,
  1334. '分摊锅炉' => 0,
  1335. '分摊废气处理' => 0,
  1336. '分摊空压机' => 0,
  1337. '分摊鼓风机' => 0,
  1338. '分摊其他' => 0,
  1339. '待摊人工' => 0,
  1340. '待摊折旧' => 0,
  1341. '待摊场地租金' => 0,
  1342. '待摊其他费用' => 0,
  1343. '加工费' => 0,
  1344. '加工费单价' => 0,
  1345. '成本考核_胶印' => 0,
  1346. '成本考核_凹印' => 0,
  1347. '成本考核_丝印' => 0,
  1348. '成本考核_模切' => 0,
  1349. '成本考核_检验' => 0,
  1350. '印版费' => 0,
  1351. 'V23制造成本' => 0,
  1352. 'Prt_rq' => date('Y-m-d H:i:s',time()),
  1353. 'Sys_id' => '',
  1354. 'Sys_rq' => date('Y-m-d H:i:s',time()),
  1355. 'Mod_rq' => date('Y-m-d H:i:s',time()),
  1356. 'U8UID' => '',
  1357. 'Uniqid' => $lastId+1,
  1358. '工序加工费' => 0,
  1359. ];
  1360. $sql= \db('工单_基本资料')->fetchSql(true)->insert($data);
  1361. $res = \db()->query($sql);
  1362. if ($res !== false){
  1363. $this->success('成功');
  1364. }else{
  1365. $this->error('失败');
  1366. }
  1367. }
  1368. /**
  1369. * 新增工单->客户代号列表获取
  1370. * @return void
  1371. * @throws \think\db\exception\BindParamException
  1372. * @throws \think\exception\PDOException
  1373. */
  1374. public function ClientList()
  1375. {
  1376. if ($this->request->isGet() === false){
  1377. $this->error('请求错误');
  1378. }
  1379. $sql = "SELECT DISTINCT
  1380. (客户编号),rtrim(客户名称 ) as 客户名称
  1381. FROM
  1382. `产品_基本资料`
  1383. GROUP BY
  1384. 客户编号
  1385. order by
  1386. 客户编号";
  1387. $list = \db()->query($sql);
  1388. if (empty($list)){
  1389. $this->success('未找到客户列表');
  1390. }
  1391. foreach ($list as $key=>$value){
  1392. $list[$key]['客户编号'] = rtrim($value['客户编号']);
  1393. if ($value['客户编号'] == '1098'){
  1394. $list[$key]['客户名称'] = '打样专用';
  1395. }
  1396. }
  1397. $this->success('成功',$list);
  1398. }
  1399. /**
  1400. * 新增工单->产品代号获取
  1401. * @ApiMethod (GET)
  1402. * @param void
  1403. * @return void
  1404. * @throws \think\db\exception\DataNotFoundException
  1405. * @throws \think\db\exception\ModelNotFoundException
  1406. * @throws \think\exception\DbException
  1407. */
  1408. public function ProductCodeList()
  1409. {
  1410. if ($this->request->isGet() === false){
  1411. $this->error('请求错误');
  1412. }
  1413. $param = $this->request->param();
  1414. if (empty($param)){
  1415. $this->error('参数错误');
  1416. }
  1417. $list = \db('产品_基本资料')
  1418. ->where('客户编号',$param['cilent'])
  1419. ->field('rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称')
  1420. ->select();
  1421. if (empty($list)){
  1422. $this->success('未获取到产品数据');
  1423. }
  1424. $this->success('成功',$list);
  1425. }
  1426. /**
  1427. * 新增印件资料->印件资料添加
  1428. * @return void
  1429. * @throws \think\db\exception\BindParamException
  1430. * @throws \think\exception\PDOException
  1431. */
  1432. public function PrintDetailAdd()
  1433. {
  1434. if (Request::instance()->isPost() === false){
  1435. $this->error('请求错误');
  1436. }
  1437. $param = Request::instance()->post();
  1438. if (empty($param)){
  1439. $this->error('参数错误');
  1440. }
  1441. $lastId = \db('工单_印件资料')->order('Uniqid desc')->value('Uniqid');
  1442. if ($lastId<1000000){
  1443. $lastId = 1000000;
  1444. }else{
  1445. $lastId = $lastId + 1;
  1446. }
  1447. $param['Uniqid'] = $lastId;
  1448. $param['Sys_rq'] = date('Y-m-d H:i:s',time());
  1449. $param['Mod_rq'] = date('Y-m-d H:i:s',time());
  1450. $sql = \db('工单_印件资料')->fetchSql(true)->insert($param);
  1451. $res = \db()->query($sql);
  1452. if ($res !== false){
  1453. $this->success('成功');
  1454. }else{
  1455. $this->error('失败');
  1456. }
  1457. }
  1458. //新增工艺资料->工艺资料添加
  1459. public function ProcessDetailAdd()
  1460. {
  1461. if (Request::instance()->isPost() === false){
  1462. $this->error('请求错误');
  1463. }
  1464. $param = Request::instance()->post();
  1465. if (empty($param)){
  1466. $this->error('参数错误');
  1467. }
  1468. $lastId = \db('工单_工艺资料')->order('UniqId desc')->value('UniqId');
  1469. if ($lastId<100000000){
  1470. $lastId = 100000000;
  1471. }else{
  1472. $lastId = $lastId + 1;
  1473. }
  1474. }
  1475. /**
  1476. * 新增工艺资料->印件编号获取
  1477. * @return void
  1478. * @throws \think\db\exception\DataNotFoundException
  1479. * @throws \think\db\exception\ModelNotFoundException
  1480. * @throws \think\exception\DbException
  1481. */
  1482. public function PrintDetailList()
  1483. {
  1484. if ($this->request->isGet() === false){
  1485. $this->error('请求错误');
  1486. }
  1487. $param = $this->request->param();
  1488. if (empty($param)){
  1489. $this->error('参数错误');
  1490. }
  1491. $printList = \db('工单_印件资料')
  1492. ->where('Yj_Gdbh',$param['workOrder'])
  1493. ->order('yj_Yjno')
  1494. ->select();
  1495. if (empty($printList)){
  1496. $this->success('未找到该工单印件资料');
  1497. }
  1498. $list = [];
  1499. foreach ($printList as $key=>$value){
  1500. $list[$key]['name'] = rtrim($value['yj_Yjno']).'-->'.rtrim($value['yj_yjmc']);
  1501. $list[$key]['no'] = rtrim($value['yj_Yjno']);
  1502. }
  1503. $this->success('成功',$list);
  1504. }
  1505. }