Commit 550cf9be617cd74ec67845396ad17442e0aed0d9
Exists in
master
and in
6 other branches
Merge remote-tracking branch 'origin/master'
Showing 4 changed files
- 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/facade/RiskReportFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
550cf9b
| ... | ... | @@ -33,7 +33,8 @@ |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * 建档统计 |
| 36 | - * @param statistType 统计环比 1=周 2=月 3=季度 4=半年 5=年 | |
| 36 | + * @param statistType 1=占比 2=环比 | |
| 37 | + * @param statistVal 1=占比 2=环比 | |
| 37 | 38 | * @param ageType 1=全部年龄 2=20岁以下 3=20-30岁 4=30-40岁 5=40岁以上 |
| 38 | 39 | * @param patientType 建档孕周 1=孕早期 2=孕中期 3=孕晚期 |
| 39 | 40 | * @return |
| ... | ... | @@ -41,9 +42,9 @@ |
| 41 | 42 | @ResponseBody |
| 42 | 43 | @TokenRequired |
| 43 | 44 | @RequestMapping(value = "/patients", method = RequestMethod.GET) |
| 44 | - public BaseObjectResponse patients(String provinceId, String cityId, String areaId, String streetId, | |
| 45 | - @RequestParam Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, HttpServletRequest request) { | |
| 46 | - return reportService.patients(provinceId, cityId, areaId, streetId, statistType, ageType, patientType, startDate, endDate, getUserId(request)); | |
| 45 | + public BaseObjectResponse patients(String provinceId, String cityId, String areaId, String streetId, Integer statistType, Integer statistVal, | |
| 46 | + Integer ageType, Integer patientType, Date startDate, Date endDate, HttpServletRequest request) { | |
| 47 | + return reportService.patients(provinceId, cityId, areaId, streetId, statistType, statistVal, ageType, patientType, startDate, endDate, getUserId(request)); | |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RiskReportFacade.java
View file @
550cf9b
| ... | ... | @@ -543,7 +543,6 @@ |
| 543 | 543 | } |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - | |
| 547 | 546 | if (addrType < 3) |
| 548 | 547 | { |
| 549 | 548 | if (CollectionUtils.isNotEmpty(list)) |
| ... | ... | @@ -564,7 +563,6 @@ |
| 564 | 563 | List<String> items = new ArrayList<>(); |
| 565 | 564 | for (Map<String, Object> addr : list) |
| 566 | 565 | { |
| 567 | - List<String> hids = new ArrayList<>(); | |
| 568 | 566 | String id = String.valueOf(addr.get("id")); |
| 569 | 567 | if (addrType == 1) |
| 570 | 568 | { |
| 571 | 569 | |
| 572 | 570 | |
| 573 | 571 | |
| ... | ... | @@ -577,30 +575,18 @@ |
| 577 | 575 | |
| 578 | 576 | //查询机构数 |
| 579 | 577 | List<Organization> orgs = organizationService.queryOrganization(idQuery); |
| 580 | - | |
| 581 | - if (CollectionUtils.isNotEmpty(orgs)) | |
| 578 | + List<String> hids = getConditionHospitalIds(currentUserHospPermissions, orgs); | |
| 579 | + Integer count = 0; | |
| 580 | + if (CollectionUtils.isNotEmpty(hids)) | |
| 582 | 581 | { |
| 583 | - for (Organization org : orgs) | |
| 584 | - { | |
| 585 | - hids.add(String.valueOf(org.getId())); | |
| 586 | - } | |
| 582 | + patientsQuery.setHospitalList(hids); | |
| 583 | + //高危等级 | |
| 584 | + patientsQuery.setrLevel(config.getId()); | |
| 585 | + count = patientsService.queryPatientCount(patientsQuery); | |
| 587 | 586 | } |
| 588 | - | |
| 589 | - PatientsQuery query1 = new PatientsQuery(); | |
| 590 | - query1.setHospitalList(hids); | |
| 591 | - query1.setYn(YnEnums.YES.getId()); | |
| 592 | - query1.setType(1); | |
| 593 | - //高危等级 | |
| 594 | - query1.setrLevel(config.getId()); | |
| 595 | - List buildType = new ArrayList(); | |
| 596 | - buildType.add(0); | |
| 597 | - buildType.add(2); | |
| 598 | - query1.setBuildTypeList(buildType); | |
| 599 | - Integer count = patientsService.queryPatientCount(query1); | |
| 600 | 587 | items.add(count == null ? "0" : String.valueOf(count)); |
| 601 | 588 | } |
| 602 | 589 | map.put("data",items); |
| 603 | - | |
| 604 | 590 | series.add(map); |
| 605 | 591 | } |
| 606 | 592 | } |
| 607 | 593 | |
| ... | ... | @@ -611,11 +597,19 @@ |
| 611 | 597 | organizationQuery.setYn(YnEnums.YES.getId()); |
| 612 | 598 | organizationQuery.setAreaId(countRequest.getAreaId()); |
| 613 | 599 | |
| 614 | - //TODO权限 | |
| 615 | - // List<Organization> press = getCurrentOrgs( countRequest, userId); | |
| 600 | + List<Integer> ids = new ArrayList<>(); | |
| 601 | + | |
| 602 | + if (CollectionUtils.isNotEmpty(currentUserHospPermissions)) | |
| 603 | + { | |
| 604 | + for (String key : currentUserHospPermissions) | |
| 605 | + { | |
| 606 | + ids.add(Integer.parseInt(key)); | |
| 607 | + } | |
| 608 | + } | |
| 609 | + organizationQuery.setIdList(ids); | |
| 616 | 610 | List<Organization> orgs = organizationService.queryOrganization(organizationQuery); |
| 617 | 611 | |
| 618 | - if (CollectionUtils.isNotEmpty(list)) | |
| 612 | + if (CollectionUtils.isNotEmpty(orgs)) | |
| 619 | 613 | { |
| 620 | 614 | for (Organization org : orgs) |
| 621 | 615 | { |
| 622 | 616 | |
| ... | ... | @@ -627,17 +621,12 @@ |
| 627 | 621 | List<String> items = new ArrayList<>(); |
| 628 | 622 | for (BasicConfig config : riskLevelConfig) |
| 629 | 623 | { |
| 630 | - PatientsQuery query1 = new PatientsQuery(); | |
| 631 | - query1.setHospitalId(String.valueOf(org.getId())); | |
| 632 | - query1.setYn(YnEnums.YES.getId()); | |
| 633 | - query1.setType(1); | |
| 624 | + | |
| 625 | + patientsQuery.setHospitalId(String.valueOf(org.getId())); | |
| 626 | + patientsQuery.setHospitalList(null); | |
| 634 | 627 | //高危等级 |
| 635 | - query1.setrLevel(config.getId()); | |
| 636 | - List buildType = new ArrayList(); | |
| 637 | - buildType.add(0); | |
| 638 | - buildType.add(2); | |
| 639 | - query1.setBuildTypeList(buildType); | |
| 640 | - Integer count = patientsService.queryPatientCount(query1); | |
| 628 | + patientsQuery.setrLevel(config.getId()); | |
| 629 | + Integer count = patientsService.queryPatientCount(patientsQuery); | |
| 641 | 630 | items.add(count == null ? "0" : String.valueOf(count)); |
| 642 | 631 | map.put("data",items); |
| 643 | 632 | } |
| ... | ... | @@ -645,7 +634,6 @@ |
| 645 | 634 | } |
| 646 | 635 | } |
| 647 | 636 | } |
| 648 | - | |
| 649 | 637 | datas.put("series",series); |
| 650 | 638 | datas.put("xAxis",xAxis); |
| 651 | 639 | datas.put("legend",titleItems); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IReportService.java
View file @
550cf9b
| ... | ... | @@ -98,7 +98,7 @@ |
| 98 | 98 | |
| 99 | 99 | BaseObjectResponse unUsedPeopleInfo(Date startDate, Date endDate, String provinceId, String cityId, String areaId, String hospitalId, Integer page, Integer limit, Integer userId); |
| 100 | 100 | |
| 101 | - BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId); | |
| 101 | + BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer statistVal, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId); | |
| 102 | 102 | |
| 103 | 103 | void patientsExport(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId, HttpServletResponse response); |
| 104 | 104 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
550cf9b
| ... | ... | @@ -190,11 +190,12 @@ |
| 190 | 190 | * @return |
| 191 | 191 | */ |
| 192 | 192 | @Override |
| 193 | - public BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, | |
| 194 | - Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId) { | |
| 193 | + public BaseObjectResponse patients(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer statistVal, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId) { | |
| 195 | 194 | List<Patients> patients = getPatients(provinceId, cityId, aredId, streetId, ageType, patientType, startDate, endDate, userId); |
| 195 | + List<Map<String, Object>> hospitals = couponMapper.findAllHospitals(); | |
| 196 | 196 | Map<String, Object> restMap = new HashMap<>(); |
| 197 | - List<Map<String, Object>> tabList = new ArrayList<>(); | |
| 197 | + List<List<String>> tabList = new ArrayList<>(); | |
| 198 | + List<String> titleList = new ArrayList<>(); | |
| 198 | 199 | List<String> xDatas = new ArrayList<>(); |
| 199 | 200 | List<Map<String, Object>> series = new ArrayList<>(); |
| 200 | 201 | List<String> legend = Arrays.asList("建档总数"); |
| ... | ... | @@ -218,7 +219,6 @@ |
| 218 | 219 | } |
| 219 | 220 | } else { |
| 220 | 221 | Map<Integer, Integer> areaCountMap = new HashMap<>(); |
| 221 | - List<Map<String, Object>> hospitals = couponMapper.findAllHospitals(); | |
| 222 | 222 | String groupKey = StringUtils.isNotEmpty(cityId) ? "areaId" : "cityId"; // 按照区县或者市统计 |
| 223 | 223 | for (Patients patient : patients) { |
| 224 | 224 | String hospitalId = patient.getHospitalId(); |
| 225 | 225 | |
| ... | ... | @@ -240,8 +240,84 @@ |
| 240 | 240 | xDatas.add(mongoUtil.findName(entry.getKey() + "")); |
| 241 | 241 | bar.add(entry.getValue()); |
| 242 | 242 | } |
| 243 | - } | |
| 244 | 243 | |
| 244 | + // 拼装tab数据 | |
| 245 | + List<Map<String, Date>> range = DateUtil.getRange(startDate, endDate); | |
| 246 | + if(StringUtils.isNotEmpty(cityId)) { // 按照区县来 | |
| 247 | + titleList.add(""); | |
| 248 | + titleList.add(""); | |
| 249 | + titleList.add(""); | |
| 250 | + for (Map<String, Date> map : range) { | |
| 251 | + titleList.add(DateUtil.getyyyy_mm(map.get("cname"))); | |
| 252 | + } | |
| 253 | + } else { // 按照城市来 | |
| 254 | + titleList.add("城市名称"); | |
| 255 | + titleList.add("机构数"); | |
| 256 | + titleList.add("统计指标(人)"); | |
| 257 | + for (Map<String, Date> map : range) { | |
| 258 | + titleList.add(DateUtil.getyyyy_mm(map.get("cname"))); | |
| 259 | + } | |
| 260 | + tabList.add(titleList); | |
| 261 | + List<Map<String, Object>> infos = new ArrayList<>(); | |
| 262 | + for (Patients patient : patients) { | |
| 263 | + for (Map<String, Object> map : hospitals) { | |
| 264 | + if(patient.getHospitalId().equals(map.get("id").toString())) { | |
| 265 | + boolean flag = true; | |
| 266 | + for (Map<String, Object> info : infos) { | |
| 267 | + if(map.get("cityId").equals(info.get("id"))) { | |
| 268 | + Set<String> hids = (Set<String>) info.get("hids"); | |
| 269 | + hids.add(patient.getHospitalId()); | |
| 270 | + for (Map<String, Date> dateMap : range) { | |
| 271 | + if(patient.getBookbuildingDate().getTime() >= dateMap.get("start").getTime() | |
| 272 | + && patient.getBookbuildingDate().getTime() < dateMap.get("end").getTime()) { | |
| 273 | + String monthKey = DateUtil.getyyyy_mm(dateMap.get("cname")); | |
| 274 | + if(info.containsKey(monthKey)) { | |
| 275 | + info.put(monthKey, (Integer) info.get(monthKey) + 1); | |
| 276 | + flag = false; | |
| 277 | + } else { | |
| 278 | + info.put(monthKey, 1); | |
| 279 | + flag = false; | |
| 280 | + } | |
| 281 | + } | |
| 282 | + } | |
| 283 | + } | |
| 284 | + } | |
| 285 | + if(flag) { | |
| 286 | + for (Map<String, Date> dateMap : range) { | |
| 287 | + if(patient.getBookbuildingDate().getTime() >= dateMap.get("start").getTime() | |
| 288 | + && patient.getBookbuildingDate().getTime() < dateMap.get("end").getTime()) { | |
| 289 | + String monthKey = DateUtil.getyyyy_mm(dateMap.get("cname")); | |
| 290 | + Map<String, Object> info = new HashMap<>(); | |
| 291 | + Set<String> hids = new HashSet<>(); | |
| 292 | + hids.add(patient.getHospitalId()); | |
| 293 | + info.put(monthKey, 1); | |
| 294 | + info.put("id", map.get("cityId")); | |
| 295 | + info.put("hids", hids); | |
| 296 | + infos.add(info); | |
| 297 | + } | |
| 298 | + } | |
| 299 | + } | |
| 300 | + } | |
| 301 | + } | |
| 302 | + } | |
| 303 | + | |
| 304 | + for (Map<String, Object> info : infos) { | |
| 305 | + List<String> tempList = new ArrayList<>(); | |
| 306 | + tempList.add(findName(info.get("id"))); | |
| 307 | + tempList.add(((Set<String>) info.get("hids")).size() + ""); | |
| 308 | + tempList.add("建档总数"); | |
| 309 | + for (Map<String, Date> map : range) { | |
| 310 | + tempList.add(info.containsKey(DateUtil.getyyyy_mm(map.get("cname"))) ? | |
| 311 | + info.get(DateUtil.getyyyy_mm(map.get("cname"))) + "" : "0"); | |
| 312 | + } | |
| 313 | + tabList.add(tempList); | |
| 314 | + } | |
| 315 | + System.out.println(tabList); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + | |
| 319 | + setTabListInfo(tabList); | |
| 320 | + | |
| 245 | 321 | barMap.put("data", bar); |
| 246 | 322 | barMap.put("type", "bar"); |
| 247 | 323 | barMap.put("name", "建档总数"); |
| ... | ... | @@ -268,6 +344,32 @@ |
| 268 | 344 | return RespBuilder.buildSuccess(restMap); |
| 269 | 345 | } |
| 270 | 346 | |
| 347 | + private void setTabListInfo(List<List<String>> tabList) { | |
| 348 | + if(CollectionUtils.isNotEmpty(tabList)) { | |
| 349 | + for (int i = 0; i < tabList.size(); i++) { | |
| 350 | + List<String> list = tabList.get(i); | |
| 351 | + int seq = 0; | |
| 352 | + if(i == 0) { | |
| 353 | + list.add(0, "序号" ); | |
| 354 | + list.add("合计"); | |
| 355 | + } else { | |
| 356 | + int count = 0; | |
| 357 | + for (int j = 3; j < list.size(); j++) { | |
| 358 | + count += Integer.parseInt(list.get(j)); | |
| 359 | + } | |
| 360 | + list.add(0, ++seq + ""); | |
| 361 | + list.add(count + ""); | |
| 362 | + } | |
| 363 | + } | |
| 364 | + } | |
| 365 | + } | |
| 366 | + | |
| 367 | + private Integer getPatientsCount(List<Patients> patients, Date start, Date end) { | |
| 368 | + Integer count = 0; | |
| 369 | + if(CollectionUtils.isNotEmpty(patients) && start != null && end != null) {} | |
| 370 | + return count; | |
| 371 | + } | |
| 372 | + | |
| 271 | 373 | @Override |
| 272 | 374 | public void patientsExport(String provinceId, String cityId, String aredId, String streetId, Integer statistType, Integer ageType, Integer patientType, Date startDate, Date endDate, Integer userId, HttpServletResponse response) { |
| 273 | 375 | List<Patients> patients = getPatients(provinceId, cityId, aredId, streetId, ageType, patientType, startDate, endDate, userId); |
| ... | ... | @@ -362,6 +464,7 @@ |
| 362 | 464 | return patients; |
| 363 | 465 | } |
| 364 | 466 | |
| 467 | + // 建档孕周 1=孕早期 2=孕中期 3=孕晚期 | |
| 365 | 468 | private void doFilter(List<Patients> patients, Integer ageType, Integer patientType) { |
| 366 | 469 | if(patientType != null) { |
| 367 | 470 | Iterator<Patients> iterator = patients.iterator(); |