|
|
@@ -761,4 +761,74 @@ public class WeighbridgeRecordManage {
|
|
|
|
|
|
return licensePlateValidateResponse;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理地磅过磅数据上报
|
|
|
+ * @param request 地磅上报请求参数
|
|
|
+ * @return 是否保存成功
|
|
|
+ */
|
|
|
+ public LicensePlateValidateResponse handleWeighbridgePushJd(WeighbridgePushRequest request) {
|
|
|
+ log.info("[地磅过磅数据上报V2]开始地磅过磅数据上报,车牌:{}, 地磅编号:{}, 重量:{}, 时间戳:{}, 图片数量:{}",
|
|
|
+ request.getLicensePlate(), request.getWeighbridgeCode(), request.getGrossWeight(),
|
|
|
+ request.getTimestamp(), request.getImages() != null ? request.getImages().length : 0);
|
|
|
+ LicensePlateValidateResponse licensePlateValidateResponse = new LicensePlateValidateResponse();
|
|
|
+ if (StringUtils.isAnyBlank(request.getLicensePlate(), request.getWeighbridgeCode()) || Objects.isNull(request.getGrossWeight()) || Objects.isNull(request.getTimestamp())) {
|
|
|
+ return getLicensePlateValidateResponse(request, licensePlateValidateResponse);
|
|
|
+ }
|
|
|
+ //查询车牌是否在验证列表中
|
|
|
+ ValidateLicensePlate validateLicensePlate = validateLicensePlateService.queryByLicensePlate(request.getLicensePlate());
|
|
|
+ try {
|
|
|
+ // 构建实体对象
|
|
|
+ WeighbridgeRecord record = buildWeighbridgeRecord(request);
|
|
|
+ if(Objects.isNull(validateLicensePlate)){
|
|
|
+ record.setCheckStatus(1);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<KwsWeighbridge> wrapper = Wrappers.<KwsWeighbridge>lambdaQuery()
|
|
|
+ .eq(KwsWeighbridge::getUniqueCode, request.getWeighbridgeCode())
|
|
|
+ .eq(KwsWeighbridge::getDelFlag, 0)
|
|
|
+ .last("limit 1");
|
|
|
+ KwsWeighbridge kwsWeighbridge = kwsWeighbridgeRepository.getOne(wrapper);
|
|
|
+ Long entId = Optional.ofNullable(kwsWeighbridge)
|
|
|
+ .map(KwsWeighbridge::getEntId)
|
|
|
+ .orElse(null);
|
|
|
+ // 保存到数据库
|
|
|
+ boolean saved = weighbridgeRecordService.save(record);
|
|
|
+ if (saved) {
|
|
|
+ // 异步处理图片上传
|
|
|
+ updateImageUrls(request, record);
|
|
|
+ licensePlateValidateResponse.setStatus(true);
|
|
|
+ licensePlateValidateResponse.setCode(200);
|
|
|
+ licensePlateValidateResponse.setMessage("数据上报成功");
|
|
|
+ LicensePlateValidateResponse.Data data = new LicensePlateValidateResponse.Data();
|
|
|
+ String timestampStr = request.getTimestamp().toString();
|
|
|
+ if (timestampStr.length() == 10) {
|
|
|
+ // 秒级时间戳
|
|
|
+ data.setTimestamp(request.getTimestamp());
|
|
|
+ } else if (timestampStr.length() == 13) {
|
|
|
+ // 毫秒级时间戳
|
|
|
+ long l = request.getTimestamp() / 1000;
|
|
|
+ data.setTimestamp(l);
|
|
|
+ }
|
|
|
+ data.setScreen_message("数据上报成功");
|
|
|
+ data.setVoice_message("数据上报成功");
|
|
|
+ licensePlateValidateResponse.setData(data);
|
|
|
+ log.info("地磅数据保存成功 - ID: {}, 车牌: {}", record.getId(), record.getLicensePlate());
|
|
|
+ record.setEntId(entId);
|
|
|
+ externalWeighbridgePushService.pushWeighbridgeRecord(record);
|
|
|
+ WeighbridgeRecord weighbridgeRecord = new WeighbridgeRecord();
|
|
|
+ weighbridgeRecord.setId(record.getId());
|
|
|
+ weighbridgeRecord.setSuccessFlag(1);
|
|
|
+ weighbridgeRecordService.updateById(weighbridgeRecord);
|
|
|
+ return licensePlateValidateResponse;
|
|
|
+ } else {
|
|
|
+ log.error("地磅数据保存失败 - 车牌: {}", request.getLicensePlate());
|
|
|
+ return getLicensePlateValidateResponse(request, licensePlateValidateResponse);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("地磅数据上报处理异常", e);
|
|
|
+ return getLicensePlateValidateResponse(request, licensePlateValidateResponse);
|
|
|
+ //throw new IotException(ErrorCodeEnum.SYSTEM_ERROR, "地磅数据上报异常: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|