From 38e572a999bd2e0df190dcbf1db204de79647382 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Thu, 19 Oct 2023 11:28:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2=E5=85=85?= =?UTF-8?q?=E7=94=B5=E6=A1=A9=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PileBasicInfoServiceImpl.java | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index 12943f0d5..3eca450bf 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -37,7 +37,6 @@ 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.math.RoundingMode; @@ -223,22 +222,37 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService { @Override // @DataScope(deptAlias = "t2") public List queryPileInfos(QueryPileDTO dto) { - StopWatch watch = new StopWatch("查询充电桩信息"); - watch.start("首先不分页查询所有符合条件的充电桩"); + List pileDetailVOS = null; + if (StringUtils.isNotBlank(dto.getStatus())) { + pileDetailVOS = queryPileListByStatus(dto); + } else { + pileDetailVOS = queryPileListNoStatus(dto); + } + return pileDetailVOS; + } + + /** + * 查询充电桩列表带状态过滤 + * @param dto + * @return + */ + private List queryPileListByStatus(QueryPileDTO dto) { + // StopWatch watch = new StopWatch("查询充电桩信息"); + // watch.start("首先不分页查询所有符合条件的充电桩"); log.info("queryPileInfos dto:{}", JSONObject.toJSONString(dto)); // 首先不分页查询所有符合条件的充电桩 List pileInfoVOS = queryPileInfoList(dto); - watch.stop(); + // watch.stop(); - watch.start("查询充电桩状态"); + // watch.start("查询充电桩状态"); // 获取桩sn列表 List pileSnList = pileInfoVOS.stream().map(PileDetailVO::getPileSn).collect(Collectors.toList()); // log.info("获取桩sn列表:{}", JSONObject.toJSONString(pileSnList)); // 批量获取桩状态 key:桩编号; value:状态 Map pileStatusMap = pileConnectorInfoService.getPileStatus(pileSnList); - watch.stop(); + // watch.stop(); - watch.start("根据状态过滤"); + // watch.start("根据状态过滤"); // log.info("批量获取桩状态:{}", JSONObject.toJSONString(pileStatusMap)); // 根据状态过滤 List snList = Lists.newArrayList(); @@ -254,11 +268,10 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService { // 不根据状态过滤,snList就等于pileSnList snList = pileSnList; // 根据状态排序 - } - watch.stop(); + // watch.stop(); - watch.start("查询桩列表"); + // watch.start("查询桩列表"); if (CollectionUtils.isEmpty(snList)) { return Lists.newArrayList(); } @@ -273,8 +286,23 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService { for (PileDetailVO pileInfoVO : pileInfoVOS) { pileInfoVO.setStatus(pileStatusMap.get(pileInfoVO.getPileSn())); } - watch.stop(); - log.info("总耗时:{}, 详细信息:{}", watch.getTotalTimeSeconds(), watch.prettyPrint()); + // watch.stop(); + // log.info("总耗时:{}, 详细信息:{}", watch.getTotalTimeSeconds(), watch.prettyPrint()); + return pileInfoVOS; + } + + /** + * 查询充电桩列表不带状态过滤 + * @param dto + * @return + */ + private List queryPileListNoStatus(QueryPileDTO dto) { + List pileInfoVOS = queryPileInfoList(dto); + List pileSnList = pileInfoVOS.stream().map(PileDetailVO::getPileSn).collect(Collectors.toList()); + Map pileStatusMap = pileConnectorInfoService.getPileStatus(pileSnList); + for (PileDetailVO pileInfoVO : pileInfoVOS) { + pileInfoVO.setStatus(pileStatusMap.get(pileInfoVO.getPileSn())); + } return pileInfoVOS; }