Commit bef39fe38399e7ddcb411e2789dd14106415100a

Authored by zhangchao
1 parent d432625adb
Exists in dev

#fix:优化五色专案管理,建档统计功能,新增导出Excel合并单元格等功能逻辑

Showing 8 changed files with 406 additions and 15 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/model/AppointmentQuery.java View file @ bef39fe
... ... @@ -9,6 +9,7 @@
9 9 private String name;
10 10 private String dept;
11 11 private String idCard;
  12 + private String deptName;
12 13  
13 14 public String getIdCard() {
14 15 return idCard;
... ... @@ -56,6 +57,14 @@
56 57  
57 58 public void setDept(String dept) {
58 59 this.dept = dept;
  60 + }
  61 +
  62 + public String getDeptName() {
  63 + return deptName;
  64 + }
  65 +
  66 + public void setDeptName(String deptName) {
  67 + this.deptName = deptName;
59 68 }
60 69 }
platform-biz-service/src/main/resources/mainOrm/master/AppointmentMapper.xml View file @ bef39fe
... ... @@ -39,6 +39,9 @@
39 39 <if test="dept!=null">
40 40 and (dept like concat(#{dept},'%') or (dept like concat("产后",'%') and dept !='产后服务部'))
41 41 </if>
  42 + <if test="deptName!=null">
  43 + and dept =#{deptName}
  44 + </if>
42 45 and <![CDATA[checkTime>=#{startTime}]]>
43 46 and <![CDATA[checkTime<=#{endTime}]]>
44 47 <include refid="orderAndLimit"/>
platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java View file @ bef39fe
1 1 package com.lyms.platform.common.utils;
2 2  
3 3 import java.io.*;
  4 +import java.math.BigDecimal;
4 5 import java.util.*;
5 6  
6 7  
... ... @@ -13,6 +14,10 @@
13 14 import jxl.write.*;
14 15 import jxl.write.Number;
15 16 import jxl.write.biff.RowsExceededException;
  17 +import org.apache.poi.ss.usermodel.CellStyle;
  18 +import org.apache.poi.ss.usermodel.HorizontalAlignment;
  19 +import org.apache.poi.ss.usermodel.Row;
  20 +import org.apache.poi.xssf.usermodel.XSSFWorkbook;
16 21  
17 22 /**
18 23 * Excel 工具类
... ... @@ -162,6 +167,93 @@
162 167 return out;
163 168 }
164 169  
  170 + /**
  171 + * 合并单元格导出
  172 + * @param out
  173 + * @param data
  174 + * @param columName
  175 + * @return
  176 + */
  177 + public static OutputStream toExcelRegion(OutputStream out,Map<String,Map<String,Object>> params ,Map<String,List<Map<String,Object>>> data, Map<String, String> columName) {
  178 + WritableWorkbook wwb;
  179 + try {
  180 + wwb = Workbook.createWorkbook(out);
  181 + // 创建一个新的工作表
  182 + WritableSheet ws = wwb.createSheet("sheet", 0); // 创建一个工作表
  183 + /**
  184 + * 设置单元格样式
  185 + */
  186 + WritableFont wf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
  187 +
  188 + WritableCellFormat wcf = new WritableCellFormat(wf);
  189 + ws.setRowView(0, 300); // 设置指定行高
  190 + // 设置列宽
  191 + Iterator<String> ite = columName.keySet().iterator();
  192 + int i = 0;
  193 + while (ite.hasNext()) {
  194 + ws.setColumnView(i, 15);
  195 + String keyName = ite.next();
  196 + keyName = columName.get(keyName);
  197 + ws.addCell(new Label(i, 0, keyName, wcf));
  198 + i++;
  199 + }
  200 + //int j = 1;
  201 + int s=0;
  202 + for (Map.Entry<String,Map<String,Object>> entry:params.entrySet()) {
  203 + // 填充数据的内容
  204 + Map<String, Object> map= entry.getValue();
  205 + List<Map<String,Object>> dataList= data.get(entry.getKey());
  206 + /* if (j==1){
  207 + ws.addCell(new Label(0, j, String.valueOf(map.get("dept"))));
  208 + ws.addCell(new Label(1, j, String.valueOf(map.get("appointmentSumNum"))));
  209 + ws.addCell(new Label(2, j, String.valueOf(map.get("buildSumNum"))));
  210 + ws.addCell(new Label(3, j, String.valueOf(map.get("newBuildSumNum"))));
  211 + ws.addCell(new Label(4, j, String.valueOf(map.get("unBuildSumNum"))));
  212 + }else {*/
  213 + ////新建/(总-已建档+新建档)
  214 + ws.addCell(new Label(0, s+1, String.valueOf(map.get("dept"))));
  215 + ws.addCell(new Label(1, s+1, String.valueOf(map.get("appointmentSumNum"))));
  216 + ws.addCell(new Label(2, s+1, String.valueOf(map.get("buildSumNum"))));
  217 + ws.addCell(new Label(3, s+1, String.valueOf(map.get("newBuildSumNum"))));
  218 + ws.addCell(new Label(4, s+1, String.valueOf(map.get("unBuildSumNum"))));
  219 + 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()+"%"));
  220 + 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()+"%"));
  221 +
  222 +
  223 +
  224 + for (int t = 0, len = dataList.size(); t < len; t++){
  225 + map=dataList.get(t);
  226 + ws.addCell(new Label(7, s+1+t, String.valueOf(map.get("doctor"))));
  227 + ws.addCell(new Label(8, s+1+t, String.valueOf(map.get("appointmentNum")!=null?map.get("appointmentNum"):0)));
  228 + ws.addCell(new Label(9, s+1+t, String.valueOf(map.get("buildNum")!=null?map.get("buildNum"):0)));
  229 + ws.addCell(new Label(10, s+1+t, String.valueOf(map.get("newBuildNum")!=null?map.get("newBuildNum"):0)));
  230 + ws.addCell(new Label(11, s+1+t, String.valueOf(map.get("unBuildNum")!=null?map.get("unBuildNum"):0)));
  231 + 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()+"%"));
  232 + 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()+"%"));
  233 + }
  234 +
  235 + ws.mergeCells(0, s+1, 0, s+dataList.size());
  236 + ws.mergeCells(1, s+1, 1, s+dataList.size());
  237 + ws.mergeCells(2, s+1, 2, s+dataList.size());
  238 + ws.mergeCells(3, s+1, 3, s+dataList.size());
  239 + ws.mergeCells(4, s+1, 4, s+dataList.size());
  240 + ws.mergeCells(5, s+1, 5, s+dataList.size());
  241 + ws.mergeCells(6, s+1, 6, s+dataList.size());
  242 + s+=dataList.size();
  243 +
  244 + }
  245 + wwb.write();
  246 + wwb.close();
  247 + } catch (IOException e) {
  248 + e.printStackTrace();
  249 + } catch (RowsExceededException e) {
  250 + e.printStackTrace();
  251 + } catch (WriteException e) {
  252 + e.printStackTrace();
  253 + }
  254 + return out;
  255 + }
  256 +
