Explorar el Código

检测单结果判定,保存到cyd

gbsong hace 3 años
padre
commit
f597809f35

+ 21 - 3
app/api/business/JcdBus.php

@@ -101,6 +101,24 @@ class JcdBus
             }
         }
 
+        //将检测单的判定结果(整体合格还是不合格)存到cyd的test_result
+        $test_result=(new SamplePesticides())->getItemBySampleId($sample_id)->toArray();
+        $test_result_true=$test_result_false=$test_result_null=0;//三个统计项目,分别是检测合格、不合格、为空
+        foreach ($test_result as $key => $value) {
+            if ($test_result[$key]['test_result'] == '合格') $test_result_true+=1;
+            if ($test_result[$key]['test_result'] == '不合格') $test_result_false+=1;
+            if ($test_result[$key]['test_result'] == '') $test_result_null+=1;
+        }
+        //所有项目都有检测值,且没有不合格,则总的检测结果为合格
+        if ($test_result_null == 0 && $test_result_false==0) {
+            (new Cyd())->updateCydDataBySampleID($sample_id,['test_result'=>1]);
+        }
+        //所有项目都有检测值,且有不合格,则总的检测结果为不合格
+        if ($test_result_null == 0 && $test_result_false!=0) {
+            (new Cyd())->updateCydDataBySampleID($sample_id,['test_result'=>0]);
+        }
+
+
         return ['enable_upload_data'=>$enable_save_data,'disable_upload_data'=>$disable_save_data];
 
     }
@@ -108,9 +126,9 @@ class JcdBus
     //生成检测报告单
     public function createTestValue($sample_id)
     {
-        $res['result_detail']=Db::name('sample_pesticides')->where('sample_id',$data['sample_id'])->select();
-        $res['result']=Db::name('cyd')->where('sample_id',$data['sample_id'])->find();
-        return $this->jsonSuccessData($res);
+        $result_detail = (new SamplePesticides())->getItemBySampleId($sample_id);
+        $result = (new Cyd())->getCydDetailBySampleID($sample_id);
+        return ['result_detail'=>$result_detail,'result'=>$result];
     }
 
 

+ 1 - 1
app/api/controller/v1/Cyd.php

@@ -44,7 +44,7 @@ class Cyd
         $result = (new CydBus())->upCydItem($sample_id);
         //返回一个undertake_id,前端要用这个刷新页面
         $undertake_id = (new CydBus())->getCydItemBySampleId($sample_id);
-        return showSuccess($undertake_id[0]['undertake_id']);
+        return showSuccess($undertake_id['undertake_id']);
     }
 
 

+ 3 - 3
app/api/controller/v1/Jcd.php

@@ -38,7 +38,7 @@ class Jcd
         $result = (new JcdBus())->upJcdItem($sample_id);
         //返回一个undertake_id,前端要用这个刷新页面
         $undertake_id = (new CydBus())->getCydItemBySampleId($sample_id);
-        return showSuccess($undertake_id[0]['undertake_id']);
+        return showSuccess($undertake_id['undertake_id']);
     }
 
     //保存检测单
@@ -52,12 +52,12 @@ class Jcd
         return showSuccess($result);
     }
 
-    //生成检测报告单
+    //生成检测报告单(这是报告单下面的数据)
     public function createTestValue(){
 
         $sample_id = request()->param('sample_id', '', 'trim');
         $result = (new JcdBus())->createTestValue($sample_id);
-        return $result;
+        return showSuccess($result);
 
     }
 }

+ 1 - 1
app/api/model/Cyd.php

@@ -52,7 +52,7 @@ class Cyd extends Model
     {
         $data = $this->with(['unitProduction', 'unitTest','unitSample'])
             ->where('sample_id','=',$sample_id)
-            ->select();
+            ->find();
         return $data;
     }
 

+ 2 - 0
app/api/model/SamplePesticides.php

@@ -37,6 +37,8 @@ class SamplePesticides extends Model
             ->save($data);
     }
 
+
+
     public function updateItemByTestIdAndSampleId($test_id, $sample_id, $data)
     {
         $result= $this->where([

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

@@ -7,7 +7,7 @@ use think\facade\Route;
 //登录 & 等出 路由表
 Route::group(function () {
     Route::post(":version.login",":version.Login/login");        //登出
-    Route::post(":version.logout1",":version.Login/logout");        //登出 todo 还没写
+    //Route::post(":version.logout1",":version.Login/logout");        //登出 todo 还没写
 
 })->allowCrossDomain();