Sfoglia il codice sorgente

增加超时/异常比例ding提醒

15810770710@163.com 2 anni fa
parent
commit
a7fb777579

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

@@ -17,10 +17,14 @@ public class CommonConstant {
     public static String PERSON_ILLEGAL_INFO_TIME_OUT = "personIllegalInfoTimeOut";
     // 不良-人员核验-业务异常redisKey
     public static String PERSON_ILLEGAL_INFO_QUERY_FAILED = "personIllegalInfoQueryFailed";
+    // 不良-人员核验-总数
+    public static String PERSON_ILLEGAL_INFO_COUNT = "personIllegalInfoCount";
     // 不良-车辆核验-超时redisKey
     public static String VEHICLE_ILLEGAL_INFO_TIME_OUT = "vehicleIllegalInfoTimeOut";
     // 不良-车辆核验-业务异常redisKey
     public static String VEHICLE_ILLEGAL_INFO_QUERY_FAILED = "vehicleIllegalInfoQueryFailed";
+    // 不良-车辆核验-总数
+    public static String VEHICLE_ILLEGAL_INFO_COUNT = "vehicleIllegalInfoCount";
 
     public static final String APPLICATION_JSON_UTF8_VALUE = "application/json;charset=UTF-8";
     // 人员核验超时时间 timeOut

+ 5 - 0
src/main/java/com/jkcredit/illegal/info/service/impl/IllegalInfoServiceImpl.java

@@ -47,6 +47,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
      */
     @Override
     public IllegalInfoResult checkIllegalInfo(IllegalInfoRequestParam requestParams) {
+        stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_COUNT).increment();
         String body = JSON.toJSONString(requestParams);
 
         Long startTime = System.currentTimeMillis();
@@ -92,6 +93,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
 
     @Override
     public VehicleIllegalInfoResult checkVehicleIllegalInfo(String params) {
+        stringRedisTemplate.boundValueOps(CommonConstant.VEHICLE_ILLEGAL_INFO_COUNT).increment();
         try {
             params = AesUtil.decryAES(decodeKey, params);
         } catch (Exception e) {
@@ -137,6 +139,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
 
     @Override
     public IllegalInfoResult checkPersonIllegalInfo(String params) {
+        stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_COUNT).increment();
         try {
             params = AesUtil.decryAES(decodeKey, params);
         } catch (Exception e) {
@@ -233,6 +236,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
      */
     @Override
     public IllegalInfoResult checkIllegalInfoV2(IllegalInfoRequestParam requestParams) {
+        stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_COUNT).increment();
         String body = JSON.toJSONString(requestParams);
         Long startTime = System.currentTimeMillis();
         String result = OkHttpUtil.doPost(illegalInfoUrl, body, CommonConstant.PERSON_TIME_OUT);
@@ -279,6 +283,7 @@ public class IllegalInfoServiceImpl implements IllegalInfoService {
      */
     @Override
     public IllegalInfoResult checkIllegalInfoV3(IllegalInfoRequestParam requestParams) {
+        stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_COUNT).increment();
         String body = JSON.toJSONString(requestParams);
 
         Long startTime = System.currentTimeMillis();

+ 22 - 10
src/main/java/com/jkcredit/illegal/info/task/ExceptionListenerTask.java

@@ -24,65 +24,77 @@ public class ExceptionListenerTask {
     public void personIllegalInfoTask() {
         int timeOutCount = 0;
         int queryFailedCount = 0;
+        int totalCount = 0;
         String timeOut = stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_TIME_OUT).get();
         String queryFailed = stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_QUERY_FAILED).get();
+        String total = stringRedisTemplate.boundValueOps(CommonConstant.PERSON_ILLEGAL_INFO_COUNT).get();
         if (timeOut != null) {
             timeOutCount = Integer.parseInt(timeOut);
         }
         if (queryFailed != null) {
             queryFailedCount = Integer.parseInt(queryFailed);
         }
+        if (total != null) {
+            totalCount = Integer.parseInt(total);
+        }
 
-        String errorMessage = "社会风险预警-人员核验接口失败,失败原因:";
+        StringBuilder errorMessage = new StringBuilder("社会风险预警-人员核验接口失败,失败原因:");
         if (timeOutCount > 10) {
-            errorMessage += "数据源超时";
-            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage);
+            errorMessage.append("数据源超时, 超时比例 ").append(timeOutCount / totalCount);
+            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage.toString());
             if (sendDingMsgResponseObject.getCode() != 1) {
                 log.info("personIllegalInfoTask, 发送钉钉异常:社会风险预警-人员核验接口失败-数据源超时");
             }
         }
 
         if (queryFailedCount > 10) {
-            errorMessage += "数据源返回结果异常";
-            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage);
+            errorMessage.append("数据源返回结果异常,异常比例 ").append(queryFailedCount / totalCount);
+            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage.toString());
             if (sendDingMsgResponseObject.getCode() != 1) {
                 log.info("personIllegalInfoTask, 发送钉钉异常:社会风险预警-人员核验接口失败-数据源返回结果异常");
             }
         }
         stringRedisTemplate.delete(CommonConstant.PERSON_ILLEGAL_INFO_TIME_OUT);
         stringRedisTemplate.delete(CommonConstant.PERSON_ILLEGAL_INFO_QUERY_FAILED);
+        stringRedisTemplate.delete(CommonConstant.PERSON_ILLEGAL_INFO_COUNT);
     }
 
     @Scheduled(cron = "0 0/5 * * * ?", zone = "Asia/Shanghai")
     public void vehicleIllegalInfoTask() {
         int timeOutCount = 0;
         int queryFailedCount = 0;
+        int totalCount = 0;
         String timeOut = stringRedisTemplate.boundValueOps(CommonConstant.VEHICLE_ILLEGAL_INFO_TIME_OUT).get();
         String queryFailed = stringRedisTemplate.boundValueOps(CommonConstant.VEHICLE_ILLEGAL_INFO_QUERY_FAILED).get();
+        String total = stringRedisTemplate.boundValueOps(CommonConstant.VEHICLE_ILLEGAL_INFO_COUNT).get();
         if (timeOut != null) {
             timeOutCount = Integer.parseInt(timeOut);
         }
         if (queryFailed != null) {
             queryFailedCount = Integer.parseInt(queryFailed);
         }
+        if (total != null) {
+            totalCount = Integer.parseInt(total);
+        }
 
-        String errorMessage = "社会风险预警-车辆核验接口失败,失败原因:";
+        StringBuilder errorMessage = new StringBuilder("社会风险预警-车辆核验接口失败,失败原因:");
         if (timeOutCount > 10) {
-            errorMessage += "数据源超时";
-            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage);
+            errorMessage.append("数据源超时,超时比例 ").append(timeOutCount / totalCount);
+            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage.toString());
             if (sendDingMsgResponseObject.getCode() != 1) {
                 log.info("vehicleIllegalInfoTask, 发送钉钉异常:社会风险预警-车辆核验接口失败-数据源超时");
             }
         }
 
         if (queryFailedCount > 10) {
-            errorMessage += "数据源返回结果异常";
-            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage);
+            errorMessage.append("数据源返回结果异常,异常比例 ").append(queryFailedCount / totalCount);
+            SendDingMsgResponseObject sendDingMsgResponseObject = DingRobotUtil.sendDingRobotMsg(errorMessage.toString());
             if (sendDingMsgResponseObject.getCode() != 1) {
                 log.info("vehicleIllegalInfoTask, 发送钉钉异常:社会风险预警-车辆核验接口失败-数据源返回结果异常");
             }
         }
         stringRedisTemplate.delete(CommonConstant.VEHICLE_ILLEGAL_INFO_TIME_OUT);
         stringRedisTemplate.delete(CommonConstant.VEHICLE_ILLEGAL_INFO_QUERY_FAILED);
