Selaa lähdekoodia

新增查询一个项目内的所有设备

Jxing 6 vuotta sitten
vanhempi
commit
829add8ec4

+ 4 - 0
src/main/java/com/sagacloud/route/Route.java

@@ -6,6 +6,7 @@ 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.GetEquipmentByPjProcessor;
 import com.sagacloud.route.processors.Insurance.*;
 import com.sagacloud.route.processors.GetPropByPjProcessor;
 import com.sagacloud.route.processors.Maintainance.FilterPropertyProcessor;
@@ -162,6 +163,9 @@ public class Route extends ExceptionHandlerBaseRoute {
         from("direct:getPropertiesByPj")
                 .process(new GetPropByPjProcessor())
                 .to(Const.dataPlatform + "/property/relation_query");
+        from("direct:getEquipmentByPj")
+                .process(new GetEquipmentByPjProcessor())
+                .to(Const.dataPlatform + "/property/relation_query");
 
         from("direct:buildVenderMap")
                 .to(Const.venders + "/auxiliary/vender/query_detail?bridgeEndpoint=true&method=POST")

+ 25 - 0
src/main/java/com/sagacloud/route/processors/GetEquipmentByPjProcessor.java

@@ -0,0 +1,25 @@
+package com.sagacloud.route.processors;
+/*
+ * Author: Jxing
+ * Create Time: 2018/7/19
+ */
+
+import com.alibaba.fastjson.JSONObject;
+import com.sagacloud.cache.ProPasCache;
+import com.sagacloud.utils.Const;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class GetEquipmentByPjProcessor implements Processor {
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String jsonStr = exchange.getIn().getBody(String.class);
+        JSONObject json = JSONObject.parseObject(jsonStr);
+        String projectId = json.getString(Const.HEADER_PROJECT);
+        String secret = ProPasCache.getPjSecret(projectId);
+        exchange.getIn().setBody("{\"venderInfo\":true,\"criteria\":{\"type\":[\"Eq\"]}}");
+//        exchange.getIn().setBody("{\"criteria\":{\"family\":[]}}");
+        exchange.getIn().setHeader(Exchange.HTTP_URI, Const.dataPlatform+"/object/subset_query?method=POST");
+        exchange.getIn().setHeader(Exchange.HTTP_QUERY,Const.HEADER_PROJECT + "=" + projectId + "&"+ Const.HEADER_SECRET+ "="+ secret);
+    }
+}