From a81c158a64561fd03b093a99f511d2df0ad5fc00 Mon Sep 17 00:00:00 2001 From: weitang Date: Sun, 27 Apr 2025 18:15:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iec61850/client/IEC61850Service.java | 3 +- .../controller/DeviceSignalController.java | 14 ++- .../controller/DeviceWorkDataController.java | 21 +++- .../auxcontrol/mapper/DeviceSignalMapper.java | 3 + .../mapper/DeviceWorkDataMapper.java | 2 + .../service/IDeviceSignalService.java | 3 + .../service/IDeviceWorkDataService.java | 4 + .../service/impl/DeviceSignalServiceImpl.java | 5 + .../impl/DeviceWorkDataServiceImpl.java | 9 ++ .../SubstationPatroldeviceController.java | 118 +++++++++--------- .../mapper/auxcontrol/DeviceSignalMapper.xml | 23 +++- .../auxcontrol/DeviceWorkDataMapper.xml | 22 ++++ 12 files changed, 161 insertions(+), 66 deletions(-) diff --git a/riis-system/src/main/java/com/yfd/platform/component/iec61850/client/IEC61850Service.java b/riis-system/src/main/java/com/yfd/platform/component/iec61850/client/IEC61850Service.java index 02c1bfb..170cdb7 100644 --- a/riis-system/src/main/java/com/yfd/platform/component/iec61850/client/IEC61850Service.java +++ b/riis-system/src/main/java/com/yfd/platform/component/iec61850/client/IEC61850Service.java @@ -77,8 +77,7 @@ public class IEC61850Service { //sendCommand("", "a397bf1d4042ae948d248b1f1856937e", "yk", "true"); //sendCommand("", "a397bf1d4042ae948d248b1f1856937e", "yt", "25.6"); } catch (ServiceError | IOException e) { - log.info("未能关联或检索设备的模型 %s: %s", gatewayDevice.getDeviceCode(), - e.getMessage()); + log.info("未能关联或检索设备的模型 {}: {}", gatewayDevice.getDeviceCode(), e.getMessage()); } return true; } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceSignalController.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceSignalController.java index 733df64..3443500 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceSignalController.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceSignalController.java @@ -72,6 +72,18 @@ public class DeviceSignalController { return ResponseResult.successData(list); } + /********************************** + * 用途说明: 查询信号信息 + * 参数说明 + * areaid 区域ID + * 返回值说明: 变电站辅控设备信号集合 + ***********************************/ + @GetMapping("/querySignalDataById") + @ApiOperation("查询信号信息") + public ResponseResult querySignalDataById(String signalId) { + Map map = deviceSignalService.querySignalDataById(signalId); + return ResponseResult.successData(map); + } /*********************************** * 用途说明:新增变电站辅控设备信号 @@ -79,7 +91,7 @@ public class DeviceSignalController { * deviceSignal 变电站辅控设备信号 * 返回值说明: com.yfd.platform.config.ResponseResult 返回新增成功或者失败 ***********************************/ - @Log(module = "变电站辅控设备信号", value = "新增变电站辅控设备信号!",type = "1") + @Log(module = "变电站辅控设备信号", value = "新增变电站辅控设备信号!", type = "1") @PostMapping("/addDeviceSignal") @ApiOperation("新增变电站辅控设备信号") @ResponseBody diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceWorkDataController.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceWorkDataController.java index b5322a0..0d7840b 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceWorkDataController.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/controller/DeviceWorkDataController.java @@ -1,11 +1,18 @@ package com.yfd.platform.modules.auxcontrol.controller; - +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yfd.platform.config.ResponseResult; +import com.yfd.platform.modules.auxcontrol.domain.DeviceAlarmRecord; +import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData; +import com.yfd.platform.modules.auxcontrol.service.IDeviceWorkDataService; 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 javax.annotation.Resource; + /** *

* 变电站-设备-运行数据 前端控制器 @@ -19,4 +26,14 @@ import org.springframework.web.bind.annotation.RestController; @Api(value = "DeviceWorkDataController", tags = "变电站设备运行数据") public class DeviceWorkDataController { + @Resource + private IDeviceWorkDataService deviceWorkDataService; + + @GetMapping("/page") + @ApiOperation("分页查询变电站辅控设备告警记录") + public ResponseResult getDeviceWorkDataPage(Page page, String startDate, String endDate) { + Page deviceWorkDataPage = deviceWorkDataService.getDeviceWorkDataPage(page, startDate, endDate); + return ResponseResult.successData(deviceWorkDataPage); + } + } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceSignalMapper.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceSignalMapper.java index eefe8a0..2881da9 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceSignalMapper.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceSignalMapper.java @@ -26,4 +26,7 @@ public interface DeviceSignalMapper extends BaseMapper { boolean updateDeviceSignalValue_yc(String node_addr,String value,String datetime); @Update("UPDATE fk_device_signal SET yx_value = #{value}, lastmodifydate = #{datetime} WHERE yx_addr = #{node_addr}") boolean updateDeviceSignalValue_yx(String node_addr,String value,String datetime); + + Map querySignalDataById(String signalId); + } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceWorkDataMapper.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceWorkDataMapper.java index c62701c..0465e66 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceWorkDataMapper.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/mapper/DeviceWorkDataMapper.java @@ -1,5 +1,6 @@ package com.yfd.platform.modules.auxcontrol.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface DeviceWorkDataMapper extends BaseMapper { + Page getDeviceWorkDataPage(Page page, String startDate, String endDate); } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceSignalService.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceSignalService.java index 84ed0b4..d4141ca 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceSignalService.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceSignalService.java @@ -54,4 +54,7 @@ public interface IDeviceSignalService extends IService { Page getDeviceSignalPage(String deviceId, String signalName, Page page); List> getDeviceSignalMaps(String mainDeviceId, String signalName); + + Map querySignalDataById(String signalId); + } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceWorkDataService.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceWorkDataService.java index 1a67014..a54b0d7 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceWorkDataService.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/IDeviceWorkDataService.java @@ -1,5 +1,6 @@ package com.yfd.platform.modules.auxcontrol.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData; import com.baomidou.mybatisplus.extension.service.IService; @@ -24,4 +25,7 @@ public interface IDeviceWorkDataService extends IService { * 返回值说明: 无 ***********************************/ void insertData(String from, String slave_ip, String address, String value, String dateTimeString); + + Page getDeviceWorkDataPage(Page page, String startDate, String endDate); + } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceSignalServiceImpl.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceSignalServiceImpl.java index 76fc586..7ec8c66 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceSignalServiceImpl.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceSignalServiceImpl.java @@ -132,4 +132,9 @@ public class DeviceSignalServiceImpl extends ServiceImpl> getDeviceSignalMaps(String mainDeviceId, String signalName) { return deviceSignalMapper.getDeviceSignalMaps(mainDeviceId, signalName); } + + @Override + public Map querySignalDataById(String signalId) { + return deviceSignalMapper.querySignalDataById(signalId); + } } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceWorkDataServiceImpl.java b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceWorkDataServiceImpl.java index 99d18dc..025ef06 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceWorkDataServiceImpl.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/auxcontrol/service/impl/DeviceWorkDataServiceImpl.java @@ -3,6 +3,7 @@ package com.yfd.platform.modules.auxcontrol.service.impl; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yfd.platform.modules.auxcontrol.domain.DeviceWorkData; import com.yfd.platform.modules.auxcontrol.mapper.DeviceSignalMapper; import com.yfd.platform.modules.auxcontrol.mapper.DeviceWorkDataMapper; @@ -28,8 +29,11 @@ import java.util.Map; */ @Service public class DeviceWorkDataServiceImpl extends ServiceImpl implements IDeviceWorkDataService { + @Resource private DeviceSignalMapper deviceSignalMapper; + @Resource + private DeviceWorkDataMapper deviceWorkDataMapper; /********************************** * 用途说明: 导出变电站设备运行数据 @@ -67,4 +71,9 @@ public class DeviceWorkDataServiceImpl extends ServiceImpl getDeviceWorkDataPage(Page page, String startDate, String endDate) { + return deviceWorkDataMapper.getDeviceWorkDataPage(page,startDate,endDate); + } + } diff --git a/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationPatroldeviceController.java b/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationPatroldeviceController.java index a4e7ef2..48f11f2 100644 --- a/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationPatroldeviceController.java +++ b/riis-system/src/main/java/com/yfd/platform/modules/basedata/controller/SubstationPatroldeviceController.java @@ -7,9 +7,12 @@ import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.collect.Lists; import com.yfd.platform.annotation.Log; import com.yfd.platform.config.HttpServerConfig; import com.yfd.platform.config.ResponseResult; +import com.yfd.platform.modules.auxcontrol.domain.GatewayDevice; +import com.yfd.platform.modules.auxcontrol.service.IGatewayDeviceService; import com.yfd.platform.modules.basedata.domain.DeviceChannel; import com.yfd.platform.modules.basedata.domain.PatroldeviceResume; import com.yfd.platform.modules.basedata.domain.SubstationPatroldevice; @@ -84,6 +87,8 @@ public class SubstationPatroldeviceController { private HttpRESTfulUtils httpUtil; @Resource private IRobotOfflineLogService robotOfflineLogService; + @Resource + private IGatewayDeviceService gatewayDeviceService; @Value("${file-space.system}") private String systempath; @@ -838,78 +843,71 @@ public class SubstationPatroldeviceController { return ResponseResult.error("未传变电站信息"); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - SysUser userInfo = userService.getUserInfo(); - Integer usertype = userInfo.getUsertype(); - if (usertype != 0) { - // 非管理员只可以查看指定摄像头 - List ids = substationPatroldeviceService.getCameraIds(userInfo.getId()); - // 获取用户所有的摄像头 - if (ids.size() > 0) { - queryWrapper.in(SubstationPatroldevice::getPatroldeviceId, ids); - } else { - return ResponseResult.successData(null); - } - } - queryWrapper.eq(SubstationPatroldevice::getStationId, stationId).eq(SubstationPatroldevice::getDatastatus, "1"); + // SysUser userInfo = userService.getUserInfo(); + // Integer usertype = userInfo.getUsertype(); + // if (usertype != 0) { + // // 非管理员只可以查看指定摄像头 + // List ids = substationPatroldeviceService.getCameraIds(userInfo.getId()); + // // 获取用户所有的摄像头 + // if (ids.size() > 0) { + // queryWrapper.in(SubstationPatroldevice::getPatroldeviceId, ids); + // } else { + // return ResponseResult.successData(null); + // } + // } + List typeList = Lists.newArrayList("10", "14"); + queryWrapper.eq(SubstationPatroldevice::getStationId, stationId).in(SubstationPatroldevice::getType, + typeList).eq(SubstationPatroldevice::getDatastatus, "1"); List list = substationPatroldeviceService.list(queryWrapper); - String[] codeArray = {"1", "2", "3", "4", "10", "13"}; - List codeList = Arrays.asList(codeArray); - Map> collect = - list.stream().filter(l -> (StrUtil.isNotBlank(l.getType()) && codeList.contains(l.getType()))).collect(Collectors.groupingBy(SubstationPatroldevice::getType)); + Map> listMap = + list.stream().filter(l -> (StrUtil.isNotBlank(l.getType()))).collect(Collectors.groupingBy(SubstationPatroldevice::getType)); Map map = new HashMap<>(); - for (String code : codeList) { - List substationPatroldevices = collect.get(code); + + for (String type : typeList) { + List substationPatroldevices = listMap.get(type); Map map1 = new HashMap<>(); if (substationPatroldevices == null) { map1.put("allCount", 0); map1.put("online", 0); map1.put("onLineRate", 0); - map.put(code, map1); + map.put(type, map1); continue; } - List collect1 = - substationPatroldevices.stream().filter(s -> "1".equals(s.getOnline())).collect(Collectors.toList - ()); - int allCount1 = substationPatroldevices.size(); - int online1 = collect1.size(); + List patroldevices = + substationPatroldevices.stream().filter(s -> "1".equals(s.getOnline())).collect(Collectors.toList()); + int allCount = substationPatroldevices.size(); + int online = patroldevices.size(); - map1.put("allCount", allCount1); - map1.put("online", online1); - map1.put("onLineRate", (int) (((float) online1 / allCount1) * 100 + 0.5)); - map.put(code, map1); + map1.put("allCount", allCount); + map1.put("online", online); + map1.put("onLineRate", (int) (((float) online / allCount) * 100 + 0.5)); + map.put(type, map1); } - // 机器人 - Map map1 = BeanUtil.beanToMap(map.get("1")); - map.remove("1"); - int allCount1 = (Integer) map1.get("allCount"); - int online1 = (Integer) map1.get("online"); - Map map2 = BeanUtil.beanToMap(map.get("2")); - map.remove("2"); - int allCount2 = (Integer) map2.get("allCount"); - int online2 = (Integer) map2.get("online"); - Map map3 = BeanUtil.beanToMap(map.get("3")); - map.remove("3"); - int allCount3 = (Integer) map3.get("allCount"); - int online3 = (Integer) map3.get("online"); - Map map4 = BeanUtil.beanToMap(map.get("4")); - map.remove("4"); - int allCount4 = (Integer) map4.get("allCount"); - int online4 = (Integer) map4.get("online"); - int count = allCount1 + allCount2 + allCount3 + allCount4; - int online = online1 + online2 + online3 + online4; - Map mapAll = new HashMap<>(); - mapAll.put("allCount", count); - mapAll.put("online", online); - mapAll.put("onLineRate", (int) (((float) online / count) * 100 + 0.5)); - map.put("robot", mapAll); - // 无人机 - Map uav = BeanUtil.beanToMap(map.get("13")); - map.remove("13"); - map.put("uav", uav); - // 摄像头 - Map camera = BeanUtil.beanToMap(map.get("10")); + Map cameraMap = BeanUtil.beanToMap(map.get("10")); + Map voiceMap = BeanUtil.beanToMap(map.get("14")); + map.put("camera", cameraMap); map.remove("10"); - map.put("camera", camera); + map.put("voice", voiceMap); + map.remove("14"); + + List gatewayDevices = + gatewayDeviceService.list(new LambdaQueryWrapper().ne(GatewayDevice::getStatus, "00")); + if (gatewayDevices.size() <= 0) { + Map map1 = new HashMap<>(); + map1.put("allCount", 0); + map1.put("online", 0); + map1.put("onLineRate", 0); + map.put("gateway", map1); + } else { + Map map1 = new HashMap<>(); + long online = gatewayDevices.stream().filter(g -> "01".equals(g.getStatus())).count(); + long allCount = gatewayDevices.size(); + map1.put("allCount", allCount); + map1.put("online", online); + map1.put("onLineRate", (int) (((float) online / allCount) * 100 + 0.5)); + map.put("gateway", map1); + + } return ResponseResult.successData(map); } diff --git a/riis-system/src/main/resources/mapper/auxcontrol/DeviceSignalMapper.xml b/riis-system/src/main/resources/mapper/auxcontrol/DeviceSignalMapper.xml index 3093849..f210f69 100644 --- a/riis-system/src/main/resources/mapper/auxcontrol/DeviceSignalMapper.xml +++ b/riis-system/src/main/resources/mapper/auxcontrol/DeviceSignalMapper.xml @@ -65,7 +65,7 @@ - fds.signal_name LIKE CONCAT('',#{signalName},'') + AND fds.signal_name LIKE CONCAT('%',#{signalName},'%') + diff --git a/riis-system/src/main/resources/mapper/auxcontrol/DeviceWorkDataMapper.xml b/riis-system/src/main/resources/mapper/auxcontrol/DeviceWorkDataMapper.xml index 9481316..00f577d 100644 --- a/riis-system/src/main/resources/mapper/auxcontrol/DeviceWorkDataMapper.xml +++ b/riis-system/src/main/resources/mapper/auxcontrol/DeviceWorkDataMapper.xml @@ -2,4 +2,26 @@ +