165 257 //导出时隐藏列
166 258 public static OutputStream toExcelhideLie(OutputStream out, List<Map<String, Object>> data, Map<String, String> columName) {
167 259 WritableWorkbook wwb;
... ... @@ -1186,9 +1278,8 @@
1186 1278 }
1187 1279  
1188 1280  
1189   - public static void main(String[] args) {
1190   - System.out.println( ExcelUtil.readExcl("F:\\美生医疗文档\\承德医院数据导入\\2023-7-2024-3-29.xls",1));
1191   - }
  1281 +
  1282 +
1192 1283  
1193 1284 }
platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentData.java View file @ bef39fe
... ... @@ -22,7 +22,7 @@
22 22 }
23 23  
24 24 public Integer getUnBuildNum() {
25   - return unBuildNum;
  25 + return unBuildNum!=null?unBuildNum:0;
26 26 }
27 27  
28 28 public void setUnBuildNum(Integer unBuildNum) {
... ... @@ -38,7 +38,7 @@
38 38 }
39 39  
40 40 public Integer getAppointmentNum() {
41   - return appointmentNum;
  41 + return appointmentNum!=null?appointmentNum:0;
42 42 }
43 43  
44 44 public void setAppointmentNum(Integer appointmentNum) {
... ... @@ -46,7 +46,7 @@
46 46 }
47 47  
48 48 public Integer getBuildNum() {
49   - return buildNum;
  49 + return buildNum!=null?buildNum:0;
50 50 }
51 51  
52 52 public void setBuildNum(Integer buildNum) {
... ... @@ -54,7 +54,7 @@
54 54 }
55 55  
56 56 public Integer getNewBuildNum() {
57   - return newBuildNum;
  57 + return newBuildNum!=null?newBuildNum:0;
58 58 }
59 59  
60 60 public void setNewBuildNum(Integer newBuildNum) {
platform-dal/src/main/java/com/lyms/platform/pojo/AppointmentModel.java View file @ bef39fe
... ... @@ -26,6 +26,8 @@
26 26 private Integer isBuild;
27 27 @Transient
28 28 private Date serEndTime;
  29 + @Transient
  30 + private Date serStartTime;
29 31 //服务是否到期 1为是 0为否
30 32 @Transient
31 33 private Integer expire;
... ... @@ -37,6 +39,14 @@
37 39 private List<Map> rlevel;//高危风险颜色
38 40 @Transient
39 41 private Integer appointmentNum;//未建档用户就诊次数
  42 +
  43 + public Date getSerStartTime() {
  44 + return serStartTime;
  45 + }
  46 +
  47 + public void setSerStartTime(Date serStartTime) {
  48 + this.serStartTime = serStartTime;
  49 + }
40 50  
41 51 public Date getBookbuildingDate() {
42 52 return bookbuildingDate;
platform-operate-api/src/main/java/com/lyms/hospitalapi/dtdyrm/DtdyrmFmService.java View file @ bef39fe
... ... @@ -599,6 +599,7 @@
599 599 cnames.put("就诊卡号", "就诊卡号");
600 600 cnames.put("就诊次数", "就诊次数");
601 601 cnames.put("姓名", "姓名");
  602 + cnames.put("服务开始时间", "服务开始时间");
602 603 cnames.put("服务截止时间", "服务截止时间");
603 604 cnames.put("手机号", "手机号");
604 605 cnames.put("证件号", "证件号");
605 606  
... ... @@ -656,7 +657,9 @@
656 657 List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
657 658 if (com.lyms.platform.operate.web.utils.CollectionUtils.isNotEmpty(patientServices)){
658 659 Date serEndTime= patientServices.get(0).getSerEndTime();
  660 + Date serStartTime=patientServices.get(0).getUpdateDate();
659 661 appointmentModel.setSerEndTime(serEndTime);
  662 + appointmentModel.setSerStartTime(serStartTime);
660 663 result.put("服务截止时间", DateUtil.gety_m_dhm(appointmentModel.getSerEndTime()));
661 664 }
662 665 }else {
... ... @@ -674,6 +677,8 @@
674 677 result.put("手机号", appointmentModel.getPhone());
675 678 result.put("证件号", appointmentModel.getIdCard());
676 679 result.put("出生日期",appointmentModel.getAge());
  680 + result.put("服务开始时间",DateUtil.gety_m_dhm(appointmentModel.getSerStartTime()));
  681 + result.put("服务截至时间",DateUtil.gety_m_dhm(appointmentModel.getSerEndTime()));
677 682 result.put("建档时间",DateUtil.getYyyyMmDd(appointmentModel.getBookbuildingDate()));
678 683 result.put("就诊时间",DateUtil.gety_m_dhm(appointmentModel.getCheckTime()));
679 684 result.put("就诊医生",appointmentModel.getDoctor());
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientDtController.java View file @ bef39fe
... ... @@ -11,10 +11,7 @@
11 11 import com.lyms.platform.common.result.CommonResult;
12 12 import com.lyms.platform.common.utils.*;
13 13 import com.lyms.platform.operate.web.facade.*;
14   -import com.lyms.platform.operate.web.request.AntExAddRequest;
15   -import com.lyms.platform.operate.web.request.AntExQueryRequest;
16   -import com.lyms.platform.operate.web.request.AntenatalExaminationQueryRequest;
17   -import com.lyms.platform.operate.web.request.PatientQueryRequest;
  14 +import com.lyms.platform.operate.web.request.*;
18 15 import com.lyms.platform.operate.web.result.HighScoreResult;
19 16 import com.lyms.platform.operate.web.service.PatientWeightService;
20 17 import com.lyms.platform.operate.web.utils.CollectionUtils;
... ... @@ -37,6 +34,8 @@
37 34 import javax.servlet.http.HttpServletRequest;
38 35 import javax.servlet.http.HttpServletResponse;
39 36 import javax.validation.Valid;
  37 +import java.io.IOException;
  38 +import java.io.OutputStream;
40 39 import java.util.*;
41 40  
42 41 /**
43 42  
44 43  
... ... @@ -707,11 +706,12 @@
707 706 PatientServiceQuery patientQuery = new PatientServiceQuery();
708 707 patientQuery.setParentid(patients.getId());
709 708 patientQuery.setSerType(1);
710   -
711 709 List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
712 710 if (CollectionUtils.isNotEmpty(patientServices)){
713 711 Date serEndTime= patientServices.get(0).getSerEndTime();
  712 + Date serStartTime=patientServices.get(0).getUpdateDate();
714 713 appointmentModel.setSerEndTime(serEndTime);
  714 + appointmentModel.setSerStartTime(serStartTime);
715 715 if (serEndTime.compareTo(date)>0){
716 716 appointmentModel.setExpire(0);
717 717 }else {
718 718  
... ... @@ -782,7 +782,119 @@
782 782 return baseResponse;
783 783 }
784 784  
  785 + /**
  786 + * 预约统计管理科室统计列表
  787 + * @param authorization
  788 + * @param doctor
  789 + * @param startTime
  790 + * @param endTime
  791 + * @return
  792 + */
  793 + @RequestMapping(method = RequestMethod.GET, value = "/dt/appointment/dept/statistics")
  794 + @ResponseBody
  795 + public BaseResponse appointmentDeptStatistics(@RequestHeader("Authorization")String authorization,
  796 + @RequestParam String doctor,
  797 + @RequestParam String startTime,
  798 + @RequestParam String endTime){
  799 + if (!authorization.contains(Authorization)){
  800 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  801 + }
  802 + BaseResponse baseResponse=new BaseResponse();
  803 + startTime=startTime+" 00:00:00";
  804 + endTime=endTime+" 23:59:59";
  805 + String dept=null;
  806 + //只有护士长和主任可以看统计(目前)
  807 + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){
  808 + dept="产科";
  809 + }else {
  810 + return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
  811 + }
  812 + AppointmentQuery appointmentQuery=new AppointmentQuery();
  813 + appointmentQuery.setStartTime(startTime);
  814 + appointmentQuery.setEndTime(endTime);
  815 + appointmentQuery.setDept(dept);
  816 + List<AppointmentModel> modelList= appointmentService.queryAppointment(appointmentQuery);
  817 + if (CollectionUtils.isNotEmpty(modelList)){
  818 + Map<String,AppointmentData> params=new HashMap();
  819 + PatientsQuery patientsQuery =new PatientsQuery();
  820 + patientsQuery.setYn(1);
  821 + patientsQuery.setHospitalId(hospitalId);
  822 + for (int i = 0,j=modelList.size(); i < j; i++) {
  823 + AppointmentModel appointmentModel= modelList.get(i);
  824 + String depts=appointmentModel.getDept();
  825 + if (StringUtils.isNotEmpty(depts)&&StringUtils.isNotEmpty(appointmentModel.getDoctor())){
  826 + AppointmentData appointmentData= params.get(depts);
  827 + if (appointmentData==null){
  828 + appointmentData=new AppointmentData();
  829 + }
  830 + appointmentData.setDept(depts);
  831 + String idCard=appointmentModel.getIdCard();
  832 + String phone=appointmentModel.getPhone();
  833 + String username=appointmentModel.getName();
  834 + if (StringUtils.isNotEmpty(idCard)){
  835 + patientsQuery.setCardNo(idCard);
  836 + }else {
  837 + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){
  838 + patientsQuery.setName(username);
  839 + patientsQuery.setPhone(phone);
  840 + }else {
  841 + appointmentModel.setIsBuild(0);
  842 + //未建档
  843 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1);
  844 + }
  845 + }
  846 + if (appointmentModel.getIsBuild()==null){
  847 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  848 + if (CollectionUtils.isNotEmpty(patientsList)){
  849 + //已经建档
  850 + //新建档人数等于当天建档人数
  851 + Patients patients= patientsList.get(0);
  852 + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){
  853 + appointmentData.setNewBuildNum(appointmentData.getNewBuildNum()!=null?appointmentData.getNewBuildNum()+1:1);
  854 + }
  855 + appointmentData.setBuildNum(appointmentData.getBuildNum()!=null?appointmentData.getBuildNum()+1:1);
  856 + }else {
  857 + //未建档
  858 + appointmentData.setUnBuildNum(appointmentData.getUnBuildNum()!=null?appointmentData.getUnBuildNum()+1:1);
  859 + }
  860 + }
  861 + appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1);
  862 + params.put(depts,appointmentData);
  863 + }
  864 + }
  865 + // 使用TreeMap进行排序
  866 + Map<String, AppointmentData> sortedMap = new TreeMap<>(new ChineseComparator());
  867 + sortedMap.putAll(params);
  868 + baseResponse.setObject(sortedMap);
  869 + }
  870 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  871 + return baseResponse;
  872 + }
  873 + // 自定义Comparator,用于按照定义好的顺序排序
  874 + static class ChineseComparator implements Comparator<String> {
  875 + @Override
  876 + public int compare(String s1, String s2) {
  877 + try {
  878 + return getPinyin(s1).compareTo(getPinyin(s2));
  879 + }catch (Exception e){
  880 + System.out.println(s1+" "+s2);
  881 + }
  882 + return 0;
  883 + }
785 884  
  885 + }
  886 + private static Integer getPinyin(String s) {
  887 + Map<String, Integer> map = new HashMap<>();
  888 + map.put("产后康复门诊", 10);
  889 + map.put("产科七病区", 7);
  890 + map.put("产科三病区", 3);
  891 + map.put("产科二病区", 2);
  892 + map.put("产科五病区", 5);
  893 + map.put("产科六病区", 6);
  894 + map.put("产科门诊", 1);
  895 + return map.get(s);
  896 + }
  897 +
786 898 /**
787 899 * 预约统计管理列表
788 900 * @param authorization
... ... @@ -796,7 +908,9 @@
796 908 public BaseResponse appointmentStatistics(@RequestHeader("Authorization")String authorization,
797 909 @RequestParam String doctor,
798 910 @RequestParam String startTime,
799   - @RequestParam String endTime){
  911 + @RequestParam String endTime,
  912 + @RequestParam(required = false) String deptName
  913 + ){
800 914 if (!authorization.contains(Authorization)){
801 915 return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
802 916 }
... ... @@ -806,7 +920,9 @@
806 920 String dept=null;
807 921 //只有护士长和主任可以看统计(目前)
808 922 if (doctor.equals("田保来")||doctor.equals("孙慧洁")){
809   - dept="产科";
  923 + if (StringUtils.isEmpty(deptName)){
  924 + dept="产科";
  925 + }
810 926 }else {
811 927 return new BaseObjectResponse().setErrorcode(-1).setErrormsg("权限异常");
812 928 }
... ... @@ -814,6 +930,7 @@
814 930 appointmentQuery.setStartTime(startTime);
815 931 appointmentQuery.setEndTime(endTime);
816 932 appointmentQuery.setDept(dept);
  933 + appointmentQuery.setDeptName(deptName);
817 934 List<AppointmentModel> modelList= appointmentService.queryAppointment(appointmentQuery);
818 935 if (CollectionUtils.isNotEmpty(modelList)){
819 936 Map<String,AppointmentData> params=new HashMap();
820 937  
... ... @@ -865,12 +982,125 @@
865 982 appointmentData.setAppointmentNum(appointmentData.getAppointmentNum()!=null?appointmentData.getAppointmentNum()+1:1);
866 983 params.put(doctorName,appointmentData);
867 984 }
868   -
869 985 }
870 986 baseResponse.setObject(params);
871 987 }
872 988 baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
873 989 return baseResponse;
  990 + }
  991 +
  992 + /**
  993 + * 统计数据导出
  994 + */
  995 + @RequestMapping(method = RequestMethod.POST, value = "/dt/appointment/statistics/export")
  996 + @ResponseBody
  997 + public void statisticsExport(@RequestHeader("Authorization")String authorization,
  998 + @RequestBody AppointmentExport appointmentExport,
  999 + HttpServletResponse response){
  1000 + if (authorization.contains(Authorization)){
  1001 + String doctor= appointmentExport.getDoctor();
  1002 + String dept=null;
  1003 + if (doctor.equals("田保来")||doctor.equals("孙慧洁")){
  1004 + dept="产科";
  1005 + }else {
  1006 + return;
  1007 + }
  1008 + try {
  1009 + Map <String, String> cnames = new LinkedHashMap <>();
  1010 + cnames.put("dept", "科室");
  1011 + cnames.put("appointmentSumNum", "科室预约就诊总人数");
  1012 + cnames.put("buildSumNum", "科室建立电子档案总人数");
  1013 + cnames.put("newBuildSumNum", "科室新建档总人数");
  1014 + cnames.put("unBuildSumNum", "科室未档总人数");
  1015 + cnames.put("buildSumRate", "科室已建档总比率");//已建档/总
  1016 + cnames.put("newBuildSumRate", "科室新建档总比率");//新建/(总-已建档+新建档)
  1017 + cnames.put("doctor", "医生");
  1018 + cnames.put("appointmentNum", "预约就诊人数");
  1019 + cnames.put("buildNum", "建立电子档案人数");
  1020 + cnames.put("newBuildNum", "新建档人数");
  1021 + cnames.put("unBuildNum", "未档总人数");
  1022 + cnames.put("buildRate", "已建档比率");
  1023 + cnames.put("newBuildRate", "新建档比率");
  1024 + response.setContentType("application/octet-stream");
  1025 + response.setHeader("Content-Disposition", "attachment;fileName=" + "科室建档统计.xls");
  1026 + OutputStream out = response.getOutputStream();
  1027 + Map<String,Map<String,Object>> params= appointmentExport.getParams();
  1028 + AppointmentQuery appointmentQuery=new AppointmentQuery();
  1029 + String startTime=appointmentExport.getStartTime()+" 00:00:00";
  1030 + String endTime=appointmentExport.getEndTime()+" 23:59:59";
  1031 + appointmentQuery.setStartTime(startTime);
  1032 + appointmentQuery.setEndTime(endTime);
  1033 + appointmentQuery.setDept(dept);
  1034 + List<AppointmentModel> modelList= appointmentService.queryAppointment(appointmentQuery);
  1035 + if (CollectionUtils.isNotEmpty(modelList)&&!params.isEmpty()){
  1036 + Map<String,List<Map<String,Object>>> data=new HashMap();
  1037 + Map<String,Map<String,Object>> params1=new HashMap();
  1038 + PatientsQuery patientsQuery =new PatientsQuery();
  1039 + patientsQuery.setYn(1);
  1040 + patientsQuery.setHospitalId(hospitalId);
  1041 + for (int i = 0,j=modelList.size(); i < j; i++) {
  1042 + AppointmentModel appointmentModel= modelList.get(i);
  1043 + String doctorName=appointmentModel.getDoctor();
  1044 + String depts=appointmentModel.getDept();
  1045 + if (StringUtils.isNotEmpty(doctorName)){
  1046 + Map<String,Object> appointmentData= params1.get(doctorName+","+depts);
  1047 + if (appointmentData==null){
  1048 + appointmentData=new HashMap<>();
  1049 + }
  1050 + appointmentData.put("doctor",doctorName);
  1051 + appointmentData.put("dept",depts);
  1052 + String idCard=appointmentModel.getIdCard();
  1053 + String phone=appointmentModel.getPhone();
  1054 + String username=appointmentModel.getName();
  1055 + if (StringUtils.isNotEmpty(idCard)){
  1056 + patientsQuery.setCardNo(idCard);
  1057 + }else {
  1058 + if (StringUtils.isNotEmpty(username)&&StringUtils.isNotEmpty(phone)){
  1059 + patientsQuery.setName(username);
  1060 + patientsQuery.setPhone(phone);
  1061 + }else {
  1062 + appointmentModel.setIsBuild(0);
  1063 + //未建档
  1064 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1);
  1065 + }
  1066 + }
  1067 + if (appointmentModel.getIsBuild()==null){
  1068 + List<Patients> patientsList= patientsService.queryPatient(patientsQuery);
  1069 + if (CollectionUtils.isNotEmpty(patientsList)){
  1070 + //已经建档
  1071 + //新建档人数等于当天建档人数
  1072 + Patients patients= patientsList.get(0);
  1073 + if (DateUtil.isBetween(patients.getCreated(),DateUtil.parseYMDHMS(startTime),DateUtil.parseYMDHMS(endTime))){
  1074 + appointmentData.put("newBuildNum",appointmentData.get("newBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("newBuildNum")))+1:1);
  1075 + }
  1076 + appointmentData.put("buildNum",appointmentData.get("buildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("buildNum")))+1:1);
  1077 + }else {
  1078 + //未建档
  1079 + appointmentData.put("unBuildNum",appointmentData.get("unBuildNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("unBuildNum")))+1:1);
  1080 + }
  1081 + }
  1082 + appointmentData.put("appointmentNum",appointmentData.get("appointmentNum")!=null?Integer.valueOf(String.valueOf(appointmentData.get("appointmentNum")))+1:1);
  1083 + params1.put(doctorName+","+depts,appointmentData);
  1084 + }
  1085 + }
  1086 + for (Map.Entry<String,Map<String,Object>> entry: params1.entrySet()) {
  1087 + Map<String,Object> value= entry.getValue();
  1088 + String deptName= String.valueOf(value.get("dept"));
  1089 + if (StringUtils.isNotEmpty(deptName)){
  1090 + List<Map<String,Object>> data1 =data.get(deptName);
  1091 + if (CollectionUtils.isEmpty(data1)){
  1092 + data1=new ArrayList<>();
  1093 + }
  1094 + data1.add(value);
  1095 + data.put(deptName,data1);
  1096 + }
  1097 + }
  1098 + ExcelUtil.toExcelRegion(out,params ,data, cnames);
  1099 + }
  1100 + } catch (IOException e) {
  1101 + ExceptionUtils.catchException(e, e.getMessage());
  1102 + }
  1103 + }
874 1104 }
875 1105  
876 1106 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/AppointmentExport.java View file @ bef39fe
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +
  4 +import java.util.Map;
  5 +
  6 +public class AppointmentExport {
  7 + private Map<String, Map<String,Object>> params;
  8 + private String doctor;
  9 + private String startTime;
  10 + private String endTime;
  11 +
  12 + public Map<String, Map<String, Object>> getParams() {
  13 + return params;
  14 + }
  15 +
  16 + public void setParams(Map<String, Map<String, Object>> params) {
  17 + this.params = params;
  18 + }
  19 +
  20 + public String getDoctor() {
  21 + return doctor;
  22 + }
  23 +
  24 + public void setDoctor(String doctor) {
  25 + this.doctor = doctor;
  26 + }
  27 +
  28 + public String getStartTime() {
  29 + return startTime;
  30 + }
  31 +
  32 + public void setStartTime(String startTime) {
  33 + this.startTime = startTime;
  34 + }
  35 +
  36 + public String getEndTime() {
  37 + return endTime;
  38 + }
  39 +
  40 + public void setEndTime(String endTime) {
  41 + this.endTime = endTime;
  42 + }
  43 +}