ProductionLot.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. if (empty($param) || isset($param['search']) === false){
  25. $this->error('参数错误');
  26. }
  27. $list = \db('工单_基本资料')
  28. ->field('Gd_gdbh,Gd_cpmc,行号')
  29. ->where('Gd_gdbh|Gd_客户代号|成品名称','like','%'.$param['search'].'%')
  30. ->where('gd_statu','1-已完工')
  31. ->group('行号')
  32. ->select();
  33. if (empty($list)){
  34. $this->success('未找到工单');
  35. }
  36. foreach ($list as $key=>$value){
  37. $list[$key]['工单'] = $value['Gd_gdbh'].'-'.$value['行号'].'-'.$value['Gd_cpmc'];
  38. }
  39. $this->success('成功',$list);
  40. }
  41. /**
  42. * 获取左侧菜单栏
  43. * @return void
  44. * @throws \think\db\exception\DataNotFoundException
  45. * @throws \think\db\exception\ModelNotFoundException
  46. * @throws \think\exception\DbException
  47. */
  48. public function GetList()
  49. {
  50. if ($this->request->isGet() === false){
  51. $this->error('参数错误');
  52. }
  53. $param = $this->request->param();
  54. if (empty($param) || isset($param['gdbh']) === false || isset($param['yjno']) === false){
  55. $this->error('参数错误');
  56. }
  57. $list = db('设备_产量计酬')
  58. ->field('DISTINCT(sczl_num) as num')
  59. ->where('sczl_gdbh',$param['gdbh'])
  60. ->where('sczl_yjno',$param['yjno'])
  61. ->order('num')
  62. ->select();
  63. if (empty($list)){
  64. $this->success('未找到流程单信息');
  65. }
  66. foreach ($list as $key => $value){
  67. $list[$key]['流程单'] = '第'.$value['num'].'个流程单';
  68. }
  69. $cpmc = db('工单_基本资料')
  70. ->where('Gd_gdbh',$param['gdbh'])
  71. ->where('行号',$param['yjno'])
  72. ->column('Gd_cpmc')[0];
  73. $data[$param['gdbh'].'-'.$cpmc]['印件'.$param['yjno']] = $list;
  74. $this->success('成功',$data);
  75. }
  76. /**
  77. * 获取工单信息
  78. * @return void
  79. * @throws \think\db\exception\DataNotFoundException
  80. * @throws \think\db\exception\ModelNotFoundException
  81. * @throws \think\exception\DbException
  82. */
  83. public function GetOrderDetail()
  84. {
  85. if ($this->request->isGet() === false){
  86. $this->error('请求错误');
  87. }
  88. $param = $this->request->param();
  89. if (empty($param) || isset($param['gdbh']) === false || isset($param['yjno']) === false){
  90. $this->error('参数错误');
  91. }
  92. $list = db('工单_基本资料')
  93. ->field('Gd_gdbh,Gd_cpdh,Gd_cpmc,订单数量,实际投料,计量单位,投料率')
  94. ->where('Gd_gdbh',$param['gdbh'])
  95. ->where('行号',$param['yjno'])
  96. ->find();
  97. if (empty($list)){
  98. $this->success('未找到该工单信息');
  99. }else{
  100. $this->success('成功',$list);
  101. }
  102. }
  103. /**
  104. * 工艺及生产班组数据获取
  105. * @return void
  106. * @throws \think\db\exception\DataNotFoundException
  107. * @throws \think\db\exception\ModelNotFoundException
  108. * @throws \think\exception\DbException
  109. */
  110. public function ProcessList()
  111. {
  112. if ($this->request->isGet() === false){
  113. $this->error('请求错误');
  114. }
  115. $param = $this->request->param();
  116. if (!isset($param['gdbh']) || !isset($param['yjno']) || !isset($param['num'])){
  117. $this->error('参数错误');
  118. }
  119. $query= db('设备_产量计酬')
  120. ->alias('a')
  121. ->field('a.sczl_num as 流程单号,a.sczl_gxh as 工序号,a.sczl_gxmc as 工序名称,a.sczl_rq as 生产日期,
  122. 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,
  123. 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
  124. ,d9.员工姓名 as name9,d10.员工姓名 as name10');
  125. // 循环连接 人事_基本资料 表(仅当 sczl_bh 不为空时才连接)
  126. for ($i = 1; $i <= 10; $i++) {
  127. $field = 'a.sczl_bh' . $i;
  128. $alias = 'd' . $i;
  129. $query->join("人事_基本资料 $alias", "$field = {$alias}.员工编号 AND {$field} IS NOT NULL", 'LEFT');
  130. }
  131. $list = $query->where('a.sczl_gdbh',$param['gdbh'])
  132. ->where('a.sczl_yjno',$param['yjno'])
  133. ->where('a.sczl_num',$param['num'])
  134. ->order('工序号,生产日期')
  135. ->select();
  136. if (empty($list)){
  137. $this->success('未找到该流程单的工艺数据');
  138. }else{
  139. $this->success('成功',$list);
  140. }
  141. }
  142. /**
  143. * 制程异常记录
  144. * @return void
  145. * @throws \think\db\exception\DataNotFoundException
  146. * @throws \think\db\exception\ModelNotFoundException
  147. * @throws \think\exception\DbException
  148. */
  149. public function ProcessAnomaly()
  150. {
  151. if ($this->request->isGet() === false){
  152. $this->error('请求错误');
  153. }
  154. $param = $this->request->param();
  155. if (!isset($param['gdbh']) || !isset($param['yjno'])){
  156. $this->error('参数错误');
  157. }
  158. $list = db('制程检验_记录附加')
  159. ->field('流程单号,缺陷备注')
  160. ->where('工单编号',$param['gdbh'])
  161. ->where('印件号',$param['yjno'])
  162. ->order('流程单号')
  163. ->select();
  164. if (empty($list)){
  165. $this->success('未找到记录');
  166. }
  167. foreach ($list as $key => $value){
  168. $list[$key]['数量'] = '';
  169. $list[$key]['用户'] = '';
  170. }
  171. $this->success('成功',$list);
  172. }
  173. }