Browse Source

查询广西贫困开发

anderx 2 years ago
parent
commit
f4ee533303

+ 12 - 1
src/main/java/com/goafanti/common/bo/OutPoverty.java

@@ -1,15 +1,26 @@
 package com.goafanti.common.bo;
 
+import com.goafanti.common.utils.excel.Excel;
+
 public class OutPoverty {
     //序号 市 县 乡镇 村 人口数  姓名 与户主关系  脱贫年度
+    @Excel(name = "序号")
     private String id;
+    @Excel(name = "名称")
+    private String name;
+    @Excel(name = "市")
     private String city;
+    @Excel(name = "县")
     private String county;
+    @Excel(name = "乡镇")
     private String township;
+    @Excel(name = "村")
     private String village;
+    @Excel(name = "人口数")
     private String peopleSum;
-    private String name;
+    @Excel(name = "与户主关系")
     private String relationship;
+    @Excel(name = "脱贫年度")
     private String povertyYear;
 
     public String getId() {

+ 55 - 1
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -3,6 +3,7 @@ package com.goafanti.common.controller;
 import com.goafanti.admin.service.AdminService;
 import com.goafanti.admin.service.AttachmentService;
 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;
@@ -15,6 +16,7 @@ import com.goafanti.common.service.PovertyService;
 import com.goafanti.common.utils.*;
 import com.goafanti.common.utils.excel.FileUtils;
 import com.goafanti.common.utils.excel.NewExcelUtil;
+import com.goafanti.core.mybatis.JDBCIdGenerator;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.core.websocket.SystemWebSocketHandler;
 import com.goafanti.expenseAccount.service.ExpenseAccountService;
@@ -95,6 +97,9 @@ public class PublicController extends CertifyApiController {
 	@Value(value = "${patentTemplate}")
 	private String					patentTemplate		= null;
 
+	@Autowired
+	private JDBCIdGenerator jdbcIdGenerator;
+
 	@Resource(name = "passwordUtil")
 	private PasswordUtil			passwordUtil;
 
@@ -787,7 +792,56 @@ public class PublicController extends CertifyApiController {
 			res.getError().add(buildError("格式不正确","格式不正确"));
 			return res;
 		}
-		res.data(povertyService.selectPoverty(file));
+		String id = jdbcIdGenerator.generateId().toString();
+		res.data(povertyService.selectPoverty(file,id));
+		return res;
+	}
+
+
+	/**
+	 * 查询贫困信息
+	 * @param id 贫困信息编号
+	 * @param type 0=所有 ,1=只看有效数据
+	 * @return
+	 */
+	@RequestMapping("/selectPovertyById/export")
+	public Result selectPovertyByIdExport(String id,Integer type) {
+		Map<String,Object> o = povertyService.selectPoverty(null, id);
+		if (type==null)type=0;
+		List<OutPoverty> resList=new ArrayList<>();
+		if (type==1){
+			List<OutPoverty> list = (List<OutPoverty>) o.get("list");
+			for (OutPoverty outPoverty : list) {
+				if (com.goafanti.common.utils.StringUtils.isNotEmpty(outPoverty.getId())){
+					resList.add(outPoverty);
+				}
+			}
+
+		}else {
+			resList = (List<OutPoverty>) o.get("list");
+		}
+		NewExcelUtil<OutPoverty> newExcelUtil=new NewExcelUtil<>(OutPoverty.class);
+		return newExcelUtil.exportExcel(resList,"广西贫困信息表",uploadPath);
+	}
+
+
+	@RequestMapping("/selectPovertyById")
+	public Result selectPovertyById(String id,Integer type) {
+		Result res=new Result();
+		Map<String,Object> o = povertyService.selectPoverty(null, id);
+		if (type==null)type=0;
+		if (type==1){
+			List<OutPoverty> list = (List<OutPoverty>) o.get("list");
+			List<OutPoverty> resList=new ArrayList<>();
+			for (OutPoverty outPoverty : list) {
+				if (com.goafanti.common.utils.StringUtils.isNotEmpty(outPoverty.getId())){
+					resList.add(outPoverty);
+				}
+			}
+			o.remove("list");
+			o.put("list",resList);
+		}
+		res.data(o);
 		return res;
 	}
 

+ 16 - 12
src/main/java/com/goafanti/common/controller/WebpageController.java

@@ -1,26 +1,24 @@
 package com.goafanti.common.controller;
 
-import java.util.List;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.servlet.ModelAndView;
-
 import com.goafanti.achievement.service.AchievementService;
 import com.goafanti.banners.enums.BannersType;
 import com.goafanti.banners.service.BannersService;
 import com.goafanti.common.model.Banners;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.demand.service.DemandService;
-import com.goafanti.user.service.OrganizationIdentityService;
-import com.goafanti.user.service.UserIdentityService;
 import com.goafanti.news.bo.NewsPortalList;
 import com.goafanti.news.enums.NewsType;
 import com.goafanti.news.service.NewsService;
+import com.goafanti.user.service.OrganizationIdentityService;
+import com.goafanti.user.service.UserIdentityService;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 @Controller
 public class WebpageController extends BaseController {
@@ -504,5 +502,11 @@ public class WebpageController extends BaseController {
 		modelview.setViewName("/portal/index");
 		return modelview;
 	}
+	@RequestMapping(value = "/admin/povertyInquiry", method = RequestMethod.GET)
+	public ModelAndView povertyInquiry(HttpServletRequest request, ModelAndView modelview) {
+		modelview.setViewName("/admin/povertyInquiry");
+		return modelview;
+	}
+
 
 }

+ 22 - 6
src/main/java/com/goafanti/common/service/PovertyService.java

@@ -7,19 +7,25 @@ import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
-import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class PovertyService {
+
+
     private static final String   gx_url="http://fpb.gxxw.cn/index.php?m=check&c=index&a=list_jdlk&name=";
 
-    public Object selectPoverty(MultipartFile file) {
+    @Cacheable(value = "selectPoverty#300", key = "'selectPoverty:key='+#id")
+    public Map<String,Object> selectPoverty(MultipartFile file,String id) {
+
         NewExcelUtil<InputPoverty> newExcelUtil=new NewExcelUtil<>(InputPoverty.class);
         List<InputPoverty> list = null;
         try {
@@ -28,12 +34,22 @@ public class PovertyService {
             e.printStackTrace();
         }
         List<OutPoverty> res=new ArrayList<>();
+        Integer totalcount =0;
+        Integer effectiveCount =0;
         for (InputPoverty e : list) {
-            res.add(selectHttpPoverty(e));
+            OutPoverty outPoverty = selectHttpPoverty(e);
+            if (outPoverty.getId()!=null){
+                effectiveCount++;
+            }
+            totalcount++;
+            res.add(outPoverty);
         }
-
-
-        return res;
+        Map<String ,Object> map=new HashMap<>();
+        map.put("list",res);
+        map.put("totalcount",totalcount);
+        map.put("effectiveCount",effectiveCount);
+        map.put("id",id);
+        return map;
     }
 
     private OutPoverty selectHttpPoverty(InputPoverty in) {

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

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

+ 18 - 0
src/main/webapp/WEB-INF/views/admin/povertyInquiry.html

@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml"
+	xmlns:th="http://www.thymeleaf.org">
+<head th:replace="common::header(~{::title},~{::link})">
+	<title>管理中心首页</title>
+	<link th:href="${staticHost+'/dll/dll.css'}" rel="stylesheet">
+	<link th:href="${staticHost+'/admin/povertyInquiry.css'}" rel="stylesheet">
+</head>
+<body>
+	<div id="root"></div>
+
+	<div th:replace="common::footer(~{::script})">
+		<script type="text/javascript" th:src="${staticHost+'/vendors.js'}"></script>
+		<script type="text/javascript" th:src="${staticHost+'/dll/dll.js'}"></script>
+		<script type="text/javascript" th:src="${staticHost+'/admin/povertyInquiry.js'}"></script>
+	</div>
+</body>
+</html>