|
@@ -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];
|
|
|
}
|
|
|
|
|
|
|