chenxiaofei il y a 1 mois
Parent
commit
bb844a300b

+ 15 - 0
iot-platform-manager/src/main/java/com/platform/api/manager/WeighbridgeRecordManage.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.platform.api.request.CanLiftGateRequest;
 import com.platform.api.request.LicensePlateValidateRequest;
 import com.platform.api.request.WeighbridgePushRequest;
 import com.platform.api.request.WeighbridgeRecordPageReqVo;
@@ -361,9 +362,23 @@ public class WeighbridgeRecordManage {
      * @return 是否保存成功
      */
     public LicensePlateValidateResponse handleValidateLicensePlate(LicensePlateValidateRequest request) {
+        log.info("车牌验证 - 请求参数: {}", JSON.toJSONString( request));
+        if (Objects.isNull(request) || StringUtils.isBlank(request.getLicensePlate())) {
+            log.warn("车牌验证参数为空");
+            return getValidateLicensePlateError(new LicensePlateValidateResponse());
+        }
         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());

+ 21 - 0
iot-platform-manager/src/main/java/com/platform/api/request/CanLiftGateRequest.java

@@ -0,0 +1,21 @@
+package com.platform.api.request;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 车牌验证请求参数
+ * @author PC
+ */
+@Data
+@Schema(description = "车辆识别请求参数")
+public class CanLiftGateRequest {
+
+    /**
+     * 车牌号
+     */
+    @Schema(description = "车牌号", example = "川A1234")
+    private String truckNo;
+
+
+}

+ 29 - 0
iot-platform-manager/src/main/java/com/platform/external/client/CanLiftGateClient.java

@@ -0,0 +1,29 @@
+package com.platform.external.client;
+
+import com.platform.api.request.CanLiftGateRequest;
+import com.platform.external.request.CarInfoReq;
+import com.platform.external.request.WaybillOrderProcessParam;
+import com.platform.result.BaseResult;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+/**
+ * 外部系统地磅数据 Feign 客户端。
+ *
+ * @author PC
+ */
+@FeignClient(
+        name = "${external-system.can-lift-gate.service-id:sckw-ng-transport}",
+        path = "${external-system.can-lift-gate.base-path:/appGatekeeper}"
+)
+public interface CanLiftGateClient {
+    /**
+     * 查询车牌是否允许抬杆。
+     *
+     * @param request 车牌与厂商来源标识
+     * @return 外部系统抬杆校验结果
+     */
+    @PostMapping("${external-system.weighbridge.lift-gate-check-path:/isPass}")
+    BaseResult<Boolean> queryCanLiftGate(@RequestBody CanLiftGateRequest request);
+}

+ 16 - 0
iot-platform-manager/src/main/java/com/platform/external/client/WeighbridgePushClient.java

@@ -1,5 +1,6 @@
 package com.platform.external.client;
 
+import com.platform.external.request.CarInfoReq;
 import com.platform.external.request.WaybillOrderProcessParam;
 import com.platform.result.BaseResult;
 import org.springframework.cloud.openfeign.FeignClient;
@@ -26,6 +27,21 @@ public interface WeighbridgePushClient {
     @PostMapping("${external-system.weighbridge.push-path:/comeInto}")
     BaseResult pushWeighbridgeRecord(@RequestBody WaybillOrderProcessParam request);
 
+    /**
+     * 推送地磅记录到外部系统。
+     *
+     * @param request 地磅记录推送请求
+     * @return 外部系统响应
+     */
     @PostMapping("${external-system.unloadingWeigh.push-path:/unloadingWeigh}")
     BaseResult unloadingPushWeigh(WaybillOrderProcessParam request);
+
+    /**
+     * 查询车牌是否允许抬杆。
+     *
+     * @param request 车牌与厂商来源标识
+     * @return 外部系统抬杆校验结果
+     */
+    @PostMapping("${external-system.weighbridge.lift-gate-check-path:/validateLicensePlate}")
+    BaseResult<Boolean> queryCanLiftGate(@RequestBody CarInfoReq request);
 }

+ 21 - 0
iot-platform-manager/src/main/java/com/platform/external/config/CanLiftGateProperties.java

@@ -0,0 +1,21 @@
+package com.platform.external.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 外部系统地磅数据推送配置。
+ *
+ * @author PC
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "external-system.can-lift-gate")
+public class CanLiftGateProperties {
+
+    /**
+     * 是否启用外部系统推送,默认关闭,避免未配置外部系统时影响现有业务流程。
+     */
+    private Boolean canLiftGate;
+}

