qiuenguang преди 1 година
родител
ревизия
269c47d492
променени са 1 файла, в които са добавени 21 реда и са изтрити 24 реда
  1. 21 24
      application/api/controller/Facility.php

+ 21 - 24
application/api/controller/Facility.php

@@ -47,23 +47,19 @@ class Facility extends Api
                 'rtrim(sczl_jtbh)' => '机台编号'
             ])
             ->where('sczl_rq','>',$date)
-            ->cache(true,3600)
+            ->cache(true,86400)
             ->order('sczl_rq desc')
             ->select();
+        if (empty($list)){
+            $this->success('未找到机台生产记录');
+        }
         foreach ($department as $value){
-            $machine = \db('设备_基本资料')
-                ->where('使用部门',$value)
-                ->where('sys_sbID','<>','')
-                ->where('使用部门',$value)
-                ->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')
-                ->select();
+            $machine = \db('设备_基本资料')->where('使用部门',$value)->where('sys_sbID','<>','')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
             foreach ($machine as $k=>$v){
                 $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
-                if (!empty($list)){
-                    foreach ($list as $kk=>$vv){
-                        if ($v['设备编号'] === $vv['机台编号']){
-                            array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
-                        }
+                foreach ($list as $kk=>$vv){
+                    if ($v['设备编号'] === $vv['机台编号']){
+                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
                     }
                 }
             }
@@ -612,8 +608,8 @@ class Facility extends Api
         $lastId = \db('设备_班组资料')
             ->order('UniqId desc')
             ->value('UniqId');
-        if ($lastId<100000){
-            $lastId = 1000000;
+        if (empty($lastId)){
+            $lastId = 0;
         }
         $param['sys_rq'] = date('Y-m-d H:i:s',time());
         $param['UniqId'] = $lastId + 1;
@@ -858,10 +854,10 @@ class Facility extends Api
             $this->error('参数错误');
         }
         $lastNumber =  \db("设备_点检记录")->field('Uniqid as ID')->order('Uniqid desc')->find()['ID'];
-        if ((int)$lastNumber>10000000){
-            $lastId = $lastNumber;
+        if (empty($lastNumber)){
+            $lastId = 0;
         }else{
-            $lastId = 10000000;
+            $lastId = $lastNumber;
         }
         $row = [];
         foreach ($param as $key=>$value){
@@ -1380,8 +1376,8 @@ class Facility extends Api
             $this->error('参数错误');
         }
         $startID = \db('制程检验_记录')->order('UniqId desc')->value('UniqId');
-        if ($startID<100000000){
-            $startID = 100000000;
+        if (empty($startID)){
+            $startID = 0;
         }
         $process = \db('工单_工艺资料')
             ->where('Gy0_gdbh',$param[0]['workOrder'])
@@ -1454,8 +1450,8 @@ class Facility extends Api
             $this->error('参数错误');
         }
         $startID = \db('制程检验_记录附加')->order('UniqId desc')->value('UniqId');
-        if ($startID<100000000){
-            $startID = 100000000;
+        if (empty($startID)){
+            $startID = 0;
         }
         $process = \db('工单_工艺资料')
             ->where('Gy0_gdbh',$param[0]['workOrder'])
@@ -1561,10 +1557,11 @@ class Facility extends Api
         $lastData = \db('设备_产量采集')
             ->order('UniqId desc')
             ->find();
-        if (empty($lastData)){
-            $lastData['UniqId'] = 0;
+        if ($lastData['UniqId'] < 160000000) {
+            $id = 160000000;
+        } else {
+            $id = $lastData['UniqId'] + 1;
         }
-        $id = $lastData['UniqId'] + 1;
         $data['当前状态'] = $params['status'];
         $data['时间'] = date('Y-m-d H:i:s');
         $data['设备编号'] = $machine;