feat:【IoT 物联网】新版本同步

This commit is contained in:
YunaiV
2025-08-30 10:54:35 +08:00
parent a89b6d14a8
commit 92581e3b24
12 changed files with 83 additions and 209 deletions

View File

@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.iot.controller.admin.ota;
import cn.hutool.core.collection.CollUtil;
4import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
@@ -21,7 +21,11 @@ import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@@ -44,8 +48,8 @@ public class IotOtaTaskRecordController {
@GetMapping("/get-status-statistics")
@Operation(summary = "获得 OTA 升级记录状态统计")
@Parameters({
@Parameter(name = "firmwareId", description = "固件编号", example = "1024"),
@Parameter(name = "taskId", description = "升级任务编号", example = "2048")
@Parameter(name = "firmwareId", description = "固件编号", example = "1024"),
@Parameter(name = "taskId", description = "升级任务编号", example = "2048")
})
@PreAuthorize("@ss.hasPermission('iot:ota-task-record:query')")
public CommonResult<Map<Integer, Long>> getOtaTaskRecordStatusStatistics(
@@ -64,17 +68,17 @@ public class IotOtaTaskRecordController {
return success(PageResult.empty());
}
// 批量查询固件信息
Map<Long, IotOtaFirmwareDO> firmwareMap = otaFirmwareService.getOtaFirmwareMap(
convertSet(pageResult.getList(), IotOtaTaskRecordDO::getFromFirmwareId));
// 批量查询固件信息
Map<Long, IotOtaFirmwareDO> firmwareMap = otaFirmwareService.getOtaFirmwareMap(
convertSet(pageResult.getList(), IotOtaTaskRecordDO::getFromFirmwareId));
Map<Long, IotDeviceDO> deviceMap = deviceService.getDeviceMap(
convertSet(pageResult.getList(), IotOtaTaskRecordDO::getDeviceId));
convertSet(pageResult.getList(), IotOtaTaskRecordDO::getDeviceId));
// 转换为响应 VO
return success(BeanUtils.toBean(pageResult, IotOtaTaskRecordRespVO.class, (vo) -> {
MapUtils.findAndThen(firmwareMap, vo.getFromFirmwareId(), firmware ->
vo.setFromFirmwareVersion(firmware.getVersion()));
vo.setFromFirmwareVersion(firmware.getVersion()));
MapUtils.findAndThen(deviceMap, vo.getDeviceId(), device ->
vo.setDeviceName(device.getDeviceName()));
vo.setDeviceName(device.getDeviceName()));
}));
}