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 dc7aa7c8b..d88afadfa 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 @@ -462,7 +462,9 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi if (billingTemplateVO == null) { return Lists.newArrayList(); } + // EchoBillingTemplateVO echoBillingTemplateVO = queryPileBillingTemplateById(Long.parseLong(billingTemplateVO.getTemplateId())); + // 时段清单 List timeArray = echoBillingTemplateVO.getTimeArray(); log.info("计费模板时段:{}", JSONObject.toJSONString(timeArray)); 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 4c9d3d65d..35b8cfbd5 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 @@ -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 priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId())); - aMapInfo.setPriceChargingInfo(priceList); - // 根据站点id查询快、慢充设备数量 - Map pileNumMap = pileConnectorInfoService.getPileTypeNum(stationInfo.getId()); - aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal")); - aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal")); - // 根据站点查询站点下所有桩 - List 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 priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId())); + aMapInfo.setPriceChargingInfo(priceList); + sw.stop(); + // 根据站点id查询快、慢充设备数量 + sw.start("根据站点id查询快、慢充设备数量"); + Map pileNumMap = pileConnectorInfoService.getPileTypeNum(stationInfo.getId()); + aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal")); + aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal")); + sw.stop(); + // 根据站点查询站点下所有桩 + sw.start("根据站点查询站点下所有桩"); + List 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); }