1.冀北:暂态暂降统计列表

2.冀北主网台账:部门电压信息展示
3.冀北:污染指数列表
This commit is contained in:
wr
2023-05-15 16:03:28 +08:00
parent 919c64a463
commit 85fb7c843e
22 changed files with 530 additions and 64 deletions

View File

@@ -32,11 +32,11 @@ public class PmsLedgerStaticDTO implements Serializable {
/**
* 根据单位统计监测点数量
*/
private HashMap<String,List<PmsSimpleDTO>> monitorStatisticsByDept;
private List<List<PmsSimpleDTO.PmsSimpleOrg>> monitorStatisticsByDept;
/**
* 根据单位统计终端数量
*/
private HashMap<String,List<PmsSimpleDTO>> terminalStatisticsByDept;
private List<List<PmsSimpleDTO.PmsSimpleOrg>> terminalStatisticsByDept;
}

View File

@@ -42,10 +42,6 @@ public class PmsMonitorBaseDTO implements Serializable {
*/
private String terminalId;
/***
* 母线ID
*/
private String generatrixId;
/***
* 监测线路名称

View File

@@ -24,4 +24,14 @@ public class PmsSimpleDTO implements Serializable {
private String classification;
private Integer sort;
@ApiModelProperty(name = "id", value = "id")
private String id;
@Data
public static class PmsSimpleOrg extends PmsSimpleDTO{
@ApiModelProperty(name = "OrgName", value = "部门名称")
private String OrgName;
}
}

View File

@@ -43,16 +43,16 @@
<groupId>com.njcn</groupId>
<artifactId>common-web</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.slf4j</groupId>-->
<!-- <artifactId>slf4j-log4j12</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>ch.qos.logback</groupId>-->
<!-- <artifactId>logback-classic</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
</dependency>
<dependency>
<groupId>com.njcn</groupId>

View File

@@ -12,6 +12,8 @@ import com.njcn.device.pms.pojo.param.PmsBaseParam;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.po.SubstationExpend;
import com.njcn.device.pms.service.ISubstationExpendService;
import com.njcn.device.pq.pojo.param.CommunicateParam;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@@ -40,7 +42,7 @@ import java.util.Map;
@Slf4j
@Api(tags = "冀北变电站地图信息")
@RestController
@RequestMapping("/pms/substationExpend")
@RequestMapping("/substationExpend")
@RequiredArgsConstructor
public class SubstationExpendController extends BaseController {
@@ -48,7 +50,7 @@ public class SubstationExpendController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getSubstationExpendInfo")
@PostMapping("/getPVSubstationExpendInfo")
@ApiOperation("冀北变电站地图信息")
@ApiImplicitParam(name = "param", value = "冀北变电站地图信息参数", required = true)
public HttpResult<Map<String, List<SubstationExpend>>> getSubstationExpendInfo(@RequestBody StatisticsBizBaseParam param) {
@@ -61,11 +63,20 @@ public class SubstationExpendController extends BaseController {
@PostMapping("/getLedgerStatic")
@ApiOperation("冀北主网监测点台账统计")
@ApiImplicitParam(name = "param", value = "冀北主网监测点台账统计参数", required = true)
public HttpResult<PmsLedgerStaticDTO> getLedgerStatic(@RequestBody PmsDeviceInfoParam param) {
public HttpResult<PmsLedgerStaticDTO> getLedgerStatic(@RequestBody StatisticsBizBaseParam param) {
String methodDescribe = getMethodDescribe("getLedgerStatic");
PmsLedgerStaticDTO result = substationExpendService.getLedgerStatistics(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getPVCommunicationStatus")
@ApiOperation("冀北主网监测点通讯状态统计")
@ApiImplicitParam(name = "param", value = "冀北主网监测点台账统计参数", required = true)
public HttpResult<List<CommunicateVO.PVCommunicateVO>> getPVCommunicationStatus(@RequestBody CommunicateParam param) {
String methodDescribe = getMethodDescribe("getPVCommunicationStatus");
List<CommunicateVO.PVCommunicateVO> communicationStatus = substationExpendService.getCommunicationStatus(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, communicationStatus, methodDescribe);
}
}

View File

@@ -192,6 +192,7 @@
</select>
<select id="statisticMonitor" resultType="com.njcn.device.pms.pojo.dto.PmsSimpleDTO">
SELECT
pm.Id,
COUNT(pm.Id) AS statistics,
pm.Voltage_Level AS name
FROM pms_monitor pm
@@ -199,7 +200,9 @@
<foreach item="item" collection="list" separator="," open="(" close=")">
#{item}
</foreach>
GROUP BY pm.Voltage_Level
GROUP BY
pm.Id,
pm.Voltage_Level
</select>
<select id="statisticTerminal" resultType="com.njcn.device.pms.pojo.dto.PmsSimpleDTO">
SELECT
@@ -208,8 +211,10 @@
FROM
( SELECT
DISTINCT pm.Terminal_Id,
pm.Voltage_Level
pss.Voltage_Level
FROM pms_monitor pm
INNER JOIN pms_terminal pt on pt.Id=pm.Terminal_Id
INNER JOIN pms_statation_stat pss on pss.Power_Id=pt.Power_Station_Id
WHERE pm.Terminal_Id IN
<foreach item="item" collection="list" separator="," open="(" close=")">
#{item}

View File

@@ -9,7 +9,6 @@
pms_monitor.Operation_Id,
pms_monitor.Powerr_id,
pms_monitor.Terminal_Id,
pms_monitor.Generatrix_Id,
pms_monitor.line_Name,
pms_monitor.line_Id
FROM

View File

@@ -6,6 +6,8 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pms.pojo.dto.PmsLedgerStaticDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.po.SubstationExpend;
import com.njcn.device.pq.pojo.param.CommunicateParam;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
import java.util.List;
import java.util.Map;
@@ -24,5 +26,7 @@ public interface ISubstationExpendService extends IService<SubstationExpend> {
Map<String, List<SubstationExpend>> getSubstationExpendInfo(StatisticsBizBaseParam param);
PmsLedgerStaticDTO getLedgerStatistics(PmsDeviceInfoParam param);
PmsLedgerStaticDTO getLedgerStatistics(StatisticsBizBaseParam param);
List<CommunicateVO.PVCommunicateVO> getCommunicationStatus(CommunicateParam param);
}

View File

@@ -1,28 +1,47 @@
package com.njcn.device.pms.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.controller.ledgerManger.PmsGeneralDeviceController;
import com.njcn.device.pms.mapper.SubstationExpendMapper;
import com.njcn.device.pms.mapper.majornetwork.DistributionMonitorMapper;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
import com.njcn.device.pms.pojo.dto.PmsLedgerStaticDTO;
import com.njcn.device.pms.pojo.dto.PmsSimpleDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.po.PmsTerminal;
import com.njcn.device.pms.pojo.po.SubstationExpend;
import com.njcn.device.pms.service.ISubstationExpendService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.device.pms.service.majornetwork.IPmsGeneralDeviceService;
import com.njcn.device.pms.service.majornetwork.ITerminalService;
import com.njcn.device.pq.pojo.param.CommunicateParam;
import com.njcn.device.pq.pojo.po.Communicate;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -43,9 +62,12 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
private final SubstationExpendMapper substationExpendMapper;
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private final IPmsGeneralDeviceService pmsGeneralDeviceService;
private final DistributionMonitorMapper distributionMonitorMapper;
private final DicDataFeignClient dicDataFeignClient;
private final InfluxDbUtils influxDbUtils;
private final ITerminalService iTerminalService;
@Override
public Map<String, List<SubstationExpend>> getSubstationExpendInfo(StatisticsBizBaseParam param) {
@@ -89,26 +111,61 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
}
@Override
public PmsLedgerStaticDTO getLedgerStatistics(PmsDeviceInfoParam param) {
public PmsLedgerStaticDTO getLedgerStatistics(StatisticsBizBaseParam param) {
PmsLedgerStaticDTO ledgerStaticDTO = new PmsLedgerStaticDTO();
List<PmsGeneralDeviceDTO> generalDeviceDTOS = pmsGeneralDeviceInfoClient.getPwPmsDeviceInfoWithOrgId(param).getData();
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
pmsDeviceInfoParam.setDeptIndex(param.getId());
pmsDeviceInfoParam.setStatisticalType(new SimpleDTO());
List<PmsGeneralDeviceDTO> generalDeviceDTOS = pmsGeneralDeviceService.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam);
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> collect = data.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
// 统计监测点
List<String> monitorIds = new ArrayList<>();
generalDeviceDTOS.stream().forEach(e -> monitorIds.addAll(e.getMonitorIdList()));
List<PmsSimpleDTO> monitorStatistic = distributionMonitorMapper.statisticMonitor(monitorIds);
ledgerStaticDTO.setMonitorStatistics(monitorStatistic);
//获取所有监测点信息
List<String> lineIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getMonitorIdList().stream()).collect(Collectors.toList());
List<PmsSimpleDTO> pmsSimpleDTOS = distributionMonitorMapper.statisticMonitor(lineIds);
//根据电压等级进行分组
Map<String, List<PmsSimpleDTO>> voltageMap = pmsSimpleDTOS.stream().collect(Collectors.groupingBy(
x-> {if (collect.containsKey(x.getName())){
DictData dictData = collect.get(x.getName());
return dictData.getName()+"_"+dictData.getSort();
}
return null;
}
));
// 根据单位统计监测点数量
HashMap<String,List<PmsSimpleDTO>> monitorMap = new HashMap<>();
for (PmsGeneralDeviceDTO generalDeviceDTO : generalDeviceDTOS) {
List<PmsSimpleDTO> monitors = new ArrayList<>();
if (CollectionUtil.isNotEmpty(generalDeviceDTO.getMonitorIdList())) {
monitors = distributionMonitorMapper.statisticMonitor(generalDeviceDTO.getMonitorIdList());
List<List<PmsSimpleDTO.PmsSimpleOrg>> list=new ArrayList<>();
for (PmsGeneralDeviceDTO dto : generalDeviceDTOS) {
List<PmsSimpleDTO.PmsSimpleOrg> dtoList=new ArrayList<>();
for (Map.Entry<String, List<PmsSimpleDTO>> stringListEntry : voltageMap.entrySet()) {
if(StrUtil.isNotBlank(stringListEntry.getKey())){
List<PmsSimpleDTO> monitorList = stringListEntry.getValue().stream().filter(x -> dto.getMonitorIdList().contains(x.getId())).collect(Collectors.toList());
PmsSimpleDTO.PmsSimpleOrg simpleDTO=new PmsSimpleDTO.PmsSimpleOrg();
if(CollUtil.isNotEmpty(monitorList)){
simpleDTO.setStatistics((int) monitorList.stream().mapToDouble(PmsSimpleDTO::getStatistics).sum());
}else{
simpleDTO.setStatistics(0);
}
String key = stringListEntry.getKey();
String[] split = key.split("_");
simpleDTO.setName(split[0]);
simpleDTO.setSort(Integer.valueOf(split[1]));
simpleDTO.setOrgName(dto.getName());
dtoList.add(simpleDTO);
}
monitorMap.put(generalDeviceDTO.getName(),monitors);
}
ledgerStaticDTO.setMonitorStatisticsByDept(monitorMap);
dtoList.sort(Comparator.comparing(r -> r.getSort()));
list.add(dtoList);
}
ledgerStaticDTO.setMonitorStatisticsByDept(list);
// 统计终端
List<String> terminalIds = new ArrayList<>();
List<PmsGeneralDeviceDTO> filterList = generalDeviceDTOS.stream().filter(e -> e.getTerminalIdList().size() != 0).collect(Collectors.toList());
@@ -117,13 +174,54 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
List<PmsSimpleDTO> terminalNumStatistic = distributionMonitorMapper.statisticTerminal(terminalIds);
ledgerStaticDTO.setTerminalStatistics(terminalNumStatistic);
// 根据单位统计终端数量
HashMap<String,List<PmsSimpleDTO>> terminalsMap = new HashMap<>();
for (PmsGeneralDeviceDTO generalDeviceDTO : generalDeviceDTOS) {
List<PmsSimpleDTO> terminals = distributionMonitorMapper.statisticTerminal(terminalIds);
terminalsMap.put(generalDeviceDTO.getName(),terminals);
//获取所有终端信息
List<String> terminalList = generalDeviceDTOS.stream().flatMap(dto -> dto.getTerminalIdList().stream()).collect(Collectors.toList());
List<PmsSimpleDTO> dtoList = distributionMonitorMapper.statisticTerminal(terminalList);
//根据终端电压等级进行分组
Map<String, List<PmsSimpleDTO>> terminalMap = dtoList.stream().collect(Collectors.groupingBy(
x-> {if (collect.containsKey(x.getName())){
DictData dictData = collect.get(x.getName());
return dictData.getName()+"_"+dictData.getSort();
}
ledgerStaticDTO.setTerminalStatisticsByDept(terminalsMap);
return null;
}
));
// 根据单位统计终端数量
List<List<PmsSimpleDTO.PmsSimpleOrg>> terminalInfo=new ArrayList<>();
for (PmsGeneralDeviceDTO dto : generalDeviceDTOS) {
List<PmsSimpleDTO.PmsSimpleOrg> terminal=new ArrayList<>();
for (Map.Entry<String, List<PmsSimpleDTO>> stringListEntry : terminalMap.entrySet()) {
if(StrUtil.isNotBlank(stringListEntry.getKey())){
List<PmsSimpleDTO> monitorList = stringListEntry.getValue().stream().filter(x -> dto.getMonitorIdList().contains(x.getId())).collect(Collectors.toList());
PmsSimpleDTO.PmsSimpleOrg simpleDTO=new PmsSimpleDTO.PmsSimpleOrg();
if(CollUtil.isNotEmpty(monitorList)){
simpleDTO.setStatistics((int) monitorList.stream().mapToDouble(PmsSimpleDTO::getStatistics).sum());
}else{
simpleDTO.setStatistics(0);
}
String key = stringListEntry.getKey();
String[] split = key.split("_");
simpleDTO.setName(split[0]);
simpleDTO.setSort(Integer.valueOf(split[1]));
simpleDTO.setOrgName(dto.getName());
terminal.add(simpleDTO);
}
}
terminal.sort(Comparator.comparing(r -> r.getSort()));
terminalInfo.add(terminal);
}
ledgerStaticDTO.setTerminalStatisticsByDept(list);
// // 根据单位统计终端数量
// HashMap<String,List<PmsSimpleDTO>> terminalsMap = new HashMap<>();
// for (PmsGeneralDeviceDTO generalDeviceDTO : generalDeviceDTOS) {
// List<PmsSimpleDTO> terminals = distributionMonitorMapper.statisticTerminal(terminalIds);
// terminalsMap.put(generalDeviceDTO.getName(),terminals);
// }
// ledgerStaticDTO.setTerminalStatisticsByDept(terminalsMap);
// 统计在线率
List<PmsSimpleDTO> onlineRateStatistic = distributionMonitorMapper.getOnlineRate(terminalIds);
@@ -138,4 +236,54 @@ public class SubstationExpendServiceImpl extends ServiceImpl<SubstationExpendMap
ledgerStaticDTO.setIntegrityStatistics(integrityStatistic);
return ledgerStaticDTO;
}
@Override
public List<CommunicateVO.PVCommunicateVO> getCommunicationStatus(CommunicateParam param) {
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
pmsDeviceInfoParam.setDeptIndex(param.getId());
pmsDeviceInfoParam.setStatisticalType(new SimpleDTO());
List<PmsGeneralDeviceDTO> generalDeviceDTOS = pmsGeneralDeviceService.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam);
//获取所有终端id
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getTerminalIdList().stream()).collect(Collectors.toList());
List<CommunicateVO.PVCommunicateVO> info =new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))).append("' ");
// if(CollUtil.isNotEmpty(terminalIds)){
// stringBuilder.append(" and ").append("(");
// for (int i = 0; i < terminalIds.size(); i++) {
// if (terminalIds.size() - i != 1) {
// stringBuilder.append("dev_id = '").append(terminalIds.get(i)).append("' or ");
// } else {
// stringBuilder.append("dev_id = '").append(terminalIds.get(i)).append("')");
// }
// }
// }
stringBuilder.append(" limit "+param.getLimit());
String sql = "select * from " + InfluxDBPublicParam.PQS_COMMUNICATE + " where " + stringBuilder + InfluxDBPublicParam.TIME_ZONE;
// 获取暂降事件
QueryResult result = influxDbUtils.query(sql);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<Communicate> communicates = influxDBResultMapper.toPOJO(result, Communicate.class);
if(CollUtil.isEmpty(communicates)){
return info;
}
List<String> ids = communicates.stream().map(Communicate::getDevId).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(ids)){
List<PmsTerminal> terminalSelectByIds = iTerminalService.getTerminalSelectByIds(ids);
Map<String, String> terminalNameIp = terminalSelectByIds.stream().collect(Collectors.toMap(PmsTerminal::getId, x -> x.getName() + "_" + x.getIp()));
CommunicateVO.PVCommunicateVO communicate;
for (Communicate cate : communicates) {
communicate=new CommunicateVO.PVCommunicateVO();
BeanUtil.copyProperties(cate, communicate);
communicate.setTime(cate.getUpdateTime());
if(terminalNameIp.containsKey(cate.getDevId())){
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
}
info.add(communicate);
}
}
return info;
}
}

View File

@@ -33,7 +33,12 @@ public interface ITerminalService extends IService<PmsTerminal> {
*/
List<PmsTerminal> getTerminalSelectList(PmsBaseParam pmsBaseParam);
/**
* 根据终端id集合新查询终端信息
* @param ids
* @return
*/
List<PmsTerminal> getTerminalSelectByIds(List<String> ids);
/**
* 根据id查询

View File

@@ -1,5 +1,6 @@
package com.njcn.device.pms.service.majornetwork.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -96,6 +97,14 @@ public class TerminalServiceImpl extends ServiceImpl<TerminalMapper, PmsTerminal
return this.list(lambdaQueryWrapper);
}
@Override
public List<PmsTerminal> getTerminalSelectByIds(List<String> ids) {
return this.list(new LambdaQueryWrapper<PmsTerminal>()
.in(CollUtil.isNotEmpty(ids),PmsTerminal::getId,ids)
.eq(PmsTerminal::getStatus,DataStateEnum.ENABLE.getCode())
);
}
/**
* 根据id查询
* @author hany

View File

@@ -0,0 +1,21 @@
package com.njcn.device.pq.pojo.param;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author wr
* @description
* @date 2023/5/15 9:53
*/
@Data
public class CommunicateParam extends StatisticsBizBaseParam {
/**
* 查询条数
*/
@ApiModelProperty("查询条数")
private Integer limit;
}

View File

@@ -168,5 +168,14 @@ public class DeviceInfoParam implements Serializable {
}
@Data
@EqualsAndHashCode(callSuper = true)
public static class CompareLimitParam extends BusinessParam{
@ApiModelProperty("查询条数")
@NotNull(message = "查询条数查询条数不能为空")
private Integer limit;
}
}

View File

@@ -20,9 +20,6 @@ public class Communicate {
private static final long serialVersionUID = 1L;
/**
* 终端Id
*/
/**
* 更新时间
*/
@@ -31,7 +28,11 @@ public class Communicate {
@Column(name = "line_id")
private String id;
/**
* 终端Id
*/
@Column(name = "dev_id")
private String devId;
/**
* 事件类型(0中断1正常2退出)

View File

@@ -1,8 +1,13 @@
package com.njcn.device.pq.pojo.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.njcn.common.utils.serializer.InstantDateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.influxdb.annotation.Column;
import java.io.Serializable;
import java.time.Instant;
import java.util.List;
/**
@@ -23,4 +28,30 @@ public class CommunicateVO implements Serializable {
* 事件类型(0中断1正常2退出)
*/
private List<Integer> type;
/**
* 冀北分布式光伏概览通讯状态统计(专用)
*/
@Data
public static class PVCommunicateVO{
@ApiModelProperty("监测id")
private String id;
@ApiModelProperty("终端id")
private String devId;
@ApiModelProperty("类型")
private Integer type;
@JsonSerialize(using = InstantDateSerializer.class)
@ApiModelProperty("发生时间")
private Instant time;
@ApiModelProperty("描述")
private String remark;
@ApiModelProperty("终端ip(终端名称_ip)")
private String devIp;
}
}

View File

@@ -42,16 +42,16 @@
<groupId>com.njcn</groupId>
<artifactId>common-web</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.slf4j</groupId>-->
<!-- <artifactId>slf4j-log4j12</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>ch.qos.logback</groupId>-->
<!-- <artifactId>logback-classic</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
</dependency>
<dependency>
<groupId>com.njcn</groupId>

View File

@@ -0,0 +1,50 @@
package com.njcn.device.pq.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.CommunicateParam;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
import com.njcn.device.pq.service.ISubstationExpendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.njcn.web.controller.BaseController;
import java.util.List;
/**
*
*/
@Slf4j
@Api(tags = "冀北变电站地图信息")
@RestController
@RequestMapping("/substationExpend")
@RequiredArgsConstructor
public class SubstationExpendController extends BaseController {
private final ISubstationExpendService substationExpendService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getPVCommunicationStatus")
@ApiOperation("冀北主网监测点通讯状态统计")
@ApiImplicitParam(name = "param", value = "冀北主网监测点台账统计参数", required = true)
public HttpResult<List<CommunicateVO.PVCommunicateVO>> getPVCommunicationStatus(@RequestBody DeviceInfoParam.CompareLimitParam param) {
String methodDescribe = getMethodDescribe("getPVCommunicationStatus");
List<CommunicateVO.PVCommunicateVO> communicationStatus = substationExpendService.getCommunicationStatus(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, communicationStatus, methodDescribe);
}
}

View File

@@ -211,6 +211,7 @@
<select id="getDeviceByIdOnOrOff" resultType="com.njcn.device.pq.pojo.vo.TerminalBaseVO">
SELECT
t1.id devId,
t1.name devName,t2.ip,t2.dev_type,t2.update_time,sub.name subName,gd.name gdName
FROM
pq_line t1,

View File

@@ -0,0 +1,21 @@
package com.njcn.device.pq.service;
import com.njcn.device.pq.pojo.param.CommunicateParam;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zhuxinyu
* @since 2023-05-08
*/
public interface ISubstationExpendService {
List<CommunicateVO.PVCommunicateVO> getCommunicationStatus(DeviceInfoParam.CompareLimitParam param);
}

View File

@@ -0,0 +1,103 @@
package com.njcn.device.pq.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pq.pojo.bo.DeviceType;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.CommunicateParam;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.po.Communicate;
import com.njcn.device.pq.pojo.po.Device;
import com.njcn.device.pq.pojo.vo.CommunicateVO;
import com.njcn.device.pq.pojo.vo.TerminalBaseVO;
import com.njcn.device.pq.service.IDeviceService;
import com.njcn.device.pq.service.ISubstationExpendService;
import com.njcn.device.pq.service.TerminalBaseService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* <p>
* 服务实现类
* </p>
*
* @author zhuxinyu
* @since 2023-05-08
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class SubstationExpendServiceImpl implements ISubstationExpendService {
private final GeneralDeviceService generalDeviceService;
private final InfluxDbUtils influxDbUtils;
private final IDeviceService deviceService;
private final TerminalBaseService terminalBaseService;
@Override
public List<CommunicateVO.PVCommunicateVO> getCommunicationStatus(DeviceInfoParam.CompareLimitParam param) {
List<GeneralDeviceDTO> generalDeviceDTOS = generalDeviceService.getDeviceInfo(param, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
//获取所有终端id
List<String> terminalIds = generalDeviceDTOS.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList());
List<CommunicateVO.PVCommunicateVO> info =new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime()))).append("' ");
if(CollUtil.isNotEmpty(terminalIds)){
stringBuilder.append(" and ").append("(");
for (int i = 0; i < terminalIds.size(); i++) {
if (terminalIds.size() - i != 1) {
stringBuilder.append("dev_id = '").append(terminalIds.get(i)).append("' or ");
} else {
stringBuilder.append("dev_id = '").append(terminalIds.get(i)).append("')");
}
}
}
stringBuilder.append(" limit "+param.getLimit());
String sql = "select * from " + InfluxDBPublicParam.PQS_COMMUNICATE + " where " + stringBuilder + InfluxDBPublicParam.TIME_ZONE;
// 获取暂降事件
QueryResult result = influxDbUtils.query(sql);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<Communicate> communicates = influxDBResultMapper.toPOJO(result, Communicate.class);
if(CollUtil.isEmpty(communicates)){
return info;
}
List<String> ids = communicates.stream().map(Communicate::getDevId).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(ids)){
List<TerminalBaseVO> deviceByIds = terminalBaseService.getDeviceByIdOnOrOff(ids, new DeviceType(), 0);
Map<String, String> terminalNameIp = deviceByIds.stream().collect(Collectors.toMap(TerminalBaseVO::getDevId, x -> x.getDevName() + "_" + x.getIp()));
CommunicateVO.PVCommunicateVO communicate;
for (Communicate cate : communicates) {
communicate=new CommunicateVO.PVCommunicateVO();
BeanUtil.copyProperties(cate, communicate);
communicate.setTime(cate.getUpdateTime());
if(terminalNameIp.containsKey(cate.getDevId())){
communicate.setDevIp(terminalNameIp.get(cate.getDevId()));
}
info.add(communicate);
}
}
return info;
}
}

