Compare commits
2 Commits
ac80a4d040
...
c3bec10f87
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c3bec10f87 | ||
![]() |
7bc871cac7 |
@ -1,5 +1,6 @@
|
|||||||
package com.yfd.platform.modules.algorithm.controller;
|
package com.yfd.platform.modules.algorithm.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmClass;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmDevice;
|
||||||
@ -53,9 +54,10 @@ public class AlgorithmDeviceController {
|
|||||||
|
|
||||||
@PostMapping("/getAlgorithmDeviceCurve")
|
@PostMapping("/getAlgorithmDeviceCurve")
|
||||||
@ApiOperation("查询算法部件的参数曲线")
|
@ApiOperation("查询算法部件的参数曲线")
|
||||||
public ResponseResult getAlgorithmDeviceCurve(String algorithmId, String componentId) {
|
public ResponseResult getAlgorithmDeviceCurve(String algorithmId, String componentId,String type) {
|
||||||
|
type = StrUtil.isBlank(type) ? "1" : type;
|
||||||
List<Map<String, Object>> algorithmDeviceCurveList = algorithmDeviceService.getAlgorithmDeviceCurve(algorithmId,
|
List<Map<String, Object>> algorithmDeviceCurveList = algorithmDeviceService.getAlgorithmDeviceCurve(algorithmId,
|
||||||
componentId);
|
componentId,type);
|
||||||
return ResponseResult.successData(algorithmDeviceCurveList);
|
return ResponseResult.successData(algorithmDeviceCurveList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package com.yfd.platform.modules.algorithm.controller;
|
package com.yfd.platform.modules.algorithm.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
|
||||||
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmLogsService;
|
||||||
|
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.RequestMapping;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 前端控制器
|
* 前端控制器
|
||||||
@ -15,6 +22,21 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/algorithm/algorithm-logs")
|
@RequestMapping("/algorithm/algorithm-logs")
|
||||||
|
@Api(value = "AlgorithmLogsController", tags = "算法分析日志")
|
||||||
public class AlgorithmLogsController {
|
public class AlgorithmLogsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IAlgorithmLogsService algorithmLogsService;
|
||||||
|
|
||||||
|
// 算法分类,区域,间隔,部件
|
||||||
|
@GetMapping("/getAlgorithmLogsPage")
|
||||||
|
@ApiOperation("分页查询算法分析日志")
|
||||||
|
public ResponseResult getAlgorithmLogsPage(String stationCode, String algorithmId, String areaId, String bayId,
|
||||||
|
String mainDeviceId, String componentId, String componentName,
|
||||||
|
Page<AlgorithmLogs> page) {
|
||||||
|
Page<AlgorithmLogs> pageMaps = algorithmLogsService.getAlgorithmLogsPage(stationCode, algorithmId, areaId,
|
||||||
|
bayId, mainDeviceId, componentId, componentName, page);
|
||||||
|
return ResponseResult.successData(pageMaps);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.yfd.platform.modules.algorithm.mapper;
|
package com.yfd.platform.modules.algorithm.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
*/
|
*/
|
||||||
public interface AlgorithmLogsMapper extends BaseMapper<AlgorithmLogs> {
|
public interface AlgorithmLogsMapper extends BaseMapper<AlgorithmLogs> {
|
||||||
|
|
||||||
|
Page<AlgorithmLogs> getAlgorithmLogsPage(String stationCode,String algorithmId, String areaId, String bayId, String mainDeviceId, String componentId,String componentName, Page<AlgorithmLogs> page);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,6 @@ public interface IAlgorithmDeviceService extends IService<AlgorithmDevice> {
|
|||||||
* 参数说明 componentId 部件id
|
* 参数说明 componentId 部件id
|
||||||
* 返回值说明: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
|
* 返回值说明: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
|
||||||
***********************************/
|
***********************************/
|
||||||
List<Map<String, Object>> getAlgorithmDeviceCurve(String algorithmId, String componentId);
|
List<Map<String, Object>> getAlgorithmDeviceCurve(String algorithmId, String componentId,String type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.yfd.platform.modules.algorithm.service;
|
package com.yfd.platform.modules.algorithm.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
@ -13,4 +14,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
*/
|
*/
|
||||||
public interface IAlgorithmLogsService extends IService<AlgorithmLogs> {
|
public interface IAlgorithmLogsService extends IService<AlgorithmLogs> {
|
||||||
|
|
||||||
|
/**********************************
|
||||||
|
* 用途说明: 分页查询算法分析日志
|
||||||
|
* 参数说明 stationCode 变电站编码
|
||||||
|
* 参数说明 algorithmId 算法分类
|
||||||
|
* 参数说明 areaId 区域Id
|
||||||
|
* 参数说明 bayId 间隔Id
|
||||||
|
* 参数说明 mainDeviceId 主设备Id
|
||||||
|
* 参数说明 componentId 部件Id
|
||||||
|
* 参数说明 page 分页参数
|
||||||
|
* 返回值说明: com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.yfd.platform.modules.algorithm.domain.AlgorithmLogs>
|
||||||
|
***********************************/
|
||||||
|
Page<AlgorithmLogs> getAlgorithmLogsPage(String stationCode,String algorithmId, String areaId, String bayId, String mainDeviceId, String componentId,String componentName, Page<AlgorithmLogs> page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.yfd.platform.modules.algorithm.service.IAlgorithmDeviceService;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
|
import com.yfd.platform.modules.auxcontrol.domain.DeviceSignal;
|
||||||
import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData;
|
import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData;
|
||||||
|
import com.yfd.platform.modules.auxcontrol.domain.TimeConfig;
|
||||||
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
||||||
import com.yfd.platform.modules.auxcontrol.service.IDeviceWorkDataService;
|
import com.yfd.platform.modules.auxcontrol.service.IDeviceWorkDataService;
|
||||||
import com.yfd.platform.modules.basedata.domain.SubstationDevice;
|
import com.yfd.platform.modules.basedata.domain.SubstationDevice;
|
||||||
@ -83,7 +84,7 @@ public class AlgorithmDeviceServiceImpl extends ServiceImpl<AlgorithmDeviceMappe
|
|||||||
* 返回值说明: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
|
* 返回值说明: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
|
||||||
***********************************/
|
***********************************/
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getAlgorithmDeviceCurve(String algorithmId, String componentId) {
|
public List<Map<String, Object>> getAlgorithmDeviceCurve(String algorithmId, String componentId,String type) {
|
||||||
List<Map<String, Object>> list = algorithmDeviceMapper.getAlgorithmDeviceType(algorithmId, componentId);
|
List<Map<String, Object>> list = algorithmDeviceMapper.getAlgorithmDeviceType(algorithmId, componentId);
|
||||||
Map<String, List<String>> groupedDevices = list.stream()
|
Map<String, List<String>> groupedDevices = list.stream()
|
||||||
.filter(map -> map.containsKey("sourceType") && map.get("sourceType") != null)
|
.filter(map -> map.containsKey("sourceType") && map.get("sourceType") != null)
|
||||||
@ -115,7 +116,8 @@ public class AlgorithmDeviceServiceImpl extends ServiceImpl<AlgorithmDeviceMappe
|
|||||||
|
|
||||||
for (String signalId : signalIdList) {
|
for (String signalId : signalIdList) {
|
||||||
List<DeviceWorkData> deviceWorkDataGroup = collect.getOrDefault(signalId, Collections.emptyList());
|
List<DeviceWorkData> deviceWorkDataGroup = collect.getOrDefault(signalId, Collections.emptyList());
|
||||||
Map<String, Object> map = processSignalData(deviceWorkDataGroup, signalId);
|
// Map<String, Object> map = processSignalData(deviceWorkDataGroup, signalId);
|
||||||
|
Map<String, Object> map = processDeviceData(deviceWorkDataGroup, signalId,type);
|
||||||
deviceDataList.add(map);
|
deviceDataList.add(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +126,106 @@ public class AlgorithmDeviceServiceImpl extends ServiceImpl<AlgorithmDeviceMappe
|
|||||||
return deviceDataList;
|
return deviceDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Map<String, Object> processDeviceData(List<DeviceWorkData> deviceWorkDataList, String signalId,
|
||||||
|
String type) {
|
||||||
|
// 根据类型生成时间槽和配置参数
|
||||||
|
TimeConfig config = generateTimeConfig(type);
|
||||||
|
|
||||||
|
// 按时间单位分组数据
|
||||||
|
Map<LocalDateTime, String> timeDataMap = groupDataByTimeUnit(deviceWorkDataList, config.getTruncateUnit());
|
||||||
|
|
||||||
|
// 构建xAxis和series数据
|
||||||
|
List<String> xAxisData = new ArrayList<>();
|
||||||
|
List<Double> seriesData = new ArrayList<>();
|
||||||
|
for (LocalDateTime slot : config.getTimeSlots()) {
|
||||||
|
xAxisData.add(slot.format(config.getFormatter()));
|
||||||
|
String value = timeDataMap.getOrDefault(slot, "0");
|
||||||
|
seriesData.add(NumberUtil.parseDouble(NumberUtil.isNumber(value) ? value : "0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建ECharts数据结构
|
||||||
|
return buildEChartsResult(xAxisData, seriesData, signalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按时间单位分组数据
|
||||||
|
*/
|
||||||
|
private Map<LocalDateTime, String> groupDataByTimeUnit(List<DeviceWorkData> dataList, ChronoUnit unit) {
|
||||||
|
Map<LocalDateTime, String> map = new HashMap<>();
|
||||||
|
for (DeviceWorkData data : dataList) {
|
||||||
|
LocalDateTime key = data.getStartTime().truncatedTo(unit);
|
||||||
|
map.put(key, data.getValue());
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建ECharts结果
|
||||||
|
*/
|
||||||
|
private Map<String, Object> buildEChartsResult(List<String> xAxisData, List<Double> seriesData, String signalId) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
// xAxis配置
|
||||||
|
Map<String, Object> xAxis = new HashMap<>();
|
||||||
|
xAxis.put("type", "category");
|
||||||
|
xAxis.put("data", xAxisData);
|
||||||
|
result.put("xAxis", xAxis);
|
||||||
|
|
||||||
|
// yAxis配置
|
||||||
|
Map<String, Object> yAxis = new HashMap<>();
|
||||||
|
yAxis.put("type", "value");
|
||||||
|
result.put("yAxis", yAxis);
|
||||||
|
|
||||||
|
// 系列数据配置
|
||||||
|
DeviceSignal deviceSignal = deviceSignalMapper.selectById(signalId);
|
||||||
|
String seriesName = deviceSignal != null ? deviceSignal.getSignalName() : "";
|
||||||
|
|
||||||
|
List<Map<String, Object>> seriesList = new ArrayList<>();
|
||||||
|
Map<String, Object> series = new HashMap<>();
|
||||||
|
series.put("name", seriesName);
|
||||||
|
series.put("type", "line");
|
||||||
|
series.put("step", "start");
|
||||||
|
series.put("data", seriesData);
|
||||||
|
seriesList.add(series);
|
||||||
|
|
||||||
|
result.put("series", seriesList);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成时间配置
|
||||||
|
*/
|
||||||
|
private TimeConfig generateTimeConfig(String type) {
|
||||||
|
List<LocalDateTime> timeSlots = new ArrayList<>();
|
||||||
|
DateTimeFormatter formatter;
|
||||||
|
ChronoUnit truncateUnit;
|
||||||
|
|
||||||
|
if ("2".equals(type)) {
|
||||||
|
// 类型2:过去24小时(每小时一个点)
|
||||||
|
LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.HOURS);
|
||||||
|
LocalDateTime startTime = now.minusHours(23);
|
||||||
|
for (int i = 0; i < 24; i++) {
|
||||||
|
timeSlots.add(startTime.plusHours(i));
|
||||||
|
}
|
||||||
|
formatter = DateTimeFormatter.ofPattern("HH时");
|
||||||
|
truncateUnit = ChronoUnit.HOURS;
|
||||||
|
} else {
|
||||||
|
// 默认类型1:过去60分钟(每分钟一个点)
|
||||||
|
LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES);
|
||||||
|
LocalDateTime startTime = now.minusMinutes(59);
|
||||||
|
for (int i = 0; i < 60; i++) {
|
||||||
|
timeSlots.add(startTime.plusMinutes(i));
|
||||||
|
}
|
||||||
|
formatter = DateTimeFormatter.ofPattern("HH时mm分");
|
||||||
|
truncateUnit = ChronoUnit.MINUTES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TimeConfig(timeSlots, formatter, truncateUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
* 用途说明: 绘制信号ECharts折线图
|
* 用途说明: 绘制信号ECharts折线图
|
||||||
* 参数说明 deviceWorkDataList 信号数据
|
* 参数说明 deviceWorkDataList 信号数据
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package com.yfd.platform.modules.algorithm.service.impl;
|
package com.yfd.platform.modules.algorithm.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
|
import com.yfd.platform.modules.algorithm.domain.AlgorithmLogs;
|
||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmLogsMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmLogsMapper;
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmLogsService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmLogsService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
@ -17,4 +20,13 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class AlgorithmLogsServiceImpl extends ServiceImpl<AlgorithmLogsMapper, AlgorithmLogs> implements IAlgorithmLogsService {
|
public class AlgorithmLogsServiceImpl extends ServiceImpl<AlgorithmLogsMapper, AlgorithmLogs> implements IAlgorithmLogsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AlgorithmLogsMapper algorithmLogsMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<AlgorithmLogs> getAlgorithmLogsPage(String stationCode,String algorithmId, String areaId, String bayId,
|
||||||
|
String mainDeviceId, String componentId,String componentName, Page<AlgorithmLogs> page) {
|
||||||
|
return algorithmLogsMapper.getAlgorithmLogsPage(stationCode,algorithmId, areaId, bayId,
|
||||||
|
mainDeviceId, componentId,componentName, page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,6 @@ public class DeviceSignalController {
|
|||||||
@ApiOperation("分页查询变电站辅控设备信号")
|
@ApiOperation("分页查询变电站辅控设备信号")
|
||||||
public ResponseResult getDeviceSignalPage(String systemcode,String meterDeviceId,String mainDeviceId, String mainComponentId, String signalName, Page<DeviceSignal> page) {
|
public ResponseResult getDeviceSignalPage(String systemcode,String meterDeviceId,String mainDeviceId, String mainComponentId, String signalName, Page<DeviceSignal> page) {
|
||||||
//参数校验 辅控设备ID不能为空
|
//参数校验 辅控设备ID不能为空
|
||||||
if (StrUtil.isBlank(mainComponentId)) {
|
|
||||||
return ResponseResult.error("参数为空");
|
|
||||||
}
|
|
||||||
Page<DeviceSignal> deviceSignalPage = deviceSignalService.getDeviceSignalPage(systemcode,meterDeviceId,mainDeviceId,mainComponentId, signalName, page);
|
Page<DeviceSignal> deviceSignalPage = deviceSignalService.getDeviceSignalPage(systemcode,meterDeviceId,mainDeviceId,mainComponentId, signalName, page);
|
||||||
return ResponseResult.successData(deviceSignalPage);
|
return ResponseResult.successData(deviceSignalPage);
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,18 @@ package com.yfd.platform.modules.patroltask.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.beanit.iec61850bean.BdaBoolean;
|
|
||||||
import com.beanit.iec61850bean.BdaTimestamp;
|
|
||||||
import com.yfd.platform.component.WebSocketServer;
|
import com.yfd.platform.component.WebSocketServer;
|
||||||
|
import com.yfd.platform.component.iec104.common.BasicInstruction104;
|
||||||
|
import com.yfd.platform.component.iec104.server.master.BootNettyClientChannel;
|
||||||
|
import com.yfd.platform.component.iec104.server.master.BootNettyClientChannelCache;
|
||||||
|
import com.yfd.platform.component.utils.OptimizedThreadPool;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.modules.auxcontrol.domain.AnalogData;
|
import com.yfd.platform.modules.auxcontrol.domain.AnalogData;
|
||||||
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper;
|
||||||
@ -26,12 +29,19 @@ import com.yfd.platform.modules.patroltask.service.ITaskTodoService;
|
|||||||
import com.yfd.platform.utils.SecurityUtils;
|
import com.yfd.platform.utils.SecurityUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,6 +77,8 @@ public class AlarmLogController {
|
|||||||
@Resource
|
@Resource
|
||||||
private TaskResultMapper taskResultMapper;
|
private TaskResultMapper taskResultMapper;
|
||||||
|
|
||||||
|
public static Map<String, String> status = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@GetMapping("/getAlarmLogList")
|
@GetMapping("/getAlarmLogList")
|
||||||
@ApiOperation("查询报警信息")
|
@ApiOperation("查询报警信息")
|
||||||
public ResponseResult getAlarmLogList(String stationId) {
|
public ResponseResult getAlarmLogList(String stationId) {
|
||||||
@ -334,4 +346,141 @@ public class AlarmLogController {
|
|||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sendExcelData")
|
||||||
|
@ApiOperation("批量发送excel数据")
|
||||||
|
public ResponseResult sendExcelData(String fileName) throws Exception {
|
||||||
|
boolean sendExcelData = status.containsKey("sendExcelData");
|
||||||
|
if (sendExcelData) {
|
||||||
|
return ResponseResult.error("当前发送数据进程还没结束");
|
||||||
|
}
|
||||||
|
status.put("sendExcelData", "1");
|
||||||
|
ExecutorService executorService = Executors.newFixedThreadPool(1);
|
||||||
|
executorService.submit(()->{
|
||||||
|
try {
|
||||||
|
processExcelWithSending("D:\\riis\\video\\excel\\" + fileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
executorService.shutdown();
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processExcelWithSending(String filePath) throws Exception {
|
||||||
|
try (FileInputStream file = new FileInputStream(filePath);
|
||||||
|
Workbook workbook = WorkbookFactory.create(file)) {
|
||||||
|
|
||||||
|
Sheet sheet = workbook.getSheetAt(1);
|
||||||
|
Row headerRow = sheet.getRow(1); // 英文注释行
|
||||||
|
|
||||||
|
// 获取列名映射(列索引 -> 英文列名)
|
||||||
|
Map<Integer, String> columnNames = getColumnNames(headerRow);
|
||||||
|
|
||||||
|
// 从数据行开始遍历(第三行)
|
||||||
|
for (int rowIndex = 2; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
||||||
|
Row dataRow = sheet.getRow(rowIndex);
|
||||||
|
if (dataRow == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> payload = buildPayload(columnNames, dataRow);
|
||||||
|
|
||||||
|
System.out.println(payload.toString());
|
||||||
|
if (!payload.isEmpty()) {
|
||||||
|
for (String address : payload.keySet()) {
|
||||||
|
String value = payload.get(address);
|
||||||
|
// 发送数据
|
||||||
|
//更新信号数据值
|
||||||
|
deviceSignalMapper.updateDeviceSignalValue_yc(address, value, getCurrentTime());
|
||||||
|
//插入历史数据
|
||||||
|
deviceWorkDataService.insertData("IEC61850", null, address, value, getCurrentTime());
|
||||||
|
//执行报警处理
|
||||||
|
alarmLogService.doAlaramRecord("IEC61850", "yc", null, address, value);
|
||||||
|
}
|
||||||
|
// 等待5秒
|
||||||
|
waitForNextRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status.remove("sendExcelData");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取列名映射(列索引 -> 英文列名)
|
||||||
|
private static Map<Integer, String> getColumnNames(Row headerRow) {
|
||||||
|
Map<Integer, String> map = new LinkedHashMap<>();
|
||||||
|
if (headerRow != null) {
|
||||||
|
for (int i = 0; i < headerRow.getLastCellNum(); i++) {
|
||||||
|
Cell cell = headerRow.getCell(i, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
|
String trimName = cell.toString().trim();
|
||||||
|
if (StrUtil.isNotBlank(trimName)) {
|
||||||
|
map.put(i, trimName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建请求负载
|
||||||
|
private static Map<String, String> buildPayload(Map<Integer, String> columnNames, Row dataRow) {
|
||||||
|
Map<String, String> payload = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
columnNames.forEach((colIndex, colName) -> {
|
||||||
|
Cell cell = dataRow.getCell(colIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
|
Object parseCellValue = parseCellValue(cell);
|
||||||
|
String value = parseCellValue == null ? "0" : parseCellValue.toString();
|
||||||
|
payload.put(colName, value);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object parseCellValue(Cell cell) {
|
||||||
|
// 获取公式计算器(需要从Workbook获取)
|
||||||
|
FormulaEvaluator evaluator = cell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||||
|
|
||||||
|
switch (cell.getCellType()) {
|
||||||
|
case STRING:
|
||||||
|
return cell.getStringCellValue().trim();
|
||||||
|
case NUMERIC:
|
||||||
|
return org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell) ?
|
||||||
|
cell.getLocalDateTimeCellValue() :
|
||||||
|
cell.getNumericCellValue();
|
||||||
|
case BOOLEAN:
|
||||||
|
return cell.getBooleanCellValue();
|
||||||
|
case FORMULA: {
|
||||||
|
// 计算公式的实际值
|
||||||
|
CellValue cellValue = evaluator.evaluate(cell);
|
||||||
|
return convertCellValue(cellValue);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换计算结果类型的方法
|
||||||
|
private static Object convertCellValue(CellValue cellValue) {
|
||||||
|
switch (cellValue.getCellType()) {
|
||||||
|
case NUMERIC:
|
||||||
|
return cellValue.getNumberValue();
|
||||||
|
case STRING:
|
||||||
|
return cellValue.getStringValue();
|
||||||
|
case BOOLEAN:
|
||||||
|
return cellValue.getBooleanValue();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 等待间隔
|
||||||
|
private static void waitForNextRequest() {
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(60); // 5秒间隔
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
throw new RuntimeException("Data sending interrupted", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,34 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.yfd.platform.modules.algorithm.mapper.AlgorithmLogsMapper">
|
<mapper namespace="com.yfd.platform.modules.algorithm.mapper.AlgorithmLogsMapper">
|
||||||
|
|
||||||
|
<select id="getAlgorithmLogsPage" resultType="com.yfd.platform.modules.algorithm.domain.AlgorithmLogs">
|
||||||
|
SELECT
|
||||||
|
ac.algorithm_class_name,
|
||||||
|
al.*
|
||||||
|
FROM
|
||||||
|
iis_algorithm_logs al
|
||||||
|
INNER JOIN iis_algorithm_class ac ON al.algorithm_id = ac.id
|
||||||
|
WHERE 1=1
|
||||||
|
<if test="stationCode != null and stationCode != ''">
|
||||||
|
AND al.station_code = #{stationCode}
|
||||||
|
</if>
|
||||||
|
<if test="algorithmId != null and algorithmId != ''">
|
||||||
|
AND al.algorithm_id = #{algorithmId}
|
||||||
|
</if>
|
||||||
|
<if test="areaId != null and areaId != ''">
|
||||||
|
AND al.area_id = #{areaId}
|
||||||
|
</if>
|
||||||
|
<if test="bayId != null and bayId != ''">
|
||||||
|
AND al.bay_id = #{bayId}
|
||||||
|
</if>
|
||||||
|
<if test="mainDeviceId != null and mainDeviceId != ''">
|
||||||
|
AND al.main_device_id = #{mainDeviceId}
|
||||||
|
</if>
|
||||||
|
<if test="componentId != null and componentId != ''">
|
||||||
|
AND al.component_id = #{componentId}
|
||||||
|
</if>
|
||||||
|
<if test="componentName != null and componentName != ''">
|
||||||
|
AND al.component_name = #{componentName}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
signal_id=#{signalId}
|
signal_id=#{signalId}
|
||||||
AND start_time >= NOW() - INTERVAL 1 HOUR
|
AND start_time >= NOW() - INTERVAL 1 HOUR
|
||||||
ORDER BY
|
ORDER BY
|
||||||
start_time DESC
|
start_time
|
||||||
</select>
|
</select>
|
||||||
<!-- <select id="getDeviceWorkData" resultType="java.util.Map">-->
|
<!-- <select id="getDeviceWorkData" resultType="java.util.Map">-->
|
||||||
<!-- SELECT-->
|
<!-- SELECT-->
|
||||||
@ -110,6 +110,6 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
AND start_time >= NOW() - INTERVAL 1 HOUR
|
AND start_time >= NOW() - INTERVAL 1 HOUR
|
||||||
ORDER BY
|
ORDER BY
|
||||||
start_time DESC
|
start_time
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -910,6 +910,7 @@ ORDER BY
|
|||||||
<if test="endDate != null and endDate != ''">
|
<if test="endDate != null and endDate != ''">
|
||||||
AND t.patroldevice_date <= #{endDate}
|
AND t.patroldevice_date <= #{endDate}
|
||||||
</if>
|
</if>
|
||||||
|
ORDER BY t.time DESC
|
||||||
</select>
|
</select>
|
||||||
<select id="getResultCurveData" resultType="com.yfd.platform.modules.patroltask.domain.TaskResult">
|
<select id="getResultCurveData" resultType="com.yfd.platform.modules.patroltask.domain.TaskResult">
|
||||||
SELECT
|
SELECT
|
||||||
|
Loading…
Reference in New Issue
Block a user