mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
update 加缓存
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -78,53 +79,70 @@ public class AMapServiceImpl implements AMapService {
|
||||
if (CollectionUtils.isEmpty(stationInfos)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
AMapStationInfo aMapInfo;
|
||||
// 拼装高德格式数据
|
||||
sw.start("拼装高德格式数据");
|
||||
for (PileStationInfo stationInfo : stationInfos) {
|
||||
aMapInfo = new AMapStationInfo();
|
||||
|
||||
aMapInfo.setStationID(String.valueOf(stationInfo.getId()));
|
||||
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, BigDecimal.ROUND_HALF_UP));
|
||||
aMapInfo.setStationLat(new BigDecimal(stationInfo.getStationLat()).setScale(6, BigDecimal.ROUND_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());
|
||||
// 根据站点id查询计费模板
|
||||
List<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||
aMapInfo.setPriceChargingInfo(priceList);
|
||||
// 根据站点id查询快、慢充设备数量
|
||||
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(stationInfo.getId());
|
||||
aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal"));
|
||||
aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal"));
|
||||
// 根据站点查询站点下所有桩
|
||||
List<AMapEquipmentInfo> aMapEquipmentInfos = getPileListByStationId(String.valueOf(stationInfo.getId()));
|
||||
aMapInfo.setEquipmentInfos(aMapEquipmentInfos);
|
||||
|
||||
resultList.add(aMapInfo);
|
||||
AMapStationInfo aMapStationInfo = assembleAMapData(stationInfo);
|
||||
resultList.add(aMapStationInfo);
|
||||
}
|
||||
sw.stop();
|
||||
log.info("接口耗时:{}, 详情:{}", sw.getTotalTimeMillis(), sw.prettyPrint());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼装高德需要的格式数据
|
||||
* @param stationInfo 站点信息
|
||||
* @return 高度需要的数据格式
|
||||
*/
|
||||
private AMapStationInfo assembleAMapData(PileStationInfo stationInfo) {
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start("set数据");
|
||||
AMapStationInfo aMapInfo = new AMapStationInfo();
|
||||
aMapInfo.setStationID(String.valueOf(stationInfo.getId()));
|
||||
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());
|
||||
sw.stop();
|
||||
// 根据站点id查询计费模板
|
||||
sw.start("根据站点id查询计费模板");
|
||||
List<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||
aMapInfo.setPriceChargingInfo(priceList);
|
||||
sw.stop();
|
||||
// 根据站点id查询快、慢充设备数量
|
||||
sw.start("根据站点id查询快、慢充设备数量");
|
||||
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(stationInfo.getId());
|
||||
aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal"));
|
||||
aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal"));
|
||||
sw.stop();
|
||||
// 根据站点查询站点下所有桩
|
||||
sw.start("根据站点查询站点下所有桩");
|
||||
List<AMapEquipmentInfo> aMapEquipmentInfos = getPileListByStationId(String.valueOf(stationInfo.getId()));
|
||||
aMapInfo.setEquipmentInfos(aMapEquipmentInfos);
|
||||
sw.stop();
|
||||
log.info("组装高德数据格式耗时:{}, 详细:{}", sw.getTotalTimeMillis(), sw.prettyPrint());
|
||||
return aMapInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家推送充电设备动态数据
|
||||
* @param pileConnectorCode
|
||||
@@ -195,8 +213,8 @@ public class AMapServiceImpl implements AMapService {
|
||||
for (BillingPriceVO billingPriceVO : billingPriceList) {
|
||||
AMapPriceChargingInfo info = new AMapPriceChargingInfo();
|
||||
info.setFeeTime(billingPriceVO.getStartTime() + "-" + billingPriceVO.getEndTime()); // 时间段
|
||||
info.setElectricityFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); // 电费
|
||||
info.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); // 服务费
|
||||
info.setElectricityFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, RoundingMode.HALF_UP)); // 电费
|
||||
info.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, RoundingMode.HALF_UP)); // 服务费
|
||||
|
||||
priceList.add(info);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user