View File

@@ -40,4 +40,10 @@ public class WaveTypeParam extends DeviceInfoParam.BusinessParam {
value = "通讯状态 0.离线 1.在线"
)
private Integer comFlag = 1;
@ApiModelProperty(
name = "type",
value = "区分 0.pq 1.pms"
)
private Integer type = 0;
}

View File

@@ -440,14 +440,29 @@ public class ReportServiceImpl implements ReportService {
*/
@Override
public Page<DetailVO> getContinueTime(WaveTypeParam waveTypeParam) {
List<String> lineIds =new ArrayList<>();
String eventType="";
List<DetailVO> result = new ArrayList<>();
if(waveTypeParam.getType()==0){
//pq系统
List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
lineIds =deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
}else{
//pms系统
PmsDeviceInfoParam param=new PmsDeviceInfoParam();
param.setDeptIndex(waveTypeParam.getDeptIndex());
param.setStatisticalType(waveTypeParam.getStatisticalType());
List<PmsGeneralDeviceDTO> data = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(param).getData();
lineIds =data.stream().flatMap(list -> list.getMonitorIdList().stream()).collect(Collectors.toList());
eventType=dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData().getId();
}
if (CollectionUtil.isEmpty(lineIds)) {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
Page<RmpEventDetailPO> pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(StrUtil.isNotBlank(eventType),RmpEventDetailPO::getEventType,eventType)
.ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
);
@@ -460,6 +475,8 @@ public class ReportServiceImpl implements ReportService {
result.add(vo);
idlist.add(eventDetail.getLineId());
}
if(waveTypeParam.getType()==0){
//pq系统
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
for (DetailVO detailVO : result) {
@@ -469,6 +486,25 @@ public class ReportServiceImpl implements ReportService {
}
}
}
}else{
//pms系统
List<Monitor> monitorInfo = monitorClient.getMonitorList(idlist).getData();
for (DetailVO detailVO : result) {
for (Monitor vo : monitorInfo) {
if (vo.getId().equals(detailVO.getLineId())) {
detailVO.setLineId(vo.getId());
detailVO.setLineName(vo.getName());
detailVO.setSubId(vo.getPowerrId());
detailVO.setSubName(vo.getPowerrName());
detailVO.setGdId(vo.getOrgId());
detailVO.setGdName(vo.getOrgName());
detailVO.setVoltageScale(vo.getVoltageLevel());
}
}
}
}
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
List<DictData> type = reason.getData();
for (DetailVO detailVO : result) {