|
|
@@ -1,9 +1,12 @@
|
|
|
package com.platform.external.service;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.platform.api.request.CanLiftGateRequest;
|
|
|
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.WeighbridgePushProperties;
|
|
|
import com.platform.external.request.WaybillOrderProcessParam;
|
|
|
import com.platform.result.BaseResult;
|
|
|
@@ -28,6 +31,11 @@ public class WeighbridgePushService {
|
|
|
|
|
|
private final WeighbridgePushProperties weighbridgePushProperties;
|
|
|
|
|
|
+
|
|
|
+ private final CanLiftGateProperties canLiftGateProperties;
|
|
|
+
|
|
|
+ private final CanLiftGateClient canLiftGateClient;
|
|
|
+
|
|
|
/**
|
|
|
* 推送地磅记录到外部系统。
|
|
|
*
|
|
|
@@ -82,4 +90,40 @@ public class WeighbridgePushService {
|
|
|
request.setWeighAmount(record.getWeight());
|
|
|
return request;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询车牌是否允许抬杆。
|
|
|
+ *
|
|
|
+ * <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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|