Commit 00edd5a7246b5c5dd91f6d7f88723c6a0a22495a

Authored by YunaiV
1 parent b46e6309

【功能新增】IoT:增加 ota 的表结构设计(90%)

yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/ota/IotOtaFirmwareDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.dal.dataobject.ota;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.KeySequence;
  5 +import com.baomidou.mybatisplus.annotation.TableField;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.*;
  8 +
  9 +/**
  10 + * IoT OTA 固件 DO
  11 + *
  12 + * @see <a href="阿里云 IoT - OTA 升级">https://help.aliyun.com/zh/iot/user-guide/ota-upgrade-overview</a>
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@TableName(value = "iot_ota_firmware", autoResultMap = true)
  17 +@KeySequence("iot_ota_firmware_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  18 +@Data
  19 +@EqualsAndHashCode(callSuper = true)
  20 +@ToString(callSuper = true)
  21 +@Builder
  22 +@NoArgsConstructor
  23 +@AllArgsConstructor
  24 +public class IotOtaFirmwareDO extends BaseDO {
  25 +
  26 + /**
  27 + * 固件编号
  28 + */
  29 + @TableField
  30 + private Long id;
  31 + /**
  32 + * 固件名称
  33 + */
  34 + private String name;
  35 + /**
  36 + * 固件版本
  37 + */
  38 + private String description;
  39 + /**
  40 + * 版本号
  41 + */
  42 + private String version;
  43 +
  44 + /**
  45 + * 产品编号
  46 + *
  47 + * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getId()}
  48 + */
  49 + private String productId;
  50 + /**
  51 + * 产品标识
  52 + *
  53 + * 冗余 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getProductKey()}
  54 + */
  55 + private String productKey;
  56 +
  57 + /**
  58 + * 签名方式
  59 + *
  60 + * 例如说:MD5、SHA256
  61 + */
  62 + private String signMethod;
  63 + /**
  64 + * 固件文件签名
  65 + */
  66 + private String fileSign;
  67 + /**
  68 + * 固件文件大小
  69 + */
  70 + private Long fileSize;
  71 + /**
  72 + * 固件文件 URL
  73 + */
  74 + private String fileUrl;
  75 +
  76 + /**
  77 + * 自定义信息,建议使用 JSON 格式
  78 + */
  79 + private String information;
  80 +
  81 +}
0 \ No newline at end of file 82 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/ota/IotOtaUpgradeRecordDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.dal.dataobject.ota;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.KeySequence;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.*;
  8 +
  9 +import java.time.LocalDateTime;
  10 +
  11 +/**
  12 + * IoT OTA 升级记录 DO
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@TableName(value = "iot_ota_upgrade_record", autoResultMap = true)
  17 +@KeySequence("iot_ota_upgrade_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  18 +@Data
  19 +@EqualsAndHashCode(callSuper = true)
  20 +@ToString(callSuper = true)
  21 +@Builder
  22 +@NoArgsConstructor
  23 +@AllArgsConstructor
  24 +public class IotOtaUpgradeRecordDO extends BaseDO {
  25 +
  26 + @TableId
  27 + private Long id;
  28 +
  29 + /**
  30 + * 固件编号
  31 + *
  32 + * 关联 {@link IotOtaFirmwareDO#getId()}
  33 + */
  34 + private Long firmwareId;
  35 + /**
  36 + * 任务编号
  37 + *
  38 + * 关联 {@link IotOtaUpgradeTaskDO#getId()}
  39 + */
  40 + private Long taskId;
  41 +
  42 + /**
  43 + * 升级状态
  44 + *
  45 + * TODO
  46 + */
  47 + private Integer status;
  48 + /**
  49 + * 升级进度,百分比
  50 + */
  51 + private Integer progress;
  52 +
  53 + /**
  54 + * 产品标识
  55 + *
  56 + * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getId()}
  57 + */
  58 + private String productKey;
  59 + /**
  60 + * 设备名称
  61 + *
  62 + * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO#getId()}
  63 + */
  64 + private String deviceName;
  65 + /**
  66 + * 设备编号
  67 + *
  68 + * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO#getId()}
  69 + */
  70 + private String deviceId;
  71 +
  72 + /**
  73 + * 升级开始时间
  74 + */
  75 + private LocalDateTime startTime;
  76 + /**
  77 + * 升级结束时间
  78 + */
  79 + private LocalDateTime endTime;
  80 +
  81 +
  82 +
  83 +}
