|
@@ -7,21 +7,31 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ozs.common.core.controller.BaseController;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
|
+import com.ozs.common.core.domain.entity.SysDept;
|
|
|
import com.ozs.common.utils.AppendUtils;
|
|
|
+import com.ozs.common.utils.StringUtils;
|
|
|
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.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;
|
|
|
import com.ozs.service.service.MsgAlarmFrequencyService;
|
|
|
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;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -32,8 +42,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -52,13 +64,13 @@ public class MsgAlarmController extends BaseController {
|
|
|
@Resource
|
|
|
MsgAlarmService msgAlarmService;
|
|
|
@Resource
|
|
|
+ MsgAlarmMapper msgAlarmMapper;
|
|
|
+ @Resource
|
|
|
MsgAlarmFrequencyService msgAlarmFrequencyService;
|
|
|
@Autowired
|
|
|
BaseCameraManagementService baseCameraManagementService;
|
|
|
@Autowired
|
|
|
BaseRailwayManagementService baseRailwayManagementService;
|
|
|
- @Value("${base.imgUrl:http://124.71.171.71:18801/picbucket}")
|
|
|
- private String imgUrl;
|
|
|
|
|
|
|
|
|
* 测试消息推送
|
|
@@ -128,13 +140,6 @@ public class MsgAlarmController extends BaseController {
|
|
|
IPage<MsgAlarm> page = msgAlarmService.page(new Page<>(msgAlarmVo.getPageNum(), msgAlarmVo.getPageSize()), lw);
|
|
|
if(!ObjectUtils.isEmpty(page) && !ObjectUtils.isEmpty(page.getRecords())){
|
|
|
List<MsgAlarm> dto1 = page.getRecords().stream().map(o -> {
|
|
|
- ArrayList<String> objects = new ArrayList<>();
|
|
|
- String[] split = o.getImageUrl().split(";");
|
|
|
- for (String s : split) {
|
|
|
- s=imgUrl+s;
|
|
|
- objects.add(s);
|
|
|
- }
|
|
|
- o.setImageUrls(objects);
|
|
|
LambdaQueryWrapper<BaseCameraManagement> cameraManagementLambdaQueryWrapper = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
if (!ObjectUtils.isEmpty(o.getCameraCode())) {
|
|
|
cameraManagementLambdaQueryWrapper.eq(BaseCameraManagement::getCameraCode, o.getCameraCode());
|
|
@@ -211,14 +216,197 @@ public class MsgAlarmController extends BaseController {
|
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
|
|
|
|
- @GetMapping(value = "/videoHistoricalAlarm/{alarmId}")
|
|
|
+ @GetMapping(value = "/videoHistoricalAlarm/{cameraCode}")
|
|
|
@ApiOperation("视频服务历史报警信息")
|
|
|
- public AjaxResult videoHistoricalAlarm(@PathVariable Long alarmId) {
|
|
|
+ public AjaxResult videoHistoricalAlarm(@PathVariable String cameraCode) {
|
|
|
QueryWrapper<MsgAlarm> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("alarm_id", alarmId);
|
|
|
+ wrapper.eq("camera_code", cameraCode);
|
|
|
wrapper.orderByDesc("alarm_time");
|
|
|
List<MsgAlarm> list = msgAlarmService.list(wrapper);
|
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * web数据统计
|
|
|
+ *
|
|
|
+ * @param alarmStatisticResVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/dataStatistic")
|
|
|
+ @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 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, 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数据统计 数据导出
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/exportDataStatistic")
|
|
|
+ @ApiOperation(value = "web数据统计")
|
|
|
+ public void exportDataStatistic(HttpServletRequest request, HttpServletResponse response, @RequestBody AlarmStatisticResVo alarmStatisticResVo) {
|
|
|
+
|
|
|
+ Workbook wb = new HSSFWorkbook();
|
|
|
+
|
|
|
+ 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);
|
|
|
+ String userId = "1";
|
|
|
+ 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 = "报警数据详情";
|
|
|
+
|
|
|
+
|
|
|
+ response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
+
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
|
|
|
+
|
|
|
+ OutputStream os;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+
|
|
|
+ os.flush();
|
|
|
+ os.close();
|
|
|
+ wb.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|