getStatationStatCurve(String subID,String voltageLevel,Integer type);
}
diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java
index dcf8627a0..082a073c8 100644
--- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java
+++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java
@@ -1,13 +1,18 @@
package com.njcn.device.pms.service.majornetwork.impl;
+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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
+import com.njcn.common.utils.PubUtils;
import com.njcn.device.pms.enums.PmsDeviceResponseEnum;
import com.njcn.device.pms.mapper.majornetwork.*;
+import com.njcn.device.pms.pojo.dto.PmsMonitorBaseDTO;
import com.njcn.device.pms.pojo.dto.PmsStatationStatInfoDTO;
import com.njcn.device.pms.pojo.param.PmsBaseParam;
import com.njcn.device.pms.pojo.param.StatationStatParam;
@@ -16,18 +21,28 @@ import com.njcn.device.pms.pojo.po.*;
import com.njcn.device.pms.pojo.vo.StatationStatVO;
import com.njcn.device.pms.service.majornetwork.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.njcn.event.pojo.vo.DeptLevelVO;
+import com.njcn.event.utils.DeptUtil;
+import com.njcn.influx.pojo.po.DataV;
+import com.njcn.influx.service.IDataVService;
+import com.njcn.system.api.DicDataFeignClient;
+import com.njcn.system.enums.DicDataEnum;
+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 com.njcn.user.pojo.po.Dept;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.param.BaseParam;
import lombok.RequiredArgsConstructor;
-import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
-import java.util.List;
-import java.util.Objects;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.*;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
*
@@ -53,8 +68,9 @@ public class StatationStatServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(StatationStat::getOrgId,statationStatParam.getOrgId())
- .eq(StatationStat::getPowerName,statationStatParam.getPowerName());
+ lambdaQueryWrapper.eq(StatationStat::getOrgId, statationStatParam.getOrgId())
+ .eq(StatationStat::getPowerName, statationStatParam.getPowerName());
int count = this.count(lambdaQueryWrapper);
- if(count>0){
+ if (count > 0) {
throw new BusinessException(PmsDeviceResponseEnum.DEPT_STATION_REPEAT);
}
@@ -95,11 +111,11 @@ public class StatationStatServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(StatationStat::getOrgId,statationStatParam.getOrgId())
- .eq(StatationStat::getPowerName,statationStatParam.getPowerName())
- .ne(StatationStat::getPowerId,statationStatParam.getPowerId());
+ lambdaQueryWrapper.eq(StatationStat::getOrgId, statationStatParam.getOrgId())
+ .eq(StatationStat::getPowerName, statationStatParam.getPowerName())
+ .ne(StatationStat::getPowerId, statationStatParam.getPowerId());
int count = this.count(lambdaQueryWrapper);
- if(count>0){
+ if (count > 0) {
throw new BusinessException(PmsDeviceResponseEnum.DEPT_STATION_REPEAT);
}
@@ -109,12 +125,12 @@ public class StatationStatServiceImpl extends ServiceImpl monitorLambdaQueryWrapper = new LambdaQueryWrapper<>();
- monitorLambdaQueryWrapper.eq(Monitor::getStatus,DataStateEnum.ENABLE.getCode()).eq(Monitor::getPowerrId,statationStat.getPowerId());
+ monitorLambdaQueryWrapper.eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode()).eq(Monitor::getPowerrId, statationStat.getPowerId());
//主网监测点
List monitorList = iMonitorService.list(monitorLambdaQueryWrapper);
- if(CollectionUtil.isNotEmpty(monitorList)){
- List monitorListP = monitorList.stream().map(item->{
+ if (CollectionUtil.isNotEmpty(monitorList)) {
+ List monitorListP = monitorList.stream().map(item -> {
Monitor monitor = new Monitor();
monitor.setPowerrName(statationStat.getPowerName());
monitor.setId(item.getId());
@@ -124,11 +140,11 @@ public class StatationStatServiceImpl extends ServiceImpl powerDistributionareaLambdaQueryWrapper = new LambdaQueryWrapper<>();
- powerDistributionareaLambdaQueryWrapper.eq(PowerDistributionarea::getStatus,DataStateEnum.ENABLE.getCode()).eq(PowerDistributionarea::getPowerStationId,statationStat.getPowerId());
+ powerDistributionareaLambdaQueryWrapper.eq(PowerDistributionarea::getStatus, DataStateEnum.ENABLE.getCode()).eq(PowerDistributionarea::getPowerStationId, statationStat.getPowerId());
List powerDistributionareaList = powerDistributionareaMapper.selectList(powerDistributionareaLambdaQueryWrapper);
- if(CollectionUtil.isNotEmpty(powerDistributionareaList)){
- powerDistributionareaList.forEach(item->{
+ if (CollectionUtil.isNotEmpty(powerDistributionareaList)) {
+ powerDistributionareaList.forEach(item -> {
PowerDistributionarea powerDistributionarea = new PowerDistributionarea();
powerDistributionarea.setPowerrName(statationStat.getPowerName());
powerDistributionarea.setId(item.getId());
@@ -138,11 +154,11 @@ public class StatationStatServiceImpl extends ServiceImpl pmsTerminalLambdaQueryWrapper = new LambdaQueryWrapper<>();
- pmsTerminalLambdaQueryWrapper.eq(PmsTerminal::getStatus,DataStateEnum.ENABLE.getCode()).eq(PmsTerminal::getPowerStationId,statationStat.getPowerId());
+ pmsTerminalLambdaQueryWrapper.eq(PmsTerminal::getStatus, DataStateEnum.ENABLE.getCode()).eq(PmsTerminal::getPowerStationId, statationStat.getPowerId());
List pmsTerminalList = terminalMapper.selectList(pmsTerminalLambdaQueryWrapper);
- if(CollectionUtil.isNotEmpty(pmsTerminalList)){
- pmsTerminalList.forEach(item->{
+ if (CollectionUtil.isNotEmpty(pmsTerminalList)) {
+ pmsTerminalList.forEach(item -> {
PmsTerminal pmsTerminalP = new PmsTerminal();
pmsTerminalP.setPowerrName(statationStat.getPowerName());
pmsTerminalP.setId(item.getId());
@@ -153,23 +169,22 @@ public class StatationStatServiceImpl extends ServiceImpl statationStatIds) {
//删除前需要判断是否存在绑定关系
//装置是否存在绑定
LambdaQueryWrapper terminalLambdaQueryWrapper = new LambdaQueryWrapper<>();
- terminalLambdaQueryWrapper.eq(PmsTerminal::getStatus,DataStateEnum.ENABLE.getCode()).in(PmsTerminal::getPowerStationId,statationStatIds);
+ terminalLambdaQueryWrapper.eq(PmsTerminal::getStatus, DataStateEnum.ENABLE.getCode()).in(PmsTerminal::getPowerStationId, statationStatIds);
int terCount = terminalMapper.selectCount(terminalLambdaQueryWrapper);
- if(terCount>0){
+ if (terCount > 0) {
throw new BusinessException(PmsDeviceResponseEnum.TERMINAL_BIND_FIND);
}
//线路
LambdaQueryWrapper wireLambdaQueryWrapper = new LambdaQueryWrapper<>();
- wireLambdaQueryWrapper.eq(GeneratrixWire::getStatus,DataStateEnum.ENABLE.getCode()).in(GeneratrixWire::getStationId,statationStatIds);
+ wireLambdaQueryWrapper.eq(GeneratrixWire::getStatus, DataStateEnum.ENABLE.getCode()).in(GeneratrixWire::getStationId, statationStatIds);
int wCount = pmsGeneratrixWireMapper.selectCount(wireLambdaQueryWrapper);
- if(wCount>0){
+ if (wCount > 0) {
throw new BusinessException(PmsDeviceResponseEnum.WIRE_BIND_FIND);
}
@@ -185,13 +200,13 @@ public class StatationStatServiceImpl extends ServiceImpl getStatationStatList(PmsBaseParam pmsBaseParam) {
LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.orderByDesc(StatationStat::getCreateTime);
- if(StrUtil.isNotBlank(pmsBaseParam.getDeptId())){
+ if (StrUtil.isNotBlank(pmsBaseParam.getDeptId())) {
Dept dept = deptFeignClient.getDeptById(pmsBaseParam.getDeptId()).getData();
- lambdaQueryWrapper.eq(StatationStat::getOrgId,dept.getCode());
+ lambdaQueryWrapper.eq(StatationStat::getOrgId, dept.getCode());
}
- if(StrUtil.isNotBlank(pmsBaseParam.getDeptCode())){
- lambdaQueryWrapper.eq(StatationStat::getOrgId,pmsBaseParam.getDeptCode());
+ if (StrUtil.isNotBlank(pmsBaseParam.getDeptCode())) {
+ lambdaQueryWrapper.eq(StatationStat::getOrgId, pmsBaseParam.getDeptCode());
}
return this.list(lambdaQueryWrapper);
@@ -213,10 +228,203 @@ public class StatationStatServiceImpl extends ServiceImpl getPowerInfo(PmsStatationStatInfoParam param) {
LambdaQueryWrapper lqw = new LambdaQueryWrapper<>();
- lqw.in(param.getOrgIds() != null, StatationStat::getOrgId,param.getOrgIds());
- lqw.in(param.getPowerIds() != null, StatationStat::getPowerId,param.getPowerIds());
- lqw.like(param.getPowerName()!=null,StatationStat::getPowerName,param.getPowerName());
- lqw.in(param.getPowerVoltageLevel() != null, StatationStat::getVoltageLevel,param.getPowerVoltageLevel());
+ lqw.in(param.getOrgIds() != null, StatationStat::getOrgId, param.getOrgIds());
+ lqw.in(param.getPowerIds() != null, StatationStat::getPowerId, param.getPowerIds());
+ lqw.like(param.getPowerName() != null, StatationStat::getPowerName, param.getPowerName());
+ lqw.in(param.getPowerVoltageLevel() != null, StatationStat::getVoltageLevel, param.getPowerVoltageLevel());
return this.list(lqw);
}
+
+ @Override
+ public List statisticsMotion(String orgId) {
+ List num = new ArrayList<>();
+ num.add(0);
+ num.add(0);
+ num.add(0);
+ List deptInfos = deptFeignClient.getDeptDescendantIndexes(orgId, Stream.of(0, 1).collect(Collectors.toList())).getData();
+ List orgIDs = deptInfos.stream().map(DeptDTO::getCode).distinct().collect(Collectors.toList());
+ //获取电压指定电压id
+ Map voltageIDs = voltageLevel();
+ //查询变电站信息
+ List list = this.list(new QueryWrapper()
+ .select(" Voltage_Level,COUNT(Power_Id) as Should_Be_Num")
+ .eq("Status", 1)
+ .in("Org_Id", orgIDs)
+ .in("Voltage_Level", voltageIDs.keySet())
+ .groupBy("Voltage_Level")
+ );
+ Map infoMap = list.stream().collect(Collectors.toMap(StatationStat::getVoltageLevel, StatationStat::getShouldBeNum));
+ voltageIDs.forEach((key, value) -> {
+ if (infoMap.containsKey(key)) {
+ Integer integer = infoMap.get(key);
+ if (value.equals(DicDataEnum.DY_500KV.getCode())) {
+ num.set(0, num.get(0) + integer);
+ }
+ if (value.equals(DicDataEnum.DY_DC_500kV.getCode())) {
+ num.set(0, num.get(0) + integer);
+ }
+ if (value.equals(DicDataEnum.DY_220KV.getCode())) {
+ num.set(1, integer);
+ }
+ if (value.equals(DicDataEnum.DY_110KV.getCode())) {
+ num.set(2, integer);
+ }
+ }
+
+ });
+ return num;
+ }
+
+ @Override
+ public List> orgStatisticsMotion(String orgId) {
+ List> info = new LinkedList<>();
+ List kv500 = new LinkedList<>();
+ List kv220 = new LinkedList<>();
+ List kv110 = new LinkedList<>();
+ //查询当前部门下子节点信息
+ List deptInfos = deptFeignClient.getDeptDescendantIndexes(orgId, Stream.of(0, 1).collect(Collectors.toList())).getData();
+ List deptLevelVOList = DeptUtil.getDeptLevelVOList(deptInfos, orgId);
+ List orgIDs = deptInfos.stream().map(DeptDTO::getCode).collect(Collectors.toList());
+
+ //获取电压指定电压id
+ Map voltageIDs = voltageLevel();
+
+ //查询变电站信息
+ List list = this.list(new QueryWrapper()
+ .select(" Org_Id,Voltage_Level,COUNT(Power_Id) as Should_Be_Num")
+ .eq("Status", 1)
+ .in("Org_Id", orgIDs)
+ .in("Voltage_Level", voltageIDs.keySet())
+ .groupBy("Org_Id,Voltage_Level")
+ );
+
+ for (DeptLevelVO deptLevelVO : deptLevelVOList) {
+ List ids = deptLevelVO.getDeptList().stream().map(DeptLevelVO::getCode).collect(Collectors.toList());
+ ids.add(deptLevelVO.getCode());
+
+ List contain = list.stream().filter(x -> ids.contains(x.getOrgId())).collect(Collectors.toList());
+ if (CollUtil.isNotEmpty(contain)) {
+
+ Map infoMap = contain.stream().collect(Collectors.groupingBy(StatationStat::getVoltageLevel, Collectors.summingLong(StatationStat::getShouldBeNum)));
+ StatationStatVO.StatationParam kv500Param = new StatationStatVO.StatationParam();
+ StatationStatVO.StatationParam kv220Param = new StatationStatVO.StatationParam();
+ StatationStatVO.StatationParam kv110Param = new StatationStatVO.StatationParam();
+
+ kv500Param.setOrgName(deptLevelVO.getName());
+ kv500Param.setNum(0L);
+ kv220Param.setOrgName(deptLevelVO.getName());
+ kv220Param.setNum(0L);
+ kv110Param.setOrgName(deptLevelVO.getName());
+ kv110Param.setNum(0L);
+
+ voltageIDs.forEach((key, value) -> {
+ if (infoMap.containsKey(key)) {
+ Long integer = infoMap.get(key);
+ if (value.equals(DicDataEnum.DY_500KV.getCode())) {
+ kv500Param.setNum(kv500Param.getNum() + integer);
+ }
+ if (value.equals(DicDataEnum.DY_DC_500kV.getCode())) {
+ kv500Param.setNum(kv500Param.getNum() + integer);
+ }
+ if (value.equals(DicDataEnum.DY_220KV.getCode())) {
+ kv220Param.setNum(integer);
+ }
+ if (value.equals(DicDataEnum.DY_110KV.getCode())) {
+ kv110Param.setNum(integer);
+ }
+
+ }
+ });
+ kv500.add(kv500Param);
+ kv220.add(kv220Param);
+ kv110.add(kv110Param);
+ } else {
+ StatationStatVO.StatationParam param = new StatationStatVO.StatationParam();
+ param.setOrgName(deptLevelVO.getName());
+ param.setNum(0L);
+ kv500.add(param);
+ kv220.add(param);
+ kv110.add(param);
+ }
+
+ }
+ info.add(kv500);
+ info.add(kv220);
+ info.add(kv110);
+ return info;
+ }
+
+ @Override
+ public List getStatationStatList(String orgID) {
+ List deptInfos = deptFeignClient.getDeptDescendantIndexes(orgID, Stream.of(0, 1).collect(Collectors.toList())).getData();
+ List orgIDs = deptInfos.stream().map(DeptDTO::getCode).collect(Collectors.toList());
+
+ LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.in(StatationStat::getOrgId, orgIDs);
+ lambdaQueryWrapper.orderByDesc(StatationStat::getCreateTime);
+ return this.list(lambdaQueryWrapper);
+ }
+
+ @Override
+ public List getStatationStatCurve(String subID,String voltageLevel,Integer type) {
+ List curves = new ArrayList<>();
+ if (StrUtil.isBlank(subID)) {
+ throw new BusinessException(PmsDeviceResponseEnum.NO_ID_STATION);
+ }
+ //获取主网信息,没有则获取配网信息
+ List list = iMonitorService.list(new LambdaQueryWrapper()
+ .eq(Monitor::getPowerrId, subID)
+ .eq(Monitor::getPowerrId,voltageLevel)
+ );
+ List dataV = iDataVService.getDataV("ff2d9674c1f1ecce7f33a5bf17fc4f2d",
+ DateUtil.beginOfDay(DateUtil.date()).toString()
+ , DateUtil.endOfDay(DateUtil.date()).toString());
+ if (CollUtil.isNotEmpty(list)) {
+ String lineId = list.get(0).getLineId();
+
+
+ dataV.stream().filter(x->!x.getPhasicType().equals("T")
+ &&x.getValueType().equals("CP95")
+ ).peek(x->{
+ StatationStatVO.Curve curve =new StatationStatVO.Curve();
+ curve.setTime(PubUtils.instantToDate(x.getTime()));
+ curve.setNum( BigDecimal.valueOf(x.getVThd()).setScale(2, RoundingMode.HALF_UP));
+ curves.add(curve);
+ }
+ );
+ }else {
+ List disMonitorAllList = distributionMonitorMapper.getDisMonitorAllList(subID, type);
+ List disMonitors = disMonitorAllList.stream().filter(x -> x.equals(voltageLevel)).collect(Collectors.toList());
+ if(CollUtil.isNotEmpty(disMonitors)){
+// curves = pvDataFeignClient.getPVDailyCurve(disMonitors.get(0).getMonitorId(), 0).getData();
+
+ }
+ }
+ return curves;
+ }
+
+ private Map voltageLevel() {
+ //获取电压指定电压id
+ Map voltageIDs = new HashMap<>();
+ //获取电压等级的字典
+ List voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
+ //将电压信息转成map,key:id value:name
+ Map voltageLevelMap = voltageLevelList.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
+
+ voltageLevelMap.forEach((key, value) -> {
+ if (key.equals(DicDataEnum.DY_500KV.getCode())) {
+ voltageIDs.put(value, key);
+ }
+ if (key.equals(DicDataEnum.DY_DC_500kV.getCode())) {
+ voltageIDs.put(value, key);
+ }
+ if (key.equals(DicDataEnum.DY_220KV.getCode())) {
+ voltageIDs.put(value, key);
+ }
+ if (key.equals(DicDataEnum.DY_110KV.getCode())) {
+ voltageIDs.put(value, key);
+ }
+ });
+ return voltageIDs;
+ }
}
diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/PqsTflgassMapper.xml b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/PqsTflgassMapper.xml
index 92b8f40b1..d39adacdb 100644
--- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/PqsTflgassMapper.xml
+++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/PqsTflgassMapper.xml
@@ -9,15 +9,17 @@
INNER JOIN pqs_transformer pf on pf.Tf_Index=pt.Tf_Index
pf.Sub_Index = #{id}
- and ( Logic_Before IN
-
- #{item}
-
- or Logic_Next IN
-
- #{item}
-
- )
+
+ and ( Logic_Before IN
+
+ #{item}
+
+ or Logic_Next IN
+
+ #{item}
+
+ )
+
diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/PqsTransformerServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/PqsTransformerServiceImpl.java
index e84bab555..d13dbc902 100644
--- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/PqsTransformerServiceImpl.java
+++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/PqsTransformerServiceImpl.java
@@ -192,8 +192,6 @@ public class PqsTransformerServiceImpl extends ServiceImpl pqsTflgasses = pqsTflgassMapper.selectFlgass(subId, ids);
- String dadadw = mostBefore(pqsTflgasses);
-// List pqsTflgasses = pqsTflgassMapper.selectList(null);
String[][] arr = new String[pqsTflgasses.size()][2];
if (CollUtil.isNotEmpty(pqsTflgasses) && ids.size() > 2) {
for (int i = 0; i < pqsTflgasses.size(); i++) {