YxManufacture.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use think\Request;
  6. class YxManufacture extends Api
  7. {
  8. protected $noNeedRight = ['*'];
  9. protected $noNeedLogin = ['*'];
  10. /**
  11. * 计划中工单
  12. * @ApiMethod (GET)
  13. * @return \think\response\Json
  14. * @throws \think\db\exception\DataNotFoundException
  15. * @throws \think\db\exception\ModelNotFoundException
  16. * @throws \think\exception\DbException
  17. */
  18. public function Project()
  19. {
  20. if ($this->request->isGet() === false){
  21. $this->error('请求错误');
  22. }
  23. $param = $this->request->param();
  24. if (empty($param)){
  25. $this->error('参数错误');
  26. }
  27. if ($param['status'] === '计划中'){
  28. $status = '3-计划中';
  29. }else{
  30. $status = '1-已完工';
  31. }
  32. $page = 0;
  33. $limit = 15;
  34. if (isset($param['page'])){
  35. $page = $param['page'];
  36. }
  37. if (isset($param['limit'])){
  38. $limit = $param['limit'];
  39. }
  40. $where = [
  41. 'gd_statu' => $status,
  42. // '行号' => '1',
  43. ];
  44. $where['工单分类'] = ['in',[1,3]];
  45. if (isset($param['search'])){
  46. $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$param['search'].'%'];
  47. }
  48. $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(成品名称) as 成品名称,
  49. rtrim(接单日期) as 接单日期,rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(Gd_khmc) as 客户名称,
  50. rtrim(Gd_客户代号) as 客户编号,rtrim(Gd_desc) as 备注,rtrim(客户料号) as 客户料号,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,
  51. rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
  52. $list = \db('工单_基本资料')->where($where)->field($field)->limit(($page-1)*$limit,$limit)->order('Uniqid desc')->select();
  53. $total = \db('工单_基本资料')->where($where)->count();
  54. if (empty($list)){
  55. $this->success('',[]);
  56. }
  57. foreach ($list as $key=>$value){
  58. $list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
  59. $list[$key]['产品名称'] = $value['产品名称'] != '' ? $value['产品名称']:$value['成品名称'];
  60. $number = \db('工单_工艺资料')->where('Gy0_gdbh',$value['工单编号'])->count();
  61. if ($number === 0){
  62. $list[$key]['status'] = 0;
  63. }else{
  64. $list[$key]['status'] = 1;
  65. }
  66. unset($list[$key]['成品名称']);
  67. }
  68. $this->success('成功',['data'=>$list,'total'=>$total]);
  69. }
  70. /**
  71. * 计划中工单->工艺资料
  72. * @ApiMethod (GET)
  73. * @param string $Gd_gdbh 工单编号
  74. * @return \think\response\Json
  75. * @throws \think\db\exception\DataNotFoundException
  76. * @throws \think\db\exception\ModelNotFoundException
  77. * @throws \think\exception\DbException
  78. */
  79. public function projectCraft()
  80. {
  81. if ($this->request->isGet() === false){
  82. $this->error('请求错误');
  83. }
  84. $Gd_gdbh = input('Gd_gdbh');
  85. if (empty($Gd_gdbh)){
  86. $this->error('参数错误');
  87. }
  88. $where = [
  89. 'Gy0_gdbh' => $Gd_gdbh
  90. ];
  91. $filed = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(重点工序) as 重点工序,Gy0_yjno,Gy0_gxh,Gy0_gxmc,Add_gxmc,rtrim(工序备注) as 工序备注,
  92. rtrim(Gy0_sbbh) as 机组,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,
  93. rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(UniqId) as UNIQID';
  94. $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
  95. if (empty($list)){
  96. $this->success('',[]);
  97. }
  98. foreach ($list as $key=>$value){
  99. if ((int)$value['Gy0_yjno'] <10){
  100. $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
  101. }
  102. if ((int)$value['Gy0_gxh'] <10){
  103. $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
  104. }
  105. if (rtrim($value['Add_gxmc']) == ''){
  106. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
  107. }else{
  108. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
  109. }
  110. unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
  111. }
  112. $this->success('成功',$list);
  113. }
  114. /**
  115. * 计划中工单->印件资料
  116. * @ApiMethod (GET)
  117. * @param string $Gd_gdbh 工单编号
  118. * @return \think\response\Json
  119. * @throws \think\db\exception\DataNotFoundException
  120. * @throws \think\db\exception\ModelNotFoundException
  121. * @throws \think\exception\DbException
  122. */
  123. public function projectPrint()
  124. {
  125. if ($this->request->isGet() === false){
  126. $this->error('请求错误');
  127. }
  128. $Gd_gdbh = input('Gd_gdbh');
  129. if (empty($Gd_gdbh)){
  130. $this->error('参数错误');
  131. }
  132. $where = [
  133. 'Yj_Gdbh' => $Gd_gdbh,
  134. ];
  135. $field = 'rtrim(Yj_Gdbh) as 工单编号,rtrim(yj_Yjno) as 印件号,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_yjmc) as 印件名称,
  136. rtrim(yj_zzmc) as 纸张名称,rtrim(yj_tlgg) as 投料规格,rtrim(yj_成品数量) as 成品数量,rtrim(yj_实际投料) as 实际投料,
  137. rtrim(yj_Dw) as 投料单位,rtrim(yj_平张投料) as 平张投料,rtrim(yj_ls) as 联数,rtrim(yj_ks) as 开数,rtrim(Sys_id) as 创建用户,
  138. rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID';
  139. $list = \db('工单_印件资料')->where($where)->field($field)->select();
  140. if (empty($list)){
  141. $this->success('');
  142. }
  143. foreach ($list as $key=>$value){
  144. $list[$key]['成品数量'] = rtrim((float)$value['成品数量']);
  145. $list[$key]['实际投料'] = rtrim((float)$value['实际投料']);
  146. }
  147. $this->success('成功',$list);
  148. }
  149. /**
  150. * 排程中/制程中工单
  151. */
  152. public function Schedule(){
  153. if ($this->request->isGet() === false){
  154. $this->error('请求错误');
  155. }
  156. $param = $this->request->param();
  157. if (empty($param)){
  158. $this->error('参数错误');
  159. }
  160. $where = '';
  161. if (!empty($param['search'])){
  162. $where = "
  163. a.Gd_gdbh LIKE '%{$param['search']}%'
  164. OR a.`成品名称` LIKE '%{$param['search']}%'
  165. ";
  166. }
  167. $where['工单分类'] = ['in',[1,3]];
  168. if ($param['status'] === '制程中'){
  169. $list = db('工单_基本资料')->alias('a')
  170. ->field([
  171. 'rtrim(a.Gd_gdbh)' => '工单编号',
  172. 'rtrim(a.Gd_cpdh)' => '产品代号',
  173. 'rtrim(a.Gd_cpmc)' => '产品名称',
  174. 'rtrim(a.接单日期)' => '接单日期',
  175. 'rtrim(a.交货日期)' => '交货日期',
  176. 'rtrim(a.订单数量)' => '订单数量',
  177. 'rtrim(a.计量单位)' => '计量单位',
  178. 'rtrim(a.销售订单号)' => '销售订单号',
  179. 'rtrim(a.Gd_客户代号)' => '客户编号',
  180. 'rtrim(a.Gd_客户名称)' => '客户名称',
  181. 'rtrim(a.客户料号)' => '客户料号',
  182. 'rtrim(a.Uniqid)' => 'GDUID',
  183. ])
  184. ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
  185. ->where([
  186. 'a.gd_statu' => '2-生产中',
  187. 'b.PD_WG' => '1900-01-01 00:00:00',
  188. 'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
  189. ])
  190. ->where($where)
  191. ->group('a.Gd_gdbh')
  192. ->select();
  193. }else{
  194. $list = db('工单_基本资料')->alias('a')
  195. ->field([
  196. 'rtrim(a.Gd_gdbh)' => '工单编号',
  197. 'rtrim(a.Gd_cpdh)' => '产品代号',
  198. 'rtrim(a.Gd_cpmc)' => '产品名称',
  199. 'rtrim(a.接单日期)' => '接单日期',
  200. 'rtrim(a.交货日期)' => '交货日期',
  201. 'rtrim(a.订单数量)' => '订单数量',
  202. 'rtrim(a.计量单位)' => '计量单位',
  203. 'rtrim(a.销售订单号)' => '销售订单号',
  204. 'rtrim(a.Gd_客户代号)' => '客户编号',
  205. 'rtrim(a.Gd_客户名称)' => '客户名称',
  206. 'rtrim(a.客户料号)' => '客户料号',
  207. 'rtrim(a.Uniqid)' => 'GDUID',
  208. ])
  209. ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
  210. ->where([
  211. 'a.gd_statu' => '2-生产中',
  212. 'b.PD_WG' => '1900-01-01 00:00:00',
  213. ])
  214. ->where($where)
  215. // ->whereNotExists(function ($query) {
  216. // $query->table('工单_工艺资料')->alias('b2')
  217. // ->where('b2.Gy0_gdbh = a.Gd_gdbh')
  218. // ->where('b2.Gy0_sj1 <> "1900-01-01 00:00:00"');
  219. // })
  220. ->group('a.Gd_gdbh')
  221. ->select();
  222. }
  223. if (empty($list)){
  224. $this->success('未找到工单信息');
  225. }
  226. $this->success('成功',$list);
  227. }
  228. /**
  229. * 排程中/制程中工单->工序列表
  230. * @ApiMethod (GET)
  231. * @param string $Gd_gdbh 工单编号
  232. * @return \think\response\Json
  233. * @throws \think\db\exception\DataNotFoundException
  234. * @throws \think\db\exception\ModelNotFoundException
  235. * @throws \think\exception\DbException
  236. */
  237. public function ScheduleProcess()
  238. {
  239. if ($this->request->isGet() === false){
  240. $this->error('请求错误');
  241. }
  242. $Gd_gdbh = input('Gd_gdbh');
  243. if (empty($Gd_gdbh)){
  244. $this->error('参数错误');
  245. }
  246. $sql = "SELECT rtrim(a.Gy0_gdbh) as 工单编号,a.Gy0_yjno,a.Gy0_gxh,a.Gy0_gxmc,a.Add_gxmc,rtrim(a.Gy0_sbbh) as 设备编号,rtrim(a.Gy0_小时产能) as 小时产能,
  247. rtrim(a.工价系数) as 产能系数,rtrim(a.Gy0_生产工时) as 生产工时,rtrim(a.Gy0_辅助工时) as 辅助工时,rtrim(a.Gy0_最早开工时间) as 最早开工时间,
  248. rtrim(a.Gy0_sj1) as 计划开工时间,rtrim(a.Gy0_sj2) as 计划完工时间,rtrim(a.Gy0_班次安排) as 班次安排,rtrim(a.工序备注) as 排单备注,
  249. rtrim(a.PD_WG) as 工序完工,rtrim(a.UniqId) as UniqId,COALESCE(b.cl, 0) AS 产量,rtrim(d.计划投料) as 工序产量
  250. FROM `工单_工艺资料` AS a
  251. JOIN `工单_基本资料` As d ON a.Gy0_gdbh = d.Gd_Gdbh
  252. LEFT JOIN (
  253. SELECT sczl_gdbh, sczl_gxh, SUM(sczl_cl) AS cl
  254. FROM `设备_产量计酬`
  255. GROUP BY sczl_gdbh, sczl_gxh
  256. ) AS b ON a.Gy0_gdbh = b.sczl_gdbh AND (a.Gy0_gxh = b.sczl_gxh OR b.sczl_gxh IS NULL)
  257. WHERE a.Gy0_gdbh = '{$Gd_gdbh}' AND a.Gy0_sbbh != ''
  258. GROUP BY a.Gy0_yjno,a.Gy0_gxh";
  259. $list = Db::query($sql);
  260. if (empty($list)){
  261. $this->success('未找到工序');
  262. }
  263. foreach ($list as $key=>$value){
  264. if ((int)$value['Gy0_yjno'] <10){
  265. $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
  266. }
  267. if ((int)$value['Gy0_gxh'] <10){
  268. $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
  269. }
  270. if (rtrim($value['Add_gxmc']) == ''){
  271. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
  272. }else{
  273. $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
  274. }
  275. unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
  276. $list[$key]['机组'] = $value['设备编号'];
  277. $list[$key]['剩余产量'] = (int)$list[$key]['工序产量']-(int)$list[$key]['产量'];
  278. }
  279. $this->success('成功',$list);
  280. }
  281. /**
  282. * 排单页面左侧车间和机台菜单
  283. * @ApiMethod (GET)
  284. * @return \think\response\Json
  285. * @throws \think\db\exception\DataNotFoundException
  286. * @throws \think\db\exception\ModelNotFoundException
  287. * @throws \think\exception\DbException
  288. */
  289. public function workbench()
  290. {
  291. if ($this->request->isGet() === false){
  292. $this->error('请求错误');
  293. }
  294. $param = $this->request->param();
  295. $machineList = db('设备映射表')->column('MNmachine');
  296. $where['设备编号'] = ['in',$machineList];
  297. $data = [];
  298. $department = \db('设备_基本资料')
  299. ->distinct(true)
  300. ->where('使用部门','<>','研发中心')
  301. ->where('设备编组','<>','')
  302. ->where('sys_sbID','<>','')
  303. ->where($where)
  304. ->order('设备编组')
  305. ->column('使用部门');
  306. if (empty($department)){
  307. $this->success('为获取到机台数据');
  308. }
  309. foreach ($department as $value){
  310. $benchClass = \db('设备_基本资料')
  311. ->where('使用部门',$value)
  312. ->where('设备编组','<>','')
  313. ->where('sys_sbID','<>','')
  314. ->distinct(true)
  315. ->order('设备编组')
  316. ->column('设备编组');
  317. foreach ($benchClass as $v){
  318. if (rtrim($v) !== ''){
  319. $machine = \db('设备_基本资料')
  320. ->alias('a')
  321. ->join('设备映射表 b','a.设备编号 = b.MNmachine')
  322. ->where('a.使用部门',$value)
  323. ->where('a.设备编组',$v)
  324. ->where('a.sys_sbID','<>','')
  325. ->field('rtrim(b.YXmachine) as 设备编号,rtrim(a.设备名称) as 设备名称')
  326. ->order('设备编号')
  327. ->select();
  328. foreach ($machine as $kk=>$vv){
  329. $data[rtrim($value)][rtrim($v)][$kk] = $vv['设备编号'].'-->'.$vv['设备名称'];
  330. }
  331. }
  332. }
  333. }
  334. $this->success('成功',$data);
  335. }
  336. /**
  337. * 车间设备制程展示
  338. * @ApiMethod (GET)
  339. * @param void $param
  340. * @return void
  341. * @throws \think\db\exception\DataNotFoundException
  342. * @throws \think\db\exception\ModelNotFoundException
  343. * @throws \think\exception\DbException
  344. */
  345. public function EquipmentScheduling()
  346. {
  347. if ($this->request->isGet() === false){
  348. $this->error('参数错误');
  349. }
  350. $param = $this->request->param();
  351. if (empty($param)){
  352. $this->error('参数错误');
  353. }
  354. $MNmachine = $param['machine'];
  355. $machine = db('设备映射表')
  356. ->where('YXmachine',$MNmachine)
  357. ->value('MNmachine');
  358. $process = \db('dic_lzde')
  359. ->where('适用机型',$machine)
  360. ->column('rtrim(适用工序)');
  361. $list = \db('工单_基本资料')
  362. ->alias('a')
  363. ->field([
  364. 'rtrim(b.Gy0_gdbh)' => '工单编号',
  365. 'rtrim(a.Gd_cpmc)' => '印件名称',
  366. 'rtrim(b.Gy0_计划接货数)' => '计划接货数',
  367. 'rtrim(b.Gy0_小时产能)' => '小时产能',
  368. 'rtrim(b.Gy0_生产工时)' => '生产工时',
  369. 'rtrim(b.Gy0_辅助工时)' => '辅助工时',
  370. 'rtrim(b.Gy0_班次安排)' => '班次安排',
  371. 'rtrim(b.工序备注)' => '排单备注',
  372. 'rtrim(b.Gy0_最早开工时间)' => '最早开工时间',
  373. 'rtrim(b.Gy0_sj1)' => '计划开工时间',
  374. 'rtrim(b.Gy0_sj2)' => '计划完工时间',
  375. 'rtrim(b.Gy0_yjno)' => 'yjno',
  376. 'rtrim(b.Gy0_gxh)' => 'gxh',
  377. 'rtrim(b.Gy0_gxmc)' => 'gxmc',
  378. 'rtrim(b.Gy0_ls)' => 'ls',
  379. 'rtrim(b.UniqId)' => 'UniqId',
  380. 'SUM(c.sczl_cl)' => '已完成'
  381. ])
  382. ->join('工单_工艺资料 b','a.Gd_gdbh = b.Gy0_gdbh AND a.行号 = b.Gy0_yjno')
  383. ->join('设备_产量计酬 c','a.Gd_gdbh = c.sczl_gdbh AND a.行号 = c.sczl_yjno AND b.Gy0_gxh = c.sczl_gxh','LEFT')
  384. ->where([
  385. 'b.Gy0_sbbh' => $machine,
  386. 'b.Gy0_sj1' => ['>','1900-01-01 00:00:00'],
  387. 'b.PD_WG' => '1900-01-01 00:00:00',
  388. 'a.gd_statu' => '2-生产中'
  389. ])
  390. ->where('b.Gy0_sj1','<','2099-01-01 00:00:00')
  391. ->group('a.Gd_gdbh,c.sczl_gxh')
  392. ->select();
  393. foreach ($list as $key=>$value){
  394. $list[$key]['计划接货数'] = (int)round($value['计划接货数']);
  395. if ($value['yjno']<10){
  396. $value['yjno'] = '0'.$value['yjno'];
  397. }
  398. if ($value['gxh']<10){
  399. $value['gxh'] = '0'.$value['gxh'];
  400. }
  401. $list[$key]['印件/工序'] = $value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
  402. unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['ls']);
  403. }
  404. $this->success('成功',$list);
  405. }
  406. /**
  407. * 机台工单展示
  408. * @ApiMethod ()
  409. * @return void
  410. * @throws \think\db\exception\BindParamException
  411. * @throws \think\exception\PDOException
  412. */
  413. public function MachineWorkOrderList()
  414. {
  415. if ($this->request->isGet() === false){
  416. $this->error('请求失败');
  417. }
  418. $param = $this->request->param();
  419. if (empty($param)){
  420. $this->error('参数错误');
  421. }
  422. $where = '';
  423. if (isset($param['search'])){
  424. $where = "
  425. b.Gd_gdbh LIKE '%{$param['search']}%'
  426. OR b.`成品名称` LIKE '%{$param['search']}%'
  427. ";
  428. }
  429. $machine = db('设备映射表')
  430. ->where('YXmachine','like','%'.$param['machine'].'%')
  431. ->value('MNmachine');
  432. $list = \db('工单_工艺资料')
  433. ->alias('a')
  434. ->field([
  435. 'RTRIM( a.Gy0_yjno )' =>'yjno',
  436. 'RTRIM( a.Gy0_gxh )' => 'gxh',
  437. 'RTRIM( a.Gy0_gxmc )' => 'gxmc',
  438. 'RTRIM( a.Add_gxmc )' => 'Add_gxmc',
  439. 'RTRIM( c.yj_yjmc )' => '印件名称',
  440. 'RTRIM( a.`Gy0_计划接货数` )' => '计划接货数',
  441. 'RTRIM( a.`Gy0_小时产能` )' => '小时产能',
  442. 'RTRIM( a.`工价系数` )' => '产能系数',
  443. 'RTRIM( a.`Gy0_生产工时` )' => '生产工时',
  444. 'RTRIM( a.Gy0_ls )' => 'ls',
  445. 'RTRIM( a.`Gy0_辅助工时` )' => '辅助工时',
  446. 'RTRIM( a.`Gy0_最早开工时间` )' => '最早开工时间',
  447. 'RTRIM( a.Gy0_sj1 )' => '计划开工时间',
  448. 'RTRIM( a.Gy0_sj2 )' => '计划完工时间',
  449. 'RTRIM( a.`Gy0_班次安排` )' => '班次安排',
  450. 'RTRIM( a.`工序备注` )' => '排单备注',
  451. 'RTRIM( b.Gd_cpmc )' => '产品名称',
  452. 'RTRIM( b.`成品名称` )' => '成品名称',
  453. 'RTRIM( b.`订单数量` )' => '订单数量',
  454. 'RTRIM( b.`计量单位` )' => '计量单位',
  455. 'RTRIM( b.`交货日期` )' => '交货日期',
  456. 'RTRIM( b.Gd_cpdh )' => '产品代号',
  457. 'RTRIM( b.`成品代号` )' => '成品代号',
  458. // 'RTRIM( e.YXmachine )' => '设备编号',
  459. 'RTRIM( a.Gy0_SITE )' => '车间名称',
  460. 'RTRIM( a.UniqId )' => 'GYUID',
  461. 'RTRIM( b.Uniqid )' => 'UNIQID',
  462. 'SUM( d.sczl_cl )' => '已完成产量',
  463. 'RTRIM( b.Gd_gdbh )' => '工单编号',
  464. 'RTRIM( b.`销售订单号` )' => '销售订单号',
  465. 'RTRIM( a.`版距` )' => '版距',
  466. 'RTRIM( a.`印刷方式` )' => '印刷方式'
  467. ])
  468. ->join('工单_印件资料 c','c.Yj_Gdbh = a.Gy0_gdbh AND c.yj_Yjno = a.Gy0_yjno')
  469. ->join('工单_基本资料 b','b.Gd_gdbh = a.Gy0_gdbh AND b.行号 = a.Gy0_yjno')
  470. ->join('设备_产量计酬 d','a.Gy0_gdbh = d.sczl_gdbh AND a.Gy0_yjno = d.sczl_yjno AND a.Gy0_gxh = d.sczl_gxh AND a.Gy0_sbbh = d.sczl_jtbh','LEFT')
  471. // ->join('设备映射表 e','d.sczl_jtbh = e.MNmachine','LEFT')
  472. ->where([
  473. 'b.gd_statu' => '2-生产中',
  474. 'a.Gy0_sbbh' => ['LIKE','%'.$machine.'%'],
  475. 'a.PD_WG' => '1900-01-01 00:00:00',
  476. ])
  477. ->where($where)
  478. ->group('a.Gy0_gdbh,a.Gy0_yjno,a.Gy0_gxh')
  479. ->order('Gy0_sj1')
  480. // ->fetchSql(true)
  481. ->select();
  482. // halt($list);
  483. if (empty($list)){
  484. $this->success('',[]);
  485. }
  486. $data['制程'] = $data['排程'] = [];
  487. foreach ($list as $key=>$value){
  488. // $machine = explode(' ',$list[$key]['设备编号']);
  489. // if (in_array($param['machine'],$machine)){
  490. $list[$key]['设备编号'] = $param['machine'];
  491. if ((int)$value['yjno'] <10){
  492. $value['yjno'] = '0'.rtrim($value['yjno']);
  493. }
  494. if ((int)$value['gxh'] <10){
  495. $value['gxh'] = '0'.rtrim($value['gxh']);
  496. }
  497. if (rtrim($value['Add_gxmc']) == ''){
  498. $list[$key]['印件工序及名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.rtrim($value['gxmc']);
  499. }else{
  500. $list[$key]['印件工序及名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.rtrim($value['gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
  501. }
  502. unset($list[$key]['Add_gxmc']);
  503. if ($value['产品名称'] == ''){
  504. $list[$key]['产品名称'] = $value['成品名称'];
  505. }
  506. if ($value['产品代号'] == ''){
  507. $list[$key]['产品代号'] = $value['成品代号'];
  508. }
  509. if ($value['已完成产量'] !== 0 && $value['印刷方式'] === '卷对卷'){
  510. $list[$key]['已完成产量'] = round($value['已完成产量']/$value['版距'] * 1000);
  511. }
  512. unset($list[$key]['成品代号'],$list[$key]['成品名称']);
  513. if ($list[$key]['计划开工时间'] !== '1900-01-01 00:00:00'){
  514. array_push($data['制程'],$list[$key]);
  515. }else{
  516. array_push($data['排程'],$list[$key]);
  517. }
  518. // }
  519. }
  520. $this->success('成功',$data);
  521. }
  522. }