فهرست منبع

修改route类结构

Jxing 6 سال پیش
والد
کامیت
b230d98fb9
1فایلهای تغییر یافته به همراه8 افزوده شده و 10 حذف شده
  1. 8 10
      src/main/java/com/sagacloud/route/processors/Insurance/GetPropertyUnderWarrantyProcessor.java

+ 8 - 10
src/main/java/com/sagacloud/route/processors/Insurance/GetPropertyUnderWarrantyProcessor.java

@@ -7,11 +7,8 @@ package com.sagacloud.route.processors.Insurance;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.sagacloud.Exceptions.InvalidPostException;
-import com.sagacloud.cache.ProPasCache;
 import com.sagacloud.pojos.DPSelectPropertyResult;
-import com.sagacloud.pojos.InsurancePost;
-import com.sagacloud.pojos.WarrantyList;
-import com.sagacloud.route.InitEnvRoute;
+import com.sagacloud.pojos.Warranty;
 import com.sagacloud.utils.Const;
 import com.sagacloud.utils.VendersUtil;
 import org.apache.camel.Exchange;
@@ -34,14 +31,15 @@ public class GetPropertyUnderWarrantyProcessor implements Processor {
             throw new InvalidPostException("数据平台返回异常!");
 
         HashSet<String> validWarranty = new HashSet<>();
-        List<WarrantyList.Warrnaty> ws = (List<WarrantyList.Warrnaty>) exchange.getProperty("warrantyList");
+        List<Warranty> ws = (List<Warranty>) exchange.getProperty("warrantyList");
         List<Map<String, Object>> propertyList = dpResult.getContent();
+        //
         for(int i = 0; i < ws.size(); ++i){
-            WarrantyList.Warrnaty warrnaty = ws.get(i);
+            Warranty warrnaty = ws.get(i);
             try {
                 Date expireDate = sdf.parse(warrnaty.getExpireDate());
                 Date now = new Date();
-                if(now.compareTo(expireDate) > 0 && !validWarranty.contains(warrnaty.getInsuranceNo()))
+                if(now.compareTo(expireDate) <= 0 && !validWarranty.contains(warrnaty.getInsuranceNo()))
                     validWarranty.add(warrnaty.getInsuranceNo());
             }catch (Exception ignore)
             {}
@@ -52,13 +50,13 @@ public class GetPropertyUnderWarrantyProcessor implements Processor {
             return;
         }
 
-        for(int i = propertyList.size() - 1; i < propertyList.size(); --i){
+        for(int i = propertyList.size() - 1; i > -1; --i){
             Map<String, Object> property = propertyList.get(i);
             Map<String, Object> infos = (Map<String, Object>) property.get("infos");
-            if(!validWarranty.contains((String)infos.get(Const.INSUR_ID))){
+            if(infos.get(Const.INSUR_ID) == null || !validWarranty.contains(infos.get(Const.INSUR_ID).toString().trim())){
                 propertyList.remove(i);
             }
         }
-        exchange.getOut().setBody(VendersUtil.successJsonMsg("", JSONArray.toJSONString(propertyList)));
+        exchange.getOut().setBody(VendersUtil.successJsonMsg("", (JSONArray) JSONArray.toJSON(propertyList)));
     }
 }