Browse Source

完成自动侦测新保单并添加到厂商库功能

Jxing 6 years ago
parent
commit
9a160da559

+ 21 - 0
src/main/java/com/sagacloud/pojos/Warranty.java

@@ -10,6 +10,27 @@ public class Warranty {
     private String contractFile;
     private Integer propertyCount = null;
 
+
+    // 二期使用字段
+    private String venderId;
+    private String projectId;
+
+    public String getVenderId() {
+        return venderId;
+    }
+
+    public void setVenderId(String venderId) {
+        this.venderId = venderId;
+    }
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
     public int getPropertyCount() {
         return propertyCount;
     }

+ 2 - 1
src/main/java/com/sagacloud/route/Route.java

@@ -168,7 +168,8 @@ public class Route extends ExceptionHandlerBaseRoute {
         // 需要输入  body是Pj1101080001, getProperty("propertyData") 是 DPSelectPropertyResult类型,
         // getProperty("map") 是 Map<String, Map<String, String>>类型  说明: 信息点Name --> (厂商库该信息点的值  --> 所属厂商)
         from("direct:getPropertyStatisticsByProject").process(new StatisticsProcessor())
-                .to(String.join("", InitEnvRoute.venders, "/auxiliary/property/create_by_project"));
+                .to(String.join("", InitEnvRoute.venders, "/auxiliary/property/create_by_project"))
+                .process(new AddNewWarranty());
 
         //body为JSONObject,含有projectId字段
         from("direct:getPropertiesByPj")

+ 33 - 0
src/main/java/com/sagacloud/route/processors/Insurance/AddNewWarranty.java

@@ -0,0 +1,33 @@
+package com.sagacloud.route.processors.Insurance;
+/*
+ * Author: Jxing
+ * Create Time: 2018/11/15
+ */
+
+import com.alibaba.fastjson.JSONObject;
+import com.sagacloud.pojos.InsurancePost;
+import com.sagacloud.pojos.Warranty;
+import com.sagacloud.utils.Const;
+import com.sagacloud.utils.HttpRequests;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class AddNewWarranty implements Processor {
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        Map<String, Warranty> newWarranty = (Map<String, Warranty>) exchange.getProperty("newWarranty");
+        for(String insuranceNum : newWarranty.keySet()){
+            JSONObject object = new JSONObject();
+            Warranty warranty = newWarranty.get(insuranceNum);
+            object.put("venderId", warranty.getVenderId());
+            object.put("insuranceNo", insuranceNum);
+            if(warranty.getContractFile() != null)
+                object.put("contractFile", warranty.getContractFile());
+            object.put("projectId", warranty.getProjectId());
+            HttpRequests.sendPost(Const.venders + "/insurance/contract/create", object.toString());
+        }
+    }
+}

+ 1 - 1
src/main/java/com/sagacloud/route/processors/PeriodTask/OnTimeTaskProcessor.java

@@ -11,7 +11,7 @@ import java.util.ArrayList;
 import java.util.Date;
 
 public class OnTimeTaskProcessor implements Processor {
-    public static int[] time = new int[]{4, 00};
+    public static int[] time = new int[]{16, 35};
     private static ArrayList<Long> nextTimeStamps = new ArrayList<>();
     private final int ONEDAY = 86400000;
     private final int ONEMINUTE = 60000;

+ 23 - 5
src/main/java/com/sagacloud/route/processors/PeriodTask/StatisticsProcessor.java

@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.sagacloud.pojos.DPSelectPropertyResult;
 import com.sagacloud.pojos.ProjectStatistics;
 import com.sagacloud.pojos.VenderStatistics;
+import com.sagacloud.pojos.Warranty;
 import com.sagacloud.route.InitEnvRoute;
 import com.sagacloud.route.processors.Insurance.GetPropertyUnderWarrantyProcessor;
 import com.sagacloud.utils.Const;
@@ -34,11 +35,13 @@ public class StatisticsProcessor implements Processor {
         Map<String, VenderStatistics> venderStatisticsMap = new HashMap<>();
         Map<String, Set<String>> contracts = new HashMap<>(); // 供应商统计供应合同数目使用
         Map<String, Set<String>> warranties = new HashMap<>(); // 保险商统计供应合同数目使用
+        Map<String, Warranty> newWarranty = new HashMap<>(); // 记录数据平台新增保单, 增加到厂商库
+        exchange.setProperty("newWarranty", newWarranty);
         for(int i = 0; i < propertyList.size(); ++i){
             Map<String, Object> singleProperty = propertyList.get(i);
             matchCountManufacturer(singleProperty, infoValueMap, manufacturerSign, venderStatisticsMap);
             matchCountSupplier(singleProperty, infoValueMap, supplierSign, venderStatisticsMap, contracts);
-            matchCountInsurer(singleProperty, infoValueMap, insuranceSign, venderStatisticsMap, warranties);
+            matchCountInsurer(singleProperty, infoValueMap, insuranceSign, venderStatisticsMap, warranties, newWarranty, projectId);
             //
         }
         for(int i = 0; i < facilityList.size(); ++i){
@@ -104,21 +107,23 @@ public class StatisticsProcessor implements Processor {
     }
 
     // InsuranceNum 在infoValueMap里面保存的已经是所有的在保保单号, 因此匹配到资产之后必须验证资产保单号是否属于在保保单
-    private void matchCountInsurer(Map<String, Object> singleProperty, Map<String, Map<String, String>> infoValueMap, Set<String> insuranceSign, Map<String, VenderStatistics> venderStatisticsMap, Map<String, Set<String>> warranties) {
+    private void matchCountInsurer(Map<String, Object> singleProperty, Map<String, Map<String, String>> infoValueMap, Set<String> insuranceSign, Map<String, VenderStatistics> venderStatisticsMap, Map<String, Set<String>> warranties, Map<String, Warranty> newWarranty, String projectId) {
         try {
             Map<String, Object> propertyInfos = (Map<String, Object>) singleProperty.get("infos");
             for(String idInfoCode : insuranceSign){
                 Map<String, String> valueMap = infoValueMap.get(idInfoCode);
                 if(propertyInfos.get(idInfoCode) == null || valueMap == null)
                     continue;
-                String infoValue = propertyInfos.get(idInfoCode).toString();   //当前信息点的值
+                String infoValue = propertyInfos.get(idInfoCode).toString();   //资产当前信息点的值
                 if(valueMap.containsKey(infoValue)){
-                    // 匹配由此保险商保的资产
+                    String venderId = valueMap.get(infoValue);
+                    // 匹配到由此保险商保的资产
                     if(propertyInfos.get(Const.INFO_INSURANCENUM) != null) {
                         String insuranceNum = propertyInfos.get(Const.INFO_INSURANCENUM).toString();
                         Map<String, String> insuranceNumMap = infoValueMap.get(Const.INFO_INSURANCENUM);
+                        // 匹配 保单号(统计被保资产个数)
                         if (insuranceNumMap.containsKey(insuranceNum)) {
-                            String venderId = insuranceNumMap.get(insuranceNum);
+                            venderId = insuranceNumMap.get(insuranceNum);
                             Set<String> insuranceSet = null;
                             if (warranties.get(venderId) == null) {
                                 insuranceSet = new HashSet<>();
@@ -128,6 +133,19 @@ public class StatisticsProcessor implements Processor {
                             if (!insuranceSet.contains(insuranceNum))
                                 insuranceSet.add(insuranceNum);
                             updateCount(venderStatisticsMap, venderId, 1, 0, 0);
+                        }else{
+                            Map<String, String> allInsuranceNum =  infoValueMap.get("AllInsuranceNum");
+                            if(!allInsuranceNum.containsKey(insuranceNum)){
+                                Warranty warranty = new Warranty();
+                                warranty.setProjectId(projectId);
+                                warranty.setInsuranceNo(insuranceNum);
+                                warranty.setVenderId(venderId);
+                                if(propertyInfos.get("InsuranceFile") != null)
+                                    warranty.setContractFile(propertyInfos.get("InsuranceFile").toString());
+                                if(!newWarranty.containsKey(insuranceNum)){
+                                    newWarranty.put(insuranceNum, warranty);
+                                }
+                            }
                         }
                         return;
                     }

+ 11 - 9
src/main/java/com/sagacloud/route/processors/VenderMapProcessor.java

@@ -20,7 +20,7 @@ public class VenderMapProcessor implements Processor {
         //第二层map的key为厂商名称、产品名称等,指向厂商id
         //2.第一层为DPManufacturerID、DPSpecificationID、DPSupplierID、DPInsurerID、DPMaintainerID时
         //第二层为厂商id指向厂商id 或 型号id指向厂商id
-        Map<String, Map> nameMap = new HashMap<>();
+        Map<String, Map<String, String>> nameMap = new HashMap<>();
         String jsonStr = exchange.getIn().getBody(String.class);
         System.out.println(jsonStr);
         JSONObject json = JSONObject.parseObject(jsonStr);
@@ -34,7 +34,7 @@ public class VenderMapProcessor implements Processor {
         exchange.getIn().setBody(exchange.getProperty("projectList"));
     }
 
-    public void buildNameMap(AllVender venders, Map<String, Map> nameMap) {
+    public void buildNameMap(AllVender venders, Map<String, Map<String, String>> nameMap) {
         initMap(nameMap);
         List<Manu> manuList = venders.getManuList();
         List<Supp> suppList = venders.getSuppList();
@@ -46,15 +46,15 @@ public class VenderMapProcessor implements Processor {
         handleMtn(nameMap,maintnList);
     }
 
-    public void initMap(Map<String, Map> nameMap) {
-        String[] keyList = new String[]{"Manufacturer", "Brand", "Specification", "Supplier", "Insurer", "InsuranceNum", "Maintainer",
-                "DPManufacturerID", "DPSpecificationID", "DPSupplierID", "DPInsurerID", "DPMaintainerID"};
+    public void initMap(Map<String, Map<String, String>> nameMap) {
+        String[] keyList = new String[]{"Manufacturer", "Brand", "Specification", "Supplier", "Insurer", "InsuranceNum"
+                , "AllInsuranceNum", "Maintainer", "DPManufacturerID", "DPSpecificationID", "DPSupplierID", "DPInsurerID", "DPMaintainerID"};
         for (String key : keyList) {
             nameMap.put(key, new HashMap<String, String>());
         }
     }
 
-    public void handleMtn(Map<String, Map> nameMap, List<Maintn> maintnList){
+    public void handleMtn(Map<String, Map<String, String>> nameMap, List<Maintn> maintnList){
         Set<String> visitedMaintainer = new HashSet<>();
         Set<String> conflictMaintainer = new HashSet<>();
         Map<String, String> maintainer = nameMap.get("Maintainer");
@@ -65,13 +65,14 @@ public class VenderMapProcessor implements Processor {
         }
     }
 
-    public void handleInsurer(Map<String, Map> nameMap, List<Insure> insureList){
+    public void handleInsurer(Map<String, Map<String, String>> nameMap, List<Insure> insureList){
         Date now = new Date();
         Set<String> visitedInsurer = new HashSet<>();
         Set<String> conflictInsurer = new HashSet<>();
         Map<String, String> insurer = nameMap.get("Insurer");
         Map<String, String> dpInsurerID = nameMap.get("DPInsurerID");
         Map<String, String> insuranceNum = nameMap.get("InsuranceNum");
+        Map<String, String> allInsuranceNum = nameMap.get("AllInsuranceNum");
         for(Insure i : insureList ){
             fillMap(insurer,i.getName(),i.getVenderId(),visitedInsurer,conflictInsurer);
             dpInsurerID.put(i.getVenderId(),i.getVenderId());
@@ -79,11 +80,12 @@ public class VenderMapProcessor implements Processor {
                 if(c.underWarranty(now)){
                     insuranceNum.put(c.getInsuranceNo(),i.getVenderId());
                 }
+                allInsuranceNum.put(c.getInsuranceNo(),i.getVenderId());
             }
         }
     }
 
-    public void handleSupplier(Map<String, Map> nameMap, List<Supp> suppList){
+    public void handleSupplier(Map<String, Map<String, String>> nameMap, List<Supp> suppList){
         Set<String> visitedSupplier = new HashSet<>();
         Set<String> conflictSupplier = new HashSet<>();
         Map<String, String> supplier = nameMap.get("Supplier");
@@ -94,7 +96,7 @@ public class VenderMapProcessor implements Processor {
         }
     }
 
-    public void handleMaunfacturer(Map<String, Map> nameMap, List<Manu> manuList) {
+    public void handleMaunfacturer(Map<String, Map<String, String>> nameMap, List<Manu> manuList) {
         Set<String> visitedManufacturer = new HashSet<>();
         Set<String> conflictManufacturer = new HashSet<>();
         Set<String> visitedBrand = new HashSet<>();