Facility.php 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  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. $sql = "SELECT
  225. rtrim(b.Gy0_gdbh) AS 工单编号,
  226. rtrim(b.Gy0_yjno) AS 印件号,
  227. rtrim(b.Gy0_gxh) AS gxh,
  228. rtrim(b.Gy0_gxmc) AS gxmc,
  229. rtrim(b.Add_gxmc) AS add_gxmc,
  230. RTRIM(a.Gd_cpmc) AS 产品名称
  231. FROM
  232. `工单_基本资料` AS a
  233. JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
  234. JOIN `产品_基本资料` AS c ON a.`成品代号` = c.`产品编号`
  235. JOIN `工单_印件资料` AS d ON a.Gd_gdbh = d.Yj_Gdbh
  236. LEFT JOIN `设备_产量计酬` AS e ON e.sczl_gdbh = a.Gd_gdbh
  237. AND e.sczl_jtbh = b.Gy0_sbbh
  238. WHERE
  239. a.gd_statu = '2-生产中'
  240. AND a.`行号` = '1'
  241. AND b.Gy0_sbbh = '{$machine}'
  242. AND c.`状态` = ''
  243. AND b.PD_WG = '1900-01-01 00:00:00'
  244. AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
  245. GROUP BY
  246. a.Gd_gdbh
  247. ORDER BY
  248. b.Gy0_sj1
  249. LIMIT 1";
  250. $list = Db::query($sql);
  251. if (empty($list)){
  252. $this->error('未找到排产工单');
  253. }
  254. foreach ($list as $key=>$value){
  255. if ($value['gxh']<10){
  256. $list[$key]['gxh'] = '0'.$value['gxh'];
  257. }
  258. $list[$key]['工序名称'] = $list[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  259. unset($list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['add_gxmc']);
  260. }
  261. $this->success('成功',$list);
  262. }
  263. /**
  264. * 设备工作清单
  265. * @ApiMethod (GET)
  266. * @param string $machine 机台编号
  267. * @return void
  268. * @throws \think\db\exception\DataNotFoundException
  269. * @throws \think\db\exception\ModelNotFoundException
  270. * @throws \think\exception\DbException
  271. */
  272. public function EquipmentWorklist()
  273. {
  274. if ($this->request->isGet() === false){
  275. $this->error('请求错误');
  276. }
  277. $machine = input('machine');
  278. if (empty($machine)){
  279. $this->error('参数错误');
  280. }
  281. $sql = "SELECT
  282. rtrim( b.Gy0_gdbh ) AS gdbh,
  283. rtrim(b.质量要求) AS 质量信息,
  284. rtrim( b.Gy0_yjno ) AS yjno,
  285. rtrim( b.Gy0_gxh ) AS gxh,
  286. rtrim( b.Gy0_gxmc ) AS gxmc,
  287. rtrim( b.Add_gxmc ) AS add_gxmc,
  288. rtrim( b.Gy0_辅助工时 ) AS 装版时数,
  289. rtrim( b.Gy0_小时产能 ) AS 工序产能,
  290. rtrim( b.Gy0_生产工时 ) AS 计划工时,
  291. rtrim( b.Gy0_sj1 ) AS sj1,
  292. rtrim( b.Gy0_sj2 ) AS sj2,
  293. rtrim(b.工序备注) AS 排产备注,
  294. RTRIM(d.yj_yjmc) AS 印件名称,
  295. RTRIM(a.Gd_cpmc) AS 产品名称,
  296. RTRIM(a.成品代号) AS 产品代号,
  297. SUM(E.sczl_cl) AS 已完成,
  298. rtrim(b.Gy0_计划接货数) AS 计划接货数,
  299. RTRIM(b.Gy0_ls) AS ls
  300. FROM
  301. `工单_基本资料` AS a
  302. JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
  303. JOIN `产品_基本资料` AS c ON a.`成品代号` = c.`产品编号`
  304. JOIN `工单_印件资料` AS d ON a.Gd_gdbh = d.Yj_Gdbh
  305. LEFT JOIN `设备_产量计酬` AS e ON e.sczl_gdbh = a.Gd_gdbh AND e.sczl_jtbh = b.Gy0_sbbh
  306. WHERE
  307. a.gd_statu = '2-生产中'
  308. AND a.`行号` = '1'
  309. AND b.Gy0_sbbh = '{$machine}'
  310. AND c.`状态` = ''
  311. AND b.PD_WG = '1900-01-01 00:00:00'
  312. AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
  313. GROUP BY a.Gd_gdbh
  314. ORDER BY b.Gy0_sj1";
  315. $orderList = Db::query($sql);
  316. if (empty($orderList)){
  317. $this->error('未找到排产工单');
  318. }
  319. foreach ($orderList as $key=>$value){
  320. $orderList[$key]['工单编号|质量信息'] = $value['gdbh'].'|'.$value['质量信息'];
  321. if ($value['yjno']<10){
  322. $orderList[$key]['yjno'] = '0'.$value['yjno'];
  323. }
  324. if ($value['gxh']<10){
  325. $orderList[$key]['gxh'] = '0'.$value['gxh'];
  326. }
  327. $orderList[$key]['印件资料'] = $orderList[$key]['yjno'].'-'.$value['印件名称'];
  328. $orderList[$key]['工序名称'] = $orderList[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
  329. $orderList[$key]['计划产量/已完成'] = (int)($value['计划接货数']/$value['ls']).'/'.$value['已完成']=null?'':(int)$value['已完成'];
  330. $orderList[$key]['计划生产时段'] =substr($value['sj1'],5,5).' '.substr($value['sj1'],11,5).'<-->'.substr($value['sj2'],5,5).' '.substr($value['sj2'],11,5);
  331. 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'],$orderList[$key]['计划接货数'],$orderList[$key]['已完成'],$orderList[$key]['印件名称'],$orderList[$key]['ls']);
  332. }
  333. $this->success('成功',$orderList);
  334. }
  335. /**
  336. * 工序、印件、完成数量
  337. * @ApiMethod (GET)
  338. * @param string $workOrder 工单编号
  339. * @return void
  340. * @throws \think\Exception
  341. * @throws \think\db\exception\DataNotFoundException
  342. * @throws \think\db\exception\ModelNotFoundException
  343. * @throws \think\exception\DbException
  344. */
  345. public function Procedure()
  346. {
  347. if ($this->request->isGet() === false){
  348. $this->error('请求错误');
  349. }
  350. $workOrder = input('Gd_gdbh');
  351. if (empty($workOrder)){
  352. $this->error('参数错误');
  353. }
  354. // $lastUniqid = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
  355. // $startUniqid = $lastUniqid['UniqId']-100000;
  356. //右边工艺及完成数量
  357. $Process = Db::table('设备_产量计酬')->where('sczl_gdbh',$workOrder)
  358. // ->where('UniqId','>',$startUniqid)
  359. ->distinct(true)->order('sczl_gxh')
  360. ->column('sczl_gxh');
  361. $data = [];
  362. foreach ($Process as $k=>$v){
  363. $res= Db::table('设备_产量计酬')->where('sczl_gdbh',$workOrder)
  364. // ->where('UniqId','>',$startUniqid)
  365. ->where('sczl_gxh',$v)
  366. ->field('rtrim(sczl_yjno) as sczl_yjno,rtrim(sczl_gxmc) as sczl_gxmc')
  367. ->find();
  368. if ($res['sczl_yjno']<10){
  369. $res['sczl_yjno'] = '0'.$res['sczl_yjno'];
  370. }
  371. $processList['process'] = $res['sczl_yjno'].'-'.$res['sczl_gxmc'];
  372. $processList['completed'] = Db::table('设备_产量计酬')
  373. ->where('sczl_gdbh',$workOrder)
  374. // ->where('UniqId','>',$startUniqid)
  375. ->where('sczl_gxh',$v)
  376. ->count();
  377. array_push($data,$processList);
  378. }
  379. $this->success('成功',$data);
  380. }
  381. /**
  382. * 班组人员及分配比例
  383. * @ApiMethod (GET)
  384. * @param string $machine 机台编号
  385. * @return void
  386. * @throws \think\db\exception\DataNotFoundException
  387. * @throws \think\db\exception\ModelNotFoundException
  388. * @throws \think\exception\DbException
  389. */
  390. public function Team()
  391. {
  392. if ($this->request->isGet() === false){
  393. $this->error('请求错误');
  394. }
  395. $machine = input('machine');
  396. if (empty($machine)){
  397. $this->error('参数错误');
  398. }
  399. $where = [
  400. 'sczl_jtbh' => $machine,
  401. ];
  402. $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,
  403. 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,
  404. 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,
  405. rtrim(sczl_rate5) as rate5,rtrim(sczl_rate6) as rate6,rtrim(sczl_rate7) as rate7,rtrim(sczl_rate8) as rate8,
  406. rtrim(sczl_rate9) as rate9,rtrim(sczl_rate10) as rate10,rtrim(UniqId) as ID';
  407. $team = Db::table('设备_产量计酬')
  408. ->where('sczl_jtbh',$machine)
  409. ->field($field)
  410. ->order('UniqId desc')
  411. ->find();
  412. $list = Db::table('设备_班组资料')->where($where)->field($field)->select();
  413. $data = [];
  414. foreach ($list as $k=>$v){
  415. if ($team == $v){
  416. $data[$k]['status'] = 1;
  417. }else{
  418. $data[$k]['status'] = 0;
  419. }
  420. $data[$k]['ID'] = $v['ID'];
  421. $data[$k]['班组号'] = $v['班组号'];
  422. for ($i=1;$i<11;$i++){
  423. if ($v['bh'.$i] != '' && $v['bh'.$i] != '000000'){
  424. $name = Db::table('人事_基本资料')->where('员工编号',$v['bh'.$i])->field('rtrim(员工姓名) as 姓名')->find();
  425. $data[$k][$i-1] = $v['bh'.$i].' '.$name['姓名'].' ('.number_format($v['rate'.$i]*100,2).'%'.')';
  426. }
  427. }
  428. }
  429. $this->success('成功',$data);
  430. }
  431. /**
  432. * 当班产量明细
  433. * @ApiMethod (GET)
  434. * @param string $machine 机台编号
  435. * @param string $workOrder 工单编号
  436. * @param string $team 班次
  437. * @return void
  438. * @throws \think\db\exception\DataNotFoundException
  439. * @throws \think\db\exception\ModelNotFoundException
  440. * @throws \think\exception\DbException
  441. */
  442. public function OutputDetail()
  443. {
  444. if ($this->request->isGet() === false){
  445. $this->error('请求错误');
  446. }
  447. $machine = input('machine');
  448. $workOrder = input('Gd_gdbh');
  449. $team = input('team');
  450. if (empty($machine) || empty($workOrder) || empty($team)){
  451. $this->error('参数错误');
  452. }
  453. // $lastUniqid = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
  454. // $startUniqid = $lastUniqid['UniqId']-100000;
  455. $name = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(Gd_cpmc) as productName')->find();
  456. $where = [
  457. // 'UniqId' => ['>',$startUniqid],
  458. 'sczl_gdbh' => $workOrder,
  459. 'sczl_jtbh' => $machine,
  460. 'sczl_cl' => ['<>',0.0],
  461. 'sczl_bzdh' => $team,
  462. ];
  463. $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as 标牌号,rtrim(sczl_cl) as 产量,
  464. rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,rtrim(sczl_装版工时) as 装版工时,
  465. rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,rtrim(sczl_异常停机工时) as 异常停机工时,rtrim(sczl_设备运行工时) as 通电工时,
  466. rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度,
  467. rtrim(sczl_sj1) as sj1,rtrim(sczl_sj2) as sj2';
  468. $list = Db::table('设备_产量计酬')->where($where)->field($field)->order('UniqId desc')->select();
  469. if (empty($list)){
  470. $this->error('未找到生产记录');
  471. }
  472. foreach ($list as $k=>$v){
  473. if ($v['yjno']<10){
  474. $list[$k]['yjno'] = '0'.$v['yjno'];
  475. }
  476. $list[$k]['印件及工序'] = $list[$k]['yjno'].'-'.$v['gxmc'];
  477. $list[$k]['生产时间段'] = substr($v['sj1'],5,5).' '.substr($v['sj1'],11,5).'<-->'.substr($v['sj2'],5,5).' '.substr($v['sj2'],11,5);
  478. $list[$k]['产品名称'] = $name['productName'];
  479. unset($list[$k]['yjno'],$list[$k]['gxmc'],$list[$k]['sj1'],$list[$k]['sj2']);
  480. }
  481. $field1 = 'SUM(sczl_cl) as 产量,SUM(sczl_zcfp) as 制程废品,SUM(sczl_zccp) as 制程次品,SUM(sczl_前工序废) as 前工序废,
  482. SUM(sczl_来料少数) as 来料异常,SUM(sczl_装版工时) as 装版工时,SUM(sczl_保养工时) as 保养工时,SUM(sczl_打样工时) as 打样工时,
  483. SUM(sczl_异常停机工时) as 异常停机工时,SUM(sczl_设备运行工时) as 通电工时,SUM(码开始行) as 码开始行,SUM(码结束行) as 码结束行,
  484. SUM(码包) as 码包,SUM(主电表) as 主电表,SUM(辅电表) as 辅电表';
  485. $total = Db::table('设备_产量计酬')->where($where)->field($field1)->order('UniqId desc')->select();
  486. $total[0]['版数'] = count($list);
  487. $list['total'] = $total[0];
  488. $this->success('成功',$list);
  489. }
  490. /**
  491. * 检验记录
  492. * @ApiMethod (GET)
  493. * @param string $machine 机台编号
  494. * @param string $workOrder 工单编号
  495. * @param string $team 班次
  496. * @return void
  497. * @throws \think\db\exception\DataNotFoundException
  498. * @throws \think\db\exception\ModelNotFoundException
  499. * @throws \think\exception\DbException
  500. */
  501. public function InspectionRecord()
  502. {
  503. if ($this->request->isGet() === false){
  504. $this->error('请求失败');
  505. }
  506. $machine = input('machine');
  507. $workOrder = input('Gd_gdbh');
  508. $team = input('team');
  509. if (empty($machine) || empty($workOrder) || empty($team)){
  510. $this->error('参数错误');
  511. }
  512. // $last_id = Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find();
  513. // $startId = $last_id['UniqId']-100000;
  514. $where = [
  515. '设备编号' => $machine,
  516. '工单编号' => $workOrder,
  517. '班组编号' => $team,
  518. '类别' => ['in',['IPQC检验','机台检验']],
  519. // 'UniqId' => ['>',$startId],
  520. ];
  521. //检验项目筛选
  522. $item = Db::table('制程检验_记录')->where($where)->distinct(true)->column('rtrim(检验项目)');
  523. //检验时间
  524. $InspectionTime = Db::table('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
  525. foreach ($InspectionTime as $k=>$v){
  526. $InspectionTime[$k] = date('H:i',strtotime($v));
  527. }
  528. //检测记录详情
  529. $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
  530. $nameDetail = Db::table('制程检验_记录')->where($where)->field($field)->find();
  531. $data = [];
  532. //检测数据
  533. foreach ($item as $key=>$value){
  534. $SubmissionTime = Db::table('制程检验_记录')->where($where)
  535. ->where('检验项目',$value)
  536. ->where('检验结果','合格')
  537. ->field('rtrim(提交时间) as 提交时间')
  538. ->select();
  539. $time = [];
  540. foreach ($SubmissionTime as $k=>$v){
  541. $time[$k] = date('H:i',strtotime($v['提交时间']));
  542. }
  543. $data[$key] = [
  544. '工单编号' => $nameDetail['工单编号'],
  545. '印件号' => $nameDetail['印件号'],
  546. '工序名称' => $nameDetail['工序名称'],
  547. '检验项目' => $value,
  548. 'inspectresult' => implode(',',$time),
  549. ];
  550. }
  551. $data['inspectiontime'] = $InspectionTime;
  552. $this->success('成功',$data);
  553. }
  554. //班组维护
  555. public function TeamMaintenance()
  556. {
  557. if (Request::instance()->isPost() === false){
  558. $this->error('请求错误');
  559. }
  560. $data = Request::instance()->post();
  561. if (empty($data)){
  562. $this->error('参数错误');
  563. }
  564. $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,
  565. 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,
  566. 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,
  567. rtrim(sczl_rate5) as sczl_rate5,rtrim(sczl_rate6) as sczl_rate6,rtrim(sczl_rate7) as sczl_rate7,rtrim(sczl_rate8) as sczl_rate8,
  568. rtrim(sczl_rate9) as sczl_rate9,rtrim(sczl_rate10) as sczl_rate10';
  569. $TeamList = Db::table('设备_班组资料')->where('UniqId',$data['ID'])->field($field)->find();
  570. }
  571. /**
  572. * 机台编号列表
  573. * @ApiMethod (GET)
  574. * @return void
  575. */
  576. public function MachineList()
  577. {
  578. if ($this->request->isGet() === false){
  579. $this->error('请求错误');
  580. }
  581. $list = Db::table('设备_基本资料')->column('设备编号');
  582. if (empty($list)){
  583. $this->error('未找到机台编号');
  584. }
  585. $this->success('成功',$list);
  586. }
  587. /**
  588. * 删除班组信息
  589. * @ApiMethod (GET)
  590. * @param void
  591. * @return void
  592. * @throws \think\Exception
  593. * @throws \think\exception\PDOException
  594. */
  595. public function teamDel()
  596. {
  597. if (Request::instance()->isPost() === false){
  598. $this->error('请求错误');
  599. }
  600. $param = Request::instance()->post();
  601. if (empty($param)){
  602. $this->error('参数错误');
  603. }
  604. $res = Db::table('设备_班组资料')
  605. ->where('UniqId',$param['UniqId'])
  606. ->delete();
  607. if ($res !== false){
  608. $this->success('成功');
  609. }else{
  610. $this->error('失败');
  611. }
  612. }
  613. //制程检验记录->指标检验
  614. public function ProcessInspectionRecords()
  615. {
  616. if ($this->request->isGet() === false){
  617. $this->error('请求错误');
  618. }
  619. $param = $this->request->param();
  620. if (empty($param)){
  621. $this->error('参数错误');
  622. }
  623. // $filed = ''
  624. }
  625. /**
  626. * 管理人员现场巡检记录->展示
  627. * @ApiMethod (GET)
  628. * @param void
  629. * @return void
  630. * @throws \think\db\exception\DataNotFoundException
  631. * @throws \think\db\exception\ModelNotFoundException
  632. * @throws \think\exception\DbException
  633. */
  634. public function FieldInspectionRecord()
  635. {
  636. if ($this->request->isGet() === false){
  637. $this->error('请求错误');
  638. }
  639. $param = $this->request->param();
  640. if (empty($param)){
  641. $this->error('参数错误');
  642. }
  643. // $last_id = Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find();
  644. // $startId = $last_id['UniqId']-100000;
  645. $date = date('Y-m-d H:i:s',time());
  646. $startTime = date('Y-m-d 08:30:00',time());
  647. if ($date<$startTime){
  648. $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
  649. }
  650. $where = [
  651. '工单编号' => $param['workOrder'],
  652. '开工时间' => $startTime,
  653. '类别' => '现场巡查记录',
  654. '班组编号' => $param['team']
  655. ];
  656. $filed = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,rtrim(流程单号) as 流程单号,
  657. rtrim(设备编号) as 设备编号,rtrim(班组编号) as 班组编号,rtrim(检验项目) as 现场管理人员,rtrim(检验备注) as 检验备注,
  658. rtrim(提交时间) as 提交时间,rtrim(开工时间) as 开工时间';
  659. $list = Db::table('制程检验_记录')->where($where)
  660. // ->where('UniqId','>',$startId)
  661. ->field($filed)
  662. // ->fetchSql(true)
  663. ->select();
  664. if (empty($list)){
  665. $this->error('未找到该工单当前班次巡检记录');
  666. }
  667. foreach ($list as $key=>$value){
  668. $number = floor((strtotime($value['提交时间'])-strtotime($value['开工时间']))/(15*60));
  669. $list[$key]['归属时段'] = $value['开工时间'];
  670. $list[$key]['分钟差数'] = $number;
  671. if ($number != 0){
  672. $list[$key]['归属时段'] = date('Y-m-d H:i:s',strtotime($value['开工时间'])+$number*15*60);
  673. }
  674. }
  675. $this->success('成功',$list);
  676. }
  677. /**
  678. * 管理人员现场巡检记录->添加
  679. * @ApiMethod (POST)
  680. * @param void
  681. * @return void
  682. */
  683. public function FieldInspectionRecordAdd()
  684. {
  685. if (Request::instance()->isPost() === false){
  686. $this->error('请求错误');
  687. }
  688. $param = Request::instance()->post();
  689. if (empty($param)){
  690. $this->error('参数错误');
  691. }
  692. if ($param['processCode']<10){
  693. $param['processCode'] = '0'.$param['processCode'];
  694. }
  695. $date = date('Y-m-d H:i:s',time());
  696. $startTime = date('Y-m-d 08:30:00',time());
  697. if ($date<$startTime){
  698. $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
  699. }
  700. $data = [
  701. '类别' => $param['category'],
  702. '工单编号' => $param['workOrder'],
  703. '印件号' => $param['printCode'],
  704. '工序名称' => $param['processCode'].'-'.$param['process'],
  705. '流程单号' => $param['flowCode'],
  706. '设备编号' => $param['machine'],
  707. '班组编号' => $param['team'],
  708. '检验项目' => '['.$param['employeeCode'].'/'.$param['employeeName'].']',
  709. '相关标准' => '',
  710. '量测仪器' => '',
  711. '检验结果' => '',
  712. '检验备注' => $param['remark'],
  713. '提交时间' => date('Y-m-d H:i:s',time()),
  714. '开工时间' => $startTime,
  715. 'sys_id' => '',
  716. 'sys_rq' => date('Y-m-d H:i:s',time()),
  717. 'mod_rq' => '',
  718. 'UniqId' => Db::table('制程检验_记录')->order('UniqId desc')->field('UniqId')->find()['UniqId']+1
  719. ];
  720. $sql = Db::table('制程检验_记录')->fetchSql(true)->insert($data);
  721. $res = Db::query($sql);
  722. if ($res !== false){
  723. $this->success('成功');
  724. }else{
  725. $this->error('失败');
  726. }
  727. }
  728. /**
  729. * 设备点检->左侧菜单栏
  730. * @ApiMethod (GET)
  731. * @param void
  732. * @return void
  733. */
  734. public function SpotCheckItem()
  735. {
  736. if ($this->request->isGet() === false){
  737. $this->error('请求错误');
  738. }
  739. $param = $this->request->param();
  740. if (empty($param)){
  741. $this->error('参数错误');
  742. }
  743. $list = Db::table('设备_点检项目')
  744. ->where('适用机型','LIKE','%;'.$param['machine'].';%')
  745. ->distinct(true)
  746. ->column('部件名称','部件编号');
  747. if (empty($list)){
  748. $this->error('未找到检验项目');
  749. }
  750. $this->success('成功',$list);
  751. }
  752. /**
  753. * 设备点检->检测项目
  754. * @ApiMethod (GET)
  755. * @param void
  756. * @return void
  757. * @throws \think\db\exception\DataNotFoundException
  758. * @throws \think\db\exception\ModelNotFoundException
  759. * @throws \think\exception\DbException
  760. */
  761. public function InspectionItem()
  762. {
  763. if ($this->request->isGet() === false){
  764. $this->error('请求错误');
  765. }
  766. $param = $this->request->param();
  767. if (empty($param)){
  768. $this->error('参数错误');
  769. }
  770. $list = Db::table('设备_点检项目')
  771. ->where('部件名称',$param['unitName'])
  772. ->field('rtrim(检验项目) as 检验项目,rtrim(判定标准) as 判定标准,rtrim(点检方法) as 点检方法')
  773. ->select();
  774. if (empty($list)){
  775. $this->error('未找到检测项目');
  776. }
  777. $this->success('成功',$list);
  778. }
  779. /**
  780. * 设备点检->检测记录添加
  781. * @ApiMethod (POST)
  782. * @param void
  783. * @return void
  784. * @throws \think\db\exception\DataNotFoundException
  785. * @throws \think\db\exception\ModelNotFoundException
  786. * @throws \think\exception\DbException
  787. */
  788. public function InspectionItemAdd()
  789. {
  790. if (Request::instance()->isPost() === false){
  791. $this->error('请求错误');
  792. }
  793. $param = Request::instance()->post();
  794. if (empty($param)){
  795. $this->error('参数错误');
  796. }
  797. $data = [
  798. 'team' => $param['team'],
  799. 'machine' => $param['machine'],
  800. 'unitName' => $param['unitName']
  801. ];
  802. unset($param['team'],$param['machine'],$param['unitName']);
  803. $lastId = Db::table('设备_点检记录')->field('rtrim(Uniqid) as id')->order('Uniqid desc')->find();
  804. $unitCode = Db::table('设备_点检项目')->where('部件名称',$data['unitName'])->field('rtrim(部件编号) as 部件编号')->find();
  805. $row = [];
  806. $param = array_values($param);
  807. foreach ($param as $key=>$value){
  808. $value = explode(';',$value);
  809. $row[$key] = [
  810. '日期' => date('Y-m-d 00:00:00',time()),
  811. '班组编号' => $data['team'],
  812. '点检设备' => $data['machine'],
  813. '部件编号' => $unitCode['部件编号'],
  814. '部件名称' => $data['unitName'],
  815. '检验项目' => $value[0],
  816. '判定标准' => $value[4],
  817. '点检方法' => $value[1],
  818. '点检结果' => $value[2],
  819. '备注说明' => $value[3],
  820. 'Sys_id' =>'',
  821. 'Sys_rq' => date('Y-m-d H:i:s',time()),
  822. 'Mod_rq' => '',
  823. 'Uniqid' => $lastId['id']+$key+1
  824. ];
  825. }
  826. $sql = Db::table('设备_点检记录')->fetchSql(true)->insertAll($row);
  827. $res = Db::query($sql);
  828. if ($res !== false){
  829. $this->success('成功');
  830. }else{
  831. $this->error('失败');
  832. }
  833. }
  834. /**
  835. * 机台印版领用->左侧菜单
  836. * @ApiMethod (GET)
  837. * @param void
  838. * @return void
  839. */
  840. public function PrintGetTab()
  841. {
  842. if ($this->request->isGet() === false){
  843. $this->error('请求错误');
  844. }
  845. $param = $this->request->param();
  846. if (empty($param)){
  847. $this->error('参数错误');
  848. }
  849. $productCode = $param['productCode'];
  850. $sql = "SELECT DISTINCT(RTRIM(b.`名称`)) as `印版分类`,RTRIM(b.`编号`) as `编号` FROM `产品_印版资料` as a
  851. JOIN `物料_存货结构` as b ON b.`编号` = SUBSTRING(a.`存货编码`,1,4)
  852. WHERE a.YB_Cpdh = '{$productCode}'";
  853. $res = Db::query($sql);
  854. if (empty($res)){
  855. $this->error('未找到该产品印版资料');
  856. }
  857. $this->success('成功',$res);
  858. }
  859. /**
  860. * 机台印版领用记录->数据详情
  861. * @ApiMethod (GET)
  862. * @param void
  863. * @return void
  864. */
  865. public function PrintDetail()
  866. {
  867. if ($this->request->isGet() === false){
  868. $this->error('请求失败');
  869. }
  870. $param = $this->request->param();
  871. if (empty($param)){
  872. $this->error('参数错误');
  873. }
  874. $productCode = $param['productCode'];
  875. $code = $param['code'].'%';
  876. $workOrder = $param['workOrder'];
  877. $sql = "SELECT
  878. RTRIM(a.`存货编码`) as `存货编码`,
  879. RTRIM(c.`物料名称`) as `存货名称`,
  880. RTRIM(b.`印版名称`) as `印版名称`,
  881. RTRIM(b.`供方批号`) as `供方批号`,
  882. RTRIM(b.`制造日期`) as `制造日期`,
  883. SUM(d.`Yb_印数`) as `印数`,
  884. RTRIM(e.`名称`) as `印版类别`,
  885. SUBSTRING(a.YB_Cpdh,1,4) as `客户编号`,
  886. RTRIM(f.`Gd_客户名称`) as `客户名称`,
  887. RTRIM(a.YB_Cpdh) as `产品编号`,
  888. RTRIM(f.Gd_cpmc) as `产品名称`
  889. FROM `产品_印版资料` as a
  890. LEFT JOIN `产品_印版库` as b ON b.`存货编码` = a.`存货编码`
  891. JOIN `物料_存货编码` as c ON c.`物料代码` = a.`存货编码`
  892. LEFT JOIN `工单_印版领用记录` as d ON d.`Yb_供方批号` = b.`供方批号`
  893. JOIN `物料_存货结构` as e ON e.`编号` = SUBSTRING(a.`存货编码`,1,4)
  894. JOIN `工单_基本资料` as f ON a.YB_Cpdh = f.Gd_cpdh
  895. WHERE a.YB_Cpdh = '{$productCode}'
  896. AND a.`存货编码` LIKE '{$code}'
  897. AND f.Gd_gdbh = '{$workOrder}'
  898. AND b.`报废日期` = '1900-01-01 00:00:00'
  899. GROUP BY b.`供方批号`
  900. ORDER BY a.`存货编码`";
  901. $list = Db::query($sql);
  902. if (empty($list)){
  903. $this->error('未找到印版');
  904. }
  905. $this->success('成功',$list);
  906. }
  907. //换型清场记录->左侧菜单栏
  908. public function remodelGetTab()
  909. {
  910. if ($this->request->isGet() === false){
  911. $this->error('请求错误');
  912. }
  913. $date = date('Y-m-d 00:00:00',time()-3888000);
  914. $nowTime = date('Y-m-d H:i:s',time());
  915. $list = Db::table('设备_基本资料')->where('使用状态',1)->order('设备编号')->column('设备编号');
  916. if (empty($list)){
  917. $this->error('失败');
  918. }
  919. $sql = "SELECT RTRIM(a.`设备编号`) as `设备编号`,RTRIM(b.`日期`) as `日期`,RTRIM(b.UniqId) as UniqId FROM `设备_基本资料` as a
  920. LEFT JOIN `制程_换型清场` as b ON b.`机台编号` = a.`设备编号`
  921. WHERE b.`日期` > '{$date}' AND b.日期 < '{$nowTime}' ORDER BY b.`日期`";
  922. $res = Db::query($sql);
  923. $data = [];
  924. foreach ($list as $key=>$value){
  925. $i=0;
  926. $data[$value] = [];
  927. foreach ($res as $k=>$v){
  928. $row = [];
  929. if ($value === $v['设备编号']){
  930. $row[$i] = [
  931. '日期' => $v['日期'],
  932. 'id' => $v['UniqId']
  933. ];
  934. $i++;
  935. foreach ($row as $vv){
  936. }
  937. array_push($data[$value],$row);
  938. }
  939. }
  940. }
  941. $this->success('成功',$data);
  942. }
  943. /**
  944. * 换型清场->详情
  945. * @return void
  946. * @throws \think\db\exception\DataNotFoundException
  947. * @throws \think\db\exception\ModelNotFoundException
  948. * @throws \think\exception\DbException
  949. */
  950. public function RemodelDetail()
  951. {
  952. if ($this->request->isGet() === false){
  953. $this->error('请求错误');
  954. }
  955. $param = $this->request->param();
  956. if (empty($param)){
  957. $this->error('参数错误');
  958. }
  959. $field = 'rtrim(日期) as 日期,rtrim(班组) as 班组,rtrim(机台编号) as 机台编号,rtrim(工单编号A) as 工单编号A,rtrim(印件工序A) as 印件工序A,
  960. rtrim(码包号A) as 码包号A,rtrim(工单编号B) as 工单编号B,rtrim(印件工序B) as 印件工序B,rtrim(码包号B) as 码包B,
  961. rtrim(清场项目A) as 项目1,rtrim(清场项目B) as 项目2,rtrim(清场项目C) as 项目3,rtrim(清场项目D) as 项目4,rtrim(清场项目E) as 项目5,
  962. rtrim(机长) as 机长,rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员';
  963. $list = Db::table('制程_换型清场')->where('UniqId',$param['UniqId'])->field($field)->find();
  964. if (empty($list)){
  965. $this->error('未找到该条清场记录');
  966. }
  967. $list['日期'] = date('Y-m-d',strtotime($list['日期']));
  968. $list['印件名称A'] = Db::table('工单_印件资料')->where('Yj_Gdbh',$list['工单编号A'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
  969. $list['印件名称B'] = Db::table('工单_印件资料')->where('Yj_Gdbh',$list['工单编号B'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
  970. $this->success('成功',$list);
  971. }
  972. //换型清场->当前清场记录
  973. public function ModelChangeRecord()
  974. {
  975. if ($this->request->isGet() === false){
  976. $this->error('请求错误');
  977. }
  978. $param = $this->request->param();
  979. if (empty($param)){
  980. $this->error('参数错误');
  981. }
  982. $date = date('Y-m-d 00:00:00',time()-3888000);
  983. $nowTime = date('Y-m-d H:i:s',time());
  984. }
  985. }