修改上报数据

This commit is contained in:
2023-08-16 10:54:26 +08:00
parent a6732021ca
commit fd9c774c13
4 changed files with 70 additions and 27 deletions
+25 -9
View File
@@ -7,6 +7,7 @@ use App\Constants\HttpEnumCode;
use App\Exception\BusinessException;
use App\Model\Area;
use App\Model\BasicCompany;
use App\Model\BasicDetectionOrgan;
use App\Model\BasicNation;
use App\Model\DetectionProject;
use App\Model\DetectionProjectPurpose;
@@ -537,6 +538,10 @@ class DetectionService extends BaseService
$detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic);
}
if (!isset($detection_pic)){
return fail(HttpEnumCode::HTTP_ERROR,"上传图片失败");
}
// 检测检测管编码是否已被使用
$params = array();
$params['detection_bar_code'] = $request_params['detection_bar_code'];
@@ -545,21 +550,28 @@ class DetectionService extends BaseService
return fail(HttpEnumCode::HTTP_ERROR,"检测管已被使用");
}
// 计算检测机构
$detection_organ_id = 1;
// 获取检测码对应的检测所
$detection_organ_code = substr($request_params['detection_bar_code'], 3, 1);
if (!$detection_organ_code){
return fail(HttpEnumCode::HTTP_ERROR,"检测码错误");
}
// 获取检测所数据
$params = array();
$params['detection_organ_code'] = $detection_organ_code;
$basic_detection_organ = BasicDetectionOrgan::getOne($params);
if (empty($basic_detection_organ)){
return fail(HttpEnumCode::HTTP_ERROR,"检测码错误");
}
Db::beginTransaction();
try {
// 上报数据
$wy = new Wy($detection_organ_id);
$wy->report($order_detection);
// 修改检测订单
$data = array();
$data['detection_pic'] = $detection_pic ?? "";
$data['detection_pic'] = $detection_pic;
$data['detection_bar_code'] = $request_params['detection_bar_code'];
$data['detection_status'] = 3;
$data['detection_organ_id'] = $detection_organ_id;// 检测机构id
$data['detection_organ_id'] = $basic_detection_organ['detection_organ_id'];// 检测机构id
$data['detection_time'] = date('Y-m-d H:i:s', time());// 上传检测时间
$params = array();
@@ -570,11 +582,15 @@ class DetectionService extends BaseService
return fail(HttpEnumCode::HTTP_ERROR,"绑定失败");
}
// 上报数据
$wy = new Wy($basic_detection_organ['detection_organ_id']);
$wy->report($order_detection_id);
Db::commit();
}catch (\Throwable $e){
Db::rollBack();
Log::getInstance("DetectionService-bindDetectionTube")->error($e->getMessage());
return fail(HttpEnumCode::HTTP_ERROR, "绑定失败");
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
}
return success();