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 d88b1c7..12f5847 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 @@ -1113,31 +1113,32 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService } List patients = mongoTemplate.find(Query.query(criteria), Patients.class); - - /* AggregationOperation match = Aggregation.match( - Criteria.where("hospitalId").is(hospitalId) -// .and("bookbuildingDate").gte(DateUtil.getYearDate(year)).lt(DateUtil.getNextYearDate(year)) - .and("id").in(patientIds)); - AggregationOperation provinceGroup = Aggregation.group("bookbuildingDate").count().as("provinceCount"); -// AggregationOperation cityGroup = Aggregation.group("cityId").count().as("cityCount"); -// AggregationOperation areaGroup = Aggregation.group("areaId").count().as("areaCount"); - Aggregation aggregation = Aggregation.newAggregation(match, provinceGroup); - AggregationResults result = mongoTemplate.aggregate(aggregation, Patients.class, HashMap.class); - List mappedResults = result.getMappedResults(); - - for (HashMap mappedResult : mappedResults) { - System.out.println(mappedResult); - } -*/ ReportModel reportModel = new ReportModel(); reportModel.setLegend(Arrays.asList("秦皇岛市", "辖区外")); reportModel.setxAxis(Arrays.asList("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月")); - List> mapList = mongoUtil.getListByGroup(patients); + + + List series = createPatientSeries(mapList); reportModel.setSeries(series); + + Map countMap = new HashMap<>(); + countMap.put("id", -1); + countMap.put("parentId", null); + countMap.put("name", "建册人数(按居住地)"); + List qhdData = series.get(0).getData(); + List otherData = series.get(0).getData(); + Integer count = 0; + for(int i = 0; i< 12; i++) { + countMap.put(i + 1 + "", Integer.parseInt(qhdData.get(i) + "") + Integer.parseInt(otherData.get(i) + "")); + count += Integer.parseInt(qhdData.get(i) + "") + Integer.parseInt(otherData.get(i) + ""); + } + countMap.put("count", count); + mapList.add(countMap); + return RespBuilder.buildSuccess("patients", mapList, "report", reportModel); } 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 f1a86bd..c79b508 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 @@ -53,7 +53,6 @@ public class MongoUtil { public List> getListByGroup(List patients) { Map codeMap = new HashMap<>(); /** key为 id_month */ - Map otherCountMap = new HashMap<>(); Map otherMonthMap = new HashMap<>(); for (int i = 1; i <= 12; i++) { otherMonthMap.put(i + "", 0); @@ -129,7 +128,7 @@ public class MongoUtil { } } - System.out.println("===================================== codemap ================================="); + /* System.out.println("===================================== codemap ================================="); Set> codeMapEntries = codeMap.entrySet(); for (Map.Entry codeMapEntry : codeMapEntries) { System.out.println(codeMapEntry.getKey() + " : " + codeMapEntry.getValue()); @@ -140,7 +139,7 @@ public class MongoUtil { for (Map.Entry> mapEntry : set) { System.out.println(mapEntry.getKey() + " : " + mapEntry.getValue()); } - } + }*/ List> restMap = new ArrayList<>(); @@ -163,6 +162,7 @@ public class MongoUtil { map.put(0, count); tempMap.put("count", count); tempMap.put("id", entry.getKey()); + tempMap.put("parentId", findParentId(entry.getKey())); tempMap.put("name", findName(entry.getKey())); restMap.add(tempMap); } @@ -174,6 +174,7 @@ public class MongoUtil { tempMap.put("count", otherCount); tempMap.put("name", "其他"); tempMap.put("id", null); + tempMap.put("parentId", -1); for (int i = 1; i <= 12; i++) { if(otherMonthMap.containsKey(i + "")) { tempMap.put(i + "", otherMonthMap.get(i + "")); @@ -193,6 +194,16 @@ public class MongoUtil { return restMap; } + private String findParentId(String key) { + if(key != null) { + BasicConfig basicConfig = mongoTemplate.findById(key, BasicConfig.class); + if(basicConfig != null) { + return basicConfig.getParentId(); + } + } + return null; + } + public String findName(Object id) { if(id != null) { BasicConfig basicConfig = mongoTemplate.findById(id, BasicConfig.class);