|
@@ -1,26 +1,37 @@
|
|
|
package com.ozs.web.controller.accountmanagment;
|
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
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.service.*;
|
|
|
-import com.ozs.web.controller.websocket.WebSocketServer;
|
|
|
+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;
|
|
@@ -31,7 +42,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.*;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -48,49 +64,33 @@ 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;
|
|
|
- @Autowired
|
|
|
- private BaseUserService baseUserService;
|
|
|
- @Autowired
|
|
|
- private WebSocketServer webSocketServer;
|
|
|
|
|
|
/**
|
|
|
* 测试消息推送
|
|
|
*/
|
|
|
@PostMapping("/push")
|
|
|
@ApiOperation(value = "预报警信息分页")
|
|
|
- public AjaxResult insertDate(String args) {
|
|
|
- String userId = getUserId();
|
|
|
- // 初始化 -> 运行中 -> 成功或失败
|
|
|
- try {
|
|
|
- // 1、初始化
|
|
|
- webSocketServer.sendOneMessage(userId, objStr(args, 1));
|
|
|
- Thread.sleep(3 * 1000);
|
|
|
- // 2、运行中
|
|
|
- webSocketServer.sendOneMessage(userId, objStr(args, 2));
|
|
|
- Thread.sleep(5 * 1000);
|
|
|
- // 3、成功或失败
|
|
|
- webSocketServer.sendOneMessage(userId, Math.random() * 10 > 5 ? objStr(args, 6) : objStr(args, 7));
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new RuntimeException("构建失败");
|
|
|
- }
|
|
|
+ public AjaxResult insertDate(String[] args) {
|
|
|
+ // 模拟需要推送的用户群
|
|
|
+ ArrayList<String> ids = new ArrayList<>();
|
|
|
+ ids.add("001");
|
|
|
+ ids.add("002");
|
|
|
+ ids.add("003");
|
|
|
+ ids.add("004");
|
|
|
+ ids.add("005");
|
|
|
+//
|
|
|
+// WebSocketService webSocketService = new WebSocketService();
|
|
|
+// webSocketService.sendMsgToUsers(ids);
|
|
|
return AjaxResult.success("推送成功");
|
|
|
}
|
|
|
|
|
|
- private String objStr(String str, int status) {
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("pipelineId", str); //流水线ID
|
|
|
- obj.put("status", status);
|
|
|
- return obj.toJSONString();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 报警信息分页
|
|
|
*
|
|
@@ -100,7 +100,7 @@ public class MsgAlarmController extends BaseController {
|
|
|
@ApiOperation(value = "报警信息分页")
|
|
|
@PostMapping("/list")
|
|
|
public AjaxResult selectMsgAlarm(@RequestBody MsgAlarmVo msgAlarmVo) {
|
|
|
- List<BaseCameraManagement> baseCameraManagementList = new ArrayList<>();
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList=new ArrayList<>();
|
|
|
LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode())) {
|
|
|
wrapper.eq(BaseCameraManagement::getRailwayCode, msgAlarmVo.getRailwayCode());
|
|
@@ -111,25 +111,21 @@ public class MsgAlarmController extends BaseController {
|
|
|
if (!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
|
|
|
wrapper.le(BaseCameraManagement::getEndMile, msgAlarmVo.getEndMile());
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode()) || !ObjectUtils.isEmpty(msgAlarmVo.getBeginMile()) || !ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getRailwayCode())||!ObjectUtils.isEmpty(msgAlarmVo.getBeginMile())||!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
|
|
|
baseCameraManagementList = baseCameraManagementService.list(wrapper);
|
|
|
}
|
|
|
- List<String> userIds = baseCameraManagementService.getUserIds(getUserId());
|
|
|
LambdaQueryWrapper<MsgAlarm> lw = new LambdaQueryWrapper<MsgAlarm>();
|
|
|
- if (!ObjectUtils.isEmpty(userIds)) {
|
|
|
- lw.in(MsgAlarm::getCreateBy, userIds);
|
|
|
- }
|
|
|
if (!ObjectUtils.isEmpty(msgAlarmVo.getLineDir())) {
|
|
|
lw.eq(MsgAlarm::getLineDir, msgAlarmVo.getLineDir());
|
|
|
}
|
|
|
- if (baseCameraManagementList.size() > 0) {
|
|
|
+ if (baseCameraManagementList.size()>0) {
|
|
|
List<String> collect = baseCameraManagementList.stream().map(BaseCameraManagement::getCameraCode).collect(Collectors.toList());
|
|
|
lw.in(MsgAlarm::getCameraCode, collect);
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmType())) {
|
|
|
lw.eq(MsgAlarm::getAlarmType, msgAlarmVo.getAlarmType());
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile()) && msgAlarmVo.getAlarmMile() != 0) {
|
|
|
+ if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile())) {
|
|
|
lw.eq(MsgAlarm::getAlarmMile, msgAlarmVo.getAlarmMile());
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(msgAlarmVo.getBeginAlarmTime())) {
|
|
@@ -142,15 +138,8 @@ public class MsgAlarmController extends BaseController {
|
|
|
lw.eq(MsgAlarm::getIsLock, msgAlarmVo.getIsLock());
|
|
|
}
|
|
|
IPage<MsgAlarm> page = msgAlarmService.page(new Page<>(msgAlarmVo.getPageNum(), msgAlarmVo.getPageSize()), lw);
|
|
|
- if (!ObjectUtils.isEmpty(page) && !ObjectUtils.isEmpty(page.getRecords())) {
|
|
|
+ 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());
|
|
@@ -169,7 +158,7 @@ public class MsgAlarmController extends BaseController {
|
|
|
o.setEndMile(end);
|
|
|
String begin = AppendUtils.stringAppend(cameraManagement.getBeginMile());
|
|
|
o.setBeginMile(begin);
|
|
|
- o.setAlarmCount((int) msgAlarmFrequencyService.count() + 1);
|
|
|
+ o.setAlarmCount((int) msgAlarmFrequencyService.count()+1);
|
|
|
return o;
|
|
|
}).collect(Collectors.toList());
|
|
|
page.setRecords(dto1);
|
|
@@ -197,11 +186,11 @@ public class MsgAlarmController extends BaseController {
|
|
|
msgAlarmResp.setDeptId(baseCameraManagement.getDeptId());
|
|
|
String begin = AppendUtils.stringAppend(baseCameraManagement.getBeginMile());
|
|
|
String end = AppendUtils.stringAppend(baseCameraManagement.getEndMile());
|
|
|
- String endMile = begin + "-" + end;
|
|
|
+ String endMile=begin+"-"+end;
|
|
|
msgAlarmResp.setBeginMile(endMile);
|
|
|
String mile = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
|
|
|
msgAlarmResp.setAlarmMile(mile);
|
|
|
- msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude() + "," + baseCameraManagement.getInstallLatitude());
|
|
|
+ msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude()+","+baseCameraManagement.getInstallLatitude());
|
|
|
return AjaxResult.success(msgAlarmResp);
|
|
|
}
|
|
|
|
|
@@ -236,5 +225,188 @@ public class MsgAlarmController extends BaseController {
|
|
|
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) {
|
|
|
+ //创建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);
|
|
|
+ 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();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|