Course.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use think\Request;
  6. use function fast\e;
  7. /**
  8. * 生产进程管理
  9. */
  10. class Course extends Api
  11. {
  12. protected $noNeedLogin = ['*'];
  13. protected $noNeedRight = ['*'];
  14. /**
  15. * 左侧菜单
  16. * @return void
  17. * @throws \think\Exception
  18. * @throws \think\db\exception\BindParamException
  19. * @throws \think\exception\PDOException
  20. */
  21. public function getTab()
  22. {
  23. if ($this->request->isGet() === false){
  24. $this->error('请求错误');
  25. }
  26. //获取总计划中数量和总生产中数量
  27. $productingAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','2-生产中')->cache(true)->count();
  28. $progressAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','3-计划中')->cache(true)->count();
  29. $data = [
  30. '印刷工单' => [],
  31. '糊盒工单' => []
  32. ];
  33. $sql = "SELECT DISTINCT
  34. (客户编号),rtrim(客户名称 ) as 客户名称
  35. FROM
  36. `产品_基本资料`
  37. WHERE
  38. 客户编号 <> ''
  39. GROUP BY
  40. 客户编号
  41. order by
  42. 客户编号";
  43. $list = \db()->query($sql);
  44. if (empty($list)){
  45. $this->success('',[]);
  46. }
  47. foreach ($list as $key=>$value){
  48. $value['客户编号'] = rtrim($value['客户编号']);
  49. $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
  50. $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
  51. $string = '';
  52. if ($productIng != 0){
  53. $string = $string."生产中:".$productIng;
  54. }
  55. if ($proGress != 0){
  56. $string = $string."计划中:".$proGress;
  57. }
  58. if ($string !== ''){
  59. $name = $value['客户编号'].$value['客户名称'];
  60. if (strpos($value['客户编号'],'J') !== false){
  61. array_push($data['糊盒工单'],$name);
  62. }else{
  63. array_push($data['印刷工单'],$name);
  64. }
  65. }
  66. }
  67. $this->success('成功',$data);
  68. }
  69. /**
  70. * 右侧工单详情
  71. * @return void
  72. * @throws \think\db\exception\DataNotFoundException
  73. * @throws \think\db\exception\ModelNotFoundException
  74. * @throws \think\exception\DbException
  75. */
  76. public function workOrderDetail()
  77. {
  78. if ($this->request->isGet() === false){
  79. $this->error('请求错误');
  80. }
  81. $param = $this->request->param();
  82. $where = [];
  83. if (!empty($param['order'])){
  84. $where['a.Gd_cpdh|a.成品代号'] = ['like',$param['order'].'%'];
  85. }
  86. if (!empty($param['search'])){
  87. $where['a.Gd_gdbh'] = ['like','%'.$param['search'].'%'];
  88. }
  89. $list = \db('工单_基本资料')
  90. ->alias('a')
  91. ->join('工单_印件资料 b','a.Gd_gdbh = b.Yj_Gdbh')
  92. ->field('b.Yj_Gdbh as 工单编号,b.yj_Yjno,b.yj_Yjdh as 印件代号,b.yj_yjmc as 印件名称,b.yj_ls as 联数,a.投料大箱 as 投料大箱,b.yj_平张投料 as 计划投料')
  93. ->where($where)
  94. ->where('gd_statu','2-生产中')
  95. ->group('b.Yj_Gdbh,b.yj_Yjno')
  96. ->select();
  97. if (empty($list)){
  98. $this->success('');
  99. }
  100. foreach ($list as $key=>$value){
  101. $process = \db('工单_工艺资料')
  102. ->alias('a')
  103. ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_yjno = b.sczl_yjno AND a.Gy0_gxh = b.sczl_gxh','left')
  104. ->where('a.Gy0_gdbh',$value['工单编号'])
  105. ->where('a.Gy0_yjno',$value['yj_Yjno'])
  106. ->field('a.Gy0_gxh,a.Gy0_gxmc,a.PD_WG,SUM(b.sczl_cl) as 产量')
  107. ->group('a.Gy0_gxh')
  108. ->select();
  109. foreach ($process as $k=>$v){
  110. $status = '';
  111. if ($v['PD_WG'] !== '1900-01-01 00:00:00'){
  112. $status = '完工';
  113. }
  114. $k++;
  115. $list[$key]['工序'.$k] = $value['yj_Yjno'].'-'.$v['Gy0_gxh'].'-'.rtrim($v['Gy0_gxmc']).'['.$v['产量'].'/'.']'.$status;
  116. }
  117. unset($list[$key]['yj_Yjno']);
  118. }
  119. $this->success('成功',$list);
  120. }
  121. }