Parcourir la source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/sagacloud/route/Route.java
FanXiaoyu il y a 6 ans
Parent
commit
3a18ba8eee

+ 9 - 1
pom.xml

@@ -165,11 +165,19 @@
             <!--<artifactId>jackson-databind</artifactId>-->
             <!--<version>2.9.5</version>-->
         <!--</dependency>-->
-
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.1</version>
+        </dependency>
     </dependencies>
     <properties>
         <jersey.version>2.25.1</jersey.version>
+        <!-- 文件拷贝时的编码 -->
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <!-- 编译时的编码 -->
+        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
     </properties>
     <profiles>
         <profile>

+ 28 - 0
src/main/java/com/sagacloud/pojos/ProjectStatistics.java

@@ -0,0 +1,28 @@
+package com.sagacloud.pojos;
+/*
+ * Author: Jxing
+ * Create Time: 2018/7/13
+ */
+
+import java.util.List;
+
+public class ProjectStatistics {
+    private String projectId;
+    private List<VenderStatistics> criterias;
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public List<VenderStatistics> getCriterias() {
+        return criterias;
+    }
+
+    public void setCriterias(List<VenderStatistics> criterias) {
+        this.criterias = criterias;
+    }
+}

+ 44 - 0
src/main/java/com/sagacloud/pojos/VenderStatistics.java

@@ -0,0 +1,44 @@
+package com.sagacloud.pojos;
+/*
+ * Author: Jxing
+ * Create Time: 2018/7/13
+ */
+
+public class VenderStatistics {
+    private String venderId;
+    private int contractCount;
+    private int totalCount;
+    private int nearlyExpireCount;
+
+    public String getVenderId() {
+        return venderId;
+    }
+
+    public void setVenderId(String venderId) {
+        this.venderId = venderId;
+    }
+
+    public int getContractCount() {
+        return contractCount;
+    }
+
+    public void setContractCount(int contractCount) {
+        this.contractCount = contractCount;
+    }
+
+    public int getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(int totalCount) {
+        this.totalCount = totalCount;
+    }
+
+    public int getNearlyExpireCount() {
+        return nearlyExpireCount;
+    }
+
+    public void setNearlyExpireCount(int nearlyExpireCount) {
+        this.nearlyExpireCount = nearlyExpireCount;
+    }
+}

+ 6 - 1
src/main/java/com/sagacloud/route/InitEnvRoute.java

@@ -4,6 +4,10 @@ import com.sagacloud.cache.ProPasCache;
 import com.sagacloud.utils.PropUtil;
 import org.apache.camel.builder.RouteBuilder;
 
+import javax.ws.rs.core.MediaType;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Created by wo on 5/24/17.
  */
@@ -28,6 +32,7 @@ public class InitEnvRoute extends RouteBuilder {
         rest("/syn")
                 .get()
                 .to("direct:syn");
-        // in 的body {"projectId":["Pj1101080001", "Pj1101080002"]}
+
     }
+
 }

+ 24 - 3
src/main/java/com/sagacloud/route/Route.java

@@ -8,6 +8,7 @@ import com.sagacloud.route.processors.Maintainance.FilterPropertyProcessor;
 import com.sagacloud.route.processors.Maintainance.QueryPropertyProcesspr;
 import com.sagacloud.route.processors.Manufacturer.MaunfacturerFilter;
 import com.sagacloud.route.processors.Manufacturer.GetVenderBySpecProcessor;
+import com.sagacloud.route.processors.PeriodTask.StatisticsProcessor;
 import com.sagacloud.route.processors.VenderMapProcessor;
 import com.sagacloud.route.processors.supplier.SupplierFilter;
 import com.sagacloud.utils.Const;
@@ -15,6 +16,8 @@ import org.apache.commons.io.IOUtils;
 
 import javax.ws.rs.core.MediaType;
 import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Created by Xiaoyu on 2018/7/10
