Commit 73f648beaf3584f4d9beb0dae6605b954afe572a

Authored by liquanyu
1 parent 646c81b762

助产机构报表

Showing 3 changed files with 122 additions and 83 deletions

platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java View file @ 73f648b
... ... @@ -235,7 +235,7 @@
235 235 }
236 236  
237 237  
238   - public static void writeExclFile(String filePath,OutputStream out)
  238 + public static void writeExclFile(String filePath,OutputStream out,List<String> areaNams,String titleName,String area,String time,List<Map<String,String>> values)
239 239 {
240 240  
241 241 File file = new File(filePath);
242 242  
... ... @@ -247,13 +247,7 @@
247 247  
248 248 WritableWorkbook book = wb.createWorkbook(out,wb);
249 249 WritableSheet ws = book.getSheet(0);
250   - List<Integer> columNames = new ArrayList<>();
251 250  
252   - for (int i = 0, len = 37; i < len; i++)
253   - {
254   - columNames.add(i);
255   - }
256   -
257 251 WritableFont contentFont = new WritableFont(WritableFont.ARIAL, 12, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
258 252 WritableCellFormat contentFormt = new WritableCellFormat(contentFont);
259 253 contentFormt.setAlignment(jxl.format.Alignment.CENTRE);
260 254  
261 255  
262 256  
263 257  
264 258  
265 259  
266 260  
267 261  
268 262  
269 263  
... ... @@ -269,70 +263,88 @@
269 263  
270 264 WritableFont title = new WritableFont(WritableFont.ARIAL, 18, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
271 265 WritableCellFormat titleFormt = new WritableCellFormat(title);
272   - titleFormt.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
  266 + titleFormt.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
273 267 titleFormt.setAlignment(jxl.format.Alignment.CENTRE);
274 268 titleFormt.setVerticalAlignment(VerticalAlignment.CENTRE);
275 269  
  270 + int column = 25;
  271 + for (String key : areaNams)
  272 + {
  273 + column++;
  274 + ws.insertColumn(column);
  275 + ws.insertColumn(column);
  276 + ws.insertColumn(column);
  277 + }
276 278  
277   - ws.insertColumn(26);
278   - ws.insertColumn(27);
279   - ws.insertColumn(28);
280 279  
281   - ws.mergeCells(26, 3, 29, 3);
  280 + ws.mergeCells(26, 3, 26 + areaNams.size(), 3);
282 281 ws.addCell(new Label(26, 3, "本市户籍", contentFormt));
283 282  
284   - ws.addCell(new Label(26, 4, "区1", contentFormt));
285   - ws.addCell(new Label(27, 4, "区2", contentFormt));
286   - ws.addCell(new Label(28, 4, "区3", contentFormt));
287   - ws.addCell(new Label(29, 4, "区4", contentFormt));
  283 + int index = 25;
  284 + for (String value : areaNams)
  285 + {
  286 + index++;
  287 + ws.addCell(new Label(index, 4, value, contentFormt));
  288 + }
288 289  
  290 +
289 291 for (int i = 0; i < ws.getRows() ; i++) {
290 292 for (int j = 0; j < ws.getColumns(); j++) {
  293 +//
  294 +// Cell cell = ws.getCell(i, j);
  295 +// System.out.println(i + "==" + j + " " +cell.getContents());
291 296  
292   - Cell cell = ws.getCell(i, j);
293   - System.out.println(i + "==" + j + " " +cell.getContents());
  297 + if(i == 0 && j == 0){
  298 + Label label = new Label(j, i, titleName,titleFormt);
  299 + ws.addCell(label);
  300 + }
294 301  
295   -// if(i == 0 && j == 0){
296   -// Label label = new Label(j, i, "四川省成都市统计",titleFormt);
297   -// ws.addCell(label);
298   -// }
299   -//
300   -// if(i == 1 && j == 0){
301   -// Label label = new Label(j, i, "成都市",leftFormt);
302   -// ws.addCell(label);
303   -// }
304   -//
305   -// if(i == 1 && j == 19){
306   -// Label label = new Label(j, i, "2018-08-20",leftFormt);
307   -// ws.addCell(label);
308   -// }
  302 + if(i == 1 && j == 0){
  303 + Label label = new Label(j, i, area,leftFormt);
  304 + ws.addCell(label);
  305 + }
  306 +
  307 + if(i == 1 && j == 19){
  308 + Label label = new Label(j, i, time,leftFormt);
  309 + ws.addCell(label);
  310 + }
309 311 }
310 312 }
311 313  
  314 + for (int i = 5, len = values.size(); i < len; i++)
  315 + {
312 316  
313   -// for (int i = 5, len = 30; i < len; i++)
314   -// {
315   -// for (int j = 0; j < columNames.size() ; j++)
316   -// {
317   -// WritableCellFormat wcfN = new WritableCellFormat(contentFont);
318   -// wcfN.setAlignment(jxl.format.Alignment.CENTRE);
319   -// wcfN.setVerticalAlignment(VerticalAlignment.CENTRE);
320   -// Number labelNF = new Number(j, i,j, wcfN);
321   -// ws.addCell(labelNF);
322   -// }
323   -//
324   -// }
325   -//
326   -// ws.addCell(new Label(0, 30, "注:统计时限:上月26日至本月25日;分娩方式中其他包括:吸引产、臀助产、臀牵引、产钳产等。", leftFormt));
327   -//
328   -// ws.mergeCells(0, 30, 36, 30);
329   -//
330   -// ws.addCell(new Label(0, 31, "填报单位:", leftFormt));
331   -// ws.mergeCells(0, 31, 5, 31);
332   -// ws.addCell(new Label(6, 31, "填报人:", leftFormt));
333   -// ws.mergeCells(6, 31, 10, 31);
334   -// ws.addCell(new Label(11, 31, "填报日期:", leftFormt));
335   -// ws.mergeCells(11, 31,36, 31);
  317 + Set<String> sets = values.get(i).keySet();
  318 + int j = 0;
  319 + for (String key : sets)
  320 + {
  321 + String value = values.get(i).get(key);
  322 + if (StringUtils.isNotEmpty(value))
  323 + {
  324 + WritableCellFormat wcfN = new WritableCellFormat(contentFont);
  325 + wcfN.setAlignment(jxl.format.Alignment.CENTRE);
  326 + wcfN.setVerticalAlignment(VerticalAlignment.CENTRE);
  327 + Number labelNF = new Number(j, i,Integer.parseInt(value), wcfN);
  328 + ws.addCell(labelNF);
  329 + }
  330 + else
  331 + {
  332 + ws.addCell(new Label(j, i,value, contentFormt));
  333 + }
  334 + j++;
  335 + }
  336 + }
  337 +
  338 + ws.addCell(new Label(0, 30, "注:统计时限:"+ time +";分娩方式中其他包括:吸引产、臀助产、臀牵引、产钳产等。", leftFormt));
  339 +
  340 + ws.mergeCells(0, 30, 36, 30);
  341 +
  342 + ws.addCell(new Label(0, 31, "填报单位:", leftFormt));
  343 + ws.mergeCells(0, 31, 5, 31);
  344 + ws.addCell(new Label(6, 31, "填报人:", leftFormt));
  345 + ws.mergeCells(6, 31, 10, 31);
  346 + ws.addCell(new Label(11, 31, "填报日期:", leftFormt));
  347 + ws.mergeCells(11, 31,36, 31);
336 348  
337 349 book.write();
338 350 book.close();
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java View file @ 73f648b
... ... @@ -2609,9 +2609,35 @@
2609 2609 String cityId, String areaId, HttpServletResponse httpServletResponse) {
2610 2610  
2611 2611 try {
  2612 +
  2613 + //本市户籍
  2614 + BasicConfigQuery basicConfigQuery = new BasicConfigQuery();
  2615 + basicConfigQuery.setYn(YnEnums.YES.getId());
  2616 + basicConfigQuery.setParentId(cityId);
  2617 +
  2618 + List<BasicConfig> basicConfigs = basicConfigService.queryBasicConfig(basicConfigQuery);
  2619 + List<String> areaNames = new LinkedList<>();
  2620 + if (CollectionUtils.isNotEmpty(basicConfigs)) {
  2621 + for (BasicConfig basicConfig : basicConfigs) {
  2622 + areaNames.add(basicConfig.getName());
  2623 + }
  2624 + }
  2625 +
  2626 + Map<String,String> params = new HashMap<>();
  2627 + params.put("proviceId",proviceId);
  2628 + params.put("cityId", cityId);
  2629 + params.put("areaId", areaId);
  2630 +
  2631 + //获取用户拥有的权限医院和条件筛选的医院交集
  2632 + List<String> hospitalIds = areaCountFacade.getCurrentUserHospPermissions(userId, proviceId,
  2633 + cityId, areaId);
  2634 +
  2635 + List<Map<String,String>> list = getDatas(hospitalIds, time,params, basicConfigs);
  2636 +
2612 2637 httpServletResponse.setContentType("application/force-download");
2613 2638 httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + new String(("助产机构报表.xls").getBytes("UTF-8"), "ISO-8859-1"));
2614   - ExcelUtil.writeExclFile("F:\\需求文档\\my.xls", httpServletResponse.getOutputStream());
  2639 + String path = this.getClass().getResource("/").getPath();
  2640 + ExcelUtil.writeExclFile(path + "\\due_org_report.xls", httpServletResponse.getOutputStream(), areaNames,"成都市","成都取",time,list);
2615 2641 } catch (IOException e) {
2616 2642 ExceptionUtils.catchException(e, "exporDueOrgCount error");
2617 2643 }
2618 2644  
... ... @@ -2620,26 +2646,10 @@
2620 2646 public BaseObjectResponse getDueOrgCount(String time, Integer userId, String hospitalId, String proviceId, String cityId, String areaId) {
2621 2647  
2622 2648  
2623   - Map<String,String> params = new HashMap<>();
2624   - params.put("proviceId",proviceId);
2625   - params.put("cityId",cityId);
2626   - params.put("areaId",areaId);
2627   -
2628   - List<String> hospitalIds = new ArrayList<>();
2629   - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(hospitalId)) {
2630   - hospitalIds.add(hospitalId);
2631   - } else {
2632   - //获取用户拥有的权限医院和条件筛选的医院交集
2633   - hospitalIds = areaCountFacade.getCurrentUserHospPermissions(userId, proviceId,
2634   - cityId, areaId);
2635   - }
2636   -
2637   - List<Map<String,String>> list = new ArrayList<>();
2638   -
2639 2649 //本市户籍
2640 2650 BasicConfigQuery basicConfigQuery = new BasicConfigQuery();
2641 2651 basicConfigQuery.setYn(YnEnums.YES.getId());
2642   - basicConfigQuery.setParentId(params.get("cityId"));
  2652 + basicConfigQuery.setParentId(cityId);
2643 2653  
2644 2654 List<BasicConfig> basicConfigs = basicConfigService.queryBasicConfig(basicConfigQuery);
2645 2655 List<String> areaNames = new LinkedList<>();
2646 2656  
... ... @@ -2649,7 +2659,32 @@
2649 2659 }
2650 2660 }
2651 2661  
  2662 + Map<String,String> params = new HashMap<>();
  2663 + params.put("proviceId",proviceId);
  2664 + params.put("cityId", cityId);
  2665 + params.put("areaId", areaId);
