Commit 9ff1c68b29c7c2f102e287fb84e539b7e31d501d

Authored by litao
1 parent 721e92aaa3

建册统计相关代码

Showing 2 changed files with 32 additions and 20 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java View file @ 9ff1c68
... ... @@ -1113,31 +1113,32 @@
1113 1113 }
1114 1114  
1115 1115 List<Patients> patients = mongoTemplate.find(Query.query(criteria), Patients.class);
1116   -
1117   - /* AggregationOperation match = Aggregation.match(
1118   - Criteria.where("hospitalId").is(hospitalId)
1119   -// .and("bookbuildingDate").gte(DateUtil.getYearDate(year)).lt(DateUtil.getNextYearDate(year))
1120   - .and("id").in(patientIds));
1121   - AggregationOperation provinceGroup = Aggregation.group("bookbuildingDate").count().as("provinceCount");
1122   -// AggregationOperation cityGroup = Aggregation.group("cityId").count().as("cityCount");
1123   -// AggregationOperation areaGroup = Aggregation.group("areaId").count().as("areaCount");
1124   - Aggregation aggregation = Aggregation.newAggregation(match, provinceGroup);
1125   - AggregationResults<HashMap> result = mongoTemplate.aggregate(aggregation, Patients.class, HashMap.class);
1126   - List<HashMap> mappedResults = result.getMappedResults();
1127   -
1128   - for (HashMap mappedResult : mappedResults) {
1129   - System.out.println(mappedResult);
1130   - }
1131   -*/
1132 1116 ReportModel reportModel = new ReportModel();
1133 1117 reportModel.setLegend(Arrays.asList("秦皇岛市", "辖区外"));
1134 1118  
1135 1119 reportModel.setxAxis(Arrays.asList("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"));
1136 1120  
1137   -
1138 1121 List<Map<String, Object>> mapList = mongoUtil.getListByGroup(patients);
  1122 +
  1123 +
  1124 +
1139 1125 List<Series> series = createPatientSeries(mapList);
1140 1126 reportModel.setSeries(series);
  1127 +
  1128 + Map<String, Object> countMap = new HashMap<>();
  1129 + countMap.put("id", -1);
  1130 + countMap.put("parentId", null);
  1131 + countMap.put("name", "建册人数(按居住地)");
  1132 + List<Object> qhdData = series.get(0).getData();
  1133 + List<Object> otherData = series.get(0).getData();
  1134 + Integer count = 0;
  1135 + for(int i = 0; i< 12; i++) {
  1136 + countMap.put(i + 1 + "", Integer.parseInt(qhdData.get(i) + "") + Integer.parseInt(otherData.get(i) + ""));
  1137 + count += Integer.parseInt(qhdData.get(i) + "") + Integer.parseInt(otherData.get(i) + "");
  1138 + }
  1139 + countMap.put("count", count);
  1140 + mapList.add(countMap);
  1141 +
1141 1142 return RespBuilder.buildSuccess("patients", mapList, "report", reportModel);
1142 1143 }
1143 1144  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java View file @ 9ff1c68
... ... @@ -53,7 +53,6 @@
53 53 public List<Map<String, Object>> getListByGroup(List<Patients> patients) {
54 54 Map<String, Integer> codeMap = new HashMap<>(); /** key为 id_month */
55 55  
56   - Map<String, Integer> otherCountMap = new HashMap<>();
57 56 Map<String, Integer> otherMonthMap = new HashMap<>();
58 57 for (int i = 1; i <= 12; i++) {
59 58 otherMonthMap.put(i + "", 0);
... ... @@ -129,7 +128,7 @@
129 128 }
130 129 }
131 130  
132   - System.out.println("===================================== codemap =================================");
  131 + /* System.out.println("===================================== codemap =================================");
133 132 Set<Map.Entry<String, Integer>> codeMapEntries = codeMap.entrySet();
134 133 for (Map.Entry<String, Integer> codeMapEntry : codeMapEntries) {
135 134 System.out.println(codeMapEntry.getKey() + " : " + codeMapEntry.getValue());
... ... @@ -140,7 +139,7 @@
140 139 for (Map.Entry<String, Map<Integer, Integer>> mapEntry : set) {
141 140 System.out.println(mapEntry.getKey() + " : " + mapEntry.getValue());
142 141 }
143   - }
  142 + }*/
144 143  
145 144 List<Map<String, Object>> restMap = new ArrayList<>();
146 145  
... ... @@ -163,6 +162,7 @@
163 162 map.put(0, count);
164 163 tempMap.put("count", count);
165 164 tempMap.put("id", entry.getKey());
  165 + tempMap.put("parentId", findParentId(entry.getKey()));
166 166 tempMap.put("name", findName(entry.getKey()));
167 167 restMap.add(tempMap);
168 168 }
... ... @@ -174,6 +174,7 @@
174 174 tempMap.put("count", otherCount);
175 175 tempMap.put("name", "其他");
176 176 tempMap.put("id", null);
  177 + tempMap.put("parentId", -1);
177 178 for (int i = 1; i <= 12; i++) {
178 179 if(otherMonthMap.containsKey(i + "")) {
179 180 tempMap.put(i + "", otherMonthMap.get(i + ""));
... ... @@ -191,6 +192,16 @@
191 192 System.out.println("rest>> " + map);
192 193 }*/
193 194 return restMap;
  195 + }
  196 +
  197 + private String findParentId(String key) {
  198 + if(key != null) {
  199 + BasicConfig basicConfig = mongoTemplate.findById(key, BasicConfig.class);
  200 + if(basicConfig != null) {
  201 + return basicConfig.getParentId();
  202 + }
  203 + }
  204 + return null;
194 205 }
195 206  
196 207 public String findName(Object id) {