初始版本提交
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.njcn.message.api;
|
||||
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
|
||||
import com.njcn.message.api.fallback.ProduceFeignClientFallbackFactory;
|
||||
import com.njcn.message.message.DeviceRebootMessage;
|
||||
import com.njcn.message.message.RecallMessage;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 3:52【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@FeignClient(
|
||||
value = "message-boot",
|
||||
path = "/produce",
|
||||
fallbackFactory = ProduceFeignClientFallbackFactory.class,
|
||||
contextId = "message")
|
||||
public interface ProduceFeignClient {
|
||||
@PostMapping("/recall")
|
||||
public HttpResult<Boolean> recall(@RequestBody RecallMessage message);
|
||||
|
||||
@PostMapping("/askRestartDevice")
|
||||
public HttpResult<Boolean> askRestartDevice(@RequestBody DeviceRebootMessage message);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.message.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.message.api.ProduceFeignClient;
|
||||
import com.njcn.message.message.DeviceRebootMessage;
|
||||
import com.njcn.message.message.RecallMessage;
|
||||
import com.njcn.message.utils.MessageEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/01/15 下午 3:55【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ProduceFeignClientFallbackFactory implements FallbackFactory<ProduceFeignClient> {
|
||||
|
||||
@Override
|
||||
public ProduceFeignClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = MessageEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new ProduceFeignClient() {
|
||||
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> recall(RecallMessage message) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "数据补招消息推送", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> askRestartDevice(DeviceRebootMessage message) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "消息数据解析", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.message.constant;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface BusinessResource {
|
||||
|
||||
/***
|
||||
* App
|
||||
*/
|
||||
String APP_RESOURCE = "APP";
|
||||
|
||||
|
||||
/***
|
||||
* Web
|
||||
*/
|
||||
String WEB_RESOURCE = "WEB";
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.njcn.message.constant;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年08月10日 15:30
|
||||
*/
|
||||
public interface BusinessTopic {
|
||||
|
||||
/**
|
||||
* 治理主送推送数据接收主题
|
||||
*/
|
||||
String NJCN_APP_AUTO_DATA_TOPIC = "njcnAppAutoDataTopic";
|
||||
|
||||
/**
|
||||
* 治理事件接收主题
|
||||
*/
|
||||
String NJCN_APP_EVENT_TOPIC = "njcnAppEventTopic";
|
||||
|
||||
/**
|
||||
* 治理告警接收主题
|
||||
*/
|
||||
String NJCN_APP_WARN_TOPIC = "njcnAppWarnTopic";
|
||||
|
||||
|
||||
/**
|
||||
* 治理文件接收主题
|
||||
*/
|
||||
String NJCN_APP_FILE_TOPIC = "njcnAppFileTopic";
|
||||
|
||||
String NJCN_APP_FILE_STREAM_TOPIC = "njcnAppFileStreamTopic";
|
||||
|
||||
String CONTROL_TOPIC = "control_Topic";
|
||||
|
||||
String ASK_REAL_DATA_TOPIC = "ask_real_data_topic";
|
||||
String RECALL_TOPIC = "recall_Topic";
|
||||
|
||||
|
||||
|
||||
/********************************数据中心*********************************/
|
||||
|
||||
String RMP_EVENT_DETAIL_TOPIC = "rmpEventDetailTopic";
|
||||
|
||||
|
||||
interface AppDataTag {
|
||||
|
||||
/**
|
||||
* 统计数据tag
|
||||
*/
|
||||
String STAT_TAG = "stat";
|
||||
|
||||
/**
|
||||
* 实时数据tag
|
||||
*/
|
||||
String RT_TAG = "rt";
|
||||
}
|
||||
|
||||
interface AppEventTag {
|
||||
|
||||
/**
|
||||
* 暂态事件(录波)tag
|
||||
*/
|
||||
String EVENT_TAG = "event";
|
||||
}
|
||||
|
||||
interface AppWarnTag {
|
||||
|
||||
/**
|
||||
* 告警事件tag
|
||||
*/
|
||||
String WARN_TAG = "warn";
|
||||
}
|
||||
|
||||
interface FileTag {
|
||||
|
||||
/**
|
||||
* 文件信息tag
|
||||
*/
|
||||
String INFO_TAG = "fileInfo";
|
||||
|
||||
/**
|
||||
* 文件流tag
|
||||
*/
|
||||
String STREAM_TAG = "streamInfo";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.message.constant;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/17 10:04【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface DeviceRebootType {
|
||||
/***
|
||||
* 1. 新增终端台账
|
||||
*/
|
||||
String ADD_TERMINAL = "add_terminal";
|
||||
|
||||
/***
|
||||
* 1. 删除终端台账
|
||||
*/
|
||||
String DELETE_TERMINAL = "delete_terminal";
|
||||
|
||||
|
||||
/***
|
||||
*修改终端 新增/删除/监测点台账
|
||||
*/
|
||||
String LEDGER_MODIFY = "ledger_modify";
|
||||
/**
|
||||
* Icd变更
|
||||
*/
|
||||
String ICD_CHANGE = "icd_change";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.message.constant;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年08月18日 11:31
|
||||
*/
|
||||
public interface MessageStatus {
|
||||
|
||||
/***
|
||||
* 状态为 成功、处理中时,打回不处理
|
||||
* 状态为 失败,可以继续处理
|
||||
*/
|
||||
String SUCCESS = "success";
|
||||
String BEING_PROCESSED = "being processed";
|
||||
String FAIL = "fail";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.message.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/11/13 15:24【需求编号】
|
||||
*01:稳态,02:短时闪变,03:长时闪变,04:暂态,05:告警
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Getter
|
||||
public enum DataTypeEnum {
|
||||
|
||||
HARMONIC(1, "稳态"),
|
||||
|
||||
FLUC(2, "短时闪变"),
|
||||
|
||||
PLT(3, "长时闪变"),
|
||||
EVENT(4, "暂态"),
|
||||
ALARM(5, "告警"),;
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String message;
|
||||
|
||||
DataTypeEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.message.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 09:56
|
||||
*/
|
||||
@Getter
|
||||
public enum MessageResponseEnum {
|
||||
MESSAGE_COMMON_ERROR("A00550","消息模块异常"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
MessageResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.message.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/13 10:15【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class AskRealDataMessage {
|
||||
private String devSeries;
|
||||
private String line;
|
||||
private Boolean realData = true;
|
||||
private Boolean soeData = true;
|
||||
//默认要60s数据3s*20所以这里默认20
|
||||
private Integer limit = 20;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.message.message;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/13 10:15【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class DeviceRebootMessage {
|
||||
private String code;
|
||||
|
||||
private DeviceInfo data;
|
||||
|
||||
@Data
|
||||
public static class DeviceInfo {
|
||||
//终端索引
|
||||
private String id;
|
||||
//终端ip
|
||||
private String ip;
|
||||
//终端型号
|
||||
private String devType;
|
||||
//挂载单位
|
||||
private String org_name;
|
||||
//组织名称
|
||||
private String port;
|
||||
//终端端口
|
||||
private String stationName;
|
||||
//变电站名
|
||||
private String name;
|
||||
//终端序列号
|
||||
private String updateTime;
|
||||
//数据更新时间
|
||||
private String manufacturer;
|
||||
//终端厂商
|
||||
private String status;
|
||||
//终端状态
|
||||
private String series;
|
||||
//终端识别码
|
||||
private String devKey;
|
||||
//
|
||||
private List<MonitorInfo> monitorData;
|
||||
|
||||
@Data
|
||||
public static class MonitorInfo {
|
||||
//监测点索引
|
||||
private String id;
|
||||
//名称
|
||||
private String name;
|
||||
//监测点逻辑号
|
||||
private String lineNo;
|
||||
//监测点电压等级
|
||||
private String voltageLevel;
|
||||
//监测点接线方式
|
||||
private String ptType;
|
||||
private String status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.message.message;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/11/7 15:05【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class RecallMessage {
|
||||
|
||||
private List<RecallDTO> data;
|
||||
@Data
|
||||
public static class RecallDTO {
|
||||
|
||||
/**
|
||||
* monitorId : ["id1","id2","id3"]
|
||||
* dataType : 稳态
|
||||
* timeInterval : ["2024-01-01 12:52:51~2024-01-01 13:53:00","2024-01-02 12:52:51~2024-01-02 13:53:00","2024-01-03 12:52:51~2024-01-03 13:53:00","2024-01-04 12:52:51~2024-01-04 13:53:00"]
|
||||
*/
|
||||
@ApiModelProperty("0/1(稳态/暂态)")
|
||||
private String dataType;
|
||||
private List<String> monitorId;
|
||||
private List<String> timeInterval;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.message.messagedto;
|
||||
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/11/8 14:09【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class MessageDataDTO extends BaseMessage implements Serializable {
|
||||
private Integer dataType;
|
||||
private String monitor;
|
||||
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.message.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.common.utils.EnumUtils;
|
||||
import com.njcn.message.enums.MessageResponseEnum;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 10:03
|
||||
*/
|
||||
public class MessageEnumUtil {
|
||||
|
||||
/**
|
||||
* 获取HarmonicResponseEnum实例
|
||||
*/
|
||||
public static MessageResponseEnum getMessageEnumResponseEnumByMessage(@NotNull Object value) {
|
||||
MessageResponseEnum harmonicResponseEnum;
|
||||
try {
|
||||
String message = value.toString();
|
||||
if(message.indexOf(StrUtil.C_COMMA)>0){
|
||||
value = message.substring(message.indexOf(StrUtil.C_COMMA)+1);
|
||||
}
|
||||
harmonicResponseEnum = EnumUtils.valueOf(MessageResponseEnum.class, value, MessageResponseEnum.class.getMethod(BusinessException.GET_MESSAGE_METHOD));
|
||||
return Objects.isNull(harmonicResponseEnum) ? MessageResponseEnum.MESSAGE_COMMON_ERROR : harmonicResponseEnum;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new BusinessException(CommonResponseEnum.INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
public static Enum<?> getExceptionEnum(HttpResult<Object> result){
|
||||
//如果返回错误,且为内部错误,则直接抛出异常
|
||||
CommonResponseEnum commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
||||
if (commonResponseEnum == CommonResponseEnum.DEVICE_RESPONSE_ENUM) {
|
||||
return getMessageEnumResponseEnumByMessage(result.getMessage());
|
||||
}
|
||||
return commonResponseEnum;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.middle.rocket.domain;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年08月04日 10:53
|
||||
*/
|
||||
@Data
|
||||
public class BaseMessage {
|
||||
|
||||
/**
|
||||
* 业务键,用于RocketMQ控制台查看消费情况
|
||||
* 为了保证唯一性,使用雪花算法生成一个随机id
|
||||
*/
|
||||
protected String key = IdUtil.getSnowflake().nextIdStr();
|
||||
|
||||
/**
|
||||
* 发送消息来源,用于排查问题
|
||||
*/
|
||||
protected String source = "";
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
protected LocalDateTime sendTime = LocalDateTime.now();
|
||||
|
||||
/**
|
||||
* 重试次数,用于判断重试次数,超过重试次数发送异常警告
|
||||
*/
|
||||
protected Integer retryTimes = 0;
|
||||
|
||||
protected String messageBoy;
|
||||
}
|
||||
Reference in New Issue
Block a user