|
@@ -14,10 +14,7 @@ import com.ozs.service.entity.BaseCameraManagement;
|
|
|
import com.ozs.service.entity.BaseRailwayManagement;
|
|
|
import com.ozs.service.entity.MsgAlarm;
|
|
|
import com.ozs.service.entity.MsgAlarmFrequency;
|
|
|
-import com.ozs.service.entity.vo.AlarmStatisticResVo;
|
|
|
-import com.ozs.service.entity.vo.AlarmStatisticVo;
|
|
|
-import com.ozs.service.entity.vo.MsgAlarmResp;
|
|
|
-import com.ozs.service.entity.vo.MsgAlarmVo;
|
|
|
+import com.ozs.service.entity.vo.*;
|
|
|
import com.ozs.service.mapper.MsgAlarmMapper;
|
|
|
import com.ozs.service.service.BaseCameraManagementService;
|
|
|
import com.ozs.service.service.BaseRailwayManagementService;
|
|
@@ -26,6 +23,7 @@ import com.ozs.service.service.MsgAlarmService;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
@@ -47,7 +45,6 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.OutputStream;
|
|
|
-import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -236,7 +233,7 @@ public class MsgAlarmController extends BaseController {
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/dataStatistic")
|
|
|
- @ApiOperation(value = "web数据统计")
|
|
|
+ @ApiOperation(value = "web数据统计 报警数据详情")
|
|
|
@ApiImplicitParams(value = {
|
|
|
@ApiImplicitParam(paramType = "query", name = "railwayCode", value = "线路编码"),
|
|
|
@ApiImplicitParam(paramType = "query", name = "startMonth", value = "起始月份"),
|
|
@@ -246,11 +243,39 @@ public class MsgAlarmController extends BaseController {
|
|
|
public AjaxResult dataStatistic(@RequestBody AlarmStatisticResVo alarmStatisticResVo) {
|
|
|
Integer pageNum = alarmStatisticResVo.getPageNum().intValue();
|
|
|
Integer pageSize = alarmStatisticResVo.getPageSize().intValue();
|
|
|
+ String userId = getUserId();
|
|
|
+ if ("1".equals(userId)) {
|
|
|
+ userId = "";
|
|
|
+ }
|
|
|
IPage<AlarmStatisticVo> page = msgAlarmService.list(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(),
|
|
|
- alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), pageNum, pageSize);
|
|
|
+ alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), pageNum, pageSize, userId);
|
|
|
return AjaxResult.success(page);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * web数据统计
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/alarmMonthStatistic")
|
|
|
+ @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 alarmMonthStatistic(@RequestBody AlarmStatisticResVo alarmStatisticResVo) {
|
|
|
+ String userId = getUserId();
|
|
|
+ if ("1".equals(userId)) {
|
|
|
+ userId = "";
|
|
|
+ }
|
|
|
+ List<AlarmStatisticVo> list = msgAlarmService.getCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(),
|
|
|
+ alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* web数据统计 数据导出
|
|
|
*
|
|
@@ -329,32 +354,42 @@ public class MsgAlarmController extends BaseController {
|
|
|
cs_text.setAlignment(HorizontalAlignment.CENTER);
|
|
|
//垂直居中
|
|
|
cs_text.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ String userId = "1";//getUserId();
|
|
|
+ if ("1".equals(userId)) {
|
|
|
+ userId = "";
|
|
|
+ }
|
|
|
//调取数据
|
|
|
List<AlarmStatisticVo> list = msgAlarmMapper.list(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getStartMonth(),
|
|
|
- alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType());
|
|
|
- //记录总共多少列(由于接口查询出来的实体类集合,所以不好循环,使用)
|
|
|
- Integer cellSum = 0;
|
|
|
+ alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
//将数据写入表格
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
- //将实体类集合转成string数组,通过‘,’,获取总共多少列
|
|
|
- String[] split = list.get(i).toString().split(",");
|
|
|
- cellSum = split.length;
|
|
|
- //创建行,由于0行是标题,所以+1
|
|
|
row = sheet.createRow(i + 1);
|
|
|
- //实体类集合不太好循环,所以逐一设置,如果是其他则可使用for循环
|
|
|
- AlarmStatisticVo wpa = (AlarmStatisticVo) list.get(i);
|
|
|
- //row.createCell(0).setCellValue(.get!=null?wpa.getType():'1');
|
|
|
- //为每一个单元格设置样式
|
|
|
- for (int j = 0; j < cellSum; j++) {
|
|
|
- row.getCell(j).setCellStyle(cs_text);
|
|
|
+ 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());
|
|
|
}
|
|
|
- }
|
|
|
- //设置单元格宽度自适应
|
|
|
- for (int i = 0; i <= cellSum; i++) {
|
|
|
- sheet.autoSizeColumn((short) i, true); //自动调整列宽
|
|
|
}
|
|
|
//设置中文文件名称
|
|
|
- String fileName = "POIExcel下载测试";//URLEncoder.encode("POIExcel下载测试","UTF-8");
|
|
|
+ String fileName = "报警数据详情";//URLEncoder.encode("POIExcel下载测试","UTF-8");
|
|
|
//浏览器默认服务器传过去的是html,不是excel文件
|
|
|
//设置响应类型:传输内容是流,并支持中文
|
|
|
response.setContentType("application/octet-stream;charset=UTF-8");
|