Merge remote-tracking branch 'origin/liaoning' into liaoning

This commit is contained in:
hzj
2025-05-15 08:57:24 +08:00
5 changed files with 220 additions and 199 deletions

View File

@@ -47,6 +47,7 @@ import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.SysDicTreePO;
import lombok.RequiredArgsConstructor;
@@ -100,6 +101,7 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
private final DataLimitRateFeignClient dataLimitRateFeignClient;
private final DataLimitRateDetailFeignClient dataLimitRateDetailFeignClient;
private final DicDataFeignClient dicDataFeignClient;
@Override
@@ -310,6 +312,47 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
specialTargetList.add(json);
}
}
} else {
if (StrUtil.isNotBlank(line.getVoltageDevOvertime())) {
specialTargetList.add(line.getVoltageDevOvertime());
}
if (StrUtil.isNotBlank(line.getFlickerOvertime())) {
specialTargetList.add(line.getFlickerOvertime());
}
if (StrUtil.isNotBlank(line.getUbalanceOvertime())) {
specialTargetList.add(line.getUbalanceOvertime());
}
if (StrUtil.isNotBlank(line.getFreqDevOvertime())) {
specialTargetList.add(line.getFreqDevOvertime());
}
if (StrUtil.isNotBlank(line.getINegOvertime())) {
specialTargetList.add(line.getINegOvertime());
}
if (StrUtil.isNotBlank(line.getUaberranceOvertime())) {
specialTargetList.add(line.getUaberranceOvertime());
}
for (int i = 2; i <= 25; i++) {
String uHarmKey = "uharm" + i + "Overtime";
String json = getFieldValueForDetail(line, uHarmKey);
if (StrUtil.isNotBlank(json)) {
specialTargetList.add(json);
}
}
for (int i = 2; i <= 25; i++) {
String uHarmKey = "iharm" + i + "Overtime";
String json = getFieldValueForDetail(line, uHarmKey);
if (StrUtil.isNotBlank(json)) {
specialTargetList.add(json);
}
}
for (int i = 1; i <= 16; i++) {
String uHarmKey = "inuharm" + i + "Overtime";
String json = getFieldValueForDetail(line, uHarmKey);
if (StrUtil.isNotBlank(json)) {
specialTargetList.add(json);
}
}
}
if (CollUtil.isNotEmpty(specialTargetList)) {
@@ -343,77 +386,124 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
@Override
public List<DetailAbnormalVO.DetailLimitInnerVO> monitorLimitTableDetail(MonitorBaseParam monitorBaseParam) {
List<DetailAbnormalVO.DetailLimitInnerVO> result = new ArrayList<>();
LineCountEvaluateParam lineCountEvaluateParam = new LineCountEvaluateParam();
lineCountEvaluateParam.setLineId(Stream.of(monitorBaseParam.getMonitorIds().get(0)).collect(Collectors.toList()));
lineCountEvaluateParam.setLineId(Collections.singletonList(monitorBaseParam.getMonitorIds().get(0)));
lineCountEvaluateParam.setStartTime(monitorBaseParam.getSearchBeginTime());
lineCountEvaluateParam.setEndTime(monitorBaseParam.getSearchBeginTime());
List<DataLimitRateDetailDto> dtoList = dataLimitRateDetailFeignClient.getRawData(lineCountEvaluateParam).getData();
if (CollUtil.isEmpty(dtoList)) {
return result;
}
if (CollUtil.isNotEmpty(dtoList)) {
DataLimitRateDetailDto dto = dtoList.get(0);
JSONArray jsonArray = new JSONArray();
List<String> specialTargetList = new ArrayList<>();
if (monitorBaseParam.getTargetKey().equals(DicDataEnum.VOLTAGE_DEV.getCode())) {
//电压偏差
jsonArray = new JSONArray(dto.getVoltageDevOvertime());
} else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.FLICKER.getCode())) {
jsonArray = new JSONArray(dto.getFlickerOvertime());
}else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.phase_Voltage.getCode())) {
jsonArray = new JSONArray(dto.getUbalanceOvertime());
} else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.FREQUENCY_DEV.getCode())) {
jsonArray = new JSONArray(dto.getFreqDevOvertime());
} else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.NEG_CURRENT.getCode())) {
jsonArray = new JSONArray(dto.getINegOvertime());
} else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.THD_V.getCode())) {
jsonArray = new JSONArray(dto.getUaberranceOvertime());
} else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.HARMONIC_VOLTAGE.getCode())) {
for (int i = 2; i <= 25; i++) {
String uHarmKey = "uharm" + i + "Overtime";
String json = getFieldValueForDetail(dto, uHarmKey);
if (StrUtil.isNotBlank(json)) {
specialTargetList.add(json+SEPARATOR+i);
}
}
} else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.HARMONIC_CURRENT.getCode())) {
for (int i = 2; i <= 25; i++) {
String uHarmKey = "iharm" + i + "Overtime";
String json = getFieldValueForDetail(dto, uHarmKey);
if (StrUtil.isNotBlank(json)) {
specialTargetList.add(json+SEPARATOR+i);
}
}
} else if (monitorBaseParam.getTargetKey().equals(DicDataEnum.INTERHARMONIC_VOLTAGE.getCode())) {
for (int i = 1; i <= 16; i++) {
String uHarmKey = "inuharm" + i + "Overtime";
String json = getFieldValueForDetail(dto, uHarmKey);
if (StrUtil.isNotBlank(json)) {
specialTargetList.add(json+SEPARATOR+i);
}
}
}
if(CollUtil.isNotEmpty(specialTargetList)){
for(String strJson : specialTargetList){
String[] temStr = strJson.split(SEPARATOR);
JSONArray jsonTem = new JSONArray(temStr[0]);
dealJsonArr(jsonTem,result,monitorBaseParam,temStr[1]);
}
Map<String, DictData> targetMap = getTargetMap();
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
processSingleTarget(dto, monitorBaseParam.getTargetKey(), targetMap, result);
} else {
dealJsonArr(jsonArray,result,monitorBaseParam,null);
}
processAllTargets(dto, targetMap, result);
}
return result;
}
private Map<String, DictData> getTargetMap() {
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.STEADY_STATIS.getCode()).getData();
return dictDataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity()));
}
private void processSingleTarget(DataLimitRateDetailDto dto, String targetKey, Map<String, DictData> targetMap, List<DetailAbnormalVO.DetailLimitInnerVO> result) {
if (!targetMap.containsKey(targetKey)) {
throw new BusinessException("异常指标参数");
}
String targetName = targetMap.get(targetKey).getName();
List<String> specialTargetList = new ArrayList<>();
JSONArray jsonArray = new JSONArray();
DicDataEnum targetEnum = DicDataEnum.getDicDataEnumValue(targetKey);
switch (Objects.requireNonNull(targetEnum)) {
case VOLTAGE_DEV:
jsonArray = new JSONArray(dto.getVoltageDevOvertime());
break;
case FLICKER:
jsonArray = new JSONArray(dto.getFlickerOvertime());
break;
case phase_Voltage:
jsonArray = new JSONArray(dto.getUbalanceOvertime());
break;
case FREQUENCY_DEV:
jsonArray = new JSONArray(dto.getFreqDevOvertime());
break;
case NEG_CURRENT:
jsonArray = new JSONArray(dto.getINegOvertime());
break;
case THD_V:
jsonArray = new JSONArray(dto.getUaberranceOvertime());
break;
case HARMONIC_VOLTAGE:
collectHarmonicData(dto, "uharm", 2, 25, specialTargetList);
break;
case HARMONIC_CURRENT:
collectHarmonicData(dto, "iharm", 2, 25, specialTargetList);
break;
case INTERHARMONIC_VOLTAGE:
collectHarmonicData(dto, "inuharm", 1, 16, specialTargetList);
break;
default:
throw new BusinessException("未支持的指标类型: " + targetKey);
}
if (CollUtil.isNotEmpty(specialTargetList)) {
processSpecialTargets(specialTargetList, result, targetName);
} else {
dealJsonArr(jsonArray, result, targetName, null);
}
}
private void processAllTargets(DataLimitRateDetailDto dto, Map<String, DictData> targetMap,
List<DetailAbnormalVO.DetailLimitInnerVO> result) {
// 处理标准指标
processStandardTarget(dto, targetMap, DicDataEnum.VOLTAGE_DEV.getCode(), dto.getVoltageDevOvertime(), result);
processStandardTarget(dto, targetMap, DicDataEnum.FLICKER.getCode(), dto.getFlickerOvertime(), result);
processStandardTarget(dto, targetMap, DicDataEnum.phase_Voltage.getCode(), dto.getUbalanceOvertime(), result);
processStandardTarget(dto, targetMap, DicDataEnum.FREQUENCY_DEV.getCode(), dto.getFreqDevOvertime(), result);
processStandardTarget(dto, targetMap, DicDataEnum.NEG_CURRENT.getCode(), dto.getINegOvertime(), result);
processStandardTarget(dto, targetMap, DicDataEnum.THD_V.getCode(), dto.getUaberranceOvertime(), result);
// 处理谐波类指标
processHarmonicTarget(dto, targetMap, DicDataEnum.HARMONIC_VOLTAGE.getCode(), "uharm", 2, 25, result);
processHarmonicTarget(dto, targetMap, DicDataEnum.HARMONIC_CURRENT.getCode(), "iharm", 2, 25, result);
processHarmonicTarget(dto, targetMap, DicDataEnum.INTERHARMONIC_VOLTAGE.getCode(), "inuharm", 1, 16, result);
}
private void processStandardTarget(DataLimitRateDetailDto dto, Map<String, DictData> targetMap,
String targetCode, String data,
List<DetailAbnormalVO.DetailLimitInnerVO> result) {
if (StrUtil.isNotBlank(data)) {
JSONArray jsonArray = new JSONArray(data);
String targetName = targetMap.get(targetCode).getName();
dealJsonArr(jsonArray, result, targetName, null);
}
}
private void processHarmonicTarget(DataLimitRateDetailDto dto, Map<String, DictData> targetMap,
String targetCode, String prefix, int start, int end,
List<DetailAbnormalVO.DetailLimitInnerVO> result) {
List<String> tempList = new ArrayList<>();
String targetName = targetMap.get(targetCode).getName();
collectHarmonicData(dto, prefix, start, end, tempList);
processSpecialTargets(tempList, result, targetName);
}
private void processSpecialTargets(List<String> specialTargetList, List<DetailAbnormalVO.DetailLimitInnerVO> result, String targetName) {
for (String strJson : specialTargetList) {
String[] temStr = strJson.split(SEPARATOR);
JSONArray jsonTem = new JSONArray(temStr[0]);
dealJsonArr(jsonTem, result, targetName, temStr[1]);
}
}
/**
* 处理json数组
*/
private void dealJsonArr(JSONArray jsonArray,List<DetailAbnormalVO.DetailLimitInnerVO> result,MonitorBaseParam monitorBaseParam,String count){
private void dealJsonArr(JSONArray jsonArray, List<DetailAbnormalVO.DetailLimitInnerVO> result, String targetName, String count) {
List<JsonBaseVO> jsonBaseVOList = jsonArray.toList(JsonBaseVO.class);
Map<String, List<JsonBaseVO>> jsonMap = jsonBaseVOList.stream().collect(Collectors.groupingBy(JsonBaseVO::getPhasic));
jsonMap.forEach((phasic, list) -> {
@@ -428,7 +518,7 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
vo.setType(it.getValueType());
vo.setVal(valArr[i]);
vo.setPhaseType(phasic);
vo.setTargetName(StrUtil.isNotBlank(count) ? count+monitorBaseParam.getTargetKey():monitorBaseParam.getTargetKey());
vo.setTargetName(StrUtil.isNotBlank(count) ? count + "" + targetName : targetName);
result.add(vo);
}
});
@@ -437,8 +527,6 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
}
private List<DataVerify> commQuery(List<String> monitorIds, MonitorBaseParam monitorBaseParam) {
LambdaQueryWrapper<DataVerify> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(DataVerify::getTime, DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())), DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())))
@@ -515,13 +603,24 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
return verifyTargetVOList;
}
private void collectHarmonicData(DataLimitRateDetailDto dto, String prefix, int start, int end, List<String> result) {
for (int i = start; i <= end; i++) {
String fieldName = prefix + i + "Overtime";
String json = getFieldValueForDetail(dto, fieldName);
if (StrUtil.isNotBlank(json)) {
result.add(json + SEPARATOR + i);
}
}
}
private Integer getFieldValue(DataLimitTargetDto dto, String fieldName) {
try {
Field field = DataLimitTargetDto.class.getDeclaredField(fieldName);
field.setAccessible(true);
return (Integer) field.get(dto);
} catch (NoSuchFieldException | IllegalAccessException e) {
logger.error("反射方法异常:{}", e.getMessage());
logger.error("DataLimitTarget反射方法异常:{}", e.getMessage());
return null;
}
}
@@ -532,7 +631,7 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
field.setAccessible(true);
return (String) field.get(dto);
} catch (NoSuchFieldException | IllegalAccessException e) {
logger.error("反射方法异常:{}", e.getMessage());
logger.error("DataLimitRateDetail反射方法异常:{}", e.getMessage());
return null;
}
}
@@ -685,11 +784,6 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
}
public List<PowerQualityIndicatorsVO> getLimitTable(List<DataLimitTargetDto> dataVerifyList, MonitorBaseParam monitorBaseParam) {
List<PowerQualityIndicatorsVO> result = new ArrayList<>();
Map<String, List<DataLimitTargetDto>> dataMap = dataVerifyList.stream().collect(Collectors.groupingBy(DataLimitTargetDto::getLineId));
@@ -702,7 +796,6 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
}
/**
* 判断测点是否存在连续异常数据
*/
@@ -758,6 +851,7 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
/**
* 检查日期列表中是否存在连续指定天数的异常
*
* @param dateList 日期列表(已排序)
* @param day 连续天数阈值
* @return 是否存在连续异常
@@ -779,6 +873,4 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
}
}

View File

@@ -20,7 +20,7 @@ import java.util.Map;
@Mapper
public interface LargeScreenMapper {
Map<String, Object> selectDownCount(@Param("lineIds") List<String> lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
Integer selectDownCount(@Param("lineIds") List<String> lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<Map<String, Object>> selectLoadTypeCount(@Param("lineIds") List<String> lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime);

View File

@@ -2,9 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.event.mapper.majornetwork.LargeScreenMapper">
<select id="selectDownCount" resultType="java.util.Map">
<select id="selectDownCount" resultType="java.lang.Integer">
select
count(ed.event_id) "count"
count(ed.event_id) "COUNT"
from r_mp_event_detail ed
where
ed.measurement_point_id in

View File

@@ -86,84 +86,37 @@ public class AreaLineServiceImpl implements AreaLineService {
List<List<Object>> listObject = new ArrayList<>();
// 获取暂降监测点
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
List<String> lineIndexs;
List<String> lineIds = generalDeviceDTOList.stream().flatMap(x -> x.getLineIndexes().stream()).collect(Collectors.toList());
List<AreaLineInfoVO> lineDetails = lineFeignClient.getBaseLineAreaInfo(lineIds).getData();
List<SubstationDetailVO> substationDetailVOList = new ArrayList<>();
// 获取所有终端信息
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
List<Object> objectList = new ArrayList<>();
List<String> subIndexs;
subIndexs = generalDeviceDTO.getSubIndexes();
lineIndexs = generalDeviceDTO.getLineIndexes();
// 通讯正常个数
int stateZc = 0;
// 通讯中断个数
int stateZd = 0;
// 总次数
int tail = 0;
String color = "";
List<SubstationDetailVO> substationDetailVOS = new ArrayList<>();
if (subIndexs.size() > 0) {
List<LineDeviceStateVO> lineList = lineFeignClient.getAllLine(lineIndexs).getData();
substationDetailVOS = lineFeignClient.getSubstationData(subIndexs).getData();
for (int i = 0; i < substationDetailVOS.size(); i++) {
List<LineDeviceStateVO> list = new ArrayList<>();
list.addAll(lineList);
Iterator<LineDeviceStateVO> iterator = list.listIterator();
// 获取监测点
while (iterator.hasNext()) {
LineDeviceStateVO line = iterator.next();
String[] ids = line.getPids().split(",");
if (!ids[3].equals(substationDetailVOS.get(i).getId())) {
iterator.remove();
}
}
List<LineDeviceStateVO> lineDataVOList = list;
// 通讯正常个数
int stateTrue;
stateTrue = 0;
// 通讯中断个数
int stateFalse = 0;
// 次数
double r = 0.0035;
List<AreaLineInfoVO> areaLineInfoVOS = lineDetails.stream().filter(x -> generalDeviceDTO.getLineIndexes().contains(x.getLineId())).collect(Collectors.toList());
Map<String, List<AreaLineInfoVO>> subMap = areaLineInfoVOS.stream().collect(Collectors.groupingBy(x->x.getSubId()+"_"+x.getSubName()));
subMap.forEach((key,value)->{
int j = 0;
// 总的监测点个数
int lineTail = lineDataVOList.size();
for (LineDeviceStateVO lineDataVO : lineDataVOList) {
if (lineDataVO.getState() == 1) {
stateTrue++;
color = "green";
} else {
stateFalse++;
color = "red";
}
for (AreaLineInfoVO line : value) {
SubstationDetailVO substationDetail = new SubstationDetailVO();
substationDetail.setId(lineDataVO.getId());
substationDetail.setSrbName(lineDataVO.getName());
substationDetail.setSubName(lineDataVO.getSubName());
substationDetail.setCoordY(substationDetailVOS.get(i).getCoordY().floatValue() + r * Math.cos(2 * Math.PI * j / lineTail));
substationDetail.setCoordX(substationDetailVOS.get(i).getCoordX().floatValue() + r * Math.sin(2 * Math.PI * j / lineTail));
substationDetail.setColor(color);
substationDetail.setId(line.getLineId());
substationDetail.setSrbName(line.getLineName());
substationDetail.setSubName(line.getSubName());
substationDetail.setCoordY(line.getLng().floatValue() + 0.0035 * Math.cos(2 * Math.PI * j / value.size()));
substationDetail.setCoordX(line.getLat().floatValue() + 0.0035 * Math.sin(2 * Math.PI * j / value.size()));
substationDetail.setColor(line.getComFlag() == 1?"green":"red");
substationDetailVOList.add(substationDetail);
j++;
}
stateZc += stateTrue;
stateZd += stateFalse;
tail += lineTail;
}
}
});
// 获取变电站
substationDetailVOList.addAll(substationDetailVOS);
if (lineIndexs.size() > 0) {
areaLineVO.setSubstationDetailVOList(substationDetailVOList);
objectList.add(generalDeviceDTO.getName());
objectList.add(tail);
objectList.add(stateZc);
objectList.add(stateZd);
objectList.add(areaLineInfoVOS.stream().filter(x->x.getComFlag()==1).count());
objectList.add(areaLineInfoVOS.stream().filter(x->x.getComFlag()==0).count());
objectList.add(areaLineInfoVOS.size());
listObject.add(objectList);
}
}
areaLineVO.setAreaValue(listObject);
return areaLineVO;
}
@@ -208,8 +161,7 @@ public class AreaLineServiceImpl implements AreaLineService {
List<AreaLineInfoVO> ev = new ArrayList<>();
Integer count = info.stream()
.filter(obj -> obj.getMeasurementPointId().equals( areaLineInfoVO.getLineId()))
.mapToInt(RmpEventDetailPO::getFileFlag)
.sum();
.collect(Collectors.toList()).size();
tail+=count;
areaLineInfoVO.setTail(count);
ev.add(areaLineInfoVO);

View File

@@ -83,12 +83,10 @@ public class LargeScreenServiceImpl implements LargeScreenService {
param.setSize(0);
list.add(param);
} else {
Map<String, Object> map = largeScreenMapper.selectDownCount(generalDeviceDTO.getLineIndexes(), largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
int count = largeScreenMapper.selectDownCount(generalDeviceDTO.getLineIndexes(), largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
MonitoringPointScaleParam param = new MonitoringPointScaleParam();
param.setName(generalDeviceDTO.getName());
param.setIndex(generalDeviceDTO.getIndex());
String s = map.get("count").toString();
int count = Integer.parseInt(s);
param.setCount(count);
param.setSize(generalDeviceDTO.getLineIndexes().size());
list.add(param);
@@ -96,27 +94,6 @@ public class LargeScreenServiceImpl implements LargeScreenService {
}
result.setParam(list);
return result;
/* //获取所有监测点集合
List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
List<Map<String, Object>> maps = largeScreenMapper.selectDownCount(lineIds);
Map<String,Integer> countMap = new HashMap<>();
for (Map<String, Object> map : maps) {
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
for (String lineIndex : generalDeviceDTO.getLineIndexes()) {
if (map.get("id").equals(lineIndex)){
if(countMap.containsKey(generalDeviceDTO.getName())){
countMap.put(generalDeviceDTO.getName(),countMap.get(generalDeviceDTO.getName())+1);
break;
}else {
countMap.put(generalDeviceDTO.getName(),1);
break;
}
}
}
}
}*/
}
/**