Commit eecab34fe1cfc3dc797112f5d784ac52879e31d5

Authored by wtt
1 parent 593b239037

婚检孕检统计导出

Showing 3 changed files with 159 additions and 41 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PreEugenicsBaseController.java View file @ eecab34
... ... @@ -196,6 +196,20 @@
196 196 return iPreEugenicsService.getRcCount(time, getUserId(request));
197 197 }
198 198  
  199 + /**
  200 + * 获取 乡镇婚检孕检统计
  201 + *
  202 + * @param time
  203 + * @param request
  204 + * @Author: 武涛涛
  205 + * @Date: 2020/9/24 16:17
  206 + */
  207 + @RequestMapping(method = RequestMethod.GET, value = "/getHjYjList")
  208 + @ResponseBody
  209 + @TokenRequired
  210 + public BaseObjectResponse getHjYjList(@RequestParam String time, HttpServletRequest request) {
  211 + return iPreEugenicsService.getHjYjList(time, getUserId(request));
  212 + }
199 213  
200 214 /**
201 215 * 导出数据
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IPreEugenicsService.java View file @ eecab34
... ... @@ -21,6 +21,8 @@
21 21  
22 22 BaseObjectResponse getRcCount(String time, Integer userId);
23 23  
  24 + BaseObjectResponse getHjYjList(String time, Integer userId);
  25 +
24 26 void exportRcCount(String time, Integer userId, HttpServletResponse response);
25 27 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PreEugebicsServiceImpl.java View file @ eecab34
... ... @@ -3,6 +3,7 @@
3 3 import java.util.*;
4 4  
5 5 import com.lyms.hospitalapi.lcfy.LisService;
  6 +import com.lyms.platform.biz.service.PremaritalCheckupService;
6 7 import com.lyms.platform.biz.service.ResidentsArchiveService;
7 8 import com.lyms.platform.common.enums.YnEnums;
8 9 import com.lyms.platform.common.result.BaseObjectResponse;
... ... @@ -15,6 +16,8 @@
15 16 import com.lyms.platform.permission.service.OrganizationService;
16 17 import com.lyms.platform.permission.service.UsersService;
17 18 import com.lyms.platform.pojo.BasicConfig;
  19 +import com.lyms.platform.pojo.PremaritalCheckup;
  20 +import com.lyms.platform.query.PremaritalCheckupQuery;
18 21 import com.lyms.platform.query.ResidentsArchiveQuery;
19 22 import org.apache.commons.collections.CollectionUtils;
20 23 import org.springframework.beans.BeanUtils;
... ... @@ -75,7 +78,8 @@
75 78 @Autowired
76 79 private ResidentsArchiveService residentsArchiveService;
77 80  
78   -
  81 + @Autowired
  82 + private PremaritalCheckupService premaritalCheckupService;
79 83 /**
80 84 * 根据身份证号获取对应的孕前优生信息
81 85 *
... ... @@ -101,7 +105,7 @@
101 105 query.addCriteria(Criteria.where("code").is(code));
102 106 }
103 107  
104   - List<PreEugenicsBaseModel> list = mongoTemplate.find(query, PreEugenicsBaseModel.class);
  108 + List <PreEugenicsBaseModel> list = mongoTemplate.find(query, PreEugenicsBaseModel.class);
105 109 if (CollectionUtils.isEmpty(list)) {
106 110  
107 111 PreEugenicsBaseModel one = new PreEugenicsBaseModel();
... ... @@ -114,8 +118,7 @@
114 118 }
115 119  
116 120 ////男
117   - if (model != null && "5d0b782f-b61b-441b-b8c5-4bf55eece273".equals(model.getSex()))
118   - {
  121 + if (model != null && "5d0b782f-b61b-441b-b8c5-4bf55eece273".equals(model.getSex())) {
119 122 //男性基本信息
120 123 one.setHusbandName(model.getUsername());
121 124 one.setHusbandNation(model.getNationId());
... ... @@ -143,7 +146,7 @@
143 146 one.setHusbandCurrentStreet(model.getStreetId());
144 147 one.setHusbandCurrentAddress(model.getAddress());
145 148  
146   - } else if (model != null){
  149 + } else if (model != null) {
147 150  
148 151 //女性性基本信息
149 152 one.setWifeName(model.getUsername());
... ... @@ -315,8 +318,8 @@
315 318 long count = mongoTemplate.count(query, PreEugenicsBaseModel.class);
316 319 param.mysqlBuild((int) count);
317 320 query.skip(param.getOffset()).limit(param.getLimit());
318   - List<PreEugenicsBaseListResult> results = new LinkedList<>();
319   - List<PreEugenicsBaseModel> preEugenicsBaseModels = mongoTemplate.find(query, PreEugenicsBaseModel.class);
  321 + List <PreEugenicsBaseListResult> results = new LinkedList <>();
  322 + List <PreEugenicsBaseModel> preEugenicsBaseModels = mongoTemplate.find(query, PreEugenicsBaseModel.class);
320 323 for (PreEugenicsBaseModel model : preEugenicsBaseModels) {
321 324 PreEugenicsBaseListResult result = getPreEugenicsBaseListResult(model);
322 325 results.add(result);
... ... @@ -479,7 +482,7 @@
479 482 }
480 483  
481 484  
482   - private void setDoctorName(Map<String, Object> map) {
  485 + private void setDoctorName(Map <String, Object> map) {
483 486 if (map != null && map.size() > 0 && map.get("doctor") != null) {
484 487 String doctor = String.valueOf(map.get("doctor"));
485 488 String doctorStr = CommonsHelper.getUserName(doctor, usersService);
486 489  
487 490  
488 491  
489 492  
... ... @@ -553,16 +556,119 @@
553 556 @Override
554 557 public BaseObjectResponse getRcCount(String time, Integer userId) {
555 558  
556   - List<Map<String,Object>> datas = getDatas(time, userId);
  559 + List <Map <String, Object>> datas = getDatas(time, userId);
557 560  
558   - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas);
  561 + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas);
559 562 }
560 563  
  564 + /**
  565 + * 获取 乡镇婚检孕检统计
  566 + *
  567 + * @param time
  568 + * @param userId
  569 + * @Author: 武涛涛
  570 + * @Date: 2020/9/24 16:18
  571 + */
