1.国网上送代码调整
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.njcn.device.pms.api;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.device.pms.api.fallback.MonitorClientFallbackFactory;
|
||||
import com.njcn.device.pms.pojo.dto.PmsMonitorDTO;
|
||||
import com.njcn.device.pms.pojo.dto.PmsMonitorInfoDTO;
|
||||
import com.njcn.device.pms.pojo.param.MonitorParam;
|
||||
import com.njcn.device.pms.pojo.param.MonitorTerminalParam;
|
||||
import com.njcn.device.pms.pojo.param.PmsMonitorInfoParam;
|
||||
import com.njcn.device.pms.pojo.param.PmsMonitorParam;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.device.pms.pojo.vo.MonitorVO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
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.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yzh
|
||||
* @date 2022/10/18
|
||||
*/
|
||||
@FeignClient(
|
||||
value = ServerInfo.DEVICE,
|
||||
path = "/monitorSend",
|
||||
contextId = "monitorSend",
|
||||
fallbackFactory = MonitorClientFallbackFactory.class)
|
||||
public interface MonitorSendClient {
|
||||
|
||||
@PostMapping("/sendType")
|
||||
HttpResult<String> windSend(@RequestBody @Validated MonitorParam.Info param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.device.pms.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pms.api.MonitorSendClient;
|
||||
import com.njcn.device.pms.pojo.param.MonitorParam;
|
||||
import com.njcn.device.pms.utils.PmsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/12/25 9:17
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MonitorSendClientFallbackFactory implements FallbackFactory<MonitorSendClient> {
|
||||
|
||||
@Override
|
||||
public MonitorSendClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = PmsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new MonitorSendClient()
|
||||
{
|
||||
|
||||
@Override
|
||||
public HttpResult<String> windSend(MonitorParam.Info param) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "国网五类台账上送接口", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,8 @@ public class TractionStationDTO extends Unit {
|
||||
/*监测点编号 是否必填:否*/
|
||||
@ExcelProperty(value = "监测点编号")
|
||||
private String monitorNumber;
|
||||
@ExcelProperty(value = "监测点名称")
|
||||
private String monitorName;
|
||||
/*第二个监测点编号 是否必填:否*/
|
||||
@ExcelProperty(value = "第二个监测点编号")
|
||||
private String monitorNumberTwo;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.njcn.device.pms.service.gwPush.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.text.StrBuilder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
@@ -18,6 +20,7 @@ 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.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
@@ -67,6 +70,10 @@ public class MonitorSendServiceImpl implements MonitorSendService {
|
||||
throw new BusinessException("请检查监测对象类型是否存在");
|
||||
}
|
||||
List<DictTreeVO> objType = dictTreeFeignClient.query(param.getObjType()).getData();
|
||||
//运行状态
|
||||
List<DictData> lineState = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
|
||||
List<DictData> run = lineState.stream().filter(x -> DicDataEnum.RUN.getCode()
|
||||
.equals(x.getCode())).collect(Collectors.toList());
|
||||
List<String> objTypeIds=new ArrayList<>();
|
||||
objTypeIds.add(param.getObjType());
|
||||
if(CollUtil.isNotEmpty(objType)){
|
||||
@@ -76,6 +83,8 @@ public class MonitorSendServiceImpl implements MonitorSendService {
|
||||
List<Monitor> monitorList = monitorService.list(new LambdaQueryWrapper<Monitor>()
|
||||
.in(StrUtil.isNotBlank(param.getMonitorTag()),Monitor::getMonitorTag, param.getMonitorTag())
|
||||
.in(Monitor::getObjType, objTypeIds)
|
||||
.eq(Monitor::getIsUpToGrid,1)
|
||||
.eq(Monitor::getMonitorState,run.get(0).getId())
|
||||
.in(CollUtil.isNotEmpty(param.getIds()),Monitor::getId, param.getIds())
|
||||
);
|
||||
List<String> powerIds= monitorList.stream().map(Monitor::getPowerrId).distinct().collect(Collectors.toList());
|
||||
@@ -93,66 +102,78 @@ public class MonitorSendServiceImpl implements MonitorSendService {
|
||||
}
|
||||
|
||||
private String monitorType(SysDicTreePO dicTree, List<Monitor> monitorList) {
|
||||
String msg;
|
||||
StrBuilder str=new StrBuilder();
|
||||
switch (dicTree.getCode()) {
|
||||
case "1401":
|
||||
List<WindSourceDto> info = this.windSend(monitorList);
|
||||
sendSize(info);
|
||||
List<List<WindSourceDto>> split = ListUtil.split(info, 100);
|
||||
for (int i = 0; i < split.size(); i++) {
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(info);
|
||||
sendParam.setStats(split.get(i));
|
||||
Map<String, String> send = GwSendUtil.send(sendParam, GWSendEnum.WIND_CREATE);
|
||||
List<String> wiIds = info.stream().map(WindSourceDto::getId).distinct().collect(Collectors.toList());
|
||||
msg = returnInformation(1, wiIds, send);
|
||||
str.append("第"+(i+1)+"次循环:"+ returnInformation(1, wiIds, send)+";</br>");
|
||||
}
|
||||
break;
|
||||
case "1402":
|
||||
List<PhotovoltaicDto> photovoltaic = this.photovoltaicSend(monitorList);
|
||||
sendSize(photovoltaic);
|
||||
List<List<PhotovoltaicDto>> phSplit = ListUtil.split(photovoltaic, 100);
|
||||
for (int i = 0; i < phSplit.size(); i++) {
|
||||
SendParam phSend = new SendParam();
|
||||
phSend.setStats(photovoltaic);
|
||||
phSend.setStats(phSplit.get(i));
|
||||
Map<String, String> phMap = GwSendUtil.send(phSend, GWSendEnum.PHOTOVOLTAIC_CREATE);
|
||||
List<String> phIds = photovoltaic.stream().map(PhotovoltaicDto::getId).distinct().collect(Collectors.toList());
|
||||
msg = returnInformation(1, phIds, phMap);
|
||||
str.append("第"+(i+1)+"次循环:"+ returnInformation(1, phIds, phMap)+";</br>");
|
||||
}
|
||||
break;
|
||||
case "2400":
|
||||
List<SensitiveUserDto> sensitive = this.sensitiveUserSend(monitorList);
|
||||
sendSize(sensitive);
|
||||
List<List<SensitiveUserDto>> seSplit = ListUtil.split(sensitive, 100);
|
||||
for (int i = 0; i < seSplit.size(); i++) {
|
||||
SendParam seSend = new SendParam();
|
||||
seSend.setStats(sensitive);
|
||||
seSend.setStats(seSplit.get(i));
|
||||
Map<String, String> seMap = GwSendUtil.send(seSend, GWSendEnum.SENSITIVE_USER_CREATE);
|
||||
List<String> seIds = sensitive.stream().map(SensitiveUserDto::getId).distinct().collect(Collectors.toList());
|
||||
msg = returnInformation(1, seIds, seMap);
|
||||
str.append("第"+(i+1)+"次循环:"+ returnInformation(1, seIds, seMap)+";</br>");
|
||||
}
|
||||
break;
|
||||
case "1300":
|
||||
List<TractionStationDTO> traction = this.tractionStationSend(monitorList);
|
||||
sendSize(traction);
|
||||
List<List<TractionStationDTO>> trSplit = ListUtil.split(traction, 100);
|
||||
for (int i = 0; i < trSplit.size(); i++) {
|
||||
SendParam trSend = new SendParam();
|
||||
trSend.setStats(traction);
|
||||
trSend.setStats(trSplit.get(i));
|
||||
Map<String, String> trMap = GwSendUtil.send(trSend, GWSendEnum.TRACTION_STATION);
|
||||
List<String> trIds = traction.stream().map(TractionStationDTO::getId).distinct().collect(Collectors.toList());
|
||||
msg = returnInformation(1, trIds, trMap);
|
||||
str.append("第"+(i+1)+"次循环:"+ returnInformation(1, trIds, trMap)+";</br>");
|
||||
}
|
||||
break;
|
||||
case "2300":
|
||||
List<OtherUserDto> other = this.otherUserSend(monitorList);
|
||||
sendSize(other);
|
||||
List<List<OtherUserDto>> otSplit = ListUtil.split(other, 100);
|
||||
for (int i = 0; i < otSplit.size(); i++) {
|
||||
SendParam otSend = new SendParam();
|
||||
otSend.setStats(other);
|
||||
otSend.setStats(otSplit.get(i));
|
||||
Map<String, String> otMap = GwSendUtil.send(otSend, GWSendEnum.OTHER_USER_CREATE);
|
||||
List<String> otIds = other.stream().map(OtherUserDto::getId).distinct().collect(Collectors.toList());
|
||||
msg = returnInformation(1, otIds, otMap);
|
||||
str.append("第"+(i++)+"循环:"+ returnInformation(1, otIds, otMap)+";</br>");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new BusinessException("请选择国网上送的监测点标签上送");
|
||||
}
|
||||
return msg;
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
private void sendSize(List info) {
|
||||
if (CollUtil.isEmpty(info)) {
|
||||
throw new BusinessException("查询数据为空,请查询数据是否存在!");
|
||||
}
|
||||
if (info.size() > 100) {
|
||||
throw new BusinessException("一次最多上送100条数据");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -456,6 +477,7 @@ public class MonitorSendServiceImpl implements MonitorSendService {
|
||||
sendVO.setCreateTime(monitor.getCreateTime());
|
||||
sendVO.setUpdateTime(monitor.getUpdateTime());
|
||||
sendVO.setId(monitor.getId());
|
||||
sendVO.setMonitorName(monitor.getName());
|
||||
sendVO.setMonitorNumber(monitor.getMonitorId());
|
||||
|
||||
//运行状态
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.event.api;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory;
|
||||
import com.njcn.event.pojo.param.EventCountParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.GeneralVO;
|
||||
@@ -56,4 +57,10 @@ public interface EventDetailFeignClient {
|
||||
*/
|
||||
@PostMapping("/getEventDetailByIdsList")
|
||||
HttpResult<List<RmpEventDetailPO>> getEventDetailByIdsList(@RequestBody List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据监测点id集合获取暂降列表
|
||||
*/
|
||||
@PostMapping("/getEventDetailByLineCount")
|
||||
HttpResult<Integer> getEventDetailByLineCount(@RequestBody EventCountParam param);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.event.api.EventDetailFeignClient;
|
||||
import com.njcn.event.pojo.param.EventCountParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.GeneralVO;
|
||||
@@ -63,6 +64,12 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory<Ev
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Integer> getEventDetailByLineCount(EventCountParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合获取暂降列表", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.event.pojo.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/12/22 10:38
|
||||
*/
|
||||
@Data
|
||||
public class EventCountParam implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "ids")
|
||||
List<String> ids;
|
||||
|
||||
@ApiModelProperty(name="startTime",value="统计起始日期(yyyy-MM-dd)")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(name="endTime",value="统计截止日期(yyyy-MM-dd)")
|
||||
private String endTime;
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.njcn.event.controller.majornetwork;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -7,6 +11,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
|
||||
import com.njcn.event.pojo.param.EventCountParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.GeneralVO;
|
||||
@@ -154,4 +159,21 @@ public class EventDetailController extends BaseController {
|
||||
List<RmpEventDetailPO> eventDetailPOS = eventDetailService.listByIds(ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventDetailPOS, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据监测点集合获取短时终端,电压暂升,电压暂降
|
||||
* @return
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getEventDetailByLineCount")
|
||||
@ApiOperation("根据暂态id集合获取暂降列表")
|
||||
public HttpResult<Integer> getEventDetailByLineCount(@RequestBody EventCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("getEventDetailByLineCount");
|
||||
int count = eventDetailService.count(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.in(CollUtil.isNotEmpty(param.getIds()), RmpEventDetailPO::getLineId, param.getIds())
|
||||
.ge(StrUtil.isNotBlank(param.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
|
||||
.le(StrUtil.isNotBlank(param.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
|
||||
);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import com.njcn.device.pms.api.MonitorSendClient;
|
||||
import com.njcn.device.pms.pojo.param.MonitorParam;
|
||||
import com.njcn.system.service.SysDicTreePOService;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MonitorSendTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final MonitorSendClient monitorSendClient;
|
||||
private final SysDicTreePOService sysDicTreePOService;
|
||||
|
||||
|
||||
@Override
|
||||
public void action() {
|
||||
//风电场
|
||||
MonitorParam.Info param = new MonitorParam.Info();
|
||||
param.setObjType(sysDicTreePOService.queryByCode("1401").getId());
|
||||
monitorSendClient.windSend(param);
|
||||
//光伏电站
|
||||
MonitorParam.Info param1 = new MonitorParam.Info();
|
||||
param1.setObjType(sysDicTreePOService.queryByCode("1402").getId());
|
||||
monitorSendClient.windSend(param1);
|
||||
//牵引站
|
||||
MonitorParam.Info param3 = new MonitorParam.Info();
|
||||
param3.setObjType(sysDicTreePOService.queryByCode("1300").getId());
|
||||
monitorSendClient.windSend(param3);
|
||||
//干扰用户
|
||||
MonitorParam.Info param4 = new MonitorParam.Info();
|
||||
param4.setObjType(sysDicTreePOService.queryByCode("2300").getId());
|
||||
monitorSendClient.windSend(param4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import com.njcn.device.pms.api.MonitorSendClient;
|
||||
import com.njcn.device.pms.pojo.param.MonitorParam;
|
||||
import com.njcn.system.service.SysDicTreePOService;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MonitorUserSendTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final MonitorSendClient monitorSendClient;
|
||||
private final SysDicTreePOService sysDicTreePOService;
|
||||
|
||||
|
||||
@Override
|
||||
public void action() {
|
||||
//重要或敏感用户
|
||||
MonitorParam.Info param2 = new MonitorParam.Info();
|
||||
param2.setObjType(sysDicTreePOService.queryByCode("2400").getId());
|
||||
monitorSendClient.windSend(param2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user