Commit 989cc36b2fa979d9b676a4450bb85ea1169d7709

Authored by liquanyu
1 parent ab34eed0b5

育龄服务生孩统计

Showing 3 changed files with 116 additions and 21 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/MatDeliverController.java View file @ 989cc36
... ... @@ -362,16 +362,36 @@
362 362 * @return
363 363 */
364 364 @TokenRequired
  365 + @ResponseBody
  366 + @RequestMapping(value = "getChildbearAgeCount", method = RequestMethod.GET)
  367 + public BaseObjectResponse getChildbearAgeCount(HttpServletRequest request,
  368 + @RequestParam String birth,
  369 + @RequestParam String hospitalId,
  370 + @RequestParam String proviceId,
  371 + @RequestParam String cityId,
  372 + @RequestParam String areaId) {
  373 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  374 + return matDeliverFacade.getChildbearAgeCount(birth,loginState.getId(),hospitalId,proviceId,cityId,areaId);
  375 + }
  376 +
  377 + /**
  378 + * 育龄服务生孩统计导出
  379 + * @param request
  380 + * @param birth
  381 + * @return
  382 + */
  383 + @TokenRequired
365 384 @ResponseBody
366   - @RequestMapping(value = "getChildbearAgeCount", method = RequestMethod.GET)
367   - public BaseObjectResponse getChildbearAgeCount(HttpServletRequest request,
  385 + @RequestMapping(value = "exportChildbearAgeCount", method = RequestMethod.GET)
  386 + public void exportChildbearAgeCount(HttpServletRequest request,
368 387 @RequestParam String birth,
369 388 @RequestParam String hospitalId,
370 389 @RequestParam String proviceId,
371 390 @RequestParam String cityId,
372   - @RequestParam String areaId) {
  391 + @RequestParam String areaId,
  392 + HttpServletResponse httpServletResponse) {
373 393 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
374   - return matDeliverFacade.getChildbearAgeCount(birth,loginState.getId(),hospitalId,proviceId,cityId,areaId);
  394 + matDeliverFacade.exportChildbearAgeCount(birth, loginState.getId(), hospitalId, proviceId, cityId, areaId, httpServletResponse);
375 395 }
376 396 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java View file @ 989cc36
... ... @@ -38,6 +38,7 @@
38 38 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
39 39 import org.springframework.stereotype.Component;
40 40  
  41 +import javax.servlet.http.HttpServletResponse;
41 42 import java.text.ParseException;
42 43 import java.text.SimpleDateFormat;
43 44 import java.util.*;
... ... @@ -2391,6 +2392,19 @@
2391 2392  
2392 2393 public BaseObjectResponse getChildbearAgeCount(String birth, Integer userId,String hospitalId,
2393 2394 String proviceId,String cityId,String areaId) {
  2395 + List<Map<String,String>> list = getChidbearAgeCountData( birth, userId, hospitalId,
  2396 + proviceId, cityId, areaId);
  2397 +
  2398 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  2399 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  2400 + objectResponse.setErrormsg("成功");
  2401 + objectResponse.setData(list);
  2402 + return objectResponse;
  2403 + }
  2404 +
  2405 + private List<Map<String,String>> getChidbearAgeCountData(String birth, Integer userId,String hospitalId,
  2406 + String proviceId,String cityId,String areaId)
  2407 + {
2394 2408 List<String> hospitalIds = new ArrayList<>();
2395 2409 if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(hospitalId)) {
2396 2410 hospitalIds.add(hospitalId);
2397 2411  
2398 2412  
... ... @@ -2399,12 +2413,11 @@
2399 2413 hospitalIds = areaCountFacade.getCurrentUserHospPermissions(userId, proviceId,
2400 2414 cityId, areaId);
2401 2415 }
  2416 + List<Map<String,String>> list = new ArrayList<>();
2402 2417  
2403   - List<Map<String,Integer>> list = new ArrayList<>();
2404   -
2405 2418 //String hospitalId = autoMatchFacade.getHospitalId(userId);
2406 2419 List<Integer> ages = new ArrayList<>();
2407   - for (int i = 15; i < 16; i ++)
  2420 + for (int i = 15; i < 50; i ++)
2408 2421 {
2409 2422 ages.add(i);
2410 2423 }
2411 2424  
... ... @@ -2427,18 +2440,70 @@
2427 2440 if (CollectionUtils.isNotEmpty(futures)) {
2428 2441 for (Future f : futures) {
2429 2442 try {
2430   - list.addAll((List<Map<String,Integer>>) f.get());
  2443 + list.addAll((List<Map<String,String>>) f.get());
2431 2444 } catch (Exception e) {
2432 2445 ExceptionUtils.catchException(e, "getChildbearAgeCount list error.");
2433 2446 }
2434 2447 }
2435 2448 }
2436 2449  
2437   - BaseObjectResponse objectResponse = new BaseObjectResponse();
2438   - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
2439   - objectResponse.setErrormsg("成功");
2440   - objectResponse.setData(list);
2441   - return objectResponse;
  2450 + Integer columnOneCount = 0;
  2451 + Integer columnTwoCount = 0;
  2452 + Integer columnThreeCount = 0;
  2453 + Integer columnMoreCount = 0;
  2454 + Integer columnRowCount = 0;
  2455 +
  2456 + for (Map<String,String> map : list)
  2457 + {
  2458 + Integer oneCount = Integer.parseInt(map.get("oneCount"));
  2459 + columnOneCount+=oneCount;
  2460 +
  2461 + Integer twoCount = Integer.parseInt(map.get("twoCount"));
  2462 + columnTwoCount+=twoCount;
  2463 +
  2464 + Integer threeCount = Integer.parseInt(map.get("threeCount"));
  2465 + columnThreeCount+=threeCount;
  2466 +
  2467 + Integer moreCount = Integer.parseInt(map.get("moreCount"));
  2468 + columnMoreCount+=moreCount;
  2469 +
  2470 + Integer rowCount = Integer.parseInt(map.get("rowCount"));
  2471 + columnRowCount+=rowCount;
  2472 +
  2473 + }
  2474 +
  2475 + Map<String,String> allMap = new HashMap<>();
  2476 + allMap.put("name","合计");
  2477 + allMap.put("oneCount",String.valueOf(columnOneCount));
  2478 + allMap.put("twoCount", String.valueOf(columnTwoCount));
  2479 + allMap.put("threeCount", String.valueOf(columnThreeCount));
  2480 + allMap.put("moreCount",String.valueOf(columnMoreCount));
  2481 + allMap.put("rowCount", String.valueOf(columnRowCount));
  2482 +
  2483 + list.add(allMap);
  2484 + return list;
  2485 + }
  2486 +
  2487 + public void exportChildbearAgeCount(String birth, Integer userId, String hospitalId,
  2488 + String proviceId, String cityId, String areaId,
  2489 + HttpServletResponse httpServletResponse) {
  2490 + try {
  2491 + List<Map<String,Object>> list = (ArrayList)getChidbearAgeCountData(birth, userId, hospitalId,
  2492 + proviceId, cityId, areaId);
  2493 + Map<String, String> header = new LinkedHashMap<>();
  2494 + header.put("name", "年龄");
  2495 + header.put("oneCount", "1孩");
  2496 + header.put("twoCount", "2孩");
  2497 + header.put("threeCount", "3孩");
  2498 + header.put("moreCount", "多孩");
  2499 + header.put("rowCount", "合计");
  2500 + httpServletResponse.setContentType("application/force-download");
  2501 + httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + new String(("育龄服务生孩统计.xls").getBytes("UTF-8"), "ISO-8859-1"));
  2502 + ExcelUtil.toExcel(httpServletResponse.getOutputStream(), list, header);
  2503 + }catch (Exception e)
  2504 + {
  2505 + ExceptionUtils.catchException(e,"exportChildbearAgeCount error");
  2506 + }
