mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 优化查询充电桩列表
This commit is contained in:
@@ -1163,6 +1163,10 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
*/
|
||||
@Override
|
||||
public void updateOrderStatusAsAbnormal(String pileSn) {
|
||||
// 先从redis判断是否有订单再进行查询
|
||||
if (Objects.isNull(redisCache.getCacheObject(CacheConstants.PILE_IS_CHARGING + pileSn))) {
|
||||
return;
|
||||
}
|
||||
// 将此桩正在进行充电的订单状态改为 异常
|
||||
List<OrderListVO> orderListVOS = selectChargingOrder(pileSn);
|
||||
if (CollectionUtils.isEmpty(orderListVOS)) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@@ -165,14 +166,22 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
|
||||
@Override
|
||||
// @DataScope(deptAlias = "t2")
|
||||
public List<PileDetailVO> queryPileInfos(QueryPileDTO dto) {
|
||||
StopWatch watch = new StopWatch("查询充电桩信息");
|
||||
watch.start("首先不分页查询所有符合条件的充电桩");
|
||||
log.info("queryPileInfos dto:{}", JSONObject.toJSONString(dto));
|
||||
// 首先不分页查询所有符合条件的充电桩
|
||||
List<PileDetailVO> pileInfoVOS = queryPileInfoList(dto);
|
||||
watch.stop();
|
||||
|
||||
watch.start("查询充电桩状态");
|
||||
// 获取桩sn列表
|
||||
List<String> pileSnList = pileInfoVOS.stream().map(PileDetailVO::getPileSn).collect(Collectors.toList());
|
||||
// log.info("获取桩sn列表:{}", JSONObject.toJSONString(pileSnList));
|
||||
// 批量获取桩状态 key:桩编号; value:状态
|
||||
Map<String, String> pileStatusMap = pileConnectorInfoService.getPileStatus(pileSnList);
|
||||
watch.stop();
|
||||
|
||||
watch.start("根据状态过滤");
|
||||
// log.info("批量获取桩状态:{}", JSONObject.toJSONString(pileStatusMap));
|
||||
// 根据状态过滤
|
||||
List<String> snList = Lists.newArrayList();
|
||||
@@ -190,7 +199,9 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
|
||||
// 根据状态排序
|
||||
|
||||
}
|
||||
watch.stop();
|
||||
|
||||
watch.start("查询桩列表");
|
||||
if (CollectionUtils.isEmpty(snList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
@@ -205,6 +216,8 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
|
||||
for (PileDetailVO pileInfoVO : pileInfoVOS) {
|
||||
pileInfoVO.setStatus(pileStatusMap.get(pileInfoVO.getPileSn()));
|
||||
}
|
||||
watch.stop();
|
||||
log.info("总耗时:{}, 详细信息:{}", watch.getTotalTimeSeconds(), watch.prettyPrint());
|
||||
return pileInfoVOS;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
@@ -115,7 +116,7 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
|
||||
result = selectPileConnectorInfoList(pileConnectorInfo);
|
||||
if (CollectionUtils.isNotEmpty(result)) {
|
||||
// 查询数据库不为空,存redis 2分钟
|
||||
redisCache.setCacheObject(redisKey, result, 2, TimeUnit.MINUTES);
|
||||
redisCache.setCacheObject(redisKey, result, 15, TimeUnit.HOURS);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -503,13 +504,13 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getPileStatus(List<String> pileSnList) {
|
||||
StopWatch watch = new StopWatch("批量获取桩状态");
|
||||
Map<String, String> resultMap = Maps.newHashMap();
|
||||
for (String pileSn : pileSnList) {
|
||||
String pileStatus = "";
|
||||
|
||||
// 标识桩故障或者离线
|
||||
boolean flag = false;
|
||||
|
||||
// 判断故障状态
|
||||
List<PileConnectorInfo> connectorList = selectPileConnectorInfoList(pileSn); // 获取枪口信息
|
||||
List<String> connectorStatusList = connectorList.stream().map(PileConnectorInfo::getStatus).collect(Collectors.toList());
|
||||
|
||||
Reference in New Issue
Block a user