@Override
public HttpCommandResultWithData getSalesDataByUsersAndTransId(SalesQueryLogDataByUserCommand command) {
HttpCommandResultWithData result = new HttpCommandResultWithData().fillResult(ReturnCode.OK);
// 入参校验
List<String> userIds = command.getUserIds();
if (CollectionUtils.isEmpty(userIds)) {
throw new SellAppCustomFailException(ErrorMsgEnum.SELL_APP_SERVICE_PARAMS_ERROR_USERS_NOT_FIND);
}
List<String> transIds = command.getTransIds();
if (CollectionUtils.isEmpty(transIds)) {
throw new SellAppCustomFailException(ErrorMsgEnum.SELL_APP_SERVICE_PARAMS_ERROR_TRANS_ID_NOT_FIND);
}
// 获取redis数据方法
Function<String, Map<String, String>> getDataByRedis = userId -> {
Map<String, String> beanMap = new HashMap<>();
transIds.forEach(transId -> {
String jsonLogArrays = Optional.ofNullable(
(String) redisTemplate.opsForHash().get(RedisStaticConst.QINGQI_LOG_REDIS_KEY_PREX + transId, userId))
.orElseGet(String::new);
List<RedisLogSimplePojo> list = new ArrayList();
try {
list = JsonUtil.toList(jsonLogArrays, RedisLogSimplePojo.class);
} catch (IOException e) {
logger.warn(\"=== getSalesDataByUsers 查询云端redis数据 云端redis hkey : {} key: {} 转换json数组异常\", RedisStaticConst.QINGQI_LOG_REDIS_KEY_PREX + transId, userId);
}
beanMap.put(transId, String.valueOf(list.size()));
});
return beanMap;
};
// 返回结果
AtomicInteger index = new AtomicInteger();
Map<String, Map<String, String>> retMap =
userIds.stream().collect(Collectors.toMap(key -> {
String userId = userIds.get(index.get());
index.incrementAndGet();
return userId;
}, getDataByRedis));
result.setData(retMap);
return result;
}
继续阅读与本文标签相同的文章
上一篇 :
全球首座3D打印凉亭亮相中原大地
下一篇 :
springboot 相关目录
-
学宏程序编程,这些知识必不可少!
2026-05-14栏目: 教程
-
华为准备卖出“落后”的5G,多家美企极力竞争!任正非格局太大!
2026-05-14栏目: 教程
-
百度:飞桨深度学习平台已累计服务150多万开发者
2026-05-14栏目: 教程
-
滴滴公布安全功能数据:近2亿用户添加紧急联系人
2026-05-14栏目: 教程
-
滴滴自动驾驶或将于年底落地上海
2026-05-14栏目: 教程
