Facility.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use think\Request;
  6. /**
  7. * 设备运行跟踪
  8. */
  9. class Facility extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 左侧菜单栏
  15. * @ApiMethod (GET)
  16. * @return void
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\ModelNotFoundException
  19. * @throws \think\exception\DbException
  20. */
  21. public function getTab()
  22. {
  23. if ($this->request->isGet() === false){
  24. $this->error('请求错误');
  25. }
  26. $data = [];
  27. $department = Db::table('设备_基本资料')->distinct(true)->column('使用部门');
  28. $date = date('Y-m-d H:i:s',time()-3888000);
  29. if (empty($department)){
  30. $this->error('未获取到机台数据');
  31. }
  32. foreach ($department as $value){
  33. if (rtrim($value) !== '研发中心'){
  34. $machine = Db::table('设备_基本资料')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
  35. foreach ($machine as $kk=>$vv){
  36. if ($vv['设备编号'] !== 'ZH01#'){
  37. $date = Db::table('设备_产量计酬')
  38. ->where('sczl_jtbh',$vv['设备编号'])
  39. // ->where('sczl_rq','> time',$date)
  40. ->distinct(true)
  41. ->cache(true)
  42. ->limit(40)
  43. ->order('UniqId desc')
  44. ->column('sczl_rq');
  45. $data[rtrim($value)][$vv['设备编号'].'【'.$vv['设备名称'].'】'] = $date;
  46. }
  47. }
  48. }
  49. }
  50. $this->success('成功',$data);
  51. }
  52. /**
  53. * 机台每日产量
  54. * @ApiMethod (GET)
  55. * @param string $machine 机台编号
  56. * @param string $date 日期
  57. * @return void
  58. * @throws \think\db\exception\DataNotFoundException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. * @throws \think\exception\DbException
  61. */
  62. public function chanLiang()
  63. {
  64. if ($this->request->isGet() === false){
  65. $this->error('请求错误');
  66. }
  67. $machine = input('machine').'#';
  68. $date = input('date');
  69. $where = [
  70. 'sczl_jtbh' => $machine,
  71. 'sczl_rq' => date('Y-m-d H:i:s',strtotime($date.' 00:00:00')),
  72. ];
  73. $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as num,rtrim(sczl_sj1) as sj1,
  74. rtrim(sczl_sj2) as sj2,rtrim(sczl_cl) as 产量,rtrim(sczl_bzdh) as bzdh,rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,
  75. rtrim(sczl_装版工时) as 装版工时,rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,rtrim(sczl_异常停机工时) as 异常总工时,rtrim(sczl_设备运行工时) as 通电工时,
  76. rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度数,
  77. rtrim(sys_id) as 用户,rtrim(mod_rq) as 更新时间,rtrim(sczl_异常工时1) as 异常补时,rtrim(sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,
  78. sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,sczl_rate2,sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
  79. sczl_rate8,sczl_rate9,sczl_rate10';
  80. //机台信息
  81. $machineDetail = Db::table('设备_基本资料')->where('设备编号',$machine)->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额')->find();
  82. //工单编号
  83. $Gd_gdbh = Db::table('设备_产量计酬')->where($where)->distinct(true)->column('sczl_gdbh');
  84. //产品名称
  85. $productName = Db::table('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->column('Gd_cpmc','Gd_gdbh');
  86. //组员信息
  87. $list = Db::table('设备_产量计酬')->where($where)->field($field)->select();
  88. $totalA = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
  89. $totalB = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
  90. if (empty($list)){
  91. $this->error('未找到机台数据');
  92. }
  93. foreach ($list as $key=>$value){
  94. $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName[$value['工单编号']];
  95. if ($value['yjno']<10){
  96. $list[$key]['yjno'] = '0'.$value['yjno'];
  97. }
  98. $list[$key]['工序'] = $list[$key]['yjno'].'-'.$list[$key]['gxmc'];
  99. $list[$key]['备注'] = $value['bzdh'].'('.$value['num'].')'.date('H:i',strtotime($value['sj1'])).'<-->'.date('H:i',strtotime($value['sj2']));
  100. $list[$key]['千件工价'] = $machineDetail['千件工价'];
  101. $list[$key]['日定额'] = $machineDetail['日定额'];
  102. for ($i=1;$i<11;$i++){
  103. if (isset($value['sczl_bh'.$i])){
  104. $name = Db::table('人事_基本资料')->where('员工编号',$value['sczl_bh'.$i])->field('rtrim(员工姓名) as name')->find();
  105. if (isset($name['name'])){
  106. $list[$key]['组员'.$i] = $value['sczl_bh'.$i].$name['name'].'('.((float)$value['sczl_rate'.$i]*100).'%'.')';
  107. }
  108. }
  109. unset($list[$key]['sczl_bh'.$i],$list[$key]['sczl_rate'.$i]);
  110. }
  111. unset($list[$key]['工序编号'],$list[$key]['yjno'],$list[$key]['gxmc'],$list[$key]['num'],$list[$key]['sj1'],$list[$key]['sj2'],$list[$key]['bzdh']);
  112. }
  113. $list['totalA'] = $totalA[0]['产量'];
  114. $list['totalB'] = $totalB[0]['产量'];
  115. $this->success('成功',$list);
  116. }
  117. /**
  118. * 当日制程检验记录
  119. * @ApiMethod (GET)
  120. * @param string $machine 机台编号
  121. * @param string $date 日期
  122. * @return void
  123. * @throws \think\db\exception\DataNotFoundException
  124. * @throws \think\db\exception\ModelNotFoundException
  125. * @throws \think\exception\DbException
  126. */
  127. public function Inspect()
  128. {
  129. if ($this->request->isGet() === false){
  130. $this->error('请求错误');
  131. }
  132. $machine = input('machine');
  133. $date = input('date');
  134. if (empty($machine) || empty($date)){
  135. $this->error('参数错误');
  136. }
  137. // $last_id = Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find();
  138. // $startId = $last_id['UniqId']-1000000;
  139. $where = [
  140. '设备编号' => $machine,
  141. '开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
  142. '类别' => ['in',['IPQC检验','机台检验']],
  143. // 'UniqId' => ['>',$startId],
  144. ];
  145. $begin = Db::table('制程检验_记录')->where($where)->field('UniqId')->find();
  146. $end = Db::table('制程检验_记录')->where($where)->order('UniqId desc')->field('UniqId')->find();
  147. $where['UniqId'] = ['between',[$begin['UniqId'],$end['UniqId']+1]];
  148. //检验项目筛选
  149. $itemA = Db::table('制程检验_记录')->where($where)->distinct(true)->where('班组编号','A班')->column('rtrim(检验项目)');
  150. $itemB = Db::table('制程检验_记录')->where($where)->distinct(true)->where('班组编号','B班')->column('rtrim(检验项目)');
  151. //检验时间
  152. $InspectionTime = Db::table('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
  153. foreach ($InspectionTime as $k=>$v){
  154. $InspectionTime[$k] = date('H:i',strtotime($v));
  155. }
  156. //检测记录详情
  157. $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
  158. $nameDetailA = Db::table('制程检验_记录')->where($where)->field($field)->where('班组编号','A班')->find();
  159. $nameDetailB = Db::table('制程检验_记录')->where($where)->field($field)->where('班组编号','B班')->find();
  160. $list = $data1 = $data2 = [];
  161. //A班检测数据
  162. foreach ($itemA as $key=>$value){
  163. $SubmissionTime = Db::table('制程检验_记录')->where($where)
  164. ->where('班组编号','A班')
  165. ->where('检验项目',$value)
  166. ->where('检验结果','合格')
  167. ->field('rtrim(提交时间) as 提交时间')
  168. ->select();
  169. $time = [];
  170. foreach ($SubmissionTime as $k=>$v){
  171. $time[$k] = date('H:i',strtotime($v['提交时间']));
  172. }
  173. $data1[$key] = [
  174. '工单编号' => $nameDetailA['工单编号'],
  175. '印件号' => $nameDetailA['印件号'],
  176. '工序名称' => $nameDetailA['工序名称'],
  177. '检验项目' => $value,
  178. 'inspectresult' => implode(',',$time),
  179. ];
  180. }
  181. //B班数据详情
  182. foreach ($itemB as $key=>$value){
  183. $SubmissionTime = Db::table('制程检验_记录')->where($where)
  184. ->where('班组编号','B班')
  185. ->where('检验项目',$value)
  186. ->where('检验结果','合格')
  187. ->field('rtrim(提交时间) as 提交时间')
  188. ->select();
  189. $time = [];
  190. foreach ($SubmissionTime as $k=>$v){
  191. $time[$k] = date('H:i',strtotime($v['提交时间']));
  192. }
  193. $data2[$key] = [
  194. '工单编号' => $nameDetailB['工单编号'],
  195. '印件号' => $nameDetailB['印件号'],
  196. '工序名称' => $nameDetailB['工序名称'],
  197. '检验项目' => $value,
  198. 'inspectresult' => implode(',',$time),
  199. ];
  200. }
  201. $list = array_merge($data2,$data1);
  202. $list['inspectiontime'] = $InspectionTime;
  203. $this->success('成功',$list);
  204. }
  205. /**
  206. * 设备生产中工单信息
  207. * @ApiMethod (GET)
  208. * @param string $machine 机台编号
  209. * @return void
  210. * @throws \think\Exception
  211. * @throws \think\db\exception\DataNotFoundException
  212. * @throws \think\db\exception\ModelNotFoundException
  213. * @throws \think\exception\DbException
  214. */
  215. public function Production()
  216. {
  217. if ($this->request->isGet() === false){
  218. $this->error('请求错误');
  219. }
  220. $machine = input('machine');
  221. if (empty($machine)){
  222. $this->error('参数错误');
  223. }
  224. // $lastUniqid = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
  225. // $startUniqid = $lastUniqid['UniqId']-10000;
  226. // halt($lastUniqid);
  227. $workOrder = Db::table('设备_产量计酬')->where('sczl_jtbh',$machine)->field('sczl_gdbh')->order('UniqId desc')->find();
  228. if (empty($workOrder)){
  229. $this->error('未找到正在生产工单');
  230. }
  231. $where = [
  232. 'Gy0_sbbh' => $machine,
  233. 'Gy0_gdbh' => $workOrder['sczl_gdbh']
  234. ];
  235. $list = Db::table('工单_工艺资料')->where($where)->find();
  236. if (empty($list)){
  237. $this->error('未找到正在生产工单');
  238. }
  239. $facilityWhere = [
  240. 'sczl_jtbh'=>$machine,
  241. 'sczl_gdbh'=>$list['Gy0_gdbh']
  242. ];
  243. $facilityField = 'sczl_bh1,sczl_bh2,sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10';
  244. $Ctaff = Db::table('设备_产量计酬')->where($facilityWhere)->field($facilityField)->order('UniqId desc')->find();
  245. $data = [];
  246. foreach ($Ctaff as $key=>$value){
  247. if (!empty($value)){
  248. $staffName = Db::table('人事_基本资料')
  249. ->where('员工编号',$value)
  250. ->field('员工姓名,员工编号')
  251. ->find();
  252. $data[$key] = [
  253. '员工编号' => rtrim($staffName['员工编号']),
  254. '员工姓名' => rtrim($staffName['员工姓名']),
  255. ];
  256. }
  257. }
  258. if ($list['Gy0_yjno']<10){
  259. $list['Gy0_yjno'] = '0'.$list['Gy0_yjno'];
  260. }
  261. if ($list['Gy0_gxh']<10){
  262. $list['Gy0_gxh'] = '0'.$list['Gy0_gxh'];
  263. }
  264. $data['工单编号'] = rtrim($list['Gy0_gdbh']);
  265. $data['印件编号'] = rtrim($list['Gy0_yjno']);
  266. $data['工序名称'] = rtrim($list['Gy0_gxh']).'-'.rtrim($list['Gy0_gxmc']).'【'.rtrim($list['Add_gxmc']).'】';
  267. $data['产品名称'] = Db::table('工单_基本资料')
  268. ->where('Gd_gdbh',rtrim($list['Gy0_gdbh']))
  269. ->field('rtrim(Gd_cpmc) as 产品名称')
  270. ->find()['产品名称'];
  271. $data['班组'] = Db::table('设备_产量计酬')->where($facilityWhere)->field('rtrim(sczl_bzdh) as bzdh')->order('UniqId desc')->find()['bzdh'];
  272. $this->success('成功',$data);
  273. }
  274. /**
  275. * 设备工作清单
  276. * @ApiMethod (GET)
  277. * @param string $machine 机台编号
  278. * @return void
  279. * @throws \think\db\exception\DataNotFoundException
  280. * @throws \think\db\exception\ModelNotFoundException
  281. * @throws \think\exception\DbException
  282. */
  283. public function EquipmentWorklist()
  284. {
  285. if ($this->request->isGet() === false){
  286. $this->error('请求错误');
  287. }
  288. $machine = input('machine');
  289. if (empty($machine)){
  290. $this->error('参数错误');
  291. }
  292. $lastTechonUniqId = Db::table('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
  293. $startTechonUniqId = $lastTechonUniqId['UniqId']-10000;
  294. // $lastYieldUniqId = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
  295. // $startYieldUniqId = $lastYieldUniqId['UniqId']-100000;
  296. $workOrder = Db::table('设备_产量计酬')
  297. ->where('sczl_jtbh',$machine)
  298. ->field('sczl_gdbh')
  299. // ->where('UniqId','>',$startYieldUniqId)
  300. ->order('UniqId desc')
  301. ->find();
  302. $startTime = Db::table('工单_工艺资料')
  303. ->where('Gy0_gdbh',$workOrder['sczl_gdbh'])
  304. ->where('Gy0_sbbh',$machine)
  305. ->where('UniqId','>',$startTechonUniqId)
  306. ->field('Gy0_sj1')
  307. ->order('UniqId desc')
  308. ->find();
  309. $where = [
  310. // 'UniqId' => ['>',$startTechonUniqId],
  311. 'Gy0_sbbh' => $machine,
  312. 'Gy0_sj1' => ['>= time',$startTime['Gy0_sj1']],
  313. ];
  314. $field = 'rtrim(Gy0_gdbh) as gdbh,rtrim(质量要求) as 质量信息,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,
  315. rtrim(Add_gxmc) as add_gxmc,rtrim(Gy0_辅助工时) as 装版时数,rtrim(Gy0_小时产能) as 工序产能,rtrim(Gy0_生产工时) as 计划工时,
  316. rtrim(Gy0_sj1) as sj1,rtrim(Gy0_sj2) as sj2,rtrim(工序备注) as 排产备注';
  317. $orderList = Db::table('工单_工艺资料')
  318. ->where($where)
  319. ->where('Gy0_sj1','<','2099-01-01 00:00:00')
  320. ->field($field)
  321. ->order('UniqId desc')
  322. ->select();
  323. foreach ($orderList as $key=>$value){
  324. $orderList[$key]['工单编号|质量信息'] = $value['gdbh'].'|'.$value['质量信息'];
  325. $name = Db::table('工单_印件资料')->where(['Yj_Gdbh'=>$value['gdbh'],'yj_Yjno'=>$value['yjno']])->field('yj_yjmc')->find();
  326. if ($value['yjno']<10){
  327. $orderList[$key]['yjno'] = '0'.$value['yjno'];
  328. }
  329. if ($value['gxh']<10){
  330. $orderList[$key]['gxh'] = '0'.$value['gxh'];
  331. }
  332. $orderList[$key]['印件资料'] = $orderList[$key]['yjno'].'-'.rtrim($name['yj_yjmc']);
  333. $orderList[$key]['工序名称'] = $orderList[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  334. $scheduled = Db::table('工单_基本资料')->where('Gd_gdbh',$value['gdbh'])->field('rtrim(计划投料) as 计划产量')->find();
  335. $finished = Db::table('设备_产量计酬')
  336. ->where('sczl_gdbh',$value['gdbh'])
  337. ->where('sczl_jtbh',$machine)
  338. // ->where('UniqId','>',$startYieldUniqId)
  339. ->order('UniqId desc')
  340. ->field('SUM(sczl_cl) as cl')
  341. ->select();
  342. $orderList[$key]['计划产量/已完成'] = $scheduled['计划产量'].'/'.$finished[0]['cl']=null?'':(int)$finished[0]['cl'];
  343. $orderList[$key]['计划生产时段'] =substr($value['sj1'],5,5).' '.substr($value['sj1'],11,5).'<-->'.substr($value['sj2'],5,5).' '.substr($value['sj2'],11,5);
  344. $orderList[$key]['产品名称'] = rtrim($name['yj_yjmc']);
  345. unset($orderList[$key]['gdbh'],$orderList[$key]['质量信息'],$orderList[$key]['yjno'],$orderList[$key]['gxh'],$orderList[$key]['gxmc'],$orderList[$key]['add_gxmc'],$orderList[$key]['sj1'],$orderList[$key]['sj2']);
  346. }
  347. $this->success('成功',$orderList);
  348. }
  349. /**
  350. * 工序、印件、完成数量
  351. * @ApiMethod (GET)
  352. * @param string $workOrder 工单编号
  353. * @return void
  354. * @throws \think\Exception
  355. * @throws \think\db\exception\DataNotFoundException
  356. * @throws \think\db\exception\ModelNotFoundException
  357. * @throws \think\exception\DbException
  358. */
  359. public function Procedure()
  360. {
  361. if ($this->request->isGet() === false){
  362. $this->error('请求错误');
  363. }
  364. $workOrder = input('Gd_gdbh');
  365. if (empty($workOrder)){
  366. $this->error('参数错误');
  367. }
  368. // $lastUniqid = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
  369. // $startUniqid = $lastUniqid['UniqId']-100000;
  370. //右边工艺及完成数量
  371. $Process = Db::table('设备_产量计酬')->where('sczl_gdbh',$workOrder)
  372. // ->where('UniqId','>',$startUniqid)
  373. ->distinct(true)->order('sczl_gxh')
  374. ->column('sczl_gxh');
  375. $data = [];
  376. foreach ($Process as $k=>$v){
  377. $res= Db::table('设备_产量计酬')->where('sczl_gdbh',$workOrder)
  378. // ->where('UniqId','>',$startUniqid)
  379. ->where('sczl_gxh',$v)
  380. ->field('rtrim(sczl_yjno) as sczl_yjno,rtrim(sczl_gxmc) as sczl_gxmc')
  381. ->find();
  382. if ($res['sczl_yjno']<10){
  383. $res['sczl_yjno'] = '0'.$res['sczl_yjno'];
  384. }
  385. $processList['process'] = $res['sczl_yjno'].'-'.$res['sczl_gxmc'];
  386. $processList['completed'] = Db::table('设备_产量计酬')
  387. ->where('sczl_gdbh',$workOrder)
  388. // ->where('UniqId','>',$startUniqid)
  389. ->where('sczl_gxh',$v)
  390. ->count();
  391. array_push($data,$processList);
  392. }
  393. $this->success('成功',$data);
  394. }
  395. /**
  396. * 班组人员及分配比例
  397. * @ApiMethod (GET)
  398. * @param string $machine 机台编号
  399. * @return void
  400. * @throws \think\db\exception\DataNotFoundException
  401. * @throws \think\db\exception\ModelNotFoundException
  402. * @throws \think\exception\DbException
  403. */
  404. public function Team()
  405. {
  406. if ($this->request->isGet() === false){
  407. $this->error('请求错误');
  408. }
  409. $machine = input('machine');
  410. if (empty($machine)){
  411. $this->error('参数错误');
  412. }
  413. $where = [
  414. 'sczl_jtbh' => $machine,
  415. ];
  416. $field = 'rtrim(sczl_bzdh) as 班组号,rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
  417. rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
  418. rtrim(sczl_bh10) as bh10,rtrim(sczl_rate1) as rate1,rtrim(sczl_rate2) as rate2,rtrim(sczl_rate3) as rate3,rtrim(sczl_rate4) as rate4,
  419. rtrim(sczl_rate5) as rate5,rtrim(sczl_rate6) as rate6,rtrim(sczl_rate7) as rate7,rtrim(sczl_rate8) as rate8,
  420. rtrim(sczl_rate9) as rate9,rtrim(sczl_rate10) as rate10,rtrim(UniqId) as ID';
  421. $team = Db::table('设备_产量计酬')
  422. ->where('sczl_jtbh',$machine)
  423. ->field($field)
  424. ->order('UniqId desc')
  425. ->find();
  426. $list = Db::table('设备_班组资料')->where($where)->field($field)->select();
  427. $data = [];
  428. foreach ($list as $k=>$v){
  429. if ($team == $v){
  430. $data[$k]['status'] = 1;
  431. }else{
  432. $data[$k]['status'] = 0;
  433. }
  434. $data[$k]['ID'] = $v['ID'];
  435. $data[$k]['班组号'] = $v['班组号'];
  436. for ($i=1;$i<11;$i++){
  437. if ($v['bh'.$i] != '' && $v['bh'.$i] != '000000'){
  438. $name = Db::table('人事_基本资料')->where('员工编号',$v['bh'.$i])->field('rtrim(员工姓名) as 姓名')->find();
  439. $data[$k][$i-1] = $v['bh'.$i].' '.$name['姓名'].' ('.number_format($v['rate'.$i]*100,2).'%'.')';
  440. }
  441. }
  442. }
  443. $this->success('成功',$data);
  444. }
  445. /**
  446. * 当班产量明细
  447. * @ApiMethod (GET)
  448. * @param string $machine 机台编号
  449. * @param string $workOrder 工单编号
  450. * @param string $team 班次
  451. * @return void
  452. * @throws \think\db\exception\DataNotFoundException
  453. * @throws \think\db\exception\ModelNotFoundException
  454. * @throws \think\exception\DbException
  455. */
  456. public function OutputDetail()
  457. {
  458. if ($this->request->isGet() === false){
  459. $this->error('请求错误');
  460. }
  461. $machine = input('machine');
  462. $workOrder = input('Gd_gdbh');
  463. $team = input('team');
  464. if (empty($machine) || empty($workOrder) || empty($team)){
  465. $this->error('参数错误');
  466. }
  467. // $lastUniqid = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
  468. // $startUniqid = $lastUniqid['UniqId']-100000;
  469. $name = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(Gd_cpmc) as productName')->find();
  470. $where = [
  471. // 'UniqId' => ['>',$startUniqid],
  472. 'sczl_gdbh' => $workOrder,
  473. 'sczl_jtbh' => $machine,
  474. 'sczl_cl' => ['<>',0.0],
  475. 'sczl_bzdh' => $team,
  476. ];
  477. $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as 标牌号,rtrim(sczl_cl) as 产量,
  478. rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,rtrim(sczl_装版工时) as 装版工时,
  479. rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,rtrim(sczl_异常停机工时) as 异常停机工时,rtrim(sczl_设备运行工时) as 通电工时,
  480. rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度,
  481. rtrim(sczl_sj1) as sj1,rtrim(sczl_sj2) as sj2';
  482. $list = Db::table('设备_产量计酬')->where($where)->field($field)->order('UniqId desc')->select();
  483. if (empty($list)){
  484. $this->error('未找到生产记录');
  485. }
  486. foreach ($list as $k=>$v){
  487. if ($v['yjno']<10){
  488. $list[$k]['yjno'] = '0'.$v['yjno'];
  489. }
  490. $list[$k]['印件及工序'] = $list[$k]['yjno'].'-'.$v['gxmc'];
  491. $list[$k]['生产时间段'] = substr($v['sj1'],5,5).' '.substr($v['sj1'],11,5).'<-->'.substr($v['sj2'],5,5).' '.substr($v['sj2'],11,5);
  492. $list[$k]['产品名称'] = $name['productName'];
  493. unset($list[$k]['yjno'],$list[$k]['gxmc'],$list[$k]['sj1'],$list[$k]['sj2']);
  494. }
  495. $field1 = 'SUM(sczl_cl) as 产量,SUM(sczl_zcfp) as 制程废品,SUM(sczl_zccp) as 制程次品,SUM(sczl_前工序废) as 前工序废,
  496. SUM(sczl_来料少数) as 来料异常,SUM(sczl_装版工时) as 装版工时,SUM(sczl_保养工时) as 保养工时,SUM(sczl_打样工时) as 打样工时,
  497. SUM(sczl_异常停机工时) as 异常停机工时,SUM(sczl_设备运行工时) as 通电工时,SUM(码开始行) as 码开始行,SUM(码结束行) as 码结束行,
  498. SUM(码包) as 码包,SUM(主电表) as 主电表,SUM(辅电表) as 辅电表';
  499. $total = Db::table('设备_产量计酬')->where($where)->field($field1)->order('UniqId desc')->select();
  500. $total[0]['版数'] = count($list);
  501. $list['total'] = $total[0];
  502. $this->success('成功',$list);
  503. }
  504. /**
  505. * 检验记录
  506. * @ApiMethod (GET)
  507. * @param string $machine 机台编号
  508. * @param string $workOrder 工单编号
  509. * @param string $team 班次
  510. * @return void
  511. * @throws \think\db\exception\DataNotFoundException
  512. * @throws \think\db\exception\ModelNotFoundException
  513. * @throws \think\exception\DbException
  514. */
  515. public function InspectionRecord()
  516. {
  517. if ($this->request->isGet() === false){
  518. $this->error('请求失败');
  519. }
  520. $machine = input('machine');
  521. $workOrder = input('Gd_gdbh');
  522. $team = input('team');
  523. if (empty($machine) || empty($workOrder) || empty($team)){
  524. $this->error('参数错误');
  525. }
  526. // $last_id = Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find();
  527. // $startId = $last_id['UniqId']-100000;
  528. $where = [
  529. '设备编号' => $machine,
  530. '工单编号' => $workOrder,
  531. '班组编号' => $team,
  532. '类别' => ['in',['IPQC检验','机台检验']],
  533. // 'UniqId' => ['>',$startId],
  534. ];
  535. //检验项目筛选
  536. $item = Db::table('制程检验_记录')->where($where)->distinct(true)->column('rtrim(检验项目)');
  537. //检验时间
  538. $InspectionTime = Db::table('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
  539. foreach ($InspectionTime as $k=>$v){
  540. $InspectionTime[$k] = date('H:i',strtotime($v));
  541. }
  542. //检测记录详情
  543. $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
  544. $nameDetail = Db::table('制程检验_记录')->where($where)->field($field)->find();
  545. $data = [];
  546. //检测数据
  547. foreach ($item as $key=>$value){
  548. $SubmissionTime = Db::table('制程检验_记录')->where($where)
  549. ->where('检验项目',$value)
  550. ->where('检验结果','合格')
  551. ->field('rtrim(提交时间) as 提交时间')
  552. ->select();
  553. $time = [];
  554. foreach ($SubmissionTime as $k=>$v){
  555. $time[$k] = date('H:i',strtotime($v['提交时间']));
  556. }
  557. $data[$key] = [
  558. '工单编号' => $nameDetail['工单编号'],
  559. '印件号' => $nameDetail['印件号'],
  560. '工序名称' => $nameDetail['工序名称'],
  561. '检验项目' => $value,
  562. 'inspectresult' => implode(',',$time),
  563. ];
  564. }
  565. $data['inspectiontime'] = $InspectionTime;
  566. $this->success('成功',$data);
  567. }
  568. //班组维护
  569. public function TeamMaintenance()
  570. {
  571. if (Request::instance()->isPost() === false){
  572. $this->error('请求错误');
  573. }
  574. $data = Request::instance()->post();
  575. if (empty($data)){
  576. $this->error('参数错误');
  577. }
  578. $field = 'rtrim(sczl_bzdh) as sczl_bzdh,rtrim(sczl_bh1) as sczl_bh1,rtrim(sczl_bh2) as sczl_bh2,rtrim(sczl_bh3) as sczl_bh3,rtrim(sczl_bh4) as sczl_bh4,
  579. rtrim(sczl_bh5) as sczl_bh5,rtrim(sczl_bh6) as sczl_bh6,rtrim(sczl_bh7) as sczl_bh7,rtrim(sczl_bh8) as sczl_bh8,rtrim(sczl_bh9) as sczl_bh9,
  580. rtrim(sczl_bh10) as sczl_bh10,rtrim(sczl_rate1) as sczl_rate1,rtrim(sczl_rate2) as sczl_rate2,rtrim(sczl_rate3) as sczl_rate3,rtrim(sczl_rate4) as sczl_rate4,
  581. rtrim(sczl_rate5) as sczl_rate5,rtrim(sczl_rate6) as sczl_rate6,rtrim(sczl_rate7) as sczl_rate7,rtrim(sczl_rate8) as sczl_rate8,
  582. rtrim(sczl_rate9) as sczl_rate9,rtrim(sczl_rate10) as sczl_rate10';
  583. $TeamList = Db::table('设备_班组资料')->where('UniqId',$data['ID'])->field($field)->find();
  584. }
  585. /**
  586. * 机台编号列表
  587. * @ApiMethod (GET)
  588. * @return void
  589. */
  590. public function MachineList()
  591. {
  592. if ($this->request->isGet() === false){
  593. $this->error('请求错误');
  594. }
  595. $list = Db::table('设备_基本资料')->column('设备编号');
  596. if (empty($list)){
  597. $this->error('未找到机台编号');
  598. }
  599. $this->success('成功',$list);
  600. }
  601. /**
  602. * 删除班组信息
  603. * @ApiMethod (GET)
  604. * @param void
  605. * @return void
  606. * @throws \think\Exception
  607. * @throws \think\exception\PDOException
  608. */
  609. public function teamDel()
  610. {
  611. if (Request::instance()->isPost() === false){
  612. $this->error('请求错误');
  613. }
  614. $param = Request::instance()->post();
  615. if (empty($param)){
  616. $this->error('参数错误');
  617. }
  618. $res = Db::table('设备_班组资料')
  619. ->where('UniqId',$param['UniqId'])
  620. ->delete();
  621. if ($res !== false){
  622. $this->success('成功');
  623. }else{
  624. $this->error('失败');
  625. }
  626. }
  627. //制程检验记录->指标检验
  628. public function ProcessInspectionRecords()
  629. {
  630. if ($this->request->isGet() === false){
  631. $this->error('请求错误');
  632. }
  633. $param = $this->request->param();
  634. if (empty($param)){
  635. $this->error('参数错误');
  636. }
  637. // $filed = ''
  638. }
  639. /**
  640. * 管理人员现场巡检记录->展示
  641. * @ApiMethod (GET)
  642. * @param void
  643. * @return void
  644. * @throws \think\db\exception\DataNotFoundException
  645. * @throws \think\db\exception\ModelNotFoundException
  646. * @throws \think\exception\DbException
  647. */
  648. public function FieldInspectionRecord()
  649. {
  650. if ($this->request->isGet() === false){
  651. $this->error('请求错误');
  652. }
  653. $param = $this->request->param();
  654. if (empty($param)){
  655. $this->error('参数错误');
  656. }
  657. // $last_id = Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find();
  658. // $startId = $last_id['UniqId']-100000;
  659. $date = date('Y-m-d H:i:s',time());
  660. $startTime = date('Y-m-d 08:30:00',time());
  661. if ($date<$startTime){
  662. $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
  663. }
  664. $where = [
  665. '工单编号' => $param['workOrder'],
  666. '开工时间' => $startTime,
  667. '类别' => '现场巡查记录',
  668. '班组编号' => $param['team']
  669. ];
  670. $filed = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,rtrim(流程单号) as 流程单号,
  671. rtrim(设备编号) as 设备编号,rtrim(班组编号) as 班组编号,rtrim(检验项目) as 现场管理人员,rtrim(检验备注) as 检验备注,
  672. rtrim(提交时间) as 提交时间,rtrim(开工时间) as 开工时间';
  673. $list = Db::table('制程检验_记录')->where($where)
  674. // ->where('UniqId','>',$startId)
  675. ->field($filed)
  676. // ->fetchSql(true)
  677. ->select();
  678. if (empty($list)){
  679. $this->error('未找到该工单当前班次巡检记录');
  680. }
  681. foreach ($list as $key=>$value){
  682. $number = floor((strtotime($value['提交时间'])-strtotime($value['开工时间']))/(15*60));
  683. $list[$key]['归属时段'] = $value['开工时间'];
  684. $list[$key]['分钟差数'] = $number;
  685. if ($number != 0){
  686. $list[$key]['归属时段'] = date('Y-m-d H:i:s',strtotime($value['开工时间'])+$number*15*60);
  687. }
  688. }
  689. $this->success('成功',$list);
  690. }
  691. /**
  692. * 管理人员现场巡检记录->添加
  693. * @ApiMethod (POST)
  694. * @param void
  695. * @return void
  696. */
  697. public function FieldInspectionRecordAdd()
  698. {
  699. if (Request::instance()->isPost() === false){
  700. $this->error('请求错误');
  701. }
  702. $param = Request::instance()->post();
  703. if (empty($param)){
  704. $this->error('参数错误');
  705. }
  706. if ($param['processCode']<10){
  707. $param['processCode'] = '0'.$param['processCode'];
  708. }
  709. $date = date('Y-m-d H:i:s',time());
  710. $startTime = date('Y-m-d 08:30:00',time());
  711. if ($date<$startTime){
  712. $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
  713. }
  714. $data = [
  715. '类别' => $param['category'],
  716. '工单编号' => $param['workOrder'],
  717. '印件号' => $param['printCode'],
  718. '工序名称' => $param['processCode'].'-'.$param['process'],
  719. '流程单号' => $param['flowCode'],
  720. '设备编号' => $param['machine'],
  721. '班组编号' => $param['team'],
  722. '检验项目' => '['.$param['employeeCode'].'/'.$param['employeeName'].']',
  723. '相关标准' => '',
  724. '量测仪器' => '',
  725. '检验结果' => '',
  726. '检验备注' => $param['remark'],
  727. '提交时间' => date('Y-m-d H:i:s',time()),
  728. '开工时间' => $startTime,
  729. 'sys_id' => '',
  730. 'sys_rq' => date('Y-m-d H:i:s',time()),
  731. 'mod_rq' => '',
  732. 'UniqId' => Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find()['UniqId']+1
  733. ];
  734. $sql = Db::table('制程检验_记录')->fetchSql(true)->insert($data);
  735. $res = Db::query($sql);
  736. if ($res !== false){
  737. $this->success('成功');
  738. }else{
  739. $this->error('失败');
  740. }
  741. }
  742. /**
  743. * 设备点检->左侧菜单栏
  744. * @ApiMethod (GET)
  745. * @param void
  746. * @return void
  747. */
  748. public function SpotCheckItem()
  749. {
  750. if ($this->request->isGet() === false){
  751. $this->error('请求错误');
  752. }
  753. $param = $this->request->param();
  754. if (empty($param)){
  755. $this->error('参数错误');
  756. }
  757. $list = Db::table('设备_点检项目')
  758. ->where('适用机型','LIKE','%;'.$param['machine'].';%')
  759. ->distinct(true)
  760. ->column('部件名称','部件编号');
  761. if (empty($list)){
  762. $this->error('未找到检验项目');
  763. }
  764. $this->success('成功',$list);
  765. }
  766. /**
  767. * 设备点检->检测项目
  768. * @ApiMethod (GET)
  769. * @param void
  770. * @return void
  771. * @throws \think\db\exception\DataNotFoundException
  772. * @throws \think\db\exception\ModelNotFoundException
  773. * @throws \think\exception\DbException
  774. */
  775. public function InspectionItem()
  776. {
  777. if ($this->request->isGet() === false){
  778. $this->error('请求错误');
  779. }
  780. $param = $this->request->param();
  781. if (empty($param)){
  782. $this->error('参数错误');
  783. }
  784. $list = Db::table('设备_点检项目')
  785. ->where('部件名称',$param['unitName'])
  786. ->field('rtrim(检验项目) as 检验项目,rtrim(判定标准) as 判定标准,rtrim(点检方法) as 点检方法')
  787. ->select();
  788. if (empty($list)){
  789. $this->error('未找到检测项目');
  790. }
  791. $this->success('成功',$list);
  792. }
  793. /**
  794. * 设备点检->检测记录添加
  795. * @ApiMethod (POST)
  796. * @param void
  797. * @return void
  798. * @throws \think\db\exception\DataNotFoundException
  799. * @throws \think\db\exception\ModelNotFoundException
  800. * @throws \think\exception\DbException
  801. */
  802. public function InspectionItemAdd()
  803. {
  804. if (Request::instance()->isPost() === false){
  805. $this->error('请求错误');
  806. }
  807. $param = Request::instance()->post();
  808. if (empty($param)){
  809. $this->error('参数错误');
  810. }
  811. $data = [
  812. 'team' => $param['team'],
  813. 'machine' => $param['machine'],
  814. 'unitName' => $param['unitName']
  815. ];
  816. unset($param['team'],$param['machine'],$param['unitName']);
  817. $lastId = Db::table('设备_点检记录')->field('rtrim(Uniqid) as id')->order('Uniqid desc')->find();
  818. $unitCode = Db::table('设备_点检项目')->where('部件名称',$data['unitName'])->field('rtrim(部件编号) as 部件编号')->find();
  819. $row = [];
  820. $param = array_values($param);
  821. foreach ($param as $key=>$value){
  822. $value = explode(';',$value);
  823. $row[$key] = [
  824. '日期' => date('Y-m-d 00:00:00',time()),
  825. '班组编号' => $data['team'],
  826. '点检设备' => $data['machine'],
  827. '部件编号' => $unitCode['部件编号'],
  828. '部件名称' => $data['unitName'],
  829. '检验项目' => $value[0],
  830. '判定标准' => $value[4],
  831. '点检方法' => $value[1],
  832. '点检结果' => $value[2],
  833. '备注说明' => $value[3],
  834. 'Sys_id' =>'',
  835. 'Sys_rq' => date('Y-m-d H:i:s',time()),
  836. 'Mod_rq' => '',
  837. 'Uniqid' => $lastId['id']+$key+1
  838. ];
  839. }
  840. $sql = Db::table('设备_点检记录')->fetchSql(true)->insertAll($row);
  841. $res = Db::query($sql);
  842. if ($res !== false){
  843. $this->success('成功');
  844. }else{
  845. $this->error('失败');
  846. }
  847. }
  848. /**
  849. * 机台印版领用->左侧菜单
  850. * @ApiMethod (GET)
  851. * @param void
  852. * @return void
  853. */
  854. public function PrintGetTab()
  855. {
  856. if ($this->request->isGet() === false){
  857. $this->error('请求错误');
  858. }
  859. $param = $this->request->param();
  860. if (empty($param)){
  861. $this->error('参数错误');
  862. }
  863. $productCode = $param['productCode'];
  864. $sql = "SELECT DISTINCT(RTRIM(b.`名称`)) as `印版分类`,RTRIM(b.`编号`) as `编号` FROM `产品_印版资料` as a
  865. JOIN `物料_存货结构` as b ON b.`编号` = SUBSTRING(a.`存货编码`,1,4)
  866. WHERE a.YB_Cpdh = '{$productCode}'";
  867. $res = Db::query($sql);
  868. if (empty($res)){
  869. $this->error('未找到该产品印版资料');
  870. }
  871. $this->success('成功',$res);
  872. }
  873. /**
  874. * 机台印版领用记录->数据详情
  875. * @ApiMethod (GET)
  876. * @param void
  877. * @return void
  878. */
  879. public function PrintDetail()
  880. {
  881. if ($this->request->isGet() === false){
  882. $this->error('请求失败');
  883. }
  884. $param = $this->request->param();
  885. if (empty($param)){
  886. $this->error('参数错误');
  887. }
  888. $productCode = $param['productCode'];
  889. $code = $param['code'].'%';
  890. $workOrder = $param['workOrder'];
  891. $sql = "SELECT
  892. RTRIM(a.`存货编码`) as `存货编码`,
  893. RTRIM(c.`物料名称`) as `存货名称`,
  894. RTRIM(b.`印版名称`) as `印版名称`,
  895. RTRIM(b.`供方批号`) as `供方批号`,
  896. RTRIM(b.`制造日期`) as `制造日期`,
  897. SUM(d.`Yb_印数`) as `印数`,
  898. RTRIM(e.`名称`) as `印版类别`,
  899. SUBSTRING(a.YB_Cpdh,1,4) as `客户编号`,
  900. RTRIM(f.`Gd_客户名称`) as `客户名称`,
  901. RTRIM(a.YB_Cpdh) as `产品编号`,
  902. RTRIM(f.Gd_cpmc) as `产品名称`
  903. FROM `产品_印版资料` as a
  904. LEFT JOIN `产品_印版库` as b ON b.`存货编码` = a.`存货编码`
  905. JOIN `物料_存货编码` as c ON c.`物料代码` = a.`存货编码`
  906. LEFT JOIN `工单_印版领用记录` as d ON d.`Yb_供方批号` = b.`供方批号`
  907. JOIN `物料_存货结构` as e ON e.`编号` = SUBSTRING(a.`存货编码`,1,4)
  908. JOIN `工单_基本资料` as f ON a.YB_Cpdh = f.Gd_cpdh
  909. WHERE a.YB_Cpdh = '{$productCode}'
  910. AND a.`存货编码` LIKE '{$code}'
  911. AND f.Gd_gdbh = '{$workOrder}'
  912. AND b.`报废日期` = '1900-01-01 00:00:00'
  913. GROUP BY b.`供方批号`
  914. ORDER BY a.`存货编码`";
  915. $list = Db::query($sql);
  916. if (empty($list)){
  917. $this->error('未找到印版');
  918. }
  919. $this->success('成功',$list);
  920. }
  921. //换型清场记录->左侧菜单栏
  922. public function remodelGetTab()
  923. {
  924. if ($this->request->isGet() === false){
  925. $this->error('请求错误');
  926. }
  927. $date = date('Y-m-d 00:00:00',time()-3888000);
  928. $nowTime = date('Y-m-d H:i:s',time());
  929. $list = Db::table('设备_基本资料')->where('使用状态',1)->order('设备编号')->column('设备编号');
  930. if (empty($list)){
  931. $this->error('失败');
  932. }
  933. $sql = "SELECT RTRIM(a.`设备编号`) as `设备编号`,RTRIM(b.`日期`) as `日期`,RTRIM(b.UniqId) as UniqId FROM `设备_基本资料` as a
  934. LEFT JOIN `制程_换型清场` as b ON b.`机台编号` = a.`设备编号`
  935. WHERE b.`日期` > '{$date}' AND b.日期 < '{$nowTime}' ORDER BY b.`日期`";
  936. $res = Db::query($sql);
  937. $data = [];
  938. foreach ($list as $key=>$value){
  939. $i=0;
  940. $data[$value] = [];
  941. foreach ($res as $k=>$v){
  942. $row = [];
  943. if ($value === $v['设备编号']){
  944. $row[$i] = [
  945. '日期' => $v['日期'],
  946. 'id' => $v['UniqId']
  947. ];
  948. $i++;
  949. foreach ($row as $vv){
  950. }
  951. array_push($data[$value],$row);
  952. }
  953. }
  954. }
  955. $this->success('成功',$data);
  956. }
  957. /**
  958. * 换型清场->详情
  959. * @return void
  960. * @throws \think\db\exception\DataNotFoundException
  961. * @throws \think\db\exception\ModelNotFoundException
  962. * @throws \think\exception\DbException
  963. */
  964. public function RemodelDetail()
  965. {
  966. if ($this->request->isGet() === false){
  967. $this->error('请求错误');
  968. }
  969. $param = $this->request->param();
  970. if (empty($param)){
  971. $this->error('参数错误');
  972. }
  973. $field = 'rtrim(日期) as 日期,rtrim(班组) as 班组,rtrim(机台编号) as 机台编号,rtrim(工单编号A) as 工单编号A,rtrim(印件工序A) as 印件工序A,
  974. rtrim(码包号A) as 码包号A,rtrim(工单编号B) as 工单编号B,rtrim(印件工序B) as 印件工序B,rtrim(码包号B) as 码包B,
  975. rtrim(清场项目A) as 项目1,rtrim(清场项目B) as 项目2,rtrim(清场项目C) as 项目3,rtrim(清场项目D) as 项目4,rtrim(清场项目E) as 项目5,
  976. rtrim(机长) as 机长,rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员';
  977. $list = Db::table('制程_换型清场')->where('UniqId',$param['UniqId'])->field($field)->find();
  978. if (empty($list)){
  979. $this->error('未找到该条清场记录');
  980. }
  981. $list['日期'] = date('Y-m-d',strtotime($list['日期']));
  982. $list['印件名称A'] = Db::table('工单_印件资料')->where('Yj_Gdbh',$list['工单编号A'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
  983. $list['印件名称B'] = Db::table('工单_印件资料')->where('Yj_Gdbh',$list['工单编号B'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
  984. $this->success('成功',$list);
  985. }
  986. //换型清场->当前清场记录
  987. public function ModelChangeRecord()
  988. {
  989. if ($this->request->isGet() === false){
  990. $this->error('请求错误');
  991. }
  992. $param = $this->request->param();
  993. if (empty($param)){
  994. $this->error('参数错误');
  995. }
  996. $date = date('Y-m-d 00:00:00',time()-3888000);
  997. $nowTime = date('Y-m-d H:i:s',time());
  998. }
  999. }