Kaynağa Gözat

工单查询接口优化

qiuenguang 1 yıl önce
ebeveyn
işleme
9ece8c440d

+ 1 - 1
application/api/controller/Manufacture.php

@@ -358,7 +358,7 @@ class Manufacture extends Api
         if (empty($workOrder) || empty($status)){
             $this->error('参数错误');
         }
-        $sql = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->fetchSql(true)->update(['gd_statu'=>$status]);
+        $sql = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->fetchSql(true)->update(['gd_statu'=>$status,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('成功');

+ 8 - 4
application/api/controller/ProductionLot.php

@@ -29,13 +29,17 @@ class ProductionLot extends Api
             $this->error('请求错误');
         }
         $param = $this->request->param();
-        if (empty($param) || isset($param['search']) === false){
-            $this->error('参数错误');
+        $where = [
+          'gd_statu' => '1-已完工',
+        ];
+        if (isset($param['search'])){
+            $where['Gd_gdbh|Gd_客户代号|成品名称'] = ['like','%'.$param['search'].'%'];
+        }else{
+            $where['Mod_rq'] = ['between',[date('Y-m-d 00:00:00',time()-1209600),date('Y-m-d H:i:s',time())]];
         }
         $list = \db('工单_基本资料')
             ->field('Gd_gdbh,Gd_cpmc,行号')
-            ->where('Gd_gdbh|Gd_客户代号|成品名称','like','%'.$param['search'].'%')
-            ->where('gd_statu','1-已完工')
+            ->where($where)
             ->group('行号')
             ->select();
         if (empty($list)){