qiuenguang 1 éve
szülő
commit
5daa8faa35
1 módosított fájl, 13 hozzáadás és 5 törlés
  1. 13 5
      application/api/controller/Decision.php

+ 13 - 5
application/api/controller/Decision.php

@@ -60,12 +60,16 @@ class Decision extends Api
             $this->error('请求错误');
         }
         $param = $this->request->param();
-        if (empty($param['mouth']) || empty($param['sist'])){
+        if (empty($param['mouth'])){
             $this->error('参数错误');
         }
+        $where = [];
+        if(!empty($param['sist'])){
+            $where['设备编组'] = $param['sist'];
+        }
         $mouth = date('Y-m',strtotime($param['mouth']));
         $machine = \db('设备_基本资料')
-            ->where('设备编组',$param['sist'])
+            ->where($where)
             ->field('设备编号')
             ->select();
         $day = \db('设备_产量计酬')
@@ -165,9 +169,13 @@ class Decision extends Api
             $this->error('请求错误');
         }
         $param = $this->request->param();
-        if (empty($param['mouth']) || empty($param['sist'])){
+        if (empty($param['mouth'])){
             $this->error('参数错误');
         }
+        $where = [];
+        if(!empty($param['sist'])){
+            $where['设备编组'] = $param['sist'];
+        }
         $mouth = date('Y-m',strtotime($param['mouth']));
         $list = \db('设备_基本资料')
             ->alias('a')
@@ -184,7 +192,7 @@ class Decision extends Api
                 'SUM(b.sczl_装版工时)' => '装板补产工时',
                 'SUM(b.sczl_异常停机工时)' => '异常停机工时'
             ])
-            ->where('a.设备编组',$param['sist'])
+            ->where($where)
             ->whereTime('b.sczl_rq',$mouth)
             ->group('a.设备编号')
             ->order('a.设备编号')
@@ -201,7 +209,7 @@ class Decision extends Api
                 'SUM(b.sczl_装版工时)' => '装板补产工时',
                 'SUM(b.sczl_异常停机工时)' => '异常停机工时'
             ])
-            ->where('a.设备编组',$param['sist'])
+            ->where($where)
             ->whereTime('b.sczl_rq',$mouth)
             ->find();
         $list['total'] = $total;