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

V0.5.x
荭琪枫 2023-07-18 22:33:34 +08:00
parent a58a129737
commit 5fb249f765
3 changed files with 27 additions and 4 deletions

View File

@ -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.vo.ota.DeviceOtaDetailVo;
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.service.OtaService;
import cc.iotkit.model.ota.OtaPackage;
@ -68,8 +69,9 @@ public class OtaController extends BaseController {
@ApiOperation("OTA升级")
@PostMapping("/device/upgrade")
public String deviceUpgrade(@RequestBody Request<DeviceUpgradeBo> request) {
return otaService.startUpgrade(request.getData().getOtaId(), request.getData().getDeviceIds());
public DeviceUpgradeVo deviceUpgrade(@RequestBody Request<DeviceUpgradeBo> request) {
String result = otaService.startUpgrade(request.getData().getOtaId(), request.getData().getDeviceIds());
return DeviceUpgradeVo.builder().result(result).build();
}
@ApiOperation("设备升级结果查询")

View File

@ -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;
}

View File

@ -27,6 +27,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import cc.iotkit.common.oss.entity.UploadResult;
@ -53,7 +54,9 @@ public class OtaService {
private final IOtaPackageData iOtaPackageData;
private final DeviceService deviceService;
private final IDeviceOtaInfoData deviceOtaInfoData;
@Qualifier("deviceInfoDataCache")
private final IDeviceInfoData deviceInfoData;
private final IDeviceOtaDetailData deviceOtaDetailData;
private final ISysOssData sysOssData;
@ -157,11 +160,11 @@ public class OtaService {
AtomicReference<Integer> fail = new AtomicReference<>(0);
deviceIds.forEach(deviceId -> {
try {
DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(deviceId);
//DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(deviceId);
String taskId = deviceService.otaUpgrade(deviceId, true, otaPackage);
deviceOtaDetails.add(DeviceOtaDetail.builder()
.taskId(taskId)
.deviceName(deviceInfo.getDeviceName())
//.deviceName(deviceInfo.getDeviceName())
.otaInfoId(deviceOtaInfo.getId())
.module(otaPackage.getModule())
.version(otaPackage.getVersion())
@ -170,6 +173,7 @@ public class OtaService {
.build());
success.getAndSet(success.get() + 1);
} catch (Exception ex) {
log.error("add device upgrade error: ",ex);
fail.getAndSet(success.get() + 1);
}
});