冀北代码提交

This commit is contained in:
wr
2023-08-09 08:46:15 +08:00
parent c4978d971e
commit 895bfa0c93
11 changed files with 454 additions and 51 deletions

View File

@@ -5,6 +5,7 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.DependsOn;
/**
* pqs
@@ -16,6 +17,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@MapperScan("com.njcn.**.mapper")
@EnableFeignClients(basePackages = "com.njcn")
@SpringBootApplication(scanBasePackages = "com.njcn")
@DependsOn("proxyMapperRegister")
public class DeviceBootApplication {
public static void main(String[] args) {

View File

@@ -28,5 +28,17 @@
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>pqs-influx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!--排除okhttp3的依赖-->
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@@ -55,7 +55,9 @@ public enum PmsDeviceResponseEnum {
DIS_MONITOR_BIND_FIND("A00353","配网监测点存在绑定该装置关系,请先解除绑定关系"),
TERMINAL_BIND_FIND("A00354","装置管理存在绑定该电站关系,请先解除绑定关系"),
WIRE_BIND_FIND("A00355","线路台账存在绑定该电站关系,请先解除绑定关系"),
TRANSFORMER_ID_REPEAT("A00355","变压器编号重复"),
TRANSFORMER_ID_REPEAT("A00356","变压器编号重复"),
NO_ID_STATION("A00357","变电站编号为空"),
;

View File

@@ -1,9 +1,13 @@
package com.njcn.device.pms.pojo.vo;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class StatationStatVO implements Serializable {
@@ -41,4 +45,27 @@ public class StatationStatVO implements Serializable {
@Data
@ApiModel(value = "变电站数据入参(冀北)")
public static class StatationParam{
@ApiModelProperty(name = "orgIds",value = "单位名称")
private String orgName;
@ApiModelProperty(name = "num",value = "变电站数量")
private Long num;
}
@Data
public static class Curve{
@ApiModelProperty(name = "time",value = "发生时间")
private Date time;
@ApiModelProperty(name = "num",value = "数值")
private BigDecimal num;
}
}

View File

@@ -46,6 +46,29 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-oss</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.8.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.8.1</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,89 @@
package com.njcn.device.pms.controller.ledgerManger;
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.pms.pojo.po.StatationStat;
import com.njcn.device.pms.pojo.vo.StatationStatVO;
import com.njcn.device.pms.service.majornetwork.IStatationStatService;
import com.njcn.device.pq.pojo.dto.PollutionLineDTO;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import retrofit2.http.GET;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author wr
* @since 2023-08-08
*/
@Slf4j
@Api(tags = "冀北变电站统计")
@RestController
@RequestMapping("/pms/substationStatistics")
@RequiredArgsConstructor
public class SubstationController extends BaseController {
private final IStatationStatService statationStatService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getStatistics")
@ApiOperation("获取在运变电站数量")
public HttpResult<List<Integer>> getStatisticsMotion(String orgID) {
String methodDescribe = getMethodDescribe("getStatisticsMotion");
List<Integer> integers = statationStatService.statisticsMotion(orgID);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, integers, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getOrgStatistics")
@ApiOperation("获取部门各个部门变电站数量(按电压等级区分)")
public HttpResult<List<List<StatationStatVO.StatationParam>>> getOrgStatisticsMotion(String orgID) {
String methodDescribe = getMethodDescribe("getOrgStatisticsMotion");
List<List<StatationStatVO.StatationParam>> lists = statationStatService.orgStatisticsMotion(orgID);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lists, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getStatationStat")
@ApiOperation("获取变压器列表")
public HttpResult<List<StatationStat>> getStatationStat(String orgID) {
String methodDescribe = getMethodDescribe("getStatationStat");
List<StatationStat> statationStatList = statationStatService.getStatationStatList(orgID);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, statationStatList, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getHarmonicCurve")
@ApiOperation("获取变压器谐波日曲线")
public HttpResult<List<StatationStatVO.Curve>> getHarmonicCurve(String subID,String voltageLevel) {
String methodDescribe = getMethodDescribe("getHarmonicCurve");
List<StatationStatVO.Curve> curves = statationStatService.getStatationStatCurve(subID, voltageLevel,0);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, curves, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getActiveCurve")
@ApiOperation("获取变压器功率日曲线")
public HttpResult<List<StatationStatVO.Curve>> getActiveCurve(String subID,String voltageLevel) {
String methodDescribe = getMethodDescribe("getActiveCurve");
List<StatationStatVO.Curve> curves = statationStatService.getStatationStatCurve(subID, voltageLevel,1);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, curves, methodDescribe);
}
}

View File

@@ -272,21 +272,21 @@
FROM
(
(
SELECT id, org_id, 3 as lineType,Power_Station_Id as powerrId,Line_Id,Voltage_Level
SELECT Update_Time,id, org_id, 3 as lineType,Power_Station_Id as powerrId,Line_Id,Voltage_Level
FROM pms_power_client
where STATUS = 1 )
UNION ALL
(
SELECT id, org_id, 3 as lineType,Power_Station_Id as powerrId,Line_Id,Voltage_Level
SELECT Update_Time,id, org_id, 3 as lineType,Power_Station_Id as powerrId,Line_Id,Voltage_Level
FROM pms_power_generation_user
WHERE
STATUS = 1 )
UNION ALL
( SELECT id, org_id, 2 as lineType,Power_Station_Id as powerrId,Line_Id,Voltage_Level
( SELECT Update_Time,id, org_id, 2 as lineType,Power_Station_Id as powerrId,Line_Id,Voltage_Level
FROM pms_power_distributionarea
WHERE STATUS = 1 )
UNION ALL
( SELECT id, org_id, 1 as lineType,Powerr_Id as powerrId,Line_Id,Voltage_Level
( SELECT Update_Time,id, org_id, 1 as lineType,Powerr_Id as powerrId,Line_Id,Voltage_Level
FROM pms_monitor
WHERE STATUS = 1 )
) t

View File

@@ -9,6 +9,7 @@ import com.njcn.device.pms.pojo.param.PmsStatationStatInfoParam;
import com.njcn.device.pms.pojo.po.StatationStat;
import com.njcn.device.pms.pojo.po.StatationStat;
import com.njcn.device.pms.pojo.vo.StatationStatVO;
import com.njcn.device.pq.pojo.dto.PollutionLineDTO;
import com.njcn.web.pojo.param.BaseParam;
import java.util.List;
@@ -99,4 +100,43 @@ public interface IStatationStatService extends IService<StatationStat> {
* @date 2022/11/21
*/
List<StatationStat> getPowerInfo(PmsStatationStatInfoParam param);
/**
* @Description: 统计指定电压等级在运变电站电压等机(冀北专用)
* @param orgId
* @return: java.util.List<java.lang.Integer>
* @Author: wr
* @Date: 2023/8/7 14:16
*/
List<Integer> statisticsMotion(String orgId);
/**
* @Description: 部门统计指定电压等级在运变电站电压等机(冀北专用)
* @param orgId
* @return: java.util.List<java.util.List<com.njcn.device.pms.pojo.param.PmsStatationStatInfoParam.StatationParam>>
* @Author: wr
* @Date: 2023/8/7 14:55
*/
List<List<StatationStatVO.StatationParam>> orgStatisticsMotion(String orgId);
/**
* @Description:查询电站列表(当前部门下所有变电站)
* @param orgID
* @return: java.util.List<com.njcn.device.pms.pojo.po.StatationStat>
* @Author: wr
* @Date: 2023/8/8 14:56
*/
List<StatationStat> getStatationStatList(String orgID);
/**
* @Description: 根据变电编号和电压等级获取曲线(冀北专用)
* @param subID 变电站信息
* @param voltageLevel 电压等级
* @param type 0谐波 1总有公
* @return:
* @Author: wr
* @Date: 2023/8/8 14:56
*/
List<StatationStatVO.Curve> getStatationStatCurve(String subID,String voltageLevel,Integer type);
}

View File

@@ -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;
/**
* <p>
@@ -53,8 +68,9 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
private final PowerDistributionareaMapper powerDistributionareaMapper;
private final DicDataFeignClient dicDataFeignClient;
private final DistributionMonitorMapper distributionMonitorMapper;
private final IDataVService iDataVService;
/**
@@ -72,16 +88,16 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
public boolean addStatationStat(StatationStatParam statationStatParam) {
StatationStat statationStatValid = this.getById(statationStatParam.getPowerId());
if(Objects.nonNull(statationStatValid)){
if (Objects.nonNull(statationStatValid)) {
throw new BusinessException(PmsDeviceResponseEnum.STATION_REPEAT);
}
//校验同一单位下不能出现同名电站
LambdaQueryWrapper<StatationStat> 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<StatationStatMapper, S
public boolean updateStatationStat(StatationStatParam statationStatParam) {
//校验同一单位下不能出现同名电站
LambdaQueryWrapper<StatationStat> 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<StatationStatMapper, S
//修改单位名称时候要确保其他台账中的电站名同时修改
LambdaQueryWrapper<Monitor> 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<Monitor> monitorList = iMonitorService.list(monitorLambdaQueryWrapper);
if(CollectionUtil.isNotEmpty(monitorList)){
List<Monitor> monitorListP = monitorList.stream().map(item->{
if (CollectionUtil.isNotEmpty(monitorList)) {
List<Monitor> 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<StatationStatMapper, S
}
//台区
LambdaQueryWrapper<PowerDistributionarea> 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<PowerDistributionarea> 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<StatationStatMapper, S
//装置
//台区
LambdaQueryWrapper<PmsTerminal> 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<PmsTerminal> 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<StatationStatMapper, S
}
@Override
public boolean delStatationStat(List<String> statationStatIds) {
//删除前需要判断是否存在绑定关系
//装置是否存在绑定
LambdaQueryWrapper<PmsTerminal> 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<GeneratrixWire> 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<StatationStatMapper, S
public List<StatationStat> getStatationStatList(PmsBaseParam pmsBaseParam) {
LambdaQueryWrapper<StatationStat> 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<StatationStatMapper, S
@Override
public List<StatationStat> getPowerInfo(PmsStatationStatInfoParam param) {
LambdaQueryWrapper<StatationStat> 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<Integer> statisticsMotion(String orgId) {
List<Integer> num = new ArrayList<>();
num.add(0);
num.add(0);
num.add(0);
List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(orgId, Stream.of(0, 1).collect(Collectors.toList())).getData();
List<String> orgIDs = deptInfos.stream().map(DeptDTO::getCode).distinct().collect(Collectors.toList());
//获取电压指定电压id
Map<String, String> voltageIDs = voltageLevel();
//查询变电站信息
List<StatationStat> list = this.list(new QueryWrapper<StatationStat>()
.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<String, Integer> 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<List<StatationStatVO.StatationParam>> orgStatisticsMotion(String orgId) {
List<List<StatationStatVO.StatationParam>> info = new LinkedList<>();
List<StatationStatVO.StatationParam> kv500 = new LinkedList<>();
List<StatationStatVO.StatationParam> kv220 = new LinkedList<>();
List<StatationStatVO.StatationParam> kv110 = new LinkedList<>();
//查询当前部门下子节点信息
List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(orgId, Stream.of(0, 1).collect(Collectors.toList())).getData();
List<DeptLevelVO> deptLevelVOList = DeptUtil.getDeptLevelVOList(deptInfos, orgId);
List<String> orgIDs = deptInfos.stream().map(DeptDTO::getCode).collect(Collectors.toList());
//获取电压指定电压id
Map<String, String> voltageIDs = voltageLevel();
//查询变电站信息
List<StatationStat> list = this.list(new QueryWrapper<StatationStat>()
.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<String> ids = deptLevelVO.getDeptList().stream().map(DeptLevelVO::getCode).collect(Collectors.toList());
ids.add(deptLevelVO.getCode());
List<StatationStat> contain = list.stream().filter(x -> ids.contains(x.getOrgId())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(contain)) {
Map<String, Long> 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<StatationStat> getStatationStatList(String orgID) {
List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(orgID, Stream.of(0, 1).collect(Collectors.toList())).getData();
List<String> orgIDs = deptInfos.stream().map(DeptDTO::getCode).collect(Collectors.toList());
LambdaQueryWrapper<StatationStat> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(StatationStat::getOrgId, orgIDs);
lambdaQueryWrapper.orderByDesc(StatationStat::getCreateTime);
return this.list(lambdaQueryWrapper);
}
@Override
public List<StatationStatVO.Curve> getStatationStatCurve(String subID,String voltageLevel,Integer type) {
List<StatationStatVO.Curve> curves = new ArrayList<>();
if (StrUtil.isBlank(subID)) {
throw new BusinessException(PmsDeviceResponseEnum.NO_ID_STATION);
}
//获取主网信息,没有则获取配网信息
List<Monitor> list = iMonitorService.list(new LambdaQueryWrapper<Monitor>()
.eq(Monitor::getPowerrId, subID)
.eq(Monitor::getPowerrId,voltageLevel)
);
List<DataV> 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<PmsMonitorBaseDTO> disMonitorAllList = distributionMonitorMapper.getDisMonitorAllList(subID, type);
List<PmsMonitorBaseDTO> 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<String, String> voltageLevel() {
//获取电压指定电压id
Map<String, String> voltageIDs = new HashMap<>();
//获取电压等级的字典
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
//将电压信息转成mapkeyid valuename
Map<String, String> 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;
}
}

View File

@@ -9,6 +9,7 @@
INNER JOIN pqs_transformer pf on pf.Tf_Index=pt.Tf_Index
<where>
pf.Sub_Index = #{id}
<if test="ids.size()!=0">
and ( Logic_Before IN
<foreach item="item" collection="ids" separator="," open="(" close=")">
#{item}
@@ -18,6 +19,7 @@
#{item}
</foreach>
)
</if>
</where>
</select>

View File

@@ -192,8 +192,6 @@ public class PqsTransformerServiceImpl extends ServiceImpl<PqsTransformerMapper,
List<PqsTflgass> pqsTflgasses = pqsTflgassMapper.selectFlgass(subId, ids);
String dadadw = mostBefore(pqsTflgasses);
// List<PqsTflgass> 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++) {