浏览代码

Merge branch 'master' of http://47.93.33.207:8886/r/venders-dp

FanXiaoyu 6 年之前
父节点
当前提交
5b0b4f5eb5

+ 11 - 5
src/main/java/com/sagacloud/route/Route.java

@@ -42,7 +42,9 @@ public class Route extends ExceptionHandlerBaseRoute {
     public void configure() throws Exception {
         configExceptionHandler();
 
-        fromF("timer://simpleTimer?period=1m").process(new OnTimeTaskProcessor()).to("direct:syncAllProject");
+        fromF("timer://simpleTimer?period=1m")
+                .process(new OnTimeTaskProcessor())
+                .to("direct:syncAllProject");
         fromF("timer://simpleTimer?period=30m").to("direct:synProjectName");
 
         rest().get("/doc")
@@ -155,6 +157,7 @@ public class Route extends ExceptionHandlerBaseRoute {
         //同步全部项目的资产信息
         from("direct:syncAllProject")
                 .process(exchange -> {
+                    System.out.println("someThing happened");
                     exchange.setProperty("projectList", ProPasCache.pjList);
                     log.warn("统计数据开始更新");
                 })
@@ -167,19 +170,21 @@ public class Route extends ExceptionHandlerBaseRoute {
 
         //body为JSONObject,含有projectId字段
         from("direct:getPropertiesByPj")
-                .process(new GetPropByPjProcessor())
-                .to(Const.dataPlatform + "/property/relation_query");
+                .process(new GetPropByPjProcessor()).setHeader(Exchange.HTTP_METHOD, constant("POST"))
+                .to(InitEnvRoute.dataPlatform + "/property/relation_query?bridgeEndpoint=true&method=POST");
         from("direct:getEquipmentByPj")
                 .process(new GetEquipmentByPjProcessor())
                 .to(Const.dataPlatform + "/object/subset_query");
 
         // 统计数据平台资产和设备信息(数量)
-        from("direct:buildVenderMap")
+        from("direct:buildVenderMap").setHeader(Exchange.HTTP_METHOD, constant("POST"))
                 .to(Const.venders + "/auxiliary/vender/query_detail?bridgeEndpoint=true&method=POST")
                 .process(new VenderMapProcessor())
-                .split(body()).parallelProcessing()
+                .split(body())
+                //.parallelProcessing()
                 .process(exchange -> {
                     String projectId = exchange.getIn().getBody(String.class);
+                    System.out.println("统计:" + projectId);
                     JSONObject json = new JSONObject();
                     json.put("projectId", projectId);
                     exchange.setProperty("projectId" + exchange.getExchangeId(), projectId);
@@ -188,6 +193,7 @@ public class Route extends ExceptionHandlerBaseRoute {
                 .to("direct:getPropertiesByPj")
                 .process(exchange -> {
                     String jsonStr = exchange.getIn().getBody(String.class);
+
                     DPSelectPropertyResult dpResult = JSONObject.parseObject(jsonStr, DPSelectPropertyResult.class);
                     exchange.setProperty("propertyData" + exchange.getExchangeId(), dpResult);
                     // 为下个路由准备输入数据

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

@@ -19,9 +19,9 @@ public class GetPropByPjProcessor implements Processor {
         String secret = ProPasCache.getPjSecret(projectId);
 
         exchange.getIn().setBody("{\"venderInfo\":true,\"criteria\":{\"family\":[]}}");
+        exchange.getIn().setHeader(Exchange.HTTP_CHARACTER_ENCODING, "UTF-8");
 //        exchange.getIn().setBody("{\"criteria\":{\"family\":[]}}");
         exchange.getIn().setHeader(Exchange.HTTP_URI, Const.dataPlatform+"/property/relation_query?method=POST");
         exchange.getIn().setHeader(Exchange.HTTP_QUERY,Const.HEADER_PROJECT + "=" + projectId + "&"+ Const.HEADER_SECRET+ "="+ secret);
-
     }
 }

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

@@ -34,6 +34,9 @@ public class OnTimeTaskProcessor implements Processor {
         }
         if(!isTime)
             exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
+        else {
+            exchange.removeProperties(Exchange.ROUTE_STOP);
+        }
     }
     private void init(){
         for(int i = 0; i < time.length; i+=2){

+ 1 - 0
src/main/java/com/sagacloud/route/processors/VenderMapProcessor.java

@@ -22,6 +22,7 @@ public class VenderMapProcessor implements Processor {
         //第二层为厂商id指向厂商id 或 型号id指向厂商id
         Map<String, Map> nameMap = new HashMap<>();
         String jsonStr = exchange.getIn().getBody(String.class);
+        System.out.println(jsonStr);
         JSONObject json = JSONObject.parseObject(jsonStr);
         if (json.getString("result").equals("failure")) {
             throw new InvalidPostException("请求厂商库出错");