Explorar el Código

新增车主核验二要素接口

xsl hace 9 meses
padre
commit
aa5b2bf812

+ 2 - 2
src/main/java/com/jkcredit/illegal/info/constant/CommonConstant.java

@@ -28,9 +28,9 @@ public class CommonConstant {
 
     public static final String APPLICATION_JSON_UTF8_VALUE = "application/json;charset=UTF-8";
     // 人员核验超时时间 timeOut
-    public static int PERSON_TIME_OUT = 500;
+    public static int PERSON_TIME_OUT = 20000;
     // 车辆核验超时时间 timeOut
-    public static int VEHICLE_TIME_OUT = 5000;
+    public static int VEHICLE_TIME_OUT = 20000;
     // dingding超时时间 timeOut
     public static int DING_TIME_OUT = 5000;
 }

+ 13 - 0
src/main/java/com/jkcredit/illegal/info/controller/IllegalInfoController.java

@@ -101,6 +101,19 @@ public class IllegalInfoController {
         }
     }
 
+    @PostMapping("/vehicleOwnerValidate.do")
+    public CommonResponseObject vehicleOwnerValidate(@RequestBody CommonParamObject params) {
+
+        log.info("vehicleOwnerValidate-接收参数:{}", params);
+        VehicleOwnerValidateResult result = illegalInfoService.vehicleOwnerValidate(params.getParam());
+        if (result != null) {
+            log.info("vehicleOwnerValidate-返回:{}", result);
+            return CommonResponseObject.success(result);
+        } else {
+            return CommonResponseObject.failure();
+        }
+    }
+
     @PostMapping("/checkIllegalInfoTest.do")
     public CommonResponseObject checkIllegalInfoTest(@RequestBody IllegalInfoRequestParam requestParams) {
         IllegalInfoResult illegalInfoResult = illegalInfoTestService.checkIllegalInfoTest(requestParams);

+ 38 - 0
src/main/java/com/jkcredit/illegal/info/model/VehicleOwnerValidateChargeObject.java

@@ -0,0 +1,38 @@
+package com.jkcredit.illegal.info.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.springframework.beans.BeanUtils;
+
+import java.io.Serializable;
+
+/**
+ * @author xusonglin
+ * @version V1.0
+ **/
+@ToString
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class VehicleOwnerValidateChargeObject implements Serializable {
+    private static final long serialVersionUID = 6336566389330019893L;
+
+    private String method;
+
+    private String traceId;
+
+    private String code;
+
+    private String result;
+
+    private boolean isCharge;
+
+    public VehicleOwnerValidateChargeObject(VehicleOwnerValidateResult result, boolean isCharge, String traceId) {
+        BeanUtils.copyProperties(result, this);
+        this.method = "vehicleOwnerValidate";
+        this.isCharge = isCharge;
+        this.traceId = traceId;
+    }
+}

+ 25 - 0
src/main/java/com/jkcredit/illegal/info/model/VehicleOwnerValidateRequestParam.java

@@ -0,0 +1,25 @@
+package com.jkcredit.illegal.info.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+import lombok.ToString;
+
+/**
+ * @author xusonglin
+ * @version V1.0
+ **/
+@Data
+@ToString
+public class VehicleOwnerValidateRequestParam {
+    @JSONField(name = "XM")
+    private String name;
+
+    @JSONField(name = "TAG")
+    private String traceId;
+
+    @JSONField(name = "HM")
+    private String plateNumber;
+
+    @JSONField(name = "ZL")
+    private String plateColor;
+}

+ 19 - 0
src/main/java/com/jkcredit/illegal/info/model/VehicleOwnerValidateResult.java

@@ -0,0 +1,19 @@
+package com.jkcredit.illegal.info.model;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+/**
+ * @author xusonglin
+ * @version V1.0
+ **/
+@Data
+@ToString
+public class VehicleOwnerValidateResult implements Serializable {
+    private static final long serialVersionUID = -8055501178509325814L;
+    private String code;
+
+    private String result;
+}

+ 3 - 0
src/main/java/com/jkcredit/illegal/info/service/IllegalInfoService.java

@@ -3,6 +3,7 @@ package com.jkcredit.illegal.info.service;
 import com.jkcredit.illegal.info.model.IllegalInfoRequestParam;
 import com.jkcredit.illegal.info.model.IllegalInfoResult;
 import com.jkcredit.illegal.info.model.VehicleIllegalInfoResult;
+import com.jkcredit.illegal.info.model.VehicleOwnerValidateResult;
 
 /**
  * @description:
@@ -20,4 +21,6 @@ public interface IllegalInfoService {
     IllegalInfoResult checkIllegalInfoV2(IllegalInfoRequestParam requestParams);
 
     IllegalInfoResult checkIllegalInfoV3(IllegalInfoRequestParam requestParams);
+
+    VehicleOwnerValidateResult vehicleOwnerValidate(String params);
 }

+ 45 - 1
src/main/java/com/jkcredit/illegal/info/service/impl/IllegalInfoServiceImpl.java

@@ -31,6 +31,8 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
     private String illegalInfoUrl;
     @Value("${illegalInfo.vehicleUrl}")
     private String vehicleIllegalInfoUrl;
+    @Value("${illegalInfo.vehicleOwnerValidateUrl}")
+    private String vehicleOwnerValidateUrl;
     @Value("${illegalInfo.decodeKey}")
     private String decodeKey;
     @Autowired
@@ -105,7 +107,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
 
         Long startTime = System.currentTimeMillis();
         String result = OkHttpUtil.doPost(vehicleIllegalInfoUrl, body, CommonConstant.VEHICLE_TIME_OUT);
-        log.info("调用上游接口-流水号:{}, 入参:{}, 返回:{}, 时延:{}", requestParam.getTraceId(), body, result, System.currentTimeMillis() - startTime);
+        log.info("调用上游接口-checkVehicleIllegalInfo-流水号:{}, 入参:{}, 返回:{}, 时延:{}", requestParam.getTraceId(), body, result, System.currentTimeMillis() - startTime);
         if (StringUtils.isBlank(result)) {
             log.info("checkVehicleIllegalInfoRequestError-流水号:{}, 入参:{}, 请求上游失败无返回", requestParam.getTraceId(), body);
             stringRedisTemplate.boundValueOps(CommonConstant.VEHICLE_ILLEGAL_INFO_TIME_OUT).increment();
@@ -310,4 +312,46 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
         }
         return illegalInfoResult;
     }
+
+    @Override
+    public VehicleOwnerValidateResult vehicleOwnerValidate(String params) {
+        try {
+            params = AesUtil.decryAES(decodeKey, params);
+        } catch (Exception e) {
+            log.info("解析参数失败, 入参:{}", params);
+            return null;
+        }
+        VehicleOwnerValidateRequestParam requestParam = getVehicleOwnerValidateRequestParam(params);
+        String body = JSON.toJSONString(requestParam);
+
+        Long startTime = System.currentTimeMillis();
+        String result = OkHttpUtil.doPost(vehicleOwnerValidateUrl, body, CommonConstant.VEHICLE_TIME_OUT);
+        log.info("调用上游接口-vehicleOwnerValidate-流水号:{}, 入参:{}, 返回:{}, 时延:{}", requestParam.getTraceId(), body, result, System.currentTimeMillis() - startTime);
+        if (StringUtils.isBlank(result)) {
+            log.info("vehicleOwnerValidateRequestError-流水号:{}, 入参:{}, 请求上游失败无返回", requestParam.getTraceId(), body);
+            return null;
+        }
+        VehicleOwnerValidateResult vehicleOwnerValidateResult = JSON.toJavaObject(JSON.parseObject(result), VehicleOwnerValidateResult.class);
+        // code0表示结果正常,其他表示异常
+        if (!vehicleOwnerValidateResult.getCode().equals("0")
+                || vehicleOwnerValidateResult.getResult().equals("2")) {
+            // 查询错误,不计费
+            CHARGE_LOGGER.info(JSON.toJSONString(new VehicleOwnerValidateChargeObject(vehicleOwnerValidateResult, false, requestParam.getTraceId())));
+            log.info("vehicleOwnerValidateResultError-流水号:{}, 上游结果异常", requestParam.getTraceId());
+        } else {
+            // 查询成功,计费
+            CHARGE_LOGGER.info(JSON.toJSONString(new VehicleOwnerValidateChargeObject(vehicleOwnerValidateResult, true, requestParam.getTraceId())));
+        }
+        return vehicleOwnerValidateResult;
+    }
+
+    private VehicleOwnerValidateRequestParam getVehicleOwnerValidateRequestParam(String params) {
+        JSONObject jsonObject = JSON.parseObject(params);
+        VehicleOwnerValidateRequestParam requestParam = new VehicleOwnerValidateRequestParam();
+        requestParam.setName(jsonObject.getString("name"));
+        requestParam.setPlateNumber(jsonObject.getString("plateNumber"));
+        requestParam.setTraceId(jsonObject.getString("traceId"));
+        requestParam.setPlateColor(jsonObject.getString("plateColor"));
+        return requestParam;
+    }
 }

+ 1 - 0
src/main/resources/application.yml

@@ -10,6 +10,7 @@ server:
 illegalInfo:
   url: https://127.0.0.1:8004/ryhc
   vehicleUrl: https://127.0.0.1:8004/clhc
+  vehicleOwnerValidateUrl: https://127.0.0.1:8004/clhc2
   certificateUrl: /home/tpuser/apps/illegal-info-v2/client.pfx
   #  certificateUrl: /Users/jkxy/Desktop/client.pfx
   certificatePassword: client