refactor(Property): 1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.dromara.property.controller.cockpit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
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.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 大屏流量接口
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/cockpit")
|
||||
public class FlowController {
|
||||
@@ -22,7 +27,8 @@ public class FlowController {
|
||||
@GetMapping("/personFlow/today")
|
||||
public R<?> getPersonFlowToday() {
|
||||
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 {
|
||||
return R.fail("数据不存在");
|
||||
}
|
||||
|
@@ -32,8 +32,9 @@ public class PassRecordConsumer implements RocketMQListener<MessageExt> {
|
||||
public void onMessage(MessageExt ext) {
|
||||
log.info("消费通行记录上报数据,数据长度={}", ext.getBody().length);
|
||||
try {
|
||||
List<Object[]> result = JSONUtil.toList(new String(ext.getBody()), Object[].class);
|
||||
RedisUtils.setCacheObject(RocketMqConstants.PASS_RECORD, result);
|
||||
List<String[]> result = JSONUtil.toList(new String(ext.getBody()), String[].class);
|
||||
log.info("消费通行记录上报数据,数据={}", result);
|
||||
RedisUtils.setCacheList(RocketMqConstants.PASS_RECORD, result);
|
||||
} catch (Exception e) {
|
||||
log.error("消费仪表上报数据处理失败,", e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user