Kaynağa Gözat

1. 永诚报价优化2

ligang134 3 yıl önce
ebeveyn
işleme
bbf8e7e28d

+ 103 - 39
src/main/java/com/ydtech/modules/ins/service/impl/InsAlltrustApiServiceImpl.java

@@ -47,6 +47,7 @@ import com.ydtech.modules.ins.model.yc.policy.Policy;
 import com.ydtech.modules.ins.model.yc.policy.response.PolicyResponse;
 import com.ydtech.modules.ins.model.yc.ruote.*;
 import com.ydtech.modules.ins.model.yc.ruote.response.RuoteResponse;
+import com.ydtech.modules.ins.model.yc.ruote.response.TfiWarnListResponse;
 import com.ydtech.modules.ins.service.*;
 import com.ydtech.modules.order.components.ConfigureParametersComponents;
 import com.ydtech.modules.order.components.InsOrdersComponents;
@@ -93,6 +94,10 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
 
     private ObjectMapper xmlMapper = null;
 
+    //请求信息列表
+    List<String> requestInfoList = new ArrayList<>();
+
+
 
     @Autowired
     private YcBuildData ycBuildData;
@@ -325,6 +330,7 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
     @Override
     public HttpResult quoteApi(BaseQuoteVo<AccidentalDrivingVo> quoteVo) {
 
+        requestInfoList = new ArrayList<>();
 
         // 获取协议配置信息
         YcConfigureParameters ycConfigureParameters = gainYcConfigParams(quoteVo.getAgreementId());
@@ -367,15 +373,23 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
         while (!boo) {
             rr = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
             //处理返回信息
-            //1、起保日期处理
+            //1、交强险重复投保处理
+            boo = ciRepetitionInsure(rr, m);
+            if (!boo) continue;
 
             //2、转报处理
             boo = reinsurance(rr, m);
             if (!boo) continue;
 
-            if (null == rr) return HttpResult.error("远程请求报价失败");
-            if (!rr.getHead().getErrorCode().equals("000000")) return HttpResult.error(rr.getHead().getErrorMessage());
+            //3、商业险日期处理
+            boo = biRepetitionInsure(rr, m);
+
+
         }
+        if (null == rr) return HttpResult.error("远程请求报价失败");
+        if (!rr.getHead().getErrorCode().equals("000000")) return HttpResult.error(rr.getHead().getErrorMessage());
+
+
 //        RuoteResponse rr = requestApi(m, new RuoteResponse(), iac, YcBuildData.API_QUOTE, InsQuoteFlow.Q_S_0);
 //        if (null == rr) return HttpResult.error("远程请求报价失败");
 //        if (!rr.getHead().getErrorCode().equals("000000")) return HttpResult.error(rr.getHead().getErrorMessage());
@@ -399,6 +413,9 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
 //            updateApiLog(apiLog, iac);
         quoteRespVo.setCompanyId(iac.getId());
 
+        requestInfoList.stream().forEach(c ->{
+            System.err.println("========请求流程信息==========:"+c);
+        });
 
         return HttpResult.ok("报价成功", quoteRespVo);
 
@@ -469,44 +486,90 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
 
 
     /**
-     * 报价  重复投保业务处理
+     * 报价  交强险 重复 投保业务处理
      */
-    public boolean repetitionInsure(RuoteResponse rr, Ruote m) {
-//        if (rr.getHead().getErrorCode().equals("009999") && rr.getHead().getErrorMessage().indexOf("重复投保") > 1) {
-//
-//            String errorMsg = rr.getHead().getErrorMessage();
-//            //截取0 到 机动车交通事故强制险
-//            String ciMsg = errorMsg.substring(0, errorMsg.indexOf("机动车交通事故强制险"));
-//
-//            String cCheckCodeJQ = rr.getVhl().getCCheckCodeJQ();
-//            String cCheckCodeSY = rr.getVhl().getCCheckCodeSY();
-//
-//            //转保调用自动识别转保码
-//            if (StringUtils.isNotEmpty(cCheckCodeJQ) || StringUtils.isNotEmpty(cCheckCodeSY)) {
-//                //调用python ocr
-//                String sendBody = "";
-//                Map bodyMap = new HashMap();
-//                bodyMap.put("jqImage", StringUtils.isNotEmpty(cCheckCodeJQ) ? cCheckCodeJQ : "");
-//                bodyMap.put("syImage", StringUtils.isNotEmpty(cCheckCodeSY) ? cCheckCodeSY : "");
-//                sendBody = JsonUtils.toJson(bodyMap);
-//                String ocrStr = HttpUtil.sendPost("http://47.92.254.66:8088/getres", sendBody);
-//                Map ocrMap = JsonUtils.toObject(ocrStr, Map.class);
-//
-//
-//                m.getRequestLabel().getCondition().getVhl().setCBusType("2");
-//                //交强
-//                m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(ocrMap.get("jqImageCode").toString());
-////                m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ(ocrMap.get("jqImageCode").toString());
-//                m.getRequestLabel().getCondition().getVhl().setCQryCdeJQ(rr.getVhl().getCQryCdeJQ());
-//
-//                //商业
-//                m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY(ocrMap.get("syImageCode").toString());
-//                m.getRequestLabel().getCondition().getVhl().setCQryCdeSY(rr.getVhl().getCQryCdeSY());
-//
-//                return false;
+    public boolean ciRepetitionInsure(RuoteResponse rr, Ruote m) {
+        String errorMsg = rr.getHead().getErrorMessage();
+        if (rr.getHead().getErrorCode().equals("009999") && errorMsg.contains("重复投保") && errorMsg.contains("机动车交通事故强制险")  && errorMsg.contains("终保日期")) {
+            requestInfoList.add(errorMsg);
+
+            //截取0 到 机动车交通事故强制险
+            String ciMsg = errorMsg.substring(0, errorMsg.indexOf("机动车交通事故强制险"));
+
+            //终保日期
+            String coverageEndDate = ciMsg.substring(ciMsg.indexOf("终保日期") + 5, ciMsg.indexOf("终保日期") + 5 + 16);
+
+            LocalDateTime start = DateTimeUtil.parseLocalDateTime(coverageEndDate, DateTimeUtil.DATETIME_PATTERN_EXT1);
+
+            LocalDateTime end = start.plusYears(1L).minusDays(1L);
+            String newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
+            if(start.getHour()>0){
+                end = start.plusYears(1L);
+                newStartDate = DateTimeUtil.format(start, DateTimeUtil.DATETIME_PATTERN);
+            }
+
+
+
+            String newEndDate = DateTimeUtil.getEndTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
+            System.err.println("新起:" + newStartDate);
+            System.err.println("新止:" + newEndDate);
+
+            m.getRequestLabel().getCondition().getBase().setTInsrncBgnTmJQ(newStartDate);
+            m.getRequestLabel().getCondition().getBase().setTInsrncEndTmJQ(newEndDate);
+
+
+            return false;
+
+        }
+        return true;
+
+
+    }
+
+    /**
+     * 报价  商业险 重复 投保业务处理
+     */
+    public boolean biRepetitionInsure(RuoteResponse rr, Ruote m) {
+
+        if (rr.getHead().getErrorCode().equals("000000") && null != rr.getTfiWarnList() && CollUtil.isNotEmpty(rr.getTfiWarnList().getTfiWarnData())) {
+
+
+//            List<TfiWarnListResponse.TfiWarnData> tfiWarnData = rr.getTfiWarnList().getTfiWarnData().stream().filter(item -> null != item).filter(item -> StringUtils.isNotEmpty(item.getWarnMessage())).collect(Collectors.toList());
+            TfiWarnListResponse.TfiWarnData tfiWarnData = rr.getTfiWarnList().getTfiWarnData().stream().filter(item -> null != item).filter(item -> StringUtils.isNotEmpty(item.getWarnMessage())).filter(item -> item.getWarnMessage().contains("终保日期")).findFirst().orElse(null);
+
+
+
 //
-//            }
-//        }
+            //截取0 到 机动车交通事故强制险
+            String ciMsg = tfiWarnData.getWarnMessage();
+            requestInfoList.add(ciMsg);
+
+
+            //终保日期
+            String coverageEndDate = ciMsg.substring(ciMsg.indexOf("终保日期") + 5, ciMsg.indexOf("终保日期") + 5 + 12);
+
+            LocalDateTime start = DateTimeUtil.parseLocalDateTime(coverageEndDate, DateTimeUtil.UNSIGNED_DATETIME_PATTERN_EXT1);
+            LocalDateTime end = start.plusYears(1L).minusDays(1L);
+
+
+            String newStartDate = DateTimeUtil.getStartTimeOfDayStr(start, DateTimeUtil.DATETIME_PATTERN);
+            String newEndDate = DateTimeUtil.getEndTimeOfDayStr(end, DateTimeUtil.DATETIME_PATTERN);
+            System.err.println("商业新起:" + newStartDate);
+            System.err.println("商业新止:" + newEndDate);
+
+            m.getRequestLabel().getCondition().getBase().setTInsrncBgnTmSY(newStartDate);
+            m.getRequestLabel().getCondition().getBase().setTInsrncEndTmSY(newEndDate);
+
+            //转保信息清空  重新报价
+            rr.getVhl().setCQryCdeJQ("");
+            rr.getVhl().setCQryCdeSY("");
+            m.getRequestLabel().getCondition().getVhl().setCCheckCodeJQ("");
+            m.getRequestLabel().getCondition().getVhl().setCCheckCodeSY("");
+
+
+            return false;
+
+        }
         return true;
 
 
@@ -522,6 +585,7 @@ public class InsAlltrustApiServiceImpl implements InsAlltrustApiService {
 
             //转保调用自动识别转保码
             if (StringUtils.isNotEmpty(cCheckCodeJQ) || StringUtils.isNotEmpty(cCheckCodeSY)) {
+                requestInfoList.add(rr.getHead().getErrorMessage());
                 //调用python ocr
                 String sendBody = "";
                 Map bodyMap = new HashMap();

+ 9 - 0
src/main/java/com/ydtech/utils/DateTimeUtil.java

@@ -25,6 +25,11 @@ public class DateTimeUtil {
      */
     public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
 
+    /**
+     * 显示年月日时分,例如 2015-08-11 09:51.
+     */
+    public static final String DATETIME_PATTERN_EXT1 = "yyyy-MM-dd HH:mm";
+
     /**
      * 仅显示年月日,例如 2015-08-11.
      */
@@ -39,6 +44,10 @@ public class DateTimeUtil {
      * 显示年月日时分秒(无符号),例如 20150811095153.
      */
     public static final String UNSIGNED_DATETIME_PATTERN = "yyyyMMddHHmmss";
+    /**
+     * 显示年月日时分秒(无符号) 扩展1,例如 201508110951.
+     */
+    public static final String UNSIGNED_DATETIME_PATTERN_EXT1 = "yyyyMMddHHmm";
 
     /**
      * 仅显示年月日(无符号),例如 20150811.

+ 36 - 6
src/main/java/com/ydtech/utils/HttpUtil.java

@@ -102,9 +102,8 @@ public class HttpUtil {
      * @author: lig
      * @date: 2023年08月14日 0014
      */
-    public static String sendPost(String url,String bodyStr,Logger log){
-        System.err.println("请求[post、json、body]参数:"+bodyStr);
-        log.info("请求[post、json、body]参数:"+bodyStr);
+    public static String sendPost(String url,String bodyStr,Logger log,String apiName){
+        log.info(apiName+"请求[post、json、body]参数:"+bodyStr);
         HttpRequest request = HttpRequest.post(url)
                 .header("Content-Type", "application/json")//以json的方式传递
 //     .header("authorization","Bearer abcdefghijklmnopqrstuvwxyz")
@@ -112,13 +111,43 @@ public class HttpUtil {
 
         HttpResponse response = request.execute();
         String respStr = response.body();
-        System.err.println("返回[post、json、body]参数:"+ respStr);
-        log.info("返回[post、json、body]参数:"+bodyStr);
+        log.info(apiName+"返回[post、json、body]参数:"+respStr);
 
         return respStr;
     }
 
 
+    /**
+     *   post  from
+     * @param url
+     * @param formMap   附件需要传的类型FilePart
+     *
+     * @author: lig
+     * @date: 2023-08-21
+     */
+    public static String sendPostFrom(String url,Map<String, Object> formMap,Logger log,String apiName){
+        System.err.println("请求[post、json、body]参数:"+ JSONUtil.toJsonStr(formMap));
+        log.info(apiName + ",请求[post、json、body]参数:"+ JSONUtil.toJsonStr(formMap));
+        HttpRequest request = HttpRequest.post(url);
+                request.header("Content-Type", "multipart/form-data; ");
+
+//        // 添加文件参数
+//        FilePart file1 = new FilePart("file1", new File("path/to/file1.jpg"));
+        request.form(formMap);
+
+
+        HttpResponse response = request.execute();
+        // 处理服务器响应
+        if (response.isOk()) {
+            String respStr = response.body();
+            log.info(apiName + "返回[post、json、body]参数:"+ respStr);
+            return respStr;
+        }
+        return null;
+
+
+
+    }
     /**
      *   post  from
      * @param url
@@ -129,6 +158,7 @@ public class HttpUtil {
      */
     public static String sendPostFrom(String url,Map<String, Object> formMap){
         System.err.println("请求[post、json、body]参数:"+ JSONUtil.toJsonStr(formMap));
+//        log.info(apiName + ",请求[post、json、body]参数:"+ JSONUtil.toJsonStr(formMap));
         HttpRequest request = HttpRequest.post(url);
                 request.header("Content-Type", "multipart/form-data; ");
 
@@ -141,7 +171,7 @@ public class HttpUtil {
         // 处理服务器响应
         if (response.isOk()) {
             String respStr = response.body();
-            System.err.println("返回[post、json、body]参数:"+ respStr);
+//            log.info(apiName + "返回[post、json、body]参数:"+ respStr);
             return respStr;
         }
         return null;

+ 4 - 1
src/main/java/com/ydtech/utils/IDCardUtils.java

@@ -345,6 +345,9 @@ public class IDCardUtils {
         if(address.indexOf("重庆市") == 0){
             regex = "(?<province>[^市].*?市)(?<city>[^县]+县|.*?区|.+市|.*?旗|.+海域|.+岛)(?<district>[^县]+县|.*?区|.+市|.*?旗|.+海域|.+岛)?(?<town>[^区]+区|.+镇)?(?<detail>.*)";
         }
+        if(address.indexOf("新疆") == 0){
+            regex = "(?<province>.*?新疆)(?<city>[^县]+县|.*?区|.+市|.*?旗|.+海域|.+岛)(?<district>[^县]+县|.*?区|.+市|.*?旗|.+海域|.+岛)?(?<town>[^区]+区|.+镇)?(?<detail>.*)";
+        }
 
         Matcher m = Pattern.compile(regex).matcher(address);
         String province = null, city = null, district = null, town = null, detail = null;
@@ -373,7 +376,7 @@ public class IDCardUtils {
 
 //        Map m = addressResolution("内蒙古锡林郭勒盟太仆寺旗红旗镇建中村张油坊营子3组48号");
 //        Map m = addressResolution("重庆市永川区朱沱镇大江住址路48号附59号");
-        Map m = addressResolution("重庆市永川区朱沱镇大江住址路48号附59号");
+        Map m = addressResolution("新疆墨玉县喀拉喀什镇喀亚什村46号");
 
         // String IDCardNum="210102820826411";
         // String IDCardNum="210102198208264114";

+ 40 - 0
src/main/java/com/ydtech/utils/RedisUtils.java

@@ -1,5 +1,6 @@
 package com.ydtech.utils;
 
+import com.alibaba.fastjson.JSON;
 import com.ydtech.components.MyJedisPoolConfig;
 import redis.clients.jedis.*;
 
@@ -197,6 +198,27 @@ public class RedisUtils {
         }
         return value;
     }
+    /**
+     * 获取某个key的value   对象
+     *
+     * @param key
+     * @return
+     */
+    public static Object getObject(String key) {
+        Jedis jedis = null;
+        String value = null;
+        try {
+            jedis = getJedis();
+            value = jedis.get(key);
+        } finally {
+            if (jedis != null) {
+                jedis.close();
+            }
+        }
+
+        Object obj = JSON.parse(value);
+        return obj;
+    }
 
     /**
      * 设置某个key的value
@@ -215,6 +237,24 @@ public class RedisUtils {
             }
         }
     }
+    /**
+     * 设置某个key的value
+     *
+     * @param key
+     * @param value
+     */
+    public static void setObject(String key, Object obj) {
+        String value = JSON.toJSONString(obj);
+        Jedis jedis = null;
+        try {
+            jedis = getJedis();
+            jedis.set(key, value);
+        } finally {
+            if (jedis != null) {
+                jedis.close();
+            }
+        }
+    }
 
     /**
      * 设置某个key的value   包含过期时间