WorkOrder.php 85 KB

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