【功能新增】IoT:设备管理界面增加导出设备功能
This commit is contained in:
parent
b5ac526139
commit
3450658159
|
@ -13,4 +13,7 @@ public class DictTypeConstants {
|
|||
public static final String PROTOCOL_TYPE = "iot_protocol_type";
|
||||
public static final String DATA_FORMAT = "iot_data_format";
|
||||
public static final String VALIDATE_TYPE = "iot_validate_type";
|
||||
|
||||
public static final String DEVICE_STATUS = "iot_device_status";
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.device;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.IotDevicePageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.IotDeviceRespVO;
|
||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.IotDeviceSaveReqVO;
|
||||
|
@ -13,13 +16,16 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
|
@ -81,6 +87,19 @@ public class IotDeviceController {
|
|||
return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出设备 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "设备.xls", "数据", IotDeviceRespVO.class,
|
||||
result.getData().getList());
|
||||
}
|
||||
|
||||
@GetMapping("/count")
|
||||
@Operation(summary = "获得设备数量")
|
||||
@Parameter(name = "productId", description = "产品编号", example = "1")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -8,6 +10,8 @@ import lombok.Data;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.module.iot.enums.DictTypeConstants.DEVICE_STATUS;
|
||||
|
||||
@Schema(description = "管理后台 - IoT 设备 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
|
@ -21,9 +25,21 @@ public class IotDeviceRespVO {
|
|||
private String deviceKey;
|
||||
|
||||
@Schema(description = "设备名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@ExcelProperty("设备名称备")
|
||||
@ExcelProperty("设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "设备备注名称", example = "张三")
|
||||
@ExcelProperty("设备备注名称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "设备序列号", example = "1024")
|
||||
@ExcelProperty("设备序列号")
|
||||
private String serialNumber;
|
||||
|
||||
@Schema(description = "设备图片", example = "我是一名码农")
|
||||
@ExcelProperty("设备图片")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "设备分组编号数组", example = "1,2")
|
||||
private Set<Long> groupIds;
|
||||
|
||||
|
@ -39,15 +55,12 @@ public class IotDeviceRespVO {
|
|||
@ExcelProperty("设备类型")
|
||||
private Integer deviceType;
|
||||
|
||||
@Schema(description = "设备备注名称", example = "张三")
|
||||
@ExcelProperty("设备备注名称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "网关设备 ID", example = "16380")
|
||||
private Long gatewayId;
|
||||
|
||||
@Schema(description = "设备状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("设备状态")
|
||||
@ExcelProperty(value = "设备状态", converter = DictConvert.class)
|
||||
@DictFormat(DEVICE_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "设备状态最后更新时间")
|
||||
|
|
Loading…
Reference in New Issue