refactor(Property): 1

This commit is contained in:
2025-09-13 13:42:45 +08:00
parent 66ac68b632
commit 65a579eb2a
2 changed files with 10 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
package org.dromara.property.controller.cockpit; package org.dromara.property.controller.cockpit;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.property.rocketmq.RocketMqConstants; import org.dromara.property.rocketmq.RocketMqConstants;
@@ -7,9 +8,13 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/** /**
* 大屏流量接口 * 大屏流量接口
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/cockpit") @RequestMapping("/cockpit")
public class FlowController { public class FlowController {
@@ -22,7 +27,8 @@ public class FlowController {
@GetMapping("/personFlow/today") @GetMapping("/personFlow/today")
public R<?> getPersonFlowToday() { public R<?> getPersonFlowToday() {
if (RedisUtils.isExistsObject(RocketMqConstants.PASS_RECORD)) { if (RedisUtils.isExistsObject(RocketMqConstants.PASS_RECORD)) {
return R.ok(RedisUtils.getCacheObject(RocketMqConstants.PASS_RECORD)); List<String[]> result = new ArrayList<>(RedisUtils.getCacheObject(RocketMqConstants.PASS_RECORD));
return R.ok(result);
} else { } else {
return R.fail("数据不存在"); return R.fail("数据不存在");
} }

View File

@@ -32,8 +32,9 @@ public class PassRecordConsumer implements RocketMQListener<MessageExt> {
public void onMessage(MessageExt ext) { public void onMessage(MessageExt ext) {
log.info("消费通行记录上报数据,数据长度={}", ext.getBody().length); log.info("消费通行记录上报数据,数据长度={}", ext.getBody().length);
try { try {
List<Object[]> result = JSONUtil.toList(new String(ext.getBody()), Object[].class); List<String[]> result = JSONUtil.toList(new String(ext.getBody()), String[].class);
RedisUtils.setCacheObject(RocketMqConstants.PASS_RECORD, result); log.info("消费通行记录上报数据,数据={}", result);
RedisUtils.setCacheList(RocketMqConstants.PASS_RECORD, result);
} catch (Exception e) { } catch (Exception e) {
log.error("消费仪表上报数据处理失败,", e); log.error("消费仪表上报数据处理失败,", e);
} }