Commit 5c6dd7d6 authored by 赵啸非's avatar 赵啸非

修改消息组件

parent a658a419
...@@ -56,30 +56,6 @@ public class ConsumerService { ...@@ -56,30 +56,6 @@ public class ConsumerService {
for (TbQueueMsg item : msgs) { for (TbQueueMsg item : msgs) {
//todo //todo
// Message innerMsg = new Message();
// TbQueueMsgHeaders headMap = item.getHeaders();
// int messageProtocl = headMap.get(MessageHeader.MESSAGEPROTOCOL)[0];
// Map<String, Object> headers = new HashMap<>();
// innerMsg.setPayload(item.getData());
// headers.put(MessageHeader.MESSAGEPROTOCOL, messageProtocl);
// innerMsg.setStoreTime(DateUtils.getCurrDate().getTime());
// if(messageProtocl== MsgTypeEnum.MSG_SYSTEM.getValue()){
// innerMsg.setHeaders(headers);
// sendSysMessage2Cluster(innerMsg);
// }else{
// String clientId = MixAll.convertByteS2Str(headMap.get(MessageHeader.CLIENTID));
// int messageType = headMap.get(MessageHeader.MESSAGETYPE)[0];
// String topic = MixAll.convertByteS2Str(headMap.get(MessageHeader.TOPIC));
// int qos = headMap.get(MessageHeader.QOS)[0];
//
// innerMsg.setClientId(clientId);
// innerMsg.setType(Message.Type.valueOf(messageType));
// headers.put(MessageHeader.TOPIC, topic);
// headers.put(MessageHeader.QOS, qos);
// headers.put(MessageHeader.RETAIN, false);
// headers.put(MessageHeader.DUP, false);
// innerMsg.setHeaders(headers);
// sendContrlMessage2Cluster(innerMsg);
// } // }
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -8,16 +8,29 @@ import java.util.Optional; ...@@ -8,16 +8,29 @@ import java.util.Optional;
@Data @Data
public class TopicPartitionInfo { public class TopicPartitionInfo {
private String topic; /**
private Integer partition; * topic名称
*/
private String fullTopicName; private String topic;
/**
* 分区,kafka存在
*/
private Integer partition;
/**
* 交换机名称,rabbmitmq存在
*/
private String exchangeName;
/**
* 带分区的topic
*/
private String fullTopicName;
@Builder @Builder
public TopicPartitionInfo(String topic, Integer partition) { public TopicPartitionInfo(String topic, Integer partition, String exchangeName) {
this.topic = topic; this.topic = topic;
this.partition = partition; this.partition = partition;
this.exchangeName = exchangeName;
String tmp = topic; String tmp = topic;
if (partition != null) { if (partition != null) {
tmp += "." + partition; tmp += "." + partition;
...@@ -26,7 +39,7 @@ public class TopicPartitionInfo { ...@@ -26,7 +39,7 @@ public class TopicPartitionInfo {
} }
public TopicPartitionInfo newByTopic(String topic) { public TopicPartitionInfo newByTopic(String topic) {
return new TopicPartitionInfo(topic, this.partition); return new TopicPartitionInfo(topic, this.partition, "");
} }
public String getTopic() { public String getTopic() {
......
package com.mortals.xhx.queue.kafka; package com.mortals.xhx.queue.kafka;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.queue.TbQueueConsumer; import com.mortals.xhx.queue.TbQueueConsumer;
import com.mortals.xhx.queue.TbQueueMsg; import com.mortals.xhx.queue.TbQueueMsg;
import com.mortals.xhx.queue.TopicPartitionInfo; import com.mortals.xhx.queue.TopicPartitionInfo;
...@@ -40,19 +41,19 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i ...@@ -40,19 +41,19 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i
@Override @Override
public void subscribe() { public void subscribe() {
log.info("enqueue topic subscribe {} ", topic);
if (stopped) { if (stopped) {
log.error("trying subscribe, but consumer stopped for topic {}", topic); log.error("consumer 线程已停止 topic {}", topic);
return; return;
} }
subscribeQueue.add(Collections.singleton(new TopicPartitionInfo(topic, null))); subscribeQueue.add(Collections.singleton(new TopicPartitionInfo(topic, null,"")));
} }
@Override @Override
public void subscribe(Set<TopicPartitionInfo> partitions) { public void subscribe(Set<TopicPartitionInfo> partitions) {
log.info("enqueue topics subscribe {} ", partitions); log.info("订阅的topics {} ", JSON.toJSONString(partitions));
if (stopped) { if (stopped) {
log.error("trying subscribe, but consumer stopped for topic {}", topic); log.error("订阅服务已停止,topic {}", topic);
return; return;
} }
subscribeQueue.add(partitions); subscribeQueue.add(partitions);
...@@ -60,7 +61,6 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i ...@@ -60,7 +61,6 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i
@Override @Override
public List<T> poll(long durationInMillis) { public List<T> poll(long durationInMillis) {
List<R> records; List<R> records;
long startNanos = System.nanoTime(); long startNanos = System.nanoTime();
if (stopped) { if (stopped) {
...@@ -73,7 +73,6 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i ...@@ -73,7 +73,6 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i
if (consumerLock.isLocked()) { if (consumerLock.isLocked()) {
log.error("poll. consumerLock is locked. will wait with no timeout. it looks like a race conditions or deadlock", new RuntimeException("stacktrace")); log.error("poll. consumerLock is locked. will wait with no timeout. it looks like a race conditions or deadlock", new RuntimeException("stacktrace"));
} }
consumerLock.lock(); consumerLock.lock();
try { try {
//更新订阅的主题 //更新订阅的主题
...@@ -169,5 +168,4 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i ...@@ -169,5 +168,4 @@ public abstract class AbstractTbQueueConsumerTemplate<R, T extends TbQueueMsg> i
abstract protected void doUnsubscribe(); abstract protected void doUnsubscribe();
} }
...@@ -56,9 +56,8 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb ...@@ -56,9 +56,8 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
GetResponse getResponse = channel.basicGet(queue, true); GetResponse getResponse = channel.basicGet(queue, true);
return getResponse; return getResponse;
} catch (IOException e) { } catch (IOException e) {
// log.error("Failed to get messages from queue: [{}]" , queue); log.error("Failed to get messages from queue: [{}]" , queue,e);
return null; return null;
// throw new RuntimeException("Failed to get messages from queue." , e);
} }
}).filter(Objects::nonNull).collect(Collectors.toList()); }).filter(Objects::nonNull).collect(Collectors.toList());
if (result.size() > 0) { if (result.size() > 0) {
...@@ -73,7 +72,6 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb ...@@ -73,7 +72,6 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
queues = partitions.stream() queues = partitions.stream()
.map(TopicPartitionInfo::getFullTopicName) .map(TopicPartitionInfo::getFullTopicName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
//queues.forEach(admin::createTopicIfNotExists);
} }
@Override @Override
......
...@@ -6,6 +6,7 @@ import com.google.common.util.concurrent.MoreExecutors; ...@@ -6,6 +6,7 @@ import com.google.common.util.concurrent.MoreExecutors;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.mortals.xhx.queue.*; import com.mortals.xhx.queue.*;
import com.rabbitmq.client.AMQP; import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection; import com.rabbitmq.client.Connection;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -16,15 +17,37 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -16,15 +17,37 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/**
* rabbmit 消息生产模板
*
* @author: zxfei
* @date: 2022/4/25 16:10
*/
@Slf4j @Slf4j
public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueueProducer<T> { public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueueProducer<T> {
/**
* defaultTopic
*/
private String defaultTopic; private String defaultTopic;
/**
* rabbmit设置
*/
private TbRabbitMqSettings rabbitMqSettings; private TbRabbitMqSettings rabbitMqSettings;
/**
* 线程执行器
*/
private ListeningExecutorService producerExecutor; private ListeningExecutorService producerExecutor;
/**
* 通道
*/
private Channel channel; private Channel channel;
/**
* 连接器
*/
private Connection connection; private Connection connection;
private final Gson gson = new Gson(); /**
* topic组
*/
private final Set<TopicPartitionInfo> topics = ConcurrentHashMap.newKeySet(); private final Set<TopicPartitionInfo> topics = ConcurrentHashMap.newKeySet();
public TbRabbitMqProducerTemplate(TbRabbitMqSettings rabbitMqSettings, String defaultTopic) { public TbRabbitMqProducerTemplate(TbRabbitMqSettings rabbitMqSettings, String defaultTopic) {
...@@ -35,8 +58,7 @@ public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueue ...@@ -35,8 +58,7 @@ public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueue
connection = rabbitMqSettings.getConnectionFactory().newConnection(); connection = rabbitMqSettings.getConnectionFactory().newConnection();
channel = connection.createChannel(); channel = connection.createChannel();
} catch (IOException | TimeoutException e) { } catch (IOException | TimeoutException e) {
log.error("Failed to create connection.", e); log.error("rabbmit创建连接失败!", e);
// throw new RuntimeException("Failed to create connection." , e);
} }
} }
...@@ -55,23 +77,19 @@ public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueue ...@@ -55,23 +77,19 @@ public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueue
public void send(TopicPartitionInfo tpi, T msg, TbQueueCallback callback) { public void send(TopicPartitionInfo tpi, T msg, TbQueueCallback callback) {
Boolean topicIfNotExist = createTopicIfNotExist(tpi); Boolean topicIfNotExist = createTopicIfNotExist(tpi);
AMQP.BasicProperties properties = new AMQP.BasicProperties(); AMQP.BasicProperties properties = new AMQP.BasicProperties();
// .builder()
// .contentType("application/json")
// .deliveryMode(2) // 消息是否持久化,1未持久,2持久
// .contentEncoding("UTF-8") // 编码方式
// .expiration("100000") // 过期时间单位毫秒
// .build();
try { try {
if (!topicIfNotExist) { if (!topicIfNotExist) {
channel.queueDeclare(tpi.getTopic(), true, false, false, null); channel.queueDeclare(tpi.getTopic(), true, false, false, null);
} }
//channel.basicPublish(rabbitMqSettings.getExchangeName(), tpi.getFullTopicName(), properties, gson.toJson(new DefaultTbQueueMsg(msg)).getBytes()); if (!innerExists(tpi.getExchangeName(), channel)) {
channel.basicPublish(rabbitMqSettings.getExchangeName(), tpi.getFullTopicName(), properties, JSON.toJSONString(new DefaultTbQueueMsg(msg)).getBytes()); channel = connection.createChannel();
channel.exchangeDeclare(tpi.getExchangeName(), BuiltinExchangeType.DIRECT);
}
channel.basicPublish(tpi.getExchangeName(), tpi.getFullTopicName(), properties, JSON.toJSONString(new DefaultTbQueueMsg(msg)).getBytes());
if (callback != null) { if (callback != null) {
callback.onSuccess(null); callback.onSuccess(null);
} }
} catch ( } catch (IOException e) {
IOException e) {
log.error("Failed publish message: [{}].", msg, e); log.error("Failed publish message: [{}].", msg, e);
if (callback != null) { if (callback != null) {
callback.onFailure(e); callback.onFailure(e);
...@@ -108,4 +126,15 @@ public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueue ...@@ -108,4 +126,15 @@ public class TbRabbitMqProducerTemplate<T extends TbQueueMsg> implements TbQueue
topics.add(tpi); topics.add(tpi);
return false; return false;
} }
private boolean innerExists(String exchangeName, Channel outerChannel) {
boolean result = true;
try {
outerChannel.exchangeDeclarePassive(exchangeName);
} catch (IOException e) {
result = false;
}
return result;
}
} }
...@@ -98,7 +98,7 @@ export default { ...@@ -98,7 +98,7 @@ export default {
}); });
let _this = this; let _this = this;
const getsocketData = (e) => { const getsocketData = (e) => {i
// 创建接收消息函数 // 创建接收消息函数
const data = e && e.detail.data; const data = e && e.detail.data;
......
...@@ -16,6 +16,7 @@ public class P6spySqlFormatConfig implements MessageFormattingStrategy { ...@@ -16,6 +16,7 @@ public class P6spySqlFormatConfig implements MessageFormattingStrategy {
@Override @Override
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) { public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
return StringUtils.isNotBlank(sql) ? DateUtils.getCurrStrDateTime() return StringUtils.isNotBlank(sql) ? DateUtils.getCurrStrDateTime()
+ " | 耗时 " + elapsed + " ms | SQL:" + StringUtils.LF + sql.replaceAll("[\\s]+", StringUtils.SPACE) + ";" : ""; + " | 耗时 " + elapsed + " ms | SQL:" + StringUtils.LF + sql.replaceAll("[\\s]+", StringUtils.SPACE) + ";" : "";
} }
......
...@@ -148,7 +148,7 @@ public class DeviceApiController { ...@@ -148,7 +148,7 @@ public class DeviceApiController {
* @return * @return
*/ */
@PostMapping("upload") @PostMapping("upload")
@DeviceAuth //@DeviceAuth
public String upload(@RequestBody UploadDeviceReq req) { public String upload(@RequestBody UploadDeviceReq req) {
log.info("【设备数据上报】【请求体】--> " + JSONObject.toJSONString(req)); log.info("【设备数据上报】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp<String> rsp = new ApiResp<>(); ApiResp<String> rsp = new ApiResp<>();
...@@ -159,7 +159,19 @@ public class DeviceApiController { ...@@ -159,7 +159,19 @@ public class DeviceApiController {
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceNum()); DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceNum());
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
//将上报信息转发到mq中 //将上报信息转发到mq中
TopicPartitionInfo info = TopicPartitionInfo.builder().topic(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceMac()).build();
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!");
}
// authInfo.setHost(platformEntity.getPlatformSn());
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!");
}
String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceMac()).build();
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders(); TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, Constant.MESSAGETYPE_HEARTBEAT); header.put(MessageHeader.MESSAGETYPE, Constant.MESSAGETYPE_HEARTBEAT);
ApiResp<String> sendDeviceMessageResp = deviceService.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(req), null); ApiResp<String> sendDeviceMessageResp = deviceService.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(req), null);
......
...@@ -59,7 +59,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -59,7 +59,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
//订阅所有已几快活设备 //订阅所有已几快活设备
Set<TopicPartitionInfo> topicPartitionInfoSet = deviceService.find(new DeviceQuery().active(ActiveEnum.已激活.getValue()).status(StatusEnum.启用.getValue())).stream() Set<TopicPartitionInfo> topicPartitionInfoSet = deviceService.find(new DeviceQuery().active(ActiveEnum.已激活.getValue()).status(StatusEnum.启用.getValue())).stream()
.map(item -> .map(item ->
new TopicPartitionInfo(Constant.UPLOAD_TOPIC + item.getDeviceMac(), null) new TopicPartitionInfo(Constant.UPLOAD_TOPIC + item.getDeviceMac(), null,null)
).collect(Collectors.toSet()); ).collect(Collectors.toSet());
mainConsumer.subscribe(topicPartitionInfoSet); mainConsumer.subscribe(topicPartitionInfoSet);
log.info("消费线程订阅设备上报消息成功!:" + JSON.toJSONString(topicPartitionInfoSet)); log.info("消费线程订阅设备上报消息成功!:" + JSON.toJSONString(topicPartitionInfoSet));
......
...@@ -8,360 +8,380 @@ import com.mortals.framework.annotation.Excel; ...@@ -8,360 +8,380 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.vo.DeviceVo; import com.mortals.xhx.module.device.model.vo.DeviceVo;
/** /**
* 设备实体对象 * 设备实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-04-25 * @date 2022-04-25
*/ */
public class DeviceEntity extends DeviceVo { public class DeviceEntity extends DeviceVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 设备名称 * 设备名称
*/ */
@Excel(name = "设备名称") @Excel(name = "设备名称")
private String deviceName; private String deviceName;
/** /**
* 设备编码 * 设备编码
*/ */
private String deviceCode; private String deviceCode;
/** /**
* 站点编号(来源基础服务平台) * 站点编号,来源基础服务平台
*/ */
private String siteCode; private String siteCode;
/** /**
* 设备的MAC地址 * 站点名称
*/ */
private String siteName;
/**
* 设备的MAC地址
*/
private String deviceMac; private String deviceMac;
/** /**
* 平台系统Id * 平台系统Id
*/ */
private Long platformId; private Long platformId;
/** /**
* 平台系统名称 * 平台系统名称
*/ */
private String platformName; private String platformName;
/** /**
* 产品Id * 产品Id
*/ */
private Long productId; private Long productId;
/** /**
* 产品Id * 产品名称
*/ */
private String productName; private String productName;
/** /**
* 设备生产厂商ID * 设备生产厂商ID
*/ */
private Long deviceFirmId; private Long deviceFirmId;
/** /**
* 设备生产厂商名称 * 设备生产厂商名称
*/ */
@Excel(name = "设备生产厂商名称") @Excel(name = "设备生产厂商名称")
private String deviceFirmname; private String deviceFirmname;
/** /**
* 设备访问ip * 设备访问ip
*/ */
private String ip; private String ip;
/** /**
* 中心设备编码 * 中心设备编码
*/ */
private String centernum; private String centernum;
/** /**
* 端口 * 端口
*/ */
private String port; private String port;
/** /**
* 在线状态 (0.离线,1.在线) * 在线状态 (0.离线,1.在线)
*/ */
@Excel(name = "在线状态 ", readConverterExp = "0=离线,1=在线")
private Integer deviceOnlineStatus; private Integer deviceOnlineStatus;
/** /**
* 启用状态 (0.停止,1.启用) * 启用状态 (0.停止,1.启用)
*/ */
private Integer status; private Integer status;
/** /**
* 激活状态 (0.未激活,1.已激活) * 激活状态 (0.未激活,1.已激活)
*/ */
@Excel(name = "激活状态 ", readConverterExp = "0=未激活,1=已激活")
private Integer active; private Integer active;
/** /**
* 备注 * 备注
*/ */
private String deviceRemark; private String deviceRemark;
/** /**
* 最近上线时间 * 最近上线时间
*/ */
private Date onlineTime; private Date onlineTime;
/** /**
* 最近离线时间 * 最近离线时间
*/ */
private Date offlineTime; private Date offlineTime;
public DeviceEntity(){} public DeviceEntity(){}
/** /**
* 获取 设备名称 * 获取 设备名称
* @return String * @return String
*/ */
public String getDeviceName(){ public String getDeviceName(){
return deviceName; return deviceName;
} }
/** /**
* 设置 设备名称 * 设置 设备名称
* @param deviceName * @param deviceName
*/ */
public void setDeviceName(String deviceName){ public void setDeviceName(String deviceName){
this.deviceName = deviceName; this.deviceName = deviceName;
} }
/** /**
* 获取 设备编码 * 获取 设备编码
* @return String * @return String
*/ */
public String getDeviceCode(){ public String getDeviceCode(){
return deviceCode; return deviceCode;
} }
/** /**
* 设置 设备编码 * 设置 设备编码
* @param deviceCode * @param deviceCode
*/ */
public void setDeviceCode(String deviceCode){ public void setDeviceCode(String deviceCode){
this.deviceCode = deviceCode; this.deviceCode = deviceCode;
} }
/** /**
* 获取 站点编号(来源基础服务平台) * 获取 站点编号,来源基础服务平台
* @return String * @return String
*/ */
public String getSiteCode(){ public String getSiteCode(){
return siteCode; return siteCode;
} }
/** /**
* 设置 站点编号(来源基础服务平台) * 设置 站点编号,来源基础服务平台
* @param siteCode * @param siteCode
*/ */
public void setSiteCode(String siteCode){ public void setSiteCode(String siteCode){
this.siteCode = siteCode; this.siteCode = siteCode;
} }
/** /**
* 获取 设备的MAC地址 * 获取 站点名称
* @return String * @return String
*/ */
public String getSiteName(){
return siteName;
}
/**
* 设置 站点名称
* @param siteName
*/
public void setSiteName(String siteName){
this.siteName = siteName;
}
/**
* 获取 设备的MAC地址
* @return String
*/
public String getDeviceMac(){ public String getDeviceMac(){
return deviceMac; return deviceMac;
} }
/** /**
* 设置 设备的MAC地址 * 设置 设备的MAC地址
* @param deviceMac * @param deviceMac
*/ */
public void setDeviceMac(String deviceMac){ public void setDeviceMac(String deviceMac){
this.deviceMac = deviceMac; this.deviceMac = deviceMac;
} }
/** /**
* 获取 平台系统Id * 获取 平台系统Id
* @return Long * @return Long
*/ */
public Long getPlatformId(){ public Long getPlatformId(){
return platformId; return platformId;
} }
/** /**
* 设置 平台系统Id * 设置 平台系统Id
* @param platformId * @param platformId
*/ */
public void setPlatformId(Long platformId){ public void setPlatformId(Long platformId){
this.platformId = platformId; this.platformId = platformId;
} }
/** /**
* 获取 平台系统名称 * 获取 平台系统名称
* @return String * @return String
*/ */
public String getPlatformName(){ public String getPlatformName(){
return platformName; return platformName;
} }
/** /**
* 设置 平台系统名称 * 设置 平台系统名称
* @param platformName * @param platformName
*/ */
public void setPlatformName(String platformName){ public void setPlatformName(String platformName){
this.platformName = platformName; this.platformName = platformName;
} }
/** /**
* 获取 产品Id * 获取 产品Id
* @return Long * @return Long
*/ */
public Long getProductId(){ public Long getProductId(){
return productId; return productId;
} }
/** /**
* 设置 产品Id * 设置 产品Id
* @param productId * @param productId
*/ */
public void setProductId(Long productId){ public void setProductId(Long productId){
this.productId = productId; this.productId = productId;
} }
/** /**
* 获取 产品Id * 获取 产品名称
* @return String * @return String
*/ */
public String getProductName(){ public String getProductName(){
return productName; return productName;
} }
/** /**
* 设置 产品Id * 设置 产品名称
* @param productName * @param productName
*/ */
public void setProductName(String productName){ public void setProductName(String productName){
this.productName = productName; this.productName = productName;
} }
/** /**
* 获取 设备生产厂商ID * 获取 设备生产厂商ID
* @return Long * @return Long
*/ */
public Long getDeviceFirmId(){ public Long getDeviceFirmId(){
return deviceFirmId; return deviceFirmId;
} }
/** /**
* 设置 设备生产厂商ID * 设置 设备生产厂商ID
* @param deviceFirmId * @param deviceFirmId
*/ */
public void setDeviceFirmId(Long deviceFirmId){ public void setDeviceFirmId(Long deviceFirmId){
this.deviceFirmId = deviceFirmId; this.deviceFirmId = deviceFirmId;
} }
/** /**
* 获取 设备生产厂商名称 * 获取 设备生产厂商名称
* @return String * @return String
*/ */
public String getDeviceFirmname(){ public String getDeviceFirmname(){
return deviceFirmname; return deviceFirmname;
} }
/** /**
* 设置 设备生产厂商名称 * 设置 设备生产厂商名称
* @param deviceFirmname * @param deviceFirmname
*/ */
public void setDeviceFirmname(String deviceFirmname){ public void setDeviceFirmname(String deviceFirmname){
this.deviceFirmname = deviceFirmname; this.deviceFirmname = deviceFirmname;
} }
/** /**
* 获取 设备访问ip * 获取 设备访问ip
* @return String * @return String
*/ */
public String getIp(){ public String getIp(){
return ip; return ip;
} }
/** /**
* 设置 设备访问ip * 设置 设备访问ip
* @param ip * @param ip
*/ */
public void setIp(String ip){ public void setIp(String ip){
this.ip = ip; this.ip = ip;
} }
/** /**
* 获取 中心设备编码 * 获取 中心设备编码
* @return String * @return String
*/ */
public String getCenternum(){ public String getCenternum(){
return centernum; return centernum;
} }
/** /**
* 设置 中心设备编码 * 设置 中心设备编码
* @param centernum * @param centernum
*/ */
public void setCenternum(String centernum){ public void setCenternum(String centernum){
this.centernum = centernum; this.centernum = centernum;
} }
/** /**
* 获取 端口 * 获取 端口
* @return String * @return String
*/ */
public String getPort(){ public String getPort(){
return port; return port;
} }
/** /**
* 设置 端口 * 设置 端口
* @param port * @param port
*/ */
public void setPort(String port){ public void setPort(String port){
this.port = port; this.port = port;
} }
/** /**
* 获取 在线状态 (0.离线,1.在线) * 获取 在线状态 (0.离线,1.在线)
* @return Integer * @return Integer
*/ */
public Integer getDeviceOnlineStatus(){ public Integer getDeviceOnlineStatus(){
return deviceOnlineStatus; return deviceOnlineStatus;
} }
/** /**
* 设置 在线状态 (0.离线,1.在线) * 设置 在线状态 (0.离线,1.在线)
* @param deviceOnlineStatus * @param deviceOnlineStatus
*/ */
public void setDeviceOnlineStatus(Integer deviceOnlineStatus){ public void setDeviceOnlineStatus(Integer deviceOnlineStatus){
this.deviceOnlineStatus = deviceOnlineStatus; this.deviceOnlineStatus = deviceOnlineStatus;
} }
/** /**
* 获取 启用状态 (0.停止,1.启用) * 获取 启用状态 (0.停止,1.启用)
* @return Integer * @return Integer
*/ */
public Integer getStatus(){ public Integer getStatus(){
return status; return status;
} }
/** /**
* 设置 启用状态 (0.停止,1.启用) * 设置 启用状态 (0.停止,1.启用)
* @param status * @param status
*/ */
public void setStatus(Integer status){ public void setStatus(Integer status){
this.status = status; this.status = status;
} }
/** /**
* 获取 激活状态 (0.未激活,1.已激活) * 获取 激活状态 (0.未激活,1.已激活)
* @return Integer * @return Integer
*/ */
public Integer getActive(){ public Integer getActive(){
return active; return active;
} }
/** /**
* 设置 激活状态 (0.未激活,1.已激活) * 设置 激活状态 (0.未激活,1.已激活)
* @param active * @param active
*/ */
public void setActive(Integer active){ public void setActive(Integer active){
this.active = active; this.active = active;
} }
/** /**
* 获取 备注 * 获取 备注
* @return String * @return String
*/ */
public String getDeviceRemark(){ public String getDeviceRemark(){
return deviceRemark; return deviceRemark;
} }
/** /**
* 设置 备注 * 设置 备注
* @param deviceRemark * @param deviceRemark
*/ */
public void setDeviceRemark(String deviceRemark){ public void setDeviceRemark(String deviceRemark){
this.deviceRemark = deviceRemark; this.deviceRemark = deviceRemark;
} }
/** /**
* 获取 最近上线时间 * 获取 最近上线时间
* @return Date * @return Date
*/ */
public Date getOnlineTime(){ public Date getOnlineTime(){
return onlineTime; return onlineTime;
} }
/** /**
* 设置 最近上线时间 * 设置 最近上线时间
* @param onlineTime * @param onlineTime
*/ */
public void setOnlineTime(Date onlineTime){ public void setOnlineTime(Date onlineTime){
this.onlineTime = onlineTime; this.onlineTime = onlineTime;
} }
/** /**
* 获取 最近离线时间 * 获取 最近离线时间
* @return Date * @return Date
*/ */
public Date getOfflineTime(){ public Date getOfflineTime(){
return offlineTime; return offlineTime;
} }
/** /**
* 设置 最近离线时间 * 设置 最近离线时间
* @param offlineTime * @param offlineTime
*/ */
public void setOfflineTime(Date offlineTime){ public void setOfflineTime(Date offlineTime){
this.offlineTime = offlineTime; this.offlineTime = offlineTime;
} }
...@@ -371,7 +391,7 @@ public class DeviceEntity extends DeviceVo { ...@@ -371,7 +391,7 @@ public class DeviceEntity extends DeviceVo {
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -379,7 +399,7 @@ public class DeviceEntity extends DeviceVo { ...@@ -379,7 +399,7 @@ public class DeviceEntity extends DeviceVo {
if (obj instanceof DeviceEntity) { if (obj instanceof DeviceEntity) {
DeviceEntity tmp = (DeviceEntity) obj; DeviceEntity tmp = (DeviceEntity) obj;
if (this.getId() == tmp.getId()) { if (this.getId() == tmp.getId()) {
return true; return true;
} }
} }
return false; return false;
...@@ -390,6 +410,7 @@ public class DeviceEntity extends DeviceVo { ...@@ -390,6 +410,7 @@ public class DeviceEntity extends DeviceVo {
sb.append(",deviceName:").append(getDeviceName()); sb.append(",deviceName:").append(getDeviceName());
sb.append(",deviceCode:").append(getDeviceCode()); sb.append(",deviceCode:").append(getDeviceCode());
sb.append(",siteCode:").append(getSiteCode()); sb.append(",siteCode:").append(getSiteCode());
sb.append(",siteName:").append(getSiteName());
sb.append(",deviceMac:").append(getDeviceMac()); sb.append(",deviceMac:").append(getDeviceMac());
sb.append(",platformId:").append(getPlatformId()); sb.append(",platformId:").append(getPlatformId());
sb.append(",platformName:").append(getPlatformName()); sb.append(",platformName:").append(getPlatformName());
...@@ -411,42 +432,44 @@ public class DeviceEntity extends DeviceVo { ...@@ -411,42 +432,44 @@ public class DeviceEntity extends DeviceVo {
public void initAttrValue(){ public void initAttrValue(){
this.deviceName = ""; this.deviceName = "";
this.deviceCode = "";
this.deviceCode = ""; this.siteCode = "";
this.siteCode = ""; this.siteName = "";
this.deviceMac = ""; this.deviceMac = "";
this.platformId = null; this.platformId = null;
this.platformName = ""; this.platformName = "";
this.productId = null; this.productId = null;
this.productName = ""; this.productName = "";
this.deviceFirmId = null; this.deviceFirmId = null;
this.deviceFirmname = ""; this.deviceFirmname = "";
this.ip = ""; this.ip = "";
this.centernum = ""; this.centernum = "";
this.port = ""; this.port = "";
this.deviceOnlineStatus = 0; this.deviceOnlineStatus = 0;
this.status = 0; this.status = 0;
this.active = 0; this.active = 0;
this.deviceRemark = ""; this.deviceRemark = "";
this.onlineTime = null; this.onlineTime = null;
this.offlineTime = null; this.offlineTime = null;
} }
} }
\ No newline at end of file
...@@ -105,7 +105,7 @@ token: ...@@ -105,7 +105,7 @@ token:
# 令牌自定义标识 # 令牌自定义标识
header: Authorization header: Authorization
# 令牌密钥 # 令牌密钥
secret: abcd1234 secret: 026db82420614469897fcc2dc1b4ce38
# 令牌有效期(默认60分钟) # 令牌有效期(默认60分钟)
expireTime: 60 expireTime: 60
# 令牌前缀 # 令牌前缀
......
...@@ -16,4 +16,7 @@ driverlist=com.mysql.cj.jdbc.Driver ...@@ -16,4 +16,7 @@ driverlist=com.mysql.cj.jdbc.Driver
# 是否开启慢SQL记录 # 是否开启慢SQL记录
outagedetection=true outagedetection=true
# 慢SQL记录标准 秒 # 慢SQL记录标准 秒
outagedetectioninterval=2 outagedetectioninterval=2
\ No newline at end of file
filter=true
exclude=mortals_xhx_task
\ No newline at end of file
...@@ -54,7 +54,7 @@ POST {{baseUrl}}/api/active ...@@ -54,7 +54,7 @@ POST {{baseUrl}}/api/active
Content-Type: application/json Content-Type: application/json
{ {
"deviceNum":"b12345678", "deviceNum":"AB:DD:DF:FD:AD:FA:DA:SS",
"deviceMac":"AB:DD:DF:FD:AD:FA:DA:SS", "deviceMac":"AB:DD:DF:FD:AD:FA:DA:SS",
"action":"active" "action":"active"
} }
...@@ -71,7 +71,7 @@ Content-Type: application/json ...@@ -71,7 +71,7 @@ Content-Type: application/json
Authorization: Bearer {{authToken}} Authorization: Bearer {{authToken}}
{ {
"deviceNum":"a12345678", "deviceNum":"AB:DD:DF:FD:AD:FA:DA:SS",
"action":"upload" "action":"upload"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment