浏览代码

Merge remote-tracking branch 'origin/dev_20260131' into dev_20260131

donglang 4 月之前
父节点
当前提交
263b6f0983

+ 2 - 4
iot-platform-manager/src/main/java/com/platform/api/controller/WeighbridgeController.java

@@ -10,7 +10,6 @@ import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -34,7 +33,7 @@ public class WeighbridgeController {
      */
     @Operation(summary = "地磅过磅数据上报", description = "接收地磅设备上报的过磅数据和图片")
     @PostMapping("/weighBridgePush")
-    public BaseResult<Boolean> weighBridgePush(
+    public LicensePlateValidateResponse weighBridgePush(
             @Parameter(description = "车牌号", required = true) @RequestParam("licensePlate") String licensePlate,
             @Parameter(description = "地磅编号", required = true) @RequestParam("weighbridgeCode") String weighbridgeCode,
             @Parameter(description = "称重重量(吨)", required = true) @RequestParam("grossWeight") BigDecimal grossWeight,
@@ -52,8 +51,7 @@ public class WeighbridgeController {
         request.setImages(images);
 
         // 调用业务层处理
-        Boolean result = weighbridgeRecordManage.handleWeighbridgePush(request);
-        return BaseResult.success(result);
+        return weighbridgeRecordManage.handleWeighbridgePush(request);
     }
 
     /**

+ 27 - 5
iot-platform-manager/src/main/java/com/platform/manage/WeighbridgeRecordManage.java

@@ -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 请求参数