From 06dcc557dd666080a5fa4689eabf65b8019b097c Mon Sep 17 00:00:00 2001 From: liquanyu Date: Tue, 20 Nov 2018 10:39:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=9B=B4=E4=BA=A7=E5=84=BF?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lyms/platform/common/utils/ExcelUtil.java | 108 ++++- .../com/lyms/platform/query/MatDeliverQuery.java | 13 + .../com/lyms/platform/query/PatientsQuery.java | 15 + .../web/controller/BabyBuildController.java | 39 +- .../operate/web/facade/BabyBookbuildingFacade.java | 521 ++++++++++++++++++++- .../platform/operate/web/facade/PatientFacade.java | 1 - 6 files changed, 680 insertions(+), 17 deletions(-) diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java index 78bda68..366b9da 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java @@ -408,7 +408,7 @@ public class ExcelUtil } - ws.addCell(new Label(0, values.size()+5, "实际报出日期:"+DateUtil.getyyyy_MM_dd(new Date())+" 单位负责人签字: 填表人签名: ", h1Formt)); + ws.addCell(new Label(0, values.size()+5, "实际报出日期:"+DateUtil.getyyyy_MM_dd1(new Date())+" 单位负责人签字: 填表人签名: ", h1Formt)); ws.mergeCells(0, values.size() +5, 28, values.size() + 5); @@ -422,6 +422,112 @@ public class ExcelUtil } + + + public static void writeWcBabyExclFile(String filePath,OutputStream out,List> values,List> qkValues,String titleName,String h1) + { + + File file = new File(filePath); + InputStream in = null; + Workbook wb = null; + try { + in = new FileInputStream(file); + wb = Workbook.getWorkbook(in); + + WritableWorkbook book = wb.createWorkbook(out,wb); + WritableSheet ws = book.getSheet(0); + WritableFont contentFont = new WritableFont(WritableFont.ARIAL, 12, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); + WritableCellFormat contentFormt = new WritableCellFormat(contentFont); + contentFormt.setAlignment(jxl.format.Alignment.CENTRE); + contentFormt.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); + contentFormt.setVerticalAlignment(VerticalAlignment.CENTRE); + + WritableFont title = new WritableFont(WritableFont.ARIAL, 18, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); + WritableCellFormat titleFormt = new WritableCellFormat(title); + titleFormt.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); + titleFormt.setAlignment(jxl.format.Alignment.CENTRE); + titleFormt.setVerticalAlignment(VerticalAlignment.CENTRE); + + WritableFont h1Title = new WritableFont(WritableFont.ARIAL, 12, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); + WritableCellFormat h1Formt = new WritableCellFormat(h1Title); + h1Formt.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); + h1Formt.setAlignment(Alignment.LEFT); + h1Formt.setVerticalAlignment(VerticalAlignment.CENTRE); + + Label label = new Label(0, 0, titleName,titleFormt); + ws.addCell(label); + + Label label1 = new Label(0, 1, h1,h1Formt); + ws.addCell(label1); + + int arrayIndex = 0; + for (int i = 6, len = values.size()+6; i < len; i++, arrayIndex++) + { + + Set sets = values.get(arrayIndex).keySet(); + int j = 1; + for (String key : sets) + { + String value = values.get(arrayIndex).get(key); + if (StringUtils.isNotEmpty(value) && StringUtils.isNum(value)) + { + WritableCellFormat wcfN = new WritableCellFormat(contentFont); + wcfN.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); + wcfN.setAlignment(jxl.format.Alignment.CENTRE); + wcfN.setVerticalAlignment(VerticalAlignment.CENTRE); + Number labelNF = new Number(j, i,Integer.parseInt(value), wcfN); + ws.addCell(labelNF); + } + else + { + ws.addCell(new Label(j, i,value, contentFormt)); + } + j++; + } + } + + + int arrayIndex1 = 0; + for (int i = 5, len = values.size()+5; i < len; i++, arrayIndex1++) + { + + Set sets = values.get(arrayIndex).keySet(); + int j = 13; + for (String key : sets) + { + String value = values.get(arrayIndex1).get(key); + if (StringUtils.isNotEmpty(value) && StringUtils.isNum(value)) + { + WritableCellFormat wcfN = new WritableCellFormat(contentFont); + wcfN.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN); + wcfN.setAlignment(jxl.format.Alignment.CENTRE); + wcfN.setVerticalAlignment(VerticalAlignment.CENTRE); + Number labelNF = new Number(j, i,Integer.parseInt(value), wcfN); + ws.addCell(labelNF); + } + else + { + ws.addCell(new Label(j, i,value, contentFormt)); + } + j++; + } + } + + + ws.addCell(new Label(0, 12, "实际报出日期:"+DateUtil.getyyyy_MM_dd1(new Date())+" 单位负责人签字: 填表人签字: ", h1Formt)); + + ws.mergeCells(0, 12, 14, 12); + + book.write(); + book.close(); + wb.close(); + }catch (Exception e) + { + e.printStackTrace(); + } + + } + public static void writeExclFile(String filePath,OutputStream out,List areaNams,String titleName,String area,String time,List> values) { diff --git a/platform-dal/src/main/java/com/lyms/platform/query/MatDeliverQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/MatDeliverQuery.java index 9d1c9b8..b106deb 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/MatDeliverQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/MatDeliverQuery.java @@ -115,6 +115,7 @@ public class MatDeliverQuery extends BaseQuery implements IConvertToNativeQuery //台数 private Integer tireNumber; + private List tireNumbers; //会阴情况 private String perinealCondition; @@ -149,6 +150,10 @@ public class MatDeliverQuery extends BaseQuery implements IConvertToNativeQuery condition = condition.and("tireNumber", tireNumber, MongoOper.IS); } + if (tireNumbers != null && tireNumbers.size() > 0) { + condition = condition.and("tireNumber", tireNumbers, MongoOper.IN); + } + if (perinealCondition != null) { condition = condition.and("perinealCondition", perinealCondition, MongoOper.IS); } @@ -323,6 +328,14 @@ public class MatDeliverQuery extends BaseQuery implements IConvertToNativeQuery return condition.toMongoQuery(); } + public List getTireNumbers() { + return tireNumbers; + } + + public void setTireNumbers(List tireNumbers) { + this.tireNumbers = tireNumbers; + } + public List getBabyIds() { return babyIds; } diff --git a/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java index 367f928..882fbd0 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java @@ -326,6 +326,8 @@ public class PatientsQuery extends BaseQuery implements IConvertToNativeQuery { private String areaPostRestId; private String streetPostRestId; + private String pcensusTypeId; + public MongoQuery convertToQuery() { MongoCondition condition = MongoCondition.newInstance(); @@ -339,10 +341,14 @@ public class PatientsQuery extends BaseQuery implements IConvertToNativeQuery { MongoCondition con = MongoCondition.newInstance("areaPostRestId", areaIdOrRestId, MongoOper.IS); condition = condition.orCondition(new MongoCondition[]{con1, con}); } + if (null != pcensusTypeId) { + condition = condition.and("pcensusTypeId", pcensusTypeId, MongoOper.IS); + } if (null != dueStatus) { condition = condition.and("dueStatus", dueStatus, MongoOper.IS); } + if (null != childExtAddrs && childExtAddrs.size() > 0) { condition = condition.and("childExtAddrs", childExtAddrs, MongoOper.IN); } @@ -977,6 +983,15 @@ public class PatientsQuery extends BaseQuery implements IConvertToNativeQuery { return condition.toMongoQuery(); } + + public String getPcensusTypeId() { + return pcensusTypeId; + } + + public void setPcensusTypeId(String pcensusTypeId) { + this.pcensusTypeId = pcensusTypeId; + } + public String getProvincePostRestId() { return provincePostRestId; } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java index 4caeddd..8502bec 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java @@ -492,7 +492,7 @@ public class BabyBuildController extends BaseController { * @param request * @param response * @param time - * @param ageType 1, <= 20 2, 20-=25 3,25-=30, 4,30-=35 5, >35 + * @param ageType 1, < 20 2, 20-24 3,25-29, 4,30-34 5, >=35 * @param lievType 1 城镇 2 农业 * @return */ @@ -510,5 +510,42 @@ public class BabyBuildController extends BaseController { return babyBookbuildingFacade.queryWcBabyReport(loginState.getId(), time, ageType,lievType ,provinceId,cityId); } + /** + * 获取可以导出的医院列表 + * @param request + * @param response + * @param provinceId + * @param cityId + * @return + */ + @ResponseBody + @RequestMapping(value = "/queryWcExportHospList",method = RequestMethod.GET) + @TokenRequired + public BaseResponse queryWcExportHospList(HttpServletRequest request,HttpServletResponse response, + @RequestParam(required = false)String provinceId, + @RequestParam(required = false)String cityId + ){ + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); + return babyBookbuildingFacade.queryWcExportHospList(loginState.getId() ,provinceId,cityId); + } + + + /** + * + * @param request + * @param response + * @param time + * @return + */ + @RequestMapping(value = "/exportWcBabyReportExcl",method = RequestMethod.GET) + @TokenRequired + public void exportWcBabyReportExcl(HttpServletRequest request,HttpServletResponse response, + @RequestParam(required = false)String time, + @RequestParam(required = true)String hospitalId + ){ + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); + babyBookbuildingFacade.exportWcBabyReportExcl(loginState.getId(), time, hospitalId,response); + } + } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java index 69a0e40..08355ef 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java @@ -16,6 +16,7 @@ import com.lyms.platform.common.result.BaseListResponse; import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.common.utils.*; +import com.lyms.platform.common.utils.ArrayUtils; import com.lyms.platform.common.utils.StringUtils; import com.lyms.platform.operate.web.request.*; import com.lyms.platform.operate.web.result.*; @@ -58,6 +59,8 @@ public class BabyBookbuildingFacade { public static final String HIS_VERSION = PropertiesUtils.getPropertyValue("his_version"); + public static final String CZ = "57624bf90cf23d4631523e9e"; + public static final String NC = "57624c090cf23d4631523e9f"; @Autowired private HisService hisServiceV2; @@ -90,6 +93,8 @@ public class BabyBookbuildingFacade { private OrganizationService organizationService; @Autowired + private BabyService babyService; + @Autowired private PatientsService patientsService; @Autowired @@ -3222,6 +3227,32 @@ public class BabyBookbuildingFacade { babyBookbuildingService.deleteFmHistoryRecord(mongoQuery); } + public BaseResponse queryWcExportHospList(Integer userId, String provinceId, String cityId) { + //获取用户权限医院和筛选条件的交集 + List currentUserHospPermissions = areaCountFacade.getCurrentUserHospPermissions(userId, provinceId, + cityId, null); + + List hospitals = new ArrayList<>(); + + if (CollectionUtils.isNotEmpty(currentUserHospPermissions)) + { + for (String hid : currentUserHospPermissions) + { + Organization org = organizationService.getOrganization(Integer.parseInt(hid)); + if (org != null) + { + Map map = new HashMap(); + map.put("hospitalId",org.getId()); + map.put("hospitalName",org.getName()); + hospitals.add(map); + } + } + } + + return new BaseObjectResponse() + .setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(hospitals); + } + public BaseResponse queryWcBabyReport(Integer userId, String time, Integer ageType, Integer lievType, String provinceId, String cityId) { //获取用户权限医院和筛选条件的交集 @@ -3237,28 +3268,59 @@ public class BabyBookbuildingFacade { basicQuery.setYn(YnEnums.YES.getId()); basicQuery.setTypeId("b7ea005c-dfac-4c2a-bdae-25239b3f44fd"); + + List ids = new ArrayList<>(); + + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery(); + dataPermissionsModelQuery.setUserId(userId); + List permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery); + int addrType = 0; if (org.apache.commons.lang.StringUtils.isNotEmpty(provinceId)) { - basicQuery.setParentId(provinceId); + ids = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(permissionsModels)) { + List addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class); + if (CollectionUtils.isNotEmpty(addressBeanList)) + { + for (AddressBean bean : addressBeanList) + { + if (bean != null && bean.getP() != null && bean.getP().equals(provinceId) && org.apache.commons.lang.StringUtils.isNotEmpty(bean.getC())) + { + ids.add(bean.getC()); + } + } + } + } + basicQuery.setIds(ids); addrType = 1; } if (org.apache.commons.lang.StringUtils.isNotEmpty(cityId)) { - basicQuery.setParentId(cityId); + ids = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(permissionsModels)) { + List addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class); + if (CollectionUtils.isNotEmpty(addressBeanList)) + { + for (AddressBean bean : addressBeanList) + { + if (bean != null && bean.getC() != null && bean.getC().equals(cityId) && org.apache.commons.lang.StringUtils.isNotEmpty(bean.getA())) + { + ids.add(bean.getA()); + } + } + } + } + basicQuery.setIds(ids); addrType = 2; } - //x轴标题数据 List xAxis = new ArrayList<>(); - - -// DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery(); -// dataPermissionsModelQuery.setUserId(userId); -// List permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery); - - //获取地址列表 - List configList = basicConfigService.queryBasicConfig(basicQuery); + List configList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(ids)) + { + configList = basicConfigService.queryBasicConfig(basicQuery); + } if (CollectionUtils.isNotEmpty(configList)) { for (BasicConfig addr : configList) { @@ -3307,9 +3369,32 @@ public class BabyBookbuildingFacade { if (CollectionUtils.isNotEmpty(hids)) { - zsItems.add("0"); - manItems.add("0"); - womanItems.add("0"); + BabyModelQuery babyModelQuery = new BabyModelQuery(); + if (dates != null) { + babyModelQuery.setBirthStart(DateUtil.parseYMD(dates[0])); + if (dates.length == 2) { + babyModelQuery.setBirthEnd(DateUtil.parseYMDHMS(dates[1])); + } + } + List parentIds = getBabyParentIds( ageType, lievType, hids); + if (CollectionUtils.isNotEmpty(parentIds)) + { + babyModelQuery.setParentIds(parentIds); + } + babyModelQuery.setDataStatus(false); + babyModelQuery.setBuildType(2); + babyModelQuery.setOrder("birth"); + babyModelQuery.setHospitalIdList(hids); + int zsCount = babyService.queryBabyCount(babyModelQuery); + zsItems.add(String.valueOf(zsCount)); + + babyModelQuery.setSex(1); + int manCount = babyService.queryBabyCount(babyModelQuery); + manItems.add(String.valueOf(manCount)); + + babyModelQuery.setSex(0); + int womanCount = babyService.queryBabyCount(babyModelQuery); + womanItems.add(String.valueOf(womanCount)); } else { @@ -3355,6 +3440,35 @@ public class BabyBookbuildingFacade { List hids = getConditionHospitalIds(currentUserHospPermissions, orgs); if (CollectionUtils.isNotEmpty(hids)) { + + BabyModelQuery babyModelQuery = new BabyModelQuery(); + if (dates != null) { + babyModelQuery.setBirthStart(DateUtil.parseYMD(dates[0])); + if (dates.length == 2) { + babyModelQuery.setBirthEnd(DateUtil.parseYMDHMS(dates[1])); + } + } + + List parentIds = getBabyParentIds( ageType, lievType, hids); + if (CollectionUtils.isNotEmpty(parentIds)) + { + babyModelQuery.setParentIds(parentIds); + } + + babyModelQuery.setDataStatus(false); + babyModelQuery.setBuildType(2); + babyModelQuery.setOrder("birth"); + babyModelQuery.setHospitalIdList(hids); + int zsCount = babyService.queryBabyCount(babyModelQuery); + items.add(String.valueOf(zsCount)); + + babyModelQuery.setSex(1); + int manCount = babyService.queryBabyCount(babyModelQuery); + items.add(String.valueOf(manCount)); + + babyModelQuery.setSex(0); + int womanCount = babyService.queryBabyCount(babyModelQuery); + items.add(String.valueOf(womanCount)); } else { @@ -3377,6 +3491,63 @@ public class BabyBookbuildingFacade { } + private List getBabyParentIds(Integer ageType, Integer lievType,List hids) + { + + List parentIds = new ArrayList<>(); + if (ageType != null || lievType != null) + { + //ageType 1, < 20 2, 20-24 3,25-29, 4,30-34 5, >=35 + + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setHospitalList(hids); + + if (ageType != null) + { + + switch (ageType) + { + case 1 : + patientsQuery.setFmAgeStart(0); + patientsQuery.setFmAgeEnd(19); + case 2 : + patientsQuery.setFmAgeStart(20); + patientsQuery.setFmAgeEnd(24); + case 3 : + patientsQuery.setFmAgeStart(25); + patientsQuery.setFmAgeEnd(29); + case 4 : + patientsQuery.setFmAgeStart(30); + patientsQuery.setFmAgeEnd(34); + case 5 : + patientsQuery.setFmAgeStart(35); + patientsQuery.setFmAgeEnd(100); + } + } + //lievType 1 城镇 2 农业 + if (lievType != null) + { + switch (ageType) { + case 1: + patientsQuery.setPcensusTypeId("57624bf90cf23d4631523e9e"); + case 2: + patientsQuery.setPcensusTypeId("57624c090cf23d4631523e9f"); + } + } + List patientsList = patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)) + { + for (Patients pat : patientsList) + { + parentIds.add(pat.getId()); + } + } + } + + return parentIds; + } + private List getConditionHospitalIds(List currentUserHospPermissions, List conditionHospitals) { List hids = new ArrayList<>(); @@ -3388,4 +3559,326 @@ public class BabyBookbuildingFacade { return hids; } + public void exportWcBabyReportExcl(Integer userId, String time, String hospitalId, HttpServletResponse response) { + + try { + + Organization org = organizationService.getOrganization(Integer.parseInt(hospitalId)); + + String titleName = "围产儿调查表"; + String h1 = "填报单位(签章): "+org.getName(); + String[] dates = null; + if (StringUtils.isNotEmpty(time)) { + dates = time.split(" - "); + h1+=" "+time; + } + + List> list = getWcBabyDatas(hospitalId, dates); + List> list1 = getWcQkBabyDatas(hospitalId, dates); + response.setContentType("application/force-download"); + response.setHeader("Content-Disposition", "attachment;filename=" + new String(("围产儿调查表.xls").getBytes("UTF-8"), "ISO-8859-1")); + String path = this.getClass().getResource("/").getPath()+ "whfy_wcbaby.xls"; + ExcelUtil.writeWcBabyExclFile(path, response.getOutputStream(), list,list1, titleName, h1); + + } catch (Exception e) { + ExceptionUtils.catchException(e, "exportDiagnosisReportExcl error"); + } + } + + private List> getWcQkBabyDatas(String hospitalId, String[] dates) { + + List> list = new ArrayList<>(); + //死胎,死产 + //城镇 + String czs = getNoBaby(hospitalId,CZ,dates); + String ncs = getNoBaby(hospitalId,NC,dates); + + Map map = new HashMap<>(); + map.put("czs",czs); + map.put("ncs", ncs); + list.add(map); + + //缺陷 + String czqx = getQueXianBaby(hospitalId,CZ,dates); + String ncqx = getQueXianBaby(hospitalId,CZ,dates); + + Map map1 = new HashMap<>(); + map1.put("czqx",czqx); + map1.put("ncqx", ncqx); + list.add(map1); + + Map map2 = new HashMap<>(); + map2.put("czqtsw","-"); + map2.put("ncqtsw", "-"); + list.add(map2); + + Map map3 = new HashMap<>(); + map3.put("czqtsw", czs + czqx); + map3.put("ncqtsw", ncs + ncqx); + list.add(map3); + + String czst = getTsBaby( hospitalId,CZ,dates,2); + String ncst = getTsBaby( hospitalId,NC,dates,2); + + Map map4 = new HashMap<>(); + map4.put("czst", czst); + map4.put("ncst", ncst); + list.add(map4); + + + String czdt = getTsBaby( hospitalId,CZ,dates,3,4,5,6,7,8); + String ncdt = getTsBaby( hospitalId,NC,dates,3,4,5,6,7,8); + + Map map5 = new HashMap<>(); + map5.put("czdt", czdt); + map5.put("ncdt", ncdt); + list.add(map5); + + Map map6 = new HashMap<>(); + map6.put("czhj", czs+czqx+czst+czdt); + map6.put("nchj", ncs+ncqx+ncst+ncdt); + list.add(map6); + + return list; + } + + + private String getTsBaby(String hospitalId,String type,String[] dates,Integer ...tireNumbers) { + + MatDeliverQuery matDeliverQuery1 = new MatDeliverQuery(); + matDeliverQuery1.setYn(YnEnums.YES.getId()); + if (dates != null) { + matDeliverQuery1.setCreatedStart(DateUtil.parseYMD(dates[0])); + if (dates.length == 2) { + matDeliverQuery1.setEndStart(DateUtil.parseYMDHMS(dates[1])); + } + } + matDeliverQuery1.setParentIdList(getPatientIdByPreType(hospitalId, type, null, null)); + matDeliverQuery1.setTireNumbers(Arrays.asList(tireNumbers)); + matDeliverQuery1.setFmHospital(hospitalId); + int doubleCount = matDeliverService.count(matDeliverQuery1); + return String.valueOf(doubleCount); + } + + private String getQueXianBaby(String hospitalId,String type,String[] dates) { + + BabyModelQuery babyModelQuery3 = new BabyModelQuery(); + babyModelQuery3.setDataStatus(false); + babyModelQuery3.setHospitalId(hospitalId); + babyModelQuery3.setParentIds(getPatientIdByPreType( hospitalId, type,null,null)); + if (dates != null) { + babyModelQuery3.setBirthStart(DateUtil.parseYMD(dates[0])); + if (dates.length == 2) { + babyModelQuery3.setBirthEnd(DateUtil.parseYMDHMS(dates[1])); + } + } + + //0非畸形 1畸形 + babyModelQuery3.setBuildType(2); + babyModelQuery3.setMalformation(1); + int queXianBabyCount = babyService.queryBabyCount(babyModelQuery3); + return String.valueOf(queXianBabyCount); + } + + private List> getWcBabyDatas(String hospitalId, String[] dates) { + List> list = new ArrayList<>(); + + //57624bf90cf23d4631523e9e 城镇 57624c090cf23d4631523e9f 农业 + + for (int i = 1;i <= 5;i++) + { + Integer fmAgeStart = null; + Integer fmAgeEnd = null; + switch (i) + { + case 1 : + fmAgeStart = 0; + fmAgeEnd = 19; + case 2 : + fmAgeStart = 20; + fmAgeEnd = 24; + case 3 : + fmAgeStart = 25; + fmAgeEnd = 29; + case 4 : + fmAgeStart = 30; + fmAgeEnd = 34; + case 5 : + fmAgeStart = 35; + fmAgeEnd = 100; + } + + + Map map = new HashMap<>(); + BabyModelQuery babyModelQuery = new BabyModelQuery(); + if (dates != null) { + babyModelQuery.setBirthStart(DateUtil.parseYMD(dates[0])); + if (dates.length == 2) { + babyModelQuery.setBirthEnd(DateUtil.parseYMDHMS(dates[1])); + } + } + babyModelQuery.setDataStatus(false); + babyModelQuery.setBuildType(2); + + babyModelQuery.setSex(1); + babyModelQuery.setParentIds(getPatientIdByPreType(hospitalId, CZ, fmAgeStart, fmAgeEnd)); + int cznCount = babyService.queryBabyCount(babyModelQuery); + + map.put("cznCount", String.valueOf(cznCount)); + + babyModelQuery.setSex(0); + babyModelQuery.setParentIds(getPatientIdByPreType(hospitalId, CZ, fmAgeStart, fmAgeEnd)); + int czlCount = babyService.queryBabyCount(babyModelQuery); + map.put("czlCount", String.valueOf(czlCount)); + + int czbmCount= 0; + map.put("czbmCount", String.valueOf(czbmCount)); + + + babyModelQuery.setSex(1); + babyModelQuery.setParentIds(getPatientIdByPreType(hospitalId, NC, fmAgeStart, fmAgeEnd)); + int ncnCount = babyService.queryBabyCount(babyModelQuery); + + map.put("ncnCount", String.valueOf(ncnCount)); + + babyModelQuery.setSex(0); + babyModelQuery.setParentIds(getPatientIdByPreType(hospitalId, NC, fmAgeStart, fmAgeEnd)); + int nclCount = babyService.queryBabyCount(babyModelQuery); + map.put("nclCount", String.valueOf(nclCount)); + + int ncbmCount= 0; + map.put("ncbmCount", String.valueOf(ncbmCount)); + + int hjnCount = cznCount+ncnCount; + map.put("hjnCount", String.valueOf(hjnCount)); + int hjlCount = czlCount+nclCount; + map.put("hjlCount", String.valueOf(hjlCount)); + int hjbmCount = 0; + map.put("hjbmCount", String.valueOf(hjbmCount)); + int hjCount = cznCount+ncnCount+czlCount+nclCount; + map.put("hjCount", String.valueOf(hjCount)); + + list.add(map); + } + + sumwcs(list); + + return list; + } + + private void sumwcs(List> list) { + + int cznCount = 0; + int czlCount = 0; + int czbmCount= 0; + + int ncnCount = 0; + int nclCount = 0; + int ncbmCount= 0; + + int hjnCount = 0; + int hjlCount = 0; + int hjbmCount = 0; + int hjCount = 0; + + if (CollectionUtils.isNotEmpty(list)) + { + for (Map map : list) + { + cznCount += Integer.parseInt(map.get("cznCount")); + czlCount += Integer.parseInt(map.get("czlCount")); + czbmCount += Integer.parseInt(map.get("czbmCount")); + ncnCount += Integer.parseInt(map.get("ncnCount")); + nclCount += Integer.parseInt(map.get("nclCount")); + ncbmCount += Integer.parseInt(map.get("ncbmCount")); + hjnCount += Integer.parseInt(map.get("hjnCount")); + hjlCount += Integer.parseInt(map.get("hjlCount")); + hjbmCount += Integer.parseInt(map.get("hjbmCount")); + hjCount += Integer.parseInt(map.get("hjCount")); + } + } + Map dataMap = new LinkedHashMap<>(); + dataMap.put("cznCount",String.valueOf(cznCount)); + dataMap.put("czlCount", String.valueOf(czlCount)); + dataMap.put("czbmCount", String.valueOf(czbmCount)); + dataMap.put("ncnCount", String.valueOf(ncnCount)); + dataMap.put("nclCount", String.valueOf(nclCount)); + dataMap.put("ncbmCount", String.valueOf(ncbmCount)); + dataMap.put("hjnCount", String.valueOf(hjnCount)); + dataMap.put("hjlCount",String.valueOf(hjlCount)); + dataMap.put("hjbmCount",String.valueOf(hjbmCount)); + dataMap.put("hjCount",String.valueOf(hjCount)); + + list.add(dataMap); + } + + private String getNoBaby(String hospitalId,String type,String[] dates) + { + List PregnancyOuts = new ArrayList<>(); + PregnancyOuts.add("1"); + PregnancyOuts.add("3"); + + MatDeliverQuery matDeliverQuery10 = new MatDeliverQuery(); + matDeliverQuery10.setYn(YnEnums.YES.getId()); + matDeliverQuery10.setParentIdList(getPatientIdByPreType(hospitalId, type, 0, 100)); + if (dates != null) { + matDeliverQuery10.setCreatedStart(DateUtil.parseYMD(dates[0])); + if (dates.length == 2) { + matDeliverQuery10.setEndStart(DateUtil.parseYMDHMS(dates[1])); + } + } + + matDeliverQuery10.setPregnancyOuts(PregnancyOuts); + matDeliverQuery10.setFmHospital(hospitalId); + int babySiChanCount = 0; + int babySiTaiCount = 0; + List babySiWangList = matDeliverService.query(matDeliverQuery10); + if (com.lyms.platform.operate.web.utils.CollectionUtils.isNotEmpty(babySiWangList)) + { + for (MaternalDeliverModel model : babySiWangList) + { + List babies = model.getBaby(); + if (com.lyms.platform.operate.web.utils.CollectionUtils.isNotEmpty(babies)) + { + for (MaternalDeliverModel.Baby baby : babies) + { + if (baby.getPregnancyOut() != null && "3".equals(baby.getPregnancyOut()) ) + { + babySiChanCount++; + } + else if (baby.getPregnancyOut() != null && "1".equals(baby.getPregnancyOut())) + { + babySiTaiCount++; + } + } + } + } + } + babySiWangList.clear(); + return String.valueOf(babySiChanCount+babySiTaiCount); + } + + private List getPatientIdByPreType(String hospitalId,String type,Integer ageStart,Integer ageEnd) + { + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setHospitalId(hospitalId); + patientsQuery.setPcensusTypeId(type); + patientsQuery.setFmAgeStart(ageStart); + patientsQuery.setFmAgeEnd(ageEnd); + patientsQuery.setType(3); + + List parentIds = new ArrayList<>(); + List patientsList = patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)) + { + for (Patients pat : patientsList) + { + parentIds.add(pat.getId()); + } + } + return parentIds; + } + + } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java index f899844..8ca31fe 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java @@ -636,7 +636,6 @@ public class PatientFacade { //查询符合条件的孕妇 StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); stopWatch.start(); - System.out.println("==========" + patientsQuery.convertToQuery().convertToMongoQuery()); List patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); stopWatch.stop(); -- 1.8.3.1