Commit 18135e77fc62fbd3cdd6d789a4edc49e417e78a9

Authored by jishenfei
1 parent 14f3aa3dd9

全部孕妇管理导出数据中隐藏字段和调整位置

Showing 3 changed files with 80 additions and 5 deletions

platform-common/pom.xml View file @ 18135e7
... ... @@ -39,7 +39,12 @@
39 39 <artifactId>commons-lang3</artifactId>
40 40 <version>3.4</version>
41 41 </dependency>
42   - </dependencies>
  42 + <dependency>
  43 + <groupId>org.apache.poi</groupId>
  44 + <artifactId>poi-ooxml-schemas</artifactId>
  45 + <version>3.15</version>
  46 + </dependency>
  47 + </dependencies>
43 48 <build>
44 49 <plugins>
45 50 <plugin>
platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java View file @ 18135e7
... ... @@ -114,7 +114,9 @@
114 114 WritableWorkbook wwb;
115 115 try {
116 116 wwb = Workbook.createWorkbook(out);
  117 +
117 118 WritableSheet ws = wwb.createSheet("sheet", 0); // 创建一个工作表
  119 +
118 120 /**
119 121 * 设置单元格样式
120 122 */
... ... @@ -146,6 +148,62 @@
146 148 j++;
147 149 }
148 150 }
  151 +
  152 +
  153 + wwb.write();
  154 + wwb.close();
  155 + } catch (IOException e) {
  156 + e.printStackTrace();
  157 + } catch (RowsExceededException e) {
  158 + e.printStackTrace();
  159 + } catch (WriteException e) {
  160 + e.printStackTrace();
  161 + }
  162 + return out;
  163 + }
  164 +
  165 + //导出时隐藏列
  166 + public static OutputStream toExcelhideLie(OutputStream out, List<Map<String, Object>> data, Map<String, String> columName) {
  167 + WritableWorkbook wwb;
  168 + try {
  169 + wwb = Workbook.createWorkbook(out);
  170 +
  171 + WritableSheet ws = wwb.createSheet("sheet", 0); // 创建一个工作表
  172 +
  173 + /**
  174 + * 设置单元格样式
  175 + */
  176 + WritableFont wf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
  177 + WritableCellFormat wcf = new WritableCellFormat(wf);
  178 + ws.setRowView(0, 300); // 设置指定行高
  179 + // 设置列宽
  180 + for (int j = 0, columLen = columName.size(); j < columLen; j++) {
  181 + ws.setColumnView(j, 15);
  182 + }
  183 + // 填充数据的内容
  184 + Map<String, Object> map;
  185 + for (int i = 0, len = data.size(); i < len; i++) {
  186 + map = data.get(i);
  187 + Iterator<String> ite = columName.keySet().iterator();
  188 + int j = 0;
  189 + String keyORvalue = "";
  190 + String keyName = "";
  191 + while (ite.hasNext()) {
  192 + keyName = ite.next();
  193 + if (i > 0) { // 类容数据
  194 + keyORvalue = map.get(keyName) == null ? "" : map.get(keyName).toString();
  195 + } else { // 第一行列名
  196 + keyORvalue = map.get(keyName) == null ? "" : map.get(keyName).toString();
  197 + keyName = columName.get(keyName);
  198 + ws.addCell(new Label(j, 0, keyName, wcf));
  199 + ws.setColumnView(6, 0);
  200 + ws.setColumnView(18, 0);
  201 + }
  202 + ws.addCell(new Label(j, 1 + i, keyORvalue));
  203 + j++;
  204 + }
  205 + }
  206 +
149 207  
150 208 wwb.write();
151 209 wwb.close();
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java View file @ 18135e7
... ... @@ -2202,6 +2202,7 @@
2202 2202 HttpServletResponse response) {
2203 2203 response.setContentType("application/octet-stream");
2204 2204 response.setHeader("Content-Disposition", "attachment;fileName=" + "datas.xls");
  2205 + Boolean isHideArea = false;
2205 2206 try {
2206 2207 String hospital = autoMatchFacade.getHospitalId(userId);
2207 2208 BaseListResponse listResponse = null;
... ... @@ -2256,6 +2257,7 @@
2256 2257 data.put("vcCardNo", rp.getVcCardNo());
2257 2258 }
2258 2259 data.put("cardNo", rp.getCardNo());
  2260 + data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : com.lyms.platform.common.utils.StringUtils.encryPhone(rp.getRealPhone()));
2259 2261 data.put("dueWeek", rp.getDueWeek());
2260 2262 data.put("bTime", rp.getbTime());
2261 2263 data.put("cTimes", rp.getcTimes());
... ... @@ -2269,7 +2271,7 @@
2269 2271 data.put("currentCh", rp.getCurrentCh());
2270 2272 data.put("checkDoctor", rp.getCheckDoctor());
2271 2273 data.put("lName", rp.getlName());
2272   - data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : com.lyms.platform.common.utils.StringUtils.encryPhone(rp.getRealPhone()));
  2274 +
2273 2275 //首次建档医院
2274 2276 data.put("firstBH", rp.getFirstBH());
2275 2277 data.put("serviceType", rp.getServiceType());
... ... @@ -2333,6 +2335,7 @@
2333 2335 cnames.put("vcCardNo", "就诊卡号");
2334 2336 }
2335 2337 cnames.put("cardNo", "身份证");
  2338 + cnames.put("phone", "联系方式");
2336 2339 cnames.put("dueWeek", "当前孕周");
2337 2340 cnames.put("bTime", "建档日期");
2338 2341 cnames.put("normal", "建档状态");
2339 2342  
... ... @@ -2346,11 +2349,12 @@
2346 2349 cnames.put("currentCh", "当前产检医院");
2347 2350 cnames.put("checkDoctor", "产检医生");
2348 2351 cnames.put("lName", "登记人");
2349   - cnames.put("phone", "联系方式");
  2352 +
2350 2353 cnames.put("firstBH", "首次建档医院");
2351 2354 cnames.put("serviceType", "服务类型");
2352 2355 cnames.put("serviceStatus", "服务状态");
2353 2356 cnames.put("remark", "备注");
  2357 + isHideArea =true;
2354 2358 }else {
2355 2359 //全部产妇
2356 2360 cnames.put("name", "姓名");
... ... @@ -2372,8 +2376,16 @@
2372 2376 cnames.put("cardNo", "身份证号码");
2373 2377 cnames.put("remark", "备注");
2374 2378 }
2375   - OutputStream out = response.getOutputStream();
2376   - ExcelUtil.toExcel(out, datas, cnames);
  2379 +
  2380 + if (isHideArea){
  2381 + OutputStream out = response.getOutputStream();
  2382 + ExcelUtil.toExcelhideLie(out, datas, cnames);
  2383 + }else{
  2384 + OutputStream out = response.getOutputStream();
  2385 + ExcelUtil.toExcel(out, datas, cnames);
  2386 + }
  2387 +
  2388 +
2377 2389 } catch (Exception e) {
2378 2390 ExceptionUtils.catchException(e, e.getMessage());
2379 2391 }