0 \ No newline at end of file 84 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/ota/IotOtaUpgradeTaskDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.dal.dataobject.ota;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
  5 +import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableField;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
  9 +import lombok.*;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * IoT OTA 升级任务 DO
  15 + *
  16 + * @author 芋道源码
  17 + */
  18 +@TableName(value = "iot_ota_upgrade_task", autoResultMap = true)
  19 +@KeySequence("iot_ota_upgrade_task_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  20 +@Data
  21 +@EqualsAndHashCode(callSuper = true)
  22 +@ToString(callSuper = true)
  23 +@Builder
  24 +@NoArgsConstructor
  25 +@AllArgsConstructor
  26 +public class IotOtaUpgradeTaskDO extends BaseDO {
  27 +
  28 + /**
  29 + * 任务编号
  30 + */
  31 + @TableField
  32 + private Long id;
  33 + /**
  34 + * 任务名称
  35 + */
  36 + private String name;
  37 + /**
  38 + * 任务描述
  39 + */
  40 + private String description;
  41 +
  42 + /**
  43 + * 固件编号
  44 + *
  45 + * 关联 {@link IotOtaFirmwareDO#getId()}
  46 + */
  47 + private Long firmwareId;
  48 +
  49 + /**
  50 + * 任务类型
  51 + *
  52 + * TODO @芋艿:1-全部、2-指定设备
  53 + */
  54 + private Integer type;
  55 + /**
  56 + * 选中的设备名字数组
  57 + *
  58 + * 关联 {@link IotDeviceDO#getDeviceName()}
  59 + */
  60 + @TableField(typeHandler = JacksonTypeHandler.class)
  61 + private List<String> deviceNames;
  62 +
  63 +}
0 \ No newline at end of file 64 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotAlertRecordDO.java
@@ -63,6 +63,7 @@ public class IotAlertRecordDO extends BaseDO { @@ -63,6 +63,7 @@ public class IotAlertRecordDO extends BaseDO {
63 @TableField(typeHandler = JacksonTypeHandler.class) 63 @TableField(typeHandler = JacksonTypeHandler.class)
64 private IotDeviceMessage deviceMessage; 64 private IotDeviceMessage deviceMessage;
65 65
  66 + // TODO @芋艿:换成枚举,枚举对应 ApiErrorLogProcessStatusEnum
66 /** 67 /**
67 * 处理状态 68 * 处理状态
68 * 69 *
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/control/IotDeviceDownstreamServiceImpl.java
@@ -57,6 +57,7 @@ public class IotDeviceDownstreamServiceImpl implements IotDeviceDownstreamServic @@ -57,6 +57,7 @@ public class IotDeviceDownstreamServiceImpl implements IotDeviceDownstreamServic
57 public IotDeviceMessage downstreamDevice(IotDeviceDownstreamReqVO downstreamReqVO) { 57 public IotDeviceMessage downstreamDevice(IotDeviceDownstreamReqVO downstreamReqVO) {
58 // 校验设备是否存在 58 // 校验设备是否存在
59 IotDeviceDO device = deviceService.validateDeviceExists(downstreamReqVO.getId()); 59 IotDeviceDO device = deviceService.validateDeviceExists(downstreamReqVO.getId());
  60 + // TODO @芋艿:离线设备,不允许推送
60 // TODO 芋艿:父设备的处理 61 // TODO 芋艿:父设备的处理
61 IotDeviceDO parentDevice = null; 62 IotDeviceDO parentDevice = null;
62 63