Commit 439b68e3f370cfc14341c06b7ab985547e7261f3
Committed by
Gitee
!1412 修复设备导入缺失上报方式的逻辑
Merge pull request !1412 from puhui999/feature/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,6 +8,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.*; | 9 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.*; |
| 10 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; | 10 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 11 | +import cn.iocoder.yudao.module.iot.enums.product.IotLocationTypeEnum; | ||
| 11 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; | 12 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| 12 | import io.swagger.v3.oas.annotations.Operation; | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 14 | import io.swagger.v3.oas.annotations.Parameter; |
| @@ -104,7 +105,7 @@ public class IotDeviceController { | @@ -104,7 +105,7 @@ public class IotDeviceController { | ||
| 104 | @PreAuthorize("@ss.hasPermission('iot:device:export')") | 105 | @PreAuthorize("@ss.hasPermission('iot:device:export')") |
| 105 | @ApiAccessLog(operateType = EXPORT) | 106 | @ApiAccessLog(operateType = EXPORT) |
| 106 | public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO, | 107 | public void exportDeviceExcel(@Valid IotDevicePageReqVO exportReqVO, |
| 107 | - HttpServletResponse response) throws IOException { | 108 | + HttpServletResponse response) throws IOException { |
| 108 | exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | 109 | exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 109 | CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO); | 110 | CommonResult<PageResult<IotDeviceRespVO>> result = getDevicePage(exportReqVO); |
| 110 | // 导出 Excel | 111 | // 导出 Excel |
| @@ -152,9 +153,10 @@ public class IotDeviceController { | @@ -152,9 +153,10 @@ public class IotDeviceController { | ||
| 152 | // 手动创建导出 demo | 153 | // 手动创建导出 demo |
| 153 | List<IotDeviceImportExcelVO> list = Arrays.asList( | 154 | List<IotDeviceImportExcelVO> list = Arrays.asList( |
| 154 | IotDeviceImportExcelVO.builder().deviceName("温度传感器001").parentDeviceName("gateway110") | 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 | ExcelUtils.write(response, "设备导入模板.xls", "数据", IotDeviceImportExcelVO.class, list); | 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 | package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device; | 1 | package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device; |
| 2 | 2 | ||
| 3 | import cn.idev.excel.annotation.ExcelProperty; | 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 | import io.swagger.v3.oas.annotations.media.Schema; | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import jakarta.validation.constraints.NotEmpty; | 7 | import jakarta.validation.constraints.NotEmpty; |
| 8 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | import lombok.AllArgsConstructor; | 9 | import lombok.AllArgsConstructor; |
| 7 | import lombok.Builder; | 10 | import lombok.Builder; |
| 8 | import lombok.Data; | 11 | import lombok.Data; |
| @@ -34,4 +37,9 @@ public class IotDeviceImportExcelVO { | @@ -34,4 +37,9 @@ public class IotDeviceImportExcelVO { | ||
| 34 | @ExcelProperty("设备分组") | 37 | @ExcelProperty("设备分组") |
| 35 | private String groupNames; | 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,7 +376,8 @@ public class IotDeviceServiceImpl implements IotDeviceService { | ||
| 376 | if (existDevice == null) { | 376 | if (existDevice == null) { |
| 377 | createDevice(new IotDeviceSaveReqVO() | 377 | createDevice(new IotDeviceSaveReqVO() |
| 378 | .setDeviceName(importDevice.getDeviceName()) | 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 | respVO.getCreateDeviceNames().add(importDevice.getDeviceName()); | 381 | respVO.getCreateDeviceNames().add(importDevice.getDeviceName()); |
| 381 | return; | 382 | return; |
| 382 | } | 383 | } |
| @@ -385,7 +386,7 @@ public class IotDeviceServiceImpl implements IotDeviceService { | @@ -385,7 +386,7 @@ public class IotDeviceServiceImpl implements IotDeviceService { | ||
| 385 | throw exception(DEVICE_KEY_EXISTS); | 386 | throw exception(DEVICE_KEY_EXISTS); |
| 386 | } | 387 | } |
| 387 | updateDevice(new IotDeviceSaveReqVO().setId(existDevice.getId()) | 388 | updateDevice(new IotDeviceSaveReqVO().setId(existDevice.getId()) |
| 388 | - .setGatewayId(gatewayId).setGroupIds(groupIds)); | 389 | + .setGatewayId(gatewayId).setGroupIds(groupIds).setLocationType(importDevice.getLocationType())); |
| 389 | respVO.getUpdateDeviceNames().add(importDevice.getDeviceName()); | 390 | respVO.getUpdateDeviceNames().add(importDevice.getDeviceName()); |
| 390 | } catch (ServiceException ex) { | 391 | } catch (ServiceException ex) { |
| 391 | respVO.getFailureDeviceNames().put(importDevice.getDeviceName(), ex.getMessage()); | 392 | respVO.getFailureDeviceNames().put(importDevice.getDeviceName(), ex.getMessage()); |