|
@@ -19,6 +19,8 @@ import com.sagacloud.route.processors.supplier.SupplierFilter;
|
|
|
import com.sagacloud.utils.Const;
|
|
|
import org.apache.camel.Exchange;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
import java.io.StringWriter;
|
|
@@ -29,11 +31,13 @@ import java.util.List;
|
|
|
* Created by Xiaoyu on 2018/7/10
|
|
|
*/
|
|
|
public class Route extends ExceptionHandlerBaseRoute {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(Route.class);
|
|
|
@Override
|
|
|
public void configure() throws Exception {
|
|
|
configExceptionHandler();
|
|
|
|
|
|
fromF("timer://simpleTimer?period=1m").process(new OnTimeTaskProcessor()).to("direct:syncAllProject");
|
|
|
+ fromF("timer://simpleTimer?period=30m").to("direct:synProjectName");
|
|
|
|
|
|
rest().get("/doc")
|
|
|
.produces("text/html;charset=UTF-8")
|
|
@@ -178,6 +182,32 @@ public class Route extends ExceptionHandlerBaseRoute {
|
|
|
exchange.getIn().setBody(exchange.getProperty("projectId" + exchange.getExchangeId()));
|
|
|
})
|
|
|
.to("direct:getPropertyStatisticsByProject");
|
|
|
+
|
|
|
+
|
|
|
+ rest("/project/").post("sync_name")
|
|
|
+ .consumes(MediaType.APPLICATION_JSON)
|
|
|
+ .produces(MediaType.APPLICATION_JSON)
|
|
|
+ .route()
|
|
|
+ .to("direct:synProjectName");
|
|
|
+
|
|
|
+ from("direct:synProjectName")
|
|
|
+ .process(exchange -> {
|
|
|
+ log.info("开始同步项目名");
|
|
|
+ JSONArray criterias = new JSONArray();
|
|
|
+ for (String pjId : ProPasCache.nameMap.keySet()) {
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("projectId",pjId);
|
|
|
+ obj.put("projectLocalName",ProPasCache.nameMap.get(pjId));
|
|
|
+ criterias.add(obj);
|
|
|
+ }
|
|
|
+ JSONObject inserJson = new JSONObject();
|
|
|
+ inserJson.put("criterias",criterias);
|
|
|
+ log.info("数据:"+inserJson.toString());
|
|
|
+ exchange.getIn().setBody(inserJson.toString());
|
|
|
+ exchange.getIn().setHeader(Exchange.HTTP_URI, InitEnvRoute.venders+"/auxiliary/project/create?method=POST");
|
|
|
+ log.info(InitEnvRoute.venders+"/auxiliary/project/create?method=POST");
|
|
|
+ })
|
|
|
+ .to(InitEnvRoute.venders+"/auxiliary/project/create");
|
|
|
}
|
|
|
|
|
|
|