+        stringRedisTemplate.delete(CommonConstant.VEHICLE_ILLEGAL_INFO_COUNT);
     }
 }

+ 10 - 3
src/main/resources/application.yml

@@ -8,11 +8,18 @@ spring:
 server:
   port: 8005
 illegalInfo:
-  url: https://47.95.12.213:8004/ryhc
-  vehicleUrl: https://47.95.12.213:8004/clhc
+  url: https://127.0.0.1:8004/ryhc
+  vehicleUrl: https://127.0.0.1:8004/clhc
   certificateUrl: /home/tpuser/apps/illegal-info-v2/client.pfx
-#  certificateUrl: /Users/jkxy/Desktop/client.pfx
+  #  certificateUrl: /Users/jkxy/Desktop/client.pfx
   certificatePassword: client
   decodeKey: 374c72b109292ad4
 dingding:
   url: https://oapi.dingtalk.com/robot/send?access_token=64e1e991ba9d148cd837c9d49f9ce82bfcfb7f8ad371c08ec392c0fca5806738
+criminalInfo:
+  url: http://36.133.192.19:9011/dsp/dataMark
+  secretId: jiaoke
+  secretKey: YzBkNWU1OGFkMzM5NGRiOTljZWNiMDllZmJmZWEyZjI=
+  productCode: PROD0002
+logging:
+  config: classpath:logback-spring.xml