561 572 @Override
  573 + public BaseObjectResponse getHjYjList(String time, Integer userId) {
  574 +
  575 + /*
  576 + 存储导出list 详情 ,只写了统计总数,没有导出详情
  577 + */
  578 + int hjAllCount = 0;
  579 + int yjAllCount = 0;
  580 +
  581 + //乡镇list 存储 乡镇名称,婚检总数,孕检总数
  582 + List <Map <String, Object>> datas = new LinkedList <>();
  583 +
  584 + //当前用户获取对应的 乡镇列表
  585 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  586 + Organization organization = organizationService.getOrganization(Integer.valueOf(hospitalId));
  587 + List <BasicConfig> items = basicConfigService.queryByParentId(organization.getAreaId());
  588 + if (CollectionUtils.isNotEmpty(items)) {
  589 + for (BasicConfig item : items) {
  590 + Map <String, Object> data = new HashMap();
  591 + data.put("name", item.getName());
  592 + /*婚检*/
  593 + List <String> residentsIds = getResidentsIds(hospitalId, item);
  594 + //通过建档 residentsIds 获取这短时间婚检孕检的男女
  595 + if(CollectionUtils.isNotEmpty(residentsIds)){
  596 + PremaritalCheckupQuery query = new PremaritalCheckupQuery();
  597 + query.setYn(YnEnums.YES.getId());
  598 + query.setHospitalId(hospitalId);
  599 + query.setParentIds(residentsIds);
  600 + if (StringUtils.isNotEmpty(time)) {
  601 + try {
  602 + query.setPremaritalUpTimeStart(DateUtil.getSNDate(time)[0]);
  603 + query.setPremaritalUpTimeEnd(DateUtil.getSNDate(time)[1]);
  604 + } catch (Exception e) {
  605 + e.printStackTrace();
  606 + }
  607 + }
  608 + List<PremaritalCheckup> hjList = premaritalCheckupService.queryPremaritalCheckup(query);
  609 + //单个乡镇婚检总数
  610 + data.put("hjCount", hjList.size());
  611 + //婚检总数
  612 + hjAllCount += hjList.size();
  613 + }
  614 +
  615 + /*孕检*/
  616 + Query yquery = new Query();
  617 + String[] arrs = time.split(" - ");
  618 + Date start = DateUtil.parseYMD(arrs[0]);
  619 + Date end = DateUtil.parseYMD(arrs[1]);
  620 + end = DateUtil.getDayLastSecond(end);
  621 + yquery.addCriteria(Criteria.where("fillDate").gte(start).lte(end));
  622 + yquery.addCriteria(Criteria.where("hyj").is(0));
  623 +// tquery.addCriteria(Criteria.where("hyj").is(1));
  624 + yquery.addCriteria(Criteria.where("hospitalId").is(hospitalId));
  625 + yquery.addCriteria(Criteria.where("wifeCurrentStreet").is(item.getId()));
  626 + List <PreEugenicsBaseModel> yjList = mongoTemplate.find(yquery, PreEugenicsBaseModel.class);
  627 + if (CollectionUtils.isNotEmpty(yjList)) {
  628 + yjAllCount += yjList.size();
  629 + data.put("yjCount", yjList.size());
  630 + }
  631 + datas.add(data);
  632 +
  633 + }
  634 + //合计
  635 + Map <String, Object> data = new HashMap();
  636 + data.put("name", "合计");
  637 + data.put("hjCount", hjAllCount);
  638 + data.put("yjCount", yjAllCount);
  639 + datas.add(data);
  640 + }
  641 +
  642 + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas);
  643 + }
  644 +
  645 + /**
  646 + * 获取乡镇,婚检建档 男女Id
  647 + * @Author: 武涛涛
  648 + * @Date: 2020/9/24 17:18
  649 + */
  650 + private List <String> getResidentsIds(String hospitalId, BasicConfig item) {
  651 + List <String> residentsIds = new ArrayList <>();
  652 + ResidentsArchiveQuery archiveQuery = new ResidentsArchiveQuery();
  653 + archiveQuery.setYn(YnEnums.YES.getId());
  654 + archiveQuery.setHospitalId(hospitalId);
  655 + archiveQuery.setStreetId(item.getId());
  656 + List<ResidentsArchiveModel> hjCounts = residentsArchiveService.queryResident(archiveQuery);
  657 + if(CollectionUtils.isNotEmpty(hjCounts)){
  658 + for (int i = 0; i < hjCounts.size(); i++) {
  659 + if(hjCounts.get(i)!=null && StringUtils.isNotEmpty(hjCounts.get(i).getId())){
  660 + residentsIds.add(hjCounts.get(i).getId());
  661 + }
  662 + }
  663 + }
  664 + return residentsIds;
  665 + }
  666 +
  667 + @Override
