| 
					
				 | 
			
			
				@@ -110,29 +110,32 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //将数据写入表格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (int i = 0; i < list.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            HSSFCell cel = row.createCell(i + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            row = sheet.createRow(i + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             AlarmStatisticVo vo = list.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 第四步,创建单元格,并设置值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (StringUtils.isNotEmpty(vo.getBaseCameraManagement().getRailwayCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                cel.setCellValue(vo.getBaseCameraManagement().getRailwayCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(0).setCellValue(vo.getBaseCameraManagement().getRailwayCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (vo.getAlarmTime() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                cel.setCellValue(vo.getAlarmTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String dateStr = sdf.format(vo.getAlarmTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Date date = sdf.parse(dateStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(1).setCellValue(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (vo.getLineDir() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                cel.setCellValue(vo.getLineDir()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(2).setCellValue(vo.getLineDir()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (vo.getAlarmType() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                cel.setCellValue(vo.getAlarmType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(3).setCellValue(vo.getAlarmType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (vo.getBaseCameraManagement().getInstallMile() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                cel.setCellValue(vo.getBaseCameraManagement().getInstallMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(4).setCellValue(vo.getBaseCameraManagement().getInstallMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (vo.getBaseCameraManagement().getBeginMile() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                cel.setCellValue(vo.getBaseCameraManagement().getBeginMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(5).setCellValue(vo.getBaseCameraManagement().getBeginMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (vo.getBaseCameraManagement().getEndMile() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                cel.setCellValue(vo.getBaseCameraManagement().getEndMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(6).setCellValue(vo.getBaseCameraManagement().getEndMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //第六步,输出Excel文件 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -147,4 +150,83 @@ public class MsgAlarmServiceImpl extends ServiceImpl<MsgAlarmMapper, MsgAlarm> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         wb.write(output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         output.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void exportExcelMonth(HttpServletResponse response, AlarmStatisticResVo alarmStatisticResVo, String userId) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 第一步,创建一个webbook,对应一个Excel文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HSSFWorkbook wb = new HSSFWorkbook(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HSSFSheet sheet = wb.createSheet("报警月统计数据"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HSSFRow row = sheet.createRow(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 第四步,创建单元格,并设置值表头 设置表头居中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HSSFCellStyle style = wb.createCellStyle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //单元格边框 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //style.setAlignment(BorderStyle.THIN); // 创建一个居中格式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        style.setBorderBottom(BorderStyle.THIN); //下边框 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        style.setBorderLeft(BorderStyle.THIN);//左边框 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        style.setBorderTop(BorderStyle.THIN);//上边框 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        style.setBorderRight(BorderStyle.THIN);//右边框 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //设置单元格字体大小 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HSSFFont font = wb.createFont(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        font.setFontName("宋体"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        font.setFontHeightInPoints((short) 11);//设置字体大小 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        style.setFont(font);//选择需要用到的字体格式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HSSFCell cell = row.createCell(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellValue("线路"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellStyle(style); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell = row.createCell(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellValue("报警类型"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellStyle(style); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell = row.createCell(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellValue("报警月份"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellStyle(style); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell = row.createCell(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellValue("报警次数"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellStyle(style); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell = row.createCell(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellValue("报警时间"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cell.setCellStyle(style); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //调取数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<AlarmStatisticVo> list = msgAlarmMapper.listMonth(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //将数据写入表格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int i = 0; i < list.size(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            row = sheet.createRow(i + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AlarmStatisticVo vo = list.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 第四步,创建单元格,并设置值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (StringUtils.isNotEmpty(vo.getBaseCameraManagement().getRailwayCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(0).setCellValue(vo.getBaseCameraManagement().getRailwayCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (vo.getAlarmType() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(1).setCellValue(vo.getAlarmType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (vo.getMonthsta() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(2).setCellValue(vo.getMonthsta()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (vo.getFrequency() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(3).setCellValue(vo.getFrequency()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (vo.getAlarmTime() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String dateStr = sdf.format(vo.getAlarmTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Date date = sdf.parse(dateStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                row.createCell(4).setCellValue(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //第六步,输出Excel文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OutputStream output = response.getOutputStream(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        response.reset(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //设置文件头:最后一个参数是设置下载文件名 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        long filename = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String fileName = "报警月统计数据"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        response.setHeader("Content-disposition", "attachment; filename=" + fileName + ".xlsx"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        wb.write(output); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        output.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |