Browse Source

fix things

wushengzong 6 years ago
parent
commit
d1cef07e18

+ 1 - 1
src/main/java/com/sagacloud/route/Route.java

@@ -256,7 +256,7 @@ public class Route extends ExceptionHandlerBaseRoute {
                 })
                 .to(InitEnvRoute.venders+"/auxiliary/project/create");
 
-        rest("/getInsurance").post()
+        rest("/getInsuranceNum").post()
                 .produces(MediaType.APPLICATION_JSON)
                 .route()
                 .process(ContractMethods :: validateDPInsurerID)

+ 16 - 2
src/main/java/com/sagacloud/route/processors/ContractMethods.java

@@ -4,7 +4,9 @@ import com.sagacloud.Exceptions.InvalidPostException;
 import org.apache.camel.Exchange;
 import org.json.JSONObject;
 
+import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -29,16 +31,28 @@ public class ContractMethods {
         if(!json.getString("Result").equalsIgnoreCase("success")){
             return;
         }
+        List<JSONObject> contents = new ArrayList<>();
         Set<String> contractIds = new HashSet<>();
         json.getJSONArray("Content").forEach(obj ->{
             JSONObject item = (JSONObject) obj;
             JSONObject infos = item.getJSONObject("infos");
             if(infos.has(venderInfo) && infos.getString(venderInfo).trim().equalsIgnoreCase(venderId) && infos.has(info)){
-                contractIds.add(item.getJSONObject("infos").getString(info));
+                if(contractIds.contains(infos.getString(info))){
+                    return;
+                }
+                JSONObject content = new JSONObject();
+                content.put(info, infos.getString(info));
+                if(info.equalsIgnoreCase("InsuranceNum")){
+                    if(infos.has("InsuranceFile")){
+                        content.put("InsuranceFile", infos.get("InsuranceFile"));
+                    }
+                }
+                contents.add(content);
+                contractIds.add(infos.getString(info));
             }
         });
         JSONObject result = new JSONObject("{\"result\":\"success\",\"resultMsg\":\"\"}");
-        result.put("content", contractIds);
+        result.put("content", contents);
         exchange.getOut().setBody(result);
     }
 

+ 12 - 3
src/main/resources/documentation.md

@@ -259,7 +259,7 @@ post体:
 
 ##查询项目下所有设备包含的保单
 
-    http://<host>:<port>/venders-dp/getInsurance?projectId=Pj110108****&secret=***
+    http://<host>:<port>/venders-dp/getInsuranceNum?projectId=Pj110108****&secret=***
     
 post体:
 
@@ -272,7 +272,14 @@ post体:
     {
         "result": "success",
         "content": [
-            "hhhh"
+            {
+                "InsuranceNum": "1234",
+                "InsuranceFile": {
+                    "name": "",
+                    "type": "image",
+                    "key": ""
+                }
+            }
         ],
         "resultMsg": ""
     }
@@ -292,7 +299,9 @@ post体:
     {
         "result": "success",
         "content": [
-            "1234"
+            {
+                "SupplierContractID": "hhhh"
+            }
         ],
         "resultMsg": ""
     }