Просмотр исходного кода

Merge branch 'master' of https://git.7in6.com/Minong/mes-server-api

曹鹤洋 1 год назад
Родитель
Сommit
6f6c798ebc
1 измененных файлов с 82 добавлено и 58 удалено
  1. 82 58
      application/api/controller/Facility.php

+ 82 - 58
application/api/controller/Facility.php

@@ -84,8 +84,8 @@ class Facility extends Api
                 $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
                 foreach ($list as $kk=>$vv){
                     if ($v['设备编号'] === $vv['机台编号']){
-//                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
-                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],$vv['时间']);
+                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
+//                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],$vv['时间']);
                     }
                 }
             }
@@ -238,48 +238,40 @@ class Facility extends Api
      */
     public function Production()
     {
-        if ($this->request->isGet() === false){
-            $this->error('请求错误');
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
         }
-        $machine = input('machine');
-        if (empty($machine)){
+        $params = Request::instance()->param();
+        if (!isset($params['machine']) || empty($params['machine'])) {
             $this->error('参数错误');
         }
-        $sql = "SELECT
-                rtrim(b.Gy0_gdbh) AS 工单编号,
-                rtrim(b.Gy0_yjno) AS 印件号,
-                rtrim(b.Gy0_gxh) AS gxh,
-                rtrim(b.Gy0_gxmc) AS gxmc,
-                rtrim(b.Add_gxmc) AS add_gxmc,
-                RTRIM(a.Gd_cpmc) AS 产品名称
-            FROM
-                `工单_基本资料` AS a
-            JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
-            JOIN `产品_基本资料` AS c ON a.`成品代号` = c.`产品编号`
-            JOIN `工单_印件资料` AS d ON a.Gd_gdbh = d.Yj_Gdbh
-            LEFT JOIN `设备_产量计酬` AS e ON e.sczl_gdbh = a.Gd_gdbh
-            AND e.sczl_jtbh = b.Gy0_sbbh
-            WHERE
-                a.gd_statu = '2-生产中'
-                AND a.`行号` = '1'
-                AND b.Gy0_sbbh = '{$machine}'
-                AND c.`状态` = ''
-                AND b.PD_WG = '1900-01-01 00:00:00'
-                AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
-            GROUP BY
-                a.Gd_gdbh
-            LIMIT 1";
-        $list = Db::query($sql);
-        if (empty($list)){
-            $this->success('未找到排产工单',[]);
-        }
-        foreach ($list as $key=>$value){
-            if ($value['gxh']<10){
-                $list[$key]['gxh'] = '0'.$value['gxh'];
+        $machine = $params['machine'];
+        $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+        $list = [];
+        $list['工单编号'] = $data['工单编号'];
+        $list['印件号'] = $data['印件号'];
+        $list['班组编号'] = $data['班组编号'];
+        $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
+        $list['产品名称'] = rtrim($name);
+        $where['Gy0_gdbh'] = $data['工单编号'];
+        $where['Gy0_yjno'] = $data['印件号'];
+        $where['Gy0_gxh'] = $data['工序号'];
+        $gxmc = \db('工单_工艺资料')->where($where)->value('Gy0_gxmc');
+        $list['工序名称'] = rtrim($gxmc);
+        $class = \db('设备_班组资料')->where('UniqId',$data['班组ID'])->field("rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
+        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,
+        rtrim(sczl_bh10) as bh10")->find();
+        $row = [];
+        for ($i=1;$i<11;$i++) {
+            if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
+                $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
+                $row[$i] = [
+                    '编号' => $class['bh' . $i],
+                    '姓名' => $name['姓名']
+                ];
             }
-            $list[$key]['工序名称'] = $list[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
-            unset($list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['add_gxmc']);
         }
+        $list['班组成员'] = $row;
         $this->success('成功',$list);
     }
 
@@ -394,7 +386,6 @@ class Facility extends Api
             $processList['process'] = $res['sczl_yjno'].'-'.$res['sczl_gxmc'];
             $processList['completed'] = \db('设备_产量计酬')
                 ->where('sczl_gdbh',$workOrder)
-//                ->where('UniqId','>',$startUniqid)
                 ->where('sczl_gxh',$v)
                 ->count();
             array_push($data,$processList);
@@ -535,14 +526,11 @@ class Facility extends Api
         if (empty($machine) || empty($workOrder) || empty($team)){
             $this->error('参数错误');
         }
-//        $last_id = \db('制程检验_记录')->order('UniqId desc')->field('UniqId')->find();
-//        $startId = $last_id['UniqId']-100000;
         $where = [
             '设备编号' => $machine,
             '工单编号' => $workOrder,
             '班组编号' => $team,
             '类别' => ['in',['IPQC检验','机台检验']],
-//            'UniqId' => ['>',$startId],
         ];
         //检验项目筛选
         $item = \db('制程检验_记录')->where($where)->distinct(true)->column('rtrim(检验项目)');
@@ -953,8 +941,12 @@ class Facility extends Api
         $this->success('成功',$list);
     }
 
-    //换型清场记录->左侧菜单栏
-
+    /**
+     * 换型清场->左侧菜单栏
+     * @ApiMethod  (GET)
+     * @param  void
+     * @return void
+     */
     public function remodelGetTab()
     {
         if ($this->request->isGet() === false){
@@ -968,28 +960,36 @@ class Facility extends Api
         }
         $sql = "SELECT RTRIM(a.`设备编号`) as `设备编号`,RTRIM(b.`日期`) as `日期`,RTRIM(b.UniqId) as UniqId FROM `设备_基本资料` as a 
                 LEFT JOIN `制程_换型清场` as b ON b.`机台编号` = a.`设备编号`
-                WHERE b.`日期` > '{$date}' AND b.日期 < '{$nowTime}' ORDER BY b.`日期`";
+                WHERE b.`日期` > '{$date}' AND b.日期 < '{$nowTime}' ORDER BY b.`UniqId`";
         $res = Db::query($sql);
-        $data = [];
+        $data = $result = [];
         foreach ($list as $key=>$value){
-            $i=0;
-            $data[$value] = [];
+            $data[$value] = $result[$value]= $time = [];
             foreach ($res as $k=>$v){
-                $row = [];
                 if ($value === $v['设备编号']){
-                    $row[$i] = [
+                    $row = [
                         '日期' => $v['日期'],
                         'id' => $v['UniqId']
                     ];
-                    $i++;
-                    foreach ($row as $vv){
+                    array_push($data[$value],$row);
 
+                }
+            }
+            foreach ($data[$value] as $m=>$n){
+                $time[$m] = $n['日期'];
+            }
+            $time = array_values(array_unique($time));
+            foreach ($time as $kk=>$vv){
+                $i=1;
+                foreach ($data[$value] as $kkk=>$vvv){
+                    if ($kkk>=$kk  && $vv === $vvv['日期']){
+                        array_push($result[$value],date('Y-m-d',strtotime($vv)).'第'.$i.'次换型/'.$vvv['id']);
+                        $i++;
                     }
-                    array_push($data[$value],$row);
                 }
             }
         }
-        $this->success('成功',$data);
+        $this->success('成功',$result);
     }
 
     /**
@@ -1022,7 +1022,15 @@ class Facility extends Api
         $this->success('成功',$list);
     }
 
-    //换型清场->当前清场记录
+    /**
+     * 换型清场->当前设备清场记录
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
     public function ModelChangeRecord()
     {
         if ($this->request->isGet() === false){
@@ -1035,9 +1043,25 @@ class Facility extends Api
         $date = date('Y-m-d 00:00:00',time()-3888000);
         $nowTime = date('Y-m-d H:i:s',time());
         $where = [
-            '日期' =>['between',[$nowTime,$date]],
-
+            '日期' =>['between',[$date,$nowTime]],
+            '机台编号' => $param['machine']
         ];
+        $field = "rtrim(日期) as 日期,rtrim(机台编号) as 机台编号,rtrim(班组) as 班组,rtrim(工单编号A) as 工单编号A,rtrim(印件工序A) as 印件工序A,
+        rtrim(码包号A) as 码包号A,rtrim(工单编号B) as 工单编号B,rtrim(印件工序B) as 印件工序B,rtrim(码包号B) as 码包号B,rtrim(清场项目A) as 清场项目A,
+        rtrim(清场项目B) as 清场项目B,rtrim(清场项目C) as 清场项目C,rtrim(清场项目D) as 清场项目D,rtrim(清场项目E) as 清场项目E,rtrim(机长) as 机长,
+        rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员,rtrim(sys_rq) as 创建时间,rtrim(UniqId) as UNIQID";
+        $list = \db('制程_换型清场')
+            ->where($where)
+            ->field($field)
+            ->select();
+        if (empty($list)){
+            $this->success('未找到换型记录');
+        }
+        foreach ($list as $key=>$value){
+            $list[$key]['印件名称A'] = \db('工单_印件资料')->where('Yj_Gdbh',$value['工单编号A'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
+            $list[$key]['印件名称B'] = \db('工单_印件资料')->where('Yj_Gdbh',$value['工单编号B'])->field('rtrim(yj_yjmc) as yjmc')->find()['yjmc'];
+        }
+        $this->success('成功',$list);
     }
 
     /**