Commit c723f24f8159f0404a99d256f153d3a3f0cea275
1 parent
d3ca566eaf
Exists in
master
and in
6 other branches
写bug
Showing 4 changed files with 51 additions and 23 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
- platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/CouponMapper.java
View file @
c723f24
platform-biz-service/src/main/resources/mainOrm/master/CouponMapper.xml
View file @
c723f24
... | ... | @@ -777,5 +777,10 @@ |
777 | 777 | </foreach> |
778 | 778 | </select> |
779 | 779 | |
780 | + <select id="findAllHospitals" resultType="map"> | |
781 | + select id, name, province_id as provinceId, city_id as cityId, area_id as areaId, street_id as streetId | |
782 | + from organization | |
783 | + where yn = 1 | |
784 | + </select> | |
780 | 785 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
c723f24
... | ... | @@ -41,9 +41,9 @@ |
41 | 41 | @ResponseBody |
42 | 42 | @TokenRequired |
43 | 43 | @RequestMapping(value = "/patients", method = RequestMethod.GET) |
44 | - public BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, | |
44 | + public BaseObjectResponse patients(String provinceId, String cityId, String areaId, String streetId, | |
45 | 45 | @RequestParam Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, HttpServletRequest request) { |
46 | - return reportService.patients(provinceId, cityId, aredId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request)); | |
46 | + return reportService.patients(provinceId, cityId, areaId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request)); | |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | |
... | ... | @@ -56,9 +56,9 @@ |
56 | 56 | @ResponseBody |
57 | 57 | @TokenRequired |
58 | 58 | @RequestMapping(value = "/patients/export", method = RequestMethod.GET) |
59 | - public void patientsExport(String provinceId, String cityId, String aredId, String streetId, @RequestParam Integer statistType, | |
59 | + public void patientsExport(String provinceId, String cityId, String areaId, String streetId, @RequestParam Integer statistType, | |
60 | 60 | Integer ageType, Integer patientType, Date startDate, Date endDate, HttpServletRequest request, HttpServletResponse response) { |
61 | - reportService.patientsExport(provinceId, cityId, aredId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request), response); | |
61 | + reportService.patientsExport(provinceId, cityId, areaId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request), response); | |
62 | 62 | // reportService.patientsExport(provinceId, cityId, aredId, streetId, statistType, ageType, patientType, startDate, endDate, 1000000185, response); |
63 | 63 | } |
64 | 64 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
c723f24
... | ... | @@ -197,27 +197,48 @@ |
197 | 197 | List<String> xDatas = new ArrayList<>(); |
198 | 198 | List<Map<String, Object>> series = new ArrayList<>(); |
199 | 199 | List<String> legend = Arrays.asList("建档总数"); |
200 | - | |
201 | - List<String> patientIds = new ArrayList<>(); | |
202 | - for (Patients patient : patients) { | |
203 | - patientIds.add(patient.getId()); | |
204 | - } | |
205 | - | |
206 | - GroupOperation groupOperation = Aggregation.group("hospitalId").count().as("count"); | |
207 | - Aggregation agg = Aggregation.newAggregation(Patients.class, Aggregation.match(Criteria.where("id").in(patientIds)), groupOperation); | |
208 | - AggregationResults<Map> results = mongoTemplate.aggregate(agg, Patients.class, Map.class); | |
209 | - List<Map> mappedResults = results.getMappedResults(); | |
210 | - | |
211 | 200 | List<Object> bar = new ArrayList<>(); |
212 | - List<Object> port = new ArrayList<>(); | |
213 | 201 | Map<String, Object> barMap = new HashMap<>(); |
214 | - barMap.put("data", new ArrayList<>()); | |
215 | - Map<String, Object> portMap = new HashMap<>(); | |
216 | - portMap.put("data", new ArrayList<>()); | |
217 | - for (Map mappedResult : mappedResults) { | |
218 | - xDatas.add(couponMapper.findHospitalNameById((String) mappedResult.get("_id"))); | |
219 | - bar.add(mappedResult.get("count")); | |
202 | + | |
203 | + if(StringUtils.isNotEmpty(aredId)) { // 按照医院统计 | |
204 | + List<String> patientIds = new ArrayList<>(); | |
205 | + for (Patients patient : patients) { | |
206 | + patientIds.add(patient.getId()); | |
207 | + } | |
208 | + GroupOperation groupOperation = Aggregation.group("hospitalId").count().as("count"); | |
209 | + Aggregation agg = Aggregation.newAggregation(Patients.class, Aggregation.match(Criteria.where("id").in(patientIds)), groupOperation); | |
210 | + AggregationResults<Map> results = mongoTemplate.aggregate(agg, Patients.class, Map.class); | |
211 | + List<Map> mappedResults = results.getMappedResults(); | |
212 | + for (Map mappedResult : mappedResults) { | |
213 | + xDatas.add(couponMapper.findHospitalNameById((String) mappedResult.get("_id"))); | |
214 | + bar.add(mappedResult.get("count")); | |
215 | + } | |
216 | + } else { | |
217 | + Map<Integer, Integer> areaCountMap = new HashMap<>(); | |
218 | + List<Map<String, Object>> hospitals = couponMapper.findAllHospitals(); | |
219 | + String groupKey = StringUtils.isNotEmpty(cityId) ? "areaId" : "cityId"; // 按照区县或者市统计 | |
220 | + for (Patients patient : patients) { | |
221 | + String hospitalId = patient.getHospitalId(); | |
222 | + if(StringUtils.isEmpty(hospitalId)) { | |
223 | + continue; | |
224 | + } | |
225 | + for (Map<String, Object> map : hospitals) { | |
226 | + if(hospitalId.equals(map.get("id").toString())) { | |
227 | + Integer areaId = Integer.parseInt(map.get(groupKey).toString()); | |
228 | + if(areaCountMap.containsKey(areaId)) { | |
229 | + areaCountMap.put(areaId, areaCountMap.get(areaId) + 1); | |
230 | + } else { | |
231 | + areaCountMap.put(areaId, 1); | |
232 | + } | |
233 | + } | |
234 | + } | |
235 | + } | |
236 | + for (Map.Entry<Integer, Integer> entry : areaCountMap.entrySet()) { | |
237 | + xDatas.add(mongoUtil.findName(entry.getKey() + "")); | |
238 | + bar.add(entry.getValue()); | |
239 | + } | |
220 | 240 | } |
241 | + | |
221 | 242 | barMap.put("data", bar); |
222 | 243 | barMap.put("type", "bar"); |
223 | 244 | barMap.put("name", "建档总数"); |
... | ... | @@ -226,6 +247,7 @@ |
226 | 247 | restMap.put("legend", legend); |
227 | 248 | restMap.put("series", series); |
228 | 249 | restMap.put("xDatas", xDatas); |
250 | + | |
229 | 251 | return RespBuilder.buildSuccess(restMap); |
230 | 252 | } |
231 | 253 | |
... | ... | @@ -1243,7 +1265,6 @@ |
1243 | 1265 | } else { |
1244 | 1266 | temp.put("week", DateUtil.getWeekDesc(pt.getLastMenses(), new Date())); |
1245 | 1267 | } |
1246 | - System.out.println(pt.getBookbuildingDate().toLocaleString()); | |
1247 | 1268 | temp.put("buildWeek", DateUtil.getWeekDesc(pt.getLastMenses(), pt.getBookbuildingDate())); /** 建档孕周 */ |
1248 | 1269 | temp.put("buildDate", DateUtil.getyyyy_MM_dd(pt.getBookbuildingDate())); /** 建档日期 */ |
1249 | 1270 | temp.put("doctorName", couponMapper.getUserName(pt.getBookbuildingDoctor())); |