|
@@ -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);
|
|
|
}
|
|
|
|