Facility.php 43 KB

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