| 
					
				 | 
			
			
				@@ -30,6 +30,8 @@ import org.apache.poi.hssf.usermodel.HSSFSheet; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.poi.hssf.usermodel.HSSFWorkbook; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.poi.ss.usermodel.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.poi.ss.util.CellRangeAddress; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.util.ObjectUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,6 +46,8 @@ import org.springframework.web.bind.annotation.RestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.servlet.http.HttpServletRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.servlet.http.HttpServletResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.File; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.FileOutputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.OutputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Date; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -61,6 +65,7 @@ import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RequestMapping("/service/msgAlarm") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class MsgAlarmController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final Logger log = LoggerFactory.getLogger(MsgAlarmController.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     MsgAlarmService msgAlarmService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -216,11 +221,11 @@ public class MsgAlarmController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return AjaxResult.success(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @GetMapping(value = "/videoHistoricalAlarm/{cameraCode}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping(value = "/videoHistoricalAlarm/{alarmId}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApiOperation("视频服务历史报警信息") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public AjaxResult videoHistoricalAlarm(@PathVariable String cameraCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxResult videoHistoricalAlarm(@PathVariable Long alarmId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         QueryWrapper<MsgAlarm> wrapper = new QueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        wrapper.eq("camera_code", cameraCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        wrapper.eq("alarm_id", alarmId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         wrapper.orderByDesc("alarm_time"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<MsgAlarm> list = msgAlarmService.list(wrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return AjaxResult.success(list); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -284,128 +289,25 @@ public class MsgAlarmController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/exportDataStatistic") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @ApiOperation(value = "web数据统计") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void exportDataStatistic(HttpServletRequest request, HttpServletResponse response, @RequestBody AlarmStatisticResVo alarmStatisticResVo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //创建Excel文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Workbook wb = new HSSFWorkbook(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //生成sheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Sheet sheet = wb.createSheet("报警数据详情"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //创建行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Row row = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //创建列 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Cell cell = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //创建表头单元格样式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CellStyle cs_header = wb.createCellStyle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置字体样式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Font boldFont = wb.createFont(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置文字类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        boldFont.setFontName("宋体"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置加粗 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        boldFont.setBold(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置文字大小 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        boldFont.setFontHeightInPoints((short) 16); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //应用设置的字体 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setFont(boldFont); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置边框下、左、右、上 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setBorderBottom(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setBorderLeft(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setBorderRight(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setBorderTop(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //水平居中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setAlignment(HorizontalAlignment.CENTER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //垂直居中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setVerticalAlignment(VerticalAlignment.CENTER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //前景填充色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置前景填充样式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_header.setFillPattern(FillPatternType.SOLID_FOREGROUND); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        row = sheet.createRow(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置单元格行高 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        row.setHeightInPoints(24); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置标题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String[] headers = new String[]{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "线路", "时间", "行别", "报警类型", "里程位置", "里程起始范围km", "里程结束范围km" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //逐个设置标题样式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (int i = 0; i < headers.length; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //创建单元格 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            cell = row.createCell(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //设置单元格内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            cell.setCellValue(headers[i]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //设置单元格样式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            cell.setCellStyle(cs_header); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //创建文本单元格样式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CellStyle cs_text = wb.createCellStyle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //创建文字设置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Font textFont = wb.createFont(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置文字类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        textFont.setFontName("Consolas"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置文字大小 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        textFont.setFontHeightInPoints((short) 10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //应用设置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_text.setFont(textFont); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置边框 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_text.setBorderBottom(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_text.setBorderLeft(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_text.setBorderRight(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_text.setBorderTop(BorderStyle.THIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //水平居中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_text.setAlignment(HorizontalAlignment.CENTER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //垂直居中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cs_text.setVerticalAlignment(VerticalAlignment.CENTER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiOperation(value = "web数据统计-数据导出") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApiImplicitParams(value = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiImplicitParam(paramType = "query", name = "railwayCode", value = "线路编码"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiImplicitParam(paramType = "query", name = "startMonth", value = "起始月份"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiImplicitParam(paramType = "query", name = "endMonth", value = "结束月份"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @ApiImplicitParam(paramType = "query", name = "alarmType", value = "灾害类型"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public AjaxResult exportDataStatistic(HttpServletResponse response, @RequestBody AlarmStatisticResVo alarmStatisticResVo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String userId = "1";//getUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ("1".equals(userId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             userId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //调取数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<AlarmStatisticVo> list = msgAlarmMapper.list(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.getAlarmTime() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                row.createCell(1).setCellValue(vo.getAlarmTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (vo.getLineDir() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                row.createCell(2).setCellValue(vo.getLineDir()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (vo.getAlarmType() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                row.createCell(3).setCellValue(vo.getAlarmType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (vo.getBaseCameraManagement().getInstallMile() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                row.createCell(4).setCellValue(vo.getBaseCameraManagement().getInstallMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (vo.getBaseCameraManagement().getBeginMile() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                row.createCell(5).setCellValue(vo.getBaseCameraManagement().getBeginMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (vo.getBaseCameraManagement().getEndMile() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                row.createCell(6).setCellValue(vo.getBaseCameraManagement().getEndMile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置中文文件名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String fileName = "报警数据详情";//URLEncoder.encode("POIExcel下载测试","UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //浏览器默认服务器传过去的是html,不是excel文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置响应类型:传输内容是流,并支持中文 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        response.setContentType("application/octet-stream;charset=UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //设置响应头信息header,下载时以文件附件下载 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //输出流对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        OutputStream os; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            os = response.getOutputStream(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //强制刷新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            os.flush(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            os.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            wb.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            msgAlarmService.exportExcel(response, alarmStatisticResVo, userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return AjaxResult.success("导出成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info(e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return AjaxResult.error("导出错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |