Commit b64a7e7d7d5660b1278486e74fb62164927eb895
1 parent
a5f35ef2a5
Exists in
master
and in
6 other branches
诸城母子导出、重点孕妇登记表,导出格式修改
Showing 5 changed files with 101 additions and 38 deletions
- platform-operate-api/pom.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/JxlsUtils.java
- platform-operate-api/src/main/resources/zddc.xls
platform-operate-api/pom.xml
View file @
b64a7e7
| ... | ... | @@ -118,6 +118,16 @@ |
| 118 | 118 | <version>1.12.0</version> |
| 119 | 119 | </dependency>--> |
| 120 | 120 | |
| 121 | + <dependency> | |
| 122 | + <groupId>org.jxls</groupId> | |
| 123 | + <artifactId>jxls</artifactId> | |
| 124 | + <version>2.3.0</version> | |
| 125 | + </dependency> | |
| 126 | + <dependency> | |
| 127 | + <groupId>org.jxls</groupId> | |
| 128 | + <artifactId>jxls-poi</artifactId> | |
| 129 | + <version>1.0.9</version> | |
| 130 | + </dependency> | |
| 121 | 131 | </dependencies> |
| 122 | 132 | <build> |
| 123 | 133 | <resources> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
View file @
b64a7e7
| ... | ... | @@ -481,7 +481,8 @@ |
| 481 | 481 | header.put("husbandName", "配偶姓名"); |
| 482 | 482 | header.put("organization", "发放机构"); |
| 483 | 483 | header.put("address", "镇街、村居或单位"); |
| 484 | - header.put("childTime", "孩次"); | |
| 484 | + header.put("", "孩次"); | |
| 485 | +// header.put("childTime", "孩次"); | |
| 485 | 486 | header.put("gestation", "孕期"); |
| 486 | 487 | header.put("bookbuildingDate", "发放时间"); |
| 487 | 488 | header.put("serial", "首次发放序号"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
b64a7e7
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | import com.lyms.platform.operate.web.result.*; |
| 15 | 15 | import com.lyms.platform.operate.web.service.PatientWeightService; |
| 16 | 16 | import com.lyms.platform.operate.web.utils.CommonsHelper; |
| 17 | +import com.lyms.platform.operate.web.utils.JxlsUtils; | |
| 17 | 18 | import com.lyms.platform.operate.web.worker.QuanChanPatientWorker; |
| 18 | 19 | import com.lyms.platform.operate.web.worker.QuanPatientWorker; |
| 19 | 20 | import com.lyms.platform.operate.web.worker.WorkHR; |
| 20 | 21 | |
| 21 | 22 | |
| ... | ... | @@ -1137,45 +1138,14 @@ |
| 1137 | 1138 | keyPregnantWomenExcelModelList.add(keyPregnantWomenExcelModel); |
| 1138 | 1139 | } |
| 1139 | 1140 | } |
| 1140 | - List<Map<String, Object>> list = new ArrayList<>(); | |
| 1141 | - for (KeyPregnantWomenExcelModel keyPregnantWomenExcelModel : keyPregnantWomenExcelModelList) { | |
| 1142 | - Map<String, Object> map = BeanUtils.objectToObjectMap(keyPregnantWomenExcelModel); | |
| 1143 | - for (String key : map.keySet()) { | |
| 1144 | - if (org.apache.commons.lang.StringUtils.isEmpty(String.valueOf(map.get(key)))) { | |
| 1145 | - map.put(key, " "); | |
| 1146 | - } | |
| 1147 | - } | |
| 1148 | - list.add(map); | |
| 1149 | - } | |
| 1150 | 1141 | |
| 1151 | - | |
| 1152 | - //2:excel导出 | |
| 1153 | - Map<String, String> header = new LinkedHashMap<>(); | |
| 1154 | - header.put("acceptanceTime", "接收日期"); | |
| 1155 | - header.put("issuedTime", "下发日期"); | |
| 1156 | - header.put("number", "编号"); | |
| 1157 | - header.put("username", "姓名"); | |
| 1158 | - header.put("age", "年龄"); | |
| 1159 | - header.put("addressbs", "户籍/本市"); | |
| 1160 | - header.put("addresswd", "外地/常驻"); | |
| 1161 | - header.put("addressld", "流动"); | |
| 1162 | - header.put("pregnancyTimes", "孕次"); | |
| 1163 | - header.put("prodTime", "产次"); | |
| 1164 | - header.put("dueDate", "预产期"); | |
| 1165 | - header.put("addressRegister", "居住地址"); | |
| 1166 | - header.put("phone", "孕妇手机"); | |
| 1167 | - header.put("husbandPhone", "丈夫手机"); | |
| 1168 | - header.put("rFactor", "重点疾病"); | |
| 1169 | - header.put("rLevel", "高危等级"); | |
| 1170 | - header.put("acknowledgingTiem", "确诊时间"); | |
| 1171 | - header.put("exportime", "随访-第一次日期"); | |
| 1172 | 1142 | response.setContentType("application/force-download"); |
| 1173 | 1143 | response.setHeader("Content-Disposition", "attachment;filename=" + new String(("重点孕妇登记表.xls").getBytes("UTF-8"), "ISO-8859-1")); |
| 1174 | - ExcelUtil.toExcel(response.getOutputStream(), list, header); | |
| 1175 | -// String path = this.getClass().getResource("/").getPath() + "zddc.xls"; | |
| 1176 | -// ExcelUtil.keyPregnantWomenExclFile2(path, response.getOutputStream(), list); | |
| 1177 | -// ExcelUtil.writeWhExclFile(path, response.getOutputStream(), list); | |
| 1178 | - | |
| 1144 | + String path = this.getClass().getResource("/").getPath() + "zddc.xls"; | |
| 1145 | + Map<String , Object> model=new HashMap<String , Object>(); | |
| 1146 | + model.put("employees", keyPregnantWomenExcelModelList); | |
| 1147 | + model.put("nowdate", new Date()); | |
| 1148 | + JxlsUtils.exportExcel(path, response.getOutputStream(), model); | |
| 1179 | 1149 | } catch (Exception e) { |
| 1180 | 1150 | ExceptionUtils.catchException(e, e.getMessage()); |
| 1181 | 1151 | } |
| ... | ... | @@ -1574,7 +1544,8 @@ |
| 1574 | 1544 | } |
| 1575 | 1545 | |
| 1576 | 1546 | //孕期:当前使用有孕== 有孕 |
| 1577 | - healthHandbookExcelModel.setGestation(healthHandbookExcelModel.getGestation()); | |
| 1547 | + healthHandbookExcelModel.setGestation("已孕"); | |
| 1548 | +// healthHandbookExcelModel.setGestation(healthHandbookExcelModel.getGestation()); | |
| 1578 | 1549 | //发放日期:当前日期 |
| 1579 | 1550 | healthHandbookExcelModel.setBookbuildingDate(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); |
| 1580 | 1551 | //首次发放序号:等待需求沟通 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/JxlsUtils.java
View file @
b64a7e7
| 1 | +package com.lyms.platform.operate.web.utils; | |
| 2 | + | |
| 3 | +import org.jxls.common.Context; | |
| 4 | +import org.jxls.expression.JexlExpressionEvaluator; | |
| 5 | +import org.jxls.transform.Transformer; | |
| 6 | +import org.jxls.util.JxlsHelper; | |
| 7 | + | |
| 8 | +import java.io.*; | |
| 9 | +import java.text.SimpleDateFormat; | |
| 10 | +import java.util.Date; | |
| 11 | +import java.util.HashMap; | |
| 12 | +import java.util.Map; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * | |
| 16 | + * @author klguang | |
| 17 | + * | |
| 18 | + */ | |
| 19 | +public class JxlsUtils { | |
| 20 | + | |
| 21 | + private static final String TEMPLATE_PATH="jxls-template"; | |
| 22 | + | |
| 23 | + public static void exportExcel(InputStream is, OutputStream os, Map<String, Object> model) throws IOException{ | |
| 24 | + Context context = new Context(); | |
| 25 | + if (model != null) { | |
| 26 | + for (String key : model.keySet()) { | |
| 27 | + context.putVar(key, model.get(key)); | |
| 28 | + } | |
| 29 | + } | |
| 30 | + JxlsHelper jxlsHelper = JxlsHelper.getInstance(); | |
| 31 | + Transformer transformer = jxlsHelper.createTransformer(is, os); | |
| 32 | + JexlExpressionEvaluator evaluator = (JexlExpressionEvaluator)transformer.getTransformationConfig().getExpressionEvaluator(); | |
| 33 | + Map<String, Object> funcs = new HashMap<String, Object>(); | |
| 34 | + funcs.put("utils", new JxlsUtils()); //添加自定义功能 | |
| 35 | + evaluator.getJexlEngine().setFunctions(funcs); | |
| 36 | + jxlsHelper.processTemplate(context, transformer); | |
| 37 | + } | |
| 38 | + | |
| 39 | + public static void exportExcel(File xls, File out, Map<String, Object> model) throws FileNotFoundException, IOException { | |
| 40 | + exportExcel(new FileInputStream(xls), new FileOutputStream(out), model); | |
| 41 | + } | |
| 42 | + | |
| 43 | + public static void exportExcel(String templateName, OutputStream os, Map<String, Object> model) throws FileNotFoundException, IOException { | |
| 44 | + File template = getTemplate(templateName); | |
| 45 | + if(template!=null){ | |
| 46 | + exportExcel(new FileInputStream(template), os, model); | |
| 47 | + } | |
| 48 | + } | |
| 49 | + | |
| 50 | + | |
| 51 | + //获取jxls模版文件 | |
| 52 | + | |
| 53 | + public static File getTemplate(String name){ | |
| 54 | +// String templatePath = JxlsUtils.class.getClassLoader().getResource(TEMPLATE_PATH).getPath(); | |
| 55 | + File template = new File(name); | |
| 56 | + if(template.exists()){ | |
| 57 | + return template; | |
| 58 | + } | |
| 59 | + return null; | |
| 60 | + } | |
| 61 | + | |
| 62 | + // 日期格式化 | |
| 63 | + public String dateFmt(Date date, String fmt) { | |
| 64 | + if (date == null) { | |
| 65 | + return ""; | |
| 66 | + } | |
| 67 | + try { | |
| 68 | + SimpleDateFormat dateFmt = new SimpleDateFormat(fmt); | |
| 69 | + return dateFmt.format(date); | |
| 70 | + } catch (Exception e) { | |
| 71 | + e.printStackTrace(); | |
| 72 | + } | |
| 73 | + return ""; | |
| 74 | + } | |
| 75 | + | |
| 76 | + // if判断 | |
| 77 | + public Object ifelse(boolean b, Object o1, Object o2) { | |
| 78 | + return b ? o1 : o2; | |
| 79 | + } | |
| 80 | + | |
| 81 | +} |
platform-operate-api/src/main/resources/zddc.xls
View file @
b64a7e7