fix:添加批量升级创建时间
parent
a58a129737
commit
5fb249f765
|
@ -10,6 +10,7 @@ import cc.iotkit.manager.dto.bo.ota.DeviceUpgradeBo;
|
||||||
import cc.iotkit.manager.dto.bo.ota.OtaPackageBo;
|
import cc.iotkit.manager.dto.bo.ota.OtaPackageBo;
|
||||||
import cc.iotkit.manager.dto.vo.ota.DeviceOtaDetailVo;
|
import cc.iotkit.manager.dto.vo.ota.DeviceOtaDetailVo;
|
||||||
import cc.iotkit.manager.dto.vo.ota.DeviceOtaInfoVo;
|
import cc.iotkit.manager.dto.vo.ota.DeviceOtaInfoVo;
|
||||||
|
import cc.iotkit.manager.dto.vo.ota.DeviceUpgradeVo;
|
||||||
import cc.iotkit.manager.dto.vo.ota.OtaPackageUploadVo;
|
import cc.iotkit.manager.dto.vo.ota.OtaPackageUploadVo;
|
||||||
import cc.iotkit.manager.service.OtaService;
|
import cc.iotkit.manager.service.OtaService;
|
||||||
import cc.iotkit.model.ota.OtaPackage;
|
import cc.iotkit.model.ota.OtaPackage;
|
||||||
|
@ -68,8 +69,9 @@ public class OtaController extends BaseController {
|
||||||
|
|
||||||
@ApiOperation("OTA升级")
|
@ApiOperation("OTA升级")
|
||||||
@PostMapping("/device/upgrade")
|
@PostMapping("/device/upgrade")
|
||||||
public String deviceUpgrade(@RequestBody Request<DeviceUpgradeBo> request) {
|
public DeviceUpgradeVo deviceUpgrade(@RequestBody Request<DeviceUpgradeBo> request) {
|
||||||
return otaService.startUpgrade(request.getData().getOtaId(), request.getData().getDeviceIds());
|
String result = otaService.startUpgrade(request.getData().getOtaId(), request.getData().getDeviceIds());
|
||||||
|
return DeviceUpgradeVo.builder().result(result).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("设备升级结果查询")
|
@ApiOperation("设备升级结果查询")
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package cc.iotkit.manager.dto.vo.ota;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 石恒
|
||||||
|
* @Date: 2023/7/18 21:48
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class DeviceUpgradeVo implements Serializable {
|
||||||
|
private String result;
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import cc.iotkit.common.oss.entity.UploadResult;
|
import cc.iotkit.common.oss.entity.UploadResult;
|
||||||
|
@ -53,7 +54,9 @@ public class OtaService {
|
||||||
|
|
||||||
private final IOtaPackageData iOtaPackageData;
|
private final IOtaPackageData iOtaPackageData;
|
||||||
private final DeviceService deviceService;
|
private final DeviceService deviceService;
|
||||||
|
|
||||||
private final IDeviceOtaInfoData deviceOtaInfoData;
|
private final IDeviceOtaInfoData deviceOtaInfoData;
|
||||||
|
@Qualifier("deviceInfoDataCache")
|
||||||
private final IDeviceInfoData deviceInfoData;
|
private final IDeviceInfoData deviceInfoData;
|
||||||
private final IDeviceOtaDetailData deviceOtaDetailData;
|
private final IDeviceOtaDetailData deviceOtaDetailData;
|
||||||
private final ISysOssData sysOssData;
|
private final ISysOssData sysOssData;
|
||||||
|
@ -157,11 +160,11 @@ public class OtaService {
|
||||||
AtomicReference<Integer> fail = new AtomicReference<>(0);
|
AtomicReference<Integer> fail = new AtomicReference<>(0);
|
||||||
deviceIds.forEach(deviceId -> {
|
deviceIds.forEach(deviceId -> {
|
||||||
try {
|
try {
|
||||||
DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(deviceId);
|
//DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(deviceId);
|
||||||
String taskId = deviceService.otaUpgrade(deviceId, true, otaPackage);
|
String taskId = deviceService.otaUpgrade(deviceId, true, otaPackage);
|
||||||
deviceOtaDetails.add(DeviceOtaDetail.builder()
|
deviceOtaDetails.add(DeviceOtaDetail.builder()
|
||||||
.taskId(taskId)
|
.taskId(taskId)
|
||||||
.deviceName(deviceInfo.getDeviceName())
|
//.deviceName(deviceInfo.getDeviceName())
|
||||||
.otaInfoId(deviceOtaInfo.getId())
|
.otaInfoId(deviceOtaInfo.getId())
|
||||||
.module(otaPackage.getModule())
|
.module(otaPackage.getModule())
|
||||||
.version(otaPackage.getVersion())
|
.version(otaPackage.getVersion())
|
||||||
|
@ -170,6 +173,7 @@ public class OtaService {
|
||||||
.build());
|
.build());
|
||||||
success.getAndSet(success.get() + 1);
|
success.getAndSet(success.get() + 1);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
log.error("add device upgrade error: ",ex);
|
||||||
fail.getAndSet(success.get() + 1);
|
fail.getAndSet(success.get() + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue