Commit 37cc84b4fc977ad9d706927044ca3e0d9fc09ea9
1 parent
e54dae9ad4
Exists in
master
and in
1 other branch
建册统计报表数据修改
Showing 2 changed files with 120 additions and 63 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
37cc84b
| ... | ... | @@ -1120,12 +1120,10 @@ |
| 1120 | 1120 | |
| 1121 | 1121 | List<Map<String, Object>> mapList = mongoUtil.getListByGroup(patients); |
| 1122 | 1122 | |
| 1123 | - | |
| 1124 | - | |
| 1125 | 1123 | List<Series> series = createPatientSeries(mapList); |
| 1126 | 1124 | reportModel.setSeries(series); |
| 1127 | 1125 | |
| 1128 | - Map<String, Object> countMap = new HashMap<>(); | |
| 1126 | + /*Map<String, Object> countMap = new HashMap<>(); | |
| 1129 | 1127 | countMap.put("id", -1); |
| 1130 | 1128 | countMap.put("parentId", null); |
| 1131 | 1129 | countMap.put("name", "建册人数(按居住地)"); |
| ... | ... | @@ -1137,7 +1135,7 @@ |
| 1137 | 1135 | count += Integer.parseInt(qhdData.get(i) + "") + Integer.parseInt(otherData.get(i) + ""); |
| 1138 | 1136 | } |
| 1139 | 1137 | countMap.put("count", count); |
| 1140 | - mapList.add(countMap); | |
| 1138 | + mapList.add(countMap);*/ | |
| 1141 | 1139 | |
| 1142 | 1140 | return RespBuilder.buildSuccess("patients", mapList, "report", reportModel); |
| 1143 | 1141 | } |
| 1144 | 1142 | |
| 1145 | 1143 | |
| 1146 | 1144 | |
| 1147 | 1145 | |
| 1148 | 1146 | |
| 1149 | 1147 | |
| ... | ... | @@ -1149,38 +1147,52 @@ |
| 1149 | 1147 | qhdSeries.setName("秦皇岛市"); |
| 1150 | 1148 | qhdSeries.setType("bar"); |
| 1151 | 1149 | qhdSeries.setStack("总计"); |
| 1152 | - List<Object> qhdDatas = new ArrayList<>(); | |
| 1153 | 1150 | |
| 1154 | - Series otherSeries = new Series(); | |
| 1155 | - otherSeries.setName("辖区外"); | |
| 1156 | - otherSeries.setType("bar"); | |
| 1157 | - otherSeries.setStack("总计"); | |
| 1158 | - List<Object> otherDatas = new ArrayList<>(); | |
| 1159 | - Map<String, Integer> temp = new HashMap<>(); | |
| 1160 | - for(int i = 1; i < 13; i++) { | |
| 1161 | - temp.put(i + "", 0); | |
| 1162 | - } | |
| 1163 | - | |
| 1164 | 1151 | String provinceId = mongoUtil.findId("河北省"); |
| 1165 | - if(StringUtils.isNotEmpty(provinceId)) {} | |
| 1166 | - for (Map<String, Object> data : datas) { | |
| 1167 | - if(provinceId.equals(data.get("id"))) { | |
| 1168 | - for(int i = 1; i < 13; i++) { | |
| 1169 | - qhdDatas.add(data.get(i + "")); | |
| 1152 | + if(StringUtils.isNotEmpty(provinceId)) { | |
| 1153 | + Map<Integer, Integer> qhdTemp = new HashMap<>();/** key = month . value = count*/ | |
| 1154 | + for (int i = 1; i < 13; i++) { | |
| 1155 | + qhdTemp.put(i, 0); | |
| 1156 | + } | |
| 1157 | + Map<Integer, Integer> otherTemp = new HashMap<>();/** key = month . value = count*/ | |
| 1158 | + for (int i = 1; i < 13; i++) { | |
| 1159 | + otherTemp.put(i, 0); | |
| 1160 | + } | |
| 1161 | + for (Map<String, Object> data : datas) { | |
| 1162 | + if(provinceId.equals(data.get("province_id"))) { | |
| 1163 | + for(int i = 1; i < 13; i++) { | |
| 1164 | + qhdTemp.put(i, qhdTemp.get(i) + Integer.parseInt(data.get(i + "") + "")); | |
| 1165 | + } | |
| 1166 | + } else { | |
| 1167 | + for(int i = 1; i < 13; i++) { | |
| 1168 | + otherTemp.put(i, otherTemp.get(i) + Integer.parseInt(data.get(i + "") + "")); | |
| 1169 | + } | |
| 1170 | 1170 | } |
| 1171 | - qhdSeries.setData(qhdDatas); | |
| 1172 | - } else { | |
| 1173 | - for(int i = 1; i < 13; i++) { | |
| 1174 | - temp.put(i + "", temp.get(i + "") + Integer.parseInt(data.get(i + "") + "")); | |
| 1175 | - } | |
| 1176 | 1171 | } |
| 1172 | + List<Object> qhdDatas = new ArrayList<>(); | |
| 1173 | + Set<Map.Entry<Integer, Integer>> entries = qhdTemp.entrySet(); | |
| 1174 | + for (Map.Entry<Integer, Integer> entry : entries) { | |
| 1175 | + qhdDatas.add(entry.getValue()); | |
| 1176 | + } | |
| 1177 | + qhdSeries.setData(qhdDatas); | |
| 1178 | + | |
| 1179 | + /** 设置其他辖区 */ | |
| 1180 | + Series otherSeries = new Series(); | |
| 1181 | + otherSeries.setName("辖区外"); | |
| 1182 | + otherSeries.setType("bar"); | |
| 1183 | + otherSeries.setStack("总计"); | |
| 1184 | + List<Object> otherDatas = new ArrayList<>(); | |
| 1185 | + | |
| 1186 | + Set<Map.Entry<Integer, Integer>> entries2 = otherTemp.entrySet(); | |
| 1187 | + for (Map.Entry<Integer, Integer> entry : entries2) { | |
| 1188 | + otherDatas.add(entry.getValue()); | |
| 1189 | + } | |
| 1190 | + otherSeries.setData(otherDatas); | |
| 1191 | + | |
| 1192 | + series.add(qhdSeries); | |
| 1193 | + series.add(otherSeries); | |
| 1177 | 1194 | } |
| 1178 | - List<Integer> integers = CollectionUtils.transValToList(temp); | |
| 1179 | - otherDatas.addAll(integers); | |
| 1180 | - otherSeries.setData(otherDatas); | |
| 1181 | 1195 | |
| 1182 | - series.add(qhdSeries); | |
| 1183 | - series.add(otherSeries); | |
| 1184 | 1196 | return series; |
| 1185 | 1197 | } |
| 1186 | 1198 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java
View file @
37cc84b
| ... | ... | @@ -51,18 +51,9 @@ |
| 51 | 51 | * @return |
| 52 | 52 | */ |
| 53 | 53 | public List<Map<String, Object>> getListByGroup(List<Patients> patients) { |
| 54 | - Map<String, Integer> codeMap = new HashMap<>(); /** key为 id_month */ | |
| 54 | + Map<String, Integer> codeMap = new HashMap<>(); /** key为 provinceId_cityId_areaId_month */ | |
| 55 | + Map<Integer, Integer> otherMap = new HashMap<>(); /** key为 month */ | |
| 55 | 56 | |
| 56 | - Map<String, Integer> otherMonthMap = new HashMap<>(); | |
| 57 | - for (int i = 1; i <= 12; i++) { | |
| 58 | - otherMonthMap.put(i + "", 0); | |
| 59 | - } | |
| 60 | - | |
| 61 | - Integer otherCount = 0; | |
| 62 | - /* for (Patients patient : patients) { | |
| 63 | - System.out.println("month:" + DateUtil.getMonth(patient.getBookbuildingDate()) + "\tprovinceId: " + patient.getProvinceId() | |
| 64 | - + "\tcityId: " + patient.getCityId() + "\tareaId:" + patient.getAreaId()); | |
| 65 | - }*/ | |
| 66 | 57 | for (Patients patient : patients) { |
| 67 | 58 | Date bookbuildingDate = patient.getBookbuildingDate(); |
| 68 | 59 | if(bookbuildingDate == null) { |
| 69 | 60 | |
| 70 | 61 | |
| 71 | 62 | |
| 72 | 63 | |
| 73 | 64 | |
| ... | ... | @@ -75,30 +66,84 @@ |
| 75 | 66 | Integer month = DateUtil.getMonth(bookbuildingDate); |
| 76 | 67 | |
| 77 | 68 | if (StringUtils.isEmpty(provinceId) || StringUtils.isEmpty(cityId) || StringUtils.isEmpty(areaId)) { |
| 78 | - otherMonthMap.put(month + "", otherMonthMap.get(month + "") + 1); | |
| 79 | - ++otherCount; | |
| 69 | + if(otherMap.containsKey(month)) { | |
| 70 | + otherMap.put(month, otherMap.get(month) + 1); | |
| 71 | + } else { | |
| 72 | + otherMap.put(month, 1); | |
| 73 | + } | |
| 80 | 74 | continue; |
| 81 | 75 | } |
| 82 | 76 | |
| 83 | - if(codeMap.containsKey(provinceId + "_" + month)) { | |
| 84 | - codeMap.put(provinceId + "_" + month, codeMap.get(provinceId + "_" + month) + 1); | |
| 77 | + String key = provinceId + "_" + cityId + "_" + areaId + "_" + month; | |
| 78 | + if(codeMap.containsKey(key)) { | |
| 79 | + codeMap.put(key, codeMap.get(key) + 1); | |
| 85 | 80 | } else { |
| 86 | - codeMap.put(provinceId + "_" + month, 1); | |
| 81 | + codeMap.put(key, 1); | |
| 87 | 82 | } |
| 88 | - if(codeMap.containsKey(cityId + "_" + month)) { | |
| 89 | - codeMap.put(cityId + "_" + month, codeMap.get(cityId + "_" + month) + 1); | |
| 90 | - } else { | |
| 91 | - codeMap.put(cityId + "_" + month, 1); | |
| 83 | +// | |
| 84 | + } | |
| 85 | + } | |
| 86 | + | |
| 87 | + Set<Map.Entry<String, Integer>> entrySet = codeMap.entrySet(); | |
| 88 | + List<Map<String, Object>> rest = new ArrayList<>(); | |
| 89 | + for (Map.Entry<String, Integer> map : entrySet) { | |
| 90 | + String[] keys = map.getKey().split("_"); | |
| 91 | + String provinceId = keys[0]; | |
| 92 | + String cityId = keys[1]; | |
| 93 | + String areaId = keys[2]; | |
| 94 | + String month = keys[3]; | |
| 95 | + | |
| 96 | + boolean flag = true; | |
| 97 | + for (Map<String,Object> data : rest) { | |
| 98 | + if(areaId.equals(data.get("area_id"))) { /** 合并相同省市区月份数据 */ | |
| 99 | + data.put(month, map.getValue()); | |
| 100 | + flag = false; | |
| 101 | + continue; | |
| 92 | 102 | } |
| 93 | - if(codeMap.containsKey(areaId + "_" + month)) { | |
| 94 | - codeMap.put(areaId + "_" + month, codeMap.get(areaId + "_" + month) + 1); | |
| 95 | - } else { | |
| 96 | - codeMap.put(areaId + "_" + month, 1); | |
| 103 | + } | |
| 104 | + | |
| 105 | + if(flag) { | |
| 106 | + Map<String, Object> tempMap = new HashMap<>(); | |
| 107 | + tempMap.put("province_id", provinceId); | |
| 108 | + tempMap.put("province_name", findName(provinceId)); | |
| 109 | + tempMap.put("city_id", cityId); | |
| 110 | + tempMap.put("city_name", findName(cityId)); | |
| 111 | + tempMap.put("area_id", areaId); | |
| 112 | + tempMap.put("area_name", findName(areaId)); | |
| 113 | + tempMap.put("level", "建册人数"); | |
| 114 | + tempMap.put(month, map.getValue()); | |
| 115 | + rest.add(tempMap); | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | + | |
| 120 | + /** 把没有月份的数据设置为0*/ | |
| 121 | + for (Map<String, Object> map : rest) { | |
| 122 | + for (int i = 1; i < 13; i++) { | |
| 123 | + if(!map.containsKey(i + "")) { | |
| 124 | + map.put(i + "", 0); | |
| 97 | 125 | } |
| 98 | 126 | } |
| 99 | 127 | } |
| 100 | 128 | |
| 101 | - List<Map<String, Map<Integer, Integer>>> datas = new ArrayList<>(); | |
| 129 | + /** 处理其他 */ | |
| 130 | + Set<Map.Entry<Integer, Integer>> otherDatas = otherMap.entrySet(); | |
| 131 | + Map<String, Object> tempMap = new HashMap<>(); | |
| 132 | + tempMap.put("province_id", null); | |
| 133 | + tempMap.put("province_name", "其他"); | |
| 134 | + tempMap.put("city_id", null); | |
| 135 | + tempMap.put("city_name", "其他"); | |
| 136 | + tempMap.put("area_id", null); | |
| 137 | + tempMap.put("area_name", "其他"); | |
| 138 | + tempMap.put("level", "建册人数"); | |
| 139 | + for (int i = 1; i < 13; i++) { | |
| 140 | + tempMap.put(i + "", 0); | |
| 141 | + } | |
| 142 | + for (Map.Entry<Integer, Integer> data : otherDatas) { | |
| 143 | + tempMap.put(data.getKey() + "", data.getValue()); | |
| 144 | + } | |
| 145 | + rest.add(tempMap); | |
| 146 | + /* List<Map<String, Map<Integer, Integer>>> datas = new ArrayList<>(); | |
| 102 | 147 | Set<Map.Entry<String, Integer>> entries = codeMap.entrySet(); |
| 103 | 148 | for (Map.Entry<String, Integer> entry : entries) { |
| 104 | 149 | String key = entry.getKey(); |
| ... | ... | @@ -126,7 +171,7 @@ |
| 126 | 171 | tempMap.put(id, map); |
| 127 | 172 | datas.add(tempMap); |
| 128 | 173 | } |
| 129 | - } | |
| 174 | + }*/ | |
| 130 | 175 | |
| 131 | 176 | /* System.out.println("===================================== codemap ================================="); |
| 132 | 177 | Set<Map.Entry<String, Integer>> codeMapEntries = codeMap.entrySet(); |
| 133 | 178 | |
| ... | ... | @@ -141,9 +186,9 @@ |
| 141 | 186 | } |
| 142 | 187 | }*/ |
| 143 | 188 | |
| 144 | - List<Map<String, Object>> restMap = new ArrayList<>(); | |
| 189 | + /*List<Map<String, Object>> restMap = new ArrayList<>(); | |
| 145 | 190 | |
| 146 | - /** 设置没数据的月份为0 */ | |
| 191 | + *//** 设置没数据的月份为0 *//* | |
| 147 | 192 | for (Map<String, Map<Integer, Integer>> data : datas) { |
| 148 | 193 | Integer count = 0; |
| 149 | 194 | Set<Map.Entry<String, Map<Integer, Integer>>> set = data.entrySet(); |
| 150 | 195 | |
| 151 | 196 | |
| ... | ... | @@ -167,11 +212,11 @@ |
| 167 | 212 | restMap.add(tempMap); |
| 168 | 213 | } |
| 169 | 214 | } |
| 215 | +*/ | |
| 170 | 216 | |
| 171 | - | |
| 172 | 217 | /** 处理 其他 数据 */ |
| 173 | - Map<String, Object> tempMap = new HashMap<>(); | |
| 174 | - tempMap.put("count", otherCount); | |
| 218 | + /* Map<String, Object> tempMap = new HashMap<>(); | |
| 219 | + otherMonthMap.put("count", otherCount); | |
| 175 | 220 | tempMap.put("name", "其他"); |
| 176 | 221 | tempMap.put("id", null); |
| 177 | 222 | tempMap.put("parentId", -1); |
| ... | ... | @@ -182,7 +227,7 @@ |
| 182 | 227 | tempMap.put(i + "", 0); |
| 183 | 228 | } |
| 184 | 229 | } |
| 185 | - restMap.add(tempMap); | |
| 230 | + restMap.add(tempMap);*/ | |
| 186 | 231 | |
| 187 | 232 | /* for (Map<String, Map<Integer, Integer>> data : datas) { |
| 188 | 233 | System.out.println("data>>> " + data); |
| ... | ... | @@ -191,7 +236,7 @@ |
| 191 | 236 | for (Map<String, Object> map : restMap) { |
| 192 | 237 | System.out.println("rest>> " + map); |
| 193 | 238 | }*/ |
| 194 | - return restMap; | |
| 239 | + return rest; | |
| 195 | 240 | } |
| 196 | 241 | |
| 197 | 242 | private String findParentId(String key) { |