1.变电站上送逻辑修改

2.添加pms配网用户侧数据完整性接口
3.添加pms配网用户侧指标越限接口
This commit is contained in:
2024-09-06 15:52:10 +08:00
parent 9f0a1ed19e
commit a3772119b4
22 changed files with 320 additions and 62 deletions

View File

@@ -11,6 +11,7 @@ import com.njcn.harmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
import com.njcn.harmonic.pojo.vo.MonitorLimitRateVO;
import com.njcn.harmonic.pojo.vo.PwLimitDataVO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import com.njcn.harmonic.service.majornetwork.RStatLimitService;
import com.njcn.web.controller.BaseController;
@@ -92,4 +93,13 @@ public class RStatLimitController extends BaseController {
}
@PostMapping("/pwMonitorLimitDataRange")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("获取配网指标超标详情")
public HttpResult<List<PwLimitDataVO>> pwMonitorLimitDataRange(@RequestBody @Validated PwUserMonitorParam pwUserMonitorParam){
String methodDescribe = getMethodDescribe("pwMonitorLimitDataRange");
List<PwLimitDataVO> page = rStatLimitService.pwMonitorLimitDataRange(pwUserMonitorParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
}

View File

@@ -7,6 +7,7 @@ import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
import com.njcn.harmonic.pojo.vo.MonitorLimitRateVO;
import com.njcn.harmonic.pojo.vo.PwLimitDataVO;
import com.njcn.harmonic.pojo.vo.RStatLimitRateDVO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import org.springframework.web.bind.annotation.RequestParam;
@@ -54,4 +55,6 @@ public interface RStatLimitService {
Page<MonitorLimitRateVO> pwMonitorLimitData(PwUserMonitorParam pwUserMonitorParam);
List<PwLimitDataVO> pwMonitorLimitDataRange(PwUserMonitorParam pwUserMonitorParam);
}

View File

@@ -2,7 +2,10 @@ package com.njcn.harmonic.service.majornetwork.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.lang.func.Func;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -32,6 +35,7 @@ import com.njcn.harmonic.pojo.po.RMpVThd;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
import com.njcn.harmonic.pojo.vo.MonitorLimitRateVO;
import com.njcn.harmonic.pojo.vo.PwLimitDataVO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import com.njcn.harmonic.service.IRStatLimitTargetDService;
import com.njcn.harmonic.service.majornetwork.RStatLimitService;
@@ -45,6 +49,8 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
@@ -472,6 +478,91 @@ public class RStatLimitServiceImpl implements RStatLimitService {
pageResult.setRecords(resultList);
}
return pageResult;
}
@Override
public List<PwLimitDataVO> pwMonitorLimitDataRange(PwUserMonitorParam pwUserMonitorParam) {
List<PwLimitDataVO> result = new ArrayList<>();
if(CollUtil.isEmpty(pwUserMonitorParam.getIds())){
return result;
}
LambdaQueryWrapper<RStatLimitTargetDPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
LocalDate startDate = LocalDate.parse(pwUserMonitorParam.getSearchBeginTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
LocalDate endDate = LocalDate.parse(pwUserMonitorParam.getSearchEndTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
lambdaQueryWrapper.select(RStatLimitTargetDPO::getLineId,RStatLimitTargetDPO::getTime,RStatLimitTargetDPO::getAllTime).in(RStatLimitTargetDPO::getLineId,pwUserMonitorParam.getIds());
lambdaQueryWrapper.between(RStatLimitTargetDPO::getTime,pwUserMonitorParam.getSearchBeginTime(),pwUserMonitorParam.getSearchEndTime());
List<RStatLimitTargetDPO> rStatLimitTargetDPOList = rStatLimitTargetDMapper.selectList(lambdaQueryWrapper);
if(CollUtil.isNotEmpty(rStatLimitTargetDPOList)){
Map<String,List<RStatLimitTargetDPO>> map = rStatLimitTargetDPOList.stream().collect(Collectors.groupingBy(RStatLimitTargetDPO::getLineId));
processDateRange(startDate,endDate,map,result);
}
return result;
}
public void processDateRange(LocalDate startDate, LocalDate endDate,Map<String,List<RStatLimitTargetDPO>> map,List<PwLimitDataVO> result) {
map.forEach((lineKey,list)->{
PwLimitDataVO pwLimitDataVO = new PwLimitDataVO();
pwLimitDataVO.setLineId(lineKey);
pwLimitDataVO.setName(lineKey);
List<PwLimitDataVO.LimitDetail> detailList = new ArrayList<>();
if (startDate.getYear() == endDate.getYear() && startDate.getMonth() == endDate.getMonth()) {
Map<LocalDate, RStatLimitTargetDPO> targetDPOMap = list.stream().collect(Collectors.toMap(RStatLimitTargetDPO::getTime, Function.identity()));
// 如果在同一个月,则遍历每一天
for (LocalDate date = startDate; !date.isAfter(endDate.minusDays(1)); date = date.plusDays(1)) {
PwLimitDataVO.LimitDetail limitDetail = new PwLimitDataVO.LimitDetail();
if (targetDPOMap.containsKey(date)) {
limitDetail.setLimitFlag(targetDPOMap.get(date).getAllTime() > 0 ? 2 : 1);
} else {
limitDetail.setLimitFlag(0);
}
limitDetail.setDay(date.getDayOfMonth() +"");
detailList.add(limitDetail);
}
}else {
Map<String,List<RStatLimitTargetDPO>> targetDPOMap = list.stream().collect(Collectors.groupingBy(it->LocalDateTimeUtil.format(it.getTime(),DatePattern.NORM_MONTH_PATTERN)));
// 如果在同一个月,则遍历每一天
// 如果不在同一个月,则遍历每个月(这里简化处理,只打印月份和年份)
LocalDate currentDate = startDate;
while (!currentDate.isAfter(endDate)) {
String date = LocalDateTimeUtil.format(currentDate,DatePattern.NORM_MONTH_PATTERN);
PwLimitDataVO.LimitDetail limitDetail = new PwLimitDataVO.LimitDetail();
if(targetDPOMap.containsKey(date)){
boolean res = targetDPOMap.get(date).stream().anyMatch(item->item.getAllTime()>0);
limitDetail.setLimitFlag(res ? 2:1);
}else {
limitDetail.setLimitFlag(0);
}
limitDetail.setDay(currentDate.getMonthValue() +"");
detailList.add(limitDetail);
// 跳到下一个月的第一天(注意:这里简化了处理,没有实际遍历这个月的每一天)
currentDate = currentDate.plusMonths(1).withDayOfMonth(1);
// 如果当前月已经超过了结束月,则退出循环
if (currentDate.isAfter(endDate)) {
break;
}
}
}
pwLimitDataVO.setDetailList(detailList);
result.add(pwLimitDataVO);
});
}

View File

@@ -8,6 +8,7 @@ import cn.hutool.core.text.StrBuilder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -162,18 +163,28 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
//以尺寸100分片
List<List<PqTypicalSourceCreatePO>> partition = ListUtils.partition(list, 100);
partition.forEach(temp->{
List<PqTypicalSourceCreateDTO> dtoList = BeanUtil.copyToList(temp, PqTypicalSourceCreateDTO.class);
StrBuilder resultLog = new StrBuilder();
AtomicBoolean resultFlag = new AtomicBoolean(true);
for (int i = 0; i < partition.size(); i++) {
List<PqTypicalSourceCreateDTO> dtoList = BeanUtil.copyToList(partition.get(i), PqTypicalSourceCreateDTO.class);
SendParam sendParam = new SendParam();
sendParam.setStats(dtoList);
sendParam.setStatisticalDate(temp.get(0).getComputeDate());
String s = JSONObject.toJSONStringWithDateFormat(sendParam, JSON.DEFFAULT_DATE_FORMAT);
sendParam.setStatisticalDate(partition.get(i).get(0).getComputeDate());
if(i == 0){
sendParam.setIsAppend("0");
}else if(i==partition.size()-1){
sendParam.setIsAppend("2");
}else {
sendParam.setIsAppend("1");
}
Map<String, String> send = GwSendUtil.send(sendParam, GWSendEnum.TYPICAL_SOURCE);
List<String> trIds = dtoList.stream().map(PqTypicalSourceCreateDTO::getId).distinct().collect(Collectors.toList());
returnInformation(1, trIds, send);
});
assUploadLog(localDate,new StrBuilder("典型源荷指标统计上送成功"),new AtomicBoolean(true));
returnInformation(i, trIds, send,resultLog, resultFlag, localDate);
}
if (resultFlag.get()) {
resultLog.append(" 上送" + list.size() + "条数据成功");
assUploadLog(localDate, resultLog, resultFlag);
}
return "成功";
}
@@ -192,34 +203,50 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
/**
* 国网上送返回信息
*
* @param num
* @param ids
* @param send
* @return
*/
private String returnInformation(Integer num, List<String> ids, Map<String, String> send) {
private void returnInformation(Integer step, List<String> ids, Map<String, String> send, StrBuilder resultLog, AtomicBoolean resultFlag, LocalDate localDate) {
int start = step * 100;
int end = (step + 1) * 100;
if (send.containsKey("succeed")) {
String succeed = send.get("succeed");
if (succeed.indexOf("\\\"") != -1) {
if (succeed.contains("\\\"")) {
succeed = succeed.replace("\\\"", "\"");
}
Map mapData = JSON.parseObject(succeed, Map.class);
String status = mapData.get("status").toString();
if ("000000".equals(status)) {
//修改信息状态
this.lambdaUpdate().in(PqTypicalSourceCreatePO::getId,ids).set(PqTypicalSourceCreatePO::getIsUploadHead,num).update();
//修改数据上送状态
updateState(ids);
String result = mapData.get("result").toString();
Map mapCount = JSON.parseObject(result, Map.class);
String count = mapCount.get("count").toString();
return "操作成功:成功数据" + count + "";
} else {
resultFlag.set(false);
String errors = mapData.get("errors").toString();
throw new BusinessException("操作失败:" + status + "_" + errors);
String errorMsg = " 上送" + start + "条至" + end + "条数据,上送失败:" + status + "_" + errors + " ;";
resultLog.append(errorMsg);
assUploadLog(localDate, resultLog, resultFlag);
throw new BusinessException(errorMsg);
}
} else {
// updateIsUploadHead(num, ids);
resultFlag.set(false);
resultLog.append(" 上送" + start + "条至" + end + "条数据网络异常;");
assUploadLog(localDate, resultLog, resultFlag);
throw new BusinessException("当前时间段国网上送请求过多,请稍后再试");
// return "当前时间段国网上送请求过多,请稍后再试";
}
}
private void updateState(List<String> ids) {
LambdaUpdateWrapper<PqTypicalSourceCreatePO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.in(PqTypicalSourceCreatePO::getId, ids)
.set(PqTypicalSourceCreatePO::getIsUploadHead, 1);
this.update(lambdaUpdateWrapper);
}
}

View File

@@ -108,10 +108,18 @@ public class PointStatisticalDataServiceImpl extends ServiceImpl<RUploadPointSta
AtomicBoolean resultFlag = new AtomicBoolean(true);
//分片上传
for (int i = 0; i < partition.size(); i++) {
List<MonitorStatisticalDTO> dtoList = BeanUtil.copyToList(partition.get(i), MonitorStatisticalDTO.class);
SendParam sp = new SendParam();
sp.setStats(dtoList);
sp.setStatisticalDate(partition.get(i).get(0).getComputeDate());
if(i == 0){
sp.setIsAppend("0");
}else if(i==partition.size()-1){
sp.setIsAppend("2");
}else {
sp.setIsAppend("1");
}
//上送数据
Map<String, String> send = GwSendUtil.send(sp, GWSendEnum.STATISTICAL_CREATE);
//获取返回结果

View File

@@ -203,6 +203,13 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
SendParam sp = new SendParam();
sp.setStats(dtoList);
sp.setStatisticalDate(collect.get(0).getComputeDate());
if(i == 0){
sp.setIsAppend("0");
}else if(i==partition.size()-1){
sp.setIsAppend("2");
}else {
sp.setIsAppend("1");
}
//上送数据
Map<String, String> send = GwSendUtil.send(sp, GWSendEnum.EVALUATION);
//获取返回结果

View File

@@ -80,18 +80,21 @@ public class RSubstationStatisticalDataServiceImpl extends ServiceImpl<RUploadSu
//(预防之前上送过,修改数据后需要再次上送)
if (CollUtil.isNotEmpty(param.getList())){
list = this.lambdaQuery()
.eq(RUploadSubstationStatisticalDataD::getStatisticalDate,param.getTime())
.in(RUploadSubstationStatisticalDataD::getId,param.getList())
.isNotNull(RUploadSubstationStatisticalDataD::getComputeDate)
.eq(RUploadSubstationStatisticalDataD::getComputeDate,param.getTime())
.list();
}
//未指定数据上送,则将所有未上送的数据,上送上去
else {
list = this.lambdaQuery()
.eq(RUploadSubstationStatisticalDataD::getStatisticalDate,param.getTime())
.isNotNull(RUploadSubstationStatisticalDataD::getComputeDate)
.eq(RUploadSubstationStatisticalDataD::getComputeDate,param.getTime())
.list();
}
if(CollUtil.isEmpty(list)){
throw new BusinessException("数据为空,请联系管理员排查");
}
//以尺寸100分片
List<List<RUploadSubstationStatisticalDataD>> partition = ListUtils.partition(list, 100);
StrBuilder resultLog = new StrBuilder();
@@ -106,6 +109,13 @@ public class RSubstationStatisticalDataServiceImpl extends ServiceImpl<RUploadSu
SendParam sp = new SendParam();
sp.setStats(dtoList);
sp.setStatisticalDate(partition.get(i).get(0).getComputeDate());
if(i == 0){
sp.setIsAppend("0");
}else if(i==partition.size()-1){
sp.setIsAppend("2");
}else {
sp.setIsAppend("1");
}
//上送数据
Map<String, String> send = GwSendUtil.send(sp, GWSendEnum.SUBSTATION_MONITOR);
//获取返回结果