From 8731e7e0685c8b7e6b90f50161cfa548c823c9ab Mon Sep 17 00:00:00 2001 From: liquanyu Date: Wed, 9 Nov 2022 15:30:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=85=B1=E5=8D=AB=E7=94=9F=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/AreaCountController.java | 48 ++++++ .../operate/web/facade/PatientSyncMysqlFacade.java | 162 ++++++++++++++++++--- 2 files changed, 186 insertions(+), 24 deletions(-) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java index 6125cc6..b2c408a 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java @@ -600,6 +600,54 @@ public class AreaCountController extends BaseController { } /** + * 早孕13周以前建档人数 + * @param request + * @param page + * @param limit + * @param areaId + * @param streetId + * @param type + * @param dateTime + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/getPregnantBuildCountList") + @ResponseBody + @TokenRequired + public BaseResponse getPregnantBuildCountList(HttpServletRequest request, + Integer page, Integer limit, + @RequestParam String areaId, + @RequestParam( required = false) String streetId, + @RequestParam Integer type, // 1 13周以前建档人数 2 孕产妇健康管理人数 + @RequestParam Date dateTime) { + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); + return patientSyncMysqlFacade.getPregnantBuildCountList(page,limit,areaId,streetId,dateTime,type); + } + + + /** + * 产后访视人数 + * @param request + * @param page + * @param limit + * @param areaId + * @param streetId + * @param type + * @param dateTime + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/getChFsCountList") + @ResponseBody + @TokenRequired + public BaseResponse getChFsCountList(HttpServletRequest request, + Integer page, Integer limit, + @RequestParam String areaId, + @RequestParam( required = false) String streetId, + @RequestParam Date dateTime) { + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); + return patientSyncMysqlFacade.getChFsCountList(page,limit,areaId,streetId,dateTime); + } + + /** * 公共卫生项目统计 中医指导明细 * @param request * @param provinceId diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientSyncMysqlFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientSyncMysqlFacade.java index acb9dfc..3de20c8 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientSyncMysqlFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientSyncMysqlFacade.java @@ -9,6 +9,7 @@ import com.lyms.platform.common.utils.*; import com.lyms.platform.operate.web.result.BabyCheckPageResult; import com.lyms.platform.operate.web.result.BabyPageResult; import com.lyms.platform.operate.web.service.impl.BaseServiceImpl; +import com.lyms.platform.operate.web.utils.CommonsHelper; import com.lyms.platform.operate.web.utils.ResponseUtil; import com.lyms.platform.operate.web.utils.UnitConstants; import com.lyms.platform.operate.web.utils.UnitUtils; @@ -3398,7 +3399,7 @@ public class PatientSyncMysqlFacade extends BaseServiceImpl { patientsQuery.setBuildDaysEnd(13*7); patientsQuery.setExtEnable(false); patientsQuery.setBuildTypeNot(1); - patientsQuery.setBookbuildingDateStart(startDateFirst); + patientsQuery.setBookbuildingDateStart(DateUtil.addYear(new Date(),-20)); patientsQuery.setBookbuildingDateEnd(endDate); int data15 = patientsService.queryPatientCount(patientsQuery); int lastDate15= null==hospitalDate.get("data15")?0:Integer.parseInt(hospitalDate.get("data15").toString()); @@ -3407,13 +3408,15 @@ public class PatientSyncMysqlFacade extends BaseServiceImpl { patientsQuery.setBuildDaysStart(null); patientsQuery.setBuildDaysEnd(null); - patientsQuery.setBookbuildingDateStart(startDateFirst); + patientsQuery.setBookbuildingDateEnd(endDate); int buildCount = patientsService.queryPatientCount(patientsQuery); + int allBuildCount = null==hospitalDate.get("allBuildCount")?0:Integer.parseInt(hospitalDate.get("allBuildCount").toString()); + hospitalDate.put("allBuildCount",buildCount+allBuildCount); String data15_data2="0.00"; if(Integer.parseInt(hospitalDate.get("data2").toString())!=0){ float v = (float) Integer.parseInt(hospitalDate.get("data15").toString()) / - buildCount; + allBuildCount; if(v>=1){ data15_data2="100.00"; }else { @@ -3444,14 +3447,9 @@ public class PatientSyncMysqlFacade extends BaseServiceImpl { } hospitalDate.put("data18",data17_data2+"%"); //产后访视人数 - int data19=0; - AggregationOperation match2 = Aggregation.match(Criteria - .where("hospitalId").is(hospitalId) - .and("createDate").gte(startDateFirst).lte(endDate)); - AggregationOperation group2 = Aggregation.group("pid"); - Aggregation aggregation2= Aggregation.newAggregation(match2, group2); - AggregationResults result2 = mongoTemplate.aggregate(aggregation2,"lyms_matdeliver_follow", HashMap.class); - data19=result2.getMappedResults().size(); + int data19= (int)mongoTemplate.count(new Query(Criteria. + where("hospitalId").is(hospitalId).and("visitDate").lte(endDate)),MatdeliverFollowModel.class); + int lastDate19= null==hospitalDate.get("data19")?0:Integer.parseInt(hospitalDate.get("data19").toString()); hospitalDate.put("data19",data19+lastDate19); //产后访视率% @@ -3486,19 +3484,9 @@ public class PatientSyncMysqlFacade extends BaseServiceImpl { hospitalDate.put("data23",data23+lastDate23); - //年度内儿童接收儿童中医指导的人数 - int data24=0; - AggregationOperation match24 = Aggregation.match(Criteria.where("hospitalId").is(hospitalId) - .and("yn") - .is(YnEnums.YES.getId()).and("birth").gte(end).lte(start)); - AggregationOperation group24 = Aggregation.group("buildId"); - Aggregation aggregation24= Aggregation.newAggregation(match24, group24); - AggregationResults result24 = mongoTemplate.aggregate(aggregation24,"lyms_babycheck", HashMap.class); - data24=result24.getMappedResults().size(); - -// data24 = (int) mongoTemplate.count(new Query(Criteria.where("hospitalId").is(hospitalId) -// .and("yn") -// .is(YnEnums.YES.getId()).and("birth").gte(end).lte(start)),BabyCheckModel.class); + //0-3岁儿童人数 + int data24=data5; + int lastDate24= null==hospitalDate.get("data24")?0:Integer.parseInt(hospitalDate.get("data24").toString()); hospitalDate.put("data24",data24+lastDate24); @@ -3739,6 +3727,7 @@ public class PatientSyncMysqlFacade extends BaseServiceImpl { results.add(result); } } + pageResult.setGrid(results); return RespBuilder.buildSuccess(pageResult); } return new BaseListResponse(); @@ -3812,4 +3801,129 @@ public class PatientSyncMysqlFacade extends BaseServiceImpl { .setData(results).setPageInfo(babyQuery.getPageInfo()); } + + public BaseResponse getPregnantBuildCountList(Integer page, Integer limit, String areaId, String streetId, Date dateTime, Integer type) { + List results = new ArrayList<>(); + //获得区县下的街道 + List regions = getRegions(areaId,streetId); + List hospitalIds = new ArrayList<>(); + for (BasicConfig region : regions) { + //获得街道下的医院 + List organizations = getOrganization(region.getId()); + for (Organization organization : organizations) { + String hospitalId= StringUtils.getIntToVal(organization.getId()); + hospitalIds.add(hospitalId); + } + } + + Date endDate=DateUtil.getDayLastSecond(DateUtil.getDateMonthLast(dateTime)); + PatientsQuery patientsQuery=new PatientsQuery(); + if (CollectionUtils.isNotEmpty(hospitalIds)) + { + //孕13周之前建册的人数 + + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setHospitalList(hospitalIds); + patientsQuery.setBuildDaysStart(0); + patientsQuery.setBuildDaysEnd(13*7); + patientsQuery.setExtEnable(false); + patientsQuery.setBuildTypeNot(1); + patientsQuery.setBookbuildingDateStart(DateUtil.addYear(new Date(),-20)); + patientsQuery.setBookbuildingDateEnd(endDate); + patientsQuery.setPage(page); + patientsQuery.setLimit(limit); + patientsQuery.setNeed("Need"); + if (type == 1) + { + + } + else + { + + } + List datas = patientsService.queryPatient(patientsQuery); + System.out.println(patientsQuery.convertToQuery().convertToMongoQuery().toString()); + if (CollectionUtils.isNotEmpty(datas)) + { + for (Patients model : datas) + { + Map result = new HashMap(); + result.put("username",model.getUsername()); + result.put("age",DateUtil.getAge2(model.getBirth(),model.getBookbuildingDate())); + result.put("buildWeek",DateUtil.getWeekDesc(model.getLastMenses(),model.getBookbuildingDate())); + result.put("buildDate",DateUtil.getyyyy_MM_dd(model.getBookbuildingDate())); + result.put("phone",model.getPhone()); + result.put("cardNo",model.getCardNo()); + result.put("address", CommonsHelper.getResidence(model.getProvinceId(), model.getCityId(), + model.getAreaId(), model.getStreetId(), model.getAddress(), + basicConfigService)); + String buildHospital = organizationService.getOrganization(Integer.parseInt(model.getHospitalId())).getName(); + result.put("buildHospital",buildHospital); + result.put("patientId",model.getId()); + results.add(result); + } + } + } + return new BaseListResponse().setErrorcode(0).setErrormsg("成功") + .setData(results).setPageInfo(patientsQuery.getPageInfo()); + } + + public BaseResponse getChFsCountList(Integer page, Integer limit, String areaId, String streetId, Date dateTime) { + List results = new ArrayList<>(); + //获得区县下的街道 + List regions = getRegions(areaId,streetId); + List hospitalIds = new ArrayList<>(); + for (BasicConfig region : regions) { + //获得街道下的医院 + List organizations = getOrganization(region.getId()); + for (Organization organization : organizations) { + String hospitalId= StringUtils.getIntToVal(organization.getId()); + hospitalIds.add(hospitalId); + } + } + Date endDate=DateUtil.getDayLastSecond(DateUtil.getDateMonthLast(dateTime)); + if (CollectionUtils.isNotEmpty(hospitalIds)) + { + Criteria criteria = Criteria. + where("hospitalId").in(hospitalIds).and("visitDate").lte(endDate); + + PageResult pageResult = findMongoPage(MatdeliverFollowModel.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "visitDate")), page, limit); + List followModels = (List ) pageResult.getGrid(); + if (CollectionUtils.isNotEmpty(followModels)) + { + for (MatdeliverFollowModel followModel : followModels) + { + Map result = new HashMap(); + MaternalDeliverModel maternalDeliverModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(followModel.getDeliverId())), MaternalDeliverModel.class); + + if (maternalDeliverModel == null) + { + continue; + } + Patients model = patientsService.findOnePatientById(maternalDeliverModel.getParentId()); + if (model == null) + { + continue; + } + result.put("username",model.getUsername()); + result.put("age",DateUtil.getAge2(model.getBirth(),followModel.getVisitDate())); + result.put("fsDay",DateUtil.getDays(maternalDeliverModel.getDueDate1(),followModel.getVisitDate())); + result.put("fsDate",DateUtil.getyyyy_MM_dd(followModel.getVisitDate())); + result.put("phone",model.getPhone()); + result.put("cardNo",model.getCardNo()); + result.put("address", CommonsHelper.getResidence(model.getProvinceId(), model.getCityId(), + model.getAreaId(), model.getStreetId(), model.getAddress(), + basicConfigService)); + String fsHospital = organizationService.getOrganization(Integer.parseInt(followModel.getHospitalId())).getName(); + result.put("fsHospital",fsHospital); + result.put("fsId",followModel.getId()); + results.add(result); + } + } + pageResult.setGrid(results); + return RespBuilder.buildSuccess(pageResult); + } + return new BaseListResponse(); + + } } -- 1.8.3.1