初始版本提交
This commit is contained in:
@@ -16,5 +16,30 @@
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-microservice</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>data-processing-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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.EventAnalysisFeignClientFallbackFactory;
|
||||
import com.njcn.message.messagedto.MessageDataDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 3:52【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@FeignClient(
|
||||
value = ServerInfo.PLATFORM_STAT_BOOT,
|
||||
path = "/eventAnalysis",
|
||||
fallbackFactory = EventAnalysisFeignClientFallbackFactory.class,
|
||||
contextId = "analysis")
|
||||
public interface EventAnalysisFeignClient {
|
||||
@PostMapping("/analysis")
|
||||
HttpResult<String> analysis(@RequestBody List<MessageDataDTO> messageList);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.event.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.event.api.EventAnalysisFeignClient;
|
||||
import com.njcn.event.utils.EventEnumUtil;
|
||||
import com.njcn.message.messagedto.MessageDataDTO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 3:55【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EventAnalysisFeignClientFallbackFactory implements FallbackFactory<EventAnalysisFeignClient> {
|
||||
|
||||
@Override
|
||||
public EventAnalysisFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = EventEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new EventAnalysisFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> analysis(List<MessageDataDTO> messageList) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "暂态消息数据解析", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Description:feign回调函数包
|
||||
* Date: 2025/01/23 下午 1:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
package com.njcn.event.api.fallback;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Description:对外接口包
|
||||
* Date: 2025/01/23 下午 1:48【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
package com.njcn.event.api;
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.event.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 09:56
|
||||
*/
|
||||
@Getter
|
||||
public enum EventResponseEnum {
|
||||
STAT_COMMON_ERROR("A00550","暂态数据解析模块异常"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
EventResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.stat.messagedto;
|
||||
package com.njcn.event.messagedto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.event.messagedto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/11/8 14:11【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class MessageEventDataSet implements Serializable {
|
||||
private Integer FLAG;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
private LocalDateTime TIME;
|
||||
@JsonProperty("VOLTAGE")
|
||||
private EventDTO volTage;
|
||||
|
||||
}
|
||||
@@ -38,6 +38,24 @@
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>data-processing-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>event-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.event.controller;
|
||||
|
||||
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.event.service.EventAnalysisService;
|
||||
import com.njcn.message.messagedto.MessageDataDTO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 2:10【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/eventAnalysis")
|
||||
@Api(tags = "事件解析")
|
||||
@AllArgsConstructor
|
||||
public class EventAnalysisController extends BaseController {
|
||||
|
||||
private final EventAnalysisService eventAnalysisService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/analysis")
|
||||
@ApiOperation("数据解析")
|
||||
public HttpResult<String> analysis(@RequestBody List<MessageDataDTO> messageList){
|
||||
String methodDescribe = getMethodDescribe("analysis");
|
||||
|
||||
eventAnalysisService.analysis(messageList);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, CommonResponseEnum.SUCCESS.getMessage(), methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.event.service;
|
||||
|
||||
|
||||
import com.njcn.message.messagedto.MessageDataDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 2:51【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface EventAnalysisService {
|
||||
void analysis(List<MessageDataDTO> messageList);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.event.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.dataProcess.api.LnDataDealFeignClient;
|
||||
import com.njcn.dataProcess.api.RmpEventDetailFeignClient;
|
||||
import com.njcn.dataProcess.dto.*;
|
||||
import com.njcn.event.messagedto.EventDTO;
|
||||
import com.njcn.event.messagedto.MessageEventDataSet;
|
||||
import com.njcn.event.service.EventAnalysisService;
|
||||
import com.njcn.message.enums.DataTypeEnum;
|
||||
import com.njcn.message.messagedto.MessageDataDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 2:51【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
|
||||
@Autowired
|
||||
private RmpEventDetailFeignClient rmpEventDetailFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
public void analysis(List<MessageDataDTO> messageList) {
|
||||
|
||||
|
||||
messageList.forEach(messageDataDTO->{
|
||||
Integer dataType = messageDataDTO.getDataType();
|
||||
String lineId = messageDataDTO.getMonitor();
|
||||
String value = messageDataDTO.getValue();
|
||||
|
||||
if(Objects.equals(DataTypeEnum.EVENT.getCode(),dataType)){
|
||||
MessageEventDataSet messageEventDataSet = JSONObject.parseObject(value, MessageEventDataSet.class);
|
||||
RmpEventDetailDTO rmpEventDetailDTO = new RmpEventDetailDTO();
|
||||
EventDTO volTage = messageEventDataSet.getVolTage();
|
||||
if(Objects.nonNull(volTage)){
|
||||
rmpEventDetailDTO.setMeasurementPointId(lineId);
|
||||
rmpEventDetailDTO.setEventType(volTage.getDiskind());
|
||||
rmpEventDetailDTO.setAdvanceType(volTage.getDiskind());
|
||||
|
||||
rmpEventDetailDTO.setStartTime(volTage.getStarttime());
|
||||
rmpEventDetailDTO.setDuration(volTage.getDur());
|
||||
rmpEventDetailDTO.setFeatureAmplitude(volTage.getMag());
|
||||
rmpEventDetailDTO.setPhase(volTage.getPhasic());
|
||||
rmpEventDetailDTO.setWavePath(volTage.getCfgFile().substring(0, volTage.getCfgFile().lastIndexOf("/")));
|
||||
|
||||
rmpEventDetailFeignClient.batchInsertion(rmpEventDetailDTO);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,8 @@ public class MessageAnalysisServiceImpl implements MessageAnalysisService {
|
||||
private LnDataDealFeignClient lnDataDealFeignClient;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RmpEventDetailFeignClient rmpEventDetailFeignClient;
|
||||
// @Autowired
|
||||
// private RmpEventDetailFeignClient rmpEventDetailFeignClient;
|
||||
@Override
|
||||
public void analysis(List<MessageDataDTO> messageList) {
|
||||
//12张表数据
|
||||
@@ -442,30 +442,32 @@ public class MessageAnalysisServiceImpl implements MessageAnalysisService {
|
||||
|
||||
|
||||
|
||||
}else if(Objects.equals(DataTypeEnum.EVENT.getCode(),dataType)){
|
||||
MessageEventDataSet messageEventDataSet = JSONObject.parseObject(value, MessageEventDataSet.class);
|
||||
RmpEventDetailDTO rmpEventDetailDTO = new RmpEventDetailDTO();
|
||||
EventDTO volTage = messageEventDataSet.getVolTage();
|
||||
if(Objects.nonNull(volTage)){
|
||||
rmpEventDetailDTO.setMeasurementPointId(lineId);
|
||||
rmpEventDetailDTO.setEventType(volTage.getDiskind());
|
||||
rmpEventDetailDTO.setAdvanceType(volTage.getDiskind());
|
||||
|
||||
rmpEventDetailDTO.setStartTime(volTage.getStarttime());
|
||||
rmpEventDetailDTO.setDuration(volTage.getDur());
|
||||
rmpEventDetailDTO.setFeatureAmplitude(volTage.getMag());
|
||||
rmpEventDetailDTO.setPhase(volTage.getPhasic());
|
||||
rmpEventDetailDTO.setWavePath(volTage.getCfgFile().substring(0, volTage.getCfgFile().lastIndexOf("/")));
|
||||
|
||||
|
||||
rmpEventDetailFeignClient.batchInsertion(rmpEventDetailDTO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
// todo 暂态数据切换到另外一个topic
|
||||
// else if(Objects.equals(DataTypeEnum.EVENT.getCode(),dataType)){
|
||||
// MessageEventDataSet messageEventDataSet = JSONObject.parseObject(value, MessageEventDataSet.class);
|
||||
// RmpEventDetailDTO rmpEventDetailDTO = new RmpEventDetailDTO();
|
||||
// EventDTO volTage = messageEventDataSet.getVolTage();
|
||||
// if(Objects.nonNull(volTage)){
|
||||
// rmpEventDetailDTO.setMeasurementPointId(lineId);
|
||||
// rmpEventDetailDTO.setEventType(volTage.getDiskind());
|
||||
// rmpEventDetailDTO.setAdvanceType(volTage.getDiskind());
|
||||
//
|
||||
// rmpEventDetailDTO.setStartTime(volTage.getStarttime());
|
||||
// rmpEventDetailDTO.setDuration(volTage.getDur());
|
||||
// rmpEventDetailDTO.setFeatureAmplitude(volTage.getMag());
|
||||
// rmpEventDetailDTO.setPhase(volTage.getPhasic());
|
||||
// rmpEventDetailDTO.setWavePath(volTage.getCfgFile().substring(0, volTage.getCfgFile().lastIndexOf("/")));
|
||||
//
|
||||
//
|
||||
// rmpEventDetailFeignClient.batchInsertion(rmpEventDetailDTO);
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
});
|
||||
LnDataDTO lnDataDTO = new LnDataDTO();
|
||||
lnDataDTO.setDataVList(dataVList);
|
||||
|
||||
Reference in New Issue
Block a user