2442 2507 }
2443 2508 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ChildbearAgeWorker.java View file @ 989cc36
... ... @@ -17,7 +17,7 @@
17 17 /**
18 18 * Created by Administrator on 2018-08-14.
19 19 */
20   -public class ChildbearAgeWorker implements Callable<List<Map<String,Integer>>> {
  20 +public class ChildbearAgeWorker implements Callable<List<Map<String,String>>> {
21 21  
22 22 private String birth;
23 23 private List<Integer> ages;
24 24  
25 25  
... ... @@ -36,16 +36,16 @@
36 36 }
37 37  
38 38 @Override
39   - public List<Map<String,Integer>> call() throws Exception {
  39 + public List<Map<String,String>> call() throws Exception {
40 40  
41 41 List<Integer> fmChildTimes = new ArrayList<>();
42 42  
43   - List<Map<String,Integer>> list = new ArrayList<>();
  43 + List<Map<String,String>> list = new ArrayList<>();
44 44  
45 45 for (Integer fmAge : ages)
46 46 {
47   - Map<String,Integer> map = new HashMap<>();
48   - map.put("age", fmAge);
  47 + Map<String,String> map = new HashMap<>();
  48 + map.put("name", String.valueOf(fmAge));
49 49 MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
50 50 matDeliverQuery.setYn(YnEnums.YES.getId());
51 51 matDeliverQuery.setFmAge(fmAge);
... ... @@ -61,7 +61,7 @@
61 61 fmChildTimes.add(1);
62 62 matDeliverQuery.setFmChildTimes(fmChildTimes);
63 63 int oneCount = matDeliverService.count(matDeliverQuery);
64   - map.put("oneChild", oneCount);
  64 + map.put("oneCount", String.valueOf(oneCount));
65 65 fmChildTimes.clear();
66 66  
67 67  
68 68  
... ... @@ -69,13 +69,23 @@
69 69 matDeliverQuery.setFmChildTimes(fmChildTimes);
70 70 int twoCount = matDeliverService.count(matDeliverQuery);
71 71 fmChildTimes.clear();
72   - map.put("twoChild", twoCount);
  72 + map.put("twoCount", String.valueOf(twoCount));
73 73  
74 74 fmChildTimes.add(3);
75 75 matDeliverQuery.setFmChildTimes(fmChildTimes);
76 76 int threeCount = matDeliverService.count(matDeliverQuery);
77 77 fmChildTimes.clear();
78   - map.put("threeChild",threeCount);
  78 + map.put("threeCount", String.valueOf(threeCount));
  79 +
  80 + fmChildTimes.add(4);
  81 + matDeliverQuery.setFmChildTimes(fmChildTimes);
  82 + int moreCount = matDeliverService.count(matDeliverQuery);
  83 + fmChildTimes.clear();
  84 + map.put("moreCount", String.valueOf(moreCount));
  85 +
  86 + int rowCount = oneCount+twoCount+threeCount+moreCount;
  87 +
  88 + map.put("rowCount", String.valueOf(rowCount));
79 89  
80 90 list.add(map);
81 91 }