From bef39fe38399e7ddcb411e2789dd14106415100a Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 25 Oct 2024 18:08:02 +0800 Subject: [PATCH] =?UTF-8?q?#fix:=E4=BC=98=E5=8C=96=E4=BA=94=E8=89=B2?= =?UTF-8?q?=E4=B8=93=E6=A1=88=E7=AE=A1=E7=90=86,=E5=BB=BA=E6=A1=A3?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=AF=BC=E5=87=BAExcel=E5=90=88=E5=B9=B6=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=E7=AD=89=E5=8A=9F=E8=83=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../permission/model/AppointmentQuery.java | 9 + .../resources/mainOrm/master/AppointmentMapper.xml | 3 + .../com/lyms/platform/common/utils/ExcelUtil.java | 97 +++++++- .../com/lyms/platform/pojo/AppointmentData.java | 8 +- .../com/lyms/platform/pojo/AppointmentModel.java | 10 + .../lyms/hospitalapi/dtdyrm/DtdyrmFmService.java | 5 + .../web/controller/PatientDtController.java | 246 ++++++++++++++++++++- .../operate/web/request/AppointmentExport.java | 43 ++++ 8 files changed, 406 insertions(+), 15 deletions(-) create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/AppointmentExport.java diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/AppointmentQuery.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/AppointmentQuery.java index 9c635a5..3d4a6fb 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/AppointmentQuery.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/AppointmentQuery.java @@ -9,6 +9,7 @@ public class AppointmentQuery extends BaseQuery { private String name; private String dept; private String idCard; + private String deptName; public String getIdCard() { return idCard; @@ -57,4 +58,12 @@ public class AppointmentQuery extends BaseQuery { public void setDept(String dept) { this.dept = dept; } + + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } } diff --git a/platform-biz-service/src/main/resources/mainOrm/master/AppointmentMapper.xml b/platform-biz-service/src/main/resources/mainOrm/master/AppointmentMapper.xml index 6a41346..9858ce8 100644 --- a/platform-biz-service/src/main/resources/mainOrm/master/AppointmentMapper.xml +++ b/platform-biz-service/src/main/resources/mainOrm/master/AppointmentMapper.xml @@ -39,6 +39,9 @@ and (dept like concat(#{dept},'%') or (dept like concat("产后",'%') and dept !='产后服务部')) + + and dept =#{deptName} + and =#{startTime}]]> and 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 533e3c9..6d4222c 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 @@ -1,6 +1,7 @@ package com.lyms.platform.common.utils; import java.io.*; +import java.math.BigDecimal; import java.util.*; @@ -13,6 +14,10 @@ import jxl.read.biff.BiffException; import jxl.write.*; import jxl.write.Number; import jxl.write.biff.RowsExceededException; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * Excel 工具类 @@ -162,6 +167,93 @@ public class ExcelUtil { return out; } + /** + * 合并单元格导出 + * @param out + * @param data + * @param columName + * @return + */ + public static OutputStream toExcelRegion(OutputStream out,Map> params ,Map>> data, Map columName) { + WritableWorkbook wwb; + try { + wwb = Workbook.createWorkbook(out); + // 创建一个新的工作表 + WritableSheet ws = wwb.createSheet("sheet", 0); // 创建一个工作表 + /** + * 设置单元格样式 + */ + WritableFont wf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); + + WritableCellFormat wcf = new WritableCellFormat(wf); + ws.setRowView(0, 300); // 设置指定行高 + // 设置列宽 + Iterator ite = columName.keySet().iterator(); + int i = 0; + while (ite.hasNext()) { + ws.setColumnView(i, 15); + String keyName = ite.next(); + keyName = columName.get(keyName); + ws.addCell(new Label(i, 0, keyName, wcf)); + i++; + } + //int j = 1; + int s=0; + for (Map.Entry> entry:params.entrySet()) { + // 填充数据的内容 + Map map= entry.getValue(); + List> dataList= data.get(entry.getKey()); + /* if (j==1){ + ws.addCell(new Label(0, j, String.valueOf(map.get("dept")))); + ws.addCell(new Label(1, j, String.valueOf(map.get("appointmentSumNum")))); + ws.addCell(new Label(2, j, String.valueOf(map.get("buildSumNum")))); + ws.addCell(new Label(3, j, String.valueOf(map.get("newBuildSumNum")))); + ws.addCell(new Label(4, j, String.valueOf(map.get("unBuildSumNum")))); + }else {*/ + ////新建/(总-已建档+新建档) + ws.addCell(new Label(0, s+1, String.valueOf(map.get("dept")))); + ws.addCell(new Label(1, s+1, String.valueOf(map.get("appointmentSumNum")))); + ws.addCell(new Label(2, s+1, String.valueOf(map.get("buildSumNum")))); + ws.addCell(new Label(3, s+1, String.valueOf(map.get("newBuildSumNum")))); + ws.addCell(new Label(4, s+1, String.valueOf(map.get("unBuildSumNum")))); + ws.addCell(new Label(5, s+1, new BigDecimal(String.valueOf(map.get("buildSumNum"))).multiply(new BigDecimal("100")).divide(new BigDecimal(String.valueOf(map.get("appointmentSumNum"))),2,BigDecimal.ROUND_HALF_UP).toPlainString()+"%")); + ws.addCell(new Label(6, s+1,new BigDecimal(String.valueOf(map.get("newBuildSumNum"))).multiply(new BigDecimal("100")).divide((new BigDecimal(String.valueOf(map.get("appointmentSumNum"))).add(new BigDecimal(String.valueOf(map.get("newBuildSumNum"))))).subtract(new BigDecimal(String.valueOf(map.get("buildSumNum")))),2,BigDecimal.ROUND_HALF_UP).toPlainString()+"%")); + + + + for (int t = 0, len = dataList.size(); t < len; t++){ + map=dataList.get(t); + ws.addCell(new Label(7, s+1+t, String.valueOf(map.get("doctor")))); + ws.addCell(new Label(8, s+1+t, String.valueOf(map.get("appointmentNum")!=null?map.get("appointmentNum"):0))); + ws.addCell(new Label(9, s+1+t, String.valueOf(map.get("buildNum")!=null?map.get("buildNum"):0))); + ws.addCell(new Label(10, s+1+t, String.valueOf(map.get("newBuildNum")!=null?map.get("newBuildNum"):0))); + ws.addCell(new Label(11, s+1+t, String.valueOf(map.get("unBuildNum")!=null?map.get("unBuildNum"):0))); + ws.addCell(new Label(12, s+1+t, new BigDecimal(String.valueOf(map.get("buildNum")!=null?map.get("buildNum"):0)).multiply(new BigDecimal("100")).divide(new BigDecimal(String.valueOf(map.get("appointmentNum")!=null?map.get("appointmentNum"):0)),2,BigDecimal.ROUND_HALF_UP).toPlainString()+"%")); + ws.addCell(new Label(13, s+1+t,new BigDecimal(String.valueOf(map.get("newBuildNum")!=null?map.get("newBuildNum"):0)).multiply(new BigDecimal("100")).divide((new BigDecimal(String.valueOf(map.get("appointmentNum")!=null?map.get("appointmentNum"):0)).add(new BigDecimal(String.valueOf(map.get("newBuildNum")!=null?map.get("newBuildNum"):0)))).subtract(new BigDecimal(String.valueOf(map.get("buildNum")!=null?map.get("buildNum"):0))),2,BigDecimal.ROUND_HALF_UP).toPlainString()+"%")); + } + + ws.mergeCells(0, s+1, 0, s+dataList.size()); + ws.mergeCells(1, s+1, 1, s+dataList.size()); + ws.mergeCells(2, s+1, 2, s+dataList.size()); + ws.mergeCells(3, s+1, 3, s+dataList.size()); + ws.mergeCells(4, s+1, 4, s+dataList.size()); + ws.mergeCells(5, s+1, 5, s+dataList.size()); + ws.mergeCells(6, s+1, 6, s+dataList.size()); + s+=dataList.size(); + + } + wwb.write(); + wwb.close(); + } catch (IOException e) { + e.printStackTrace(); + } catch (RowsExceededException e) { + e.printStackTrace(); + } catch (WriteException e) { + e.printStackTrace(); + } + return out; + } + //导出时隐藏列 public static OutputStream toExcelhideLie(OutputStream out, List> data, Map columName) { WritableWorkbook wwb; @@ -1186,8 +1278,7 @@ public class ExcelUtil { } - public static void main(String[] args) { - System.out.println( ExcelUtil.readExcl("F:\\美生医疗文档\\承德医院数据导入\\2023-7-2024-3-29.xls",1)); - } + + } diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentData.java b/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentData.java index b75c5d1..78a4cab 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentData.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentData.java @@ -22,7 +22,7 @@ public class AppointmentData { } public Integer getUnBuildNum() { - return unBuildNum; + return unBuildNum!=null?unBuildNum:0; } public void setUnBuildNum(Integer unBuildNum) { @@ -38,7 +38,7 @@ public class AppointmentData { } public Integer getAppointmentNum() { - return appointmentNum; + return appointmentNum!=null?appointmentNum:0; } public void setAppointmentNum(Integer appointmentNum) { @@ -46,7 +46,7 @@ public class AppointmentData { } public Integer getBuildNum() { - return buildNum; + return buildNum!=null?buildNum:0; } public void setBuildNum(Integer buildNum) { @@ -54,7 +54,7 @@ public class AppointmentData { } public Integer getNewBuildNum() { - return newBuildNum; + return newBuildNum!=null?newBuildNum:0; } public void setNewBuildNum(Integer newBuildNum) { diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentModel.java index 652c271..0045fe5 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentModel.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentModel.java @@ -26,6 +26,8 @@ public class AppointmentModel { private Integer isBuild; @Transient private Date serEndTime; + @Transient + private Date serStartTime; //服务是否到期 1为是 0为否 @Transient private Integer expire; @@ -38,6 +40,14 @@ public class AppointmentModel { @Transient private Integer appointmentNum;//未建档用户就诊次数 + public Date getSerStartTime() { + return serStartTime; + } + + public void setSerStartTime(Date serStartTime) { + this.serStartTime = serStartTime; + } + public Date getBookbuildingDate() { return bookbuildingDate; } diff --git a/platform-operate-api/src/main/java/com/lyms/hospitalapi/dtdyrm/DtdyrmFmService.java b/platform-operate-api/src/main/java/com/lyms/hospitalapi/dtdyrm/DtdyrmFmService.java index d21e7b9..a5131fc 100644 --- a/platform-operate-api/src/main/java/com/lyms/hospitalapi/dtdyrm/DtdyrmFmService.java +++ b/platform-operate-api/src/main/java/com/lyms/hospitalapi/dtdyrm/DtdyrmFmService.java @@ -599,6 +599,7 @@ public class DtdyrmFmService implements IdtdyrmFmService { cnames.put("就诊卡号", "就诊卡号"); cnames.put("就诊次数", "就诊次数"); cnames.put("姓名", "姓名"); + cnames.put("服务开始时间", "服务开始时间"); cnames.put("服务截止时间", "服务截止时间"); cnames.put("手机号", "手机号"); cnames.put("证件号", "证件号"); @@ -656,7 +657,9 @@ public class DtdyrmFmService implements IdtdyrmFmService { List patientServices = patientServiceService.queryPatientService(patientQuery); if (com.lyms.platform.operate.web.utils.CollectionUtils.isNotEmpty(patientServices)){ Date serEndTime= patientServices.get(0).getSerEndTime(); + Date serStartTime=patientServices.get(0).getUpdateDate(); appointmentModel.setSerEndTime(serEndTime); + appointmentModel.setSerStartTime(serStartTime); result.put("服务截止时间", DateUtil.gety_m_dhm(appointmentModel.getSerEndTime())); } }else { @@ -674,6 +677,8 @@ public class DtdyrmFmService implements IdtdyrmFmService { result.put("手机号", appointmentModel.getPhone()); result.put("证件号", appointmentModel.getIdCard()); result.put("出生日期",appointmentModel.getAge()); + result.put("服务开始时间",DateUtil.gety_m_dhm(appointmentModel.getSerStartTime())); + result.put("服务截至时间",DateUtil.gety_m_dhm(appointmentModel.getSerEndTime())); result.put("建档时间",DateUtil.getYyyyMmDd(appointmentModel.getBookbuildingDate())); result.put("就诊时间",DateUtil.gety_m_dhm(appointmentModel.getCheckTime())); result.put("就诊医生",appointmentModel.getDoctor()); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientDtController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientDtController.java index b5d673d..3819c47 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientDtController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientDtController.java @@ -11,10 +11,7 @@ import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.common.result.CommonResult; import com.lyms.platform.common.utils.*; import com.lyms.platform.operate.web.facade.*; -import com.lyms.platform.operate.web.request.AntExAddRequest; -import com.lyms.platform.operate.web.request.AntExQueryRequest; -import com.lyms.platform.operate.web.request.AntenatalExaminationQueryRequest; -import com.lyms.platform.operate.web.request.PatientQueryRequest; +import com.lyms.platform.operate.web.request.*; import com.lyms.platform.operate.web.result.HighScoreResult; import com.lyms.platform.operate.web.service.PatientWeightService; import com.lyms.platform.operate.web.utils.CollectionUtils; @@ -37,6 +34,8 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.io.OutputStream; import java.util.*; /** @@ -707,11 +706,12 @@ public class PatientDtController extends BaseController { PatientServiceQuery patientQuery = new PatientServiceQuery(); patientQuery.setParentid(patients.getId()); patientQuery.setSerType(1); - List patientServices = patientServiceService.queryPatientService(patientQuery); if (CollectionUtils.isNotEmpty(patientServices)){ Date serEndTime= patientServices.get(0).getSerEndTime(); + Date serStartTime=patientServices.get(0).getUpdateDate(); appointmentModel.setSerEndTime(serEndTime); + appointmentModel.setSerStartTime(serStartTime); if (serEndTime.compareTo(date)>0){ appointmentModel.setExpire(0); }else { @@ -782,6 +782,118 @@ public class PatientDtController extends BaseController { return baseResponse; } + /** + * 预约统计管理科室统计列表 + * @param authorization + * @param doctor + * @param startTime + * @param endTime + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/dt/appointment/dept/statistics") + @ResponseBody + public BaseResponse appointmentDeptStatistics(@RequestHeader("Authorization")String authorization, + @RequestParam String doctor, + @RequestParam String startTime, + @RequestParam String endTime){ + if (!authorization.contains(Authorization)){ + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + BaseResponse baseResponse=new BaseResponse(); + startTime=startTime+" 00:00:00"; + endTime=endTime+" 23:59:59"; + String dept=null; + //只有护士长和主任可以看统计(目前) + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){ + dept="产科"; + }else { + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); + } + AppointmentQuery appointmentQuery=new AppointmentQuery(); + appointmentQuery.setStartTime(startTime); + appointmentQuery.setEndTime(endTime); + appointmentQuery.setDept(dept); + List modelList= appointmentService.queryAppointment(appointmentQuery); + if (CollectionUtils.isNotEmpty(modelList)){ + Map params=new HashMap(); + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + for (int i = 0,j=modelList.size(); i < j; i++) { + AppointmentModel appointmentModel= modelList.get(i); + String depts=appointmentModel.getDept(); + if (StringUtils.isNotEmpty(depts)&&StringUtils.isNotEmpty(appointmentModel.getDoctor())){ + AppointmentData appointmentData= params.get(depts); + if (appointmentData==null){ + appointmentData=new AppointmentData(); + } + appointmentData.setDept(depts); + String idCard=appointmentModel.getIdCard(); + String phone=appointmentModel.getPhone(); + String username=appointmentModel.getName(); + if (StringUtils.isNotEmpty(idCard)){ + patientsQuery.setCardNo(idCard); + }else { + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){ + patientsQuery.setName(username); + patientsQuery.setPhone(phone); + }else { + appointmentModel.setIsBuild(0); + //未建档 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1); + } + } + if (appointmentModel.getIsBuild()==null){ + List patientsList= patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)){ + //已经建档 + //新建档人数等于当天建档人数 + Patients patients= patientsList.get(0); + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){ + appointmentData.setNewBuildNum(appointmentData.getNewBuildNum()!=null?appointmentData.getNewBuildNum()+1:1); + } + appointmentData.setBuildNum(appointmentData.getBuildNum()!=null?appointmentData.getBuildNum()+1:1); + }else { + //未建档 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1); + } + } + appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1); + params.put(depts,appointmentData); + } + } + // 使用TreeMap进行排序 + Map sortedMap = new TreeMap<>(new ChineseComparator()); + sortedMap.putAll(params); + baseResponse.setObject(sortedMap); + } + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + return baseResponse; + } + // 自定义Comparator,用于按照定义好的顺序排序 + static class ChineseComparator implements Comparator { + @Override + public int compare(String s1, String s2) { + try { + return getPinyin(s1).compareTo(getPinyin(s2)); + }catch (Exception e){ + System.out.println(s1+" "+s2); + } + return 0; + } + + } + private static Integer getPinyin(String s) { + Map map = new HashMap<>(); + map.put("产后康复门诊", 10); + map.put("产科七病区", 7); + map.put("产科三病区", 3); + map.put("产科二病区", 2); + map.put("产科五病区", 5); + map.put("产科六病区", 6); + map.put("产科门诊", 1); + return map.get(s); + } /** * 预约统计管理列表 @@ -796,7 +908,9 @@ public class PatientDtController extends BaseController { public BaseResponse appointmentStatistics(@RequestHeader("Authorization")String authorization, @RequestParam String doctor, @RequestParam String startTime, - @RequestParam String endTime){ + @RequestParam String endTime, + @RequestParam(required = false) String deptName + ){ if (!authorization.contains(Authorization)){ return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); } @@ -806,7 +920,9 @@ public class PatientDtController extends BaseController { String dept=null; //只有护士长和主任可以看统计(目前) if (doctor.equals("田保来")||doctor.equals("孙慧洁")){ - dept="产科"; + if (StringUtils.isEmpty(deptName)){ + dept="产科"; + } }else { return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常"); } @@ -814,6 +930,7 @@ public class PatientDtController extends BaseController { appointmentQuery.setStartTime(startTime); appointmentQuery.setEndTime(endTime); appointmentQuery.setDept(dept); + appointmentQuery.setDeptName(deptName); List modelList= appointmentService.queryAppointment(appointmentQuery); if (CollectionUtils.isNotEmpty(modelList)){ Map params=new HashMap(); @@ -865,7 +982,6 @@ public class PatientDtController extends BaseController { appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1); params.put(doctorName,appointmentData); } - } baseResponse.setObject(params); } @@ -874,6 +990,120 @@ public class PatientDtController extends BaseController { } /** + * 统计数据导出 + */ + @RequestMapping(method = RequestMethod.POST, value = "/dt/appointment/statistics/export") + @ResponseBody + public void statisticsExport(@RequestHeader("Authorization")String authorization, + @RequestBody AppointmentExport appointmentExport, + HttpServletResponse response){ + if (authorization.contains(Authorization)){ + String doctor= appointmentExport.getDoctor(); + String dept=null; + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){ + dept="产科"; + }else { + return; + } + try { + Map cnames = new LinkedHashMap <>(); + cnames.put("dept", "科室"); + cnames.put("appointmentSumNum", "科室预约就诊总人数"); + cnames.put("buildSumNum", "科室建立电子档案总人数"); + cnames.put("newBuildSumNum", "科室新建档总人数"); + cnames.put("unBuildSumNum", "科室未档总人数"); + cnames.put("buildSumRate", "科室已建档总比率");//已建档/总 + cnames.put("newBuildSumRate", "科室新建档总比率");//新建/(总-已建档+新建档) + cnames.put("doctor", "医生"); + cnames.put("appointmentNum", "预约就诊人数"); + cnames.put("buildNum", "建立电子档案人数"); + cnames.put("newBuildNum", "新建档人数"); + cnames.put("unBuildNum", "未档总人数"); + cnames.put("buildRate", "已建档比率"); + cnames.put("newBuildRate", "新建档比率"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;fileName=" + "科室建档统计.xls"); + OutputStream out = response.getOutputStream(); + Map> params= appointmentExport.getParams(); + AppointmentQuery appointmentQuery=new AppointmentQuery(); + String startTime=appointmentExport.getStartTime()+" 00:00:00"; + String endTime=appointmentExport.getEndTime()+" 23:59:59"; + appointmentQuery.setStartTime(startTime); + appointmentQuery.setEndTime(endTime); + appointmentQuery.setDept(dept); + List modelList= appointmentService.queryAppointment(appointmentQuery); + if (CollectionUtils.isNotEmpty(modelList)&&!params.isEmpty()){ + Map>> data=new HashMap(); + Map> params1=new HashMap(); + PatientsQuery patientsQuery =new PatientsQuery(); + patientsQuery.setYn(1); + patientsQuery.setHospitalId(hospitalId); + for (int i = 0,j=modelList.size(); i < j; i++) { + AppointmentModel appointmentModel= modelList.get(i); + String doctorName=appointmentModel.getDoctor(); + String depts=appointmentModel.getDept(); + if (StringUtils.isNotEmpty(doctorName)){ + Map appointmentData= params1.get(doctorName+","+depts); + if (appointmentData==null){ + appointmentData=new HashMap<>(); + } + appointmentData.put("doctor",doctorName); + appointmentData.put("dept",depts); + String idCard=appointmentModel.getIdCard(); + String phone=appointmentModel.getPhone(); + String username=appointmentModel.getName(); + if (StringUtils.isNotEmpty(idCard)){ + patientsQuery.setCardNo(idCard); + }else { + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){ + patientsQuery.setName(username); + patientsQuery.setPhone(phone); + }else { + appointmentModel.setIsBuild(0); + //未建档 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1); + } + } + if (appointmentModel.getIsBuild()==null){ + List patientsList= patientsService.queryPatient(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsList)){ + //已经建档 + //新建档人数等于当天建档人数 + Patients patients= patientsList.get(0); + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){ + appointmentData.put("newBuildNum",appointmentData.get("newBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("newBuildNum")))+1:1); + } + appointmentData.put("buildNum",appointmentData.get("buildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("buildNum")))+1:1); + }else { + //未建档 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1); + } + } + appointmentData.put("appointmentNum",appointmentData.get("appointmentNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("appointmentNum")))+1:1); + params1.put(doctorName+","+depts,appointmentData); + } + } + for (Map.Entry> entry: params1.entrySet()) { + Map value= entry.getValue(); + String deptName= String.valueOf(value.get("dept")); + if (StringUtils.isNotEmpty(deptName)){ + List> data1 =data.get(deptName); + if (CollectionUtils.isEmpty(data1)){ + data1=new ArrayList<>(); + } + data1.add(value); + data.put(deptName,data1); + } + } + ExcelUtil.toExcelRegion(out,params ,data, cnames); + } + } catch (IOException e) { + ExceptionUtils.catchException(e, e.getMessage()); + } + } + } + + /** * 挂号信息同步 * @param authorization * @param doctor diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/AppointmentExport.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/AppointmentExport.java new file mode 100644 index 0000000..76eb6dc --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/AppointmentExport.java @@ -0,0 +1,43 @@ +package com.lyms.platform.operate.web.request; + + +import java.util.Map; + +public class AppointmentExport { + private Map> params; + private String doctor; + private String startTime; + private String endTime; + + public Map> getParams() { + return params; + } + + public void setParams(Map> params) { + this.params = params; + } + + public String getDoctor() { + return doctor; + } + + public void setDoctor(String doctor) { + this.doctor = doctor; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } +} -- 1.8.3.1