562 668 public void exportRcCount(String time, Integer userId, HttpServletResponse response) {
563 669  
564   - List<Map<String,Object>> datas = getDatas( time, userId);
565   - Map<String, String> cnames = new LinkedHashMap<>();
  670 + List <Map <String, Object>> datas = getDatas(time, userId);
  671 + Map <String, String> cnames = new LinkedHashMap <>();
566 672 cnames.put("name", "乡镇");
567 673 cnames.put("hjCount", "婚检");
568 674 cnames.put("yjCount", "孕检");
569 675  
570 676  
... ... @@ -572,23 +678,20 @@
572 678 }
573 679  
574 680  
575   - private List<Map<String,Object>> getDatas(String time,Integer userId)
576   - {
  681 + private List <Map <String, Object>> getDatas(String time, Integer userId) {
577 682 String hospitalId = autoMatchFacade.getHospitalId(userId);
578 683 Organization organization = organizationService.getOrganization(Integer.valueOf(hospitalId));
579   - List<Map<String,Object>> datas = new LinkedList<>();
  684 + List <Map <String, Object>> datas = new LinkedList <>();
580 685  
581 686 int hjAllCount = 0;
582 687 int yjAllCount = 0;
583 688 int tcAllCount = 0;
584 689  
585   - List<BasicConfig> items = basicConfigService.queryByParentId(organization.getAreaId());
586   - if (CollectionUtils.isNotEmpty(items))
587   - {
588   - for (BasicConfig item : items)
589   - {
590   - Map<String,Object> data = new HashMap();
591   - data.put("name",item.getName());
  690 + List <BasicConfig> items = basicConfigService.queryByParentId(organization.getAreaId());
  691 + if (CollectionUtils.isNotEmpty(items)) {
  692 + for (BasicConfig item : items) {
  693 + Map <String, Object> data = new HashMap();
  694 + data.put("name", item.getName());
592 695 //查询条件
593 696 ResidentsArchiveQuery query = new ResidentsArchiveQuery();
594 697 query.setYn(YnEnums.YES.getId());
... ... @@ -607,8 +710,8 @@
607 710 e.printStackTrace();
608 711 }
609 712 }
610   - long hjCount = sumField("lyms_resident", "checkup", query.convertToQuery().getCriteria());
611   - hjAllCount+=hjCount;
  713 + long hjCount = sumField("lyms_resident", "checkup", query.convertToQuery().getCriteria());
  714 + hjAllCount += hjCount;
612 715 Query yquery = new Query();
613 716  
614 717 String[] arrs = time.split(" - ");
615 718  
616 719  
617 720  
618 721  
619 722  
620 723  
621 724  
... ... @@ -632,45 +735,44 @@
632 735 long tcCount = mongoTemplate.count(tquery, PreEugenicsBaseModel.class);
633 736 tcAllCount += tcCount;
634 737  
635   - data.put("hjCount",hjCount);
  738 + data.put("hjCount", hjCount);
636 739 data.put("yjCount", yjCount);
637   - data.put("tcCount",tcCount);
  740 + data.put("tcCount", tcCount);
638 741  
639 742 datas.add(data);
640 743  
641 744 }
642   - Map<String,Object> data = new HashMap();
643   - data.put("name","合计");
644   - data.put("hjCount",hjAllCount);
645   - data.put("yjCount",yjAllCount);
646   - data.put("tcCount",tcAllCount);
  745 + Map <String, Object> data = new HashMap();
  746 + data.put("name", "合计");
  747 + data.put("hjCount", hjAllCount);
  748 + data.put("yjCount", yjAllCount);
  749 + data.put("tcCount", tcAllCount);
647 750 datas.add(data);
648 751 }
649 752 return datas;
650 753 }
651 754  
652   - public Integer sumField(String collection,String filedName,Criteria criteria) {
  755 + public Integer sumField(String collection, String filedName, Criteria criteria) {
653 756  
654 757 Integer total = 0;
655 758 Query query = new Query();
656   - if(criteria!=null){
  759 + if (criteria != null) {
657 760 query.addCriteria(criteria);
658 761 }
659   - List<AggregationOperation> operations = new ArrayList<>();
  762 + List <AggregationOperation> operations = new ArrayList <>();
660 763 operations.add(Aggregation.match(criteria));
661 764 operations.add(Aggregation.group().sum(filedName).as("total"));
662 765 Aggregation aggregation = Aggregation.newAggregation(operations);
663   - AggregationResults<Total> results =mongoTemplate.aggregate(aggregation, collection, Total.class);
664   - List<Total> totals = results.getMappedResults();
665   - if (CollectionUtils.isNotEmpty(totals))
666   - {
667   - total = totals.get(0).getTotal();
  766 + AggregationResults <Total> results = mongoTemplate.aggregate(aggregation, collection, Total.class);
  767 + List <Total> totals = results.getMappedResults();
  768 + if (CollectionUtils.isNotEmpty(totals)) {
  769 + total = totals.get(0).getTotal();
668 770 }
669 771 return total;
670 772 }
671 773 }
672   -class Total
673   -{
  774 +
  775 +class Total {
674 776 private int total;
675 777  
676 778 public int getTotal() {