!1412 修复设备导入缺失上报方式的逻辑
Merge pull request !1412 from puhui999/feature/iot
This commit is contained in:
@@ -8,6 +8,7 @@ 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.*;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotLocationTypeEnum;
|
||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -104,7 +105,7 @@ public class IotDeviceController {
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO);
|
||||
// 导出 Excel
|
||||
@@ -152,9 +153,10 @@ public class IotDeviceController {
|
||||
// 手动创建导出 demo
|
||||
List<IotDeviceImportExcelVO> list = Arrays.asList(
|
||||
IotDeviceImportExcelVO.builder().deviceName("温度传感器001").parentDeviceName("gateway110")
|
||||
.productKey("1de24640dfe").groupNames("灰度分组,生产分组").build(),
|
||||
IotDeviceImportExcelVO.builder().deviceName("biubiu")
|
||||
.productKey("YzvHxd4r67sT4s2B").groupNames("").build());
|
||||
.productKey("1de24640dfe").groupNames("灰度分组,生产分组")
|
||||
.locationType(IotLocationTypeEnum.IP.getType()).build(),
|
||||
IotDeviceImportExcelVO.builder().deviceName("biubiu").productKey("YzvHxd4r67sT4s2B")
|
||||
.groupNames("").locationType(IotLocationTypeEnum.MANUAL.getType()).build());
|
||||
// 输出
|
||||
ExcelUtils.write(response, "设备导入模板.xls", "数据", IotDeviceImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotLocationTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -34,4 +37,9 @@ public class IotDeviceImportExcelVO {
|
||||
@ExcelProperty("设备分组")
|
||||
private String groupNames;
|
||||
|
||||
@ExcelProperty("上报方式(1:IP 定位, 2:设备上报,3:手动定位)")
|
||||
@NotNull(message = "上报方式不能为空")
|
||||
@InEnum(IotLocationTypeEnum.class)
|
||||
private Integer locationType;
|
||||
|
||||
}
|
||||
|
||||
@@ -376,7 +376,8 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
||||
if (existDevice == null) {
|
||||
createDevice(new IotDeviceSaveReqVO()
|
||||
.setDeviceName(importDevice.getDeviceName())
|
||||
.setProductId(product.getId()).setGatewayId(gatewayId).setGroupIds(groupIds));
|
||||
.setProductId(product.getId()).setGatewayId(gatewayId).setGroupIds(groupIds)
|
||||
.setLocationType(importDevice.getLocationType()));
|
||||
respVO.getCreateDeviceNames().add(importDevice.getDeviceName());
|
||||
return;
|
||||
}
|
||||
@@ -385,7 +386,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
||||
throw exception(DEVICE_KEY_EXISTS);
|
||||
}
|
||||
updateDevice(new IotDeviceSaveReqVO().setId(existDevice.getId())
|
||||
.setGatewayId(gatewayId).setGroupIds(groupIds));
|
||||
.setGatewayId(gatewayId).setGroupIds(groupIds).setLocationType(importDevice.getLocationType()));
|
||||
respVO.getUpdateDeviceNames().add(importDevice.getDeviceName());
|
||||
} catch (ServiceException ex) {
|
||||
respVO.getFailureDeviceNames().put(importDevice.getDeviceName(), ex.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user