#update
This commit is contained in:
@@ -102,6 +102,11 @@ public class DeviceTask {
|
||||
return builder(FastBeeConstant.TASK.DEVICE_HEARTBEAT_MONITOR);
|
||||
}
|
||||
|
||||
@Bean(FastBeeConstant.TASK.AUTO_RULE)
|
||||
public Executor autoRule() {
|
||||
return builder(FastBeeConstant.TASK.AUTO_RULE);
|
||||
}
|
||||
|
||||
@Bean(FastBeeConstant.TASK.MAP_MESSAGE_PUSH)
|
||||
public Executor mapMessagePush() {
|
||||
return builder(FastBeeConstant.TASK.MAP_MESSAGE_PUSH);
|
||||
|
||||
@@ -11,7 +11,6 @@ public interface FastBeeConstant {
|
||||
String UFT8 = "UTF-8";
|
||||
String GB2312 = "GB2312";
|
||||
|
||||
|
||||
String MQTT = "mqtt";
|
||||
String PORT = "port";
|
||||
String ADAPTER = "adapter";
|
||||
@@ -27,16 +26,16 @@ public interface FastBeeConstant {
|
||||
String WM_PREFIX = "server-";
|
||||
String FAST_PHONE = "phone-";
|
||||
|
||||
/*MQTT平台判定离线时间 keepAlive*1.5 */
|
||||
/* MQTT平台判定离线时间 keepAlive*1.5 */
|
||||
Long DEVICE_PING_EXPIRED = 90000L;
|
||||
}
|
||||
|
||||
interface CLIENT {
|
||||
//加盐
|
||||
// 加盐
|
||||
String TOKEN = "fastbee-smart!@#$123";
|
||||
}
|
||||
|
||||
/*webSocket配置*/
|
||||
/* webSocket配置 */
|
||||
interface WS {
|
||||
String HEART_BEAT = "heartbeat";
|
||||
String HTTP_SERVER_CODEC = "httpServerCodec";
|
||||
@@ -87,13 +86,13 @@ public interface FastBeeConstant {
|
||||
* 消息消费线程
|
||||
*/
|
||||
String MESSAGE_CONSUME_TASK = "messageConsumeTask";
|
||||
/*内部消费线程publish*/
|
||||
/* 内部消费线程publish */
|
||||
String MESSAGE_CONSUME_TASK_PUB = "messageConsumeTaskPub";
|
||||
/*内部消费线程Fetch*/
|
||||
/* 内部消费线程Fetch */
|
||||
String MESSAGE_CONSUME_TASK_FETCH = "messageConsumeTaskFetch";
|
||||
/*OTA升级延迟队列*/
|
||||
/* OTA升级延迟队列 */
|
||||
String DELAY_UPGRADE_TASK = "delayUpgradeTask";
|
||||
/*OTA升级线程池*/
|
||||
/* OTA升级线程池 */
|
||||
String OTA_THREAD_POOL = "otaThreadPoolTaskExecutor";
|
||||
|
||||
/**
|
||||
@@ -111,6 +110,10 @@ public interface FastBeeConstant {
|
||||
*/
|
||||
String MAP_MESSAGE_PUSH = "mapMessagePush";
|
||||
|
||||
/**
|
||||
* 规则触发任务
|
||||
*/
|
||||
String AUTO_RULE = "autoRule";
|
||||
|
||||
/**
|
||||
* 设备任务处理线程
|
||||
@@ -128,67 +131,66 @@ public interface FastBeeConstant {
|
||||
|
||||
String PREDIX = "/+/+";
|
||||
|
||||
/*OTA消息回复*/
|
||||
/* OTA消息回复 */
|
||||
String OTA_REPLY = "upgrade/reply";
|
||||
|
||||
}
|
||||
|
||||
/*集群,全局发布的消息类型*/
|
||||
/* 集群,全局发布的消息类型 */
|
||||
interface CHANNEL {
|
||||
/*设备状态*/
|
||||
/* 设备状态 */
|
||||
String DEVICE_STATUS = "device_status";
|
||||
/*平台读取属性*/
|
||||
/* 平台读取属性 */
|
||||
String PROP_READ = "prop_read";
|
||||
/*推送消息*/
|
||||
/* 推送消息 */
|
||||
String PUBLISH = "publish";
|
||||
/*服务下发*/
|
||||
/* 服务下发 */
|
||||
String FUNCTION_INVOKE = "function_invoke";
|
||||
/*事件*/
|
||||
/* 事件 */
|
||||
String EVENT = "event";
|
||||
/*other*/
|
||||
/* other */
|
||||
String OTHER = "other";
|
||||
/*Qos1 推送应答*/
|
||||
/* Qos1 推送应答 */
|
||||
String PUBLISH_ACK = "publish_ack";
|
||||
/*Qos2 发布消息收到*/
|
||||
/* Qos2 发布消息收到 */
|
||||
String PUB_REC = "pub_rec";
|
||||
/*Qos 发布消息释放*/
|
||||
/* Qos 发布消息释放 */
|
||||
String PUB_REL = "pub_rel";
|
||||
/*Qos2 发布消息完成*/
|
||||
/* Qos2 发布消息完成 */
|
||||
String PUB_COMP = "pub_comp";
|
||||
|
||||
String UPGRADE = "upgrade";
|
||||
|
||||
/*-------------------------ROCKETMQ-------------------------*/
|
||||
String SUFFIX = "group";
|
||||
/*设备状态*/
|
||||
/* 设备状态 */
|
||||
String DEVICE_STATUS_GROUP = DEVICE_STATUS + SUFFIX;
|
||||
String PROP_READ_GROUP = PROP_READ + SUFFIX;
|
||||
/*服务下发*/
|
||||
/* 服务下发 */
|
||||
String FUNCTION_INVOKE_GROUP = FUNCTION_INVOKE + SUFFIX;
|
||||
/*推送消息*/
|
||||
/* 推送消息 */
|
||||
String PUBLISH_GROUP = PUBLISH + SUFFIX;
|
||||
/*Qos1 推送应答*/
|
||||
/* Qos1 推送应答 */
|
||||
String PUBLISH_ACK_GROUP = PUBLISH_ACK + SUFFIX;
|
||||
/*Qos2 发布消息收到*/
|
||||
/* Qos2 发布消息收到 */
|
||||
String PUB_REC_GROUP = PUB_REC + SUFFIX;
|
||||
/*Qos 发布消息释放*/
|
||||
/* Qos 发布消息释放 */
|
||||
String PUB_REL_GROUP = PUB_REL + SUFFIX;
|
||||
/*Qos2 发布消息完成*/
|
||||
/* Qos2 发布消息完成 */
|
||||
String PUB_COMP_GROUP = PUB_COMP + SUFFIX;
|
||||
/*OTA升级*/
|
||||
/* OTA升级 */
|
||||
String UPGRADE_GROUP = UPGRADE + SUFFIX;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* redisKey 定义
|
||||
*/
|
||||
interface REDIS {
|
||||
/*在线设备列表*/
|
||||
/* 在线设备列表 */
|
||||
String DEVICE_ONLINE_LIST = "device:online:list";
|
||||
/*设备实时状态key*/
|
||||
/* 设备实时状态key */
|
||||
String DEVICE_RUNTIME_DATA = "device:runtime:";
|
||||
/*通讯协议参数*/
|
||||
/* 通讯协议参数 */
|
||||
String DEVICE_PROTOCOL_PARAM = "device:param:";
|
||||
/**
|
||||
* 设备消息id缓存key
|
||||
@@ -227,11 +229,11 @@ public interface FastBeeConstant {
|
||||
*/
|
||||
String MESSAGE_RETAIN_TOTAL = "message:retain:total";
|
||||
|
||||
/*发送消息数*/
|
||||
/* 发送消息数 */
|
||||
String MESSAGE_SEND_TOTAL = "message:send:total";
|
||||
/*接收消息数*/
|
||||
/* 接收消息数 */
|
||||
String MESSAGE_RECEIVE_TOTAL = "message:receive:total";
|
||||
/*连接次数*/
|
||||
/* 连接次数 */
|
||||
String MESSAGE_CONNECT_TOTAL = "message:connect:total";
|
||||
/**
|
||||
* 认证次数
|
||||
@@ -316,7 +318,6 @@ public interface FastBeeConstant {
|
||||
String CH = "CH";
|
||||
String ModbusTcp = "MODBUS-TCP";
|
||||
|
||||
|
||||
}
|
||||
|
||||
interface URL {
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.maibu.core.domain.OrgBaseDO;
|
||||
import com.maibu.core.domain.map.RestPoint;
|
||||
import com.maibu.core.enums.DeviceTaskStaus;
|
||||
import com.maibu.core.enums.RouteType;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -40,6 +42,11 @@ public class DevicePlanTask extends OrgBaseDO {
|
||||
private LocalDateTime canExecuteTime; // 这个时间之前都不能执行
|
||||
|
||||
@TableField(exist = false)
|
||||
private volatile boolean taskAccepted = false; //任务被上位机接收
|
||||
private volatile boolean taskAccepted = false; // 任务被上位机接收
|
||||
|
||||
private RouteType routeType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private RestPoint backTaskPoint;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.maibu.core.domain.OrgBaseDO;
|
||||
import com.maibu.core.enums.RouteType;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -20,12 +21,14 @@ public class WorkRecord extends OrgBaseDO {
|
||||
private String workName;
|
||||
private Long userId;
|
||||
|
||||
private String mode;//导航任务模式 single_point|coverage
|
||||
private String mode;// 导航任务模式 single_point|coverage
|
||||
|
||||
// private String jsonData;
|
||||
// private String jsonData;
|
||||
|
||||
private RouteType routeType;
|
||||
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private PlanPath jsonData; //计划
|
||||
private PlanPath jsonData; // 计划
|
||||
|
||||
private String imgUrl;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.maibu.core.business.path.LatAndLngEntity;
|
||||
import com.maibu.core.business.path.RoutePlanSendEntity;
|
||||
import com.maibu.core.enums.ConnectorType;
|
||||
import com.maibu.core.enums.DeviceTaskStaus;
|
||||
import com.maibu.core.enums.RouteType;
|
||||
import com.maibu.core.host.HostWorkRecordCreateDTO;
|
||||
import com.maibu.core.host.MutiPointEntity;
|
||||
import com.maibu.core.host.PointEntity;
|
||||
@@ -247,22 +248,22 @@ public class NettyDevice extends Connector {
|
||||
}
|
||||
|
||||
// public void readConfigCommand() {
|
||||
// byte[] bytes = DeviceRunParam.toReadBytes();
|
||||
// log.debug("下发读取配置的报文:{}", toHexString(bytes));
|
||||
// if (this.getChannel() != null && this.getChannel().isActive()) {
|
||||
// this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
||||
// }
|
||||
// log.debug("下发读取配置的报文完成:{}", toHexString(bytes));
|
||||
// byte[] bytes = DeviceRunParam.toReadBytes();
|
||||
// log.debug("下发读取配置的报文:{}", toHexString(bytes));
|
||||
// if (this.getChannel() != null && this.getChannel().isActive()) {
|
||||
// this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
||||
// }
|
||||
// log.debug("下发读取配置的报文完成:{}", toHexString(bytes));
|
||||
// }
|
||||
|
||||
// public void writeConfigCommand(DeviceRunParam deviceRunParam) {
|
||||
// log.debug("下发修改配置的属性:{}", JsonUtils.toJsonString(deviceRunParam));
|
||||
// byte[] bytes = deviceRunParam.toWriteBytes();
|
||||
// log.debug("下发修改配置的报文:{}", toHexString(bytes));
|
||||
// if (this.getChannel() != null && this.getChannel().isActive()) {
|
||||
// this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
||||
// }
|
||||
// log.debug("下发修改配置的报文完成:{}", toHexString(bytes));
|
||||
// log.debug("下发修改配置的属性:{}", JsonUtils.toJsonString(deviceRunParam));
|
||||
// byte[] bytes = deviceRunParam.toWriteBytes();
|
||||
// log.debug("下发修改配置的报文:{}", toHexString(bytes));
|
||||
// if (this.getChannel() != null && this.getChannel().isActive()) {
|
||||
// this.getChannel().writeAndFlush(Unpooled.wrappedBuffer(bytes));
|
||||
// }
|
||||
// log.debug("下发修改配置的报文完成:{}", toHexString(bytes));
|
||||
// }
|
||||
|
||||
// todo 优化
|
||||
@@ -365,32 +366,38 @@ public class NettyDevice extends Connector {
|
||||
dto.setProtocol_version(Constant.protocol_version);
|
||||
|
||||
PointEntity point = new PointEntity();
|
||||
if (!StringUtils.isEmpty(workRecord.getMode())) {
|
||||
if (workRecord.getMode().equals("single_point")) {
|
||||
point.setLongitude(workRecord.getJsonData().getPath().get(0).getLng());
|
||||
point.setLatitude(workRecord.getJsonData().getPath().get(0).getLat());
|
||||
}
|
||||
if (workRecord.getMode().equals("coverage")) {
|
||||
List<MutiPointEntity> boundary_points = new ArrayList<>();
|
||||
// workRecord.getJsonData().getPath().forEach(x -> {
|
||||
// MutiPointEntity mutiPoint = new MutiPointEntity();
|
||||
// mutiPoint.setLongitude(x.getLng());
|
||||
// mutiPoint.setLatitude(x.getLat());
|
||||
// mutiPoint.setIndex();
|
||||
// boundary_points.add(mutiPoint);
|
||||
// });
|
||||
List<LatAndLngEntity> path = workRecord.getJsonData().getPath();
|
||||
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
LatAndLngEntity x = path.get(i);
|
||||
|
||||
MutiPointEntity mutiPoint = new MutiPointEntity();
|
||||
mutiPoint.setLongitude(x.getLng());
|
||||
mutiPoint.setLatitude(x.getLat());
|
||||
mutiPoint.setIndex(i);
|
||||
boundary_points.add(mutiPoint);
|
||||
//TODO 增加其他系统任务类型 写死的code
|
||||
if (RouteType.BACK_TO_REST_POINT.equals(task.getRouteType())) {
|
||||
point.setLongitude(task.getBackTaskPoint().getPosition().getLng());
|
||||
point.setLatitude(task.getBackTaskPoint().getPosition().getLat());
|
||||
} else {
|
||||
if (!StringUtils.isEmpty(workRecord.getMode())) {
|
||||
if (workRecord.getMode().equals("single_point")) {
|
||||
point.setLongitude(workRecord.getJsonData().getPath().get(0).getLng());
|
||||
point.setLatitude(workRecord.getJsonData().getPath().get(0).getLat());
|
||||
}
|
||||
if (workRecord.getMode().equals("coverage")) {
|
||||
List<MutiPointEntity> boundary_points = new ArrayList<>();
|
||||
// workRecord.getJsonData().getPath().forEach(x -> {
|
||||
// MutiPointEntity mutiPoint = new MutiPointEntity();
|
||||
// mutiPoint.setLongitude(x.getLng());
|
||||
// mutiPoint.setLatitude(x.getLat());
|
||||
// mutiPoint.setIndex();
|
||||
// boundary_points.add(mutiPoint);
|
||||
// });
|
||||
List<LatAndLngEntity> path = workRecord.getJsonData().getPath();
|
||||
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
LatAndLngEntity x = path.get(i);
|
||||
|
||||
MutiPointEntity mutiPoint = new MutiPointEntity();
|
||||
mutiPoint.setLongitude(x.getLng());
|
||||
mutiPoint.setLatitude(x.getLat());
|
||||
mutiPoint.setIndex(i);
|
||||
boundary_points.add(mutiPoint);
|
||||
}
|
||||
point.setBoundary_points(boundary_points);
|
||||
}
|
||||
point.setBoundary_points(boundary_points);
|
||||
}
|
||||
}
|
||||
dto.setData(point);
|
||||
|
||||
@@ -17,4 +17,6 @@ public class DeviceMapPushDTO {
|
||||
|
||||
private String cm;// 控制模式 manual_remote|auto
|
||||
|
||||
private String ms; // 运动状态 moving|stopped|blocked
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.maibu.core.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -14,6 +15,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基类,时间类型改为LocalDateTime
|
||||
*
|
||||
* @author fastb
|
||||
* @date 2023-08-22 9:11
|
||||
*/
|
||||
@@ -23,20 +25,24 @@ public class BaseDO implements Serializable {
|
||||
|
||||
/** 创建者 */
|
||||
@ApiModelProperty("创建者")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@ApiModelProperty("创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 更新者 */
|
||||
@ApiModelProperty("更新者")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@ApiModelProperty("更新时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/** 逻辑删除 */
|
||||
|
||||
@@ -3,16 +3,20 @@ package com.maibu.core.domain.entity;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.maibu.core.business.path.LatAndLngEntity;
|
||||
import com.maibu.core.domain.BaseDO;
|
||||
import com.maibu.utils.LongListTypeHandler;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "sys_region")
|
||||
@TableName(value = "sys_region", autoResultMap = true)
|
||||
public class SysRegion extends BaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@@ -28,8 +32,14 @@ public class SysRegion extends BaseDO {
|
||||
|
||||
private String remark;
|
||||
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<LatAndLngEntity> scope; // 区域范围
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Long bindRoute;// 绑定的线路id
|
||||
private Long defaultRoute;// 绑定的线路id
|
||||
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> bindRoutes;// 绑定的线路id
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
package com.maibu.core.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.maibu.core.domain.BaseDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.maibu.core.domain.BaseDO;
|
||||
import com.maibu.core.domain.map.SiteMapInfo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "sys_site")
|
||||
@TableName(value = "sys_site", autoResultMap = true)
|
||||
public class SysSite extends BaseDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@@ -45,4 +48,10 @@ public class SysSite extends BaseDO {
|
||||
|
||||
private String siteMapName; // geoserver 地图名称
|
||||
|
||||
/**
|
||||
* 场站相关的地图信息 比如停车点,充电点,临时不可走点 等等 待拓展
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private SiteMapInfo siteMapInfo;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.maibu.core.domain.map;
|
||||
|
||||
import com.maibu.core.business.path.LatAndLngEntity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RestPoint {
|
||||
|
||||
private LatAndLngEntity position;
|
||||
|
||||
private String bindDeviceId;
|
||||
|
||||
private String alias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.maibu.core.domain.map;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.maibu.core.domain.OrgNoUserDO;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "sys_site_map_info", autoResultMap = true)
|
||||
public class SiteMapInfo extends OrgNoUserDO {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<RestPoint> restPoints; // 休息点
|
||||
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<TempObstaclePoint> tempObstaclePoints; // 临时不可走点
|
||||
|
||||
// todo 拓展 安全区 充电区?
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.maibu.core.domain.map;
|
||||
|
||||
import com.maibu.core.business.path.LatAndLngEntity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TempObstaclePoint {
|
||||
|
||||
private LatAndLngEntity position;
|
||||
|
||||
private Double radius;
|
||||
|
||||
private String alias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.maibu.core.domain.rule;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.maibu.core.enums.ActionType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
public class ActionConfig {
|
||||
|
||||
/**
|
||||
* 触发任务类型
|
||||
*/
|
||||
private ActionType actionType;
|
||||
|
||||
/**
|
||||
* 参数值
|
||||
*/
|
||||
private Map<String, Object> args;
|
||||
|
||||
private Long routeId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.maibu.core.domain.rule;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.maibu.core.domain.OrgNoUserDO;
|
||||
import com.maibu.core.enums.DeviceScope;
|
||||
import com.maibu.core.enums.RuleType;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 自动化规则配置
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "iot_auto_rule", autoResultMap = true)
|
||||
public class IotAutoRule extends OrgNoUserDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规则类型,如 LOW_BATTERY_RETURN
|
||||
*/
|
||||
private RuleType ruleType;
|
||||
|
||||
/**
|
||||
* 适用设备、分组、全部
|
||||
*/
|
||||
private DeviceScope deviceScope;
|
||||
|
||||
/**
|
||||
* 触发条件
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private TriggerConditions conditions;
|
||||
|
||||
/**
|
||||
* 执行动作及参数
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private ActionConfig actionConfig;
|
||||
|
||||
/**
|
||||
* 是否启用:0-禁用,1-启用
|
||||
*/
|
||||
private Boolean enabled = false;
|
||||
|
||||
// 是否强制执行 比如车子当前有任务
|
||||
private Boolean ForceExecute = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.maibu.core.domain.rule;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.maibu.core.domain.OrgNoUserDO;
|
||||
import com.maibu.core.enums.RuleType;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 自动化规则触发记录
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(value = "iot_auto_rule_record", autoResultMap = true)
|
||||
public class IotAutoRuleRecord extends OrgNoUserDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则 ID
|
||||
*/
|
||||
private Long ruleId;
|
||||
|
||||
private RuleType ruleType;
|
||||
|
||||
/**
|
||||
* 触发设备 ID
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 触发时的指标快照
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private Object triggerValue;
|
||||
|
||||
/**
|
||||
* 触发时间
|
||||
*/
|
||||
private LocalDateTime triggerTime;
|
||||
|
||||
/**
|
||||
* 关联的返航任务 ID
|
||||
*/
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 执行失败原因
|
||||
*/
|
||||
private String errorMessage;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.maibu.core.domain.rule;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.maibu.core.enums.CompareEnum;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
public class TriggerConditions {
|
||||
|
||||
/**
|
||||
* 触发条件判断的字段key 电量 battery /temperature/offline_duration/voltage
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 比较运算符:GT、GTE、LT、LTE、EQ、NE
|
||||
*/
|
||||
private CompareEnum operator;
|
||||
|
||||
/**
|
||||
* 比较阈值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.maibu.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ActionType {
|
||||
|
||||
AUTO_TASK("AUTO_TASK", "路径规划任务"),
|
||||
|
||||
BACK_TO_REST("BACK_TO_REST", "回休息区"),
|
||||
|
||||
SEND_COMMAND("SEND_COMMAND", "下发指令"),
|
||||
|
||||
ALARM("ALARM", "告警"),
|
||||
|
||||
WORK_ORDER("WORK_ORDER", "工单下发");
|
||||
|
||||
/** 订单类型值(存储在数据库中) */
|
||||
private final String value;
|
||||
|
||||
/** 订单类型名称(用于前端显示) */
|
||||
private final String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.maibu.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DeviceScope {
|
||||
|
||||
ALL("ALL", "所有设备"),
|
||||
|
||||
GROUP("GROUP", "设备组"),
|
||||
|
||||
SOME("SOME", "特定的");
|
||||
|
||||
/** 订单类型值(存储在数据库中) */
|
||||
private final String value;
|
||||
|
||||
/** 订单类型名称(用于前端显示) */
|
||||
private final String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.maibu.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RouteType {
|
||||
|
||||
MOWING_TASK("MOWING_TASK", "割草任务"),
|
||||
|
||||
INSPECTION_TASK("INSPECTION_TASK", "巡检任务"),
|
||||
|
||||
BACK_TO_REST_POINT("BACK_TO_REST_POINT", "返航任务"),
|
||||
|
||||
OTHER("OTHER", "其他类型");
|
||||
|
||||
/** 订单类型值(存储在数据库中) */
|
||||
private final String value;
|
||||
|
||||
/** 订单类型名称(用于前端显示) */
|
||||
private final String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.maibu.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RuleType {
|
||||
|
||||
LOW_BATTERY_RETURN("LOW_BATTERY_RETURN", "低电量返航");
|
||||
|
||||
/** 错误来源值(存储在数据库中) */
|
||||
private final String value;
|
||||
|
||||
/** 错误来源名称(用于前端显示) */
|
||||
private final String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.maibu.core.host;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DetectionStamp {
|
||||
|
||||
private Long sec;
|
||||
private Long nanosec;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.maibu.core.host;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.maibu.core.enums.MesType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ObstacleDetectionData {
|
||||
|
||||
|
||||
private MesType mesType;
|
||||
|
||||
/**
|
||||
* 融合状态
|
||||
*/
|
||||
private String fusion_status;
|
||||
|
||||
/**
|
||||
* 障碍物检测状态
|
||||
*/
|
||||
private String obstacle_status;
|
||||
|
||||
/**
|
||||
* 检测目标数量
|
||||
*/
|
||||
private Integer object_count;
|
||||
|
||||
/**
|
||||
* 检测目标列表
|
||||
*/
|
||||
private List<ObstacleObject> objects;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.maibu.core.host;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ObstacleObject {
|
||||
|
||||
private Integer class_id;
|
||||
private String class_name;
|
||||
private Double confidence;
|
||||
|
||||
private Integer x1;
|
||||
private Integer y1;
|
||||
private Integer x2;
|
||||
private Integer y2;
|
||||
|
||||
private Double x;
|
||||
private Double y;
|
||||
private Double z;
|
||||
|
||||
private Double distance;
|
||||
private Double angle;
|
||||
|
||||
private Double latitude;
|
||||
private Double longitude;
|
||||
|
||||
private Integer track_id;
|
||||
|
||||
private Double size_x;
|
||||
private Double size_y;
|
||||
private Double size_z;
|
||||
|
||||
private DetectionStamp det_stamp;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.maibu.core.host;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ObstaclePostDTO extends HostBase {
|
||||
|
||||
private ObstacleDetectionData fusion_obstacle;
|
||||
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import lombok.Data;
|
||||
@Data
|
||||
public class VehicleMessage {
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private double battery_percentage;// 实时电量百分比
|
||||
private double battery_voltage;// 实时电压
|
||||
|
||||
|
||||
@@ -6,16 +6,27 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.maibu.core.business.*;
|
||||
import com.maibu.core.business.dto.DeviceMapPushDTO;
|
||||
import com.maibu.mqtt.CustomMqttDeviceMonitor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.maibu.core.business.AlarmOrderConfig;
|
||||
import com.maibu.core.business.Device;
|
||||
import com.maibu.core.business.DeviceModel;
|
||||
import com.maibu.core.business.DevicePlan;
|
||||
import com.maibu.core.business.DevicePlanTask;
|
||||
import com.maibu.core.business.DeviceRunParam;
|
||||
import com.maibu.core.business.DeviceRunStatistics;
|
||||
import com.maibu.core.business.ErrorIdentificationStandard;
|
||||
import com.maibu.core.business.IoTCommonDevice;
|
||||
import com.maibu.core.business.OrderModel;
|
||||
import com.maibu.core.business.Product;
|
||||
import com.maibu.core.business.dto.DeviceMapPushDTO;
|
||||
import com.maibu.core.domain.entity.SysSite;
|
||||
import com.maibu.core.domain.rule.IotAutoRule;
|
||||
import com.maibu.core.enums.ErrorSource;
|
||||
import com.maibu.core.enums.RuleType;
|
||||
import com.maibu.core.host.VehicleMessage;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -62,11 +73,34 @@ public class SiteMemory {
|
||||
|
||||
public static ConcurrentHashMap<String, VehicleMessage> vehicleMessageMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static ConcurrentHashMap<RuleType, IotAutoRule> iotAutoRuleMap = new ConcurrentHashMap<>();
|
||||
|
||||
public List<IotAutoRule> getAllIotAutoRule() {
|
||||
return new ArrayList<>(iotAutoRuleMap.values());
|
||||
}
|
||||
|
||||
public IotAutoRule getIotAutoRule(RuleType ruleType) {
|
||||
return iotAutoRuleMap.get(ruleType);
|
||||
}
|
||||
|
||||
public void saveIotAutoRule(RuleType ruleType, IotAutoRule iotAutoRule) {
|
||||
iotAutoRuleMap.put(ruleType, iotAutoRule);
|
||||
}
|
||||
|
||||
public void removeIotAutoRule(RuleType ruleType) {
|
||||
iotAutoRuleMap.remove(ruleType);
|
||||
}
|
||||
|
||||
public List<VehicleMessage> getAllVehicleMessage() {
|
||||
return new ArrayList<>(vehicleMessageMap.values());
|
||||
}
|
||||
|
||||
public VehicleMessage getVehicleMessage(String deviceId) {
|
||||
return vehicleMessageMap.get(deviceId);
|
||||
}
|
||||
|
||||
public void saveVehicleMessage(String deviceId, VehicleMessage vehicleMessage) {
|
||||
vehicleMessage.setDeviceId(deviceId);
|
||||
vehicleMessageMap.put(deviceId, vehicleMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.maibu.core.business.device.DeviceStatusDetail;
|
||||
import com.maibu.core.business.device.NettyDevice;
|
||||
import com.maibu.core.business.dto.DeviceMapPushDTO;
|
||||
import com.maibu.core.business.dto.WebDeviceTaskStatusMessageDTO;
|
||||
import com.maibu.core.business.dto.WebMapMessageDTO;
|
||||
import com.maibu.core.business.dto.WebStatusMessageDTO;
|
||||
import com.maibu.core.business.inter.WebsocketMesDispather;
|
||||
import com.maibu.core.enums.DeviceTaskStaus;
|
||||
@@ -107,6 +108,10 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
||||
case "upgrade_reply":
|
||||
handleUpgradeReply(deviceId, topic, payload);
|
||||
break;
|
||||
case "obstacle_post":
|
||||
handleObstaclePost(deviceId, topic, payload);
|
||||
break;
|
||||
|
||||
default:
|
||||
log.debug("割草机消息: deviceId={}, topic={}, action={}", deviceId, topic, action);
|
||||
break;
|
||||
@@ -247,6 +252,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
||||
VehicleMessage vehicleMessage = siteMemory.getVehicleMessage(deviceId);
|
||||
if (vehicleMessage != null) {
|
||||
dto.setCm(vehicleMessage.getControl_mode());
|
||||
dto.setMs(vehicleMessage.getMotion());
|
||||
dto.setB(vehicleMessage.getBattery_percentage());
|
||||
}
|
||||
siteMemory.saveMapPushDTO(deviceId, dto);
|
||||
@@ -634,6 +640,49 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理控障碍物提示
|
||||
*/
|
||||
private void handleObstaclePost(String deviceId, String topic, String payload) {
|
||||
|
||||
log.debug("【障碍物提示】deviceId={}, payload={}", deviceId, payload);
|
||||
|
||||
ObstacleDetectionData data = JsonUtils.parseObject(payload, ObstacleDetectionData.class);
|
||||
|
||||
List<NettyDevice> controlMasters = deviceSessionManager
|
||||
.getAllSlaveControl(deviceId);
|
||||
data.setMesType(MesType.detectionReport);
|
||||
if (!CollectionUtils.isEmpty(controlMasters)) {
|
||||
|
||||
for (NettyDevice x : controlMasters) {
|
||||
try {
|
||||
websocketMesDispather.dispather(x.getConnectorId(), JsonUtils.toJsonString(data));
|
||||
} catch (Exception e) {
|
||||
log.error("实时数据websocket推送失败: connectorId={}, error={}", x.getConnectorId(),
|
||||
e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
NettyDevice device = deviceSessionManager.getDevice(deviceId);
|
||||
if (device != null && device.getDevice() != null) {
|
||||
Long siteId = device.getDevice().getSiteId();
|
||||
websocketMesDispather.mapMessageDispather(siteId,
|
||||
JsonUtils.toJsonString(data));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("实时地图数据websocket推送失败: siteId={}, error={}", e);
|
||||
}
|
||||
try {
|
||||
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
||||
String.format(MqttTopic.DEVICE_OBSTACLE_PUSH_TOPIC, deviceId),
|
||||
JsonUtils.toJsonString(data));
|
||||
} catch (MqttException e) {
|
||||
log.error("实时数据websocket推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 Topic 中解析 deviceId
|
||||
* Topic 格式:mower/{deviceId}/...
|
||||
@@ -686,6 +735,8 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
||||
return "route_reply";
|
||||
if (remaining.equals("/ota/result/post"))
|
||||
return "upgrade_reply";
|
||||
if (remaining.equals("/perception/obstacle/post"))
|
||||
return "obstacle_post";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ public class MqttTopic {
|
||||
public static final String DEVICE_ROUTE_PUSH_TOPIC = "device/%s/route/post";
|
||||
|
||||
public static final String DEVICE_STATUS_PUSH_TOPIC = "device/%s/status/change";
|
||||
// 障碍物信息
|
||||
public static final String DEVICE_OBSTACLE_PUSH_TOPIC = "device/%s/obstacle/post";
|
||||
|
||||
/** 产品标识:割草机 */
|
||||
public static final String MOWER_PRODUCT = "mower";
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.maibu.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class LongListTypeHandler extends AbstractJsonTypeHandler<List<Long>> {
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
private static final JavaType LIST_TYPE =
|
||||
OBJECT_MAPPER.getTypeFactory()
|
||||
.constructCollectionType(List.class, Long.class);
|
||||
|
||||
public LongListTypeHandler(Class<?> type) {
|
||||
// 兼容 MyBatis-Plus 通过反射传入字段类型的方式
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Long> parse(String json) {
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(json, LIST_TYPE);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("bindRoutes JSON 解析失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toJson(List<Long> obj) {
|
||||
try {
|
||||
return OBJECT_MAPPER.writeValueAsString(obj);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("bindRoutes JSON 序列化失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user