Kaynağa Gözat

update getCydList

ggsong 3 yıl önce
ebeveyn
işleme
10707be71f

+ 8 - 0
app/api/business/CydBus.php

@@ -18,4 +18,12 @@ class CydBus
         $count = (new Cyd())->countCydInfoByTaskID($task_id);
         return ['rows'=>$data,'total'=>$count];
     }
+
+    //修改抽样单状态,status=1已上报,0未上报
+    public function updateCydStatus($cyd_id)
+    {
+        $cyd_status = ['status' => '1'];
+        $result = (new Cyd())->updateCydDataByID($cyd_id, $cyd_status);
+        return $result;
+    }
 }

+ 16 - 5
app/api/controller/v1/Cyd.php

@@ -12,14 +12,15 @@ use think\exception\ValidateException;
 
 class Cyd
 {
+    //监管端获取抽样单列表
     public function getCydList()
     {
         $task_id = request()->param('task_id', '', 'int');
-        try {
-            validate(\app\api\validate\Sample::class)->scene('get_cyd_list')->check($task_id);
-        } catch (ValidateException $exception) {
-            return show(config('status.err_validate'),$exception->getError());
-        }
+//        try {
+//            validate(\app\api\validate\Sample::class)->scene('get_cyd_list')->check($task_id);
+//        } catch (ValidateException $exception) {
+//            return show(config('status.err_validate'),$exception->getError());
+//        }
 
         $result = (new CydBus())->getCydList($task_id);
         if ($result['total'] == 0) {
@@ -27,4 +28,14 @@ class Cyd
         }
         return showSuccess($result);
     }
+
+    public function updateCydStatus()
+    {
+        $cyd_id = request()->param('cyd_id', '', 'int');
+        $result = (new CydBus())->updateCydStatus($cyd_id);
+        return showSuccess($result);
+    }
+
+
+
 }

+ 8 - 2
app/api/model/Cyd.php

@@ -28,12 +28,18 @@ class Cyd extends Model
 
     public function selectCydInfoByTaskID($task_id)
     {
-        return $this->where('task_id', '=', $task_id)->select();
+        return $this->where([
+            'task_id' => $task_id,
+            'status'=>1
+        ])->select();
     }
 
     public function countCydInfoByTaskID($task_id)
     {
-        return $this->where('task_id', '=', $task_id)->count();
+        return $this->where([
+            'task_id' => $task_id,
+            'status'=>1
+        ])->count();
     }
 
 

+ 1 - 0
app/api/route/app.php

@@ -20,6 +20,7 @@ Route::group(function () {
 
     //抽样单相关路由
     Route::post(":version.getCydList",":version.Cyd/getCydList");        //获取抽样单列表
+    Route::post(":version.updateCydStatus",":version.Cyd/updateCydStatus");        //修改抽样单上报状态