Browse Source

查询全国贫困开发

anderx 2 years ago
parent
commit
f8a11bfe04

+ 28 - 0
src/main/java/com/goafanti/common/bo/OutPovertyFlag.java

@@ -0,0 +1,28 @@
+package com.goafanti.common.bo;
+
+import com.goafanti.common.utils.excel.Excel;
+
+public class OutPovertyFlag {
+
+    @Excel(name = "名称")
+    private String name;
+    @Excel(name = "查询结果")
+    private String povertyStatus;
+
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPovertyStatus() {
+        return povertyStatus;
+    }
+
+    public void setPovertyStatus(String povertyStatus) {
+        this.povertyStatus = povertyStatus;
+    }
+}

+ 53 - 4
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -2,10 +2,8 @@ package com.goafanti.common.controller;
 
 import com.goafanti.admin.service.AdminService;
 import com.goafanti.admin.service.AttachmentService;
+import com.goafanti.common.bo.*;
 import com.goafanti.common.bo.Error;
-import com.goafanti.common.bo.OutPoverty;
-import com.goafanti.common.bo.OutUser;
-import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.enums.UserType;
@@ -883,8 +881,59 @@ public class PublicController extends CertifyApiController {
 			return res;
 		}
 		String id = jdbcIdGenerator.generateId().toString();
-		res.data(povertyService.selectFlag(file,id));
+		Map<String, Object> map = povertyService.selectFlag(file, id);
+		List<OutPovertyFlag> falseList = (List<OutPovertyFlag>) map.get("falseList");
+		List<OutPovertyFlag> list = (List<OutPovertyFlag>) map.get("trueList");
+		list.addAll(falseList);
+		map.put("list",list);
+		map.remove("falseList");
+		map.remove("trueList");
+		res.data(map);
 		return res;
 	}
 
+	/**
+	 * 查询贫困信息
+	 * @param id 贫困信息编号
+	 * @param type 0=所有 ,1=只看有效数据
+	 * @return
+	 */
+	@RequestMapping("/selectPovertyFlagById")
+	public Result selectPovertyFlagById(String id,Integer type) {
+		Result res =new Result();
+		Map<String,Object> map = povertyService.selectFlag(null, id);
+		if (type==null)type=0;
+		List<OutPovertyFlag> resList=new ArrayList<>();
+		if (type==1){
+			map.put("list",map.get("trueList"));
+		}else {
+			map.put("list",map.get("falseList"));
+		}
+		map.remove("trueList");
+		map.remove("falseList");
+		return res.data(map);
+	}
+	/**
+	 * 查询贫困信息
+	 * @param id 贫困信息编号
+	 * @param type 0=所有 ,1=只看有效数据
+	 * @return
+	 */
+	@RequestMapping("/selectPovertyFlagById/export")
+	public Result selectPovertyFlagByIdExport(String id,Integer type) {
+		Map<String,Object> map = povertyService.selectFlag(null, id);
+		if (type==null)type=0;
+		List<OutPovertyFlag> resList=new ArrayList<>();
+		if (type==1){
+			map.put("list",map.get("trueList"));
+
+		}else {
+			map.put("list",map.get("falseList"));
+		}
+		map.remove("trueList");
+		map.remove("falseList");
+		NewExcelUtil<OutPovertyFlag> newExcelUtil=new NewExcelUtil<>(OutPovertyFlag.class);
+		return newExcelUtil.exportExcel(resList,"全国贫困信息表",uploadPath);
+	}
+
 }

+ 33 - 9
src/main/java/com/goafanti/common/service/PovertyService.java

@@ -3,6 +3,7 @@ package com.goafanti.common.service;
 import com.alibaba.fastjson.JSONObject;
 import com.goafanti.common.bo.InputPoverty;
 import com.goafanti.common.bo.OutPoverty;
+import com.goafanti.common.bo.OutPovertyFlag;
 import com.goafanti.common.utils.HttpUtils;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.common.utils.excel.NewExcelUtil;
@@ -112,9 +113,10 @@ public class PovertyService {
         }
         return out;
     }
-
     private static final String flag_url="https://cpadis.cpad.gov.cn:1443/cpad_par/app/observeHouse/checkIdentity?loginToken=&userId=&version=";
-    public Object selectFlag(MultipartFile file, String id) {
+
+    @Cacheable(value = "selectPovertytFlag#300", key = "'selectPovertytFlag:key='+#id")
+    public Map<String, Object> selectFlag(MultipartFile file, String id) {
         NewExcelUtil<InputPoverty> newExcelUtil=new NewExcelUtil<>(InputPoverty.class);
         List<InputPoverty> list = null;
         try {
@@ -122,17 +124,39 @@ public class PovertyService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        List<OutPoverty> res=new ArrayList<>();
-        Map<String, Object> map=new HashMap<>();
+        List<OutPovertyFlag> trueList=new ArrayList<>();
+        List<OutPovertyFlag> falseList=new ArrayList<>();
+        Map<String, Object> param=new HashMap<>();
+        Map<String, Object> res=new HashMap<>();
+        Integer totalcount =0;
+        Integer effectiveCount =0;
         for (InputPoverty in : list) {
             String name=StringUtils.deleteWhitespace(in.getName());
             String idCode=StringUtils.deleteWhitespace(in.getIdCard());
-            map.put("name",name);
-            map.put("idCode",idCode);
-            JSONObject jsonObject = HttpUtils.httpPostBody(flag_url, map);
+            param.put("name",name);
+            param.put("idCode",idCode);
+            JSONObject jsonObject = HttpUtils.httpPostBody(flag_url, param);
             String data = jsonObject.getString("data");
-            System.out.println("name="+name+",flag="+data);
+            OutPovertyFlag outPovertyFlag=new OutPovertyFlag();
+            outPovertyFlag.setName(name);
+            if (StringUtils.equals(data,"true")){
+                outPovertyFlag.setPovertyStatus("是");
+                trueList.add(outPovertyFlag);
+            effectiveCount++;
+            }else if (StringUtils.equals(data,"false")){
+                outPovertyFlag.setPovertyStatus("否");
+                falseList.add(outPovertyFlag);
+            }else {
+                outPovertyFlag.setPovertyStatus("查询错误");
+                falseList.add(outPovertyFlag);
+            }
+            totalcount++;
         }
-        return 1;
+        res.put("trueList",trueList);
+        res.put("falseList",falseList);
+        res.put("totalcount",totalcount);
+        res.put("effectiveCount",effectiveCount);
+        res.put("id",id);
+        return res;
     }
 }

+ 0 - 1
src/main/java/com/goafanti/common/utils/HttpUtils.java

@@ -98,7 +98,6 @@ public class HttpUtils {
 			str=str.append(string).append("=").append(map.get(string)).append("&");
 		}
 		String substring = str.substring(0, str.length() - 1);
-		System.out.println(substring);
 		return substring;
 	}
 

+ 1 - 0
src/main/java/com/goafanti/core/cache/serializer/FastJsonRedisSerializer.java

@@ -30,6 +30,7 @@ public class FastJsonRedisSerializer implements RedisSerializer<Object> {
 		pc.addAccept("com.goafanti.expenseAccount.bo.OutExpenseAccountStatistics");
 		pc.addAccept("java.util.Map");
 		pc.addAccept("com.goafanti.common.bo.OutPoverty");
+		pc.addAccept("com.goafanti.common.bo.OutPovertyFlag");
 
 	}