Browse Source

fix:添加批量升级创建时间

荭琪枫 1 year ago
parent
commit
3b5f1aeb43

+ 2 - 0
iot-common/iot-common-dao/iot-common-model/src/main/java/cc/iotkit/model/ota/DeviceOtaInfo.java

@@ -17,6 +17,8 @@ public class DeviceOtaInfo implements Id<Long> {
 
     private Long id;
 
+    private Long packageId;
+
     private String desc;
 
     private String version;

+ 2 - 0
iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/model/TbDeviceOtaInfo.java

@@ -25,6 +25,8 @@ public class TbDeviceOtaInfo {
     @GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
     private Long id;
 
+    private Long packageId;
+
     @Column(name = "[desc]")
     private String desc;
 

+ 2 - 0
iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/ota/DeviceOtaInfoBo.java

@@ -20,6 +20,8 @@ public class DeviceOtaInfoBo extends BaseDto {
 
     private Long id;
 
+    private Long packageId;
+
     private String taskId;
 
     private String version;

+ 2 - 0
iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/ota/DeviceOtaInfoVo.java

@@ -21,6 +21,8 @@ public class DeviceOtaInfoVo implements Serializable {
 
     private Long id;
 
+    private Long packageId;
+
     private String desc;
 
     private String version;

+ 5 - 5
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/OtaService.java

@@ -141,13 +141,14 @@ public class OtaService {
     /**
      * 开始升级
      */
-    public String startUpgrade(Long otaId, List<String> deviceIds) {
-        OtaPackage otaPackage = iOtaPackageData.findById(otaId);
+    public String startUpgrade(Long otaPackageId, List<String> deviceIds) {
+        OtaPackage otaPackage = iOtaPackageData.findById(otaPackageId);
         if (Objects.isNull(otaPackage)) {
             throw new BizException(ErrCode.DATA_NOT_EXIST);
         }
         DeviceOtaInfo deviceOtaInfo = deviceOtaInfoData.save(DeviceOtaInfo.builder()
                 .total(deviceIds.size())
+                        .packageId(otaPackageId)
                 .productKey(otaPackage.getProductKey())
                 .module(otaPackage.getModule())
                 .desc(otaPackage.getDesc())
@@ -173,8 +174,8 @@ public class OtaService {
                         .build());
                 success.getAndSet(success.get() + 1);
             } catch (Exception ex) {
-                log.error("add device upgrade error: ", ex);
-                fail.getAndSet(success.get() + 1);
+                log.error("add device upgrade error deviceId:{} ", deviceId, ex);
+                fail.getAndSet(fail.get() + 1);
             }
         });
         deviceOtaDetailData.batchSave(deviceOtaDetails);
@@ -206,5 +207,4 @@ public class OtaService {
                 .build();
         deviceService.otaUpgrade(deviceId, true, otaPackage);
     }
-
 }