Jelajahi Sumber

订单代码

chenxiaofei 1 bulan lalu
induk
melakukan
7d96a3ac3e

+ 20 - 0
iot-platform-manager/src/main/java/com/platform/api/controller/WeighbridgeV2Controller.java

@@ -1,8 +1,10 @@
 package com.platform.api.controller;
 
 import com.platform.api.manager.WeighbridgeRecordManage;
+import com.platform.api.request.CanLiftGateRequest;
 import com.platform.api.request.LicensePlateValidateRequest;
 import com.platform.api.request.WeighbridgePushRequest;
+import com.platform.api.response.CanLiftGateResponse;
 import com.platform.api.response.LicensePlateValidateResponse;
 import com.platform.config.XpCloudProperties;
 import com.platform.exception.IotException;
@@ -122,6 +124,24 @@ public class WeighbridgeV2Controller {
         return weighbridgeRecordManage.handleWeighbridgePushV2(request);
     }
 
+
+
+    @Operation(summary = "抬杆接口查询", description = "抬杆接口查询")
+    @PostMapping("/canLiftGateV2")
+    public CanLiftGateResponse canLiftGateV2(
+            @Parameter(
+                    name = SIGNATURE,
+                    in = ParameterIn.HEADER)
+            @RequestHeader(value = SIGNATURE, required = false)  String printReceiptAuthSn,
+            @RequestBody CanLiftGateRequest req
+    ) {
+        assertPrintReceiptAuthorized(printReceiptAuthSn);
+
+        // 调用业务层处理
+        return weighbridgeRecordManage.canLiftGate(req);
+    }
+
+
     /**
      * 简单鉴权:当配置了允许的凭证时,请求头 {@link #SIGNATURE} 的值必须与其一致。
      *

+ 42 - 14
iot-platform-manager/src/main/java/com/platform/api/manager/WeighbridgeRecordManage.java

@@ -8,6 +8,7 @@ import com.platform.api.request.CanLiftGateRequest;
 import com.platform.api.request.LicensePlateValidateRequest;
 import com.platform.api.request.WeighbridgePushRequest;
 import com.platform.api.request.WeighbridgeRecordPageReqVo;
+import com.platform.api.response.CanLiftGateResponse;
 import com.platform.api.response.WeighbridgeRecordExcel;
 import com.platform.api.response.WeighbridgeRecordResVo;
 import com.platform.entity.KwsWeighbridge;
@@ -370,15 +371,6 @@ public class WeighbridgeRecordManage {
         log.info("车牌验证, 车牌:{}", request.getLicensePlate());
         LicensePlateValidateResponse response = new LicensePlateValidateResponse();
         ValidateLicensePlate validateLicensePlate;
-        //是否抬杆
-        CanLiftGateRequest canLiftGateRequest = new CanLiftGateRequest();
-        boolean canLiftGate = externalWeighbridgePushService.queryCanLiftGate(canLiftGateRequest);
-        log.info("是否抬杆: {}", canLiftGate);
-        if (!canLiftGate){
-            log.info("状态查询结果:{},不能抬杆", canLiftGate);
-            return getValidateLicensePlateError(response);
-        }
-
         //查询车牌是不存在
         try {
             validateLicensePlate = validateLicensePlateService.queryByLicensePlate(request.getLicensePlate(), request.getUuid());
@@ -676,11 +668,47 @@ public class WeighbridgeRecordManage {
     }
 
 
+    /**
+     * 查询车辆是否允许抬杆。
+     *
+     * @param req 抬杆校验请求参数
+     * @return 抬杆校验响应结果
+     */
+    public CanLiftGateResponse canLiftGate(CanLiftGateRequest req) {
+        log.info("开始处理车辆抬杆校验请求:{}", JSON.toJSONString(req));
+        if (Objects.isNull(req) || StringUtils.isBlank(req.getTruckNo())) {
+            log.warn("车辆抬杆校验参数不合法,请求参数:{}", JSON.toJSONString(req));
+            return buildCanLiftGateResponse(false, 400, "车牌号不能为空", false);
+        }
 
- 
-
-
-
-
+        try {
+            boolean canLiftGate = externalWeighbridgePushService.queryCanLiftGate(req);
+            log.info("车辆抬杆校验完成,车牌号:{},是否允许抬杆:{}", req.getTruckNo(), canLiftGate);
+            return buildCanLiftGateResponse(true, 200, "抬杆校验成功", canLiftGate);
+        } catch (Exception e) {
+            log.error("查询车辆是否允许抬杆异常,车牌号:{}", req.getTruckNo(), e);
+            return buildCanLiftGateResponse(false, 400, "抬杆校验失败", false);
+        }
+    }
 
+    /**
+     * 构建抬杆校验统一返回对象。
+     *
+     * @param status      接口处理状态
+     * @param code        接口处理状态码
+     * @param message     接口处理描述
+     * @param canLiftGate 是否允许抬杆
+     * @return 抬杆校验响应结果
+     */
+    private CanLiftGateResponse buildCanLiftGateResponse(Boolean status, Integer code, String message, Boolean canLiftGate) {
+        CanLiftGateResponse response = new CanLiftGateResponse();
+        response.setStatus(status);
+        response.setCode(code);
+        response.setMessage(message);
+
+        CanLiftGateResponse.Data data = new CanLiftGateResponse.Data();
+        data.setCanLiftGate(canLiftGate);
+        response.setData(data);
+        return response;
+    }
 }

+ 46 - 0
iot-platform-manager/src/main/java/com/platform/api/response/CanLiftGateResponse.java

@@ -0,0 +1,46 @@
+package com.platform.api.response;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 车牌验证请求参数
+ * @author PC
+ */
+@Data
+@Schema(description = "抬杆校验返回参数")
+public class CanLiftGateResponse {
+    /**
+     * 返回状态
+     */
+    @Schema(description = "返回状态")
+    private Boolean status;
+
+    /**
+     * 返回状态值
+     */
+    @Schema(description = "返回描述")
+    private Integer code;
+
+    /**
+     * 返回数据集
+     */
+    @Schema(description = "返回数据集")
+    private String message;
+
+    /**
+     * 抬杆校验数据
+     */
+    @Schema(description = "抬杆校验数据")
+    private Data data;
+
+    @lombok.Data
+    public static class Data {
+
+        /**
+         * 是否允许抬杆;true允许抬杆,false不允许抬杆。
+         */
+        @Schema(description = "是否允许抬杆", example = "true")
+        private Boolean canLiftGate;
+    }
+}