@Override
public HttpCommandResultWithData getSalesDataByUsersAndTransId(SalesQueryLogDataByUserCommand command) {
HttpCommandResultWithData result = new HttpCommandResultWithData().fillResult(ReturnCode.OK);
// 入参校验
List
if (CollectionUtils.isEmpty(userIds)) {
throw new SellAppCustomFailException(ErrorMsgEnum.SELL_APP_SERVICE_ParaMS_ERROR_USERS_NOT_FIND);
}
List
if (CollectionUtils.isEmpty(transIds)) {
throw new SellAppCustomFailException(ErrorMsgEnum.SELL_APP_SERVICE_ParaMS_ERROR_TRANS_ID_NOT_FIND);
}
Function
Map
transIds.forEach(transId -> {
String jsonLogArrays = Optional.ofNullable(
(String) redistemplate.opsForHash().get(RedisStaticConst.QINGQI_LOG_REdis_KEY_PREX + transId,userId))
.orElseGet(String::new);
List
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
userIds.stream().collect(Collectors.toMap(key -> {
String userId = userIds.get(index.get());
index.incrementAndGet();
return userId;
},getDataByRedis));
result.setData(retMap);
return result;
}