1.pms公共连接点功能

This commit is contained in:
cdf
2024-08-24 20:47:15 +08:00
parent f4fd509d12
commit 6dc1b415dc
15 changed files with 608 additions and 35 deletions

View File

@@ -44,6 +44,9 @@ public enum GWSendEnum {
PARK_AND_STATION("parkAndStation", "/pms-ghq-powerquality-start/powerQuality/park/create"),
REPORT_CREATE("reportCreate", "/pms-ghq-powerquality-start/powerQuality/report/create"),
COMM_POINT("commPoint","/pms-ghq-powerquality-start/powerQuality/publicConnection/pqBusMonitorDataStatisticalCreate")
;

View File

@@ -22,6 +22,10 @@ public class SendParam {
@ApiModelProperty(value = "统计日期")
private String statisticalDate;
private String statisticalType;
private String isAppend;
@ApiModelProperty(value = "上报参数")
private List stats;
}

View File

@@ -191,6 +191,7 @@ spring:
uri: lb://harmonic-boot
predicates:
- Path=/IndexAnalysis/**
- Path=/pms-tech-powerquality-start/**
#项目日志的配置

View File

@@ -27,4 +27,7 @@ public interface UploadGwDataFeignClient {
@PostMapping("/uploadEvaluationData")
HttpResult<String> uploadEvaluationData(@RequestBody UploadParam param);
@PostMapping("/upGwCommPoint")
HttpResult<String> upGwCommPoint(@RequestBody UploadParam param);
}

View File

@@ -45,6 +45,12 @@ public class UploadGwDataFallbackFactory implements FallbackFactory<UploadGwData
log.error("{}异常,降级处理,异常为:{}", "国网上送-母线基准水平评估数据", throwable.toString());
return new HttpResult<>(CommonResponseEnum.FAIL.getCode(),CommonResponseEnum.FAIL.getMessage());
}
@Override
public HttpResult<String> upGwCommPoint(UploadParam param) {
log.error("{}异常,降级处理,异常为:{}", "国网上送-公共连接点数据", throwable.toString());
return new HttpResult<>(CommonResponseEnum.FAIL.getCode(),CommonResponseEnum.FAIL.getMessage());
}
};
}
}

View File

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import com.njcn.db.bo.BaseEntity;
import java.io.Serializable;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@@ -16,8 +18,7 @@ import lombok.Setter;
* @author xy
* @since 2024-08-15
*/
@Getter
@Setter
@TableName("r_upload_comm_point_bus")
public class RUploadCommPointBus implements Serializable {
@@ -162,5 +163,246 @@ public class RUploadCommPointBus implements Serializable {
@TableField(exist = false)
private String cnMonitorId;
private Integer uploadStatus;
public Integer getUploadStatus() {
return uploadStatus;
}
public void setUploadStatus(Integer uploadStatus) {
this.uploadStatus = uploadStatus;
}
public String getObjId() {
return objId;
}
public void setObjId(String objId) {
this.objId = objId;
}
public String getStatisticalType() {
return statisticalType;
}
public void setStatisticalType(String statisticalType) {
this.statisticalType = statisticalType;
}
public String getStatisticalDate() {
return statisticalDate;
}
public void setStatisticalDate(String statisticalDate) {
this.statisticalDate = statisticalDate;
}
public String getBusId() {
return busId;
}
public void setBusId(String busId) {
this.busId = busId;
}
public String getBusName() {
return busName;
}
public void setBusName(String busName) {
this.busName = busName;
}
public String getProvinceOrg() {
return provinceOrg;
}
public void setProvinceOrg(String provinceOrg) {
this.provinceOrg = provinceOrg;
}
public String getProvinceOrgName() {
return provinceOrgName;
}
public void setProvinceOrgName(String provinceOrgName) {
this.provinceOrgName = provinceOrgName;
}
public String getCityOrg() {
return cityOrg;
}
public void setCityOrg(String cityOrg) {
this.cityOrg = cityOrg;
}
public String getCityOrgName() {
return cityOrgName;
}
public void setCityOrgName(String cityOrgName) {
this.cityOrgName = cityOrgName;
}
public String getMaintOrg() {
return maintOrg;
}
public void setMaintOrg(String maintOrg) {
this.maintOrg = maintOrg;
}
public String getMaintOrgName() {
return maintOrgName;
}
public void setMaintOrgName(String maintOrgName) {
this.maintOrgName = maintOrgName;
}
public String getStationType() {
return stationType;
}
public void setStationType(String stationType) {
this.stationType = stationType;
}
public String getStationId() {
return stationId;
}
public void setStationId(String stationId) {
this.stationId = stationId;
}
public String getStationName() {
return stationName;
}
public void setStationName(String stationName) {
this.stationName = stationName;
}
public String getStationVoltageLevel() {
return stationVoltageLevel;
}
public void setStationVoltageLevel(String stationVoltageLevel) {
this.stationVoltageLevel = stationVoltageLevel;
}
public String getBusVoltageLevel() {
return busVoltageLevel;
}
public void setBusVoltageLevel(String busVoltageLevel) {
this.busVoltageLevel = busVoltageLevel;
}
public Integer getOvDays() {
return ovDays;
}
public void setOvDays(Integer ovDays) {
this.ovDays = ovDays;
}
public Double getAvgVrms() {
return avgVrms;
}
public void setAvgVrms(Double avgVrms) {
this.avgVrms = avgVrms;
}
public Double getgVrms() {
return gVrms;
}
public void setgVrms(Double gVrms) {
this.gVrms = gVrms;
}
public Integer getHarmVOvDays() {
return harmVOvDays;
}
public void setHarmVOvDays(Integer harmVOvDays) {
this.harmVOvDays = harmVOvDays;
}
public Integer getHarmVOvDuration() {
return harmVOvDuration;
}
public void setHarmVOvDuration(Integer harmVOvDuration) {
this.harmVOvDuration = harmVOvDuration;
}
public Integer getVunbanOvDays() {
return vunbanOvDays;
}
public void setVunbanOvDays(Integer vunbanOvDays) {
this.vunbanOvDays = vunbanOvDays;
}
public Integer getVunbanOvDuration() {
return vunbanOvDuration;
}
public void setVunbanOvDuration(Integer vunbanOvDuration) {
this.vunbanOvDuration = vunbanOvDuration;
}
public Integer getPltOvDays() {
return pltOvDays;
}
public void setPltOvDays(Integer pltOvDays) {
this.pltOvDays = pltOvDays;
}
public Integer getPltOvDuration() {
return pltOvDuration;
}
public void setPltOvDuration(Integer pltOvDuration) {
this.pltOvDuration = pltOvDuration;
}
public String getMonitorId() {
return monitorId;
}
public void setMonitorId(String monitorId) {
this.monitorId = monitorId;
}
public String getMonitorIds() {
return monitorIds;
}
public void setMonitorIds(String monitorIds) {
this.monitorIds = monitorIds;
}
public String getDataSource() {
return dataSource;
}
public void setDataSource(String dataSource) {
this.dataSource = dataSource;
}
public String getCnMonitorId() {
return cnMonitorId;
}
public void setCnMonitorId(String cnMonitorId) {
this.cnMonitorId = cnMonitorId;
}
}

View File

@@ -1,6 +1,23 @@
package com.njcn.harmonic.controller.upload;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.common.utils.LogUtil;
import com.njcn.harmonic.pojo.param.UploadDataParam;
import com.njcn.harmonic.pojo.po.upload.RUploadCommPointBus;
import com.njcn.harmonic.pojo.vo.upload.UploadPointStatisticalDataVo;
import com.njcn.harmonic.service.upload.IRUploadCommPointBusService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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;
@@ -15,8 +32,33 @@ import com.njcn.web.controller.BaseController;
* @since 2024-08-15
*/
@RestController
@RequestMapping("/upload/rUploadCommPointBus")
@RequestMapping("/upload")
@RequiredArgsConstructor
public class RUploadCommPointBusController extends BaseController {
private final IRUploadCommPointBusService irUploadCommPointBusService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getCommPointBusPage")
@ApiOperation("分页查询公共连接点")
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
public HttpResult<Page<RUploadCommPointBus>> getCommPointBusPage(@RequestBody @Validated UploadDataParam param) {
String methodDescribe = getMethodDescribe("getCommPointBusPage");
Page<RUploadCommPointBus> page = irUploadCommPointBusService.getCommPointBusPage(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/upGwCommPoint")
@ApiOperation("上送国网")
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
public HttpResult<Boolean> upGwCommPoint(@RequestBody UploadDataParam param) {
String methodDescribe = getMethodDescribe("upGwCommPoint");
irUploadCommPointBusService.upGw(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
}

View File

@@ -1,14 +1,24 @@
package com.njcn.harmonic.service.upload;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.harmonic.pojo.param.UploadDataParam;
import com.njcn.harmonic.pojo.po.upload.RUploadCommPointBus;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
/**
* <p>
* 公共连接点母线电能质量统计 服务类
* </p>
*/
@Service
public interface IRUploadCommPointBusService extends IService<RUploadCommPointBus> {
Page<RUploadCommPointBus> getCommPointBusPage(UploadDataParam param);
Boolean upGw(UploadDataParam param);
}

View File

@@ -1,12 +1,33 @@
package com.njcn.harmonic.service.upload.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.harmonic.mapper.upload.RUploadCommPointBusMapper;
import com.njcn.harmonic.pojo.param.UploadDataParam;
import com.njcn.harmonic.pojo.po.upload.RUploadCommPointBus;
import com.njcn.harmonic.service.upload.IRUploadCommPointBusService;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.web.enums.GWSendEnum;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.param.SendParam;
import com.njcn.web.utils.GwSendUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* <p>
* 公共连接点母线电能质量统计 服务实现类
@@ -18,4 +39,80 @@ import org.springframework.stereotype.Service;
@Service
public class RUploadCommPointBusServiceImpl extends ServiceImpl<RUploadCommPointBusMapper, RUploadCommPointBus> implements IRUploadCommPointBusService {
@Override
public Page<RUploadCommPointBus> getCommPointBusPage(UploadDataParam param) {
DateTime dateTime = DateUtil.parse(param.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN);
if(param.getDataType().equals("02")){
param.setSearchBeginTime(DateUtil.format(dateTime,DatePattern.NORM_MONTH_PATTERN));
}else if(param.getDataType().equals("01")){
param.setSearchBeginTime(DateUtil.format(dateTime,DatePattern.NORM_YEAR_PATTERN));
}
LambdaQueryWrapper<RUploadCommPointBus> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(RUploadCommPointBus::getStatisticalType,param.getDataType())
.eq(RUploadCommPointBus::getStatisticalDate,param.getSearchBeginTime());
return this.page(new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param)),lambdaQueryWrapper);
}
@Override
public Boolean upGw(UploadDataParam param) {
if(StrUtil.isBlank(param.getSearchBeginTime())){
throw new BusinessException("日期不可为空");
}
LambdaQueryWrapper<RUploadCommPointBus> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if(StrUtil.isBlank(param.getDataType())){
//类型为空则上送日月年数据
DateTime dateTime = DateUtil.parse(param.getSearchBeginTime(),DatePattern.NORM_DATE_PATTERN);
String month = DateUtil.format(dateTime,DatePattern.NORM_MONTH_PATTERN);
String year = DateUtil.format(dateTime,DatePattern.NORM_YEAR_PATTERN);
lambdaQueryWrapper.in(RUploadCommPointBus::getStatisticalDate, Stream.of(param.getSearchBeginTime(),month,year).collect(Collectors.toList()));
}else {
lambdaQueryWrapper.eq(RUploadCommPointBus::getStatisticalType,param.getDataType())
.eq(RUploadCommPointBus::getStatisticalDate,param.getSearchBeginTime());
}
List<RUploadCommPointBus> rUploadCommPointBusList = this.list(lambdaQueryWrapper);
if(CollUtil.isEmpty(rUploadCommPointBusList)){
throw new BusinessException("查询数据为空");
}
List<List<RUploadCommPointBus>> list = CollUtil.split(rUploadCommPointBusList,100);
for(int i=0;i<list.size();i++){
SendParam sendParam = new SendParam();
if(i==0){
sendParam.setIsAppend("0");
}else if(i==list.size()-1){
sendParam.setIsAppend("2");
}else {
sendParam.setIsAppend("1");
}
if(StrUtil.isNotBlank(param.getDataType())){
DateTime dateTime = DateUtil.parse(param.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN);
sendParam.setStatisticalType(param.getDataType());
if(param.getDataType().equals(DicDataEnum.STATISTICAL_TYPE_M.getCode())){
param.setSearchBeginTime(DateUtil.format(dateTime,DatePattern.NORM_MONTH_PATTERN));
}else if(param.getDataType().equals(DicDataEnum.STATISTICAL_TYPE_Y.getCode())){
param.setSearchBeginTime(DateUtil.format(dateTime,DatePattern.NORM_YEAR_PATTERN));
}
sendParam.setStatisticalDate(param.getSearchBeginTime());
}
sendParam.setStats(list);
Map<String, String> sendRes = GwSendUtil.send(sendParam, GWSendEnum.COMM_POINT);
List<String> ids = list.get(i).stream().map(RUploadCommPointBus::getObjId).collect(Collectors.toList());
int count = GwSendUtil.returnInfoMsg(ids,sendRes);
System.out.println("上送成功,上送成功返回"+count+"");
if(count == list.get(i).size()){
LambdaUpdateWrapper<RUploadCommPointBus> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(RUploadCommPointBus::getUploadStatus,1).in(RUploadCommPointBus::getObjId,ids);
this.update(lambdaUpdateWrapper);
}
}
return true;
}
}

View File

@@ -12,6 +12,7 @@ import com.njcn.prepare.harmonic.service.mysql.area.RStatOrgService;
import com.njcn.prepare.harmonic.service.mysql.dim.*;
import com.njcn.prepare.harmonic.service.mysql.line.PollutionService;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.*;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadCommPointBusService;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadEvaluationDataDService;
import com.njcn.prepare.harmonic.service.mysql.send.ConverterIndexStatisticsPOService;
import com.njcn.prepare.harmonic.service.mysql.send.PqTypicalSourceCreatePOService;
@@ -50,11 +51,6 @@ public class OrgPointExecutor extends BaseExecutor{
private final RAlarmCountService rAlarmCountService;
private final RDimBusbarHarmnicDPOService rDimBusbarHarmnicDPOService;
private final RDimStationHarmnicDPOService rDimStationHarmnicDPOService;
private final RDimStationTargetDPOService rDimStationTargetDPOService;
private final RDimStationTargetMPOService rDimStationTargetMPOService;
private final RDimStationTargetYPOService rDimStationTargetYPOService;
private final RDimBusTargetDPOService rDimBusTargetDPOService;
private final RDimBusTargetMPOService rDimBusTargetMPOService;
@@ -77,6 +73,8 @@ public class OrgPointExecutor extends BaseExecutor{
private final ConverterIndexStatisticsPOService converterIndexStatisticsPOService;
private final PqTypicalSourceCreatePOService pqTypicalSourceCreatePOService;
private final IRUploadEvaluationDataDService irUploadEvaluationDataDService;
private final IRUploadCommPointBusService irUploadCommPointBusService;
/**
*
* 3.3.2. 单位标数据质量
@@ -714,4 +712,24 @@ public class OrgPointExecutor extends BaseExecutor{
}
}
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rUploadCommPoint", nodeType = NodeTypeEnum.COMMON)
public boolean rUploadCommPointAccess(NodeComponent bindCmp) {
return isAccess(bindCmp);
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rUploadCommPoint", nodeType = NodeTypeEnum.COMMON)
public void rUploadCommPointProcess(NodeComponent bindCmp) {
String tag = bindCmp.getTag();
CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam = bindCmp.getRequestData();
if (tag.equalsIgnoreCase("r_upload_comm_point_d")) {
//日表
irUploadCommPointBusService.handlerDay(calculatedParam.getDataDate());
} else if (tag.equalsIgnoreCase("r_upload_comm_point_m")) {
//月表
irUploadCommPointBusService.handlerMonth(calculatedParam.getDataDate());
} else if (tag.equalsIgnoreCase("r_upload_comm_point_y")) {
//月表
irUploadCommPointBusService.handlerYear(calculatedParam.getDataDate());
}
}
}

View File

@@ -24,4 +24,6 @@ public class CommPointController {
}
}

View File

@@ -14,4 +14,10 @@ public interface IRUploadCommPointBusService extends IService<RUploadCommPointBu
void handlerDay(String date);
void handlerMonth(String date);
void handlerYear(String date);
}

View File

@@ -2,6 +2,9 @@ package com.njcn.prepare.harmonic.service.mysql.upload.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -82,7 +85,6 @@ public class RUploadCommPointBusServiceImpl extends MppServiceImpl<RUploadCommPo
@Override
@Async("asyncExecutor")
public void handlerDay(String date){
List<RUploadCommPointBus> poLIst = new ArrayList<>();
@@ -177,6 +179,7 @@ public class RUploadCommPointBusServiceImpl extends MppServiceImpl<RUploadCommPo
rUploadCommPointBus.setMonitorId(point.getMonitorId());
rUploadCommPointBus.setDataSource("01");
rUploadCommPointBus.setCnMonitorId(point.getId());
rUploadCommPointBus.setUploadStatus(DataStateEnum.DELETED.getCode());
poLIst.add(rUploadCommPointBus);
});
@@ -202,7 +205,7 @@ public class RUploadCommPointBusServiceImpl extends MppServiceImpl<RUploadCommPo
}
if(cpMap.containsKey(item.getCnMonitorId())){
RStatDataVDPO rStatDataVDPO = cpMap.get(item.getCnMonitorId());
item.setGVrms(rStatDataVDPO.getRms());
item.setgVrms(rStatDataVDPO.getRms());
}
Integer limitDay = 0;
@@ -254,6 +257,158 @@ public class RUploadCommPointBusServiceImpl extends MppServiceImpl<RUploadCommPo
}
public void handlerMonth(String date){
DateTime begin = DateUtil.beginOfMonth(DateUtil.parse(date, DatePattern.NORM_DATE_PATTERN));
DateTime end = DateUtil.parse(date, DatePattern.NORM_DATE_PATTERN);
String month = DateUtil.format(end,DatePattern.NORM_MONTH_PATTERN);
LambdaQueryWrapper<RUploadCommPointBus> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(RUploadCommPointBus::getStatisticalDate,begin,end).eq(RUploadCommPointBus::getStatisticalType,DicDataEnum.STATISTICAL_TYPE_D.getCode());
List<RUploadCommPointBus> rUploadCommPointBusList = this.list(lambdaQueryWrapper);
List<RUploadCommPointBus> poLIst = new ArrayList<>();
Map<String,List<RUploadCommPointBus>> map = rUploadCommPointBusList.stream().collect(Collectors.groupingBy(RUploadCommPointBus::getBusId));
map.forEach((busId,list)->{
RUploadCommPointBus one = list.get(0);
RUploadCommPointBus rUploadCommPointBus = new RUploadCommPointBus();
rUploadCommPointBus.setObjId(IdUtil.simpleUUID());
rUploadCommPointBus.setBusId(busId);
rUploadCommPointBus.setBusName(one.getBusName());
rUploadCommPointBus.setBusVoltageLevel(one.getBusVoltageLevel());
rUploadCommPointBus.setStatisticalType(DicDataEnum.STATISTICAL_TYPE_M.getCode());
rUploadCommPointBus.setStatisticalDate(month);
rUploadCommPointBus.setProvinceOrg(one.getProvinceOrg());
rUploadCommPointBus.setProvinceOrgName(one.getProvinceOrgName());
rUploadCommPointBus.setCityOrg(one.getCityOrg());
rUploadCommPointBus.setCityOrgName(one.getCityOrgName());
rUploadCommPointBus.setMaintOrg(one.getMaintOrg());
rUploadCommPointBus.setMaintOrgName(one.getMaintOrgName());
rUploadCommPointBus.setStationType("zf01");
rUploadCommPointBus.setStationId(one.getStationId());
rUploadCommPointBus.setStationName(one.getStationName());
rUploadCommPointBus.setStationVoltageLevel(one.getStationVoltageLevel());
rUploadCommPointBus.setDataSource("01");
List<String> temList = list.stream().map(RUploadCommPointBus::getMonitorId).collect(Collectors.toList());
String point = findMostFrequentString(temList);
rUploadCommPointBus.setMonitorId(point);
rUploadCommPointBus.setAvgVrms(list.stream().filter(item->Objects.nonNull(item.getAvgVrms())).mapToDouble(RUploadCommPointBus::getAvgVrms).average().orElse(0.0));
rUploadCommPointBus.setgVrms(list.stream().filter(item->Objects.nonNull(item.getgVrms())).mapToDouble(RUploadCommPointBus::getgVrms).average().orElse(0.0));
rUploadCommPointBus.setHarmVOvDuration(list.stream().filter(item->Objects.nonNull(item.getHarmVOvDuration())).mapToInt(RUploadCommPointBus::getHarmVOvDuration).sum());
rUploadCommPointBus.setHarmVOvDays(list.stream().filter(item->Objects.nonNull(item.getHarmVOvDays())).mapToInt(RUploadCommPointBus::getHarmVOvDays).sum());
rUploadCommPointBus.setVunbanOvDuration(list.stream().filter(item->Objects.nonNull(item.getVunbanOvDuration())).mapToInt(RUploadCommPointBus::getVunbanOvDuration).sum());
rUploadCommPointBus.setVunbanOvDays(list.stream().filter(item->Objects.nonNull(item.getVunbanOvDays())).mapToInt(RUploadCommPointBus::getVunbanOvDays).sum());
rUploadCommPointBus.setPltOvDuration(list.stream().filter(item->Objects.nonNull(item.getPltOvDuration())).mapToInt(RUploadCommPointBus::getPltOvDuration).sum());
rUploadCommPointBus.setPltOvDays(list.stream().filter(item->Objects.nonNull(item.getPltOvDays())).mapToInt(RUploadCommPointBus::getPltOvDays).sum());
rUploadCommPointBus.setOvDays(list.stream().filter(item->Objects.nonNull(item.getOvDays())).mapToInt(RUploadCommPointBus::getOvDays).sum());
rUploadCommPointBus.setUploadStatus(DataStateEnum.DELETED.getCode());
poLIst.add(rUploadCommPointBus);
});
if(CollUtil.isNotEmpty(poLIst)){
this.saveOrUpdateBatchByMultiId(poLIst);
}
}
public void handlerYear(String date){
DateTime begin = DateUtil.beginOfYear(DateUtil.parse(date, DatePattern.NORM_DATE_PATTERN));
DateTime end = DateUtil.parse(date, DatePattern.NORM_DATE_PATTERN);
String year = DateUtil.format(end,DatePattern.NORM_YEAR_PATTERN);
LambdaQueryWrapper<RUploadCommPointBus> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(RUploadCommPointBus::getStatisticalDate,begin,end).eq(RUploadCommPointBus::getStatisticalType,DicDataEnum.STATISTICAL_TYPE_D.getCode());
List<RUploadCommPointBus> rUploadCommPointBusList = this.list(lambdaQueryWrapper);
List<RUploadCommPointBus> poLIst = new ArrayList<>();
Map<String,List<RUploadCommPointBus>> map = rUploadCommPointBusList.stream().collect(Collectors.groupingBy(RUploadCommPointBus::getBusId));
map.forEach((busId,list)->{
RUploadCommPointBus one = list.get(0);
RUploadCommPointBus rUploadCommPointBus = new RUploadCommPointBus();
rUploadCommPointBus.setStatisticalType(DicDataEnum.STATISTICAL_TYPE_Y.getCode());
rUploadCommPointBus.setStatisticalDate(year);
rUploadCommPointBus.setObjId(IdUtil.simpleUUID());
rUploadCommPointBus.setBusId(busId);
rUploadCommPointBus.setBusName(one.getBusName());
rUploadCommPointBus.setBusVoltageLevel(one.getBusVoltageLevel());
rUploadCommPointBus.setProvinceOrg(one.getProvinceOrg());
rUploadCommPointBus.setProvinceOrgName(one.getProvinceOrgName());
rUploadCommPointBus.setCityOrg(one.getCityOrg());
rUploadCommPointBus.setCityOrgName(one.getCityOrgName());
rUploadCommPointBus.setMaintOrg(one.getMaintOrg());
rUploadCommPointBus.setMaintOrgName(one.getMaintOrgName());
rUploadCommPointBus.setStationType("zf01");
rUploadCommPointBus.setStationId(one.getStationId());
rUploadCommPointBus.setStationName(one.getStationName());
rUploadCommPointBus.setStationVoltageLevel(one.getStationVoltageLevel());
rUploadCommPointBus.setDataSource("01");
List<String> temList = list.stream().map(RUploadCommPointBus::getMonitorId).collect(Collectors.toList());
String point = findMostFrequentString(temList);
rUploadCommPointBus.setMonitorId(point);
rUploadCommPointBus.setAvgVrms(list.stream().filter(item->Objects.nonNull(item.getAvgVrms())).mapToDouble(RUploadCommPointBus::getAvgVrms).average().orElse(0.0));
rUploadCommPointBus.setgVrms(list.stream().filter(item->Objects.nonNull(item.getgVrms())).mapToDouble(RUploadCommPointBus::getgVrms).average().orElse(0.0));
rUploadCommPointBus.setHarmVOvDuration(list.stream().filter(item->Objects.nonNull(item.getHarmVOvDuration())).mapToInt(RUploadCommPointBus::getHarmVOvDuration).sum());
rUploadCommPointBus.setHarmVOvDays(list.stream().filter(item->Objects.nonNull(item.getHarmVOvDays())).mapToInt(RUploadCommPointBus::getHarmVOvDays).sum());
rUploadCommPointBus.setVunbanOvDuration(list.stream().filter(item->Objects.nonNull(item.getVunbanOvDuration())).mapToInt(RUploadCommPointBus::getVunbanOvDuration).sum());
rUploadCommPointBus.setVunbanOvDays(list.stream().filter(item->Objects.nonNull(item.getVunbanOvDays())).mapToInt(RUploadCommPointBus::getVunbanOvDays).sum());
rUploadCommPointBus.setPltOvDuration(list.stream().filter(item->Objects.nonNull(item.getPltOvDuration())).mapToInt(RUploadCommPointBus::getPltOvDuration).sum());
rUploadCommPointBus.setPltOvDays(list.stream().filter(item->Objects.nonNull(item.getPltOvDays())).mapToInt(RUploadCommPointBus::getPltOvDays).sum());
rUploadCommPointBus.setOvDays(list.stream().filter(item->Objects.nonNull(item.getOvDays())).mapToInt(RUploadCommPointBus::getOvDays).sum());
rUploadCommPointBus.setUploadStatus(DataStateEnum.DELETED.getCode());
poLIst.add(rUploadCommPointBus);
});
if(CollUtil.isNotEmpty(poLIst)){
this.saveOrUpdateBatchByMultiId(poLIst);
}
}
public String findMostFrequentString(List<String> strings) {
if (strings == null || strings.isEmpty()) {
throw new IllegalArgumentException("输入的列表不能为空");
}
// 使用HashMap来记录每个字符串及其出现次数
Map<String, Integer> frequencyMap = new HashMap<>();
for (String str : strings) {
frequencyMap.put(str, frequencyMap.getOrDefault(str, 0) + 1);
}
// 初始化最大出现次数和对应的字符串
int maxCount = 0;
String mostFrequent = strings.get(0); // 假设列表不为空,则取第一个字符串作为初始值
// 遍历HashMap找到出现次数最多的字符串
for (Map.Entry<String, Integer> entry : frequencyMap.entrySet()) {
if (entry.getValue() > maxCount) {
maxCount = entry.getValue();
mostFrequent = entry.getKey();
}
}
return mostFrequent;
}
/***
* 获取越限最大值
* @param object
@@ -306,13 +461,6 @@ public class RUploadCommPointBusServiceImpl extends MppServiceImpl<RUploadCommPo
return monitorRes;
}
public void handlerMonth(String date){
}
public void handlerYear(String date){
}
}

View File

@@ -124,13 +124,13 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
List<DeptGetChildrenMoreDTO> list = calculatedParam.getIdList();
list.forEach(item -> {
if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()), item.getDeptLevel())) {
if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()), item.getDeptLevel())
//县数据
|| Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()),item.getDeptLevel())
|| Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()), item.getDeptLevel())) {
return;
}
if(item.getUnitId().equals("13B9B47F1E4F3324E05338297A0A0595")){
System.out.println("555");
}
BusBarDto busBarDto = allDept.stream().filter(o -> Objects.equals(o.getOrgId(), item.getUnitId())).findFirst().orElse(null);

View File

@@ -25,22 +25,13 @@ public class UploadGwTaskSubstationRunner implements TimerTaskRunner {
@Override
public void action(String date) {
UploadParam param = new UploadParam();
/*param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
String code = uploadGwDataFeignClient.uploadSubstationStatisticalData(param).getCode();
if(code.equals("A0002")){
throw new BusinessException("失败");
}
*/
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_MONTH_PATTERN));
String codeM = uploadGwDataFeignClient.uploadSubstationStatisticalData(param).getCode();
if(codeM.equals("A0002")){
throw new BusinessException("失败");
}
uploadGwDataFeignClient.uploadSubstationStatisticalData(param);
//年
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_YEAR_PATTERN));
String code2 = uploadGwDataFeignClient.uploadSubstationStatisticalData(param).getCode();
if(code2.equals("A0002")){
throw new BusinessException("失败");
}
uploadGwDataFeignClient.uploadSubstationStatisticalData(param);
}
}