ProductionLot.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. /**
  5. * 工单生产批次信息查询
  6. */
  7. class ProductionLot extends Api
  8. {
  9. protected $noNeedLogin = ['*'];
  10. protected $noNeedRight = ['*'];
  11. /**
  12. * 获取查询工单列表
  13. * @return void
  14. * @throws \think\db\exception\DataNotFoundException
  15. * @throws \think\db\exception\ModelNotFoundException
  16. * @throws \think\exception\DbException
  17. */
  18. public function GetOrderList()
  19. {
  20. if ($this->request->isGet() === false){
  21. $this->error('请求错误');
  22. }
  23. $param = $this->request->param();
  24. $where = [
  25. 'gd_statu' => '1-已完工',
  26. ];
  27. if (empty($param['search'])){
  28. $where['Mod_rq'] = ['between',[date('Y-m-d 00:00:00',time()-1209600),date('Y-m-d H:i:s',time())]];
  29. }else{
  30. $where['Gd_gdbh|Gd_客户代号|成品名称'] = ['like','%'.$param['search'].'%'];
  31. }
  32. $list = \db('工单_基本资料')
  33. ->field('Gd_gdbh,Gd_cpmc,行号')
  34. ->where($where)
  35. ->group('行号')
  36. ->select();
  37. if (empty($list)){
  38. $this->success('未找到工单');
  39. }
  40. foreach ($list as $key=>$value){
  41. $list[$key]['工单'] = $value['Gd_gdbh'].'-'.$value['行号'].'-'.$value['Gd_cpmc'];
  42. }
  43. $this->success('成功',$list);
  44. }
  45. /**
  46. * 获取左侧菜单栏
  47. * @return void
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. * @throws \think\exception\DbException
  51. */
  52. public function GetList()
  53. {
  54. if ($this->request->isGet() === false){
  55. $this->error('参数错误');
  56. }
  57. $param = $this->request->param();
  58. if (empty($param) || isset($param['gdbh']) === false || isset($param['yjno']) === false){
  59. $this->error('参数错误');
  60. }
  61. $list = db('设备_产量计酬')
  62. ->field('DISTINCT(sczl_num) as num')
  63. ->where('sczl_gdbh',$param['gdbh'])
  64. ->where('sczl_yjno',$param['yjno'])
  65. ->order('num')
  66. ->select();
  67. if (empty($list)){
  68. $this->success('未找到流程单信息');
  69. }
  70. foreach ($list as $key => $value){
  71. $list[$key]['流程单'] = '第'.$value['num'].'个流程单';
  72. }
  73. // $cpmc = db('工单_基本资料')
  74. // ->where('Gd_gdbh',$param['gdbh'])
  75. // ->where('行号',$param['yjno'])
  76. // ->column('Gd_cpmc')[0];
  77. // $data[$param['gdbh'].'-'.$cpmc]['印件'.$param['yjno']] = $list;
  78. $this->success('成功',$list);
  79. }
  80. /**
  81. * 获取工单信息
  82. * @return void
  83. * @throws \think\db\exception\DataNotFoundException
  84. * @throws \think\db\exception\ModelNotFoundException
  85. * @throws \think\exception\DbException
  86. */
  87. public function GetOrderDetail()
  88. {
  89. if ($this->request->isGet() === false){
  90. $this->error('请求错误');
  91. }
  92. $param = $this->request->param();
  93. if (empty($param) || isset($param['gdbh']) === false || isset($param['yjno']) === false){
  94. $this->error('参数错误');
  95. }
  96. $list = db('工单_基本资料')
  97. ->field('Gd_gdbh,Gd_cpdh,Gd_cpmc,订单数量,实际投料,计量单位,投料率')
  98. ->where('Gd_gdbh',$param['gdbh'])
  99. ->where('行号',$param['yjno'])
  100. ->find();
  101. if (empty($list)){
  102. $this->success('未找到该工单信息');
  103. }else{
  104. $this->success('成功',$list);
  105. }
  106. }
  107. /**
  108. * 工艺及生产班组数据获取
  109. * @return void
  110. * @throws \think\db\exception\DataNotFoundException
  111. * @throws \think\db\exception\ModelNotFoundException
  112. * @throws \think\exception\DbException
  113. */
  114. public function ProcessList()
  115. {
  116. if ($this->request->isGet() === false){
  117. $this->error('请求错误');
  118. }
  119. $param = $this->request->param();
  120. if (!isset($param['gdbh']) || !isset($param['yjno']) || !isset($param['num'])){
  121. $this->error('参数错误');
  122. }
  123. $query= db('设备_产量计酬')
  124. ->alias('a')
  125. ->field('a.sczl_num as 流程单号,a.sczl_gxh as 工序号,a.sczl_gxmc as 工序名称,a.sczl_rq as 生产日期,
  126. a.sczl_jtbh as 机台编号,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.sczl_bh5,a.sczl_bh6,a.sczl_bh7,
  127. a.sczl_bh8,a.sczl_bh9,a.sczl_bh10,d1.员工姓名 as name1,d2.员工姓名 as name2,d3.员工姓名 as name3,d4.员工姓名 as name4,d5.员工姓名 as name5,d6.员工姓名 as name6,d7.员工姓名 as name7,d8.员工姓名 as name8
  128. ,d9.员工姓名 as name9,d10.员工姓名 as name10');
  129. // 循环连接 人事_基本资料 表(仅当 sczl_bh 不为空时才连接)
  130. for ($i = 1; $i <= 10; $i++) {
  131. $field = 'a.sczl_bh' . $i;
  132. $alias = 'd' . $i;
  133. $query->join("人事_基本资料 $alias", "$field = {$alias}.员工编号 AND {$field} IS NOT NULL", 'LEFT');
  134. }
  135. $list = $query->where('a.sczl_gdbh',$param['gdbh'])
  136. ->where('a.sczl_yjno',$param['yjno'])
  137. ->where('a.sczl_num',$param['num'])
  138. ->order('工序号,生产日期')
  139. ->select();
  140. if (empty($list)){
  141. $this->success('未找到该流程单的工艺数据');
  142. }else{
  143. $this->success('成功',$list);
  144. }
  145. }
  146. /**
  147. * 制程异常记录
  148. * @return void
  149. * @throws \think\db\exception\DataNotFoundException
  150. * @throws \think\db\exception\ModelNotFoundException
  151. * @throws \think\exception\DbException
  152. */
  153. public function ProcessAnomaly()
  154. {
  155. if ($this->request->isGet() === false){
  156. $this->error('请求错误');
  157. }
  158. $param = $this->request->param();
  159. if (!isset($param['gdbh']) || !isset($param['yjno'])){
  160. $this->error('参数错误');
  161. }
  162. $list = db('制程检验_记录附加')
  163. ->field('流程单号,缺陷备注')
  164. ->where('工单编号',$param['gdbh'])
  165. ->where('印件号',$param['yjno'])
  166. ->order('流程单号')
  167. ->select();
  168. if (empty($list)){
  169. $this->success('未找到记录');
  170. }
  171. foreach ($list as $key => $value){
  172. $list[$key]['数量'] = '';
  173. $list[$key]['用户'] = '';
  174. }
  175. $this->success('成功',$list);
  176. }
  177. }