Commit 8ced4a0a2cee3dbee171ecdcfb7766ede875f2d5

Authored by YunaiV
1 parent 7bcbe9a2

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

yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeRecordStatusEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.enums.ota;
  2 +
  3 +
  4 +import cn.iocoder.yudao.framework.common.core.ArrayValuable;
  5 +import lombok.Getter;
  6 +import lombok.RequiredArgsConstructor;
  7 +
  8 +import java.util.Arrays;
  9 +
  10 +/**
  11 + * IoT OTA 升级记录的范围枚举
  12 + *
  13 + * @author haohao
  14 + */
  15 +@RequiredArgsConstructor
  16 +@Getter
  17 +public enum IotOtaUpgradeRecordStatusEnum implements ArrayValuable<Integer> {
  18 +
  19 + PENDING(0), // 待推送
  20 + PUSHED(10), // 已推送
  21 + UPGRADING(20), // 升级中
  22 + SUCCESS(30), // 升级成功
  23 + FAILURE(40), // 升级失败
  24 + CANCELED(50),; // 已取消
  25 +
  26 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotOtaUpgradeRecordStatusEnum::getStatus).toArray(Integer[]::new);
  27 +
  28 + /**
  29 + * 范围
  30 + */
  31 + private final Integer status;
  32 +
  33 + @Override
  34 + public Integer[] array() {
  35 + return ARRAYS;
  36 + }
  37 +
  38 +}
0 \ No newline at end of file 39 \ No newline at end of file
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeTaskScopeEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.enums.ota;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.ArrayValuable;
  4 +import lombok.Getter;
  5 +import lombok.RequiredArgsConstructor;
  6 +
  7 +import java.util.Arrays;
  8 +
  9 +/**
  10 + * IoT OTA 升级任务的范围枚举
  11 + *
  12 + * @author haohao
  13 + */
  14 +@RequiredArgsConstructor
  15 +@Getter
  16 +public enum IotOtaUpgradeTaskScopeEnum implements ArrayValuable<Integer> {
  17 +
  18 + ALL(1), // 全部设备:只包括当前产品下的设备,不包括未来创建的设备
  19 + SELECT(2); // 指定设备
  20 +
  21 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotOtaUpgradeTaskScopeEnum::getScope).toArray(Integer[]::new);
  22 +
  23 + /**
  24 + * 范围
  25 + */
  26 + private final Integer scope;
  27 +
  28 + @Override
  29 + public Integer[] array() {
  30 + return ARRAYS;
  31 + }
  32 +
  33 +}
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ota/IotOtaUpgradeTaskStatusEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.enums.ota;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.ArrayValuable;
  4 +import lombok.Getter;
  5 +import lombok.RequiredArgsConstructor;
  6 +
  7 +import java.util.Arrays;
  8 +
  9 +/**
  10 + * IoT OTA 升级任务的范围枚举
  11 + *
  12 + * @author haohao
  13 + */
  14 +@RequiredArgsConstructor
  15 +@Getter
  16 +public enum IotOtaUpgradeTaskStatusEnum implements ArrayValuable<Integer> {
  17 +
  18 + IN_PROGRESS(10), // 进行中:升级中
  19 + COMPLETED(20), // 已完成:已结束,全部升级完成
  20 + INCOMPLETE(21), // 未完成:已结束,部分升级完成
  21 + CANCELED(30),; // 已取消:一般是主动取消任务
  22 +
  23 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotOtaUpgradeTaskStatusEnum::getStatus).toArray(Integer[]::new);
  24 +
  25 + /**
  26 + * 范围
  27 + */
  28 + private final Integer status;
  29 +
  30 + @Override
  31 + public Integer[] array() {
  32 + return ARRAYS;
  33 + }
  34 +
  35 +}
0 \ No newline at end of file 36 \ 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
@@ -40,17 +40,6 @@ public class IotOtaUpgradeRecordDO extends BaseDO { @@ -40,17 +40,6 @@ public class IotOtaUpgradeRecordDO extends BaseDO {
40 private Long taskId; 40 private Long taskId;
41 41
42 /** 42 /**
43 - * 升级状态  
44 - *  
45 - * TODO  
46 - */  
47 - private Integer status;  
48 - /**  
49 - * 升级进度,百分比  
50 - */  
51 - private Integer progress;  
52 -  
53 - /**  
54 * 产品标识 43 * 产品标识
55 * 44 *
56 * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getId()} 45 * 关联 {@link cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO#getId()}
@@ -70,6 +59,23 @@ public class IotOtaUpgradeRecordDO extends BaseDO { @@ -70,6 +59,23 @@ public class IotOtaUpgradeRecordDO extends BaseDO {
70 private String deviceId; 59 private String deviceId;
71 60
72 /** 61 /**
  62 + * 升级状态
  63 + *
  64 + * 关联 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeRecordStatusEnum}
  65 + */
  66 + private Integer status;
  67 + /**
  68 + * 升级进度,百分比
  69 + */
  70 + private Integer progress;
  71 + /**
  72 + * 升级进度描述
  73 + *
  74 + * 注意,只记录设备最后一次的升级进度描述
  75 + * 如果想看历史记录,可以查看 {@link cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO} 设备日志
  76 + */
  77 + private String description;
  78 + /**
73 * 升级开始时间 79 * 升级开始时间
74 */ 80 */
75 private LocalDateTime startTime; 81 private LocalDateTime startTime;
@@ -78,6 +84,4 @@ public class IotOtaUpgradeRecordDO extends BaseDO { @@ -78,6 +84,4 @@ public class IotOtaUpgradeRecordDO extends BaseDO {
78 */ 84 */
79 private LocalDateTime endTime; 85 private LocalDateTime endTime;
80 86
81 -  
82 -  
83 } 87 }
84 \ No newline at end of file 88 \ 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
@@ -47,11 +47,18 @@ public class IotOtaUpgradeTaskDO extends BaseDO { @@ -47,11 +47,18 @@ public class IotOtaUpgradeTaskDO extends BaseDO {
47 private Long firmwareId; 47 private Long firmwareId;
48 48
49 /** 49 /**
50 - * 任务类型 50 + * 任务状态
51 * 51 *
52 - * TODO @芋艿:1-全部、2-指定设备 52 + * 关联 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeTaskStatusEnum}
53 */ 53 */
54 - private Integer type; 54 + private Integer status;
  55 +
  56 + /**
  57 + * 升级范围
  58 + *
  59 + * 关联 {@link cn.iocoder.yudao.module.iot.enums.ota.IotOtaUpgradeTaskScopeEnum}
  60 + */
  61 + private Integer scope;
55 /** 62 /**
56 * 选中的设备名字数组 63 * 选中的设备名字数组
57 * 64 *