diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index e3b528ab..cd512d99 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -136,6 +136,7 @@ public class DcDeviceController extends BaseController { * @param deviceId 物联设备id * @return 获取属性数据操作结果 */ + @ApiOperation("获取设备最新属性数据") @GetMapping("/properties/latest/{deviceId}") public AjaxResult getDeviceLatestProperties(@PathVariable @Parameter(description = "设备ID") String deviceId) throws HttpException, IOException { @@ -155,6 +156,7 @@ public class DcDeviceController extends BaseController { * @param props 查询条件 * @return 属性列表 */ + @ApiOperation("获取设备历史属性列表") @GetMapping("/properties/history/{deviceId}/{propertyId}") public AjaxResult queryDeviceProperties(@PathVariable @Parameter(description = "设备ID") String deviceId, @PathVariable @Parameter(description = "属性ID") String propertyId, @@ -178,6 +180,7 @@ public class DcDeviceController extends BaseController { * @param propertyId 属性id * @return 获取属性数据操作结果 */ + @ApiOperation("获取设备指定属性最新数据") @GetMapping("/properties/latest/{deviceId}/{propertyId}") public AjaxResult getDeviceLatestProperty(@PathVariable @Parameter(description = "设备ID") String deviceId, @PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException { @@ -196,6 +199,7 @@ public class DcDeviceController extends BaseController { * @param propertyId 属性 * @return 属性实时数据 */ + @ApiOperation("获取设备指定属性实时数据") @GetMapping("/properties/realtime/{deviceId}/{propertyId}") public AjaxResult getDeviceRealtimeProperty( @PathVariable String deviceId, @@ -221,6 +225,7 @@ public class DcDeviceController extends BaseController { * @param props 属性id集 * @return 属性实时数据 */ + @ApiOperation("获取设备属性实时数据") @PostMapping("/properties/realtime/{deviceId}") public AjaxResult getDeviceRealtimeProperties( @PathVariable String deviceId, @@ -249,6 +254,7 @@ public class DcDeviceController extends BaseController { * @param props 参数 * @return 设备属性操作结果 */ + @ApiOperation("设置设备属性值") @PostMapping("/properties/setting/{deviceId}") public AjaxResult setDeviceProperties( @PathVariable String deviceId, @@ -274,6 +280,7 @@ public class DcDeviceController extends BaseController { * @param props 调用参数 * @return 调用结果 */ + @ApiOperation("设备功能调用") @PostMapping("/functions/{deviceId}/{functionId}") public AjaxResult invokedFunction( @PathVariable String deviceId, @@ -302,6 +309,7 @@ public class DcDeviceController extends BaseController { * @param queryParam 查询条件 * @return 查询事件结果 */ + @ApiOperation("查询事件历史数据列表") @GetMapping("/events/history/{deviceId}/{eventId}") public AjaxResult queryPagerDeviceEvents( @PathVariable @Parameter(description = "设备ID") String deviceId, @@ -327,6 +335,7 @@ public class DcDeviceController extends BaseController { * @param id 物联设备id * @return 更新结果 */ + @ApiOperation("获取设备物模型") @GetMapping(value = "/metadata/{id}") public AjaxResult getMetadata(@PathVariable String id) throws HttpException, IOException { diff --git a/zc-business/src/main/java/com/zc/business/message/device/OfflineMessageListener.java b/zc-business/src/main/java/com/zc/business/message/device/OfflineMessageListener.java index a773a5ce..ebd7bded 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/OfflineMessageListener.java +++ b/zc-business/src/main/java/com/zc/business/message/device/OfflineMessageListener.java @@ -1,14 +1,18 @@ package com.zc.business.message.device; +import com.alibaba.fastjson.JSON; import com.zc.common.core.redis.stream.RedisStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.stream.ObjectRecord; import org.springframework.data.redis.connection.stream.RecordId; import org.springframework.data.redis.stream.StreamListener; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; +import javax.annotation.Resource; +import java.util.List; + /** * 离线消息监听 */ @@ -17,15 +21,30 @@ public class OfflineMessageListener implements StreamListener message) { String streamKay = message.getStream(); RecordId recordId = message.getId(); + threadPoolTaskExecutor.execute(() -> { + List list = JSON.parseArray(message.getValue(), String.class); + this.handle(list); + }); + // 消费完后直接删除消息 redisStream.del(streamKay, String.valueOf(recordId)); } + + /** + * 处理离线消息 + */ + private void handle(List msg) { + System.out.println(msg); + } }