Pārlūkot izejas kodu

同步接口完成,待测试

FanXiaoyu 6 gadi atpakaļ
vecāks
revīzija
e444b79150
1 mainītis faili ar 18 papildinājumiem un 8 dzēšanām
  1. 18 8
      src/main/java/com/sagacloud/route/Route.java

+ 18 - 8
src/main/java/com/sagacloud/route/Route.java

@@ -2,6 +2,7 @@ package com.sagacloud.route;
 
 import com.alibaba.fastjson.JSONObject;
 import com.github.rjeschke.txtmark.Processor;
+import com.sagacloud.pojos.DPSelectPropertyResult;
 import com.sagacloud.route.processors.Insurance.*;
 import com.sagacloud.route.processors.GetPropByPjProcessor;
 import com.sagacloud.route.processors.Maintainance.FilterPropertyProcessor;
@@ -127,7 +128,7 @@ public class Route extends ExceptionHandlerBaseRoute {
         // 需要输入  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())
+        from("direct:getPropertyStatisticsByProject").process(new StatisticsProcessor())
                 .to(String.join("", InitEnvRoute.venders, "/auxiliary/property/create_by_project"));
 
         //body为JSONObject,含有projectId字段
@@ -150,13 +151,22 @@ public class Route extends ExceptionHandlerBaseRoute {
                 })
                 .to(Const.venders+"/auxiliary/vender/query_detail")
                 .process(new VenderMapProcessor())
-                .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");
+                .split(body()).parallelProcessing()
+                .process(exchange -> {
+                    String projectId = exchange.getIn().getBody(String.class);
+                    JSONObject json = new JSONObject();
+                    json.put("projectId",projectId);
+                    exchange.setProperty("projectId",projectId);
+                    exchange.getIn().setBody(json.toString());
+                })
+                .to("direct:getPropertiesByPj")
+                .process(exchange -> {
+                    String jsonStr = exchange.getIn().getBody(String.class);
+                    DPSelectPropertyResult dpResult = JSONObject.parseObject(jsonStr, DPSelectPropertyResult.class);
+                    exchange.setProperty("propertyData",dpResult);
+                    exchange.getIn().setBody(exchange.getProperty("projectId"));
+                })
+                .to("direct:getPropertyStatisticsByProject");
     }