设备重启和进程重启
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
package com.njcn.message.api;
|
package com.njcn.message.api;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.ServerInfo;
|
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.common.pojo.response.HttpResult;
|
||||||
|
|
||||||
import com.njcn.message.api.fallback.ProduceFeignClientFallbackFactory;
|
import com.njcn.message.api.fallback.ProduceFeignClientFallbackFactory;
|
||||||
import com.njcn.message.message.DeviceRebootMessage;
|
import com.njcn.message.message.DeviceRebootMessage;
|
||||||
|
import com.njcn.message.message.ProcessRebootMessage;
|
||||||
import com.njcn.message.message.RecallMessage;
|
import com.njcn.message.message.RecallMessage;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
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.RequestBody;
|
||||||
@@ -28,4 +33,9 @@ public interface ProduceFeignClient {
|
|||||||
|
|
||||||
@PostMapping("/askRestartDevice")
|
@PostMapping("/askRestartDevice")
|
||||||
public HttpResult<Boolean> askRestartDevice(@RequestBody DeviceRebootMessage message);
|
public HttpResult<Boolean> askRestartDevice(@RequestBody DeviceRebootMessage message);
|
||||||
|
|
||||||
|
@PostMapping("/askRestartProcess")
|
||||||
|
|
||||||
|
public HttpResult<Boolean> askRestartProcess(@RequestBody ProcessRebootMessage message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
|
|
||||||
import com.njcn.message.api.ProduceFeignClient;
|
import com.njcn.message.api.ProduceFeignClient;
|
||||||
import com.njcn.message.message.DeviceRebootMessage;
|
import com.njcn.message.message.DeviceRebootMessage;
|
||||||
|
import com.njcn.message.message.ProcessRebootMessage;
|
||||||
import com.njcn.message.message.RecallMessage;
|
import com.njcn.message.message.RecallMessage;
|
||||||
import com.njcn.message.utils.MessageEnumUtil;
|
import com.njcn.message.utils.MessageEnumUtil;
|
||||||
import feign.hystrix.FallbackFactory;
|
import feign.hystrix.FallbackFactory;
|
||||||
@@ -43,7 +44,13 @@ public class ProduceFeignClientFallbackFactory implements FallbackFactory<Produc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResult<Boolean> askRestartDevice(DeviceRebootMessage message) {
|
public HttpResult<Boolean> askRestartDevice(DeviceRebootMessage message) {
|
||||||
log.error("{}异常,降级处理,异常为:{}", "消息数据解析", throwable.toString());
|
log.error("{}异常,降级处理,异常为:{}", "设备重启", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<Boolean> askRestartProcess(ProcessRebootMessage message) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "进程重启", throwable.toString());
|
||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public interface BusinessTopic {
|
|||||||
|
|
||||||
String CONTROL_TOPIC = "control_Topic";
|
String CONTROL_TOPIC = "control_Topic";
|
||||||
|
|
||||||
|
String PROCESS_TOPIC = "process_Topic";
|
||||||
|
|
||||||
String ASK_REAL_DATA_TOPIC = "ask_real_data_topic";
|
String ASK_REAL_DATA_TOPIC = "ask_real_data_topic";
|
||||||
String RECALL_TOPIC = "recall_Topic";
|
String RECALL_TOPIC = "recall_Topic";
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.njcn.message.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Date: 2025/02/17 上午 10:09【需求编号】
|
||||||
|
*
|
||||||
|
* @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";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,21 +13,55 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class DeviceRebootMessage {
|
public class DeviceRebootMessage {
|
||||||
//set_process
|
private String code;
|
||||||
private String code="set_process";
|
|
||||||
|
|
||||||
private Integer index;
|
private DeviceInfo data;
|
||||||
|
|
||||||
private List<RebootData> data;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class RebootData {
|
public static class DeviceInfo {
|
||||||
//reset/add",重置或者添加进程
|
//终端索引
|
||||||
private String fun;
|
private String id;
|
||||||
//重置启动多少个进程,或者添加第几个进程
|
//终端ip
|
||||||
private Integer processNum;
|
private String ip;
|
||||||
//"stat/recall/all"//重置的进程类型:stat或者recall或者所有进程;添加的进程类型:stat或者recall或者stat和recall;只有稳态和补招是多进程
|
//终端型号
|
||||||
private String frontType;
|
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,35 @@
|
|||||||
|
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 ProcessRebootMessage {
|
||||||
|
|
||||||
|
//set_process
|
||||||
|
private String code="set_process";
|
||||||
|
|
||||||
|
private Integer index;
|
||||||
|
|
||||||
|
private List<ProcessRebootMessage.RebootData> data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class RebootData {
|
||||||
|
//reset/add",重置或者添加进程
|
||||||
|
private String fun;
|
||||||
|
//重置启动多少个进程,或者添加第几个进程
|
||||||
|
private Integer processNum;
|
||||||
|
//"stat/recall/all"//重置的进程类型:stat或者recall或者所有进程;添加的进程类型:stat或者recall或者stat和recall;只有稳态和补招是多进程
|
||||||
|
private String frontType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -20,6 +20,11 @@ public class RecallMessage {
|
|||||||
public static class RecallDTO {
|
public static class RecallDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* {
|
||||||
|
* "dataType":1,
|
||||||
|
* "monitorId":["1","2"],
|
||||||
|
* "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"]
|
||||||
|
* }
|
||||||
* monitorId : ["id1","id2","id3"]
|
* monitorId : ["id1","id2","id3"]
|
||||||
* dataType : 稳态
|
* 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"]
|
* 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"]
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
|
||||||
import com.njcn.message.message.DeviceRebootMessage;
|
import com.njcn.message.message.DeviceRebootMessage;
|
||||||
|
import com.njcn.message.message.ProcessRebootMessage;
|
||||||
import com.njcn.message.message.RecallMessage;
|
import com.njcn.message.message.RecallMessage;
|
||||||
import com.njcn.message.produce.template.DeviceRebootMessageTemplate;
|
import com.njcn.message.produce.template.DeviceRebootMessageTemplate;
|
||||||
|
import com.njcn.message.produce.template.ProcessRebootMessageTemplate;
|
||||||
import com.njcn.message.produce.template.RecallMessaggeTemplate;
|
import com.njcn.message.produce.template.RecallMessaggeTemplate;
|
||||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
@@ -35,12 +37,14 @@ public class ProduceController extends BaseController {
|
|||||||
|
|
||||||
private final DeviceRebootMessageTemplate deviceRebootMessageTemplate;
|
private final DeviceRebootMessageTemplate deviceRebootMessageTemplate;
|
||||||
|
|
||||||
|
private final ProcessRebootMessageTemplate processRebootMessageTemplate;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/recall")
|
@PostMapping("/recall")
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("数据补招消息推送")
|
@ApiOperation("数据补招消息推送")
|
||||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||||
public HttpResult<Boolean> recall(@RequestParam RecallMessage message){
|
public HttpResult<Boolean> recall(@RequestBody RecallMessage message){
|
||||||
String methodDescribe = getMethodDescribe("recall");
|
String methodDescribe = getMethodDescribe("recall");
|
||||||
BaseMessage baseMessage = new BaseMessage();
|
BaseMessage baseMessage = new BaseMessage();
|
||||||
baseMessage.setMessageBody(JSONObject.toJSONString(message));
|
baseMessage.setMessageBody(JSONObject.toJSONString(message));
|
||||||
@@ -59,4 +63,16 @@ public class ProduceController extends BaseController {
|
|||||||
deviceRebootMessageTemplate.sendMember(baseMessage);
|
deviceRebootMessageTemplate.sendMember(baseMessage);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/askRestartProcess")
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("请求前置重启设备消息推送")
|
||||||
|
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||||
|
public HttpResult<Boolean> askRestartProcess(@RequestBody ProcessRebootMessage message){
|
||||||
|
String methodDescribe = getMethodDescribe("recall");
|
||||||
|
BaseMessage baseMessage = new BaseMessage();
|
||||||
|
baseMessage.setMessageBody(JSONObject.toJSONString(message));
|
||||||
|
processRebootMessageTemplate.sendMember(baseMessage);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.njcn.message.produce.template;
|
||||||
|
|
||||||
|
import com.njcn.message.constant.BusinessResource;
|
||||||
|
import com.njcn.message.constant.BusinessTopic;
|
||||||
|
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||||
|
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||||
|
import org.apache.rocketmq.client.producer.SendResult;
|
||||||
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/8/11 15:28
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class ProcessRebootMessageTemplate extends RocketMQEnhanceTemplate {
|
||||||
|
|
||||||
|
public ProcessRebootMessageTemplate(RocketMQTemplate template) {
|
||||||
|
super(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SendResult sendMember(BaseMessage baseMessage) {
|
||||||
|
baseMessage.setSource(BusinessResource.WEB_RESOURCE);
|
||||||
|
baseMessage.setKey("Test_Keys");
|
||||||
|
return send(BusinessTopic.PROCESS_TOPIC,"Test_Tag", baseMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user