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