From ff19a3dc738c84fd9c05be70cbee7631375ff954 Mon Sep 17 00:00:00 2001 From: litao Date: Fri, 16 Jun 2017 11:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=BA=E5=86=8C=E7=BB=9F=E8=AE=A1=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/service/impl/ReportServiceImpl.java | 41 ++++++++++++++++++---- .../lyms/platform/operate/web/utils/MongoUtil.java | 22 ++++++------ 2 files changed, 44 insertions(+), 19 deletions(-) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java index 5014a46..d88b1c7 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java @@ -1135,24 +1135,51 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService reportModel.setxAxis(Arrays.asList("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月")); - List series = createPatientSeries(patients); List> mapList = mongoUtil.getListByGroup(patients); + List series = createPatientSeries(mapList); + reportModel.setSeries(series); return RespBuilder.buildSuccess("patients", mapList, "report", reportModel); } - private List createPatientSeries(List patients) { + private List createPatientSeries(List> datas) { List series = new ArrayList<>(); + Series qhdSeries = new Series(); qhdSeries.setName("秦皇岛市"); qhdSeries.setType("bar"); - List qhdDatas = new ArrayList<>(); - BasicConfig basicConfig = mongoTemplate.findOne(Query.query(Criteria.where("name").is("河北省")), BasicConfig.class); - if(basicConfig != null) {} - for (Patients patient : patients) { -// if(patient.getProvinceId() == 1) + qhdSeries.setStack("总计"); + List qhdDatas = new ArrayList<>(); + + Series otherSeries = new Series(); + otherSeries.setName("辖区外"); + otherSeries.setType("bar"); + otherSeries.setStack("总计"); + List otherDatas = new ArrayList<>(); + Map temp = new HashMap<>(); + for(int i = 1; i < 13; i++) { + temp.put(i + "", 0); + } + + String provinceId = mongoUtil.findId("河北省"); + if(StringUtils.isNotEmpty(provinceId)) {} + for (Map data : datas) { + if(provinceId.equals(data.get("id"))) { + for(int i = 1; i < 13; i++) { + qhdDatas.add(data.get(i + "")); + } + qhdSeries.setData(qhdDatas); + } else { + for(int i = 1; i < 13; i++) { + temp.put(i + "", temp.get(i + "") + Integer.parseInt(data.get(i + "") + "")); + } + } } + List integers = CollectionUtils.transValToList(temp); + otherDatas.addAll(integers); + otherSeries.setData(otherDatas); series.add(qhdSeries); + series.add(otherSeries); return series; } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java index 3f97647..f1a86bd 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java @@ -58,18 +58,6 @@ public class MongoUtil { for (int i = 1; i <= 12; i++) { otherMonthMap.put(i + "", 0); } - /*otherMonthMap.put("1", 0); - otherMonthMap.put("2", 0); - otherMonthMap.put("3", 0); - otherMonthMap.put("4", 0); - otherMonthMap.put("5", 0); - otherMonthMap.put("6", 0); - otherMonthMap.put("7", 0); - otherMonthMap.put("8", 0); - otherMonthMap.put("9", 0); - otherMonthMap.put("10", 0); - otherMonthMap.put("11", 0); - otherMonthMap.put("12", 0);*/ Integer otherCount = 0; /* for (Patients patient : patients) { @@ -215,4 +203,14 @@ public class MongoUtil { return null; } + public String findId(String name) { + if(StringUtils.isNotEmpty(name)) { + BasicConfig basicConfig = mongoTemplate.findOne(Query.query(Criteria.where("name").is(name)), BasicConfig.class); + if(basicConfig != null) { + return basicConfig.getId(); + } + } + return null; + } + } -- 1.8.3.1