Commit 94abcdff003b4b105b8ce3dc614807592b17ba76
1 parent
d53bc66a
fix:【IoT 物联网】修复设备导入缺失上报方式的逻辑
Showing
3 changed files
with
17 additions
and
6 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java
| ... | ... | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | 9 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.*; |
| 10 | 10 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 11 | +import cn.iocoder.yudao.module.iot.enums.product.IotLocationTypeEnum; | |
| 11 | 12 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| 12 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | 14 | import io.swagger.v3.oas.annotations.Parameter; |
| ... | ... | @@ -104,7 +105,7 @@ public class IotDeviceController { |
| 104 | 105 | @PreAuthorize("@ss.hasPermission('iot:device:export')") |
| 105 | 106 | @ApiAccessLog(operateType = EXPORT) |
| 106 | 107 | public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO, |
| 107 | - HttpServletResponse response) throws IOException { | |
| 108 | + HttpServletResponse response) throws IOException { | |
| 108 | 109 | exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 109 | 110 | CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO); |
| 110 | 111 | // 导出 Excel |
| ... | ... | @@ -152,9 +153,10 @@ public class IotDeviceController { |
| 152 | 153 | // 手动创建导出 demo |
| 153 | 154 | List<IotDeviceImportExcelVO> list = Arrays.asList( |
| 154 | 155 | IotDeviceImportExcelVO.builder().deviceName("温度传感器001").parentDeviceName("gateway110") |
| 155 | - .productKey("1de24640dfe").groupNames("灰度分组,生产分组").build(), | |
| 156 | - IotDeviceImportExcelVO.builder().deviceName("biubiu") | |
| 157 | - .productKey("YzvHxd4r67sT4s2B").groupNames("").build()); | |
| 156 | + .productKey("1de24640dfe").groupNames("灰度分组,生产分组") | |
| 157 | + .locationType(IotLocationTypeEnum.IP.getType()).build(), | |
| 158 | + IotDeviceImportExcelVO.builder().deviceName("biubiu").productKey("YzvHxd4r67sT4s2B") | |
| 159 | + .groupNames("").locationType(IotLocationTypeEnum.MANUAL.getType()).build()); | |
| 158 | 160 | // 输出 |
| 159 | 161 | ExcelUtils.write(response, "设备导入模板.xls", "数据", IotDeviceImportExcelVO.class, list); |
| 160 | 162 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDeviceImportExcelVO.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device; |
| 2 | 2 | |
| 3 | 3 | import cn.idev.excel.annotation.ExcelProperty; |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import cn.iocoder.yudao.module.iot.enums.product.IotLocationTypeEnum; | |
| 4 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 7 | import jakarta.validation.constraints.NotEmpty; |
| 8 | +import jakarta.validation.constraints.NotNull; | |
| 6 | 9 | import lombok.AllArgsConstructor; |
| 7 | 10 | import lombok.Builder; |
| 8 | 11 | import lombok.Data; |
| ... | ... | @@ -34,4 +37,9 @@ public class IotDeviceImportExcelVO { |
| 34 | 37 | @ExcelProperty("设备分组") |
| 35 | 38 | private String groupNames; |
| 36 | 39 | |
| 40 | + @ExcelProperty("上报方式(1:IP 定位, 2:设备上报,3:手动定位)") | |
| 41 | + @NotNull(message = "上报方式不能为空") | |
| 42 | + @InEnum(IotLocationTypeEnum.class) | |
| 43 | + private Integer locationType; | |
| 44 | + | |
| 37 | 45 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceServiceImpl.java
| ... | ... | @@ -376,7 +376,8 @@ public class IotDeviceServiceImpl implements IotDeviceService { |
| 376 | 376 | if (existDevice == null) { |
| 377 | 377 | createDevice(new IotDeviceSaveReqVO() |
| 378 | 378 | .setDeviceName(importDevice.getDeviceName()) |
| 379 | - .setProductId(product.getId()).setGatewayId(gatewayId).setGroupIds(groupIds)); | |
| 379 | + .setProductId(product.getId()).setGatewayId(gatewayId).setGroupIds(groupIds) | |
| 380 | + .setLocationType(importDevice.getLocationType())); | |
| 380 | 381 | respVO.getCreateDeviceNames().add(importDevice.getDeviceName()); |
| 381 | 382 | return; |
| 382 | 383 | } |
| ... | ... | @@ -385,7 +386,7 @@ public class IotDeviceServiceImpl implements IotDeviceService { |
| 385 | 386 | throw exception(DEVICE_KEY_EXISTS); |
| 386 | 387 | } |
| 387 | 388 | updateDevice(new IotDeviceSaveReqVO().setId(existDevice.getId()) |
| 388 | - .setGatewayId(gatewayId).setGroupIds(groupIds)); | |
| 389 | + .setGatewayId(gatewayId).setGroupIds(groupIds).setLocationType(importDevice.getLocationType())); | |
| 389 | 390 | respVO.getUpdateDeviceNames().add(importDevice.getDeviceName()); |
| 390 | 391 | } catch (ServiceException ex) { |
| 391 | 392 | respVO.getFailureDeviceNames().put(importDevice.getDeviceName(), ex.getMessage()); | ... | ... |