feat:【IoT 物联网】增加 OTA 相关的数据读取
This commit is contained in:
parent
ecf6a4a846
commit
e5ce195279
@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
|
|||||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
|
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@ -121,10 +122,14 @@ public class IotDeviceController {
|
|||||||
|
|
||||||
@GetMapping("/simple-list")
|
@GetMapping("/simple-list")
|
||||||
@Operation(summary = "获取设备的精简信息列表", description = "主要用于前端的下拉选项")
|
@Operation(summary = "获取设备的精简信息列表", description = "主要用于前端的下拉选项")
|
||||||
@Parameter(name = "deviceType", description = "设备类型", example = "1")
|
@Parameters({
|
||||||
|
@Parameter(name = "deviceType", description = "设备类型", example = "1"),
|
||||||
|
@Parameter(name = "productId", description = "产品编号", example = "1024")
|
||||||
|
})
|
||||||
public CommonResult<List<IotDeviceRespVO>> getDeviceSimpleList(
|
public CommonResult<List<IotDeviceRespVO>> getDeviceSimpleList(
|
||||||
@RequestParam(value = "deviceType", required = false) Integer deviceType) {
|
@RequestParam(value = "deviceType", required = false) Integer deviceType,
|
||||||
List<IotDeviceDO> list = deviceService.getDeviceListByDeviceType(deviceType);
|
@RequestParam(value = "productId", required = false) Long productId) {
|
||||||
|
List<IotDeviceDO> list = deviceService.getDeviceListByCondition(deviceType, productId);
|
||||||
return success(convertList(list, device -> // 只返回 id、name、productId 字段
|
return success(convertList(list, device -> // 只返回 id、name、productId 字段
|
||||||
new IotDeviceRespVO().setId(device.getId()).setDeviceName(device.getDeviceName())
|
new IotDeviceRespVO().setId(device.getId()).setDeviceName(device.getDeviceName())
|
||||||
.setProductId(device.getProductId())));
|
.setProductId(device.getProductId())));
|
||||||
|
|||||||
@ -3,12 +3,14 @@ package cn.iocoder.yudao.module.iot.controller.admin.ota;
|
|||||||
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.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwarePageReqVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwarePageReqVO;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareRespVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareRespVO;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareUpdateReqVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwareUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
|
import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
|
||||||
import cn.iocoder.yudao.module.iot.service.ota.IotOtaFirmwareService;
|
import cn.iocoder.yudao.module.iot.service.ota.IotOtaFirmwareService;
|
||||||
|
import cn.iocoder.yudao.module.iot.service.product.IotProductService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -27,6 +29,8 @@ public class IotOtaFirmwareController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IotOtaFirmwareService otaFirmwareService;
|
private IotOtaFirmwareService otaFirmwareService;
|
||||||
|
@Resource
|
||||||
|
private IotProductService productService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建 OTA 固件")
|
@Operation(summary = "创建 OTA 固件")
|
||||||
@ -47,8 +51,16 @@ public class IotOtaFirmwareController {
|
|||||||
@Operation(summary = "获得 OTA 固件")
|
@Operation(summary = "获得 OTA 固件")
|
||||||
@PreAuthorize("@ss.hasPermission('iot:ota-firmware:query')")
|
@PreAuthorize("@ss.hasPermission('iot:ota-firmware:query')")
|
||||||
public CommonResult<IotOtaFirmwareRespVO> getOtaFirmware(@RequestParam("id") Long id) {
|
public CommonResult<IotOtaFirmwareRespVO> getOtaFirmware(@RequestParam("id") Long id) {
|
||||||
IotOtaFirmwareDO otaFirmware = otaFirmwareService.getOtaFirmware(id);
|
IotOtaFirmwareDO firmware = otaFirmwareService.getOtaFirmware(id);
|
||||||
return success(BeanUtils.toBean(otaFirmware, IotOtaFirmwareRespVO.class));
|
if (firmware == null) {
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
return success(BeanUtils.toBean(firmware, IotOtaFirmwareRespVO.class, o -> {
|
||||||
|
IotProductDO product = productService.getProduct(firmware.getProductId());
|
||||||
|
if (product != null) {
|
||||||
|
o.setProductName(product.getName());
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
|
|||||||
@ -2,10 +2,15 @@ package cn.iocoder.yudao.module.iot.controller.admin.ota;
|
|||||||
|
|
||||||
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.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.task.record.IotOtaTaskRecordPageReqVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.task.record.IotOtaTaskRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.task.record.IotOtaTaskRecordRespVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.task.record.IotOtaTaskRecordRespVO;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
|
||||||
import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaTaskRecordDO;
|
import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaTaskRecordDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
|
||||||
|
import cn.iocoder.yudao.module.iot.service.ota.IotOtaFirmwareService;
|
||||||
import cn.iocoder.yudao.module.iot.service.ota.IotOtaTaskRecordService;
|
import cn.iocoder.yudao.module.iot.service.ota.IotOtaTaskRecordService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@ -13,6 +18,7 @@ import io.swagger.v3.oas.annotations.Parameters;
|
|||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
import org.dromara.hutool.core.collection.CollUtil;
|
||||||
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.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -23,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - IoT OTA 升级任务记录")
|
@Tag(name = "管理后台 - IoT OTA 升级任务记录")
|
||||||
@RestController
|
@RestController
|
||||||
@ -32,18 +39,22 @@ public class IotOtaTaskRecordController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IotOtaTaskRecordService otaTaskRecordService;
|
private IotOtaTaskRecordService otaTaskRecordService;
|
||||||
|
@Resource
|
||||||
|
private IotDeviceService deviceService;
|
||||||
|
@Resource
|
||||||
|
private IotOtaFirmwareService otaFirmwareService;
|
||||||
|
|
||||||
@GetMapping("/get-status-count")
|
@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>> getOtaTaskRecordStatusCountMap(
|
public CommonResult<Map<Integer, Long>> getOtaTaskRecordStatusStatistics(
|
||||||
@RequestParam(value = "firmwareId", required = false) Long firmwareId,
|
@RequestParam(value = "firmwareId", required = false) Long firmwareId,
|
||||||
@RequestParam(value = "taskId", required = false) Long taskId) {
|
@RequestParam(value = "taskId", required = false) Long taskId) {
|
||||||
return success(otaTaskRecordService.getOtaTaskRecordStatusCountMap(firmwareId, taskId));
|
return success(otaTaskRecordService.getOtaTaskRecordStatusStatistics(firmwareId, taskId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@ -52,7 +63,22 @@ public class IotOtaTaskRecordController {
|
|||||||
public CommonResult<PageResult<IotOtaTaskRecordRespVO>> getOtaTaskRecordPage(
|
public CommonResult<PageResult<IotOtaTaskRecordRespVO>> getOtaTaskRecordPage(
|
||||||
@Valid IotOtaTaskRecordPageReqVO pageReqVO) {
|
@Valid IotOtaTaskRecordPageReqVO pageReqVO) {
|
||||||
PageResult<IotOtaTaskRecordDO> pageResult = otaTaskRecordService.getOtaTaskRecordPage(pageReqVO);
|
PageResult<IotOtaTaskRecordDO> pageResult = otaTaskRecordService.getOtaTaskRecordPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, IotOtaTaskRecordRespVO.class));
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return success(PageResult.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量查询固件信息
|
||||||
|
Map<Long, IotOtaFirmwareDO> firmwareMap = otaFirmwareService.getOtaFirmwareMap(
|
||||||
|
convertSet(pageResult.getList(), IotOtaTaskRecordDO::getFromFirmwareId));
|
||||||
|
Map<Long, IotDeviceDO> deviceMap = deviceService.getDeviceMap(
|
||||||
|
convertSet(pageResult.getList(), IotOtaTaskRecordDO::getDeviceId));
|
||||||
|
// 转换为响应 VO
|
||||||
|
return success(BeanUtils.toBean(pageResult, IotOtaTaskRecordRespVO.class, (vo) -> {
|
||||||
|
MapUtils.findAndThen(firmwareMap, vo.getFromFirmwareId(), firmware ->
|
||||||
|
vo.setFromFirmwareVersion(firmware.getVersion()));
|
||||||
|
MapUtils.findAndThen(deviceMap, vo.getDeviceId(), device ->
|
||||||
|
vo.setDeviceName(device.getDeviceName()));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
|
|||||||
@ -25,6 +25,9 @@ public class IotOtaFirmwareRespVO implements VO {
|
|||||||
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
|
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "智能设备")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
@Schema(description = "固件文件 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/firmware.bin")
|
@Schema(description = "固件文件 URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/firmware.bin")
|
||||||
private String fileUrl;
|
private String fileUrl;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.task.record;
|
package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.task.record;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import cn.iocoder.yudao.module.iot.enums.ota.IotOtaTaskRecordStatusEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -11,7 +13,8 @@ public class IotOtaTaskRecordPageReqVO extends PageParam {
|
|||||||
@Schema(description = "升级任务编号", example = "1024")
|
@Schema(description = "升级任务编号", example = "1024")
|
||||||
private Long taskId;
|
private Long taskId;
|
||||||
|
|
||||||
@Schema(description = "设备标识", example = "摄像头A1-1")
|
@Schema(description = "升级记录状态", example = "5")
|
||||||
private String deviceName;
|
@InEnum(IotOtaTaskRecordStatusEnum.class)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,40 +3,46 @@ package cn.iocoder.yudao.module.iot.controller.admin.ota.vo.task.record;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - IoT OTA 升级记录 Response VO")
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - IoT OTA 升级任务记录 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class IotOtaTaskRecordRespVO {
|
public class IotOtaTaskRecordRespVO {
|
||||||
|
|
||||||
// TODO @芋艿:梳理字段
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
|
||||||
@Schema(description = "升级记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "固件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "固件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private Long firmwareId;
|
private Long firmwareId;
|
||||||
|
|
||||||
@Schema(description = "固件版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "v1.0.0")
|
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||||
private String firmwareVersion;
|
|
||||||
|
|
||||||
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Long taskId;
|
private Long taskId;
|
||||||
|
|
||||||
@Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
private String deviceId;
|
private Long deviceId;
|
||||||
|
|
||||||
@Schema(description = "来源的固件编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
@Schema(description = "设备名称", example = "智能开关")
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
@Schema(description = "来源的固件编号", example = "1023")
|
||||||
private Long fromFirmwareId;
|
private Long fromFirmwareId;
|
||||||
|
|
||||||
@Schema(description = "来源的固件版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "v1.0.0")
|
@Schema(description = "来源固件版本", example = "1.0.0")
|
||||||
private String fromFirmwareVersion;
|
private String fromFirmwareVersion;
|
||||||
|
|
||||||
@Schema(description = "升级状态", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "升级状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "升级进度,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
@Schema(description = "升级进度,百分比", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||||
private Integer progress;
|
private Integer progress;
|
||||||
|
|
||||||
@Schema(description = "升级进度描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
@Schema(description = "升级进度描述", example = "正在下载固件...")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,9 +52,11 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
|
|||||||
return selectCount(IotDeviceDO::getProductId, productId);
|
return selectCount(IotDeviceDO::getProductId, productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<IotDeviceDO> selectListByDeviceType(@Nullable Integer deviceType) {
|
default List<IotDeviceDO> selectListByCondition(@Nullable Integer deviceType,
|
||||||
|
@Nullable Long productId) {
|
||||||
return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
|
return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
|
||||||
.geIfPresent(IotDeviceDO::getDeviceType, deviceType));
|
.eqIfPresent(IotDeviceDO::getDeviceType, deviceType)
|
||||||
|
.eqIfPresent(IotDeviceDO::getProductId, productId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<IotDeviceDO> selectListByState(Integer state) {
|
default List<IotDeviceDO> selectListByState(Integer state) {
|
||||||
|
|||||||
@ -23,7 +23,8 @@ public interface IotOtaTaskRecordMapper extends BaseMapperX<IotOtaTaskRecordDO>
|
|||||||
|
|
||||||
default PageResult<IotOtaTaskRecordDO> selectPage(IotOtaTaskRecordPageReqVO pageReqVO) {
|
default PageResult<IotOtaTaskRecordDO> selectPage(IotOtaTaskRecordPageReqVO pageReqVO) {
|
||||||
return selectPage(pageReqVO, new LambdaQueryWrapperX<IotOtaTaskRecordDO>()
|
return selectPage(pageReqVO, new LambdaQueryWrapperX<IotOtaTaskRecordDO>()
|
||||||
.eqIfPresent(IotOtaTaskRecordDO::getTaskId, pageReqVO.getTaskId()));
|
.eqIfPresent(IotOtaTaskRecordDO::getTaskId, pageReqVO.getTaskId())
|
||||||
|
.eqIfPresent(IotOtaTaskRecordDO::getStatus, pageReqVO.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
default void updateByTaskIdAndStatus(Long taskId, Integer fromStatus, IotOtaTaskRecordDO updateRecord) {
|
default void updateByTaskIdAndStatus(Long taskId, Integer fromStatus, IotOtaTaskRecordDO updateRecord) {
|
||||||
|
|||||||
@ -18,5 +18,6 @@ public class DictTypeConstants {
|
|||||||
|
|
||||||
public static final String OTA_TASK_DEVICE_SCOPE = "iot_ota_task_device_scope";
|
public static final String OTA_TASK_DEVICE_SCOPE = "iot_ota_task_device_scope";
|
||||||
public static final String OTA_TASK_STATUS = "iot_ota_task_status";
|
public static final String OTA_TASK_STATUS = "iot_ota_task_status";
|
||||||
|
public static final String OTA_TASK_RECORD_STATUS = "iot_ota_task_record_status";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,8 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IoT 设备 Service 接口
|
* IoT 设备 Service 接口
|
||||||
*
|
*
|
||||||
@ -138,12 +140,14 @@ public interface IotDeviceService {
|
|||||||
PageResult<IotDeviceDO> getDevicePage(IotDevicePageReqVO pageReqVO);
|
PageResult<IotDeviceDO> getDevicePage(IotDevicePageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于设备类型,获得设备列表
|
* 根据条件,获得设备列表
|
||||||
*
|
*
|
||||||
* @param deviceType 设备类型
|
* @param deviceType 设备类型
|
||||||
|
* @param productId 产品编号
|
||||||
* @return 设备列表
|
* @return 设备列表
|
||||||
*/
|
*/
|
||||||
List<IotDeviceDO> getDeviceListByDeviceType(@Nullable Integer deviceType);
|
List<IotDeviceDO> getDeviceListByCondition(@Nullable Integer deviceType,
|
||||||
|
@Nullable Long productId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得状态,获得设备列表
|
* 获得状态,获得设备列表
|
||||||
@ -241,4 +245,22 @@ public interface IotDeviceService {
|
|||||||
*/
|
*/
|
||||||
List<IotDeviceDO> validateDeviceListExists(Collection<Long> ids);
|
List<IotDeviceDO> validateDeviceListExists(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得设备列表
|
||||||
|
*
|
||||||
|
* @param ids 设备编号数组
|
||||||
|
* @return 设备列表
|
||||||
|
*/
|
||||||
|
List<IotDeviceDO> getDeviceList(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得设备 Map
|
||||||
|
*
|
||||||
|
* @param ids 设备编号数组
|
||||||
|
* @return 设备 Map
|
||||||
|
*/
|
||||||
|
default Map<Long, IotDeviceDO> getDeviceMap(Collection<Long> ids) {
|
||||||
|
return convertMap(getDeviceList(ids), IotDeviceDO::getId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -264,8 +264,8 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IotDeviceDO> getDeviceListByDeviceType(@Nullable Integer deviceType) {
|
public List<IotDeviceDO> getDeviceListByCondition(@Nullable Integer deviceType, @Nullable Long productId) {
|
||||||
return deviceMapper.selectListByDeviceType(deviceType);
|
return deviceMapper.selectListByCondition(deviceType, productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -470,16 +470,21 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IotDeviceDO> validateDeviceListExists(Collection<Long> ids) {
|
public List<IotDeviceDO> validateDeviceListExists(Collection<Long> ids) {
|
||||||
if (CollUtil.isEmpty(ids)) {
|
List<IotDeviceDO> devices = getDeviceList(ids);
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<IotDeviceDO> devices = deviceMapper.selectByIds(ids);
|
|
||||||
if (devices.size() != ids.size()) {
|
if (devices.size() != ids.size()) {
|
||||||
throw exception(DEVICE_NOT_EXISTS);
|
throw exception(DEVICE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IotDeviceDO> getDeviceList(Collection<Long> ids) {
|
||||||
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return deviceMapper.selectByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
private IotDeviceServiceImpl getSelf() {
|
private IotDeviceServiceImpl getSelf() {
|
||||||
return SpringUtil.getBean(getClass());
|
return SpringUtil.getBean(getClass());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,12 @@ import cn.iocoder.yudao.module.iot.controller.admin.ota.vo.firmware.IotOtaFirmwa
|
|||||||
import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
|
import cn.iocoder.yudao.module.iot.dal.dataobject.ota.IotOtaFirmwareDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OTA 固件管理 Service 接口
|
* OTA 固件管理 Service 接口
|
||||||
*
|
*
|
||||||
@ -30,13 +36,31 @@ public interface IotOtaFirmwareService {
|
|||||||
void updateOtaFirmware(@Valid IotOtaFirmwareUpdateReqVO updateReqVO);
|
void updateOtaFirmware(@Valid IotOtaFirmwareUpdateReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据 ID 获取 OTA 固件信息
|
* 获取 OTA 固件信息
|
||||||
*
|
*
|
||||||
* @param id OTA 固件编号
|
* @param id 固件编号
|
||||||
* @return 固件信息
|
* @return 固件信息
|
||||||
*/
|
*/
|
||||||
IotOtaFirmwareDO getOtaFirmware(Long id);
|
IotOtaFirmwareDO getOtaFirmware(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 OTA 固件信息列表
|
||||||
|
*
|
||||||
|
* @param ids 固件编号集合
|
||||||
|
* @return 固件信息列表
|
||||||
|
*/
|
||||||
|
List<IotOtaFirmwareDO> getOtaFirmwareList(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 OTA 固件信息 Map
|
||||||
|
*
|
||||||
|
* @param ids 固件编号集合
|
||||||
|
* @return 固件信息 Map
|
||||||
|
*/
|
||||||
|
default Map<Long, IotOtaFirmwareDO> getOtaFirmwareMap(Collection<Long> ids) {
|
||||||
|
return convertMap(getOtaFirmwareList(ids), IotOtaFirmwareDO::getId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询 OTA 固件信息
|
* 分页查询 OTA 固件信息
|
||||||
*
|
*
|
||||||
@ -46,10 +70,10 @@ public interface IotOtaFirmwareService {
|
|||||||
PageResult<IotOtaFirmwareDO> getOtaFirmwarePage(@Valid IotOtaFirmwarePageReqVO pageReqVO);
|
PageResult<IotOtaFirmwareDO> getOtaFirmwarePage(@Valid IotOtaFirmwarePageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证物联网 OTA 固件是否存在
|
* 验证 OTA 固件是否存在
|
||||||
*
|
*
|
||||||
* @param id 物联网 OTA 固件编号
|
* @param id 固件编号
|
||||||
* @return OTA 固件
|
* @return 固件信息
|
||||||
*/
|
*/
|
||||||
IotOtaFirmwareDO validateFirmwareExists(Long id);
|
IotOtaFirmwareDO validateFirmwareExists(Long id);
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,13 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.OTA_FIRMWARE_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.OTA_FIRMWARE_NOT_EXISTS;
|
||||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.OTA_FIRMWARE_PRODUCT_VERSION_DUPLICATE;
|
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.OTA_FIRMWARE_PRODUCT_VERSION_DUPLICATE;
|
||||||
|
|
||||||
@ -76,6 +81,14 @@ public class IotOtaFirmwareServiceImpl implements IotOtaFirmwareService {
|
|||||||
return otaFirmwareMapper.selectById(id);
|
return otaFirmwareMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IotOtaFirmwareDO> getOtaFirmwareList(Collection<Long> ids) {
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return otaFirmwareMapper.selectByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<IotOtaFirmwareDO> getOtaFirmwarePage(IotOtaFirmwarePageReqVO pageReqVO) {
|
public PageResult<IotOtaFirmwareDO> getOtaFirmwarePage(IotOtaFirmwarePageReqVO pageReqVO) {
|
||||||
return otaFirmwareMapper.selectPage(pageReqVO);
|
return otaFirmwareMapper.selectPage(pageReqVO);
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public interface IotOtaTaskRecordService {
|
|||||||
* @param taskId 任务编号
|
* @param taskId 任务编号
|
||||||
* @return 状态统计 Map,key 为状态码,value 为对应状态的升级记录数量
|
* @return 状态统计 Map,key 为状态码,value 为对应状态的升级记录数量
|
||||||
*/
|
*/
|
||||||
Map<Integer, Long> getOtaTaskRecordStatusCountMap(Long firmwareId, Long taskId);
|
Map<Integer, Long> getOtaTaskRecordStatusStatistics(Long firmwareId, Long taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 OTA 升级记录
|
* 获取 OTA 升级记录
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class IotOtaTaskRecordServiceImpl implements IotOtaTaskRecordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Integer, Long> getOtaTaskRecordStatusCountMap(Long firmwareId, Long taskId) {
|
public Map<Integer, Long> getOtaTaskRecordStatusStatistics(Long firmwareId, Long taskId) {
|
||||||
// 按照 status 枚举,初始化 countMap 为 0
|
// 按照 status 枚举,初始化 countMap 为 0
|
||||||
Map<Integer, Long> countMap = convertMap(Arrays.asList(IotOtaTaskRecordStatusEnum.values()),
|
Map<Integer, Long> countMap = convertMap(Arrays.asList(IotOtaTaskRecordStatusEnum.values()),
|
||||||
IotOtaTaskRecordStatusEnum::getStatus, iotOtaTaskRecordStatusEnum -> 0L);
|
IotOtaTaskRecordStatusEnum::getStatus, iotOtaTaskRecordStatusEnum -> 0L);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user