+ 45 - 0
iot-platform-manager/src/main/java/com/platform/external/service/WeighbridgePushService.java

@@ -1,11 +1,16 @@
 package com.platform.external.service;
 
 import com.alibaba.fastjson2.JSON;
+import com.platform.api.request.CanLiftGateRequest;
+import com.platform.api.request.LicensePlateValidateRequest;
 import com.platform.entity.WeighbridgeRecord;
 import com.platform.exception.IotException;
+import com.platform.external.client.CanLiftGateClient;
 import com.platform.external.client.WeighbridgePushClient;
+import com.platform.external.config.CanLiftGateProperties;
 import com.platform.external.config.UnloadWeighbridgePushProperties;
 import com.platform.external.config.WeighbridgePushProperties;
+import com.platform.external.request.CarInfoReq;
 import com.platform.external.request.WaybillOrderProcessParam;
 import com.platform.result.BaseResult;
 import lombok.RequiredArgsConstructor;
@@ -13,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -31,6 +37,10 @@ public class WeighbridgePushService {
 
     private final UnloadWeighbridgePushProperties unloadWeighbridgePushProperties;
 
+    private final CanLiftGateProperties canLiftGateProperties;
+
+    private final CanLiftGateClient canLiftGateClient;
+
     /**
      * 推送地磅记录到外部系统。
      *
@@ -115,4 +125,39 @@ public class WeighbridgePushService {
             throw new IotException("外部系统地磅数据推送失败");
         }
     }
+
+    /**
+     * 查询车牌是否允许抬杆。
+     *
+     * <p>外部系统不可用、返回失败或数据格式异常时,统一按不允许抬杆处理,避免异常放行。</p>
+     *
+     * @param request 车牌校验请求
+     * @return true允许抬杆,false不允许抬杆
+     */
+    public boolean queryCanLiftGate(CanLiftGateRequest request) {
+        if (!Boolean.TRUE.equals(canLiftGateProperties.getCanLiftGate())) {
+            log.debug("外部系统抬杆校验未启用,车牌默认允许抬杆");
+            return true;
+        }
+        if (Objects.isNull(request) || StringUtils.isBlank(request.getTruckNo())) {
+            log.warn("外部系统抬杆校验参数为空,跳过调用");
+            return false;
+        }
+        try {
+            log.info("外部系统抬杆校验开始,车牌: {}", request.getTruckNo());
+            BaseResult<Boolean> response = canLiftGateClient.queryCanLiftGate(request);
+            log.info("外部系统抬杆校验完成,车牌: {}, 响应: {}", request.getTruckNo(), JSON.toJSONString(response));
+            if (Objects.isNull(response) || !response.isSuccess()) {
+                log.warn("外部系统抬杆校验失败,车牌: {}, 响应: {}", request.getTruckNo(), JSON.toJSONString(response));
+                return false;
+            }
+            boolean canLiftGate = response.getData();
+            log.info("外部系统抬杆校验完成,车牌: {}, 是否允许抬杆: {}", request.getTruckNo(), canLiftGate);
+            return canLiftGate;
+        } catch (Exception e) {
+            log.error("外部系统抬杆校验异常,车牌: {}", request.getTruckNo(), e);
+            return false;
+        }
+    }
+
 }