@@ -104,6 +107,27 @@ public class Route extends ExceptionHandlerBaseRoute {
                 .to("direct:getPropertiesByPj")
                 .process(new FilterPropertyProcessor());
 
+
+        rest("/test/").get().produces(MediaType.APPLICATION_JSON).route()
+                .process(msg -> {
+                    List<String> lst = new ArrayList<>();
+                    for(int i = 0; i < 1000; i++){
+                        lst.add("hh" + i);
+                    }
+                    msg.getOut().setBody(lst);
+                }).split(body(), (oldmsg, newmsg) -> {
+            if(oldmsg == null){
+                return newmsg;
+            }
+            oldmsg.getIn().setBody(oldmsg.getIn().getBody(String.class) + newmsg.getIn().getBody(String.class));
+            return oldmsg;
+        }).parallelProcessing().parallelAggregate().to("direct://test");
+
+        // 需要输入  body是Pj1101080001, getProperty("propertyData") 是 DPSelectPropertyResult类型,
+        // getProperty("idMap") 是 Map<String, String>类型,  说明: 所有DPID  --> venderId
+        // getProperty("nameMap") 是 Map<String, Map<String, String>>类型  说明: 信息点Name --> (厂商库该信息点的值  --> 所属厂商)
+        from("direct:getProperty").process(new StatisticsProcessor());
+
         //body为JSONObject,含有projectId字段
         from("direct:getPropertiesByPj")
                 .process(new GetPropByPjProcessor())
@@ -117,9 +141,6 @@ public class Route extends ExceptionHandlerBaseRoute {
                 .route()
                 .to("direct:getPropertiesByPj");
 
-        from("direct:buildVenderMap")
-                .to(Const.venders+"/auxiliary/vender/query_detail")
-                .process(new VenderMapProcessor());
     }
 
 

+ 41 - 0
src/main/java/com/sagacloud/route/processors/PeriodTask/StatisticsProcessor.java

@@ -0,0 +1,41 @@
+package com.sagacloud.route.processors.PeriodTask;
+/*
+ * Author: Jxing
+ * Create Time: 2018/7/13
+ */
+
+import com.sagacloud.pojos.DPSelectPropertyResult;
+import com.sagacloud.pojos.VenderStatistics;
+import com.sagacloud.utils.VendersUtil;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class StatisticsProcessor implements Processor {
+    public static final Set<String> manufacturerNameSign = VendersUtil.createSet("Manufacturer", "Brand", "Specification");
+    public static final Set<String> manufacturerIdSign = VendersUtil.createSet("DPManufacturerID", "DPSpecificationID");
+    public static final Set<String> supplierNameSign = VendersUtil.createSet("Supplier");
+    public static final Set<String> supplierIdSign = VendersUtil.createSet("DPSupplierID");
+    public static final Set<String> insuranceNameSign = VendersUtil.createSet("Insurer", "InsuranceNum");
+    public static final Set<String> insuranceIdSign = VendersUtil.createSet("DPInsurerID");
+    public static final Set<String> maintainanceNameSign = VendersUtil.createSet("Maintainer");
+    public static final Set<String> maintainanceIdSign = VendersUtil.createSet("DPMaintainerID");
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String projectId = exchange.getIn().getBody(String.class);
+        DPSelectPropertyResult propertyData = (DPSelectPropertyResult) exchange.getProperty("propertyData");
+        Map<String, String> idMap = (Map<String, String>) exchange.getProperty("idMap");
+        Map<String, Map<String, String>> nameMap = (Map<String, Map<String, String>>) exchange.getProperty("nameMap");
+        List<Map<String, Object>> propertyList = propertyData.getContent();
+
+        for(int i = 0; i < propertyList.size(); ++i){
+            Map<String, Object> singleProperty = propertyList.get(i);
+            //Map<String, VenderStatistics>
+            //compareCount(idMap, nameMap, manufacturerIdSign, manufacturerNameSign);
+        }
+
+    }
+}