|
@@ -3,6 +3,8 @@ package com.sagacloud.route;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.rjeschke.txtmark.Processor;
|
|
|
+import com.sagacloud.Exceptions.InvalidPostException;
|
|
|
+import com.sagacloud.cache.ProPasCache;
|
|
|
import com.sagacloud.pojos.DPSelectPropertyResult;
|
|
|
import com.sagacloud.route.processors.Insurance.*;
|
|
|
import com.sagacloud.route.processors.GetPropByPjProcessor;
|
|
@@ -47,12 +49,12 @@ public class Route extends ExceptionHandlerBaseRoute {
|
|
|
.process(exchange -> {
|
|
|
String jsonStr = exchange.getIn().getBody(String.class);
|
|
|
JSONObject json = JSONObject.parseObject(jsonStr);
|
|
|
- exchange.setProperty("venderId",json.getString("venderId"));
|
|
|
+ exchange.setProperty("venderId", json.getString("venderId"));
|
|
|
exchange.getIn().setBody(jsonStr);
|
|
|
})
|
|
|
.to("direct:getPropertiesByPj")
|
|
|
.process(new GetVenderBySpecProcessor())
|
|
|
- .to(Const.venders+"/manufacturer/specification/query_vender")
|
|
|
+ .to(Const.venders + "/manufacturer/specification/query_vender")
|
|
|
.process(new MaunfacturerFilter());
|
|
|
|
|
|
// 供应商查询项目下的资产
|
|
@@ -63,12 +65,12 @@ public class Route extends ExceptionHandlerBaseRoute {
|
|
|
.process(exchange -> {
|
|
|
String jsonStr = exchange.getIn().getBody(String.class);
|
|
|
JSONObject json = JSONObject.parseObject(jsonStr);
|
|
|
- exchange.setProperty("venderId",json.getString("venderId"));
|
|
|
+ exchange.setProperty("venderId", json.getString("venderId"));
|
|
|
exchange.getIn().setBody(jsonStr);
|
|
|
})
|
|
|
.to("direct:getPropertiesByPj")
|
|
|
.process(new GetVenderBySpecProcessor())
|
|
|
- .to(Const.venders+"/manufacturer/specification/query_vender")
|
|
|
+ .to(Const.venders + "/manufacturer/specification/query_vender")
|
|
|
.process(new SupplierFilter());
|
|
|
|
|
|
|
|
@@ -114,32 +116,19 @@ public class Route extends ExceptionHandlerBaseRoute {
|
|
|
rest("/test/").get().produces(MediaType.APPLICATION_JSON).route()
|
|
|
.process(msg -> {
|
|
|
List<String> lst = new ArrayList<>();
|
|
|
- for(int i = 0; i < 1000; i++){
|
|
|
+ for (int i = 0; i < 1000; i++) {
|
|
|
lst.add("hh" + i);
|
|
|
}
|
|
|
msg.getOut().setBody(lst);
|
|
|
}).split(body(), (oldmsg, newmsg) -> {
|
|
|
- if(oldmsg == null){
|
|
|
+ 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:getPropertyStatisticsByProject").process(new StatisticsProcessor())
|
|
|
- .to(String.join("", InitEnvRoute.venders, "/auxiliary/property/create_by_project"));
|
|
|
-
|
|
|
- //body为JSONObject,含有projectId字段
|
|
|
- from("direct:getPropertiesByPj")
|
|
|
- .process(new GetPropByPjProcessor())
|
|
|
- .to(Const.dataPlatform+"/property/relation_query");
|
|
|
-// .process(exchange -> {
|
|
|
-// System.out.println(exchange.getIn().getBody(String.class));
|
|
|
-// });
|
|
|
- rest("/test").post()
|
|
|
+ rest("/project/sync").post()
|
|
|
.consumes(MediaType.APPLICATION_JSON)
|
|
|
.produces(MediaType.APPLICATION_JSON)
|
|
|
.route()
|
|
@@ -148,30 +137,48 @@ public class Route extends ExceptionHandlerBaseRoute {
|
|
|
JSONObject json = JSONObject.parseObject(jsonStr);
|
|
|
JSONArray projectArr = json.getJSONArray("project");
|
|
|
List<String> projectList = projectArr.toJavaList(String.class);
|
|
|
- exchange.setProperty("projectList",projectList);
|
|
|
+ if (projectList == null || projectList.size() == 0) {
|
|
|
+ throw new InvalidPostException("project不能为空");
|
|
|
+ }
|
|
|
+ exchange.setProperty("projectList", projectList);
|
|
|
+ })
|
|
|
+ .to("direct:buildVenderMap");
|
|
|
+
|
|
|
+ //同步全部项目的资产信息
|
|
|
+ from("direct:syncAllProject")
|
|
|
+ .process(exchange -> {
|
|
|
+ exchange.setProperty("projectList", ProPasCache.pjList);
|
|
|
})
|
|
|
.to("direct:buildVenderMap");
|
|
|
|
|
|
+ // 需要输入 body是Pj1101080001, getProperty("propertyData") 是 DPSelectPropertyResult类型,
|
|
|
+ // getProperty("idMap") 是 Map<String, String>类型, 说明: 所有DPID --> venderId
|
|
|
+ // getProperty("nameMap") 是 Map<String, Map<String, String>>类型 说明: 信息点Name --> (厂商库该信息点的值 --> 所属厂商)
|
|
|
+ from("direct:getPropertyStatisticsByProject").process(new StatisticsProcessor())
|
|
|
+ .to(String.join("", InitEnvRoute.venders, "/auxiliary/property/create_by_project"));
|
|
|
+
|
|
|
+ //body为JSONObject,含有projectId字段
|
|
|
+ from("direct:getPropertiesByPj")
|
|
|
+ .process(new GetPropByPjProcessor())
|
|
|
+ .to(Const.dataPlatform + "/property/relation_query");
|
|
|
+
|
|
|
from("direct:buildVenderMap")
|
|
|
-// .process(exchange -> {
|
|
|
-// exchange.getIn().setHeader(Exchange.HTTP_URI, Const.venders+"/auxiliary/vender/query_detail?method=POST");
|
|
|
-// })
|
|
|
- .to(Const.venders+"/auxiliary/vender/query_detail?bridgeEndpoint=true&method=POST")
|
|
|
+ .to(Const.venders + "/auxiliary/vender/query_detail?bridgeEndpoint=true&method=POST")
|
|
|
.process(new VenderMapProcessor())
|
|
|
.split(body()).parallelProcessing()
|
|
|
.process(exchange -> {
|
|
|
String projectId = exchange.getIn().getBody(String.class);
|
|
|
JSONObject json = new JSONObject();
|
|
|
- json.put("projectId",projectId);
|
|
|
- exchange.setProperty("projectId"+exchange.getExchangeId(),projectId);
|
|
|
+ json.put("projectId", projectId);
|
|
|
+ exchange.setProperty("projectId" + exchange.getExchangeId(), 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"+exchange.getExchangeId(),dpResult);
|
|
|
- exchange.getIn().setBody(exchange.getProperty("projectId"+exchange.getExchangeId()));
|
|
|
+ exchange.setProperty("propertyData" + exchange.getExchangeId(), dpResult);
|
|
|
+ exchange.getIn().setBody(exchange.getProperty("projectId" + exchange.getExchangeId()));
|
|
|
})
|
|
|
.to("direct:getPropertyStatisticsByProject");
|
|
|
}
|