mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-04 10:00:11 +08:00
新增 批量查询枪口列表接口
This commit is contained in:
@@ -128,4 +128,11 @@ public interface PileConnectorInfoMapper {
|
||||
* @return
|
||||
*/
|
||||
PileConnectorInfoVO getConnectorInfoByParams(@Param("dto") QueryConnectorInfoDTO dto);
|
||||
|
||||
/**
|
||||
* 通过站点idList查询枪口列表信息
|
||||
* @param stationIds
|
||||
* @return
|
||||
*/
|
||||
List<ConnectorInfoVO> batchSelectConnectorList(@Param("stationIds") List<String> stationIds);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,13 @@ public interface PileConnectorInfoService {
|
||||
|
||||
List<ConnectorInfoVO> getConnectorListForLianLian(Long stationId);
|
||||
|
||||
/**
|
||||
* 根据站点idList批量查询枪口数据
|
||||
* @param stationIds
|
||||
* @return
|
||||
*/
|
||||
List<ConnectorInfoVO> batchSelectConnectorList(List<String> stationIds);
|
||||
|
||||
List<ConnectorInfoVO> selectConnectorInfoList(String pileSn);
|
||||
|
||||
PageResponse selectStationConnectorList(QueryConnectorListDTO dto);
|
||||
|
||||
@@ -46,10 +46,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -484,10 +481,67 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConnectorInfoVO> getConnectorListForLianLian(Long stationId) {
|
||||
return getUniAppConnectorList(stationId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询枪口列表接口
|
||||
* @param stationIds
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ConnectorInfoVO> batchSelectConnectorList(List<String> stationIds){
|
||||
List<ConnectorInfoVO> resultList = new ArrayList<>();
|
||||
Map<String, List<ConnectorInfoVO>> map = new LinkedHashMap<>();
|
||||
String baseRedisKey = CacheConstants.GET_UNIAPP_CONNECTOR_LIST_BY_STATION_ID;
|
||||
// 先查询缓存数据
|
||||
for (String stationId : stationIds) {
|
||||
String redisKey = baseRedisKey + stationId;
|
||||
List<ConnectorInfoVO> list = redisCache.getCacheList(redisKey);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
map.put(stationId, list);
|
||||
// 重新设置缓存
|
||||
redisCache.deleteObject(redisKey);
|
||||
redisCache.setCacheList(redisKey, list);
|
||||
redisCache.expire(redisKey, CacheConstants.cache_expire_time_1h);
|
||||
}
|
||||
}
|
||||
// 先将已经有数据的stationId进行收集
|
||||
List<String> hasDataStationIds = new ArrayList<>(map.keySet());
|
||||
Collection<List<ConnectorInfoVO>> values = map.values();
|
||||
// 筛选出没有数据的stationIds
|
||||
List<String> noDataStationIds = stationIds.stream()
|
||||
.filter(x -> !hasDataStationIds.contains(x))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(noDataStationIds)) {
|
||||
// 重新查询数据库
|
||||
// 通过stationIds批量查询数据库
|
||||
List<ConnectorInfoVO> newConnectorInfoList = pileConnectorInfoMapper.batchSelectConnectorList(noDataStationIds);
|
||||
|
||||
values.add(newConnectorInfoList);
|
||||
|
||||
// 设置缓存
|
||||
// 先将list根据站点id分组
|
||||
Map<String, List<ConnectorInfoVO>> collect = newConnectorInfoList.stream()
|
||||
.collect(Collectors.groupingBy(ConnectorInfoVO::getStationId));
|
||||
// 循环map并设置缓存
|
||||
for (Map.Entry<String, List<ConnectorInfoVO>> entry : collect.entrySet()) {
|
||||
String stationId = entry.getKey();
|
||||
List<ConnectorInfoVO> voList = entry.getValue();
|
||||
|
||||
String redisKey = baseRedisKey + stationId;
|
||||
redisCache.setCacheObject(redisKey, voList, CacheConstants.cache_expire_time_1h);
|
||||
}
|
||||
}
|
||||
|
||||
// 最终将 values 中的所有 ConnectorInfoVO 元素收集到 resultList
|
||||
values.forEach(resultList::addAll);
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConnectorInfoVO> selectConnectorInfoList(String pileSn) {
|
||||
// log.info("查询充电枪口详情-selectConnectorInfoList, param:{}", pileSn);
|
||||
|
||||
@@ -285,4 +285,24 @@
|
||||
AND
|
||||
t3.pile_connector_code = #{dto.pileConnectorCode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="batchSelectConnectorList" resultType="com.jsowell.pile.vo.base.ConnectorInfoVO">
|
||||
SELECT
|
||||
t1.pile_connector_code as pileConnectorCode,
|
||||
t2.station_id as stationId,
|
||||
t1.STATUS as connectorStatus,
|
||||
t1.pile_sn as pileSn,
|
||||
t2.model_id as modelId,
|
||||
t3.speed_type as chargingType,
|
||||
t3.rated_power as ratedPower
|
||||
FROM
|
||||
pile_connector_info t1
|
||||
JOIN pile_basic_info t2 ON (t1.pile_sn = t2.sn AND t2.del_flag = '0')
|
||||
JOIN pile_model_info t3 ON (t2.model_id = t3.id AND t3.del_flag = '0')
|
||||
WHERE t1.del_flag = '0'
|
||||
AND t2.station_id in
|
||||
<foreach collection="stationIds" item="stationId" open="(" separator="," close=")">
|
||||
#{stationId, jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user