Commit 47c281d933ffe3ace90ba73e66dcfc1863b33fb8
1 parent
25236678
【代码优化】IoT:去除 Simulation 关键字,定义更清晰
Showing
8 changed files
with
36 additions
and
31 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java
| ... | ... | @@ -6,9 +6,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceSimulationDownstreamReqVO; | |
| 9 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceDownstreamReqVO; | |
| 10 | 10 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.device.*; |
| 11 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceSimulationUpstreamReqVO; | |
| 11 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceUpstreamReqVO; | |
| 12 | 12 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 13 | 13 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| 14 | 14 | import cn.iocoder.yudao.module.iot.service.device.control.IotDeviceDownstreamService; |
| ... | ... | @@ -159,21 +159,19 @@ public class IotDeviceController { |
| 159 | 159 | ExcelUtils.write(response, "设备导入模板.xls", "数据", IotDeviceImportExcelVO.class, list); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - @PostMapping("/simulation-upstream") | |
| 163 | - @Operation(summary = "模拟设备上行") | |
| 164 | - @PreAuthorize("@ss.hasPermission('iot:device:simulation')") | |
| 165 | - public CommonResult<Boolean> simulationDeviceUpstream( | |
| 166 | - @Valid @RequestBody IotDeviceSimulationUpstreamReqVO upstreamReqVO) { | |
| 167 | - deviceUpstreamService.simulationDeviceUpstream(upstreamReqVO); | |
| 162 | + @PostMapping("/upstream") | |
| 163 | + @Operation(summary = "设备上行", description = "可用于设备模拟") | |
| 164 | + @PreAuthorize("@ss.hasPermission('iot:device:upstream')") | |
| 165 | + public CommonResult<Boolean> upstreamDevice(@Valid @RequestBody IotDeviceUpstreamReqVO upstreamReqVO) { | |
| 166 | + deviceUpstreamService.upstreamDevice(upstreamReqVO); | |
| 168 | 167 | return success(true); |
| 169 | 168 | } |
| 170 | 169 | |
| 171 | - @PostMapping("/simulation-downstream") | |
| 172 | - @Operation(summary = "模拟设备下行") | |
| 173 | - @PreAuthorize("@ss.hasPermission('iot:device:simulation')") | |
| 174 | - public CommonResult<Boolean> simulationDownstreamDevice( | |
| 175 | - @Valid @RequestBody IotDeviceSimulationDownstreamReqVO downstreamReqVO) { | |
| 176 | - deviceDownstreamService.simulationDeviceDownstream(downstreamReqVO); | |
| 170 | + @PostMapping("/downstream") | |
| 171 | + @Operation(summary = "设备下行", description = "可用于设备模拟") | |
| 172 | + @PreAuthorize("@ss.hasPermission('iot:device:downstream')") | |
| 173 | + public CommonResult<Boolean> downstreamDevice(@Valid @RequestBody IotDeviceDownstreamReqVO downstreamReqVO) { | |
| 174 | + deviceDownstreamService.downstreamDevice(downstreamReqVO); | |
| 177 | 175 | return success(true); |
| 178 | 176 | } |
| 179 | 177 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceSimulationDownstreamReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceDownstreamReqVO.java
| ... | ... | @@ -7,9 +7,9 @@ import jakarta.validation.constraints.NotEmpty; |
| 7 | 7 | import jakarta.validation.constraints.NotNull; |
| 8 | 8 | import lombok.Data; |
| 9 | 9 | |
| 10 | -@Schema(description = "管理后台 - IoT 模拟设备下行 Request VO") // 服务调用、属性设置、属性获取等 | |
| 10 | +@Schema(description = "管理后台 - IoT 设备下行 Request VO") // 服务调用、属性设置、属性获取等 | |
| 11 | 11 | @Data |
| 12 | -public class IotDeviceSimulationDownstreamReqVO { | |
| 12 | +public class IotDeviceDownstreamReqVO { | |
| 13 | 13 | |
| 14 | 14 | @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "177") |
| 15 | 15 | @NotNull(message = "设备编号不能为空") | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceSimulationUpstreamReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/control/IotDeviceUpstreamReqVO.java
| ... | ... | @@ -7,9 +7,9 @@ import jakarta.validation.constraints.NotEmpty; |
| 7 | 7 | import jakarta.validation.constraints.NotNull; |
| 8 | 8 | import lombok.Data; |
| 9 | 9 | |
| 10 | -@Schema(description = "管理后台 - IoT 模拟设备上行 Request VO") // 属性上报、事件上报、状态变更等 | |
| 10 | +@Schema(description = "管理后台 - IoT 设备上行 Request VO") // 属性上报、事件上报、状态变更等 | |
| 11 | 11 | @Data |
| 12 | -public class IotDeviceSimulationUpstreamReqVO { | |
| 12 | +public class IotDeviceUpstreamReqVO { | |
| 13 | 13 | |
| 14 | 14 | @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "177") |
| 15 | 15 | @NotNull(message = "设备编号不能为空") | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceDO.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/control/IotDeviceDownstreamService.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.device.control; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceSimulationDownstreamReqVO; | |
| 3 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceDownstreamReqVO; | |
| 4 | 4 | import jakarta.validation.Valid; |
| 5 | 5 | |
| 6 | 6 | /** |
| ... | ... | @@ -13,10 +13,10 @@ import jakarta.validation.Valid; |
| 13 | 13 | public interface IotDeviceDownstreamService { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * 模拟设备下行 | |
| 16 | + * 设备下行,可用于设备模拟 | |
| 17 | 17 | * |
| 18 | 18 | * @param downstreamReqVO 设备下行请求 VO |
| 19 | 19 | */ |
| 20 | - void simulationDeviceDownstream(@Valid IotDeviceSimulationDownstreamReqVO downstreamReqVO); | |
| 20 | + void downstreamDevice(@Valid IotDeviceDownstreamReqVO downstreamReqVO); | |
| 21 | 21 | |
| 22 | 22 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/control/IotDeviceDownstreamServiceImpl.java
| ... | ... | @@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.iot.api.device.dto.control.downstream.IotDeviceDo |
| 9 | 9 | import cn.iocoder.yudao.module.iot.api.device.dto.control.downstream.IotDevicePropertyGetReqDTO; |
| 10 | 10 | import cn.iocoder.yudao.module.iot.api.device.dto.control.downstream.IotDevicePropertySetReqDTO; |
| 11 | 11 | import cn.iocoder.yudao.module.iot.api.device.dto.control.downstream.IotDeviceServiceInvokeReqDTO; |
| 12 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceSimulationDownstreamReqVO; | |
| 12 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceDownstreamReqVO; | |
| 13 | 13 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 14 | 14 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugin.IotPluginInstanceDO; |
| 15 | 15 | import cn.iocoder.yudao.module.iot.enums.device.IotDeviceMessageIdentifierEnum; |
| ... | ... | @@ -56,7 +56,7 @@ public class IotDeviceDownstreamServiceImpl implements IotDeviceDownstreamServic |
| 56 | 56 | private IotDeviceProducer deviceProducer; |
| 57 | 57 | |
| 58 | 58 | @Override |
| 59 | - public void simulationDeviceDownstream(IotDeviceSimulationDownstreamReqVO downstreamReqVO) { | |
| 59 | + public void downstreamDevice(IotDeviceDownstreamReqVO downstreamReqVO) { | |
| 60 | 60 | // 校验设备是否存在 |
| 61 | 61 | IotDeviceDO device = deviceService.validateDeviceExists(downstreamReqVO.getId()); |
| 62 | 62 | // TODO 芋艿:父设备的处理 |
| ... | ... | @@ -93,7 +93,7 @@ public class IotDeviceDownstreamServiceImpl implements IotDeviceDownstreamServic |
| 93 | 93 | * @param parentDevice 父设备 |
| 94 | 94 | */ |
| 95 | 95 | @SuppressWarnings("unchecked") |
| 96 | - private void invokeDeviceService(IotDeviceSimulationDownstreamReqVO downstreamReqVO, | |
| 96 | + private void invokeDeviceService(IotDeviceDownstreamReqVO downstreamReqVO, | |
| 97 | 97 | IotDeviceDO device, IotDeviceDO parentDevice) { |
| 98 | 98 | // 1. 参数校验 |
| 99 | 99 | if (!(downstreamReqVO.getData() instanceof Map<?, ?>)) { |
| ... | ... | @@ -130,7 +130,7 @@ public class IotDeviceDownstreamServiceImpl implements IotDeviceDownstreamServic |
| 130 | 130 | * @param parentDevice 父设备 |
| 131 | 131 | */ |
| 132 | 132 | @SuppressWarnings("unchecked") |
| 133 | - private void setDeviceProperty(IotDeviceSimulationDownstreamReqVO downstreamReqVO, | |
| 133 | + private void setDeviceProperty(IotDeviceDownstreamReqVO downstreamReqVO, | |
| 134 | 134 | IotDeviceDO device, IotDeviceDO parentDevice) { |
| 135 | 135 | // 1. 参数校验 |
| 136 | 136 | if (!(downstreamReqVO.getData() instanceof Map<?, ?>)) { |
| ... | ... | @@ -168,7 +168,7 @@ public class IotDeviceDownstreamServiceImpl implements IotDeviceDownstreamServic |
| 168 | 168 | * @param parentDevice 父设备 |
| 169 | 169 | */ |
| 170 | 170 | @SuppressWarnings("unchecked") |
| 171 | - private void getDeviceProperty(IotDeviceSimulationDownstreamReqVO downstreamReqVO, | |
| 171 | + private void getDeviceProperty(IotDeviceDownstreamReqVO downstreamReqVO, | |
| 172 | 172 | IotDeviceDO device, IotDeviceDO parentDevice) { |
| 173 | 173 | // 1. 参数校验 |
| 174 | 174 | if (!(downstreamReqVO.getData() instanceof List<?>)) { | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/control/IotDeviceUpstreamService.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.service.device.control; |
| 3 | 3 | import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.IotDeviceEventReportReqDTO; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.IotDevicePropertyReportReqDTO; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.IotDeviceStateUpdateReqDTO; |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceSimulationUpstreamReqVO; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceUpstreamReqVO; | |
| 7 | 7 | import jakarta.validation.Valid; |
| 8 | 8 | |
| 9 | 9 | /** |
| ... | ... | @@ -16,11 +16,11 @@ import jakarta.validation.Valid; |
| 16 | 16 | public interface IotDeviceUpstreamService { |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * 模拟设备上行 | |
| 19 | + * 设备上行,可用于设备模拟 | |
| 20 | 20 | * |
| 21 | 21 | * @param simulatorReqVO 设备上行请求 VO |
| 22 | 22 | */ |
| 23 | - void simulationDeviceUpstream(@Valid IotDeviceSimulationUpstreamReqVO simulatorReqVO); | |
| 23 | + void upstreamDevice(@Valid IotDeviceUpstreamReqVO simulatorReqVO); | |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * 更新设备状态 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/control/IotDeviceUpstreamServiceImpl.java
| ... | ... | @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.IotDeviceEven |
| 11 | 11 | import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.IotDevicePropertyReportReqDTO; |
| 12 | 12 | import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.IotDeviceStateUpdateReqDTO; |
| 13 | 13 | import cn.iocoder.yudao.module.iot.api.device.dto.control.upstream.IotDeviceUpstreamAbstractReqDTO; |
| 14 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceSimulationUpstreamReqVO; | |
| 14 | +import cn.iocoder.yudao.module.iot.controller.admin.device.vo.control.IotDeviceUpstreamReqVO; | |
| 15 | 15 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 16 | 16 | import cn.iocoder.yudao.module.iot.enums.device.IotDeviceMessageIdentifierEnum; |
| 17 | 17 | import cn.iocoder.yudao.module.iot.enums.device.IotDeviceMessageTypeEnum; |
| ... | ... | @@ -52,7 +52,7 @@ public class IotDeviceUpstreamServiceImpl implements IotDeviceUpstreamService { |
| 52 | 52 | |
| 53 | 53 | @Override |
| 54 | 54 | @SuppressWarnings("unchecked") |
| 55 | - public void simulationDeviceUpstream(IotDeviceSimulationUpstreamReqVO simulatorReqVO) { | |
| 55 | + public void upstreamDevice(IotDeviceUpstreamReqVO simulatorReqVO) { | |
| 56 | 56 | // 1. 校验存在 |
| 57 | 57 | IotDeviceDO device = deviceService.validateDeviceExists(simulatorReqVO.getId()); |
| 58 | 58 | ... | ... |