zbj//1.变电站指标统计_日统计 算法

This commit is contained in:
zhangbaojian
2023-06-19 18:16:57 +08:00
parent c910be9b7f
commit cfba93b908
17 changed files with 704 additions and 68 deletions

View File

@@ -82,7 +82,7 @@ public interface CommTerminalGeneralClient {
* @date 2023/5/10
*/
@PostMapping("substationGetLine")
HttpResult<List<LineDevGetDTO>> substationGetLine(@RequestParam("substationId")String substationId);
HttpResult<LineDevGetBandDTO> substationGetLine(@RequestParam("substationId")String substationId);
/**

View File

@@ -62,7 +62,7 @@ public class CommTerminalGeneralClientFallbackFactory implements FallbackFactory
}
@Override
public HttpResult<List<LineDevGetDTO>> substationGetLine(String substationId) {
public HttpResult<LineDevGetBandDTO> substationGetLine(String substationId) {
log.error("{}异常,降级处理,异常为:{}", "根据单站id获取监测点信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -0,0 +1,78 @@
package com.njcn.prepare.harmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Data;
import java.time.LocalDate;
/**
* @author zbj
* @since 2023-06-19
*/
@Data
@TableName("r_stat_substation_d")
public class RStatSubstationDPO {
@MppMultiId(value = "data_date")
private LocalDate dataDate;
@MppMultiId(value = "substation_id")
private String substationId;
@TableField(value = "effective_measurement_count")
private Integer effectiveMeasurementCount;
@TableField(value = "harmonic_count")
private Integer harmonicCount;
@TableField(value = "freq_count")
private Integer freqCount;
@TableField(value = "v_dev_count")
private Integer vDevCount;
@TableField(value = "v_count")
private Integer vCount;
@TableField(value = "i_count")
private Integer iCount;
@TableField(value = "unbalance_count")
private Integer unbalanceCount;
@TableField(value = "i_neg_count")
private Integer iNegCount;
@TableField(value = "flicker_count")
private Integer flickerCount;
@TableField(value = "inuharm_count")
private Integer inuharmCount;
@TableField(value = "event_measurement_count")
private Integer eventMeasurementCount;
@TableField(value = "event_count")
private Integer eventCount;
@TableField(value = "swell_measurement_count")
private Integer swellMeasurementCount;
@TableField(value = "swell_count")
private Integer swellCount;
@TableField(value = "sag_measurement_count")
private Integer sagMeasurementCount;
@TableField(value = "sag_count")
private Integer sagCount;
@TableField(value = "interrupt_measurement_count")
private Integer interruptMeasurementCount;
@TableField(value = "interrupt_count")
private Integer interruptCount;
}

View File

@@ -0,0 +1,81 @@
package com.njcn.prepare.harmonic.controller.newalgorithm;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
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.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.prepare.harmonic.pojo.param.OrgParam;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.RStatEventOrgService;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.RStatSubstationService;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept;
import com.njcn.web.controller.BaseController;
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.util.StringUtils;
import org.springframework.validation.annotation.Validated;
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 java.time.LocalDateTime;
import java.util.List;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/12/28 13:47【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@Api(tags = "变电站指标统计")
@RestController
@RequestMapping("/rStartSubstation")
@RequiredArgsConstructor
public class RStatSubstationController extends BaseController {
private final RStatSubstationService rStatSubstationService;
private final CommTerminalGeneralClient commTerminalGeneralClient;
private final DeptFeignClient deptFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/rStartSubstationHandler")
@ApiOperation("变电站指标统计")
@ApiImplicitParam(name = "orgParam", value = "参数", required = true)
public HttpResult<String> rStartSubstationHandler(@RequestBody @Validated OrgParam orgParam) {
log.info(LocalDateTime.now() + "rStartSubstationHandler开始执行");
String methodDescribe = getMethodDescribe("rStartSubstationHandler");
/**
* 支持补录
*/
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
if (StringUtils.isEmpty(orgParam.getOrgId())) {
Dept data = deptFeignClient.getRootDept().getData();
deptGetLineParam.setDeptId(data.getId());
} else {
deptGetLineParam.setDeptId(orgParam.getOrgId());
}
deptGetLineParam.setServerName(ServerInfo.PREPARE_BOOT);
List<DeptGetSubStationDTO> data = commTerminalGeneralClient.deptSubStation(deptGetLineParam).getData();
rStatSubstationService.handler(data,orgParam.getDataDate(),orgParam.getType());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
*
@@ -22,4 +23,6 @@ public interface RMpTargetWarnDMapper extends MppBaseMapper<RMpTargetWarnDPO> {
List<RMpMonitorAlarmCountMDTO> getDate(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("list") List<String> list);
Map<String,Object> getSumDate(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("lineIds") List<String> lineIds);
}

View File

@@ -42,7 +42,9 @@
sum(is_sag_warn)/count(distinct data_date) sagSeverity,
case when sum(is_interrupt_warn) > 0 then 1 else 0 end interruptAlarmInfo,
sum(is_interrupt_warn)/count(distinct data_date) interruptSeverity,
sum(is_v_dev_warn)/count(distinct data_date)+sum(is_freq_warn)/count(distinct data_date)+sum(is_unbalance_warn)/count(distinct data_date)+sum(is_v_warn)/count(distinct data_date)+sum(is_flicker_warn)/count(distinct data_date) harmonicTypeGradeTotal,
sum(is_v_dev_warn)/count(distinct data_date)+sum(is_freq_warn)/count(distinct
data_date)+sum(is_unbalance_warn)/count(distinct data_date)+sum(is_v_warn)/count(distinct
data_date)+sum(is_flicker_warn)/count(distinct data_date) harmonicTypeGradeTotal,
sum(is_sag_warn)/count(distinct data_date)+sum(is_interrupt_warn)/count(distinct data_date) eventTypeGradeTotal
from
r_mp_target_warn_d
@@ -60,5 +62,19 @@
order by harmonicTypeGradeTotal desc,eventTypeGradeTotal desc
</select>
<select id="getSumDate" resultType="java.util.Map">
SELECT
count(*) "iECount"
FROM
r_mp_target_warn_d
WHERE
measurement_point_id in
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND data_date between #{startTime} and #{endTime}
AND is_effective = 1
</select>
</mapper>

View File

@@ -7,9 +7,10 @@ import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/12/28 14:58【需求编号】
@@ -24,4 +25,6 @@ public interface RMpEventDetailDMapper extends MppBaseMapper<RMpEventDetailDPO>
int getInterruptTimes(@Param("lineId") String lineId, @Param("date") LocalDate date);
Map<String, Object> getSumAndCount(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("lineIds") List<String> lineIds);
}

View File

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* RMpPartHarmonicDetailDMapper
@@ -19,8 +20,11 @@ public interface RMpPartHarmonicDetailDMapper extends MppBaseMapper<RMpPartHarmo
RMpPartHarmonicDetailM getPartSumByData(@Param("lineId") String lineId, @Param("startTime") LocalDate startTime, @Param("endTime") LocalDate endTime);
Map<String, Object> getPartSum(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("lineIds") List<String> lineIds);
/**
* 获取监测点稳态指标超标明细日表1数据
*
* @param time 时间
* @return 集合
*/

View File

@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* RMpSurplusHarmonicDetailDMapper
@@ -21,8 +22,11 @@ public interface RMpSurplusHarmonicDetailDMapper extends MppBaseMapper<RMpSurplu
RMpSurplusHarmonicDetailM getSurplusSumByData(@Param("lineId") String lineId, @Param("startTime") LocalDate startTime, @Param("endTime") LocalDate endTime);
Map<String, Object> getSurplusSum(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("lineIds") List<String> lineIds);
/**
* 获取监测点稳态指标超标明细日表2数据
*
* @param time 时间
* @return 集合
*/

View File

@@ -3,22 +3,37 @@
<mapper namespace="com.njcn.prepare.harmonic.mapper.mysql.line.RMpEventDetailDMapper">
<select id="getSagTimes" resultType="int">
SELECT
IFNULL( MAX( sag_times ), 0 )
FROM
`r_mp_event_detail_d`
WHERE
measurement_point_id = #{lineId}
<![CDATA[AND DATE_FORMAT(data_date, '%Y-%m-%d') = #{date}]]>
SELECT IFNULL(MAX(sag_times), 0)
FROM `r_mp_event_detail_d`
WHERE measurement_point_id = #{lineId}
<![CDATA[AND DATE_FORMAT(data_date, '%Y-%m-%d') = #{date}
]]>
</select>
<select id="getInterruptTimes" resultType="int">
SELECT IFNULL(MAX(interrupt_times), 0)
FROM `r_mp_event_detail_d`
WHERE measurement_point_id = #{lineId}
<![CDATA[AND DATE_FORMAT(data_date, '%Y-%m-%d') = #{date}
]]>
</select>
<select id="getSumAndCount" resultType="java.util.Map">
SELECT
IFNULL( MAX( interrupt_times ), 0 )
count( CASE WHEN swell_times > 0 THEN 1 END ) "swellTimesCount",
sum( swell_times ) "swellTimesSum" ,
count( CASE WHEN sag_times > 0 THEN 1 END ) "sagTimesCount",
sum( sag_times ) "sagTimesSum" ,
count( CASE WHEN interrupt_times > 0 THEN 1 END ) "interruptTimesCount",
sum( interrupt_times ) "interruptTimesSum",
count( CASE WHEN swell_times > 0 || sag_times > 0 || interrupt_times > 0 THEN 1 END ) "resultCount"
FROM
`r_mp_event_detail_d`
r_mp_event_detail_d
WHERE
measurement_point_id = #{lineId}
<![CDATA[AND DATE_FORMAT(data_date, '%Y-%m-%d') = #{date}]]>
measurement_point_id in
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND data_date between #{startTime} and #{endTime}
</select>
</mapper>

View File

@@ -417,4 +417,23 @@
</if>
</select>
<select id="getPartSum" resultType="java.util.Map">
SELECT
sum(is_harmonic) "isHarmonicCount" ,
sum(is_freq) "isFreqCount" ,
sum(is_v_dev) "isVDevCount" ,
sum(is_v) "isVCount" ,
sum(is_i) "isICount" ,
sum(is_unbalance) "isUnbalanceCount" ,
sum(is_i_neg) "isINegCount"
FROM
r_mp_part_harmonic_detail_d
WHERE
measurement_point_id in
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND data_date between #{startTime} and #{endTime}
</select>
</mapper>

View File

@@ -140,4 +140,18 @@
</if>
</select>
<select id="getSurplusSum" resultType="java.util.Map">
SELECT
sum( is_flicker ) "isFlickerCount",
sum( is_inuharm ) "isInuharmCount"
FROM
r_mp_surplus_harmonic_detail_d
WHERE
measurement_point_id in
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND data_date between #{startTime} and #{endTime}
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
package com.njcn.prepare.harmonic.mapper.mysql.newalgorithm;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.prepare.harmonic.pojo.po.RStatEventDPO;
import com.njcn.prepare.harmonic.pojo.po.RStatEventDVO;
import com.njcn.prepare.harmonic.pojo.po.RStatSubstationDPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/12/13 15:39【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Mapper
public interface RStatSubstationDPOMapper extends MppBaseMapper<RStatSubstationDPO> {
}

View File

@@ -0,0 +1,14 @@
package com.njcn.prepare.harmonic.service.mysql.newalgorithm;
import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.prepare.harmonic.pojo.po.RStatSubstationDPO;
/**
* @author zbj
* @since 2023-06-19
*/
public interface RStatSubstationDPOService extends IMppService<RStatSubstationDPO> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.prepare.harmonic.service.mysql.newalgorithm;
import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO;
import java.util.List;
/**
* @author zbj
* @since 2023-06-19
*/
public interface RStatSubstationService {
void handler(List<DeptGetSubStationDTO> data, String dataDate, Integer type);
}

View File

@@ -0,0 +1,21 @@
package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RStatEventVoltageDPOMapper;
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RStatSubstationDPOMapper;
import com.njcn.prepare.harmonic.pojo.po.RStatEventVoltageDPO;
import com.njcn.prepare.harmonic.pojo.po.RStatSubstationDPO;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.RStatEventVoltageDPOService;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.RStatSubstationDPOService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
*
* @author zbj
* @since 2023-06-19
*/
@Service
@RequiredArgsConstructor
public class RStatSubstationDPOServiceImpl extends MppServiceImpl<RStatSubstationDPOMapper, RStatSubstationDPO> implements RStatSubstationDPOService {
}

View File

@@ -0,0 +1,326 @@
package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO;
import com.njcn.device.biz.pojo.dto.LineDevGetBandDTO;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.harmonic.pojo.po.RMpEventDetailDPO;
import com.njcn.harmonic.pojo.po.RMpEventDetailMPO;
import com.njcn.harmonic.pojo.po.RStatOrgDPO;
import com.njcn.harmonic.pojo.po.RStatOrgMPO;
import com.njcn.prepare.harmonic.mapper.mysql.area.*;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpEventDetailDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpEventDetailMMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpPartHarmonicDetailDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpSurplusHarmonicDetailDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RStatEventDPOMapper;
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RStatEventMPOMapper;
import com.njcn.prepare.harmonic.pojo.po.*;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.*;
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 lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* <p>
* 变电站指标统计
* </p>
*
* @author zbj
* @since 2023-06-19
*/
@Service
@RequiredArgsConstructor
public class RStatSubstationServiceImpl implements RStatSubstationService {
private final CommTerminalGeneralClient commTerminalGeneralClient;
private final RMpTargetWarnDMapper rMpTargetWarnDMapper;
private final RMpPartHarmonicDetailDMapper rMpPartHarmonicDetailDMapper;
private final RMpSurplusHarmonicDetailDMapper mpSurplusHarmonicDetailDMapper;
private final RMpEventDetailDMapper rMpEventDetailDMapper;
private final RStatSubstationDPOService rStatSubstationDPOService;
@Override
public void handler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) {
switch (type) {
/* case 1:
this.rStartEventYHandler (data, dataDate, type);
break;
case 2:
this.rStartEventQHandler(data, dataDate, type);
break;
case 3:
this.rStartEventMHandler(data, dataDate, type);
break;*/
case 5:
this.rStatSubstationDHandler(data, dataDate, type);
break;
default:
break;
}
}
//天表
public void rStatSubstationDHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) {
List<RStatSubstationDPO> rStatSubstationDPOS = new ArrayList<>();
Date date = DateUtil.parse(dataDate);
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
List<String> zwList = new ArrayList<>();
List<String> pwList = new ArrayList<>();
for (DeptGetSubStationDTO datum : data) {
if (!CollectionUtils.isEmpty(datum.getStationIds())) {
zwList.addAll(datum.getStationIds());
}
if (!CollectionUtils.isEmpty(datum.getPwStationIds())) {
pwList.addAll(datum.getPwStationIds());
}
}
List<String> zw = zwList.stream().distinct().collect(Collectors.toList());
List<String> pw = pwList.stream().distinct().collect(Collectors.toList());
//主网
if (!CollectionUtils.isEmpty(zw)) {
zw.forEach(z -> {
//获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData();
//获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
//判空
if (!CollectionUtils.isEmpty(lineIds)) {
int sw = 0, sa = 0, in = 0, result = 0;
//r_mp_target_warn_d 表中字段求和
Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(dataDate, dataDate, lineIds);
//r_mp_part_harmonic_detail_d 表中字段求和
Map<String, Object> partSum = rMpPartHarmonicDetailDMapper.getPartSum(dataDate, dataDate, lineIds);
//r_mp_surplus_harmonic_detail_d 表中字段求和
Map<String, Object> surplusSum = mpSurplusHarmonicDetailDMapper.getSurplusSum(dataDate, dataDate, lineIds);
//r_mp_event_detail_d 表中字段求和及计数
Map<String, Object> eventDetailSumAndCount = rMpEventDetailDMapper.getSumAndCount(dataDate, dataDate, lineIds);
RStatSubstationDPO rStatSubstationDPO = new RStatSubstationDPO();
rStatSubstationDPO.setDataDate(localDate);
rStatSubstationDPO.setSubstationId(z);
if (!CollectionUtils.isEmpty(warnSum)) {
rStatSubstationDPO.setEffectiveMeasurementCount(warnSum.containsKey("iECount") ?
Integer.parseInt(warnSum.get("iECount").toString()) : 0);
} else {
rStatSubstationDPO.setEffectiveMeasurementCount(0);
}
if (!CollectionUtils.isEmpty(partSum)) {
rStatSubstationDPO.setHarmonicCount(partSum.containsKey("isHarmonicCount") ?
Integer.parseInt(partSum.get("isHarmonicCount").toString()) : 0);
rStatSubstationDPO.setFreqCount(partSum.containsKey("isFreqCount") ?
Integer.parseInt(partSum.get("isFreqCount").toString()) : 0);
rStatSubstationDPO.setVDevCount(partSum.containsKey("isVDevCount") ?
Integer.parseInt(partSum.get("isVDevCount").toString()) : 0);
rStatSubstationDPO.setVCount(partSum.containsKey("isVCount") ?
Integer.parseInt(partSum.get("isVCount").toString()) : 0);
rStatSubstationDPO.setICount(partSum.containsKey("isICount") ?
Integer.parseInt(partSum.get("isICount").toString()) : 0);
rStatSubstationDPO.setUnbalanceCount(partSum.containsKey("isUnbalanceCount") ?
Integer.parseInt(partSum.get("isUnbalanceCount").toString()) : 0);
rStatSubstationDPO.setINegCount(partSum.containsKey("isINegCount") ?
Integer.parseInt(partSum.get("isINegCount").toString()) : 0);
} else {
rStatSubstationDPO.setHarmonicCount(0);
rStatSubstationDPO.setFreqCount(0);
rStatSubstationDPO.setVDevCount(0);
rStatSubstationDPO.setVCount(0);
rStatSubstationDPO.setICount(0);
rStatSubstationDPO.setUnbalanceCount(0);
rStatSubstationDPO.setINegCount(0);
}
if (!CollectionUtils.isEmpty(surplusSum)) {
rStatSubstationDPO.setFlickerCount(surplusSum.containsKey("isFlickerCount") ?
Integer.parseInt(surplusSum.get("isFlickerCount").toString()) : 0);
rStatSubstationDPO.setInuharmCount(surplusSum.containsKey("isInuharmCount") ?
Integer.parseInt(surplusSum.get("isInuharmCount").toString()) : 0);
} else {
rStatSubstationDPO.setFlickerCount(0);
rStatSubstationDPO.setInuharmCount(0);
}
if (!CollectionUtils.isEmpty(eventDetailSumAndCount)) {
rStatSubstationDPO.setEventMeasurementCount(eventDetailSumAndCount.containsKey("resultCount") ?
Integer.parseInt(eventDetailSumAndCount.get("resultCount").toString()) : 0);
if (eventDetailSumAndCount.containsKey("swellTimesSum")) {
sw = Integer.parseInt(eventDetailSumAndCount.get("swellTimesSum").toString());
}
if (eventDetailSumAndCount.containsKey("sagTimesSum")) {
sa = Integer.parseInt(eventDetailSumAndCount.get("sagTimesSum").toString());
}
if (eventDetailSumAndCount.containsKey("interruptTimesSum")) {
in = Integer.parseInt(eventDetailSumAndCount.get("interruptTimesSum").toString());
}
result = sw + sa + in;
rStatSubstationDPO.setEventCount(result);
rStatSubstationDPO.setSwellMeasurementCount(eventDetailSumAndCount.containsKey("swellTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("swellTimesCount").toString()) : 0);
rStatSubstationDPO.setSwellCount(sw);
rStatSubstationDPO.setSagMeasurementCount(eventDetailSumAndCount.containsKey("sagTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("sagTimesCount").toString()) : 0);
rStatSubstationDPO.setSagCount(sa);
rStatSubstationDPO.setInterruptMeasurementCount(eventDetailSumAndCount.containsKey("interruptTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("interruptTimesCount").toString()) : 0);
rStatSubstationDPO.setInterruptCount(in);
} else {
rStatSubstationDPO.setEventMeasurementCount(0);
rStatSubstationDPO.setEventCount(0);
rStatSubstationDPO.setSwellMeasurementCount(0);
rStatSubstationDPO.setSwellCount(0);
rStatSubstationDPO.setSagMeasurementCount(0);
rStatSubstationDPO.setSagCount(0);
rStatSubstationDPO.setInterruptMeasurementCount(0);
rStatSubstationDPO.setInterruptCount(0);
}
rStatSubstationDPOS.add(rStatSubstationDPO);
}
});
}
//配网
if (!CollectionUtils.isEmpty(pw)) {
pw.forEach(p -> {
//获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(p).getData();
//获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
//判空
if (!CollectionUtils.isEmpty(lineIds)) {
int sw = 0, sa = 0, in = 0, result = 0;
//r_mp_target_warn_d 表中字段求和
Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(dataDate, dataDate, lineIds);
//r_mp_part_harmonic_detail_d 表中字段求和
Map<String, Object> partSum = rMpPartHarmonicDetailDMapper.getPartSum(dataDate, dataDate, lineIds);
//r_mp_surplus_harmonic_detail_d 表中字段求和
Map<String, Object> surplusSum = mpSurplusHarmonicDetailDMapper.getSurplusSum(dataDate, dataDate, lineIds);
//r_mp_event_detail_d 表中字段求和及计数
Map<String, Object> eventDetailSumAndCount = rMpEventDetailDMapper.getSumAndCount(dataDate, dataDate, lineIds);
RStatSubstationDPO rStatSubstationDPO = new RStatSubstationDPO();
rStatSubstationDPO.setDataDate(localDate);
rStatSubstationDPO.setSubstationId(p);
if (!CollectionUtils.isEmpty(warnSum)) {
rStatSubstationDPO.setEffectiveMeasurementCount(warnSum.containsKey("iECount") ?
Integer.parseInt(warnSum.get("iECount").toString()) : 0);
} else {
rStatSubstationDPO.setEffectiveMeasurementCount(0);
}
if (!CollectionUtils.isEmpty(partSum)) {
rStatSubstationDPO.setHarmonicCount(partSum.containsKey("isHarmonicCount") ?
Integer.parseInt(partSum.get("isHarmonicCount").toString()) : 0);
rStatSubstationDPO.setFreqCount(partSum.containsKey("isFreqCount") ?
Integer.parseInt(partSum.get("isFreqCount").toString()) : 0);
rStatSubstationDPO.setVDevCount(partSum.containsKey("isVDevCount") ?
Integer.parseInt(partSum.get("isVDevCount").toString()) : 0);
rStatSubstationDPO.setVCount(partSum.containsKey("isVCount") ?
Integer.parseInt(partSum.get("isVCount").toString()) : 0);
rStatSubstationDPO.setICount(partSum.containsKey("isICount") ?
Integer.parseInt(partSum.get("isICount").toString()) : 0);
rStatSubstationDPO.setUnbalanceCount(partSum.containsKey("isUnbalanceCount") ?
Integer.parseInt(partSum.get("isUnbalanceCount").toString()) : 0);
rStatSubstationDPO.setINegCount(partSum.containsKey("isINegCount") ?
Integer.parseInt(partSum.get("isINegCount").toString()) : 0);
} else {
rStatSubstationDPO.setHarmonicCount(0);
rStatSubstationDPO.setFreqCount(0);
rStatSubstationDPO.setVDevCount(0);
rStatSubstationDPO.setVCount(0);
rStatSubstationDPO.setICount(0);
rStatSubstationDPO.setUnbalanceCount(0);
rStatSubstationDPO.setINegCount(0);
}
if (!CollectionUtils.isEmpty(surplusSum)) {
rStatSubstationDPO.setFlickerCount(surplusSum.containsKey("isFlickerCount") ?
Integer.parseInt(surplusSum.get("isFlickerCount").toString()) : 0);
rStatSubstationDPO.setInuharmCount(surplusSum.containsKey("isInuharmCount") ?
Integer.parseInt(surplusSum.get("isInuharmCount").toString()) : 0);
} else {
rStatSubstationDPO.setFlickerCount(0);
rStatSubstationDPO.setInuharmCount(0);
}
if (!CollectionUtils.isEmpty(eventDetailSumAndCount)) {
rStatSubstationDPO.setEventMeasurementCount(eventDetailSumAndCount.containsKey("resultCount") ?
Integer.parseInt(eventDetailSumAndCount.get("resultCount").toString()) : 0);
if (eventDetailSumAndCount.containsKey("swellTimesSum")) {
sw = Integer.parseInt(eventDetailSumAndCount.get("swellTimesSum").toString());
}
if (eventDetailSumAndCount.containsKey("sagTimesSum")) {
sa = Integer.parseInt(eventDetailSumAndCount.get("sagTimesSum").toString());
}
if (eventDetailSumAndCount.containsKey("interruptTimesSum")) {
in = Integer.parseInt(eventDetailSumAndCount.get("interruptTimesSum").toString());
}
result = sw + sa + in;
rStatSubstationDPO.setEventCount(result);
rStatSubstationDPO.setSwellMeasurementCount(eventDetailSumAndCount.containsKey("swellTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("swellTimesCount").toString()) : 0);
rStatSubstationDPO.setSwellCount(sw);
rStatSubstationDPO.setSagMeasurementCount(eventDetailSumAndCount.containsKey("sagTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("sagTimesCount").toString()) : 0);
rStatSubstationDPO.setSagCount(sa);
rStatSubstationDPO.setInterruptMeasurementCount(eventDetailSumAndCount.containsKey("interruptTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("interruptTimesCount").toString()) : 0);
rStatSubstationDPO.setInterruptCount(in);
} else {
rStatSubstationDPO.setEventMeasurementCount(0);
rStatSubstationDPO.setEventCount(0);
rStatSubstationDPO.setSwellMeasurementCount(0);
rStatSubstationDPO.setSwellCount(0);
rStatSubstationDPO.setSagMeasurementCount(0);
rStatSubstationDPO.setSagCount(0);
rStatSubstationDPO.setInterruptMeasurementCount(0);
rStatSubstationDPO.setInterruptCount(0);
}
rStatSubstationDPOS.add(rStatSubstationDPO);
}
});
}
if (!CollectionUtils.isEmpty(rStatSubstationDPOS)) {
rStatSubstationDPOService.saveOrUpdateBatchByMultiId(rStatSubstationDPOS, 500);
}
}
}