From 5fb249f7653928242cc7bc9270f9b38c23b330e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=AD=E7=90=AA=E6=9E=AB?= <374696376@qq.com> Date: Tue, 18 Jul 2023 22:33:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/controller/OtaController.java | 6 ++++-- .../manager/dto/vo/ota/DeviceUpgradeVo.java | 17 +++++++++++++++++ .../cc/iotkit/manager/service/OtaService.java | 8 ++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/ota/DeviceUpgradeVo.java 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); } });