1.国网上送接口
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user