1.国网上送接口

This commit is contained in:
wr
2023-12-13 16:32:19 +08:00
parent a61fd925dd
commit e49998797d
15 changed files with 1184 additions and 8 deletions

View File

@@ -4,7 +4,10 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/** /**
* pms-device * pms-device
@@ -224,10 +227,16 @@ public class MonitorParam {
@ApiModelProperty(value = "是否专项分析监测点") @ApiModelProperty(value = "是否专项分析监测点")
private Integer isSpecialMonitor; private Integer isSpecialMonitor;
@Data
public static class Info implements Serializable {
@ApiModelProperty(name = "monitorTag",value = "监测点对象标签")
@NotNull(message = "监测点对象标签不可为空")
private String monitorTag;
@ApiModelProperty(name = "ids",value = "id集合")
@NotEmpty(message = "id集合不能为空")
private List<String> ids;
}

View File

@@ -206,4 +206,17 @@ public class Monitor extends BaseEntity {
*/ */
private String ptPhaseType; private String ptPhaseType;
/**
* 是否发电用户0-否1-是;
*/
private Integer ifPowerUser;
/**
* 场站属性
*/
private String fieldStation;
/**
* 0.以上送 1.未上送 2.取消上送 3.待重新上送
*/
private Integer isUploadHead;
} }

View File

@@ -9,7 +9,7 @@ import java.time.LocalDate;
/** /**
* <p> * <p>
* 电用户 * 电用户
* </p> * </p>
* *
* @author hongawen * @author hongawen

View File

@@ -117,7 +117,13 @@ public class TractionStation extends BaseEntity {
*/ */
private Integer status; private Integer status;
/**
* 监测点状态(字典)
*/
private String monitorState;
/**
* 0.以上送 1.未上送 2.取消上送 3.待重新上送
*/
private Integer isUploadHead;
} }

View File

