From 3397c6bdd2b3aded93d627bd36ccb2766b174e3b Mon Sep 17 00:00:00 2001 From: litao Date: Wed, 5 Jul 2017 17:25:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/service/impl/PostReviewServiceImpl.java | 2 +- .../web/service/impl/ReportServiceImpl.java | 65 +++++++++++++++++++--- .../operate/web/utils/CollectionUtils.java | 11 ++++ 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PostReviewServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PostReviewServiceImpl.java index 9516e17..36f71b4 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PostReviewServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PostReviewServiceImpl.java @@ -74,7 +74,7 @@ public class PostReviewServiceImpl extends BaseServiceImpl implements IPostRevie for (PostReviewModel model : grid) { Map tempMap = new HashMap<>(); Patients p = mongoTemplate.findById(model.getParentId(), Patients.class); - tempMap.put("checkTime", model.getCheckTime()); /** 复查日期 */ + tempMap.put("checkTime", model.getCheckTime() == null ? null : DateUtil.getyyyy_MM_dd(model.getCheckTime())); /** 复查日期 */ tempMap.put("hcertificateNum", p == null ? null : p.getCardNo()); /** 证件号 */ tempMap.put("username", p == null ? null : p.getUsername()); /** 姓名 */ tempMap.put("age", p == null ? null : DateUtil.getAge(p.getBirth())); /** 年龄 */ diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java index 4c8984f..f15bc3b 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java @@ -1155,20 +1155,33 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService @Override public BaseObjectResponse getCheckNumber(Date startDate, Date endDate, Integer startWeek, Integer endWeek, Integer childBirth, Integer userId) { + List> datas = new ArrayList<>(); BaseObjectResponse rest = new BaseObjectResponse(); - Criteria criteria = Criteria.where("hospitalId").is(autoMatchFacade.getHospitalId(userId)); + String hid = autoMatchFacade.getHospitalId(userId); + + /** 查出所有符合条件的patients */ + Criteria criteria = Criteria.where("hospitalId").is(hid).and("yn").ne("0"); if(startDate != null && endDate != null) { criteria.and("bookbuildingDate").gte(startDate).lt(DateUtil.addDay(endDate, 1)); } - if(startWeek != null) { /** 末次月经 到 现在相隔的周数 */ - criteria.and("lastMenses").lt(DateUtil.addDay(DateUtil.getWeekDay(startWeek), 1)); + if(startWeek != null && endWeek != null) { /** 末次月经 到 现在相隔的周数 */ + criteria.and("lastMenses").lte(DateUtil.getWeekDay(startWeek)) + .gte(DateUtil.getWeekDay(-startWeek)); } - if(endWeek != null) { /** 末次月经 到 现在相隔的周数 */ - criteria.and("lastMenses").gte(DateUtil.addDay(DateUtil.getWeekDay(startWeek), 1)); + List patients = mongoUtil.findField(Patients.class, criteria,"id", "bookbuildingDate", "fmDate", "pid"); + List patientIds = CollectionUtils.getId(patients, "id", String.class); + if(CollectionUtils.isNotEmpty(patientIds)) { + /** 初诊数据 */ + Criteria c = Criteria.where("hospitalId").is(hid).and("parentId").in(patientIds); + List antExChuModels = mongoUtil.findField(AntExChuModel.class, c, "id", "checkTime", "parentId"); + + /** 复诊数据 */ + List antExModels = mongoUtil.findField(AntenatalExaminationModel.class, c, "id", "checkDate", "parentId"); + + /** 组装数据 */ + doMerge(datas, antExChuModels, antExModels, patients); } - List patients = mongoUtil.findField(Patients.class, criteria, "id"); - System.out.println(patients.size()); // List antExChuModels = mongoTemplate.find(antexcQuery, AntExChuModel.class); // mongoUtil.findField(AntExChuModel.class, antexcQuery, ""); @@ -1186,6 +1199,44 @@ public class ReportServiceImpl extends BaseServiceImpl implements IReportService return rest; } + private void doMerge(List> datas, List antExChuModels, List antExModels, List patients) { + for (AntExChuModel antExChuModel : antExChuModels) { + for (Patients patient : patients) { + if(patient.getId().equals(antExChuModel.getParentId())) { + Map temp = new HashMap<>(); + temp.put("pid", antExChuModel.getPid()); + temp.put("checkTime", antExChuModel.getCheckTime()); + temp.put("patientId", patient.getId()); + temp.put("bookbuildingDate", patient.getBookbuildingDate()); + temp.put("fmDate", patient.getFmDate()); + datas.add(temp); + break; + } + } + } + + for (AntenatalExaminationModel antExModel : antExModels) { + for (Patients patient : patients) { + if(patient.getId().equals(antExModel.getParentId())) { + Map temp = new HashMap<>(); + temp.put("pid", antExModel.getPid()); + temp.put("checkTime", antExModel.getCheckDate()); + temp.put("patientId", antExModel.getId()); + temp.put("bookbuildingDate", patient.getBookbuildingDate()); + temp.put("fmDate", patient.getFmDate()); + datas.add(temp); + break; + } + } + } + System.out.println(antExChuModels.size()); + System.out.println(antExModels.size()); + System.out.println(datas.size()); + for (Map data : datas) { + System.out.println(data); + } + } + private List createPatientSeries(List> datas) { List series = new ArrayList<>(); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java index 2a764dd..23d9bea 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/CollectionUtils.java @@ -1,5 +1,6 @@ package com.lyms.platform.operate.web.utils; +import com.lyms.platform.pojo.Patients; import org.apache.commons.lang3.StringUtils; import org.springframework.util.Assert; @@ -149,4 +150,14 @@ public class CollectionUtils extends org.apache.commons.collections.CollectionUt } return true; } + + public static List getId(List data, String field, Class clazz) { + List list = new ArrayList<>(); + for (Object o : data) { + Object id = ReflectUtil.invoke(o, "get" + field.substring(0, 1).toUpperCase() + field.substring(1)); + list.add((T) id); + } + return list; + } + } -- 1.8.3.1