|
|
@@ -15,6 +15,7 @@ import com.platform.utils.FileUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jspecify.annotations.NonNull;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -42,13 +43,13 @@ public class WeighbridgeRecordManage {
|
|
|
* @param request 地磅上报请求参数
|
|
|
* @return 是否保存成功
|
|
|
*/
|
|
|
- public Boolean handleWeighbridgePush(WeighbridgePushRequest request) {
|
|
|
+ public LicensePlateValidateResponse handleWeighbridgePush(WeighbridgePushRequest request) {
|
|
|
log.info("处理地磅数据上报 - 车牌:{}, 地磅编号:{}, 重量:{}, 时间戳:{}",
|
|
|
request.getLicensePlate(),
|
|
|
request.getWeighbridgeCode(),
|
|
|
request.getGrossWeight(),
|
|
|
request.getTimestamp());
|
|
|
-
|
|
|
+ LicensePlateValidateResponse licensePlateValidateResponse = new LicensePlateValidateResponse();
|
|
|
try {
|
|
|
// 构建实体对象
|
|
|
WeighbridgeRecord record = buildWeighbridgeRecord(request);
|
|
|
@@ -57,19 +58,40 @@ public class WeighbridgeRecordManage {
|
|
|
boolean saved = weighbridgeRecordService.save(record);
|
|
|
|
|
|
if (saved) {
|
|
|
+ licensePlateValidateResponse.setStatus(true);
|
|
|
+ licensePlateValidateResponse.setCode(200);
|
|
|
+ licensePlateValidateResponse.setMessage("上报成功,请放行");
|
|
|
+ LicensePlateValidateResponse.Data data = new LicensePlateValidateResponse.Data();
|
|
|
+ data.setTimestamp(request.getTimestamp());
|
|
|
+ data.setScreen_message("车辆请下磅");
|
|
|
+ data.setVoice_message("车辆请下磅");
|
|
|
+ licensePlateValidateResponse.setData(data);
|
|
|
log.info("地磅数据保存成功 - ID: {}, 车牌: {}", record.getId(), record.getLicensePlate());
|
|
|
- return true;
|
|
|
+ return licensePlateValidateResponse;
|
|
|
} else {
|
|
|
log.error("地磅数据保存失败 - 车牌: {}", request.getLicensePlate());
|
|
|
- throw new IotException(ErrorCodeEnum.DATA_SAVE_FAIL, "地磅数据保存失败");
|
|
|
+ return getLicensePlateValidateResponse(request, licensePlateValidateResponse);
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("地磅数据上报处理异常", e);
|
|
|
- throw new IotException(ErrorCodeEnum.SYSTEM_ERROR, "地磅数据上报异常: " + e.getMessage());
|
|
|
+ return getLicensePlateValidateResponse(request, licensePlateValidateResponse);
|
|
|
+ //throw new IotException(ErrorCodeEnum.SYSTEM_ERROR, "地磅数据上报异常: " + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private static LicensePlateValidateResponse getLicensePlateValidateResponse(WeighbridgePushRequest request, LicensePlateValidateResponse licensePlateValidateResponse) {
|
|
|
+
|
|
|
+ licensePlateValidateResponse.setStatus(false);
|
|
|
+ licensePlateValidateResponse.setCode(400);
|
|
|
+ licensePlateValidateResponse.setMessage("上报异常,请稍后");
|
|
|
+ LicensePlateValidateResponse.Data data = new LicensePlateValidateResponse.Data();
|
|
|
+ data.setTimestamp(request.getTimestamp());
|
|
|
+ data.setVoice_message("数据上报异常,请联系管理员");
|
|
|
+ licensePlateValidateResponse.setData(data);
|
|
|
+ return licensePlateValidateResponse;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 构建地磅记录实体对象
|
|
|
* @param request 请求参数
|