@@ -38,9 +38,9 @@ public class OverviewVO implements Serializable {
private String ytbSumNum; private String ytbSumNum;
@ApiModelProperty(name = "yhbSumNum", value = "环比监测点数量") @ApiModelProperty(name = "yhbSumNum", value = "环比监测点数量")
private String yhbSumNum; private String yhbSumNum;
@ApiModelProperty(name = "sumNum", value = "同比监测点占比") @ApiModelProperty(name = "sameNum", value = "同比监测点占比")
private String sameNum; private String sameNum;
@ApiModelProperty(name = "sumNum", value = "环比监测点占比") @ApiModelProperty(name = "ringNum", value = "环比监测点占比")
private String ringNum; private String ringNum;
@ApiModelProperty(name = "setRate", value = "设置率") @ApiModelProperty(name = "setRate", value = "设置率")
private String setRate="20.3"; private String setRate="20.3";

View File

@@ -0,0 +1,66 @@
package com.njcn.device.pms.pojo.vo.gw;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author wr
* @description
* @date 2023/12/12 9:03
*/
@Data
public class PhotovoltaicDto extends Unit{
private static final long serialVersionUID = 1L;
/** 主键 是否必填: 是 */
private String id;
/** 新能源场站名称 是否必填: 是 */
private String stationName;
/** 总装机容量 是否必填: 否 */
private BigDecimal ratedCapacity;
/** 装置额定容量 是否必填: 否 */
private BigDecimal deviceCapacity;
/** 治理装置类型 是否必填: 否 */
private String deviceType;
/** 装置电压等级编码 是否必填: 否 */
private String deviceVoltageLevel;
/** 并网电压等级 是否必填: 否 */
private String gcVoltageLevel;
/** 是否现场测试 是否必填: 否 */
private String isSceneTest;
/** 是否专线供电 是否必填: 否 */
private String isSpecial;
/** 监测点编号 是否必填: 否 */
private String monitorId;
/** 新能源场站属性 是否必填: 是 */
private String monitorObjectType;
/** 新能源场站协议容量 是否必填: 是 */
private Float stationCapacity;
/** 新能源场站id 是否必填: 是 */
private String stationId;
/** 关联变电站的主键 是否必填: */
private String substationId;
/** 发电客户标识 是否必填: 否 */
private String fcId;
/** 发电用户编号 是否必填: 否 */
private String fcNo;
/** 站房类型 是否必填: 否 */
private String stationType;
/** 关联变电站名称 是否必填: */
private String substationName;
/** 关联变电站电压等级 是否必填: */
private String substationVoltageLevel;
/** 逆变器组网方式 是否必填: 否 */
private String inverterNetWorkWay;
/** 运行状态 是否必填: 是 */
private String runStatus;
/** 创建时间 是否必填: */
private LocalDateTime createTime;
/** 更新时间 是否必填: */
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,120 @@
package com.njcn.device.pms.pojo.vo.gw;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @author wr
* @description
* @date 2023/12/7 14:29
*/
@Data
public class SensitiveUserDto extends Unit{
private static final long serialVersionUID = 1L;
/*主键 是否必填:是*/
private String id;
/*省id 是否必填:是*/
private String provinceId;
/*省名称 是否必填:否*/
private String provinceName;
/*所属地市id 是否必填:是*/
private String cityId;
/*所属地市名称 是否必填:否*/
private String cityName;
/*所属区县id 是否必填:否*/
private String countyId;
/*所属区县名称 是否必填:否*/
private String countyName;
/*运维班组标识 是否必填:否*/
private String maintGroupId;
/*运维班组名称 是否必填:否*/
private String maintGroupName;
/*重要、敏感用户名称 是否必填:是*/
private String sensitiveUserName;
/*合同容量 是否必填:是*/
private Float userProtocolCapacity;
/*监测点编号 是否必填:否*/
private String monitorId;
/*用户标识 是否必填:否*/
private String consNo;
/*通讯地址 是否必填:否*/
private String meterAddress;
/*用户类型 是否必填:否*/
private String consSort;
/*用电类别 是否必填:否*/
private String elecTypeCode;
/*行业分类 是否必填:否*/
private String tradeCode;
/*用户电压等级 是否必填:是*/
private String consVoltageLevel;
/*变电站ID 是否必填:是*/
private String stationId;
/*变电站名称 是否必填:是*/
private String stationName;
/*变电站电压等级 是否必填:否*/
private String stationVoltageLevel;
/*馈线资源ID 是否必填:否*/
private String feederId;
/*馈线名称 是否必填:否*/
private String feederName;
/*是否专线用户 是否必填:否*/
private String pubPrivFlag;
/*变压器ID 是否必填:否*/
private String transId;
/*变压器名称 是否必填:否*/
private String transName;
/*变压器类型 是否必填:否*/
private String transType;
/*变压器性质 是否必填:否*/
private String transNature;
/*变压器所属运维单位 是否必填:否*/
private String maintOrg;
/*客户重要性等级 是否必填:否*/
private String custImportance;
/*重要客户类别 是否必填:否*/
private String highRkType;
/*是否光伏用户 是否必填:否*/
private String fcGcFlag;
/*发电方式 是否必填:否*/
private String gcTypeCode;
/*电能质量问题描述 是否必填:否*/
private String problemDesc;
/*最后发生日期 是否必填:否*/
private Date ocDate;
/*是否已实现在线监测 是否必填:否*/
private String isMonitoringOnline;
/*是否有电能质量治理装置 是否必填:否*/
private String haveDevice;
/*治理装置类型 是否必填:否*/
private String deviceType;
/*装置电压等级 是否必填:否*/
private String deviceVoltageLevel;
/*装置额定容量 是否必填:否*/
private BigDecimal deviceCapacity;
/*投诉日期 是否必填:否*/
private Date complaintDate;
/*投诉内容 是否必填:否*/
private String complaintContent;
/*整改措施 是否必填:否*/
private String modifyMethods;
/*是否发生投诉 是否必填:否*/
private String haveComplaint;
/*是否发生质量问题 是否必填:否*/
private String havePowerQualityProblem;
/*站房类型 是否必填:否*/
private String stationType;
/*运行状态 是否必填:是*/
private String runStatus;
/*创建时间 是否必填:*/
private LocalDateTime createTime;
/*更新时间 是否必填:*/
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,88 @@
package com.njcn.device.pms.pojo.vo.gw;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author wr
* @description
* @date 2023/12/8 9:17
*/
@Data
public class TractionStationDTO extends Unit{
private static final long serialVersionUID = 1L;
/*主键 是否必填:是*/
private String id;
/*副备变电站id 是否必填:否*/
private String auxiliarySubstationId;
/*副备变电站名称 是否必填:否*/
private String auxiliarySubstationName;
/*副备变电站电压等级 是否必填:否*/
private String auxiliaryVoltageLevel;
/*电缆芯数 是否必填:否*/
private String cableCoresNum;
/*电缆敷设方式 是否必填:否*/
private String cableLayingMethod;
/*电缆型号 是否必填:否*/
private String cableModel;
/*电缆线路长度 是否必填:否*/
private BigDecimal cableRouteLength;
/*牵引站变压器接线方式 是否必填:否*/
private String connetGroupWay;
/*创建时间 是否必填:否*/
private LocalDateTime createTime;
/*是否专线供电 是否必填:否*/
private String ifSpecial;
/*主备变电站id 是否必填:否*/
private String mainSubstationId;
/*主备变电站名称 是否必填:否*/
private String mainSubstationName;
/*主备变电站电压等级 是否必填:否*/
private String mainVolatageLevel;
/*监测点编号 是否必填:否*/
private String monitorNumber;
/*第二个监测点编号 是否必填:否*/
private String monitorNumberTwo;
/*铁路id 是否必填:否*/
private String railwayId;
/*铁路名称 是否必填:是*/
private String railwayName;
/*铁路编号 是否必填:否*/
private String railwayNumber;
/*铁路类型 是否必填:否*/
private String railwayType;
/*牵引站编号 是否必填:否*/
private String tractionCode;
/*牵引站变压器容量 是否必填:否*/
private Float tractionSubstationCapacity;
/*所属变电站id 是否必填:否*/
private String tractionSubstationId;
/*所属变电站名称 是否必填:否*/
private String tractionSubstationName;
/*供电电压等级 是否必填:是*/
private String tractionVoltageLevel;
/*变压器联结组方式 是否必填:否*/
private String transformerConnectionGroupMethod;
/*变压器额定容量 是否必填:否*/
private BigDecimal transformerNameplateCapacity;
/*变压器一次侧额定电压等级 是否必填:否*/
private String transformerOneVoltageLevel;
/*变压器二次侧额定电压等级 是否必填:否*/
private String transformerTwoVoltageLevel;
/*三相vv额定容量 是否必填:否*/
private BigDecimal triphaseVvNameplateCapacity;
/*上报日期 是否必填:否*/
private LocalDateTime uploadDate;
/*运行状态 是否必填:是*/
private String runStatus;
/*更新时间 是否必填:否*/
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,24 @@
package com.njcn.device.pms.pojo.vo.gw;
import lombok.Data;
/**
* @author wr
* @description
* @date 2023/12/12 16:23
*/
@Data
public class Unit {
/** 省id 是否必填: 是 */
private String provinceId;
/** 省名称 是否必填: 否 */
private String provinceName;
/** 所属地市id 是否必填: 是 */
private String cityId;
/** 所属地市名称 是否必填: 否 */
private String cityName;
/** 所属区县id 是否必填: 否 */
private String countyId;
/** 所属区县名称 是否必填: 否 */
private String countyName;
}

View File

@@ -0,0 +1,100 @@
package com.njcn.device.pms.pojo.vo.gw;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author wr
* @description
* @date 2023/12/7 8:52
*/
@Data
public class WindSourceDto extends Unit{
private static final long serialVersionUID = 1L;
private String id;
@ApiModelProperty(name = "stationName", value = "新能源场站名称")
private String stationName;
@ApiModelProperty(name = "ratedCapacity", value = "总装机容量")
private BigDecimal ratedCapacity;
@ApiModelProperty(name = "deviceCapacity", value = "装置额定容量")
private Float deviceCapacity;
@ApiModelProperty(name = "deviceType", value = "治理装置类型")
private String deviceType;
@ApiModelProperty(name = "deviceVoltageLevel", value = "装置电压等级编码")
private String deviceVoltageLevel;
@ApiModelProperty(name = "gcVoltageLevel", value = "并网电压等级")
private String gcVoltageLevel;
@ApiModelProperty(name = "isSceneTest", value = "是否现场测试")
private String isSceneTest;
@ApiModelProperty(name = "isSpecial", value = "是否专线供电")
private String isSpecial;
@ApiModelProperty(name = "monitorId", value = "监测点编号")
private String monitorId;
@ApiModelProperty(name = "monitorObjectType", value = "新能源场站属性")
private String monitorObjectType;
@ApiModelProperty(name = "stationCapacity", value = "新能源场站协议容量")
private Float stationCapacity;
@ApiModelProperty(name = "stationId", value = "新能源场站id")
private String stationId;
@ApiModelProperty(name = "substationId", value = "关联变电站的主键")
private String substationId;
@ApiModelProperty(name = "fcId", value = "发电客户标识")
private String fcId;
@ApiModelProperty(name = "fcNo", value = "发电用户编号")
private String fcNo;
@ApiModelProperty(name = "stationType", value = "站房类型")
private String stationType;
@ApiModelProperty(name = "substationName", value = "关联变电站名称")
private String substationName;
@ApiModelProperty(name = "substationVoltageLevel", value = "关联变电站电压等级")
private String substationVoltageLevel;
@ApiModelProperty(name = "singleRatedCapacity", value = "单机容量")
private Float singleRatedCapacity;
@ApiModelProperty(name = "windNum", value = "风机台数")
private Integer windNum;
@ApiModelProperty(name = "windStationType", value = "风电场类型")
private String windStationType;
@ApiModelProperty(name = "windType", value = "风机类型编码")
private String windType;
@ApiModelProperty(name = "runStatus", value = "运行状态")
private String runStatus;
@ApiModelProperty(name = "createTime", value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(name = "updateTime", value = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,84 @@
package com.njcn.device.pms.controller.gwPush;
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.param.MonitorParam;
import com.njcn.device.pms.service.gwPush.MonitorSendService;
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 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.util.List;
/**
*
*/
@RestController
@RequestMapping("/deviceSend")
@Api(tags = "台账类国网上送")
@RequiredArgsConstructor
public class DeviceSendController extends BaseController {
private final MonitorSendService monitorSendService;
@PostMapping("/sendType")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("国网上送接口")
@ApiImplicitParam(name = "param",value = "请求体",required = true)
public HttpResult<String> windSend(@RequestBody @Validated MonitorParam.Info param){
String methodDescribe = getMethodDescribe("sendType");
String s = monitorSendService.sendType(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
}
// @PostMapping("/windSend")
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @ApiOperation("上送电能质量风电场台账数据接口")
// @ApiImplicitParam(name = "ids",value = "请求体",required = true)
// public HttpResult<String> windSend(@RequestBody List<String> ids){
// String methodDescribe = getMethodDescribe("windSend");
// String s = deviceSendService.windSend(ids);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
// }
//
// @PostMapping("/photovoltaicSend")
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @ApiOperation("上送电能质量光伏电站台账数据接口")
// @ApiImplicitParam(name = "ids",value = "请求体",required = true)
// public HttpResult<String> photovoltaicSend(@RequestBody List<String> ids){
// String methodDescribe = getMethodDescribe("photovoltaicSend");
// String s = deviceSendService.photovoltaicSend(ids);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
// }
//
// @PostMapping("/sensitiveUserSend")
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @ApiOperation("上送电能质量重要、敏感用户台账数据接口")
// @ApiImplicitParam(name = "ids",value = "请求体",required = true)
// public HttpResult<String> sensitiveUserSend(@RequestBody List<String> ids){
// String methodDescribe = getMethodDescribe("sensitiveUserSend");
// String s = deviceSendService.sensitiveUserSend(ids);
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
// }
@PostMapping("/tractionStationSend")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("上送电能质量牵引站台账数据接口")
@ApiImplicitParam(name = "ids",value = "请求体",required = true)
public HttpResult<String> tractionStationSend(@RequestBody List<String> ids){
String methodDescribe = getMethodDescribe("tractionStationSend");
String s = monitorSendService.tractionStationSend(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
}
}

View File

@@ -0,0 +1,56 @@
package com.njcn.device.pms.service.gwPush;
import com.njcn.device.pms.pojo.param.MonitorParam;
import java.util.List;
/**
* 国网台账类上送
*/
public interface MonitorSendService {
/**
* 监测点上送信息
* @param param
* @return
*/
String sendType(MonitorParam.Info param);
/**
* @Description: 电能质量风电场台账数据接口
* @param ids
* @return: java.lang.String
* @Author: wr
* @Date: 2023/12/7 9:00
*/
String windSend(List<String> ids);
/**
* @Description: 电能质量光伏电站台账数据接口
* @param ids
* @return: java.lang.String
* @Author: wr
* @Date: 2023/12/7 14:18
*/
String photovoltaicSend(List<String> ids);
/**
* @Description: 电能质量重要、敏感用户台账数据接口
* @param ids
* @return: java.lang.String
* @Author: wr
* @Date: 2023/12/7 14:18
*/
String sensitiveUserSend(List<String> ids);
/**
* @Description: 电能质量牵引站台账数据接口
* @param ids
* @return: java.lang.String
* @Author: wr
* @Date: 2023/12/7 14:18
*/
String tractionStationSend(List<String> ids);
}

View File

@@ -0,0 +1,598 @@
package com.njcn.device.pms.service.gwPush.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
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.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.pojo.param.MonitorParam;
import com.njcn.device.pms.pojo.po.*;
import com.njcn.device.pms.pojo.vo.gw.*;
import com.njcn.device.pms.service.gwPush.MonitorSendService;
import com.njcn.device.pms.service.majornetwork.*;
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.vo.PvTerminalTreeVO;
import com.njcn.web.enums.GWSendEnum;
import com.njcn.web.pojo.param.SendParam;
import com.njcn.web.utils.GwSendUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author wr
* @description 国网台账类上送
* @date 2023/12/7 8:57
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class MonitorSendServiceImpl implements MonitorSendService {
private final IMonitorService monitorService;
private final DeptFeignClient deptFeignClient;
private final IPowerClientService powerClientService;
private final DicDataFeignClient dicDataFeignClient;
private final IPowerGenerationUserService iPowerGenerationUserService;
private final ITractionStationService tractionStationService;
@Override
public String sendType(MonitorParam.Info param) {
DictData data = dicDataFeignClient.getDicDataById(param.getMonitorTag()).getData();
DicDataEnum enumValue = DicDataEnum.getDicDataEnumValue(data.getCode());
String msg;
switch (enumValue){
case WIND_FARM:
msg=this.windSend(param.getIds());
break;
case POWER_STATION:
msg= this.photovoltaicSend(param.getIds());
break;
case SENSITIVE_USERS:
msg= this.sensitiveUserSend(param.getIds());
break;
default:
throw new BusinessException("请选择国网上送的监测点对象标签上送!");
}
return msg;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String windSend(List<String> ids) {
//获取监测点信息
List<Monitor> monitorList = monitorService.list(new LambdaQueryWrapper<Monitor>()
.in(Monitor::getId, ids)
);
if (CollUtil.isEmpty(monitorList)) {
return "为查询数据,请查询数据是否存在!";
}
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
//治理装置类型
List<DictData> deviceType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData();
Map<String, DictData> mapDeviceType = deviceType.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//电压等级
List<DictData> voltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> mapVoltage = voltage.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//运行状态
List<DictData> lineState = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
Map<String, DictData> mapLineState = lineState.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<WindSourceDto> info = new ArrayList<>();
WindSourceDto sendVO;
for (Monitor monitor : monitorList) {
sendVO = new WindSourceDto();
//添加部门信息
BeanUtil.copyProperties(setOrgProvince(mapCode, mapList, monitor.getOrgId()), sendVO);
sendVO.setStationName(monitor.getName());
//电站等级
if (mapVoltage.containsKey(monitor.getVoltageLevel())) {
sendVO.setGcVoltageLevel(String.format("%02d", mapVoltage.get(monitor.getVoltageLevel()).getAlgoDescribe()));
sendVO.setSubstationVoltageLevel(String.format("%02d", mapVoltage.get(monitor.getVoltageLevel()).getAlgoDescribe()));
}
sendVO.setId(monitor.getId());
sendVO.setIsSpecial(monitor.getIsSpecialSupplyElectricity().toString());
sendVO.setMonitorId(monitor.getId());
sendVO.setStationCapacity(monitor.getUserAgreementCapacity());
sendVO.setStationId(monitor.getId());
sendVO.setSubstationId(monitor.getPowerrId());
sendVO.setSubstationName(monitor.getPowerrName());
sendVO.setFcId(monitor.getMonitorObjectId());
sendVO.setFcNo(monitor.getMonitorObjectId());
sendVO.setMonitorObjectType(monitor.getFieldStation());
//运行状态
if (mapLineState.containsKey(monitor.getMonitorState())) {
sendVO.setRunStatus(mapLineState.get(monitor.getMonitorState()).getValue());
}
sendVO.setCreateTime(monitor.getCreateTime());
sendVO.setUpdateTime(monitor.getUpdateTime());
// sendVO.setRatedCapacity();
// sendVO.setDeviceCapacity();
// sendVO.setDeviceType();
// sendVO.setDeviceVoltageLevel();
// sendVO.setIsSceneTest();
// sendVO.setStationType();
// sendVO.setSingleRatedCapacity();
// sendVO.setWindNum();
// sendVO.setWindStationType();
// sendVO.setWindType();
//
info.add(sendVO);
}
if (info.size() > 100) {
throw new BusinessException("一次最多上送100条数据");
}
SendParam param = new SendParam();
param.setStats(info);
Map<String, String> send = GwSendUtil.send(param, GWSendEnum.WIND_CREATE);
List<String> trIds = info.stream().map(WindSourceDto::getId).distinct().collect(Collectors.toList());
return returnInformation(1, trIds, send);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String photovoltaicSend(List<String> ids) {
//获取监测点信息
List<Monitor> monitorList = monitorService.list(new LambdaQueryWrapper<Monitor>()
.in(Monitor::getId, ids)
);
if (CollUtil.isEmpty(monitorList)) {
return "为查询数据,请查询数据是否存在!";
}
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
//治理装置类型
List<DictData> deviceType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData();
Map<String, DictData> mapDeviceType = deviceType.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//电压等级
List<DictData> voltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> mapVoltage = voltage.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//运行状态
List<DictData> lineState = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
Map<String, DictData> mapLineState = lineState.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<PhotovoltaicDto> info = new ArrayList<>();
PhotovoltaicDto sendVO;
for (Monitor monitor : monitorList) {
sendVO = new PhotovoltaicDto();
//添加部门信息
BeanUtil.copyProperties(setOrgProvince(mapCode, mapList, monitor.getOrgId()), sendVO);
sendVO.setStationName(monitor.getName());
//电站等级
if (mapVoltage.containsKey(monitor.getVoltageLevel())) {
sendVO.setGcVoltageLevel(String.format("%02d", mapVoltage.get(monitor.getVoltageLevel()).getAlgoDescribe()));
sendVO.setSubstationVoltageLevel(String.format("%02d", mapVoltage.get(monitor.getVoltageLevel()).getAlgoDescribe()));
}
sendVO.setId(monitor.getId());
sendVO.setIsSpecial(monitor.getIsSpecialSupplyElectricity().toString());
sendVO.setMonitorId(monitor.getId());
sendVO.setStationCapacity(monitor.getUserAgreementCapacity());
sendVO.setStationId(monitor.getId());
sendVO.setSubstationId(monitor.getPowerrId());
sendVO.setSubstationName(monitor.getPowerrName());
sendVO.setFcId(monitor.getMonitorObjectId());
sendVO.setFcNo(monitor.getMonitorObjectId());
sendVO.setMonitorObjectType(monitor.getFieldStation());
//运行状态
if (mapLineState.containsKey(monitor.getMonitorState())) {
sendVO.setRunStatus(mapLineState.get(monitor.getMonitorState()).getValue());
}
sendVO.setCreateTime(monitor.getCreateTime());
sendVO.setUpdateTime(monitor.getUpdateTime());
// sendVO.setRatedCapacity();
// sendVO.setDeviceCapacity();
// sendVO.setDeviceType();
// sendVO.setDeviceVoltageLevel();
// sendVO.setIsSceneTest();
// sendVO.setStationType();
// sendVO.setInverterNetWorkWay();
info.add(sendVO);
}
if (info.size() > 100) {
throw new BusinessException("一次最多上送100条数据");
}
SendParam param = new SendParam();
param.setStats(info);
Map<String, String> send = GwSendUtil.send(param, GWSendEnum.PHOTOVOLTAIC_CREATE);
List<String> trIds = info.stream().map(PhotovoltaicDto::getId).distinct().collect(Collectors.toList());
return returnInformation(1, trIds, send);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String sensitiveUserSend(List<String> ids) {
List<Monitor> monitorList = monitorService.list(new LambdaQueryWrapper<Monitor>()
.in(Monitor::getId, ids)
);
//根据用户类型进行分组
Map<Integer, List<String>> userMonitor = monitorList.stream().filter(x -> ObjectUtil.isNotNull(x.getIfPowerUser()))
.collect(Collectors.groupingBy(Monitor::getIfPowerUser,
Collectors.mapping(Monitor::getMonitorObjectId, Collectors.toList())));
//获取用电用户
List<PowerClient> powerClients = new ArrayList<>();
if (userMonitor.containsKey(0)) {
powerClients = powerClientService.list(new LambdaQueryWrapper<PowerClient>()
.in(PowerClient::getId, userMonitor.get(0)));
}
//获取发电用户
List<PowerGenerationUser> powerGenerationUsers =new ArrayList<>();
if(userMonitor.containsKey(1)){
powerGenerationUsers = iPowerGenerationUserService.list(new LambdaQueryWrapper<PowerGenerationUser>()
.in(PowerGenerationUser::getId, userMonitor.get(1)));
}
if (CollUtil.isEmpty(monitorList)) {
return "为查询数据,请查询数据是否存在!";
}
//用户分类
List<DictData> userClass = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.USER_CLASS.getCode()).getData();
Map<String, DictData> mapUserClass = userClass.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//电压等级
List<DictData> voltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> mapVoltage = voltage.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//电压等级
List<DictData> eleClass = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.ELE_CLASS.getCode()).getData();
Map<String, DictData> mapEleClass = eleClass.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//行业分类
List<DictData> industryType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.INDUSTRY_TYPE.getCode()).getData();
Map<String, DictData> mapIndustryType = industryType.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//重要性等级
List<DictData> importanceLevel = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.IMPORTANCE_LEVEL.getCode()).getData();
Map<String, DictData> mapImportanceLevel = importanceLevel.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//运行状态
List<DictData> lineState = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
Map<String, DictData> mapLineState = lineState.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
List<SensitiveUserDto> info = new ArrayList<>();
SensitiveUserDto sendVO;
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
for (Monitor monitor : monitorList) {
sendVO = new SensitiveUserDto();
PvTerminalTreeVO pvTerminalTreeVO;
//添加部门信息
BeanUtil.copyProperties(setOrgProvince(mapCode, mapList, monitor.getOrgId()), sendVO);
sendVO.setId(monitor.getId());
if (mapList.containsKey(monitor.getOperationId())) {
pvTerminalTreeVO = mapList.get(monitor.getOperationId());
sendVO.setMaintGroupName(pvTerminalTreeVO.getName());
sendVO.setMaintGroupId(pvTerminalTreeVO.getCode());
}
sendVO.setSensitiveUserName(monitor.getName());
sendVO.setUserProtocolCapacity(monitor.getUserAgreementCapacity());
sendVO.setMonitorId(monitor.getId());
sendVO.setStationId(monitor.getPowerrId());
sendVO.setStationName(monitor.getPowerrName());
sendVO.setPubPrivFlag(monitor.getIsSpecialMonitor()+"");
//运行状态
if (mapLineState.containsKey(monitor.getMonitorState())) {
sendVO.setRunStatus(mapLineState.get(monitor.getMonitorState()).getValue());
}
sendVO.setCreateTime(monitor.getCreateTime());
sendVO.setUpdateTime(monitor.getUpdateTime());
if (mapVoltage.containsKey(monitor.getVoltageLevel())) {
sendVO.setStationVoltageLevel(String.format("%02d", mapVoltage.get(monitor.getVoltageLevel()).getAlgoDescribe()));
}
if (ObjectUtil.isNotNull(monitor.getIfPowerUser())) {
setSensitiveUser(powerClients,powerGenerationUsers,mapVoltage, mapUserClass, mapEleClass, mapIndustryType, mapImportanceLevel, sendVO, monitor);
}
// sendVO.setMeterAddress();
// sendVO.setTradeCode();
// sendVO.setConsVoltageLevel();
//
// sendVO.setFeederId();
// sendVO.setFeederName();
// sendVO.setTransId();
// sendVO.setTransName();
// sendVO.setTransType();
// sendVO.setTransNature();
// sendVO.setMaintOrg();
// sendVO.setHighRkType();
// sendVO.setFcGcFlag();
// sendVO.setGcTypeCode();
// sendVO.setProblemDesc();
// sendVO.setOcDate();
// sendVO.setIsMonitoringOnline();
// sendVO.setHaveDevice();
// sendVO.setDeviceType();
// sendVO.setDeviceVoltageLevel();
// sendVO.setDeviceCapacity();
// sendVO.setComplaintDate();
// sendVO.setComplaintContent();
// sendVO.setModifyMethods();
// sendVO.setHaveComplaint();
// sendVO.setHavePowerQualityProblem();
// sendVO.setStationType();
info.add(sendVO);
}
if (info.size() > 100) {
throw new BusinessException("一次最多上送100条数据");
}
SendParam param = new SendParam();
param.setStats(info);
Map<String, String> send = GwSendUtil.send(param, GWSendEnum.SENSITIVE_USER_CREATE);
List<String> trIds = info.stream().map(SensitiveUserDto::getId).distinct().collect(Collectors.toList());
return returnInformation(1, trIds, send);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String tractionStationSend(List<String> ids) {
//获取牵引站信息
List<TractionStation> tractionStationList = tractionStationService.list(new LambdaQueryWrapper<TractionStation>()
.in(TractionStation::getId, ids)
);
if (CollUtil.isEmpty(tractionStationList)) {
return "为查询数据,请查询数据是否存在!";
}
List<TractionStationDTO> info = new ArrayList<>();
TractionStationDTO sendVO;
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
//牵引站变压器接线方式
List<DictData> connetGroupWay = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.CONNET_GROUP_WAY.getCode()).getData();
Map<String, DictData> mapConnetGroupWay = connetGroupWay.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
//电压等级
List<DictData> voltage = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> mapVoltage = voltage.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
for (TractionStation traction : tractionStationList) {
sendVO = new TractionStationDTO();
DictData dictData;
//添加部门信息
BeanUtil.copyProperties(setOrgProvince(mapCode, mapList, traction.getOrgId()), sendVO);
//牵引站变压器接线方式
if (mapConnetGroupWay.containsKey(traction.getConnetGroupWay())) {
dictData = mapConnetGroupWay.get(traction.getConnetGroupWay());
sendVO.setConnetGroupWay(dictData.getValue());
}
sendVO.setCreateTime(traction.getCreateTime());
sendVO.setIfSpecial(traction.getIfSpecial() + "");
sendVO.setRailwayId(traction.getRailwayLineId());
sendVO.setRailwayNumber(traction.getRailwayLineId());
sendVO.setRailwayName(traction.getName());
sendVO.setTractionCode(traction.getId());
sendVO.setTractionSubstationCapacity(traction.getRatedCapacity());
sendVO.setTractionSubstationId(traction.getPowerId());
sendVO.setTractionSubstationName(traction.getPowerName());
//电压等级
if (mapVoltage.containsKey(traction.getVoltageLevel())) {
sendVO.setTractionVoltageLevel(String.format("%02d", mapVoltage.get(traction.getVoltageLevel()).getAlgoDescribe()));
}
sendVO.setUpdateTime(traction.getUpdateTime());
sendVO.setId(traction.getId());
// sendVO.setAuxiliarySubstationId();
// sendVO.setAuxiliarySubstationName();
// sendVO.setAuxiliaryVoltageLevel();
// sendVO.setCableCoresNum();
// sendVO.setCableLayingMethod();
// sendVO.setCableModel();
// sendVO.setCableRouteLength();
// sendVO.setMainSubstationId();
// sendVO.setMainSubstationName();
// sendVO.setMainVolatageLevel();
// sendVO.setMonitorNumber();
// sendVO.setMonitorNumberTwo();
// sendVO.setRailwayType();
// sendVO.setTransformerConnectionGroupMethod();
// sendVO.setTransformerNameplateCapacity();
// sendVO.setTransformerOneVoltageLevel();
// sendVO.setTransformerTwoVoltageLevel();
// sendVO.setTriphaseVvNameplateCapacity();
// sendVO.setUploadDate();
// sendVO.setRunStatus();
info.add(sendVO);
}
if (info.size() > 100) {
throw new BusinessException("一次最多上送100条数据");
}
SendParam param = new SendParam();
param.setStats(info);
Map<String, String> send = GwSendUtil.send(param, GWSendEnum.TRACTION_STATION);
List<String> trIds = info.stream().map(TractionStationDTO::getId).distinct().collect(Collectors.toList());
return returnInformation(2, trIds, send);
}
/**
* 省市县,对象添加
*
* @param mapCode
* @param mapList
* @param orgId
* @return
*/
private Unit setOrgProvince(Map<String, PvTerminalTreeVO> mapCode, Map<String, PvTerminalTreeVO> mapList, String orgId) {
Unit unit = new Unit();
if (mapCode.containsKey(orgId)) {
PvTerminalTreeVO pvTerminalTreeVO = mapCode.get(orgId);
String[] split = (pvTerminalTreeVO.getPids() + StrUtil.COMMA + pvTerminalTreeVO.getId())
.split(StrUtil.COMMA);
for (int i = 2; i < split.length; i++) {
if (i == 2) {
if (mapList.containsKey(split[i])) {
pvTerminalTreeVO = mapList.get(split[i]);
unit.setProvinceName(pvTerminalTreeVO.getName());
unit.setProvinceId(pvTerminalTreeVO.getCode());
}
}
if (i == 3) {
if (mapList.containsKey(split[i])) {
pvTerminalTreeVO = mapList.get(split[i]);
unit.setCityName(pvTerminalTreeVO.getName());
unit.setCityId(pvTerminalTreeVO.getCode());
}
}
if (i == 4) {
if (mapList.containsKey(split[i])) {
pvTerminalTreeVO = mapList.get(split[i]);
unit.setCountyName(pvTerminalTreeVO.getName());
unit.setCountyId(pvTerminalTreeVO.getCode());
}
}
}
}
return unit;
}
/**
* 重要敏感用户对象属性添加
*
* @param powerClients 发电用户
* @param mapUserClass
* @param mapEleClass
* @param mapIndustryType
* @param mapImportanceLevel
* @param mapImportanceLevel
* @param sendVO
* @param monitor
*/
private void setSensitiveUser(List<PowerClient> powerClients,List<PowerGenerationUser> powerGenerationUsers, Map<String, DictData> mapVoltage, Map<String, DictData> mapUserClass, Map<String, DictData> mapEleClass, Map<String, DictData> mapIndustryType, Map<String, DictData> mapImportanceLevel, SensitiveUserDto sendVO, Monitor monitor) {
DictData dictData;
if (1 == monitor.getIfPowerUser()) {
List<PowerClient> powerClientList = powerClients.stream()
.filter(x -> x.getId().equals(monitor.getMonitorObjectId()))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(powerClientList)) {
PowerClient powerClient = powerClientList.get(0);
//用户类型
if (mapUserClass.containsKey(powerClient.getUserType())) {
dictData = mapUserClass.get(powerClient.getUserType());
sendVO.setConsNo(dictData.getId());
sendVO.setConsSort(dictData.getValue());
}
//用电类别
if (mapEleClass.containsKey(powerClient.getElectricityType())) {
dictData = mapEleClass.get(powerClient.getElectricityType());
sendVO.setElecTypeCode(dictData.getValue());
}
//行业分类
if (mapIndustryType.containsKey(powerClient.getIndustryType())) {
dictData = mapIndustryType.get(powerClient.getIndustryType());
sendVO.setTradeCode(dictData.getValue());
}
//重要性等级
if (mapImportanceLevel.containsKey(powerClient.getImportanceLevel())) {
dictData = mapImportanceLevel.get(powerClient.getImportanceLevel());
sendVO.setCustImportance(dictData.getValue());
}
//用户电压等级
if (mapVoltage.containsKey(powerClient.getVoltageLevel())) {
dictData = mapVoltage.get(powerClient.getVoltageLevel());
sendVO.setConsVoltageLevel(dictData.getValue());
}
}
}else{
List<PowerGenerationUser> powerGenerationUserList = powerGenerationUsers.stream()
.filter(x -> x.getId().equals(monitor.getMonitorObjectId()))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(powerGenerationUserList)) {
PowerGenerationUser powerGenerationUser = powerGenerationUserList.get(0);
//用户电压等级
if (mapVoltage.containsKey(powerGenerationUser.getVoltageLevel())) {
dictData = mapVoltage.get(powerGenerationUser.getVoltageLevel());
sendVO.setConsVoltageLevel(dictData.getValue());
}
}
}
}
/**
* 国网上送返回信息
*
* @param num
* @param ids
* @param send
* @return
*/
private String returnInformation(Integer num, List<String> ids, Map<String, String> send) {
if (send.containsKey("succeed")) {
String succeed = send.get("succeed");
if (succeed.indexOf("\\\"") != -1) {
succeed = succeed.replace("\\\"", "\"");
}
Map mapData = JSON.parseObject(succeed, Map.class);
String status = mapData.get("status").toString();
if ("000000".equals(status)) {
//修改信息状态
updateIsUploadHead(num, ids);
String result = mapData.get("result").toString();
Map mapCount = JSON.parseObject(result, Map.class);
String count = mapCount.get("count").toString();
return "操作成功:成功数据" + count + "";
} else {
String errors = mapData.get("errors").toString();
throw new BusinessException("操作失败:" + status + "_" + errors);
}
} else {
// updateIsUploadHead(num, ids);
throw new BusinessException("当前时间段国网上送请求过多,请稍后再试");
// return "当前时间段国网上送请求过多,请稍后再试";
}
}
/**
* 修改上送信息状态
*
* @param num
* @param ids id集合
*/
private void updateIsUploadHead(Integer num, List<String> ids) {
switch (num) {
case 1:
monitorService.update(new LambdaUpdateWrapper<Monitor>()
.set(Monitor::getIsUploadHead, 1)
.in(Monitor::getId, ids)
);
break;
case 2:
tractionStationService.update(new LambdaUpdateWrapper<TractionStation>()
.set(TractionStation::getIsUploadHead, 1)
.in(TractionStation::getId, ids)
);
break;
default:
break;
}
}
}

View File

@@ -536,4 +536,12 @@ public enum DicDataEnum {
this.value = null; this.value = null;
} }
public static DicDataEnum getDicDataEnumValue(String code) {
for (DicDataEnum item : values()) {
if (item.getCode().equals(code)) {
return item;
}
}
return null;
}
} }

View File

@@ -112,6 +112,10 @@ public enum DicDataTypeEnum {
DEVICE_UNIT("数据单位类型","Device_Unit"), DEVICE_UNIT("数据单位类型","Device_Unit"),
//国网上送 //国网上送
USER_CLASS("用户分类","User_Class"),
IMPORTANCE_LEVEL("重要性等级","Importance_Level"),
ELE_CLASS("用电类别","Ele_Class"),
INDUSTRY_TYPE("行业分类","industry_type"),
PLAN_STATUS("计划状态","plan_status"), PLAN_STATUS("计划状态","plan_status"),
APP_EVENT("APP暂态事件类型","app_event"), APP_EVENT("APP暂态事件类型","app_event"),
DEVICE_TYPE("设备类型","Device_Type") DEVICE_TYPE("设备类型","Device_Type")