WorkOrder.php 63 KB

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