From 895bfa0c93a9dc65cdaad19fca6610c16bf338c4 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Wed, 9 Aug 2023 08:46:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=80=E5=8C=97=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/njcn/DeviceBootApplication.java | 2 + pqs-device/pms-device/pms-device-api/pom.xml | 12 + .../pms/enums/PmsDeviceResponseEnum.java | 4 +- .../device/pms/pojo/vo/StatationStatVO.java | 27 ++ pqs-device/pms-device/pms-device-boot/pom.xml | 23 ++ .../ledgerManger/SubstationController.java | 89 ++++++ .../mapping/DistributionMonitorMapper.xml | 8 +- .../majornetwork/IStatationStatService.java | 40 +++ .../impl/StatationStatServiceImpl.java | 278 +++++++++++++++--- .../pq/mapper/mapping/PqsTflgassMapper.xml | 20 +- .../impl/PqsTransformerServiceImpl.java | 2 - 11 files changed, 454 insertions(+), 51 deletions(-) create mode 100644 pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/controller/ledgerManger/SubstationController.java diff --git a/pqs-device/device-boot/src/main/java/com/njcn/DeviceBootApplication.java b/pqs-device/device-boot/src/main/java/com/njcn/DeviceBootApplication.java index 210bc589f..38b0a7526 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/DeviceBootApplication.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/DeviceBootApplication.java @@ -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) { diff --git a/pqs-device/pms-device/pms-device-api/pom.xml b/pqs-device/pms-device/pms-device-api/pom.xml index 7ffaf2a15..03b10389d 100644 --- a/pqs-device/pms-device/pms-device-api/pom.xml +++ b/pqs-device/pms-device/pms-device-api/pom.xml @@ -28,5 +28,17 @@ 1.0.0 compile + + com.njcn + pqs-influx + 0.0.1-SNAPSHOT + + + + com.squareup.okhttp3 + * + + + \ No newline at end of file diff --git a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/enums/PmsDeviceResponseEnum.java b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/enums/PmsDeviceResponseEnum.java index 45575fbc5..2b7ef3f23 100644 --- a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/enums/PmsDeviceResponseEnum.java +++ b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/enums/PmsDeviceResponseEnum.java @@ -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","变电站编号为空"), ; diff --git a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/StatationStatVO.java b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/StatationStatVO.java index 4ad07d624..784c75615 100644 --- a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/StatationStatVO.java +++ b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/StatationStatVO.java @@ -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; + + } + } diff --git a/pqs-device/pms-device/pms-device-boot/pom.xml b/pqs-device/pms-device/pms-device-boot/pom.xml index 262f0ea71..e2437ea57 100644 --- a/pqs-device/pms-device/pms-device-boot/pom.xml +++ b/pqs-device/pms-device/pms-device-boot/pom.xml @@ -46,6 +46,29 @@ ${project.version} compile + + com.njcn + common-oss + ${project.version} + + + com.squareup.okhttp3 + okhttp + + + + + + com.squareup.okhttp3 + okhttp + 4.8.1 + + + + com.squareup.okhttp3 + logging-interceptor + 4.8.1 + diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/controller/ledgerManger/SubstationController.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/controller/ledgerManger/SubstationController.java new file mode 100644 index 000000000..eae6b7564 --- /dev/null +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/controller/ledgerManger/SubstationController.java @@ -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; + + +/** + *

+ * 前端控制器 + *

+ * + * @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> getStatisticsMotion(String orgID) { + String methodDescribe = getMethodDescribe("getStatisticsMotion"); + List integers = statationStatService.statisticsMotion(orgID); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, integers, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getOrgStatistics") + @ApiOperation("获取部门各个部门变电站数量(按电压等级区分)") + public HttpResult>> getOrgStatisticsMotion(String orgID) { + String methodDescribe = getMethodDescribe("getOrgStatisticsMotion"); + List> lists = statationStatService.orgStatisticsMotion(orgID); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lists, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getStatationStat") + @ApiOperation("获取变压器列表") + public HttpResult> getStatationStat(String orgID) { + String methodDescribe = getMethodDescribe("getStatationStat"); + List statationStatList = statationStatService.getStatationStatList(orgID); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, statationStatList, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/getHarmonicCurve") + @ApiOperation("获取变压器谐波日曲线") + public HttpResult> getHarmonicCurve(String subID,String voltageLevel) { + String methodDescribe = getMethodDescribe("getHarmonicCurve"); + List curves = statationStatService.getStatationStatCurve(subID, voltageLevel,0); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, curves, methodDescribe); + } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping("/getActiveCurve") + @ApiOperation("获取变压器功率日曲线") + public HttpResult> getActiveCurve(String subID,String voltageLevel) { + String methodDescribe = getMethodDescribe("getActiveCurve"); + List curves = statationStatService.getStatationStatCurve(subID, voltageLevel,1); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, curves, methodDescribe); + } + +} + diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/mapper/majornetwork/mapping/DistributionMonitorMapper.xml b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/mapper/majornetwork/mapping/DistributionMonitorMapper.xml index 09b288f15..50d0e36ca 100644 --- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/mapper/majornetwork/mapping/DistributionMonitorMapper.xml +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/mapper/majornetwork/mapping/DistributionMonitorMapper.xml @@ -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 diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/IStatationStatService.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/IStatationStatService.java index caeeda664..7c9e5e8b4 100644 --- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/IStatationStatService.java +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/IStatationStatService.java @@ -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 { * @date 2022/11/21 */ List getPowerInfo(PmsStatationStatInfoParam param); + + /** + * @Description: 统计指定电压等级在运变电站电压等机(冀北专用) + * @param orgId + * @return: java.util.List + * @Author: wr + * @Date: 2023/8/7 14:16 + */ + List statisticsMotion(String orgId); + + /** + * @Description: 部门统计指定电压等级在运变电站电压等机(冀北专用) + * @param orgId + * @return: java.util.List> + * @Author: wr + * @Date: 2023/8/7 14:55 + */ + List> orgStatisticsMotion(String orgId); + + + /** + * @Description:查询电站列表(当前部门下所有变电站) + * @param orgID + * @return: java.util.List + * @Author: wr + * @Date: 2023/8/8 14:56 + */ + List getStatationStatList(String orgID); + + /** + * @Description: 根据变电编号和电压等级获取曲线(冀北专用) + * @param subID 变电站信息 + * @param voltageLevel 电压等级 + * @param type 0谐波 1总有公 + * @return: + * @Author: wr + * @Date: 2023/8/8 14:56 + */ + List 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++) {