mirror of
https://github.com/YunaiV/ruoyi-vue-pro.git
synced 2026-04-19 13:48:37 +00:00
!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.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.*;
|
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.dal.dataobject.device.IotDeviceDO;
|
||||||
|
import cn.iocoder.yudao.module.iot.enums.product.IotLocationTypeEnum;
|
||||||
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;
|
||||||
@@ -104,7 +105,7 @@ public class IotDeviceController {
|
|||||||
@PreAuthorize("@ss.hasPermission('iot:device:export')")
|
@PreAuthorize("@ss.hasPermission('iot:device:export')")
|
||||||
@ApiAccessLog(operateType = EXPORT)
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO,
|
public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO);
|
CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO);
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
@@ -152,9 +153,10 @@ public class IotDeviceController {
|
|||||||
// 手动创建导出 demo
|
// 手动创建导出 demo
|
||||||
List<IotDeviceImportExcelVO> list = Arrays.asList(
|
List<IotDeviceImportExcelVO> list = Arrays.asList(
|
||||||
IotDeviceImportExcelVO.builder().deviceName("温度传感器001").parentDeviceName("gateway110")
|
IotDeviceImportExcelVO.builder().deviceName("温度传感器001").parentDeviceName("gateway110")
|
||||||
.productKey("1de24640dfe").groupNames("灰度分组,生产分组").build(),
|
.productKey("1de24640dfe").groupNames("灰度分组,生产分组")
|
||||||
IotDeviceImportExcelVO.builder().deviceName("biubiu")
|
.locationType(IotLocationTypeEnum.IP.getType()).build(),
|
||||||
.productKey("YzvHxd4r67sT4s2B").groupNames("").build());
|
IotDeviceImportExcelVO.builder().deviceName("biubiu").productKey("YzvHxd4r67sT4s2B")
|
||||||
|
.groupNames("").locationType(IotLocationTypeEnum.MANUAL.getType()).build());
|
||||||
// 输出
|
// 输出
|
||||||
ExcelUtils.write(response, "设备导入模板.xls", "数据", IotDeviceImportExcelVO.class, list);
|
ExcelUtils.write(response, "设备导入模板.xls", "数据", IotDeviceImportExcelVO.class, list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
|
package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
|
||||||
|
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -34,4 +37,9 @@ public class IotDeviceImportExcelVO {
|
|||||||
@ExcelProperty("设备分组")
|
@ExcelProperty("设备分组")
|
||||||
private String groupNames;
|
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) {
|
if (existDevice == null) {
|
||||||
createDevice(new IotDeviceSaveReqVO()
|
createDevice(new IotDeviceSaveReqVO()
|
||||||
.setDeviceName(importDevice.getDeviceName())
|
.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());
|
respVO.getCreateDeviceNames().add(importDevice.getDeviceName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -385,7 +386,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||||||
throw exception(DEVICE_KEY_EXISTS);
|
throw exception(DEVICE_KEY_EXISTS);
|
||||||
}
|
}
|
||||||
updateDevice(new IotDeviceSaveReqVO().setId(existDevice.getId())
|
updateDevice(new IotDeviceSaveReqVO().setId(existDevice.getId())
|
||||||
.setGatewayId(gatewayId).setGroupIds(groupIds));
|
.setGatewayId(gatewayId).setGroupIds(groupIds).setLocationType(importDevice.getLocationType()));
|
||||||
respVO.getUpdateDeviceNames().add(importDevice.getDeviceName());
|
respVO.getUpdateDeviceNames().add(importDevice.getDeviceName());
|
||||||
} catch (ServiceException ex) {
|
} catch (ServiceException ex) {
|
||||||
respVO.getFailureDeviceNames().put(importDevice.getDeviceName(), ex.getMessage());
|
respVO.getFailureDeviceNames().put(importDevice.getDeviceName(), ex.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user