优化逻辑
This commit is contained in:
parent
272cf93055
commit
ef7c1c9e9d
@ -626,7 +626,6 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<MyMessagePro
|
||||
List<Map<String, String>> items = (List<Map<String, String>>) map.get("Items");
|
||||
for (Map<String, String> item : items) {
|
||||
AlarmLog alarmLog = BeanUtil.toBean(item, AlarmLog.class);
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
String patroldeviceCode = alarmLog.getPatroldeviceCode();
|
||||
List<SubstationPatroldevice> substationPatroldevices =
|
||||
nettyServerHandler.substationPatroldeviceService.list(new LambdaQueryWrapper<SubstationPatroldevice>().eq(SubstationPatroldevice::getPatroldeviceCode, patroldeviceCode));
|
||||
|
@ -35,6 +35,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -203,12 +205,14 @@ public class AlgorithmArrangeController {
|
||||
map.put("stationName", algorithmArrange.getStationName());
|
||||
Map<String, Object> businessTypeMap = sysDictionaryItemsService.getDeviceMapByType("businessType");
|
||||
Map<String, Object> stationTypeMap = sysDictionaryItemsService.getDeviceMapByType("stationType");
|
||||
JSONObject businessTypeJSON= JSONUtil.parseObj(businessTypeMap.get("resultMap"));
|
||||
JSONObject stationTypeJSON= JSONUtil.parseObj(stationTypeMap.get("resultMap"));
|
||||
String businessType = StrUtil.isNotBlank(algorithmArrange.getBusinessType()) ? businessTypeJSON.getStr(algorithmArrange.getBusinessType()) : "";
|
||||
String stationType = StrUtil.isNotBlank(algorithmArrange.getStationType()) ? stationTypeJSON.getStr(algorithmArrange.getStationType()) : "";
|
||||
JSONObject businessTypeJSON = JSONUtil.parseObj(businessTypeMap.get("resultMap"));
|
||||
JSONObject stationTypeJSON = JSONUtil.parseObj(stationTypeMap.get("resultMap"));
|
||||
String businessType = StrUtil.isNotBlank(algorithmArrange.getBusinessType()) ?
|
||||
businessTypeJSON.getStr(algorithmArrange.getBusinessType()) : "";
|
||||
String stationType = StrUtil.isNotBlank(algorithmArrange.getStationType()) ?
|
||||
stationTypeJSON.getStr(algorithmArrange.getStationType()) : "";
|
||||
map.put("stationType", stationType);
|
||||
map.put("businessType",businessType);
|
||||
map.put("businessType", businessType);
|
||||
map.put("voltLevel", algorithmArrange.getVoltLevel());
|
||||
map.put("status", "完成");
|
||||
map.put("date", DateUtil.now());
|
||||
@ -243,7 +247,7 @@ public class AlgorithmArrangeController {
|
||||
"")).getPath() + "templates" + File.separator + "布点报告模板.docx";
|
||||
XWPFTemplate compile = XWPFTemplate.compile(path, config);
|
||||
XWPFTemplate template = compile.render(map);
|
||||
// template.write(new FileOutputStream("E:\\巡视报告模板.docx"));
|
||||
// template.write(new FileOutputStream("E:\\巡视报告模板.docx"));
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-disposition", "attachment;filename=reportTemp.docx");
|
||||
|
||||
@ -255,6 +259,113 @@ public class AlgorithmArrangeController {
|
||||
PoitlIOUtils.closeQuietlyMulti(template, bos, out);
|
||||
}
|
||||
|
||||
@PostMapping("/createArrangeById")
|
||||
@ApiOperation("创建布点报告")
|
||||
public ResponseResult exportArrangeById(String id) throws IOException {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
AlgorithmArrange algorithmArrange = algorithmArrangeService.getById(id);
|
||||
map.put("arrangeName", algorithmArrange.getArrangeName());
|
||||
map.put("stationName", algorithmArrange.getStationName());
|
||||
Map<String, Object> businessTypeMap = sysDictionaryItemsService.getDeviceMapByType("businessType");
|
||||
Map<String, Object> stationTypeMap = sysDictionaryItemsService.getDeviceMapByType("stationType");
|
||||
JSONObject businessTypeJSON = JSONUtil.parseObj(businessTypeMap.get("resultMap"));
|
||||
JSONObject stationTypeJSON = JSONUtil.parseObj(stationTypeMap.get("resultMap"));
|
||||
String businessType = StrUtil.isNotBlank(algorithmArrange.getBusinessType()) ?
|
||||
businessTypeJSON.getStr(algorithmArrange.getBusinessType()) : "";
|
||||
String stationType = StrUtil.isNotBlank(algorithmArrange.getStationType()) ?
|
||||
stationTypeJSON.getStr(algorithmArrange.getStationType()) : "";
|
||||
map.put("stationType", stationType);
|
||||
map.put("businessType", businessType);
|
||||
map.put("voltLevel", algorithmArrange.getVoltLevel());
|
||||
map.put("status", "完成");
|
||||
map.put("date", DateUtil.now());
|
||||
List<Map<String, Object>> arrangeDeviceInfo = algorithmArrangeDeviceService.getArrangeDeviceInfo(id);
|
||||
arrangeDeviceInfo.forEach(a -> {
|
||||
// 图片流
|
||||
a.put("index", arrangeDeviceInfo.indexOf(a) + 1);
|
||||
});
|
||||
try {
|
||||
|
||||
String arrangeImageUrl = algorithmArrange.getArrangeImageUrl();
|
||||
if (StrUtil.isNotBlank(arrangeImageUrl)) {
|
||||
map.put("img",
|
||||
Pictures.ofStream(Files.newInputStream(new File(httpServerConfig.getPlanFilePath() + arrangeImageUrl).toPath()), FileUtil.getPictureType(arrangeImageUrl)).fitSize().create());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
List<Map<String, Object>> demo = getMapData();
|
||||
//创建一个列表的规则
|
||||
HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
|
||||
//设置列表配置,如果有多个列表时需加.bind("list1", policy) 新列表配置即可
|
||||
Configure config = Configure.builder().bind("list", policy).build();
|
||||
if (!arrangeDeviceInfo.isEmpty()) {
|
||||
map.put("list", arrangeDeviceInfo);
|
||||
} else {
|
||||
map.put("list", demo);
|
||||
}
|
||||
// 加载模板渲染数据
|
||||
String path = Objects.requireNonNull(Objects.requireNonNull(ClassUtils.getDefaultClassLoader()).getResource(
|
||||
"")).getPath() + "templates" + File.separator + "布点报告模板.docx";
|
||||
XWPFTemplate compile = XWPFTemplate.compile(path, config);
|
||||
XWPFTemplate template = compile.render(map);
|
||||
String fileName = "report" + File.separator + id + ".docx";
|
||||
String filePath = httpServerConfig.getPlanFilePath() + fileName;
|
||||
Path reportPath = Paths.get(filePath);
|
||||
// 确保父目录存在,如果不存在则创建
|
||||
Files.createDirectories(reportPath.getParent());
|
||||
template.write(Files.newOutputStream(reportPath));
|
||||
LambdaUpdateWrapper<AlgorithmArrange> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(AlgorithmArrange::getId, id).set(AlgorithmArrange::getCustom2, fileName);
|
||||
algorithmArrangeService.update(updateWrapper);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@GetMapping("/downloadArrangeReport")
|
||||
@ApiOperation("下载布点报告")
|
||||
public void downloadArrangeReport(String id, HttpServletResponse response) {
|
||||
try {
|
||||
AlgorithmArrange algorithmArrange = algorithmArrangeService.getById(id);
|
||||
String fileName = algorithmArrange.getCustom2();
|
||||
if (StrUtil.isBlank(fileName)) {
|
||||
return;
|
||||
}
|
||||
// 构建文件路径
|
||||
String filePath = httpServerConfig.getPlanFilePath() + fileName;
|
||||
File file = new File(filePath);
|
||||
|
||||
if (!file.exists()) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "报告文件不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置响应头
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + id + ".docx\"");
|
||||
|
||||
// 输出文件流到响应
|
||||
try (InputStream inputStream = Files.newInputStream(file.toPath());
|
||||
OutputStream out = response.getOutputStream()) {
|
||||
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, bytesRead);
|
||||
}
|
||||
out.flush();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("下载报告失败:{}", e.getMessage(), e);
|
||||
try {
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "下载失败:" + e.getMessage());
|
||||
} catch (IOException ex) {
|
||||
log.error("发送错误响应失败:{}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getMapData() {
|
||||
List<Map<String, Object>> demo = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -6,9 +6,7 @@ import com.yfd.platform.modules.algorithm.domain.AlgorithmArrangeDevice;
|
||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmArrangeDeviceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@ -31,12 +29,23 @@ public class AlgorithmArrangeDeviceController {
|
||||
private IAlgorithmArrangeDeviceService algorithmArrangeDeviceService;
|
||||
|
||||
@GetMapping("/getArrangeDeviceInfo")
|
||||
@ApiOperation("查询当前布点的主设备数量")
|
||||
@ApiOperation("查询布点区域的设备数量")
|
||||
public ResponseResult getArrangeDeviceInfo(String arrangeId) {
|
||||
List<Map<String, Object>> maps = algorithmArrangeDeviceService.getArrangeDeviceInfo(arrangeId);
|
||||
return ResponseResult.successData(maps);
|
||||
}
|
||||
|
||||
@PostMapping("/saveBatchArrange")
|
||||
@ApiOperation("批量保存或修改布点数据")
|
||||
public ResponseResult saveBatchArrange(@RequestBody List<AlgorithmArrangeDevice> algorithmArrangeDevices) {
|
||||
boolean b = algorithmArrangeDeviceService.saveOrUpdateBatch(algorithmArrangeDevices);
|
||||
if (b) {
|
||||
return ResponseResult.success();
|
||||
} else {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getArrangeDeviceById")
|
||||
@ApiOperation("根据ID查询当前布点详情")
|
||||
public ResponseResult getArrangeDeviceById(String arrangeId) {
|
||||
|
@ -3,6 +3,7 @@ package com.yfd.platform.modules.algorithm.domain;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -57,5 +58,9 @@ public class AlgorithmClass implements Serializable {
|
||||
@ApiModelProperty("服务地址")
|
||||
private String serviceAddress;
|
||||
|
||||
|
||||
/**
|
||||
* 类型,1:故障预警;2:故障诊断,3:健康评估
|
||||
*/
|
||||
@ApiModelProperty("类型,1:故障预警;2:故障诊断,3:健康评估")
|
||||
private String algorithmType;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.yfd.platform.modules.algorithm.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -11,9 +12,14 @@ import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmLogsMapper;
|
||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper;
|
||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
|
||||
import com.yfd.platform.modules.basedata.domain.Substation;
|
||||
import com.yfd.platform.modules.basedata.domain.SubstationComponent;
|
||||
import com.yfd.platform.modules.basedata.mapper.SubstationComponentMapper;
|
||||
import com.yfd.platform.modules.basedata.mapper.SubstationMapper;
|
||||
import com.yfd.platform.modules.patroltask.domain.AlarmLog;
|
||||
import com.yfd.platform.modules.patroltask.mapper.AlarmLogMapper;
|
||||
import com.yfd.platform.utils.HttpRESTfulUtils;
|
||||
import com.yfd.platform.utils.SecurityUtils;
|
||||
import com.yfd.platform.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -21,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -28,7 +35,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zhengsl
|
||||
@ -46,9 +53,15 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
||||
@Resource
|
||||
private AlgorithmDeviceMapper algorithmDeviceMapper;
|
||||
|
||||
@Resource
|
||||
private AlarmLogMapper alarmLogMapper;
|
||||
|
||||
@Resource
|
||||
private SubstationComponentMapper substationComponentMapper;
|
||||
|
||||
@Resource
|
||||
private SubstationMapper substationMapper;
|
||||
|
||||
@Resource
|
||||
private AlgorithmLogsMapper algorithmLogsMapper;
|
||||
|
||||
@ -134,8 +147,8 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
||||
}
|
||||
// 固定参数就是固定参数,点位数据是默认最新点位,信号也是找最新数据
|
||||
List<Map<String, String>> mapList = algorithmParamsMapper.getAnalyseParams(id, componentId);
|
||||
if (mapList.size() <= 0) {
|
||||
return null;
|
||||
if (mapList.isEmpty()) {
|
||||
return new JSONObject();
|
||||
}
|
||||
Map<String, Object> senData = new HashMap<>();
|
||||
for (Map<String, String> map : mapList) {
|
||||
@ -152,6 +165,14 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
||||
algorithmLogs.setParamsValue(senData.toString());
|
||||
if (jsonObject.containsKey("result")) {
|
||||
algorithmLogs.setAnalysisResult(jsonObject.getString("result"));
|
||||
JSONObject result = jsonObject.getJSONObject("result");
|
||||
String value = result.getString("value");
|
||||
String description = result.getString("description");
|
||||
if ("1".equals(value)) {
|
||||
// 创建告警数据
|
||||
AlarmLog alarmLog = buildAlarmLog(substationComponent, desc, description, algorithmClass, senData);
|
||||
alarmLogMapper.insert(alarmLog);
|
||||
}
|
||||
}
|
||||
algorithmLogs.setAnalysisTime(LocalDateTime.now());
|
||||
algorithmLogsMapper.insert(algorithmLogs);
|
||||
@ -160,4 +181,47 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
||||
jsonObject.put("desc", desc);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private AlarmLog buildAlarmLog(SubstationComponent component, String desc, String description,
|
||||
AlgorithmClass algorithmClass, Map<String, Object> senData) {
|
||||
|
||||
Substation substation =
|
||||
substationMapper.selectOne(new LambdaQueryWrapper<Substation>().eq(Substation::getStationCode,
|
||||
component.getStationCode()));
|
||||
AlarmLog alarmLog = new AlarmLog();
|
||||
alarmLog.setStationCode(component.getStationCode());
|
||||
if (substation != null) {
|
||||
// 注意:这里原代码用了 stationCode 当 stationId,可能需要修正
|
||||
alarmLog.setStationId(substation.getStationId());
|
||||
}
|
||||
alarmLog.setStationName(component.getStationName());
|
||||
alarmLog.setAreaId(component.getAreaId());
|
||||
alarmLog.setAreaName(component.getAreaName());
|
||||
alarmLog.setBayId(component.getBayId());
|
||||
alarmLog.setBayName(component.getBayName());
|
||||
alarmLog.setMainDeviceId(component.getMainDeviceId());
|
||||
alarmLog.setMainDeviceName(component.getMainDeviceName());
|
||||
alarmLog.setMaterialId(component.getMaterialId());
|
||||
alarmLog.setComponentId(component.getComponentId());
|
||||
alarmLog.setComponentName(component.getComponentName());
|
||||
alarmLog.setValue(JSONObject.toJSONString(senData)); // 推荐转为 JSON 字符串
|
||||
alarmLog.setContent(desc + ":" + description);
|
||||
alarmLog.setAlarmDate(DateUtil.now());
|
||||
alarmLog.setAlarmLevel("3");
|
||||
alarmLog.setTaskAlarmType("4");
|
||||
alarmLog.setCheckFlag("0");
|
||||
alarmLog.setDatastatus("1");
|
||||
|
||||
// 设置告警来源类型
|
||||
if ("1".equals(algorithmClass.getAlgorithmType())) {
|
||||
alarmLog.setTaskAlarmType("5");
|
||||
} else if ("2".equals(algorithmClass.getAlgorithmType())) {
|
||||
alarmLog.setTaskAlarmType("6");
|
||||
}
|
||||
alarmLog.setLastmodifier(SecurityUtils.getCurrentUsername());
|
||||
alarmLog.setLastmodifydate(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
return alarmLog;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.yfd.platform.modules.patroltask.controller;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@ -49,7 +50,6 @@ import java.util.stream.Collectors;
|
||||
* 告警日志表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @since 2023-05-03
|
||||
*/
|
||||
@RestController
|
||||
@ -95,12 +95,13 @@ public class AlarmLogController {
|
||||
if (StrUtil.isBlank(stationId)) {
|
||||
return ResponseResult.successData(null);
|
||||
}
|
||||
List<AlarmLog> list =alarmLogService.getNotCheckAlarmCount(stationId);
|
||||
// String[] split = stationId.split(",");
|
||||
// LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(AlarmLog::getDatastatus, "1").in(AlarmLog::getStationId, Arrays.asList(split)).eq(AlarmLog::getCheckFlag
|
||||
// , 0).orderByDesc(AlarmLog::getAlarmDate);
|
||||
// List<AlarmLog> list = alarmLogService.list(queryWrapper);
|
||||
List<AlarmLog> list = alarmLogService.getNotCheckAlarmCount(stationId);
|
||||
// String[] split = stationId.split(",");
|
||||
// LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(AlarmLog::getDatastatus, "1").in(AlarmLog::getStationId, Arrays.asList(split)).eq
|
||||
// (AlarmLog::getCheckFlag
|
||||
// , 0).orderByDesc(AlarmLog::getAlarmDate);
|
||||
// List<AlarmLog> list = alarmLogService.list(queryWrapper);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("count", list.size());
|
||||
map.put("notCheck", list);
|
||||
@ -125,7 +126,8 @@ public class AlarmLogController {
|
||||
}
|
||||
List<String> idList = Arrays.asList(stationId.split(","));
|
||||
LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(AlarmLog::getStationId, idList).isNotNull(AlarmLog::getAlarmLevel).eq(AlarmLog::getDatastatus, "1").select(AlarmLog::getId,
|
||||
queryWrapper.in(AlarmLog::getStationId, idList).isNotNull(AlarmLog::getAlarmLevel).eq(AlarmLog::getDatastatus
|
||||
, "1").select(AlarmLog::getId,
|
||||
AlarmLog::getContent, AlarmLog::getAlarmLevel, AlarmLog::getAlarmDate, AlarmLog::getStationName);
|
||||
List<Map<String, Object>> maps = alarmLogService.listMaps(queryWrapper);
|
||||
Map<Object, List<Map<String, Object>>> alarmLevel = maps.stream().collect(Collectors.groupingBy(m -> m.get(
|
||||
@ -188,25 +190,36 @@ public class AlarmLogController {
|
||||
return ResponseResult.successData(alarmList);
|
||||
}
|
||||
|
||||
// @GetMapping("/getAlarmLogPage")
|
||||
// @ApiOperation("根据设备编号查询告警列表")
|
||||
// public ResponseResult getAlarmLogPage(Page<Map<String, Object>> page,) {
|
||||
//
|
||||
// return ResponseResult.successData(null);
|
||||
// }
|
||||
|
||||
@GetMapping("/getAlarmLogPage")
|
||||
@ApiOperation("告警信息确认分页")
|
||||
public ResponseResult getAlarmLogPage(Page<Map<String, Object>> page, String stationCode, String taskAlarmType,
|
||||
String alarmLevel, String checkFlag,String alarmSourceType, String startDate, String endDate) {
|
||||
String alarmLevel, String checkFlag, String alarmSourceType,
|
||||
String startDate, String endDate) {
|
||||
if (StrUtil.isBlank(stationCode)) {
|
||||
return ResponseResult.successData(page);
|
||||
}
|
||||
Page<Map<String, Object>> alarmList = alarmLogService.getAlarmLogPage(page, stationCode, taskAlarmType,
|
||||
alarmLevel, checkFlag,alarmSourceType, startDate, endDate);
|
||||
alarmLevel, checkFlag, alarmSourceType, startDate, endDate);
|
||||
|
||||
List<Map<String, Object>> records = alarmList.getRecords();
|
||||
records.forEach(r -> {
|
||||
String patroldeviceCode = r.get("patroldeviceCode").toString();
|
||||
LambdaQueryWrapper<DeviceChannel> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(DeviceChannel::getDeviceid, patroldeviceCode).select(DeviceChannel::getDeviceid,
|
||||
DeviceChannel::getChannelid);
|
||||
List<Map<String, Object>> channelList = deviceChannelService.listMaps(queryWrapper1);
|
||||
if (channelList != null && channelList.size() > 0) {
|
||||
r.put("channelList", channelList);
|
||||
String patroldeviceCode = ObjectUtil.isNotEmpty(r.get("patroldeviceCode")) ?
|
||||
r.get("patroldeviceCode").toString() : "";
|
||||
if (StrUtil.isNotBlank(patroldeviceCode)) {
|
||||
LambdaQueryWrapper<DeviceChannel> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(DeviceChannel::getDeviceid, patroldeviceCode).select(DeviceChannel::getDeviceid,
|
||||
DeviceChannel::getChannelid);
|
||||
List<Map<String, Object>> channelList = deviceChannelService.listMaps(queryWrapper1);
|
||||
if (channelList != null && !channelList.isEmpty()) {
|
||||
r.put("channelList", channelList);
|
||||
}
|
||||
}
|
||||
});
|
||||
alarmList.setRecords(records);
|
||||
@ -267,7 +280,8 @@ public class AlarmLogController {
|
||||
@ApiOperation("根据机器人编号查询告警历史(前20条)")
|
||||
public ResponseResult getAlarmHistory(String patroldeviceCode) {
|
||||
LambdaQueryWrapper<AlarmLog> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AlarmLog::getPatroldeviceCode, patroldeviceCode).select(AlarmLog::getAlarmDate,AlarmLog::getContent).orderByDesc(AlarmLog::getAlarmDate).last("LIMIT 20");
|
||||
queryWrapper.eq(AlarmLog::getPatroldeviceCode, patroldeviceCode).select(AlarmLog::getAlarmDate,
|
||||
AlarmLog::getContent).orderByDesc(AlarmLog::getAlarmDate).last("LIMIT 20");
|
||||
List<Map<String, Object>> mapList = alarmLogService.listMaps(queryWrapper);
|
||||
return ResponseResult.successData(mapList);
|
||||
}
|
||||
@ -279,7 +293,6 @@ public class AlarmLogController {
|
||||
return ResponseResult.successData(alarmLog);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getConfirmationRate")
|
||||
@ApiOperation("告警准确率统计")
|
||||
public ResponseResult getConfirmationRate(String stationId) {
|
||||
@ -289,7 +302,7 @@ public class AlarmLogController {
|
||||
|
||||
@GetMapping("/sendAlarmById")
|
||||
@ApiOperation("发送报警")
|
||||
public ResponseResult sendAlarmById(String stationId,String id) {
|
||||
public ResponseResult sendAlarmById(String stationId, String id) {
|
||||
AlarmLog alarmLog = alarmLogService.getById(id);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(alarmLog);
|
||||
TaskResult taskResult = taskResultMapper.selectById(alarmLog.getTaskResultId());
|
||||
@ -340,7 +353,7 @@ public class AlarmLogController {
|
||||
}
|
||||
status.put("sendExcelData", "1");
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(1);
|
||||
executorService.submit(()->{
|
||||
executorService.submit(() -> {
|
||||
try {
|
||||
processExcelWithSending("D:\\riis\\video\\excel\\" + fileName);
|
||||
} catch (Exception e) {
|
||||
|
@ -309,8 +309,4 @@ public class AlarmLog implements Serializable {
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* 报警来源类型(1:智巡;2:辅控)
|
||||
*/
|
||||
private String alarmSourceType;
|
||||
}
|
||||
|
@ -712,7 +712,6 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
||||
alarmLog.setAreaName(taskResult.getAreaName());
|
||||
alarmLog.setBayId(taskResult.getBayId());
|
||||
alarmLog.setBayName(taskResult.getBayName());
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
alarmLog.setMainDeviceId(taskResult.getMainDeviceId());
|
||||
alarmLog.setMainDeviceName(taskResult.getMainDeviceName());
|
||||
alarmLog.setComponentId(taskResult.getComponentId());
|
||||
@ -1764,7 +1763,6 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
||||
alarmLog.setComponentName(taskResult.getComponentName());
|
||||
alarmLog.setDeviceId(taskResult.getDeviceId());
|
||||
alarmLog.setDeviceName(taskResult.getDeviceName());
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
alarmLog.setPatroldeviceCode(taskResult.getPatroldeviceCode());
|
||||
alarmLog.setPatroldeviceName(taskResult.getPatroldeviceName());
|
||||
alarmLog.setMaterialId(taskResult.getMaterialId());
|
||||
@ -1986,7 +1984,6 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
|
||||
if ("2000".equals(code)) {
|
||||
Thread.sleep(1500);//延迟1.5秒
|
||||
AlarmLog alarmLog = new AlarmLog();
|
||||
alarmLog.setAlarmSourceType("1");
|
||||
alarmLog.setId(IdUtil.fastSimpleUUID());
|
||||
//摄像机ID
|
||||
String deviceid = jsonObject.getStr("requestId");
|
||||
|
@ -79,7 +79,7 @@
|
||||
SELECT
|
||||
id,
|
||||
station_id,
|
||||
alarm_source_type,
|
||||
task_alarm_type,
|
||||
content,
|
||||
alarm_level alarm_level,
|
||||
alarm_date
|
||||
@ -144,7 +144,6 @@
|
||||
al.notice_linkages,
|
||||
al.alarm_class,
|
||||
al.region,
|
||||
al.alarm_source_type,
|
||||
tr.patroldevice_code deviceId,
|
||||
tr.patroldevice_channelcode channelId,
|
||||
tr.patroldevice_pos patroldevicePos,
|
||||
@ -240,9 +239,6 @@
|
||||
<if test="checkFlag != null and checkFlag != ''">
|
||||
AND al.check_flag = #{checkFlag}
|
||||
</if>
|
||||
<if test="alarmSourceType != null and alarmSourceType != ''">
|
||||
AND al.alarm_source_type = #{alarmSourceType}
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and al.alarm_date >= #{startDate}
|
||||
</if>
|
||||
@ -250,8 +246,6 @@
|
||||
and al.alarm_date < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
|
||||
</if>
|
||||
ORDER BY al.alarm_date DESC
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<!-- <select id="getDeviceAlarmRecordPage"-->
|
||||
|
Loading…
Reference in New Issue
Block a user