qiuenguang 1 рік тому
батько
коміт
569cf0c9e9
1 змінених файлів з 29 додано та 16 видалено
  1. 29 16
      application/api/controller/Facility.php

+ 29 - 16
application/api/controller/Facility.php

@@ -221,25 +221,38 @@ class Facility extends Api
         }
         $machine = $params['machine'];
         $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+        $endTime = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$data['工单编号'])
+            ->where('Gy0_sbbh','like','%'.$machine.'%')
+            ->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)->find();
-        if ((int)$gxmc['Gy0_gxh']<10){
-            $gxmc['Gy0_gxh'] = '0'.rtrim($gxmc['Gy0_gxh']);
-        }
-        if ($gxmc['Add_gxmc'] !== ''){
-            $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']).'【'.rtrim($gxmc['Add_gxmc']).'】';
+        if ($endTime['PD_WG'] === '1900-01-01 00:00:00'){
+            $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)->find();
+            if ((int)$gxmc['Gy0_gxh']<10){
+                $gxmc['Gy0_gxh'] = '0'.rtrim($gxmc['Gy0_gxh']);
+            }
+            if ($gxmc['Add_gxmc'] !== ''){
+                $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']).'【'.rtrim($gxmc['Add_gxmc']).'】';
+            }else{
+                $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']);
+            }
+            $list['工序名称'] = $printName;
         }else{
-            $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']);
+            $list['工单编号'] = '';
+            $list['印件号'] = 0;
+            $list['班组编号'] = '';
+            $list['产品名称'] = '';
+            $list['工序名称'] = '';
         }
-        $list['工序名称'] = $printName;
         $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();