Commit ec9772cded4c07a3a811db268ff627bad9ece470
1 parent
10e8ce53be
Exists in
master
and in
1 other branch
update
Showing 2 changed files with 70 additions and 21 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PremaritalCheckupController.java
View file @
ec9772c
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | import org.springframework.web.bind.annotation.*; |
16 | 16 | |
17 | 17 | import javax.servlet.http.HttpServletRequest; |
18 | +import javax.servlet.http.HttpServletResponse; | |
18 | 19 | import javax.validation.Valid; |
19 | 20 | |
20 | 21 | /** |
21 | 22 | |
22 | 23 | |
... | ... | @@ -87,8 +88,21 @@ |
87 | 88 | @TokenRequired |
88 | 89 | public BaseListResponse queryPremaritalCheckup(@Valid PremaritalCheckupQueryRequest queryRequest, |
89 | 90 | HttpServletRequest request){ |
91 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
92 | + return premaritalCheckupFacade.queryPremaritalCheckup(queryRequest,loginState.getId()); | |
93 | + } | |
90 | 94 | |
91 | - return premaritalCheckupFacade.queryPremaritalCheckup(queryRequest); | |
95 | + @RequestMapping(value = "/premaritalCheckupExport", method = RequestMethod.GET) | |
96 | + @ResponseBody | |
97 | + @TokenRequired | |
98 | + public void premaritalCheckupExport(@Valid PremaritalCheckupQueryRequest queryRequest, | |
99 | + HttpServletResponse response, | |
100 | + HttpServletRequest request) { | |
101 | + //获取当前登录用户ID | |
102 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
103 | + premaritalCheckupFacade.premaritalCheckupExport(queryRequest,loginState.getId(),response); | |
92 | 104 | } |
105 | + | |
106 | + | |
93 | 107 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/FolicAcidFacade.java
View file @
ec9772c
... | ... | @@ -386,28 +386,30 @@ |
386 | 386 | //叶酸发放导出 |
387 | 387 | public void folicAcidExport(FolicAcidQueryRequest queryRequest,Integer userId,HttpServletResponse response){ |
388 | 388 | OutputStream out = null; |
389 | - List<Map<String,Object>> list = new ArrayList<>(); | |
390 | - | |
391 | - List<Organization> organizationList = new ArrayList<>(); | |
392 | 389 | try { |
393 | - FolicAcidQuery query = new FolicAcidQuery(); | |
394 | - query.setYn(YnEnums.YES.getId()); | |
395 | - String hospitalId = autoMatchFacade.getHospitalId(userId); | |
396 | - query.setHospitalId(hospitalId); | |
390 | + List<Map<String,Object>> list = new ArrayList<>(); | |
397 | 391 | |
392 | + List<Organization> organizationList = null; | |
393 | + | |
394 | + FolicAcidQuery folicAcidQuery = new FolicAcidQuery(); | |
395 | + folicAcidQuery.setYn(YnEnums.YES.getId()); | |
396 | + folicAcidQuery.setPage(queryRequest.getPage()); | |
397 | + folicAcidQuery.setLimit(queryRequest.getLimit()); | |
398 | + folicAcidQuery.setNeed("y"); | |
399 | + | |
398 | 400 | if(StringUtils.isNotEmpty(queryRequest.getDrawTime())){ |
399 | 401 | String[] dates = queryRequest.getDrawTime().split(" - "); |
400 | - query.setDrawTimeStart(DateUtil.parseYMD(dates[0])); | |
402 | + folicAcidQuery.setDrawTimeStart(DateUtil.parseYMD(dates[0])); | |
401 | 403 | if(dates.length>=2){ |
402 | 404 | Date date= DateUtil.parseYMD(dates[1]); |
403 | 405 | if(null!=date){ |
404 | 406 | long d = date.getTime() + 86398000; |
405 | 407 | date = new Date(d); |
406 | 408 | } |
407 | - query.setDrawTimeEnd(date); | |
409 | + folicAcidQuery.setDrawTimeEnd(date); | |
408 | 410 | } |
409 | 411 | } |
410 | - query.setHighRisk(queryRequest.getHighRisk()); | |
412 | + folicAcidQuery.setHighRisk(queryRequest.getHighRisk()); | |
411 | 413 | |
412 | 414 | //省市区筛选机构 |
413 | 415 | if (StringUtils.isNotEmpty(queryRequest.getProvinceId()) || StringUtils.isNotEmpty(queryRequest.getCityId()) || |
414 | 416 | |
415 | 417 | |
416 | 418 | |
417 | 419 | |
418 | 420 | |
419 | 421 | |
420 | 422 | |
... | ... | @@ -417,31 +419,65 @@ |
417 | 419 | organizationQuery.setProvinceId(queryRequest.getProvinceId()); |
418 | 420 | organizationQuery.setCityId(queryRequest.getCityId()); |
419 | 421 | organizationQuery.setAreaId(queryRequest.getAreaId()); |
422 | + organizationList = new ArrayList<>(); | |
420 | 423 | organizationList = organizationService.queryHospitals(organizationQuery); |
421 | 424 | } |
422 | - List<String> hospitalIds = new ArrayList<>(); | |
423 | 425 | |
424 | - if (CollectionUtils.isNotEmpty(organizationList)){ | |
425 | - for (Organization hospital : organizationList){ | |
426 | - hospitalIds.add(String.valueOf(hospital.getId())); | |
426 | + List<String> hospitalList = null; | |
427 | + //判断当前用户是否有区域权限 | |
428 | + if (userId!=null){ | |
429 | + hospitalList = new ArrayList<>(); | |
430 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
431 | + if(null!=hospital){ | |
432 | + //本院 | |
433 | + hospitalList.add(hospital); | |
427 | 434 | } |
428 | - if (CollectionUtils.isNotEmpty(hospitalIds)){ | |
429 | - query.setHospitalList(hospitalIds); | |
435 | + //查询用户是否有区域权限 | |
436 | + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery(); | |
437 | + dataPermissionsModelQuery.setUserId(userId); | |
438 | + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery); | |
439 | + if (CollectionUtils.isNotEmpty(permissionsModels)) { | |
440 | + Set<String> set = permissionsModels.get(0).getData().keySet(); | |
441 | + Iterator<String> it = set.iterator(); | |
442 | + while (it.hasNext()) { | |
443 | + String id = it.next(); | |
444 | + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(id) && !hospitalList.contains(id)) { | |
445 | + hospitalList.add(id); | |
446 | + } | |
447 | + } | |
430 | 448 | } |
449 | + if (StringUtils.isNotEmpty(queryRequest.getHospitalId())){ | |
450 | + List<String> orgId = new ArrayList<>(); | |
451 | + orgId.add(queryRequest.getHospitalId()); | |
452 | + hospitalList.retainAll(orgId); | |
453 | + } | |
454 | + | |
455 | + if (organizationList!=null){ | |
456 | + List<String> orgId = new ArrayList<>(); | |
457 | + if (CollectionUtils.isNotEmpty(organizationList)) { | |
458 | + for (Organization org : organizationList) { | |
459 | + if (null != org.getId()) { | |
460 | + orgId.add(org.getId() + ""); | |
461 | + } | |
462 | + } | |
463 | + } | |
464 | + hospitalList.retainAll(orgId); | |
465 | + } | |
466 | + folicAcidQuery.setHospitalList(hospitalList); | |
431 | 467 | } |
432 | - List<FolicAcid> folicAcidList = folicAcidService.queryFolicAcid(query); | |
468 | + List<FolicAcid> folicAcidList = folicAcidService.queryFolicAcid(folicAcidQuery); | |
433 | 469 | if (CollectionUtils.isNotEmpty(folicAcidList)){ |
434 | 470 | for (FolicAcid data : folicAcidList){ |
435 | 471 | Map<String,Object> map = new HashMap<>(); |
436 | 472 | if (StringUtils.isNotEmpty(data.getParentId())){ |
437 | - ResidentsArchiveModel model = residentsArchiveService.getResident(data.getId()); | |
473 | + ResidentsArchiveModel model = residentsArchiveService.getResident(data.getParentId()); | |
438 | 474 | map.put("certificateNum", model.getCertificateNum()); |
439 | 475 | map.put("username", model.getUsername()); |
440 | 476 | map.put("phone", model.getPhone()); |
441 | 477 | map.put("residence", CommonsHelper.getResidence(model.getProvinceId(), model.getCityId(), |
442 | 478 | model.getAreaId(), model.getStreetId(), model.getAddress(), basicConfigService)); |
443 | 479 | } |
444 | - map.put("drawTime", data.getDrawTime()); | |
480 | + map.put("drawTime", DateUtil.getyyyy_MM_dd(data.getDrawTime())); | |
445 | 481 | map.put("drawCount", data.getDrawCount()); |
446 | 482 | if (data.getPregnancyType()!=null){ |
447 | 483 | if (data.getPregnancyType()==1){ |
... | ... | @@ -471,7 +507,6 @@ |
471 | 507 | cnames.put("highRisk","高危因素"); |
472 | 508 | cnames.put("hospitalName","发放单位"); |
473 | 509 | cnames.put("operator","发放人"); |
474 | - | |
475 | 510 | response.setContentType("application/octet-stream"); |
476 | 511 | response.setHeader("Content-Disposition", "attachment;fileName=" + "yesuan.xls"); |
477 | 512 | ExcelUtil.toExcel(out, list, cnames); |