mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
优化批量获取桩状态
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -158,12 +160,29 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
List<String> redisKeys = pileSnList.stream()
|
||||
.map(pileSn -> CacheConstants.SELECT_PILE_CONNECTOR_INFO_LIST + pileSn)
|
||||
.collect(Collectors.toList());
|
||||
List<PileConnectorInfo> redisResult = redisCache.multiGet(redisKeys);
|
||||
List<Object> redisResult = redisCache.multiGet(redisKeys);
|
||||
List<PileConnectorInfo> connectorInfoList = Lists.newArrayList();
|
||||
for (Object o : redisResult) {
|
||||
if (Objects.isNull(o)) {
|
||||
continue;
|
||||
}
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(o));
|
||||
for (Object o1 : jsonArray) {
|
||||
PileConnectorInfo pileConnectorInfo = JSONObject.parseObject(JSON.toJSONString(o1), PileConnectorInfo.class);
|
||||
connectorInfoList.add(pileConnectorInfo);
|
||||
}
|
||||
}
|
||||
// 分组
|
||||
Map<String, List<PileConnectorInfo>> collect = redisResult.stream()
|
||||
.filter(Objects::nonNull)
|
||||
Map<String, List<PileConnectorInfo>> collect = connectorInfoList.stream()
|
||||
.collect(Collectors.groupingBy(PileConnectorInfo::getPileSn));
|
||||
return null;
|
||||
resultMap.putAll(collect);
|
||||
|
||||
// 筛选出未从缓存中获取到的pileSn
|
||||
List<String> noCachePileSnList = pileSnList.stream()
|
||||
.filter(pileSn -> !collect.containsKey(pileSn))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -726,7 +745,6 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
@Override
|
||||
public Map<String, String> getPileStatusV2(List<String> pileSnList) {
|
||||
Map<String, String> resultMap = Maps.newHashMap();
|
||||
|
||||
Map<String, List<PileConnectorInfo>> pileConnectorMap = selectPileConnectorInfoListByPileSnList(pileSnList);
|
||||
for (String pileSn : pileSnList) {
|
||||
String pileStatus = "";
|
||||
|
||||
@@ -24,7 +24,19 @@
|
||||
|
||||
<select id="selectPileConnectorInfoList" parameterType="com.jsowell.pile.domain.PileConnectorInfo"
|
||||
resultMap="PileConnectorInfoResult">
|
||||
<include refid="selectPileConnectorInfoVo"/>
|
||||
select
|
||||
id,
|
||||
name,
|
||||
pile_connector_code,
|
||||
status,
|
||||
park_no,
|
||||
pile_sn,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
del_flag
|
||||
from pile_connector_info
|
||||
where
|
||||
del_flag = '0'
|
||||
<if test="name != null and name != ''">
|
||||
|
||||
Reference in New Issue
Block a user