2652 2666  
  2667 + //获取用户拥有的权限医院和条件筛选的医院交集
  2668 + List<String> hospitalIds = areaCountFacade.getCurrentUserHospPermissions(userId, proviceId,
  2669 + cityId, areaId);
  2670 +
  2671 + List<Map<String,String>> list = getDatas(hospitalIds, time,params, basicConfigs);
  2672 +
  2673 + Map<String,Object> data = new HashMap<>();
  2674 + data.put("countData",list);
  2675 + data.put("areaNames",areaNames);
  2676 +
  2677 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  2678 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  2679 + objectResponse.setErrormsg("成功");
  2680 + objectResponse.setData(data);
  2681 + return objectResponse;
  2682 + }
  2683 +
  2684 + private List<Map<String,String>> getDatas(List<String> hospitalIds,String time,Map<String,String> params, List<BasicConfig> basicConfigs)
  2685 + {
  2686 + List<Map<String,String>> list = new ArrayList<>();
  2687 +
2653 2688 int batchSize = 5;
2654 2689 int end = 0;
2655 2690 List<Future> futures = new ArrayList<>();
2656 2691  
... ... @@ -2675,17 +2710,9 @@
2675 2710 }
2676 2711 }
2677 2712  
2678   - sum(list,basicConfigs);
  2713 + sum(list, basicConfigs);
2679 2714  
2680   - Map<String,Object> data = new HashMap<>();
2681   - data.put("countData",list);
2682   - data.put("areaNames",areaNames);
2683   -
2684   - BaseObjectResponse objectResponse = new BaseObjectResponse();
2685   - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
2686   - objectResponse.setErrormsg("成功");
2687   - objectResponse.setData(data);
2688   - return objectResponse;
  2715 + return list;
2689 2716 }
2690 2717  
2691 2718 public void sum(List<Map<String,String>> list,List<BasicConfig> basicConfigs)
platform-operate-api/src/main/resources/due_org_report.xls View file @ 73f648b

No preview for this file type