mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 高德
This commit is contained in:
@@ -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<AMapStationInfo> stationInfos = aMapService.getStationInfos(dto);
|
||||
List<AMapStationInfo> stationInfosV2 = aMapService.getStationInfosV2(dto);
|
||||
logger.info("高德拉取充电站静态数据 success");
|
||||
return result.successResponse(stationInfos);
|
||||
}
|
||||
|
||||
@@ -135,6 +135,13 @@ public interface PileBillingTemplateMapper {
|
||||
*/
|
||||
BillingTemplateVO selectBillingTemplateByStationId(@Param("stationId") String stationId);
|
||||
|
||||
/**
|
||||
* 批量查询站点正在使用的计费模板信息
|
||||
* @param stationIdList 站点id集合
|
||||
* @return
|
||||
*/
|
||||
List<BillingTemplateVO> selectBillingTemplateByStationIdList(@Param("stationIdList") List<String> stationIdList);
|
||||
|
||||
/**
|
||||
* 通过模板id数组批量查询计费模板详情列表
|
||||
*/
|
||||
|
||||
@@ -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<BillingPriceVO> conversionParameters(List<BillingDetailVO> billingDetailList);
|
||||
|
||||
/**
|
||||
* 查询计费价格详情
|
||||
* @param stationId 站点id
|
||||
@@ -160,4 +163,7 @@ public interface IPileBillingTemplateService {
|
||||
CurrentTimePriceDetails getCurrentTimePriceDetails(String stationId);
|
||||
|
||||
List<PileBillingDetail> queryBillingDetailById(Long id);
|
||||
|
||||
// 批量查询站点计费模板
|
||||
List<BillingTemplateVO> selectBillingTemplateByStationIdList(List<String> stationIdList);
|
||||
}
|
||||
|
||||
@@ -379,6 +379,14 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi
|
||||
return pileBillingDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BillingTemplateVO> selectBillingTemplateByStationIdList(List<String> stationIdList) {
|
||||
if (CollectionUtils.isEmpty(stationIdList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return pileBillingTemplateMapper.selectBillingTemplateByStationIdList(stationIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BillingTemplateVO> queryPublicBillingTemplateList() {
|
||||
return pileBillingTemplateMapper.queryPublicBillingTemplateList();
|
||||
@@ -455,6 +463,45 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi
|
||||
return max.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换参数
|
||||
* @param billingDetailList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BillingPriceVO> conversionParameters(List<BillingDetailVO> billingDetailList) {
|
||||
List<BillingPriceVO> resultList = Lists.newArrayList();
|
||||
if (org.springframework.util.CollectionUtils.isEmpty(billingDetailList)) {
|
||||
return resultList;
|
||||
}
|
||||
for (BillingDetailVO billingDetailVO : billingDetailList) {
|
||||
List<String> 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<BillingPriceVO> queryBillingPrice(String stationId) {
|
||||
// 查询站点当前计费模板 有缓存
|
||||
|
||||
@@ -19,6 +19,9 @@ import java.util.Map;
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class BillingTemplateVO {
|
||||
// 站点id
|
||||
private String stationId;
|
||||
|
||||
// 计费模板id
|
||||
private String templateId;
|
||||
|
||||
|
||||
@@ -489,4 +489,41 @@
|
||||
and t2.station_id = #{stationId,jdbcType=VARCHAR}
|
||||
order by t2.publish_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectBillingTemplateByStationIdList" resultType="com.jsowell.pile.vo.web.BillingTemplateVO">
|
||||
select
|
||||
t1.id as stationId,
|
||||
t2.id as templateId,
|
||||
t2.template_code as templateCode,
|
||||
t2.name as templateName,
|
||||
t2.remark as remark,
|
||||
t2.type as deviceType,
|
||||
t2.publish_time as publishTime,
|
||||
t3.electricity_price AS sharpElectricityPrice,
|
||||
t3.service_price AS sharpServicePrice,
|
||||
t3.apply_time AS sharpApplyDate,
|
||||
t4.electricity_price AS peakElectricityPrice,
|
||||
t4.service_price AS peakServicePrice,
|
||||
t4.apply_time AS peakApplyDate,
|
||||
t5.electricity_price AS flatElectricityPrice,
|
||||
t5.service_price AS flatServicePrice,
|
||||
t5.apply_time AS flatApplyDate,
|
||||
t6.electricity_price AS valleyElectricityPrice,
|
||||
t6.service_price AS valleyServicePrice,
|
||||
t6.apply_time AS valleyApplyDate
|
||||
from
|
||||
pile_billing_template t2
|
||||
left join pile_station_info t1 on t1.id = t2.station_id
|
||||
left JOIN pile_billing_detail t3 ON t3.template_code = t2.template_code AND t3.time_type = '1'
|
||||
left JOIN pile_billing_detail t4 ON t4.template_code = t2.template_code AND t4.time_type = '2'
|
||||
left JOIN pile_billing_detail t5 ON t5.template_code = t2.template_code AND t5.time_type = '3'
|
||||
left JOIN pile_billing_detail t6 ON t6.template_code = t2.template_code AND t6.time_type = '4'
|
||||
where
|
||||
t2.del_flag = '0'
|
||||
and t2.status = '1'
|
||||
and t2.station_id in
|
||||
<foreach collection="stationIdList" item="item" open="(" separator="," close=")">
|
||||
#{item,jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -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<AMapStationInfo> getStationInfosV2(GetStationInfoDTO dto);
|
||||
}
|
||||
|
||||
@@ -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<AMapStationInfo> getStationInfosV2(GetStationInfoDTO dto) {
|
||||
List<AMapStationInfo> resultList = Lists.newArrayList();
|
||||
// 设置分页参数
|
||||
int pageNo = dto.getCurrentPage() == null ? 1 : dto.getCurrentPage();
|
||||
int pageSize = dto.getPageSize() == null ? 20 : dto.getPageSize();
|
||||
PageUtils.startPage(pageNo, pageSize);
|
||||
|
||||
// 第一次查询,得到站点
|
||||
List<PileStationInfo> stationInfos = pileStationInfoService.getStationInfosByThirdParty();
|
||||
PageInfo<PileStationInfo> pageInfo = new PageInfo<>(stationInfos);
|
||||
List<PileStationInfo> stationList = pageInfo.getList();
|
||||
if (CollectionUtils.isEmpty(stationList)) {
|
||||
return resultList;
|
||||
}
|
||||
// 站点id
|
||||
List<String> stationIdList = stationList.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList());
|
||||
// 第二次查询,得到计费模板信息
|
||||
Map<String, List<AMapPriceChargingInfo>> priceInfoMap = getPriceInfoByStationIdList(stationIdList);
|
||||
|
||||
// 第三次查询,得到充电桩
|
||||
Map<String, List<AMapEquipmentInfo>> 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<AMapEquipmentInfo> 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<String, List<AMapPriceChargingInfo>> getPriceInfoByStationIdList(List<String> stationIdList) {
|
||||
Map<String, List<AMapPriceChargingInfo>> resultMap = Maps.newHashMap();
|
||||
|
||||
List<BillingTemplateVO> list = pileBillingTemplateService.selectBillingTemplateByStationIdList(stationIdList);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
List<AMapPriceChargingInfo> priceList;
|
||||
AMapPriceChargingInfo info;
|
||||
for (BillingTemplateVO billingTemplateVO : list) {
|
||||
// billingTemplateVO 站点计费模板
|
||||
priceList = Lists.newArrayList();
|
||||
List<BillingDetailVO> billingDetailList = billingTemplateVO.getBillingDetailList();
|
||||
for (BillingDetailVO billingDetailVO : billingDetailList) {
|
||||
// billingDetailVO 计费模板的尖峰平谷详细信息
|
||||
List<String> 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<String, List<AMapEquipmentInfo>> getPileListByStationIdList(List<String> stationIdList) {
|
||||
Map<String, List<AMapEquipmentInfo>> resultMap = Maps.newHashMap();
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据桩号查询枪口列表
|
||||
|
||||
Reference in New Issue
Block a user