diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/OtaController.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/OtaController.java index 221186e5..ee1026d6 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/OtaController.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/OtaController.java @@ -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 request) { - return otaService.startUpgrade(request.getData().getOtaId(), request.getData().getDeviceIds()); + public DeviceUpgradeVo deviceUpgrade(@RequestBody Request request) { + String result = otaService.startUpgrade(request.getData().getOtaId(), request.getData().getDeviceIds()); + return DeviceUpgradeVo.builder().result(result).build(); } @ApiOperation("设备升级结果查询") diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/ota/DeviceUpgradeVo.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/ota/DeviceUpgradeVo.java new file mode 100644 index 00000000..13f557df --- /dev/null +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/ota/DeviceUpgradeVo.java @@ -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; +} diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/OtaService.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/OtaService.java index d877ddc5..b595385a 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/OtaService.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/OtaService.java @@ -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 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); } });