#update
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package com.maibu.common;
|
||||
|
||||
public class CommandConstant {
|
||||
|
||||
public static byte remoteControl = (byte)0x00;
|
||||
|
||||
public static byte heartbeat = (byte)0xff;
|
||||
|
||||
public static byte path = (byte)0x01;
|
||||
|
||||
public static byte status = (byte)0x02;
|
||||
|
||||
public static byte connect = (byte)0x03;
|
||||
|
||||
public static byte interaction = (byte)0x12; //主要用于推送状态消息等
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.maibu.common;
|
||||
|
||||
import com.maibu.core.enums.ConnectionCloseReason;
|
||||
import io.netty.util.AttributeKey;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Constant {
|
||||
|
||||
public static final AttributeKey<String> ATT_DEVICE_ID = AttributeKey.valueOf("deviceId");
|
||||
|
||||
public static final AttributeKey<ConnectionCloseReason> ATT_CLOSE_REASON = AttributeKey.valueOf("closeReason");
|
||||
|
||||
public static final AttributeKey<String> ATT_ORG_ID = AttributeKey.valueOf("orgId");
|
||||
|
||||
public static final AttributeKey<String> ATT_SITE_ID = AttributeKey.valueOf("siteId");
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.maibu.controller;
|
||||
|
||||
import com.maibu.common.CommandConstant;
|
||||
import com.maibu.constant.CommandConstant;
|
||||
import com.maibu.core.controller.BaseController;
|
||||
import com.maibu.core.domain.AjaxResult;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.dto.ObstacleData;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import com.maibu.utils.CommandUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.maibu.controller;
|
||||
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.maibu.core.controller.BaseController;
|
||||
import com.maibu.core.domain.AjaxResult;
|
||||
import com.maibu.core.page.TableDataInfo;
|
||||
import com.maibu.core.business.ErrorIdentificationStandard;
|
||||
import com.maibu.dto.SendCommandDTO;
|
||||
import com.maibu.service.NettyDeviceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -19,26 +20,29 @@ public class NettyDeviceController extends BaseController {
|
||||
private NettyDeviceService nettyDeviceService;
|
||||
|
||||
@GetMapping("/statusHistory")
|
||||
public TableDataInfo statusHistory(DeviceRunningStatusHistory history)
|
||||
{
|
||||
public TableDataInfo statusHistory(DeviceRunningStatusHistory history) {
|
||||
startPage();
|
||||
List<DeviceRunningStatusHistory> list = nettyDeviceService.statusHistory(history);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/getErrorIdentification")
|
||||
public TableDataInfo getErrorIdentification()
|
||||
{
|
||||
public TableDataInfo getErrorIdentification() {
|
||||
startPage();
|
||||
List<ErrorIdentificationStandard> list = nettyDeviceService.allErrorIdentificationStandard();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("/updateErrorIdentification")
|
||||
public AjaxResult updateErrorIdentification(@RequestBody ErrorIdentificationStandard standard)
|
||||
{
|
||||
int i = nettyDeviceService.updateErrorIdentification(standard);
|
||||
public AjaxResult updateErrorIdentification(@RequestBody ErrorIdentificationStandard standard) {
|
||||
int i = nettyDeviceService.updateErrorIdentification(standard);
|
||||
return AjaxResult.success(i);
|
||||
}
|
||||
|
||||
@PostMapping("/sendCommand")
|
||||
public AjaxResult sendCommand(@RequestBody SendCommandDTO command) {
|
||||
nettyDeviceService.sendCommand(command);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.maibu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class SendCommandDTO {
|
||||
|
||||
private String commandType;
|
||||
|
||||
private Map<String,Object> params;
|
||||
|
||||
private List<String> deviceIds;
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.maibu.core.business.dto.DeviceTaskCommandDTO;
|
||||
import com.maibu.core.business.dto.uav.FlightTaskCreateDTO;
|
||||
import com.maibu.core.business.inter.mower.MowerCommandInter;
|
||||
import com.maibu.core.business.inter.uav.UAVCommandInter;
|
||||
import com.maibu.service.DeviceTaskService;
|
||||
|
||||
@Component
|
||||
@@ -16,8 +14,8 @@ public class MowerCommamdHandler implements MowerCommandInter {
|
||||
private DeviceTaskService dService;
|
||||
|
||||
@Override
|
||||
public void createDeviceTask(DeviceTaskCommandDTO dto) {
|
||||
dService.createDeviceTask(dto, "system");
|
||||
public Long createDeviceTask(DeviceTaskCommandDTO dto) {
|
||||
return dService.createDeviceTask(dto, "system");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class InitThread implements ApplicationRunner {
|
||||
if (!CollectionUtils.isEmpty(deviceRunParamList)) {
|
||||
deviceRunParamList.forEach(x -> {
|
||||
Long orgId = x.getOrgId();
|
||||
Long siteId = x.getId();
|
||||
Long siteId = x.getSiteId();
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
if (siteMemory != null) {
|
||||
siteMemory.saveDeviceRunParam(x);
|
||||
@@ -174,7 +174,7 @@ public class InitThread implements ApplicationRunner {
|
||||
if (!CollectionUtils.isEmpty(standadList)) {
|
||||
standadList.forEach(x -> {
|
||||
Long orgId = x.getOrgId();
|
||||
Long siteId = x.getId();
|
||||
Long siteId = x.getSiteId();
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
if (siteMemory != null) {
|
||||
siteMemory.saveErrorIdentificationStandard(x);
|
||||
@@ -186,7 +186,7 @@ public class InitThread implements ApplicationRunner {
|
||||
if (!CollectionUtils.isEmpty(orderModelList)) {
|
||||
orderModelList.forEach(x -> {
|
||||
Long orgId = x.getOrgId();
|
||||
Long siteId = x.getId();
|
||||
Long siteId = x.getSiteId();
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
if (siteMemory != null) {
|
||||
siteMemory.saveOrderModel(x);
|
||||
@@ -198,7 +198,7 @@ public class InitThread implements ApplicationRunner {
|
||||
if (!CollectionUtils.isEmpty(alarmOrderList)) {
|
||||
alarmOrderList.forEach(x -> {
|
||||
Long orgId = x.getOrgId();
|
||||
Long siteId = x.getId();
|
||||
Long siteId = x.getSiteId();
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
if (siteMemory != null) {
|
||||
siteMemory.saveAlarmOrderConfig(x);
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
package com.maibu.manager;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.maibu.core.enums.ConnectorStatus;
|
||||
import com.maibu.core.enums.ConnectorType;
|
||||
import com.maibu.core.business.device.Connector;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备会话管理器
|
||||
* 负责管理设备信息、连接通道、双向绑定关系、状态管理和消息转发
|
||||
*/
|
||||
@Component
|
||||
@Data
|
||||
public class DeviceSessionManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DeviceSessionManager.class);
|
||||
// 设备ID -> 设备对象(业务实体)
|
||||
private final ConcurrentHashMap<String, NettyDevice> deviceMap = new ConcurrentHashMap<>();
|
||||
|
||||
// 设备ID -> Channel(通信通道)
|
||||
private final ConcurrentHashMap<String, Channel> channelMap = new ConcurrentHashMap<>();
|
||||
|
||||
// Channel -> 设备ID(反查)
|
||||
private final ConcurrentHashMap<Channel, String> channelToDeviceIdMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public void clearChannelToDeviceIdMap(String deviceId) {
|
||||
if (StringUtils.isEmpty(deviceId) || CollectionUtils.isEmpty(channelToDeviceIdMap)) {
|
||||
return;
|
||||
}
|
||||
// 获取 entrySet 迭代器,安全遍历+删除
|
||||
Iterator<Map.Entry<Channel, String>> iterator = channelToDeviceIdMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Channel, String> entry = iterator.next();
|
||||
Channel channel = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
// 匹配目标 deviceId
|
||||
if (deviceId.equals(value)) {
|
||||
// 关闭 Channel:捕获 IO 异常,避免单个 Channel 关闭失败影响整体遍历
|
||||
if (channel != null && channel.isActive()) {
|
||||
try {
|
||||
channel.close().syncUninterruptibly(); // 优雅关闭,等待关闭完成
|
||||
} catch (Exception e) {
|
||||
// 记录日志,不中断后续操作
|
||||
logger.error("关闭 Channel 失败", e);
|
||||
}
|
||||
}
|
||||
// 关键:使用迭代器的 remove() 方法,安全移除键值对,不会触发并发修改异常
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 注册设备连接(设备上线)
|
||||
*
|
||||
* @param deviceId 设备ID
|
||||
* @param channel 通信通道
|
||||
* @param deviceType 设备类型(MASTER/SLAVE)
|
||||
*/
|
||||
public void registerDevice(String deviceId, Channel channel, ConnectorType deviceType, ConnectorStatus status, String slaveId) {
|
||||
NettyDevice nettyDevice = deviceMap.computeIfAbsent(deviceId, id -> new NettyDevice(id, deviceType));
|
||||
nettyDevice.setChannel(channel);
|
||||
nettyDevice.setConnectorStatus(status); // 默认上线即ACTIVE
|
||||
nettyDevice.setCurrentSlaveId(slaveId);
|
||||
nettyDevice.setLatestLoginTime(System.currentTimeMillis());
|
||||
deviceMap.put(deviceId, nettyDevice);
|
||||
channelMap.put(deviceId, channel);
|
||||
channelToDeviceIdMap.put(channel, deviceId);
|
||||
System.out.println("Registered device: " + deviceId + " type: " + deviceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上位机绑定下位机,建立双向绑定关系
|
||||
*
|
||||
* @param masterId 上位机设备ID
|
||||
* @param slaveId 下位机设备ID
|
||||
*/
|
||||
public void bindConnector(String masterId, String slaveId) {
|
||||
NettyDevice master = deviceMap.get(masterId);
|
||||
if (master == null) return;
|
||||
NettyDevice slave = deviceMap.computeIfAbsent(slaveId, id -> new NettyDevice(id, ConnectorType.SLAVE));
|
||||
master.addConnectedDevice(slave);
|
||||
System.out.println("Bind connectors for master " + masterId + " and slave " + slaveId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备ID获取设备对象
|
||||
*/
|
||||
public NettyDevice getDevice(String deviceId) {
|
||||
return deviceMap.get(deviceId);
|
||||
}
|
||||
|
||||
// 模糊匹配
|
||||
public List<NettyDevice> getDevicesLike(String query) {
|
||||
return deviceMap.values().stream()
|
||||
.filter(device -> device.getConnectorId().contains(query))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public List<NettyDevice> getSlaveControl(String slaveId) {
|
||||
// 获取所有连接的主机 且是active状态的
|
||||
return deviceMap.values().stream()
|
||||
.filter(device -> ObjectUtil.equals(device.getCurrentSlaveId(), slaveId)
|
||||
&& ConnectorStatus.ACTIVE.equals(device.getConnectorStatus()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public List<NettyDevice> getAllSlaveControl(String slaveId) {
|
||||
// 获取所有连接的主机 不区分状态
|
||||
return deviceMap.values().stream()
|
||||
.filter(device -> ObjectUtil.equals(device.getCurrentSlaveId(), slaveId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public NettyDevice getCurrentControl(String slaveId) {
|
||||
// 获取所有连接的主机 不区分状态
|
||||
return deviceMap.values().stream()
|
||||
.filter(device -> ObjectUtil.equals(device.getCurrentSlaveId(), slaveId)
|
||||
&& ConnectorStatus.ACTIVE.equals(device.getConnectorStatus()))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
|
||||
/// 模糊匹配
|
||||
public NettyDevice getUserControl(String userName) {
|
||||
return deviceMap.values().stream()
|
||||
.filter(device -> device.getConnectorId().contains(userName)
|
||||
&& ConnectorStatus.ACTIVE.equals(device.getConnectorStatus()))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备ID获取Channel
|
||||
*/
|
||||
public Channel getChannel(String deviceId) {
|
||||
return channelMap.get(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Channel反查设备ID
|
||||
*/
|
||||
public String getDeviceIdByChannel(Channel channel) {
|
||||
return channelToDeviceIdMap.get(channel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据从机查控制的主机
|
||||
*/
|
||||
public NettyDevice getMasterBySlaveId(String slaveId) {
|
||||
return deviceMap.values().stream().filter(x -> Objects.equals(x.getCurrentSlaveId(), slaveId)
|
||||
&& ConnectorStatus.ACTIVE.equals(x.getConnectorStatus())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据从机查所有主机
|
||||
*/
|
||||
public List<NettyDevice> getMastersBySlaveId(String slaveId) {
|
||||
return deviceMap.values().stream().filter(x -> Objects.equals(x.getCurrentSlaveId(), slaveId)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除设备连接(设备下线)
|
||||
*/
|
||||
public void removeDevice(String deviceId) {
|
||||
NettyDevice nettyDevice = deviceMap.remove(deviceId);
|
||||
// Channel channel = channelMap.remove(deviceId);
|
||||
clearChannelToDeviceIdMap(deviceId);
|
||||
// if (channel != null) {
|
||||
// channelToDeviceIdMap.remove(channel);
|
||||
// channel.close();
|
||||
// }
|
||||
if (nettyDevice != null) {
|
||||
// 仅当设备是上位机时,才解绑绑定关系
|
||||
if (nettyDevice.getDeviceType() == ConnectorType.MASTER) {
|
||||
for (Connector connected : new HashSet<>(nettyDevice.getConnectedConnectors())) {
|
||||
nettyDevice.removeConnectedDevice(connected);
|
||||
}
|
||||
} else {
|
||||
// 如果是下位机,则保留绑定关系,只清理channel和状态
|
||||
nettyDevice.setChannel(null);
|
||||
nettyDevice.setConnectorStatus(ConnectorStatus.DISABLED); // 或者设置为离线状态
|
||||
// 注意:此时device仍留在deviceMap中
|
||||
nettyDevice.setLatestStatus(null);
|
||||
deviceMap.put(deviceId, nettyDevice);
|
||||
}
|
||||
System.out.println("Removed device: " + deviceId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断设备是否在线
|
||||
*/
|
||||
public boolean isOnline(String deviceId) {
|
||||
Channel ch = channelMap.get(deviceId);
|
||||
return ch != null && ch.isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断设备是否允许发送消息(ACTIVE状态才允许)
|
||||
*/
|
||||
public boolean canSend(String deviceId) {
|
||||
NettyDevice nettyDevice = deviceMap.get(deviceId);
|
||||
return nettyDevice != null && nettyDevice.canSend();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断设备是否允许接收消息(非DISABLED状态才允许)
|
||||
*/
|
||||
public boolean canReceive(String deviceId) {
|
||||
NettyDevice nettyDevice = deviceMap.get(deviceId);
|
||||
return nettyDevice != null && nettyDevice.canReceive();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.maibu.netty.handler;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -10,11 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.maibu.common.CommandConstant;
|
||||
import com.maibu.constant.CommandConstant;
|
||||
import com.maibu.core.business.device.Connector;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.core.enums.ConnectorType;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -36,7 +36,10 @@ public class CommandForwardHandler extends SimpleChannelInboundHandler<String> {
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
Channel currentChannel = ctx.channel();
|
||||
byte[] bytes = Hex.decodeHex(msg.toCharArray());
|
||||
if (bytes.length > 3 && (bytes[2] == CommandConstant.remoteControl || bytes[2] == CommandConstant.path || bytes[2] == CommandConstant.status)) {
|
||||
if (bytes.length > 3 && (bytes[2] == CommandConstant.remoteControl
|
||||
|| bytes[2] == CommandConstant.path
|
||||
|| bytes[2] == CommandConstant.status
|
||||
)) {
|
||||
|
||||
String senderDeviceId = deviceSessionManager.getDeviceIdByChannel(currentChannel);
|
||||
NettyDevice senderNettyDevice =
|
||||
|
||||
@@ -7,7 +7,13 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.maibu.constant.Constant;
|
||||
import com.maibu.core.business.DeviceRunParam;
|
||||
import com.maibu.mapper.DeviceRunParamMapper;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import com.maibu.memory.SiteMemory;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
@@ -17,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.maibu.common.CommandConstant;
|
||||
import com.maibu.constant.CommandConstant;
|
||||
import com.maibu.common.NettyCacheKey;
|
||||
import com.maibu.core.business.DeviceRunStatistics;
|
||||
import com.maibu.core.business.DeviceRunningStatusHistory;
|
||||
@@ -30,7 +36,6 @@ import com.maibu.core.redis.RedisCache;
|
||||
import com.maibu.dto.WebStatusMessageDTO;
|
||||
import com.maibu.influxdb.MowerRealTimeData;
|
||||
import com.maibu.influxdb.util.InfluxSqlBuilder;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
import com.maibu.mqtt.MqttTopic;
|
||||
import com.maibu.utils.json.JsonUtils;
|
||||
@@ -55,6 +60,9 @@ public class DataToDataBaseHandler extends SimpleChannelInboundHandler<String> {
|
||||
@Autowired
|
||||
private WebsocketMesDispather websocketMesDispather;
|
||||
|
||||
@Autowired
|
||||
private DeviceRunParamMapper deviceRunParamMapper;
|
||||
|
||||
private static final Long recordInterval = 5000L; // 5秒记录一次
|
||||
|
||||
// private static final Long pushInterval = 500L; // 0.5秒推送一次
|
||||
@@ -136,6 +144,15 @@ public class DataToDataBaseHandler extends SimpleChannelInboundHandler<String> {
|
||||
latestStatus.setWorkArea(Double.valueOf(workArea));
|
||||
nettyDevice.setLatestStatus(latestStatus);
|
||||
}
|
||||
} else if (bytes[2] == CommandConstant.readConfig) {
|
||||
DeviceRunParam runParam = DeviceRunParam.fromBytes(bytes);
|
||||
logger.debug("收到返回的设备运行参数: {}", JsonUtils.toJsonString(runParam));
|
||||
CompletableFuture<DeviceRunParam> future =
|
||||
ctx.channel().attr(Constant.READ_CONFIG_KEY).get();
|
||||
if (future != null) {
|
||||
future.complete(runParam);
|
||||
ctx.channel().attr(Constant.READ_CONFIG_KEY).set(null);
|
||||
}
|
||||
}
|
||||
ctx.fireChannelRead(msg);
|
||||
} catch (Exception e) {
|
||||
@@ -143,6 +160,7 @@ public class DataToDataBaseHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public WebStatusMessageDTO createWebDeviceStatusMessage(String[] split) {
|
||||
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
||||
List<DeviceStatusDetail> transferData = transferStatusData(split);
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
@@ -17,8 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.maibu.common.CommandConstant;
|
||||
import com.maibu.common.Constant;
|
||||
import com.maibu.constant.CommandConstant;
|
||||
import com.maibu.constant.Constant;
|
||||
import com.maibu.core.business.Device;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.core.business.inter.WebsocketMesDispather;
|
||||
@@ -37,7 +38,6 @@ import com.maibu.dto.DeviceRequestDTO;
|
||||
import com.maibu.dto.DeviceRespondDTO;
|
||||
import com.maibu.dto.DeviceStatusChangeDTO;
|
||||
import com.maibu.dto.DeviceTaskStatusMessageDTO;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.mapper.DeviceRunStatisticsMapper;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
import com.maibu.mqtt.MqttTopic;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.maibu.netty.handler;
|
||||
|
||||
|
||||
import com.maibu.common.Constant;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.constant.Constant;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.maibu.netty.handler;
|
||||
|
||||
import com.maibu.common.CommandConstant;
|
||||
import com.maibu.common.Constant;
|
||||
import com.maibu.constant.CommandConstant;
|
||||
import com.maibu.constant.Constant;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
@@ -2,10 +2,14 @@ package com.maibu.scheduled;
|
||||
|
||||
import com.maibu.common.NettyCacheKey;
|
||||
import com.maibu.core.business.DevicePlan;
|
||||
import com.maibu.core.business.DeviceRunParam;
|
||||
import com.maibu.core.business.DeviceStatusRecordDTO;
|
||||
import com.maibu.core.redis.RedisCache;
|
||||
import com.maibu.mapper.DeviceStatusHistoryMapper;
|
||||
import com.maibu.memory.SiteMemory;
|
||||
import com.maibu.utils.json.JsonUtils;
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -70,4 +74,21 @@ public class ScheduledTask {
|
||||
}
|
||||
System.out.println("0点定时刷新状态执行完成");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws DecoderException {
|
||||
String hex = "AB AA 05 88 4D 43 37 30 30 50 4C 55 53 2D 43 4E 2D 4A 53 2D 31 37 38 34 38 37 31 39 37 39 31 39 30 2D 30 30 30 30 30 30 30 41 2D 36 30 00 B1 FB 7F FE FE FE 00 00 00 00 00 00 00 00 00 00 00 00 00 12 01 48 95 E8 03 E8 03 28 32 91 53 24 4D 43 37 30 30 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 31 32 33 34 35 36 37 38 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 CD CC A4 41 00 00 80 3F 33 33 33 3F B8 1E 05 3F 33 33 33 3F 9A 99 19 3E 00 00 80 3F 00 00 80 3F 00 00 80 3F 32 36 2D 34 2D 32 37 00 2D 32 37 00 50 B1 BF 00 00 AA AB";
|
||||
String cleanHex = hex.replaceAll("\\s+", ""); // 移除所有空白字符
|
||||
byte[] bytes = Hex.decodeHex(cleanHex);
|
||||
DeviceRunParam runParam = DeviceRunParam.fromBytes(bytes);
|
||||
System.out.println(JsonUtils.toJsonString(runParam));
|
||||
|
||||
runParam.setLeftBackwardGain(0.2f);
|
||||
runParam.setLeftForwardGain(0.2f);
|
||||
runParam.setRightForwardGain(0.2f);
|
||||
runParam.setRightBackwardGain(0.2f);
|
||||
|
||||
byte[] newB = runParam.toWriteBytes();
|
||||
System.out.println(Hex.encodeHexString(newB));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import com.maibu.core.business.alarm_center.Alarm;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -26,7 +28,6 @@ import com.maibu.core.business.alarm_center.AlarmMessage;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.core.redis.RedisCache;
|
||||
import com.maibu.dto.DeviceErrorPushDTO;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
import com.maibu.memory.SiteMemory;
|
||||
import com.maibu.service.impl.AlarmServiceImpl;
|
||||
@@ -93,25 +94,37 @@ public class AlertPushService {
|
||||
Boolean exists = redisCache.hasKey(pushKey);
|
||||
if (exists != null && !exists) {
|
||||
newList.add(detail);
|
||||
redisCache.setCacheObject(pushKey, JsonUtils.toJsonString(detail), 10,
|
||||
TimeUnit.MINUTES);
|
||||
redisCache.setCacheObject(pushKey, JsonUtils.toJsonString(detail));
|
||||
AlarmOrderConfig config = siteMemory.getAlarmOrderConfig(detail.getNo());
|
||||
log.debug("compare config:{}", JsonUtils.toJsonString(config));
|
||||
if (config != null && config.isAutoGenerateOrder()) {
|
||||
IOTWorkOrder workOrder = wService.generateWorkOrders(siteId, deviceId, orgId, config.getModelId(), detail.getNo());
|
||||
workOrders.add(workOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
AlarmOrderConfig config = siteMemory.getAlarmOrderConfig(detail.getNo());
|
||||
if (config != null && config.isAutoGenerateOrder()) {
|
||||
IOTWorkOrder workOrder = wService.generateWorkOrders(siteId, deviceId, orgId, orgId);
|
||||
workOrders.add(workOrder);
|
||||
}
|
||||
});
|
||||
//todo 后续添加配置推送的告警等级
|
||||
if (alertPush == 1) {
|
||||
alarmService.pushAlertMes(dto.getDetails());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(workOrders)) {
|
||||
wService.saveAll(workOrders);
|
||||
List<Alarm> alarms = alarmService.pushAlertMes(newList);
|
||||
log.debug("alarms : {}", JsonUtils.toJsonString(alarms));
|
||||
log.debug("workOrders : {}", JsonUtils.toJsonString(workOrders));
|
||||
if (!CollectionUtils.isEmpty(workOrders)) {
|
||||
if (!CollectionUtils.isEmpty(alarms)) {
|
||||
workOrders.forEach(x -> {
|
||||
alarms.forEach(y -> {
|
||||
if (x.getAlarmNo().equals(y.getAlarmNo())) {
|
||||
x.setAlarmId(y.getId());
|
||||
x.setTaskDescription(y.getAlarmContent());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
wService.saveAll(workOrders);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@ package com.maibu.service;
|
||||
import com.maibu.core.business.DevicePlan;
|
||||
import com.maibu.core.business.DevicePlanTask;
|
||||
import com.maibu.core.business.DeviceTaskPlanRule;
|
||||
import com.maibu.core.business.WorkRecord;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.core.enums.DeviceTaskPlanRepeatType;
|
||||
import com.maibu.core.enums.DeviceTaskStaus;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.mapper.DevicePlanMapper;
|
||||
import com.maibu.mapper.DevicePlanTaskMapper;
|
||||
import com.maibu.mapper.WorkRecordMapper;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
import com.maibu.memory.SiteMemory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -29,7 +30,6 @@ import com.maibu.dto.DevicePlanStatisticsDTO;
|
||||
import com.maibu.dto.DevicePlanTaskStatisticsDTO;
|
||||
import com.maibu.dto.DeviceTaskQueryDTO;
|
||||
import com.maibu.dto.DeviceWorkStatisticsDTO;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.mapper.DeviceMapper;
|
||||
import com.maibu.mapper.DevicePlanMapper;
|
||||
import com.maibu.mapper.DevicePlanTaskMapper;
|
||||
@@ -454,7 +454,7 @@ public class DeviceTaskService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean createDeviceTask(DeviceTaskCommandDTO dto, String username) {
|
||||
public Long createDeviceTask(DeviceTaskCommandDTO dto, String username) {
|
||||
DevicePlanTask task = new DevicePlanTask();
|
||||
task.setOrgId(dto.getOrgId());
|
||||
task.setSiteId(dto.getSiteId());
|
||||
@@ -464,7 +464,7 @@ public class DeviceTaskService {
|
||||
task.setCreateTime(LocalDateTime.now());
|
||||
task.setRouteId(dto.getRouteId());
|
||||
task.setStartTime(dto.getStartTime());
|
||||
boolean result = devicePlanTaskMapper.saveOrUpdate(task);
|
||||
devicePlanTaskMapper.saveOrUpdate(task);
|
||||
if (dto.getOrgId() == null) {
|
||||
SysSite site = sysSiteMapper.selectById(dto.getSiteId());
|
||||
if (site != null) {
|
||||
@@ -473,7 +473,7 @@ public class DeviceTaskService {
|
||||
}
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(task.getOrgId(), task.getSiteId());
|
||||
siteMemory.addDevicePlanPrepare(task);
|
||||
return result;
|
||||
return task.getId();
|
||||
}
|
||||
|
||||
public boolean cancelTask(DeviceTaskCommandDTO dto, String username) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,7 +37,6 @@ import com.maibu.core.enums.ErrorSource;
|
||||
import com.maibu.core.enums.RespondCode;
|
||||
import com.maibu.core.redis.RedisCache;
|
||||
import com.maibu.dto.DeviceErrorPushDTO;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.mapper.ErrorIdentificationStandardMapper;
|
||||
import com.maibu.memory.GlobalMemory;
|
||||
import com.maibu.memory.SiteMemory;
|
||||
@@ -92,19 +92,22 @@ public class DeviceThreadService {
|
||||
String[] parts = k.split(":");
|
||||
String deviceId = parts[1];
|
||||
NettyDevice slaveDevice = sessionManager.getDevice(deviceId);
|
||||
Long siteId = slaveDevice != null ? slaveDevice.getDevice().getSiteId() : null;
|
||||
Long orgId = slaveDevice != null ? slaveDevice.getDevice().getOrgId() : null;
|
||||
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
List<AlarmMessage> compared = compareErrorStandard(siteId, orgId, history,
|
||||
siteMemory.standards.get(ErrorSource.MOWER));
|
||||
|
||||
DeviceErrorPushDTO pushDTO = new DeviceErrorPushDTO();
|
||||
pushDTO.setDeviceId(deviceId);
|
||||
pushDTO.setTime(System.currentTimeMillis());
|
||||
pushDTO.setDetails(compared);
|
||||
pushDTO.setEvent(RespondCode.device_error_push);
|
||||
pushList.add(pushDTO);
|
||||
if (slaveDevice != null && slaveDevice.isOnline()) {
|
||||
Long siteId = slaveDevice.getDevice().getSiteId();
|
||||
Long orgId = slaveDevice.getDevice().getOrgId();
|
||||
log.debug("compare siteId:{},orgId:{}", siteId, orgId);
|
||||
SiteMemory siteMemory = GlobalMemory.getSiteMemory(orgId, siteId);
|
||||
if (siteMemory != null) {
|
||||
List<AlarmMessage> compared = compareErrorStandard(siteId, orgId, history,
|
||||
siteMemory.standards.get(ErrorSource.MOWER));
|
||||
DeviceErrorPushDTO pushDTO = new DeviceErrorPushDTO();
|
||||
pushDTO.setDeviceId(deviceId);
|
||||
pushDTO.setTime(System.currentTimeMillis());
|
||||
pushDTO.setDetails(compared);
|
||||
pushDTO.setEvent(RespondCode.device_error_push);
|
||||
pushList.add(pushDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 按实际deviceId分组,推送错误信息
|
||||
@@ -195,7 +198,7 @@ public class DeviceThreadService {
|
||||
}
|
||||
|
||||
public List<AlarmMessage> compareErrorStandard(Long siteId, Long orgId, DeviceRunningStatusHistory history,
|
||||
List<ErrorIdentificationStandard> standards) {
|
||||
List<ErrorIdentificationStandard> standards) {
|
||||
if (history == null || CollectionUtils.isEmpty(standards))
|
||||
return null;
|
||||
List<AlarmMessage> list = new ArrayList<>();
|
||||
@@ -204,9 +207,11 @@ public class DeviceThreadService {
|
||||
String compareValues = standard.getCompareValues();
|
||||
CompareEnum compareType = standard.getCompareType();
|
||||
String targetValue = knownClassFieldFinding(fieldName, history);
|
||||
log.debug("compare2 compareType:{} compareValues:{},targetValue:{}", compareType, compareValues, targetValue);
|
||||
if (!StringUtils.isEmpty(compareValues) && !StringUtils.isEmpty(targetValue)) {
|
||||
boolean result = CompareUtils.compare(compareType, compareValues, targetValue);
|
||||
if (!result) {
|
||||
boolean result = CompareUtils.compare(compareType, targetValue, compareValues);
|
||||
log.debug("compare3 result:{}", result);
|
||||
if (result) {
|
||||
AlarmMessage alarm = new AlarmMessage();
|
||||
alarm.setContent(standard.getErrorDescription());
|
||||
alarm.setDeviceSn(history.getDeviceId());
|
||||
@@ -217,6 +222,7 @@ public class DeviceThreadService {
|
||||
alarm.setNo(standard.getErrorCode());
|
||||
alarm.setSuggestion(standard.getSuggestion());
|
||||
alarm.setStatus("未处理");
|
||||
alarm.setTimeValues(targetValue);
|
||||
alarm.setTime(LocalDateTime.now());
|
||||
alarm.setOrgId(orgId);
|
||||
alarm.setSiteId(siteId);
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.maibu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.maibu.constant.Constant;
|
||||
import com.maibu.core.business.DeviceRunningStatusHistory;
|
||||
import com.maibu.core.business.ErrorIdentificationStandard;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.dto.SendCommandDTO;
|
||||
import com.maibu.mapper.DeviceStatusHistoryMapper;
|
||||
import com.maibu.mapper.ErrorIdentificationStandardMapper;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,6 +24,9 @@ public class NettyDeviceService {
|
||||
@Autowired
|
||||
private DeviceStatusHistoryMapper deviceStatusHistoryMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceSessionManager deviceSessionManager;
|
||||
|
||||
@Autowired
|
||||
private ErrorIdentificationStandardMapper errorIdentificationStandardMapper;
|
||||
|
||||
@@ -40,5 +48,25 @@ public class NettyDeviceService {
|
||||
return errorIdentificationStandardMapper.updateById(standard);
|
||||
}
|
||||
|
||||
public void sendCommand(SendCommandDTO command) {
|
||||
if (command == null || command.getCommandType() == null || CollectionUtils.isEmpty(command.getDeviceIds()))
|
||||
return;
|
||||
command.getDeviceIds().forEach(deviceId -> {
|
||||
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
||||
if (nettyDevice != null && !nettyDevice.isExecutingTask()) {
|
||||
if (nettyDevice.getChannel() != null && nettyDevice.getChannel().isActive()) {
|
||||
if (Constant.WheelGainCoefficients.equals(command.getCommandType())) {
|
||||
double leftForwardGain = (double) command.getParams().get("leftForwardGain");
|
||||
double leftBackwardGain = (double) command.getParams().get("leftBackwardGain");
|
||||
double rightForwardGain = (double) command.getParams().get("rightForwardGain");
|
||||
double rightBackwardGain = (double) command.getParams().get("rightBackwardGain");
|
||||
nettyDevice.sendWheelGainCoefficientsCommand(leftForwardGain, leftBackwardGain, rightForwardGain, rightBackwardGain);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import com.maibu.core.domain.AjaxResult;
|
||||
import com.maibu.core.domain.entity.UserClient;
|
||||
import com.maibu.core.domain.model.LoginUser;
|
||||
import com.maibu.core.enums.ConnectorStatus;
|
||||
import com.maibu.manager.DeviceSessionManager;
|
||||
import com.maibu.mapper.DeviceMapper;
|
||||
import com.maibu.mapper.SysUserClientMapper;
|
||||
import com.maibu.memory.DeviceSessionManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -31,38 +31,38 @@ public class CompareUtils {
|
||||
return !compareValue.equals(targetValue);
|
||||
case GT:
|
||||
return isNumeric(compareValue) && isNumeric(targetValue) &&
|
||||
Double.parseDouble(compareValue) > Double.parseDouble(targetValue);
|
||||
Double.parseDouble(targetValue) > Double.parseDouble(compareValue);
|
||||
case LT:
|
||||
return isNumeric(compareValue) && isNumeric(targetValue) &&
|
||||
Double.parseDouble(compareValue) < Double.parseDouble(targetValue);
|
||||
Double.parseDouble(targetValue) < Double.parseDouble(compareValue);
|
||||
case GTE:
|
||||
return isNumeric(compareValue) && isNumeric(targetValue) &&
|
||||
Double.parseDouble(compareValue) >= Double.parseDouble(targetValue);
|
||||
Double.parseDouble(targetValue) >= Double.parseDouble(compareValue);
|
||||
case LTE:
|
||||
return isNumeric(compareValue) && isNumeric(targetValue) &&
|
||||
Double.parseDouble(compareValue) <= Double.parseDouble(targetValue);
|
||||
Double.parseDouble(targetValue) <= Double.parseDouble(compareValue);
|
||||
case BETWEEN:
|
||||
// 范围值用英文中划线分割
|
||||
String[] rangeValues = targetValue.split("-");
|
||||
String[] rangeValues = compareValue.split("-");
|
||||
if (rangeValues.length != 2) {
|
||||
return false;
|
||||
}
|
||||
return isNumeric(compareValue) && isNumeric(rangeValues[0]) && isNumeric(rangeValues[1]) &&
|
||||
Double.parseDouble(compareValue) >= Double.parseDouble(rangeValues[0]) &&
|
||||
Double.parseDouble(compareValue) <= Double.parseDouble(rangeValues[1]);
|
||||
Double.parseDouble(targetValue) >= Double.parseDouble(rangeValues[0]) &&
|
||||
Double.parseDouble(targetValue) <= Double.parseDouble(rangeValues[1]);
|
||||
case NOT_BETWEEN:
|
||||
// 范围值用英文中划线分割
|
||||
String[] notRangeValues = targetValue.split("-");
|
||||
String[] notRangeValues = compareValue.split("-");
|
||||
if (notRangeValues.length != 2) {
|
||||
return false;
|
||||
}
|
||||
return isNumeric(compareValue) && isNumeric(notRangeValues[0]) && isNumeric(notRangeValues[1]) &&
|
||||
(Double.parseDouble(compareValue) < Double.parseDouble(notRangeValues[0]) ||
|
||||
Double.parseDouble(compareValue) > Double.parseDouble(notRangeValues[1]));
|
||||
(Double.parseDouble(targetValue) < Double.parseDouble(notRangeValues[0]) ||
|
||||
Double.parseDouble(targetValue) > Double.parseDouble(notRangeValues[1]));
|
||||
case CONTAIN:
|
||||
return compareValue.contains(targetValue);
|
||||
return targetValue.contains(compareValue);
|
||||
case NOT_CONTAIN:
|
||||
return !compareValue.contains(targetValue);
|
||||
return !targetValue.contains(compareValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class DingTalkTemplate {
|
||||
"告警时间:%s\n\n" +
|
||||
"设备名称:%s\n\n" +
|
||||
"设备编号:%s\n\n" +
|
||||
"当前值:%s\n\n" +
|
||||
"告警内容:\n%s\n\n" +
|
||||
"发生位置:\n%s\n\n" +
|
||||
"处理建议:\n%s\n\n" +
|
||||
@@ -21,6 +22,7 @@ public class DingTalkTemplate {
|
||||
alarm.getTime(),
|
||||
alarm.getDeviceName(),
|
||||
alarm.getDeviceSn(),
|
||||
alarm.getTimeValues(),
|
||||
alarm.getContent(),
|
||||
alarm.getLocation(),
|
||||
alarm.getSuggestion(),
|
||||
|
||||
Reference in New Issue
Block a user