From 9a0bf581fd556a34409582b2ae92a056ae3e6715 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Sun, 25 Jun 2023 17:14:23 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E9=AB=98=E5=BE=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jsowell/amap/AMapController.java | 5 +- .../mapper/PileBillingTemplateMapper.java | 7 ++ .../service/IPileBillingTemplateService.java | 6 + .../impl/PileBillingTemplateServiceImpl.java | 47 ++++++++ .../pile/vo/web/BillingTemplateVO.java | 3 + .../mapper/pile/PileBillingTemplateMapper.xml | 37 ++++++ .../thirdparty/amap/service/AMapService.java | 3 +- .../amap/service/impl/AMapServiceImpl.java | 108 +++++++++++++++++- 8 files changed, 210 insertions(+), 6 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/amap/AMapController.java b/jsowell-admin/src/main/java/com/jsowell/amap/AMapController.java index a7d9ff204..958ea20de 100644 --- a/jsowell-admin/src/main/java/com/jsowell/amap/AMapController.java +++ b/jsowell-admin/src/main/java/com/jsowell/amap/AMapController.java @@ -1,19 +1,15 @@ package com.jsowell.amap; -import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson2.JSON; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.core.controller.BaseController; import com.jsowell.pile.dto.QueryPileDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; -import com.jsowell.thirdparty.amap.common.AMapCommonParams; import com.jsowell.thirdparty.amap.common.AMapCommonResult; import com.jsowell.thirdparty.amap.domain.AMapStationInfo; import com.jsowell.thirdparty.amap.service.AMapService; import com.jsowell.thirdparty.amap.util.AMapUtils; -import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -46,6 +42,7 @@ public class AMapController extends BaseController { String bizContent = requestMap.get("biz_content"); GetStationInfoDTO dto = JSON.parseObject(bizContent, GetStationInfoDTO.class); List stationInfos = aMapService.getStationInfos(dto); + List stationInfosV2 = aMapService.getStationInfosV2(dto); logger.info("高德拉取充电站静态数据 success"); return result.successResponse(stationInfos); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java index 6bdcacf0d..22db03161 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java @@ -135,6 +135,13 @@ public interface PileBillingTemplateMapper { */ BillingTemplateVO selectBillingTemplateByStationId(@Param("stationId") String stationId); + /** + * 批量查询站点正在使用的计费模板信息 + * @param stationIdList 站点id集合 + * @return + */ + List selectBillingTemplateByStationIdList(@Param("stationIdList") List stationIdList); + /** * 通过模板id数组批量查询计费模板详情列表 */ diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java index 1b071db0b..ad9e8b10b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java @@ -7,6 +7,7 @@ import com.jsowell.pile.dto.CreateOrUpdateBillingTemplateDTO; import com.jsowell.pile.dto.ImportBillingTemplateDTO; import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails; +import com.jsowell.pile.vo.web.BillingDetailVO; import com.jsowell.pile.vo.web.BillingTemplateVO; import com.jsowell.pile.vo.web.EchoBillingTemplateVO; @@ -105,6 +106,8 @@ public interface IPileBillingTemplateService { */ BillingTemplateVO queryUsedBillingTemplate(String stationId); + List conversionParameters(List billingDetailList); + /** * 查询计费价格详情 * @param stationId 站点id @@ -160,4 +163,7 @@ public interface IPileBillingTemplateService { CurrentTimePriceDetails getCurrentTimePriceDetails(String stationId); List queryBillingDetailById(Long id); + + // 批量查询站点计费模板 + List selectBillingTemplateByStationIdList(List stationIdList); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java index 96d7188bc..14328f02e 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java @@ -379,6 +379,14 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi return pileBillingDetails; } + @Override + public List selectBillingTemplateByStationIdList(List stationIdList) { + if (CollectionUtils.isEmpty(stationIdList)) { + return Lists.newArrayList(); + } + return pileBillingTemplateMapper.selectBillingTemplateByStationIdList(stationIdList); + } + @Override public List queryPublicBillingTemplateList() { return pileBillingTemplateMapper.queryPublicBillingTemplateList(); @@ -455,6 +463,45 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi return max.orElse(null); } + /** + * 转换参数 + * @param billingDetailList + * @return + */ + @Override + public List conversionParameters(List billingDetailList) { + List resultList = Lists.newArrayList(); + if (org.springframework.util.CollectionUtils.isEmpty(billingDetailList)) { + return resultList; + } + for (BillingDetailVO billingDetailVO : billingDetailList) { + List applyTimeList = billingDetailVO.getApplyTime(); + BigDecimal electricityPrice = billingDetailVO.getElectricityPrice(); + BigDecimal servicePrice = billingDetailVO.getServicePrice(); + for (String applyTime : applyTimeList) { + String[] split = applyTime.split("-"); + // 开始时间 + String startTime = split[0]; + // 结束时间 + String endTime = split[1]; + // 是否当前时间 + boolean in = DateUtils.isIn(LocalTime.now(), LocalTime.parse(startTime), LocalTime.parse(endTime)); + resultList.add( + BillingPriceVO.builder() + .timeType(billingDetailVO.getTimeType()) + .startTime(startTime) + .endTime(endTime) + .electricityPrice(electricityPrice.toString()) + .servicePrice(servicePrice.toString()) + .totalPrice(electricityPrice.add(servicePrice).toString()) + .isCurrentTime(in ? Constants.ONE : Constants.ZERO) + .build() + ); + } + } + return resultList; + } + @Override public List queryBillingPrice(String stationId) { // 查询站点当前计费模板 有缓存 diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/BillingTemplateVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/BillingTemplateVO.java index d7237d561..6735b508b 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/BillingTemplateVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/BillingTemplateVO.java @@ -19,6 +19,9 @@ import java.util.Map; @AllArgsConstructor @Builder public class BillingTemplateVO { + // 站点id + private String stationId; + // 计费模板id private String templateId; diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml index 413e806a5..a38b9cba1 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml @@ -489,4 +489,41 @@ and t2.station_id = #{stationId,jdbcType=VARCHAR} order by t2.publish_time desc + + \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java index 56fe7eef4..9ce5824d5 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/AMapService.java @@ -1,6 +1,5 @@ package com.jsowell.thirdparty.amap.service; -import com.jsowell.pile.dto.amap.ChargeDeviceDynamicsDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; import com.jsowell.thirdparty.amap.domain.AMapStationInfo; @@ -36,4 +35,6 @@ public interface AMapService { * @return */ String pushChargingOrderInfo(String orderCode); + + List getStationInfosV2(GetStationInfoDTO dto); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java index 816ba896a..fcf75cb18 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java @@ -3,6 +3,8 @@ package com.jsowell.thirdparty.amap.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; @@ -15,6 +17,8 @@ import com.jsowell.pile.service.*; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO; +import com.jsowell.pile.vo.web.BillingDetailVO; +import com.jsowell.pile.vo.web.BillingTemplateVO; import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.thirdparty.amap.domain.*; import com.jsowell.thirdparty.amap.service.AMapService; @@ -31,7 +35,10 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.concurrent.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Collectors; /** @@ -116,6 +123,68 @@ public class AMapServiceImpl implements AMapService { return resultList; } + + @Override + public List getStationInfosV2(GetStationInfoDTO dto) { + List resultList = Lists.newArrayList(); + // 设置分页参数 + int pageNo = dto.getCurrentPage() == null ? 1 : dto.getCurrentPage(); + int pageSize = dto.getPageSize() == null ? 20 : dto.getPageSize(); + PageUtils.startPage(pageNo, pageSize); + + // 第一次查询,得到站点 + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(); + PageInfo pageInfo = new PageInfo<>(stationInfos); + List stationList = pageInfo.getList(); + if (CollectionUtils.isEmpty(stationList)) { + return resultList; + } + // 站点id + List stationIdList = stationList.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()); + // 第二次查询,得到计费模板信息 + Map> priceInfoMap = getPriceInfoByStationIdList(stationIdList); + + // 第三次查询,得到充电桩 + Map> equipmentInfoMap = getPileListByStationIdList(stationIdList); + + // 拼装数据 + AMapStationInfo aMapInfo = null; + for (PileStationInfo stationInfo : stationList) { + aMapInfo = new AMapStationInfo(); + String stationId = String.valueOf(stationInfo.getId()); + aMapInfo.setStationID(stationId); + aMapInfo.setOperatorID(""); + aMapInfo.setEquipmentOwnerID(""); + aMapInfo.setOperatorName(""); + aMapInfo.setStationName(stationInfo.getStationName()); + aMapInfo.setCountryCode(stationInfo.getCountryCode()); + aMapInfo.setAreaCode(stationInfo.getAreaCode()); + aMapInfo.setAddress(stationInfo.getAddress()); + aMapInfo.setServiceTel(stationInfo.getServiceTel()); + aMapInfo.setStationType(Integer.parseInt(stationInfo.getStationType())); + aMapInfo.setStationStatus(Integer.parseInt(stationInfo.getStationStatus())); + Integer openType = Integer.parseInt(stationInfo.getPublicFlag()) == 0 ? 7 : 0; + aMapInfo.setOpenType(openType); + aMapInfo.setParkNums(0); + aMapInfo.setStationLng(new BigDecimal(stationInfo.getStationLng()).setScale(6, RoundingMode.HALF_UP)); + aMapInfo.setStationLat(new BigDecimal(stationInfo.getStationLat()).setScale(6, RoundingMode.HALF_UP)); + String construction = stationInfo.getConstruction(); + if (StringUtils.equals("12", construction) || StringUtils.equals("13", construction) || + StringUtils.equals("14", construction) || StringUtils.equals("15", construction)) { + construction = "255"; + } + aMapInfo.setConstruction(Integer.parseInt(construction)); + aMapInfo.setBusineHours(stationInfo.getBusinessHours()); + + // 计费模板 + aMapInfo.setPriceChargingInfo(priceInfoMap.get(stationId)); + // 站点设备信息 + List equipmentInfos = equipmentInfoMap.get(stationId); + aMapInfo.setEquipmentInfos(equipmentInfos); + } + return null; + } + /** * 拼装高德需要的格式数据 * @param stationInfo 站点信息 @@ -268,6 +337,7 @@ public class AMapServiceImpl implements AMapService { } + /** * 根据站点id查询计费模板 * @param StationId @@ -288,6 +358,37 @@ public class AMapServiceImpl implements AMapService { return priceList; } + private Map> getPriceInfoByStationIdList(List stationIdList) { + Map> resultMap = Maps.newHashMap(); + + List list = pileBillingTemplateService.selectBillingTemplateByStationIdList(stationIdList); + if (CollectionUtils.isEmpty(list)) { + return resultMap; + } + + List priceList; + AMapPriceChargingInfo info; + for (BillingTemplateVO billingTemplateVO : list) { + // billingTemplateVO 站点计费模板 + priceList = Lists.newArrayList(); + List billingDetailList = billingTemplateVO.getBillingDetailList(); + for (BillingDetailVO billingDetailVO : billingDetailList) { + // billingDetailVO 计费模板的尖峰平谷详细信息 + List applyTime = billingDetailVO.getApplyTime(); + for (String s : applyTime) { + info = new AMapPriceChargingInfo(); + info.setFeeTime(s); + info.setElectricityFee(billingDetailVO.getElectricityPrice()); + info.setServiceFee(billingDetailVO.getServicePrice()); + priceList.add(info); + } + } + resultMap.put(billingTemplateVO.getStationId(), priceList); + } + return resultMap; + } + + /** * 根据站点查询站点下所有桩 @@ -321,6 +422,11 @@ public class AMapServiceImpl implements AMapService { return pileList; } + private Map> getPileListByStationIdList(List stationIdList) { + Map> resultMap = Maps.newHashMap(); + return resultMap; + } + /** * 根据桩号查询枪口列表