暂降原因
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
package com.njcn.advance.api;
|
||||||
|
|
||||||
|
import com.njcn.advance.api.fallback.EventCauseFeignClientFallbackFactory;
|
||||||
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Date: 2025/08/01 上午 8:54【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.ADVANCE_BOOT,path = "/eventAdvance",
|
||||||
|
fallbackFactory = EventCauseFeignClientFallbackFactory.class,
|
||||||
|
contextId = "eventAdvance" )
|
||||||
|
public interface EventCauseFeignClient {
|
||||||
|
@PostMapping(value = "/analysisCauseAndType")
|
||||||
|
HttpResult<EventAnalysisDTO> analysisCauseAndType(@RequestBody EventAnalysisDTO eventAnalysis);
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.njcn.advance.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.advance.api.EventCauseFeignClient;
|
||||||
|
import com.njcn.advance.api.EventWaveAnalysisFeignClient;
|
||||||
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
|
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||||
|
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.utils.EventlEnumUtil;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class EventCauseFeignClientFallbackFactory implements FallbackFactory<EventCauseFeignClient> {
|
||||||
|
@Override
|
||||||
|
public EventCauseFeignClient create(Throwable throwable) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (throwable.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||||
|
exceptionEnum = EventlEnumUtil.getExceptionEnum(businessException.getResult());
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
|
||||||
|
return new EventCauseFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<EventAnalysisDTO> analysisCauseAndType(EventAnalysisDTO eventAnalysis) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "暂降原因分析", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.njcn.advance.event.pojo;
|
package com.njcn.advance.pojo.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.advance.event.controller;
|
package com.njcn.advance.event.controller;
|
||||||
|
|
||||||
import com.njcn.advance.event.pojo.EventAnalysisDTO;
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
import com.njcn.advance.event.service.IEventAdvanceService;
|
import com.njcn.advance.event.service.IEventAdvanceService;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
@@ -13,11 +13,10 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
@@ -35,7 +34,7 @@ public class EventCauseController extends BaseController {
|
|||||||
@PostMapping(value = "/analysisCauseAndType")
|
@PostMapping(value = "/analysisCauseAndType")
|
||||||
@ApiOperation("分析暂降事件的原因和类型")
|
@ApiOperation("分析暂降事件的原因和类型")
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
public HttpResult<EventAnalysisDTO> analysisCauseAndType(EventAnalysisDTO eventAnalysis) {
|
public HttpResult<EventAnalysisDTO> analysisCauseAndType(@RequestBody EventAnalysisDTO eventAnalysis) {
|
||||||
String methodDescribe = getMethodDescribe("analysisCauseAndType");
|
String methodDescribe = getMethodDescribe("analysisCauseAndType");
|
||||||
eventAnalysis = eventAdvanceService.analysisCauseAndType(eventAnalysis);
|
eventAnalysis = eventAdvanceService.analysisCauseAndType(eventAnalysis);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventAnalysis, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventAnalysis, methodDescribe);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.advance.event.service;
|
package com.njcn.advance.event.service;
|
||||||
|
|
||||||
import com.njcn.advance.event.pojo.EventAnalysisDTO;
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.njcn.advance.event.cause.core.VoltageSagAnalyzer;
|
|||||||
import com.njcn.advance.event.cause.model.AnalysisResult;
|
import com.njcn.advance.event.cause.model.AnalysisResult;
|
||||||
import com.njcn.advance.event.cause.model.DataFeature;
|
import com.njcn.advance.event.cause.model.DataFeature;
|
||||||
import com.njcn.advance.event.cause.model.QvvrDataStruct;
|
import com.njcn.advance.event.cause.model.QvvrDataStruct;
|
||||||
import com.njcn.advance.event.pojo.EventAnalysisDTO;
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
import com.njcn.advance.event.service.IEventAdvanceService;
|
import com.njcn.advance.event.service.IEventAdvanceService;
|
||||||
import com.njcn.advance.event.type.jna.QvvrDLL;
|
import com.njcn.advance.event.type.jna.QvvrDLL;
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
|
|||||||
@@ -89,6 +89,11 @@
|
|||||||
<artifactId>supervision-api</artifactId>
|
<artifactId>supervision-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>advance-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
|
import com.njcn.advance.api.EventCauseFeignClient;
|
||||||
|
import com.njcn.advance.api.EventWaveAnalysisFeignClient;
|
||||||
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
import com.njcn.common.pojo.constant.LogInfo;
|
import com.njcn.common.pojo.constant.LogInfo;
|
||||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
@@ -19,6 +22,7 @@ import com.njcn.device.pq.api.DeptLineFeignClient;
|
|||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||||
|
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||||
import com.njcn.event.pojo.vo.SendEventVO;
|
import com.njcn.event.pojo.vo.SendEventVO;
|
||||||
import com.njcn.event.utils.EventUtil;
|
import com.njcn.event.utils.EventUtil;
|
||||||
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
|
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
|
||||||
@@ -66,7 +70,7 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
|||||||
private final DeptLineFeignClient deptLineFeignClient;
|
private final DeptLineFeignClient deptLineFeignClient;
|
||||||
private final DeptFeignClient deptFeignClient;
|
private final DeptFeignClient deptFeignClient;
|
||||||
|
|
||||||
|
private final EventCauseFeignClient eventCauseFeignClient;
|
||||||
@Override
|
@Override
|
||||||
public List<EventDetail> getEventDetailData(String id, String startTime, String endTime) {
|
public List<EventDetail> getEventDetailData(String id, String startTime, String endTime) {
|
||||||
//数据暂降查询
|
//数据暂降查询
|
||||||
@@ -168,12 +172,26 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
|||||||
}
|
}
|
||||||
|
|
||||||
rmpEventDetailPO.setEventDescribe(" ");
|
rmpEventDetailPO.setEventDescribe(" ");
|
||||||
//默认都是其他
|
//如果不为空,说明是二次上传波形文件了;
|
||||||
DictData reason = dicDataFeignClient.getDicDataByCode(DicDataEnum.RESON_REST.getCode()).getData();
|
String reason,type;
|
||||||
DictData advanceType = dicDataFeignClient.getDicDataByCode(DicDataEnum.TYPE_REST.getCode()).getData();
|
if(!StringUtils.isEmpty(rmpEventDetailPO.getWavePath())){
|
||||||
|
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(rmpEventDetailPO.getLineId()).getData();
|
||||||
|
String ip = lineDetailData.getIp();
|
||||||
|
EventAnalysisDTO eventAnalysisDTO = new EventAnalysisDTO();
|
||||||
|
eventAnalysisDTO.setIp(ip);
|
||||||
|
eventAnalysisDTO.setWaveName(rmpEventDetailPO.getWavePath());
|
||||||
|
EventAnalysisDTO result = eventCauseFeignClient.analysisCauseAndType(eventAnalysisDTO).getData();
|
||||||
|
reason =reasonReflection(result.getCause());
|
||||||
|
type =advanceTypeReflection(result.getType());
|
||||||
|
DictData advancereason = dicDataFeignClient.getDicDataByCode(reason).getData();
|
||||||
|
DictData advanceType = dicDataFeignClient.getDicDataByCode(type).getData();
|
||||||
|
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
||||||
|
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rmpEventDetailPO.setAdvanceReason(reason.getId());
|
|
||||||
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
|
||||||
String severity = EventUtil.getYzd(deatilDTO.getDuration().floatValue(),(deatilDTO.getAmplitude().floatValue()/100));
|
String severity = EventUtil.getYzd(deatilDTO.getDuration().floatValue(),(deatilDTO.getAmplitude().floatValue()/100));
|
||||||
rmpEventDetailPO.setSeverity(Double.valueOf(severity));
|
rmpEventDetailPO.setSeverity(Double.valueOf(severity));
|
||||||
rmpEventDetailPO.setCreateTime(LocalDateTime.now());
|
rmpEventDetailPO.setCreateTime(LocalDateTime.now());
|
||||||
@@ -181,6 +199,7 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
|||||||
RmpEventDetailPO one = this.lambdaQuery().eq(RmpEventDetailPO::getLineId, rmpEventDetailPO.getLineId()).eq(RmpEventDetailPO::getStartTime, rmpEventDetailPO.getStartTime()).one();
|
RmpEventDetailPO one = this.lambdaQuery().eq(RmpEventDetailPO::getLineId, rmpEventDetailPO.getLineId()).eq(RmpEventDetailPO::getStartTime, rmpEventDetailPO.getStartTime()).one();
|
||||||
if(Objects.nonNull(one)){
|
if(Objects.nonNull(one)){
|
||||||
rmpEventDetailPO.setEventId(one.getEventId());
|
rmpEventDetailPO.setEventId(one.getEventId());
|
||||||
|
|
||||||
this.updateById(rmpEventDetailPO);
|
this.updateById(rmpEventDetailPO);
|
||||||
} else {
|
} else {
|
||||||
this.save(rmpEventDetailPO);
|
this.save(rmpEventDetailPO);
|
||||||
@@ -191,9 +210,72 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
|||||||
pushEvent(rmpEventDetailPO);
|
pushEvent(rmpEventDetailPO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String advanceTypeReflection(Integer type) {
|
||||||
|
String result = DicDataEnum.TYPE_REST.getCode();
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
result = DicDataEnum.INTERPHASE_BC.getCode();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
result = DicDataEnum.PHASE_C.getCode();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = DicDataEnum.INTERPHASE_AC.getCode();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = DicDataEnum.PHASE_A.getCode();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
result = DicDataEnum.INTERPHASE_AB.getCode();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
result = DicDataEnum.PHASE_B.getCode();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
result = DicDataEnum.GROUND_BC.getCode();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
result = DicDataEnum.GROUND_AC.getCode();
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
result = DicDataEnum.GROUND_AB.getCode();
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
result = DicDataEnum.GROUND_ABC.getCode();
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
result = DicDataEnum.TYPE_REST.getCode();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String reasonReflection(Integer cause) {
|
||||||
|
String result =DicDataEnum.RESON_REST.getCode();
|
||||||
|
switch (cause) {
|
||||||
|
case 0:
|
||||||
|
result = DicDataEnum.RESON_REST.getCode();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
result = DicDataEnum.SHORT_TROUBLE.getCode();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = DicDataEnum.TRANSFORMER_EXCITATION.getCode();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = DicDataEnum.LARGE_INDUCTION.getCode();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
result = DicDataEnum.VOLTAGE_DISTURBANCE.getCode();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void pushEvent(RmpEventDetailPO po) {
|
private void pushEvent(RmpEventDetailPO po) {
|
||||||
String id = po.getLineId();
|
String id = po.getLineId();
|
||||||
//根据监测点获取部门
|
//根据监测点获取部门
|
||||||
@@ -234,6 +316,7 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
|||||||
break;
|
break;
|
||||||
case 1210003:
|
case 1210003:
|
||||||
result = DicDataEnum.OTHER.getCode();
|
result = DicDataEnum.OTHER.getCode();
|
||||||
|
break;
|
||||||
case 1210004:
|
case 1210004:
|
||||||
result = DicDataEnum.SHORT_INTERRUPTIONS.getCode();
|
result = DicDataEnum.SHORT_INTERRUPTIONS.getCode();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user