New file |
| | |
| | | package com.ruoyi.integration.drainage; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.nacos.common.utils.JacksonUtils; |
| | | import com.ruoyi.chargingPile.api.feignClient.*; |
| | | import com.ruoyi.chargingPile.api.model.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ChargingPercentProvinceDto; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.HttpUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; |
| | | import com.ruoyi.integration.api.vo.StartChargeResult; |
| | | import com.ruoyi.integration.drainage.kuaidian.TCECKDUtil; |
| | | import com.ruoyi.integration.drainage.kuaidian.model.*; |
| | | import com.ruoyi.integration.drainage.model.*; |
| | | import com.ruoyi.integration.drainage.model.enu.*; |
| | | import com.ruoyi.integration.mongodb.service.UploadRealTimeMonitoringDataService; |
| | | import com.ruoyi.order.api.dto.ChargingStatisticeDTO; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.AddTripartitePlatformOrder; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy; |
| | | import com.ruoyi.other.api.domain.Operator; |
| | | import com.ruoyi.other.api.feignClient.OperatorClient; |
| | | import com.ruoyi.other.api.feignClient.SystemConfigurationClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.concurrent.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2025/1/21 17:52 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/evcs/v1.0") |
| | | public class TCECController1 { |
| | | |
| | | @Resource |
| | | private SiteClient siteClient; |
| | | |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | | |
| | | @Resource |
| | | private ChargingGunClient chargingGunClient; |
| | | |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | | @Resource |
| | | private OperatorClient operatorClient; |
| | | |
| | | @Resource |
| | | private AccountingStrategyDetailClient accountingStrategyDetailClient; |
| | | |
| | | @Resource |
| | | private ChargingOrderAccountingStrategyClient chargingOrderAccountingStrategyClient; |
| | | |
| | | @Resource |
| | | private UploadRealTimeMonitoringDataService uploadRealTimeMonitoringDataService; |
| | | |
| | | @Resource |
| | | private TokenUtil tokenUtil; |
| | | |
| | | @Resource |
| | | private ParkingLotClient parkingLotClient; |
| | | |
| | | @Resource |
| | | private ParkingRecordClient parkingRecordClient; |
| | | |
| | | @Resource |
| | | private SystemConfigurationClient systemConfigurationClient; |
| | | // 监管平台密钥 向量 地址 |
| | | private static String ourDataSecret = ""; |
| | | private static String ourDataSecretIv = ""; |
| | | private static String url = "https://dev-gov-hlht-sc.unievbj.com/evcs/v1.0.0/";// 测试 |
| | | // private static String url = "https://hlht-dipper-sc.unievbj.com/evcs/v1.0.0/";// 正式 |
| | | private static String operatorSecret = "f1331ef0b37c2d1b";// 测试 |
| | | // private static String operatorSecret = "a762796b2a8989b8";// 正式 |
| | | |
| | | |
| | | |
| | | /** |
| | | * 请求校验 |
| | | * @param baseRequest |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public BaseResult requestCheck(Boolean tokenCheck, BaseRequest baseRequest, HttpServletRequest request){ |
| | | BaseResult baseResult = new BaseResult(); |
| | | baseResult.setRet(0); |
| | | baseResult.setMsg("成功"); |
| | | baseResult.setOperatorID(baseRequest.getOperatorID()); |
| | | Long mapKey = Long.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
| | | baseResult.setTimeStamp(mapKey); |
| | | baseResult.setSeq("0001"); |
| | | //校验token和签名 |
| | | String operatorID = baseRequest.getOperatorID(); |
| | | String sig = baseRequest.getSig(); |
| | | Long timeStamp = baseRequest.getTimeStamp(); |
| | | String data = baseRequest.getData(); |
| | | String seq = baseRequest.getSeq(); |
| | | if(StringUtils.isEmpty(operatorID) || StringUtils.isEmpty(sig) || StringUtils.isEmpty(data) || StringUtils.isEmpty(seq) || null == timeStamp){ |
| | | baseResult.setRet(4003); |
| | | baseResult.setMsg("参数异常"); |
| | | return baseResult; |
| | | } |
| | | |
| | | R<Operator> r = operatorClient.getOperator(operatorID); |
| | | if(200 != r.getCode()){ |
| | | baseResult.setRet(500); |
| | | baseResult.setMsg("系统异常"); |
| | | return baseResult; |
| | | } |
| | | //校验token |
| | | if(tokenCheck){ |
| | | Operator loginUser = tokenUtil.getLoginUser(request); |
| | | if(null == loginUser){ |
| | | baseResult.setRet(4002); |
| | | baseResult.setMsg("身份校验失败,无效的token"); |
| | | return baseResult; |
| | | } |
| | | } |
| | | |
| | | Operator operator = r.getData(); |
| | | baseResult.setOperator(operator); |
| | | baseRequest.setOperator(operator); |
| | | //校验签名 |
| | | String sign = TCECUtil.ourBuildSign(baseRequest); |
| | | if(!sign.equals(sig)){ |
| | | baseResult.setRet(4001); |
| | | baseResult.setMsg("签名校验失败"); |
| | | return baseResult; |
| | | } |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取token |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_token") |
| | | public BaseResult queryToken(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台获取token请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | BaseResult baseResult = requestCheck(false, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台获取token响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取token响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | QueryTokenResult queryTokenResult = new QueryTokenResult(); |
| | | Operator operator = baseResult.getOperator(); |
| | | if(null == operator){ |
| | | queryTokenResult.setSuccStat(1); |
| | | queryTokenResult.setFailReason(1); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryTokenResult); |
| | | log.info("三方平台获取token响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取token响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台获取token请求Data:" + decrypt); |
| | | QueryToken queryToken = JSON.parseObject(decrypt, QueryToken.class); |
| | | if(!queryToken.getOperatorSecret().equals(operator.getOurOperatorSecret())){ |
| | | queryTokenResult.setSuccStat(1); |
| | | queryTokenResult.setFailReason(2); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryTokenResult); |
| | | log.info("三方平台获取token响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取token响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | //生成token |
| | | Map<String, Object> token = tokenUtil.createToken(operator); |
| | | String access_token = token.get("access_token").toString(); |
| | | Long expires_in = Long.valueOf(token.get("expires_in").toString()); |
| | | |
| | | queryTokenResult.setOperatorID("906171535"); |
| | | queryTokenResult.setSuccStat(0); |
| | | queryTokenResult.setFailReason(0); |
| | | queryTokenResult.setAccessToken(access_token); |
| | | queryTokenResult.setTokenAvailableTime(expires_in * 60); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryTokenResult); |
| | | log.info("三方平台获取token响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取token响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询充电站信息 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_stations_info") |
| | | public BaseResult queryStationsInfo(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台查询充电站信息请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台查询充电站信息响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询充电站信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台查询充电站信息请求Data:" + decrypt); |
| | | QueryStationsInfo queryStationsInfo = JSON.parseObject(decrypt, QueryStationsInfo.class); |
| | | Integer pageNo = queryStationsInfo.getPageNo(); |
| | | Integer pageSize = queryStationsInfo.getPageSize(); |
| | | if(null == pageNo){ |
| | | pageNo = 1; |
| | | } |
| | | if(null == pageSize){ |
| | | pageSize = 10; |
| | | } |
| | | PageInfo<Site> siteListPaging = siteClient.getSiteListPaging(pageNo, pageSize, new ArrayList<>()); |
| | | List<TParkingLot> parkingLots = parkingLotClient.getAllParkingLot().getData(); |
| | | QueryStationsInfoResult queryStationsInfoResult = new QueryStationsInfoResult(); |
| | | queryStationsInfoResult.setPageNo(pageNo); |
| | | queryStationsInfoResult.setPageCount((0 == (siteListPaging.getTotal() % pageSize) ? 0 : 1) + Double.valueOf(siteListPaging.getTotal() / pageSize).intValue()); |
| | | queryStationsInfoResult.setItemSize(Long.valueOf(siteListPaging.getTotal()).intValue()); |
| | | queryStationsInfoResult.setStationInfos(buildSite(parkingLots, siteListPaging.getRecords())); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryStationsInfoResult); |
| | | log.info("三方平台查询充电站信息响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询充电站信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建站点数据 |
| | | * @param sites |
| | | * @return |
| | | */ |
| | | public List<StationInfo> buildSite(List<TParkingLot> parkingLots, List<Site> sites){ |
| | | List<Integer> siteIds = sites.stream().map(Site::getId).collect(Collectors.toList()); |
| | | List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData(); |
| | | List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList()); |
| | | List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(collect1).getData(); |
| | | String serviceTel = systemConfigurationClient.getServerPhone().getData(); |
| | | List<StationInfo> StationInfos = new ArrayList<>(); |
| | | for (Site datum : sites) { |
| | | StationInfo stationInfo = new StationInfo(); |
| | | stationInfo.setAreaCodeCountryside(datum.getAreaCodeCountryside()); |
| | | stationInfo.setStationClassification(datum.getStationClassification()); |
| | | stationInfo.setGeneralApplicationType(datum.getGeneralApplicationType()); |
| | | if (org.springframework.util.StringUtils.hasLength(datum.getSwapMatchCars())){ |
| | | stationInfo.setSwapMatchCars(Arrays.asList(datum.getSwapMatchCars().split(","))); |
| | | } |
| | | stationInfo.setBusineHours(datum.getStartServiceTime()); |
| | | stationInfo.setRoundTheClock(datum.getRoundTheClock()); |
| | | stationInfo.setParkType(datum.getParkType()); |
| | | stationInfo.setElectricityFee("{"+datum.getElectricityFee()+"}"); |
| | | stationInfo.setServiceFee("{"+datum.getServiceFee()+"}"); |
| | | stationInfo.setParkFee("{\"rules\":"+datum.getParkFee()+","+"\"freeDuration\":"+datum.getParkFeeFree()+"}"); |
| | | stationInfo.setElectricityType(datum.getElectricityType()); |
| | | stationInfo.setBusinessExpandType(datum.getBusinessExpandType()); |
| | | stationInfo.setCapacity(datum.getCapacity()); |
| | | stationInfo.setRatedPower(datum.getRatedPower()); |
| | | stationInfo.setPeriodFee(datum.getPeriodFee()); |
| | | stationInfo.setOfficialRunTime(datum.getOfficialRunTime()); |
| | | stationInfo.setStationOrientation(datum.getStationOrientation()); |
| | | stationInfo.setStationArea(datum.getStationArea()); |
| | | stationInfo.setHavePerson(datum.getHavePerson()); |
| | | stationInfo.setVideoMonitor(datum.getVideoMonitor()); |
| | | if (StringUtils.isNotEmpty(datum.getSupportingFacilities())){ |
| | | String[] split = datum.getSupportingFacilities().split(","); |
| | | List<Integer> collect = Arrays.stream(split).map(Integer::parseInt).collect(Collectors.toList()); |
| | | stationInfo.setSupportingFacilities(collect); |
| | | } |
| | | stationInfo.setPrinterFlag(datum.getPrinterFlag()); |
| | | stationInfo.setBarrierFlag(datum.getBarrierFlag()); |
| | | stationInfo.setParkingLockFlag(datum.getParkingLockFlag()); |
| | | stationInfo.setEquipmentOwnerName(datum.getEquipmentOwnerName()); |
| | | stationInfo.setResidentNo(datum.getResidentNo()); |
| | | stationInfo.setSupplyType(datum.getSupplyType()); |
| | | stationInfo.setWattHourMeterNo(datum.getWattHourMeterNo()); |
| | | BigDecimal forwardPower = datum.getForwardPower(); |
| | | if (forwardPower!=null){ |
| | | stationInfo.setForwardPower(forwardPower.setScale(4, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | stationInfo.setRecordUniqueNo(datum.getRecordUniqueNo()); |
| | | stationInfo.setStationID(datum.getId().toString()); |
| | | stationInfo.setOperatorID("906171535"); |
| | | stationInfo.setEquipmentOwnerID("906171535"); |
| | | stationInfo.setStationName(datum.getName()); |
| | | stationInfo.setCountryCode(StringUtils.isNotEmpty(datum.getCountryCode()) ? datum.getCountryCode() : "CN"); |
| | | stationInfo.setAreaCode(datum.getDistrictsCode()); |
| | | stationInfo.setAddress(datum.getAddress()); |
| | | stationInfo.setStationTel(datum.getPhone()); |
| | | stationInfo.setServiceTel(serviceTel); |
| | | switch (datum.getSiteType()){ |
| | | case 0: |
| | | stationInfo.setStationType(StationTypeEnum.OTHER.getType()); |
| | | break; |
| | | case 1: |
| | | stationInfo.setStationType(StationTypeEnum.PUBLIC.getType()); |
| | | break; |
| | | case 2: |
| | | stationInfo.setStationType(StationTypeEnum.PERSONAGE.getType()); |
| | | break; |
| | | case 3: |
| | | stationInfo.setStationType(StationTypeEnum.BUS_SPECIFIC.getType()); |
| | | break; |
| | | case 4: |
| | | stationInfo.setStationType(StationTypeEnum.SANITATION_SPECIFIC.getType()); |
| | | break; |
| | | case 5: |
| | | stationInfo.setStationType(StationTypeEnum.LOGISTICS_SPECIFIC.getType()); |
| | | break; |
| | | case 6: |
| | | stationInfo.setStationType(StationTypeEnum.TEXT_SPECIFIC.getType()); |
| | | break; |
| | | } |
| | | if(datum.getStatus() == 1){ |
| | | stationInfo.setStationStatus(StationStatusEnum.NORMAL_USE.getStatus()); |
| | | } |
| | | if(datum.getStatus() == 2){ |
| | | stationInfo.setStationStatus(StationStatusEnum.MAINTAIN.getStatus()); |
| | | } |
| | | if(datum.getStatus() == 3){ |
| | | stationInfo.setStationStatus(StationStatusEnum.OFF_LINE.getStatus()); |
| | | } |
| | | stationInfo.setParkNums(datum.getParkingSpace()); |
| | | stationInfo.setStationLat(new BigDecimal(datum.getLat()).setScale(6, RoundingMode.DOWN)); |
| | | stationInfo.setStationLng(new BigDecimal(datum.getLon()).setScale(6, RoundingMode.DOWN)); |
| | | stationInfo.setConstruction(datum.getConstructionSite() == 0 ? ConstructionEnum.OTHER.getType() : datum.getConstructionSite()); |
| | | stationInfo.setPictures(StringUtils.isNotEmpty(datum.getImgUrl()) ? Arrays.asList(datum.getImgUrl().split(",")) : new ArrayList<>()); |
| | | stationInfo.setSiteGuide(datum.getGuide()); |
| | | stationInfo.setMatchCars(datum.getVehicleDescription()); |
| | | // stationInfo.setBusineHours(datum.getStartServiceTime() + "-" + datum.getEndServiceTime()); |
| | | stationInfo.setElectricityFee(datum.getRateDescription()); |
| | | //添加停车费信息 |
| | | Optional<TParkingLot> first = parkingLots.stream().filter(s -> s.getSiteId().equals(datum.getId())).findFirst(); |
| | | if(first.isPresent()){ |
| | | TParkingLot tParkingLot = first.get(); |
| | | buildPlaceHolder(tParkingLot, stationInfo); |
| | | } |
| | | //构建充电设备信息数据 |
| | | stationInfo.setEquipmentInfos(buildEquipmentInfo(datum.getId(), tChargingPiles, chargingGunList)); |
| | | StationInfos.add(stationInfo); |
| | | |
| | | } |
| | | return StationInfos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建停车费信息 |
| | | * @param tParkingLot |
| | | * @param stationInfo |
| | | */ |
| | | public void buildPlaceHolder(TParkingLot tParkingLot, StationInfo stationInfo){ |
| | | stationInfo.setOvertimeFee(tParkingLot.getName() + "停车费"); |
| | | PlaceHolder placeHolder = new PlaceHolder(); |
| | | placeHolder.setFreeTime(tParkingLot.getChargeFreeDuration()); |
| | | placeHolder.setMaxFee(tParkingLot.getChargeCapping()); |
| | | List<PlaceHolderPrice> PlaceHolderPrices = new ArrayList<>(); |
| | | PlaceHolderPrice placeHolderPrice = new PlaceHolderPrice(); |
| | | placeHolderPrice.setStartTime("00:00"); |
| | | placeHolderPrice.setEndTime("23:59"); |
| | | placeHolderPrice.setPrice(tParkingLot.getChargeRate()); |
| | | PlaceHolderPrices.add(placeHolderPrice); |
| | | placeHolder.setPlaceHolderPrices(PlaceHolderPrices); |
| | | stationInfo.setPlaceHolder(placeHolder); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 构建桩数据 |
| | | * @param tChargingPiles |
| | | * @return |
| | | */ |
| | | public List<EquipmentInfo> buildEquipmentInfo(Integer siteId, List<TChargingPile> tChargingPiles, List<TChargingGun> chargingGunList){ |
| | | List<EquipmentInfo> equipmentInfos = new ArrayList<>(); |
| | | List<TChargingPile> collect = tChargingPiles.stream().filter(s -> s.getSiteId().equals(siteId)).collect(Collectors.toList()); |
| | | for (TChargingPile tChargingPile : collect) { |
| | | EquipmentInfo equipmentInfo = new EquipmentInfo(); |
| | | equipmentInfo.setEquipmentID(tChargingPile.getId().toString()); |
| | | equipmentInfo.setManufacturerID(tChargingPile.getManufacturerCode()); |
| | | equipmentInfo.setManufacturerName(tChargingPile.getManufacturer()); |
| | | equipmentInfo.setEquipmentModel(tChargingPile.getEquipmentType()); |
| | | equipmentInfo.setEquipmentUniqueNumber(tChargingPile.getEquipmentUniqueNumber()); |
| | | equipmentInfo.setEquipmentClassification(tChargingPile.getEquipmentClassification()); |
| | | if(null != tChargingPile.getProductionDate()){ |
| | | equipmentInfo.setProductionDate(tChargingPile.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | } |
| | | switch (tChargingPile.getType()){ |
| | | case 0: |
| | | equipmentInfo.setEquipmentType(EquipmentTypeEnum.OTHER.getType()); |
| | | break; |
| | | case 1: |
| | | equipmentInfo.setEquipmentType(EquipmentTypeEnum.DIRECT_CURRENT.getType()); |
| | | break; |
| | | case 2: |
| | | equipmentInfo.setEquipmentType(EquipmentTypeEnum.ALTERNATING_CURRENT.getType()); |
| | | break; |
| | | case 3: |
| | | equipmentInfo.setEquipmentType(EquipmentTypeEnum.ALTERNATING_DIRECT.getType()); |
| | | break; |
| | | case 4: |
| | | equipmentInfo.setEquipmentType(EquipmentTypeEnum.WIRELESS_DEVICE.getType()); |
| | | break; |
| | | case 5: |
| | | equipmentInfo.setEquipmentType(EquipmentTypeEnum.ORDER.getType()); |
| | | break; |
| | | case 6: |
| | | equipmentInfo.setEquipmentType(EquipmentTypeEnum.V2G.getType()); |
| | | break; |
| | | } |
| | | |
| | | //构建设备接口信息 |
| | | equipmentInfo.setConnectorInfos(buildConnectorInfos(tChargingPile.getId(), tChargingPile.getCode(), chargingGunList)); |
| | | equipmentInfo.setPower(tChargingPile.getRatedPower()); |
| | | equipmentInfos.add(equipmentInfo); |
| | | } |
| | | return equipmentInfos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建接口数据 |
| | | * @param chargingGunList |
| | | * @return |
| | | */ |
| | | public List<ConnectorInfo> buildConnectorInfos(Integer chargingPileId, String code, List<TChargingGun> chargingGunList){ |
| | | List<ConnectorInfo> connectorInfos = new ArrayList<>(); |
| | | List<TChargingGun> collect = chargingGunList.stream().filter(s -> s.getChargingPileId().equals(chargingPileId)).collect(Collectors.toList()); |
| | | for (TChargingGun chargingGun : collect) { |
| | | ConnectorInfo connectorInfo = new ConnectorInfo(); |
| | | connectorInfo.setConnectorID(chargingGun.getFullNumber()); |
| | | connectorInfo.setConnectorName(chargingGun.getName()); |
| | | connectorInfo.setEquipmentClassification(chargingGun.getEquipmentClassification()); |
| | | connectorInfo.setConstantVoltageLowerLimits(chargingGun.getConstantVoltageLowerLimits()); |
| | | connectorInfo.setConstantVoltageUpperLimits(chargingGun.getConstantVoltageUpperLimits()); |
| | | connectorInfo.setConstantCurrentLowerLimits(chargingGun.getConstantCurrentLowerLimits()); |
| | | connectorInfo.setConstantCurrentUpperLimits(chargingGun.getConstantCurrentUpperLimits()); |
| | | connectorInfo.setAuxPower(chargingGun.getAuxPower()); |
| | | connectorInfo.setOpreateStatus(chargingGun.getOpreateStatus()); |
| | | connectorInfo.setOpreateHours(chargingGun.getOpreateHours()); |
| | | switch (chargingGun.getType()){ |
| | | case 0: |
| | | connectorInfo.setConnectorType(ConnectorTypeEnum.OTHER.getType()); |
| | | break; |
| | | case 1: |
| | | connectorInfo.setConnectorType(ConnectorTypeEnum.HOUSEHOLD_SOCKET.getType()); |
| | | break; |
| | | case 2: |
| | | connectorInfo.setConnectorType(ConnectorTypeEnum.AC_SOCKET.getType()); |
| | | break; |
| | | case 3: |
| | | connectorInfo.setConnectorType(ConnectorTypeEnum.AC_INTERFACE_PLUG.getType()); |
| | | break; |
| | | case 4: |
| | | connectorInfo.setConnectorType(ConnectorTypeEnum.DC_INTERFACE_GUN_HEAD.getType()); |
| | | break; |
| | | case 5: |
| | | connectorInfo.setConnectorType(ConnectorTypeEnum.WIRELESS_CHARGING_STAND.getType()); |
| | | break; |
| | | } |
| | | connectorInfo.setCurrent(chargingGun.getRatedCurrent().intValue()); |
| | | connectorInfo.setPower(chargingGun.getRatedPower()); |
| | | connectorInfo.setParkNo(chargingGun.getParkingNumber()); |
| | | connectorInfo.setNationalStandard(Integer.valueOf(chargingGun.getNationalStandard())); |
| | | connectorInfo.setQRCode("https://mxcd.zhinenganguan.com?No=" + code + chargingGun.getCode()); |
| | | connectorInfos.add(connectorInfo); |
| | | } |
| | | return connectorInfos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 接口状态变化后推送给第三方 |
| | | * @return |
| | | */ |
| | | @PostMapping("/pushChargingGunStatus") |
| | | public R pushChargingGunStatus(@RequestParam("fullNumber") String fullNumber, @RequestParam("status") Integer status){ |
| | | ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo(); |
| | | connectorStatusInfo.setConnectorID(fullNumber); |
| | | switch (status){ |
| | | case 1: |
| | | connectorStatusInfo.setStatus(0); |
| | | break; |
| | | case 2: |
| | | connectorStatusInfo.setStatus(1); |
| | | break; |
| | | case 3: |
| | | connectorStatusInfo.setStatus(2); |
| | | break; |
| | | case 4: |
| | | connectorStatusInfo.setStatus(3); |
| | | break; |
| | | case 5: |
| | | connectorStatusInfo.setStatus(3); |
| | | break; |
| | | case 6: |
| | | connectorStatusInfo.setStatus(4); |
| | | break; |
| | | case 7: |
| | | connectorStatusInfo.setStatus(255); |
| | | break; |
| | | } |
| | | ConnectorStatusInfo connectorStatusInfo1 = new ConnectorStatusInfo(); |
| | | BeanUtils.copyProperties(connectorStatusInfo, connectorStatusInfo1); |
| | | connectorStatusInfo.setConnectorStatusInfo(connectorStatusInfo1); |
| | | List<Operator> operators = operatorClient.getAllOperator().getData(); |
| | | for (Operator operator : operators) { |
| | | TCECUtil.notificationStationStatus(operator, connectorStatusInfo); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 设备接口状态查询 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_station_status") |
| | | public BaseResult queryStationStatus(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台获取设备接口状态请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台获取设备接口状态响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取设备接口状态响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台获取设备接口状态请求Data:" + decrypt); |
| | | QueryStationStatus queryStationsInfo = JSON.parseObject(decrypt, QueryStationStatus.class); |
| | | List<Integer> collect = queryStationsInfo.getStationIDs().stream().map(Integer::valueOf).collect(Collectors.toList()); |
| | | List<Site> data = siteClient.getSiteByIds(collect).getData(); |
| | | List<Integer> siteIds = data.stream().map(Site::getId).collect(Collectors.toList()); |
| | | List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData(); |
| | | List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList()); |
| | | List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(collect1).getData(); |
| | | |
| | | QueryStationStatusResult result = new QueryStationStatusResult(); |
| | | result.setTotal(data.size()); |
| | | List<StationStatusInfo> StationStatusInfos = new ArrayList<>(); |
| | | for (Site datum : data) { |
| | | StationStatusInfo stationStatusInfo = new StationStatusInfo(); |
| | | stationStatusInfo.setStationID(datum.getId().toString()); |
| | | //构建接口状态 |
| | | List<ConnectorStatusInfo> ConnectorStatusInfos = new ArrayList<>(); |
| | | List<TChargingGun> collect2 = chargingGunList.stream().filter(s -> s.getSiteId().equals(datum.getId())).collect(Collectors.toList()); |
| | | for (TChargingGun chargingGun : collect2) { |
| | | ConnectorStatusInfo info = new ConnectorStatusInfo(); |
| | | info.setConnectorID(chargingGun.getFullNumber()); |
| | | switch (chargingGun.getStatus()){ |
| | | case 1: |
| | | info.setStatus(0); |
| | | break; |
| | | case 2: |
| | | info.setStatus(1); |
| | | break; |
| | | case 3: |
| | | info.setStatus(2); |
| | | break; |
| | | case 4: |
| | | info.setStatus(3); |
| | | break; |
| | | case 5: |
| | | info.setStatus(3); |
| | | break; |
| | | case 6: |
| | | info.setStatus(4); |
| | | break; |
| | | case 7: |
| | | info.setStatus(255); |
| | | break; |
| | | } |
| | | ConnectorStatusInfos.add(info); |
| | | } |
| | | stationStatusInfo.setConnectorStatusInfos(ConnectorStatusInfos); |
| | | StationStatusInfos.add(stationStatusInfo); |
| | | } |
| | | result.setStationStatusInfos(StationStatusInfos); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(result); |
| | | log.info("三方平台获取设备接口状态响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取设备接口状态响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询统计信息 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_station_stats") |
| | | public BaseResult queryStationStats(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台获取统计信息请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台获取统计信息响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取统计信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台获取统计信息请求Data:" + decrypt); |
| | | QueryStationStats queryStationStats = JSON.parseObject(decrypt, QueryStationStats.class); |
| | | QueryStationStatsResult result = new QueryStationStatsResult(); |
| | | ChargingPercentProvinceDto dto = new ChargingPercentProvinceDto(); |
| | | dto.setDate1(LocalDate.parse(queryStationStats.getStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | dto.setDate2(LocalDate.parse(queryStationStats.getEndTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | dto.setSiteIds(new HashSet<>(Integer.valueOf(queryStationStats.getStationID()))); |
| | | dto.setTripartitePlatformName(operator.getName()); |
| | | List<TChargingOrder> chargingOrders = chargingOrderClient.getOrderBySiteIdAndTime(dto).getData(); |
| | | BigDecimal reduce = chargingOrders.stream().map(TChargingOrder::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | StationStatsInfo stationStats = new StationStatsInfo(); |
| | | stationStats.setStationID(chargingOrders.get(0).getSiteId().toString()); |
| | | stationStats.setStartTime(queryStationStats.getStartTime()); |
| | | stationStats.setEndTime(queryStationStats.getEndTime()); |
| | | stationStats.setStationElectricity(reduce); |
| | | //构建设备统计数据 |
| | | List<EquipmentStatsInfo> EquipmentStatsInfos = new ArrayList<>(); |
| | | Map<Integer, List<TChargingOrder>> collect = chargingOrders.stream().collect(Collectors.groupingBy(TChargingOrder::getChargingPileId)); |
| | | for (Integer integer : collect.keySet()) { |
| | | List<TChargingOrder> tChargingOrders = collect.get(integer); |
| | | BigDecimal reduce1 = tChargingOrders.stream().map(TChargingOrder::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | EquipmentStatsInfo equipmentStatsInfo = new EquipmentStatsInfo(); |
| | | equipmentStatsInfo.setEquipmentID(integer.toString()); |
| | | equipmentStatsInfo.setEquipmentElectricity(reduce1); |
| | | |
| | | //构建设备接口统计数据 |
| | | Map<Integer, List<TChargingOrder>> collect2 = tChargingOrders.stream().collect(Collectors.groupingBy(TChargingOrder::getChargingGunId)); |
| | | List<ConnectorStatsInfo> ConnectorStatsInfos = new ArrayList<>(); |
| | | for (Integer integer1 : collect2.keySet()) { |
| | | List<TChargingOrder> tChargingOrders1 = collect2.get(integer1); |
| | | BigDecimal reduce2 = tChargingOrders1.stream().map(TChargingOrder::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(integer1).getData(); |
| | | ConnectorStatsInfo connectorStatsInfo = new ConnectorStatsInfo(); |
| | | connectorStatsInfo.setConnectorID(chargingGun.getFullNumber()); |
| | | connectorStatsInfo.setConnectorElectricity(reduce2); |
| | | ConnectorStatsInfos.add(connectorStatsInfo); |
| | | } |
| | | equipmentStatsInfo.setConnectorStatsInfos(ConnectorStatsInfos); |
| | | EquipmentStatsInfos.add(equipmentStatsInfo); |
| | | } |
| | | stationStats.setEquipmentStatsInfos(EquipmentStatsInfos); |
| | | result.setStationStats(stationStats); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(result); |
| | | log.info("三方平台获取统计信息响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台获取统计信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 请求设备认证 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_equip_auth") |
| | | public BaseResult queryEquipAuth(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台设备认证请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台设备认证响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台设备认证响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台设备认证请求Data:" + decrypt); |
| | | QueryEquipAuth queryEquipAuth = JSON.parseObject(decrypt, QueryEquipAuth.class); |
| | | String connectorID = queryEquipAuth.getConnectorID(); |
| | | TChargingGun tChargingGun = chargingGunClient.getChargingGunByFullNumber(connectorID).getData(); |
| | | if(null == tChargingGun){ |
| | | baseResult.setRet(4004); |
| | | baseResult.setMsg("connectorID 参数无效"); |
| | | log.info("三方平台设备认证响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | QueryEquipAuthResult queryEquipAuthResult = new QueryEquipAuthResult(); |
| | | queryEquipAuthResult.setEquipAuthSeq(queryEquipAuth.getEquipAuthSeq()); |
| | | queryEquipAuthResult.setConnectorID(connectorID); |
| | | //1=离线,2=空闲,3=占用(未充电),4=占用(充电中),5=占用(已充满),6=占用(预约锁定),7=故障 |
| | | switch (tChargingGun.getStatus()){ |
| | | case 1: |
| | | queryEquipAuthResult.setSuccStat(1); |
| | | queryEquipAuthResult.setFailReason(2); |
| | | break; |
| | | case 2: |
| | | queryEquipAuthResult.setSuccStat(0); |
| | | queryEquipAuthResult.setFailReason(0); |
| | | break; |
| | | case 3: |
| | | queryEquipAuthResult.setSuccStat(0); |
| | | queryEquipAuthResult.setFailReason(1); |
| | | break; |
| | | case 4: |
| | | queryEquipAuthResult.setSuccStat(1); |
| | | queryEquipAuthResult.setFailReason(4); |
| | | break; |
| | | case 5: |
| | | queryEquipAuthResult.setSuccStat(1); |
| | | queryEquipAuthResult.setFailReason(5); |
| | | break; |
| | | case 6: |
| | | queryEquipAuthResult.setSuccStat(1); |
| | | queryEquipAuthResult.setFailReason(6); |
| | | break; |
| | | case 7: |
| | | queryEquipAuthResult.setSuccStat(1); |
| | | queryEquipAuthResult.setFailReason(2); |
| | | break; |
| | | } |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryEquipAuthResult); |
| | | log.info("三方平台设备认证响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台设备认证响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询业务策略信息 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_equip_business_policy") |
| | | public BaseResult queryEquipBusinessPolicy(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台查询业务策略信息请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台查询业务策略信息响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询业务策略信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台查询业务策略信息请求Data:" + decrypt); |
| | | QueryEquipBusinessPolicy queryEquipBusinessPolicy = JSON.parseObject(decrypt, QueryEquipBusinessPolicy.class); |
| | | |
| | | //构建返回结果 |
| | | QueryEquipBusinessPolicyResult queryEquipBusinessPolicyResult = new QueryEquipBusinessPolicyResult(); |
| | | queryEquipBusinessPolicyResult.setEquipBizSeq(queryEquipBusinessPolicy.getEquipBizSeq()); |
| | | queryEquipBusinessPolicyResult.setConnectorID(queryEquipBusinessPolicy.getConnectorID()); |
| | | queryEquipBusinessPolicyResult.setSuccStat(0); |
| | | queryEquipBusinessPolicyResult.setFailReason(0); |
| | | String connectorID = queryEquipBusinessPolicy.getConnectorID(); |
| | | TChargingGun tChargingGun = chargingGunClient.getChargingGunByFullNumber(connectorID).getData(); |
| | | if(null == tChargingGun){ |
| | | baseResult.setRet(4004); |
| | | baseResult.setMsg("connectorID 参数无效"); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryEquipBusinessPolicyResult); |
| | | log.info("三方平台查询业务策略信息响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询业务策略信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); |
| | | if(null == accountingStrategyId){ |
| | | List<Site> data = siteClient.getSiteByIds(Arrays.asList(tChargingGun.getSiteId())).getData(); |
| | | accountingStrategyId = data.get(0).getAccountingStrategyId(); |
| | | } |
| | | List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailClient.getListByAccountingStrategyId(accountingStrategyId).getData(); |
| | | if(accountingStrategyDetails.size() == 0){ |
| | | queryEquipBusinessPolicyResult.setSuccStat(1); |
| | | queryEquipBusinessPolicyResult.setFailReason(1); |
| | | queryEquipBusinessPolicyResult.setSumPeriod(0); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryEquipBusinessPolicyResult); |
| | | log.info("三方平台查询业务策略信息响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询业务策略信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | List<PolicyInfo> PolicyInfos = new ArrayList<>(); |
| | | for (TAccountingStrategyDetail accountingStrategyDetail : accountingStrategyDetails) { |
| | | PolicyInfo policyInfo = new PolicyInfo(); |
| | | policyInfo.setStartTime(accountingStrategyDetail.getStartTime().replaceAll(":", "") + "00"); |
| | | policyInfo.setElecPrice(accountingStrategyDetail.getElectrovalence()); |
| | | policyInfo.setSevicePrice(accountingStrategyDetail.getServiceCharge()); |
| | | PolicyInfos.add(policyInfo); |
| | | } |
| | | queryEquipBusinessPolicyResult.setSumPeriod(PolicyInfos.size()); |
| | | queryEquipBusinessPolicyResult.setPolicyInfos(PolicyInfos); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryEquipBusinessPolicyResult); |
| | | log.info("三方平台查询业务策略信息响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询业务策略信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 站点变更推送通知(快电) |
| | | * @param siteIds |
| | | * @return |
| | | */ |
| | | @PostMapping("/notificationStationChange") |
| | | public R notificationStationChange(@RequestParam("siteIds") List<Integer> siteIds){ |
| | | Operator operator = operatorClient.getOperatorByName("KuaiDian").getData(); |
| | | NotificationStationChangeResult notificationStationChange = TCECKDUtil.notificationStationChange(operator, 3, siteIds); |
| | | //启动重试推送机制 |
| | | if(null == notificationStationChange || 1 == notificationStationChange.getSuccStat()){ |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor.execute(new Runnable() { |
| | | //计数器 |
| | | Integer size = 0; |
| | | @Override |
| | | public void run() { |
| | | NotificationStationChangeResult notificationStationChange1 = TCECKDUtil.notificationStationChange(operator, 3, siteIds); |
| | | //启动重试推送机制 |
| | | if(null != notificationStationChange1 && 0 == notificationStationChange1.getSuccStat()){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | size++; |
| | | if(size >= 5){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | //间隔一分钟重试一次 |
| | | try { |
| | | Thread.sleep(60000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 请求开始充电 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_start_charge") |
| | | public BaseResult queryStartCharge(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台请求开始充电请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台请求开始充电响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求开始充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台请求开始充电请求Data:" + decrypt); |
| | | QueryStartCharge queryStartCharge = JSON.parseObject(decrypt, QueryStartCharge.class); |
| | | |
| | | //构建返回结果 |
| | | QueryStartChargeResult result = new QueryStartChargeResult(); |
| | | result.setStartChargeSeq(queryStartCharge.getStartChargeSeq()); |
| | | result.setConnectorID(queryStartCharge.getConnectorID()); |
| | | String connectorID = queryStartCharge.getConnectorID(); |
| | | TChargingGun tChargingGun = chargingGunClient.getChargingGunByFullNumber(connectorID).getData(); |
| | | //设备不存在 |
| | | if(null == tChargingGun){ |
| | | baseResult.setRet(4004); |
| | | baseResult.setMsg("connectorID 参数无效"); |
| | | result.setSuccStat(1); |
| | | result.setFailReason(1); |
| | | result.setStartChargeSeqStat(5); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(result); |
| | | log.info("三方平台请求开始充电响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求开始充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | //设备离线 |
| | | if(tChargingGun.getStatus() == 1){ |
| | | result.setSuccStat(1); |
| | | result.setFailReason(2); |
| | | result.setStartChargeSeqStat(5); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(result); |
| | | log.info("三方平台请求开始充电响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求开始充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | //调用充电接口 |
| | | AddTripartitePlatformOrder addTripartitePlatformOrder = new AddTripartitePlatformOrder(); |
| | | addTripartitePlatformOrder.setStartChargeSeq(queryStartCharge.getStartChargeSeq()); |
| | | addTripartitePlatformOrder.setChargingGunId(tChargingGun.getId()); |
| | | addTripartitePlatformOrder.setOperatorId(operator.getOperatorId()); |
| | | addTripartitePlatformOrder.setPaymentAmount(null == queryStartCharge.getChargingAmt() ? new BigDecimal(9999) : queryStartCharge.getChargingAmt()); |
| | | addTripartitePlatformOrder.setRechargePaymentType(0); |
| | | addTripartitePlatformOrder.setPlateNum(queryStartCharge.getPlateNum()); |
| | | R order = chargingOrderClient.addTripartitePlatformOrder(addTripartitePlatformOrder); |
| | | //启动失败 |
| | | if(200 != order.getCode()){ |
| | | result.setSuccStat(1); |
| | | result.setFailReason(1); |
| | | result.setStartChargeSeqStat(2); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(result); |
| | | log.info("三方平台请求开始充电响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求开始充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | result.setStartChargeSeqStat(1); |
| | | result.setSuccStat(0); |
| | | result.setFailReason(0); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(result); |
| | | log.info("三方平台请求开始充电响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求开始充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | |
| | | //定义定时任务推送订单状态 |
| | | ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | Runnable task = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | TChargingOrder chargingOrder = chargingOrderClient.getChargingOrderByStartChargeSeq(result.getStartChargeSeq()).getData(); |
| | | if(chargingOrder.getStatus() != 3){ |
| | | scheduler.shutdown(); |
| | | return; |
| | | } |
| | | log.info("开始执行三方平台定时推送"); |
| | | notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }; |
| | | //一分钟执行一次 |
| | | scheduler.scheduleAtFixedRate(task, 10, 10, TimeUnit.SECONDS); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 启动充电结果推送 |
| | | * @param result |
| | | * @return |
| | | */ |
| | | @PostMapping("/notificationStartChargeResult") |
| | | public R notificationStartChargeResult(@RequestBody StartChargeResult result){ |
| | | NotificationStartCharge notificationStartCharge = new NotificationStartCharge(); |
| | | BeanUtils.copyProperties(result, notificationStartCharge); |
| | | Operator operator = operatorClient.getOperator(result.getOperatorID()).getData(); |
| | | NotificationStartChargeResult notificationStartChargeResult = TCECUtil.notificationStartChargeResult(operator, notificationStartCharge); |
| | | //启动重试推送机制 |
| | | if(null == notificationStartChargeResult || 1 == notificationStartChargeResult.getSuccStat()){ |
| | | |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor.execute(new Runnable() { |
| | | //计数器 |
| | | Integer size = 0; |
| | | @Override |
| | | public void run() { |
| | | NotificationStartChargeResult notificationStartChargeResult1 = TCECUtil.notificationStartChargeResult(operator, notificationStartCharge); |
| | | //启动重试推送机制 |
| | | if(null != notificationStartChargeResult1 && 0 == notificationStartChargeResult1.getSuccStat()){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | size++; |
| | | if(size >= 5){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | //间隔一分钟重试一次 |
| | | try { |
| | | Thread.sleep(60000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询充电状态 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_equip_charge_status") |
| | | public BaseResult queryEquipChargeStatus(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台查询充电状态请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台查询充电状态响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询充电状态响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台查询充电状态请求Data:" + decrypt); |
| | | QueryEquipChargeStatus queryEquipChargeStatus = JSON.parseObject(decrypt, QueryEquipChargeStatus.class); |
| | | //校验token和签名 |
| | | QueryEquipChargeStatusResult queryEquipChargeStatusResult = buildQueryEquipChargeStatusResult(queryEquipChargeStatus.getStartChargeSeq()); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryEquipChargeStatusResult); |
| | | log.info("三方平台查询充电状态响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台查询充电状态响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建充电状态结果 |
| | | * @param startChargeSeq |
| | | * @return |
| | | */ |
| | | public QueryEquipChargeStatusResult buildQueryEquipChargeStatusResult(String startChargeSeq){ |
| | | //构建返回结果 |
| | | QueryEquipChargeStatusResult queryEquipChargeStatusResult = new QueryEquipChargeStatusResult(); |
| | | queryEquipChargeStatusResult.setStartChargeSeq(startChargeSeq); |
| | | TChargingOrder chargingOrder = chargingOrderClient.getChargingOrderByStartChargeSeq(startChargeSeq).getData(); |
| | | if(null == chargingOrder){ |
| | | return null; |
| | | } |
| | | //0=未知,1=等待中/已插枪,2=启动中,3=充电中,4=停止中,5=已结束 |
| | | switch (chargingOrder.getStatus()){ |
| | | case 0: |
| | | queryEquipChargeStatusResult.setStartChargeSeqStat(5); |
| | | break; |
| | | case 1: |
| | | queryEquipChargeStatusResult.setStartChargeSeqStat(0); |
| | | break; |
| | | case 2: |
| | | queryEquipChargeStatusResult.setStartChargeSeqStat(1); |
| | | break; |
| | | case 3: |
| | | queryEquipChargeStatusResult.setStartChargeSeqStat(2); |
| | | break; |
| | | case 4: |
| | | queryEquipChargeStatusResult.setStartChargeSeqStat(3); |
| | | break; |
| | | case 5: |
| | | queryEquipChargeStatusResult.setStartChargeSeqStat(4); |
| | | break; |
| | | } |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | queryEquipChargeStatusResult.setConnectorID(chargingGun.getFullNumber()); |
| | | //1=离线,2=空闲,3=占用(未充电),4=占用(充电中),5=占用(已充满),6=占用(预约锁定),7=故障 |
| | | switch (chargingGun.getStatus()){ |
| | | case 1: |
| | | queryEquipChargeStatusResult.setConnectorStatus(0); |
| | | break; |
| | | case 2: |
| | | queryEquipChargeStatusResult.setConnectorStatus(1); |
| | | break; |
| | | case 3: |
| | | queryEquipChargeStatusResult.setConnectorStatus(2); |
| | | break; |
| | | case 4: |
| | | queryEquipChargeStatusResult.setConnectorStatus(3); |
| | | break; |
| | | case 5: |
| | | queryEquipChargeStatusResult.setConnectorStatus(1); |
| | | break; |
| | | case 6: |
| | | queryEquipChargeStatusResult.setConnectorStatus(4); |
| | | break; |
| | | case 7: |
| | | queryEquipChargeStatusResult.setConnectorStatus(255); |
| | | break; |
| | | } |
| | | queryEquipChargeStatusResult.setCurrentA(chargingOrder.getCurrent()); |
| | | queryEquipChargeStatusResult.setVoltageA(chargingOrder.getVoltage()); |
| | | UploadRealTimeMonitoringData timeMonitoringData = uploadRealTimeMonitoringDataService.getLastDataById(chargingOrder.getCode()); |
| | | queryEquipChargeStatusResult.setSoc(null == timeMonitoringData ? BigDecimal.ZERO : new BigDecimal(timeMonitoringData.getSoc())); |
| | | queryEquipChargeStatusResult.setStartTime((null == chargingOrder.getStartTime() ? chargingOrder.getCreateTime() : chargingOrder.getStartTime()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | queryEquipChargeStatusResult.setEndTime((null == chargingOrder.getEndTime() ? LocalDateTime.now() : chargingOrder.getEndTime()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | queryEquipChargeStatusResult.setTotalPower(chargingOrder.getElectricity()); |
| | | |
| | | List<TChargingOrderAccountingStrategy> data = chargingOrderAccountingStrategyClient.getChargingOrderAccountingStrategyByOrderId(chargingOrder.getId()).getData(); |
| | | if(data.size() > 0){ |
| | | BigDecimal totalElectricity = data.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal serviceCharge = data.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | queryEquipChargeStatusResult.setElecMoney(totalElectricity); |
| | | queryEquipChargeStatusResult.setSeviceMoney(serviceCharge); |
| | | queryEquipChargeStatusResult.setTotalMoney(chargingOrder.getPaymentAmount()); |
| | | }else{ |
| | | queryEquipChargeStatusResult.setElecMoney(chargingOrder.getRechargeAmount().subtract(chargingOrder.getResidualAmount())); |
| | | queryEquipChargeStatusResult.setSeviceMoney(BigDecimal.ZERO); |
| | | queryEquipChargeStatusResult.setTotalMoney(chargingOrder.getRechargeAmount().subtract(chargingOrder.getResidualAmount())); |
| | | } |
| | | |
| | | //构建充电明细 |
| | | List<ChargeDetail> chargeDetails = new ArrayList<>(); |
| | | |
| | | LocalDateTime startTime = null == chargingOrder.getStartTime() ? LocalDateTime.now() : chargingOrder.getStartTime(); |
| | | LocalDateTime endTime = null == chargingOrder.getEndTime() ? LocalDateTime.now() : chargingOrder.getEndTime(); |
| | | String s_format = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | String e_format = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | for (TChargingOrderAccountingStrategy datum : data) { |
| | | ChargeDetail chargeDetail = new ChargeDetail(); |
| | | if(s_format.equals(e_format)){ |
| | | chargeDetail.setDetailStartTime(s_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(s_format + " " + datum.getEndTime() + ":59"); |
| | | }else{ |
| | | String substring = datum.getEndTime().substring(0, datum.getEndTime().indexOf(":")); |
| | | if(Integer.valueOf(substring) > 12){ |
| | | chargeDetail.setDetailStartTime(s_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(s_format + " " + datum.getEndTime() + ":59"); |
| | | }else{ |
| | | chargeDetail.setDetailStartTime(e_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(e_format + " " + datum.getEndTime() + ":59"); |
| | | } |
| | | } |
| | | chargeDetail.setElecPrice(datum.getElectrovalence()); |
| | | chargeDetail.setSevicePrice(datum.getServiceCharge()); |
| | | chargeDetail.setDetailPower(datum.getChargingCapacity()); |
| | | chargeDetail.setDetailElecMoney(datum.getPeriodElectricPrice()); |
| | | chargeDetail.setDetailSeviceMoney(datum.getPeriodServicePrice()); |
| | | chargeDetails.add(chargeDetail); |
| | | } |
| | | queryEquipChargeStatusResult.setChargeDetails(chargeDetails); |
| | | return queryEquipChargeStatusResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送充电状态 |
| | | * @param startChargeSeq |
| | | * @return |
| | | */ |
| | | @PostMapping("/notificationEquipChargeStatus") |
| | | public R notificationEquipChargeStatus(@RequestParam(value = "startChargeSeq") String startChargeSeq, @RequestParam(value = "operatorId") Integer operatorId){ |
| | | QueryEquipChargeStatusResult queryEquipChargeStatusResult = buildQueryEquipChargeStatusResult(startChargeSeq); |
| | | Operator operator = operatorClient.getOperatorById(operatorId).getData(); |
| | | NotificationEquipChargeStatusResult notificationEquipChargeStatusResult = TCECUtil.notificationEquipChargeStatus(operator, queryEquipChargeStatusResult); |
| | | //启动重试推送机制 |
| | | if(null == notificationEquipChargeStatusResult || 1 == notificationEquipChargeStatusResult.getSuccStat()){ |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor.execute(new Runnable() { |
| | | //计数器 |
| | | Integer size = 0; |
| | | @Override |
| | | public void run() { |
| | | NotificationEquipChargeStatusResult notificationEquipChargeStatusResult1 = TCECUtil.notificationEquipChargeStatus(operator, queryEquipChargeStatusResult); |
| | | //启动重试推送机制 |
| | | if(null != notificationEquipChargeStatusResult1 && 0 == notificationEquipChargeStatusResult1.getSuccStat()){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | size++; |
| | | if(size >= 5){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | //间隔一分钟重试一次 |
| | | try { |
| | | Thread.sleep(60000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 请求停止充电 |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_stop_charge") |
| | | public BaseResult queryStopCharge(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台请求停止充电请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台请求停止充电响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求停止充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台请求停止充电请求Data:" + decrypt); |
| | | QueryStopCharge queryStopCharge = JSON.parseObject(decrypt, QueryStopCharge.class); |
| | | QueryStopChargeResult queryStopChargeResult = new QueryStopChargeResult(); |
| | | queryStopChargeResult.setStartChargeSeq(queryStopCharge.getStartChargeSeq()); |
| | | queryStopChargeResult.setStartChargeSeqStat(3); |
| | | queryStopChargeResult.setSuccStat(0); |
| | | queryStopChargeResult.setFailReason(0); |
| | | //执行停机操作 |
| | | R r = chargingOrderClient.tripartitePlatformStopCharge(queryStopCharge.getStartChargeSeq()); |
| | | if(200 != r.getCode()){ |
| | | queryStopChargeResult.setStartChargeSeqStat(5); |
| | | queryStopChargeResult.setSuccStat(1); |
| | | queryStopChargeResult.setFailReason(3); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryStopChargeResult); |
| | | log.info("三方平台请求停止充电响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求停止充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryStopChargeResult); |
| | | log.info("三方平台请求停止充电响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台请求停止充电响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 推送停止充电结果 |
| | | * @param startChargeSeq 充电订单号 |
| | | * @param connectorID 充电设备接口编码 |
| | | * @return |
| | | */ |
| | | @PostMapping("/notificationStopChargeResult") |
| | | public R notificationStopChargeResult(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("connectorID") String connectorID, |
| | | @RequestParam("operatorId") Integer operatorId){ |
| | | Operator operator = operatorClient.getOperatorById(operatorId).getData(); |
| | | NotificationStopChargeResult info = new NotificationStopChargeResult(); |
| | | info.setStartChargeSeq(startChargeSeq); |
| | | info.setStartChargeSeqStat(4); |
| | | info.setConnectorID(connectorID); |
| | | info.setSuccStat(0); |
| | | info.setFailReason(0); |
| | | NotificationStopCharge notificationStopCharge = TCECUtil.notificationStopChargeResult(operator, info); |
| | | //启动重试推送机制 |
| | | if(null == notificationStopCharge || 1 == notificationStopCharge.getSuccStat()){ |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor.execute(new Runnable() { |
| | | //计数器 |
| | | Integer size = 0; |
| | | @Override |
| | | public void run() { |
| | | NotificationStopCharge notificationStopCharge1 = TCECUtil.notificationStopChargeResult(operator, info); |
| | | //启动重试推送机制 |
| | | if(null != notificationStopCharge1 && 0 == notificationStopCharge1.getSuccStat()){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | size++; |
| | | if(size >= 5){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | //间隔一分钟重试一次 |
| | | try { |
| | | Thread.sleep(60000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送订单信息 |
| | | * @param startChargeSeq |
| | | * @return |
| | | */ |
| | | @PostMapping("/notificationChargeOrderInfo") |
| | | public R notificationChargeOrderInfo(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("operatorId") Integer operatorId){ |
| | | NotificationChargeOrderInfo info = buildNotificationChargeOrderInfo(startChargeSeq); |
| | | Operator operator = operatorClient.getOperatorById(operatorId).getData(); |
| | | NotificationChargeOrderInfoResult notificationChargeOrderInfoResult = TCECUtil.notificationChargeOrderInfo(operator, info); |
| | | //启动重试推送机制 |
| | | if(null == notificationChargeOrderInfoResult || 1 == notificationChargeOrderInfoResult.getConfirmResult()){ |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | threadPoolExecutor.execute(new Runnable() { |
| | | //计数器 |
| | | Integer size = 0; |
| | | @Override |
| | | public void run() { |
| | | NotificationChargeOrderInfoResult notificationChargeOrderInfoResult1 = TCECUtil.notificationChargeOrderInfo(operator, info); |
| | | //启动重试推送机制 |
| | | if(null != notificationChargeOrderInfoResult1 && 0 == notificationChargeOrderInfoResult1.getConfirmResult()){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | size++; |
| | | if(size >= 5){ |
| | | threadPoolExecutor.shutdown(); |
| | | return; |
| | | } |
| | | //间隔一分钟重试一次 |
| | | try { |
| | | Thread.sleep(60000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 构建推送订单信息 |
| | | * @param startChargeSeq |
| | | * @return |
| | | */ |
| | | public NotificationChargeOrderInfo buildNotificationChargeOrderInfo(String startChargeSeq){ |
| | | //构建返回结果 |
| | | NotificationChargeOrderInfo notificationChargeOrderInfo = new NotificationChargeOrderInfo(); |
| | | notificationChargeOrderInfo.setStartChargeSeq(startChargeSeq); |
| | | TChargingOrder chargingOrder = chargingOrderClient.getChargingOrderByStartChargeSeq(startChargeSeq).getData(); |
| | | if(null == chargingOrder){ |
| | | return null; |
| | | } |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | notificationChargeOrderInfo.setConnectorID(chargingGun.getFullNumber()); |
| | | notificationChargeOrderInfo.setStartTime((null == chargingOrder.getStartTime() ? chargingOrder.getCreateTime() : chargingOrder.getStartTime()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | notificationChargeOrderInfo.setEndTime((null == chargingOrder.getEndTime() ? LocalDateTime.now() : chargingOrder.getEndTime()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | notificationChargeOrderInfo.setTotalPower(chargingOrder.getElectricity()); |
| | | |
| | | List<TChargingOrderAccountingStrategy> data = chargingOrderAccountingStrategyClient.getChargingOrderAccountingStrategyByOrderId(chargingOrder.getId()).getData(); |
| | | if(data.size() > 0){ |
| | | BigDecimal totalElectricity = data.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal serviceCharge = data.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | notificationChargeOrderInfo.setTotalElecMoney(totalElectricity.setScale(2, RoundingMode.HALF_EVEN)); |
| | | notificationChargeOrderInfo.setTotalSeviceMoney(serviceCharge.setScale(2, RoundingMode.HALF_EVEN)); |
| | | notificationChargeOrderInfo.setTotalMoney(chargingOrder.getPaymentAmount()); |
| | | }else{ |
| | | notificationChargeOrderInfo.setTotalElecMoney(chargingOrder.getRechargeAmount().subtract(chargingOrder.getResidualAmount())); |
| | | notificationChargeOrderInfo.setTotalSeviceMoney(BigDecimal.ZERO); |
| | | notificationChargeOrderInfo.setTotalMoney(chargingOrder.getRechargeAmount().subtract(chargingOrder.getResidualAmount())); |
| | | } |
| | | |
| | | |
| | | TParkingRecord parkingRecord = parkingRecordClient.getParkingRecordByChargingOrderId(chargingOrder.getId()).getData(); |
| | | if(null != parkingRecord && parkingRecord.getStatus() == 3){ |
| | | notificationChargeOrderInfo.setTotalDelayMoney(parkingRecord.getPayment()); |
| | | } |
| | | |
| | | //结束方式(0=异常终止,1=主动终止,2=满电终止,3=费用不足终止) |
| | | switch (chargingOrder.getEndMode()){ |
| | | case 0: |
| | | notificationChargeOrderInfo.setStopReason(3); |
| | | break; |
| | | case 1: |
| | | notificationChargeOrderInfo.setStopReason(0); |
| | | break; |
| | | case 2: |
| | | notificationChargeOrderInfo.setStopReason(2); |
| | | break; |
| | | case 3: |
| | | notificationChargeOrderInfo.setStopReason(5); |
| | | break; |
| | | } |
| | | |
| | | //构建充电明细 |
| | | List<ChargeDetail> chargeDetails = new ArrayList<>(); |
| | | |
| | | LocalDateTime startTime = null == chargingOrder.getStartTime() ? LocalDateTime.now() : chargingOrder.getStartTime(); |
| | | LocalDateTime endTime = null == chargingOrder.getEndTime() ? LocalDateTime.now() : chargingOrder.getEndTime(); |
| | | String s_format = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | String e_format = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | for (TChargingOrderAccountingStrategy datum : data) { |
| | | ChargeDetail chargeDetail = new ChargeDetail(); |
| | | if(s_format.equals(e_format)){ |
| | | chargeDetail.setDetailStartTime(s_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(s_format + " " + datum.getEndTime() + ":59"); |
| | | }else{ |
| | | String substring = datum.getEndTime().substring(0, datum.getEndTime().indexOf(":")); |
| | | if(Integer.valueOf(substring) > 12){ |
| | | chargeDetail.setDetailStartTime(s_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(s_format + " " + datum.getEndTime() + ":59"); |
| | | }else{ |
| | | chargeDetail.setDetailStartTime(e_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(e_format + " " + datum.getEndTime() + ":59"); |
| | | } |
| | | } |
| | | chargeDetail.setElecPrice(datum.getElectrovalence()); |
| | | chargeDetail.setSevicePrice(datum.getServiceCharge()); |
| | | chargeDetail.setDetailPower(datum.getChargingCapacity()); |
| | | chargeDetail.setDetailElecMoney(datum.getPeriodElectricPrice()); |
| | | chargeDetail.setDetailSeviceMoney(datum.getPeriodServicePrice()); |
| | | chargeDetails.add(chargeDetail); |
| | | } |
| | | notificationChargeOrderInfo.setChargeDetails(chargeDetails); |
| | | return notificationChargeOrderInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 二维码查询枪号(快电) |
| | | * @param baseRequest |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_terminal_code") |
| | | public BaseResult queryTerminalCode(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台二维码查询枪号请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台二维码查询枪号响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台二维码查询枪号响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台二维码查询枪号请求Data:" + decrypt); |
| | | QueryTerminalCode queryTerminalCode = JSON.parseObject(decrypt, QueryTerminalCode.class); |
| | | String qrCode = queryTerminalCode.getQRCode(); |
| | | String substring = qrCode.substring(qrCode.indexOf("=") + 1); |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunByFullNumber(substring).getData(); |
| | | QueryTerminalCodeResult queryTerminalCodeResult = new QueryTerminalCodeResult(); |
| | | if(null != chargingGun){ |
| | | queryTerminalCodeResult.setTerminalCode(chargingGun.getId().toString()); |
| | | } |
| | | |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryTerminalCodeResult); |
| | | log.info("三方平台二维码查询枪号响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台二维码查询枪号响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推送充电车牌号 |
| | | * 客户归属运营商向设备运营商推送充电用户车牌号减免停车费,多次推送以最后一次车牌号为准 |
| | | * @param baseRequest |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/notification_charge_carnum") |
| | | public BaseResult notificationChargeCarnum(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.buildSign(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getDataSecret(), operator.getDataSecretIv()); |
| | | NotificationChargeCarnum notificationChargeCarnum = JSON.parseObject(decrypt, NotificationChargeCarnum.class); |
| | | |
| | | NotificationChargeCarnumResult notificationChargeCarnumResult = new NotificationChargeCarnumResult(); |
| | | notificationChargeCarnumResult.setStartChargeSeqs(notificationChargeCarnum.getStartChargeSeqs()); |
| | | notificationChargeCarnumResult.setSuccStat(0); |
| | | notificationChargeCarnumResult.setFailReason(0); |
| | | TChargingOrder chargingOrder = chargingOrderClient.getChargingOrderByStartChargeSeq(notificationChargeCarnum.getStartChargeSeqs()).getData(); |
| | | if(null == chargingOrder){ |
| | | notificationChargeCarnumResult.setSuccStat(1); |
| | | notificationChargeCarnumResult.setFailReason(1); |
| | | }else{ |
| | | //待处理相关业务逻辑 |
| | | } |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(notificationChargeCarnumResult); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.buildSign(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 账单拉取(快电) |
| | | * @param baseRequest |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/query_charge_order_info") |
| | | public BaseResult queryChargeOrderInfo(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("三方平台账单拉取请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("三方平台账单拉取响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台账单拉取响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("三方平台账单拉取请求Data:" + decrypt); |
| | | QueryChargeOrderInfo queryChargeOrderInfo = JSON.parseObject(decrypt, QueryChargeOrderInfo.class); |
| | | //构建返回结果 |
| | | QueryChargeOrderInfoResult result = buildQueryChargeOrderInfoResult(queryChargeOrderInfo); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(result); |
| | | log.info("三方平台账单拉取响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("三方平台账单拉取响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 构建充电账单拉取实体 |
| | | * @param queryChargeOrderInfo |
| | | * @return |
| | | */ |
| | | public QueryChargeOrderInfoResult buildQueryChargeOrderInfoResult(QueryChargeOrderInfo queryChargeOrderInfo){ |
| | | //构建返回结果 |
| | | QueryChargeOrderInfoResult queryChargeOrderInfoResult = new QueryChargeOrderInfoResult(); |
| | | List<OrderInfo> orderInfos = new ArrayList<>(); |
| | | List<String> startChargeSeqs = queryChargeOrderInfo.getStartChargeSeqs(); |
| | | List<TChargingOrder> chargingOrders = chargingOrderClient.getChargingOrderByStartChargeSeqs(startChargeSeqs).getData(); |
| | | for (TChargingOrder chargingOrder : chargingOrders) { |
| | | if(null == chargingOrder){ |
| | | return null; |
| | | } |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | OrderInfo orderInfo = new OrderInfo(); |
| | | orderInfo.setStartChargeSeq(chargingOrder.getStartChargeSeq()); |
| | | orderInfo.setConnectorID(chargingGun.getFullNumber()); |
| | | orderInfo.setStartTime((null == chargingOrder.getStartTime() ? chargingOrder.getCreateTime() : chargingOrder.getStartTime()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | orderInfo.setEndTime((null == chargingOrder.getEndTime() ? LocalDateTime.now() : chargingOrder.getEndTime()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | orderInfo.setTotalPower(chargingOrder.getTotalElectricity()); |
| | | orderInfo.setTotalElecMoney(chargingOrder.getElectrovalence()); |
| | | orderInfo.setTotalSeviceMoney(chargingOrder.getServiceCharge()); |
| | | orderInfo.setTotalMoney(chargingOrder.getTotalElectricity().add(chargingOrder.getServiceCharge())); |
| | | //结束方式(0=异常终止,1=主动终止,2=满电终止,3=费用不足终止) |
| | | switch (chargingOrder.getEndMode()){ |
| | | case 0: |
| | | orderInfo.setStopReason(3); |
| | | break; |
| | | case 1: |
| | | orderInfo.setStopReason(0); |
| | | break; |
| | | case 2: |
| | | orderInfo.setStopReason(2); |
| | | break; |
| | | case 3: |
| | | orderInfo.setStopReason(4); |
| | | break; |
| | | } |
| | | //构建充电明细 |
| | | List<ChargeDetail> chargeDetails = new ArrayList<>(); |
| | | List<TChargingOrderAccountingStrategy> data = chargingOrderAccountingStrategyClient.getChargingOrderAccountingStrategyByOrderId(chargingOrder.getId()).getData(); |
| | | |
| | | LocalDateTime startTime = chargingOrder.getStartTime(); |
| | | LocalDateTime endTime = null == chargingOrder.getEndTime() ? LocalDateTime.now() : chargingOrder.getEndTime(); |
| | | String s_format = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | String e_format = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | for (TChargingOrderAccountingStrategy datum : data) { |
| | | ChargeDetail chargeDetail = new ChargeDetail(); |
| | | if(s_format.equals(e_format)){ |
| | | chargeDetail.setDetailStartTime(s_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(s_format + " " + datum.getEndTime() + ":59"); |
| | | }else{ |
| | | String substring = datum.getEndTime().substring(0, datum.getEndTime().indexOf(":")); |
| | | if(Integer.valueOf(substring) > 12){ |
| | | chargeDetail.setDetailStartTime(s_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(s_format + " " + datum.getEndTime() + ":59"); |
| | | }else{ |
| | | chargeDetail.setDetailStartTime(e_format + " " + datum.getStartTime() + ":00"); |
| | | chargeDetail.setDetailEndTime(e_format + " " + datum.getEndTime() + ":59"); |
| | | } |
| | | } |
| | | chargeDetail.setElecPrice(datum.getElectrovalence()); |
| | | chargeDetail.setSevicePrice(datum.getServiceCharge()); |
| | | chargeDetail.setDetailPower(datum.getChargingCapacity()); |
| | | chargeDetail.setDetailElecMoney(datum.getPeriodElectricPrice()); |
| | | chargeDetail.setDetailSeviceMoney(datum.getPeriodServicePrice()); |
| | | chargeDetails.add(chargeDetail); |
| | | } |
| | | orderInfo.setChargeDetails(chargeDetails); |
| | | orderInfos.add(orderInfo); |
| | | } |
| | | queryChargeOrderInfoResult.setOrderInfos(orderInfos); |
| | | return queryChargeOrderInfoResult; |
| | | } |
| | | |
| | | |
| | | |
| | | /*********************数据监管平台接口*********************/ |
| | | /** |
| | | * 查询运营商信息 |
| | | * @param baseRequest |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/supervise_query_operator_info") |
| | | public BaseResult superviseQueryOperatorInfo(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("监管平台查询充电站信息请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("监管平台查询充电站信息响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("监管平台查询充电站信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("监管平台查询充电站信息请求Data:" + decrypt); |
| | | SuperviseQueryOperatorInfo superviseQueryOperatorInfo = JSON.parseObject(decrypt, SuperviseQueryOperatorInfo.class); |
| | | Integer pageNo = superviseQueryOperatorInfo.getPageNo(); |
| | | Integer pageSize = superviseQueryOperatorInfo.getPageSize(); |
| | | if(null == pageNo){ |
| | | pageNo = 1; |
| | | } |
| | | if(null == pageSize){ |
| | | pageSize = 50; |
| | | } |
| | | String operatorTel = systemConfigurationClient.getServerPhone().getData(); |
| | | SuperviseQueryOperatorInfoResultPage superviseQueryOperatorInfoResultPage = new SuperviseQueryOperatorInfoResultPage(); |
| | | superviseQueryOperatorInfoResultPage.setPageNo(1); |
| | | superviseQueryOperatorInfoResultPage.setPageCount(1); |
| | | superviseQueryOperatorInfoResultPage.setItemSize(1); |
| | | |
| | | SuperviseQueryOperatorInfoResult superviseQueryOperatorInfoResult = new SuperviseQueryOperatorInfoResult(); |
| | | superviseQueryOperatorInfoResult.setOperatorID("906171535"); |
| | | superviseQueryOperatorInfoResult.setOperatorUSCID("91510903906171535D"); |
| | | superviseQueryOperatorInfoResult.setOperatorName("四川明星新能源科技有限公司"); |
| | | superviseQueryOperatorInfoResult.setOperatorTel1(operatorTel); |
| | | List<SuperviseQueryOperatorInfoResult> superviseQueryOperatorInfoResults = new ArrayList<>(); |
| | | superviseQueryOperatorInfoResults.add(superviseQueryOperatorInfoResult); |
| | | // 将superviseQueryOperatorInfoResults转化为json数组 |
| | | superviseQueryOperatorInfoResultPage.setOperatorInfos(superviseQueryOperatorInfoResults); |
| | | String jsonString = JacksonUtils.toJson(superviseQueryOperatorInfoResultPage); |
| | | //参数加密 |
| | | log.info("监管平台查询充电站信息响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("监管平台查询充电站信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询充电站信息 |
| | | * @param baseRequest |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @PostMapping("/supervise_query_stations_info") |
| | | public BaseResult superviseQueryStationsInfo(@RequestBody BaseRequest baseRequest, HttpServletRequest request){ |
| | | log.info("监管平台查询充电站信息请求参数:" + JacksonUtils.toJson(baseRequest)); |
| | | //校验token和签名 |
| | | BaseResult baseResult = requestCheck(true, baseRequest, request); |
| | | if(0 != baseResult.getRet()){ |
| | | log.info("监管平台查询充电站信息响应Data:"); |
| | | baseResult.setData(""); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("监管平台查询充电站信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | Operator operator = baseResult.getOperator(); |
| | | //解密参数 |
| | | String decrypt = AESUtil.decrypt(baseRequest.getData(), operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | log.info("监管平台查询充电站信息请求Data:" + decrypt); |
| | | QueryStationsInfo queryStationsInfo = JSON.parseObject(decrypt, QueryStationsInfo.class); |
| | | Integer pageNo = queryStationsInfo.getPageNo(); |
| | | Integer pageSize = queryStationsInfo.getPageSize(); |
| | | List<String> stationIDs = queryStationsInfo.getStationIDs(); |
| | | if(null == pageNo){ |
| | | pageNo = 1; |
| | | } |
| | | if(null == pageSize){ |
| | | pageSize = 50; |
| | | } |
| | | PageInfo<Site> siteListPaging = siteClient.getSiteListPaging(pageNo, pageSize, stationIDs); |
| | | List<TParkingLot> parkingLots = parkingLotClient.getAllParkingLot().getData(); |
| | | QueryStationsInfoResult queryStationsInfoResult = new QueryStationsInfoResult(); |
| | | queryStationsInfoResult.setPageNo(pageNo); |
| | | queryStationsInfoResult.setPageCount((0 == (siteListPaging.getTotal() % pageSize) ? 0 : 1) + Double.valueOf(siteListPaging.getTotal() / pageSize).intValue()); |
| | | queryStationsInfoResult.setItemSize(Long.valueOf(siteListPaging.getTotal()).intValue()); |
| | | queryStationsInfoResult.setStationInfos(buildSite(parkingLots, siteListPaging.getRecords())); |
| | | //参数加密 |
| | | String jsonString = JacksonUtils.toJson(queryStationsInfoResult); |
| | | log.info("监管平台查询充电站信息响应Data:" + jsonString); |
| | | String encrypt = AESUtil.encrypt(jsonString, operator.getOurDataSecret(), operator.getOurDataSecretIv()); |
| | | baseResult.setData(encrypt); |
| | | baseResult.setSig(TCECUtil.ourBuildSign(baseResult)); |
| | | log.info("监管平台查询充电站信息响应参数:" + JacksonUtils.toJson(baseResult)); |
| | | return baseResult; |
| | | } |
| | | /** |
| | | * 推送充电用能统计 |
| | | * @return |
| | | */ |
| | | @PostMapping("/supervise_notification_operation_stats_info") |
| | | public void superviseNotificationOperationStatsInfo(){ |
| | | List<Site> data = siteClient.getSiteAll().getData(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalDateTime startLocalDateTime = now.minusDays(1); |
| | | LocalDateTime endLocalDateTime = now.minusDays(1); |
| | | // 获取今天凌晨 |
| | | startLocalDateTime.withHour(0); |
| | | startLocalDateTime.withMinute(0); |
| | | startLocalDateTime.withSecond(0); |
| | | String start = DateUtils.localDateTimeToString(startLocalDateTime); |
| | | endLocalDateTime.withHour(23); |
| | | endLocalDateTime.withMinute(59); |
| | | endLocalDateTime.withSecond(59); |
| | | String end = DateUtils.localDateTimeToString(endLocalDateTime); |
| | | ChargingStatisticeDTO chargingStatisticeDTO = new ChargingStatisticeDTO(); |
| | | chargingStatisticeDTO.setStartTime(startLocalDateTime); |
| | | chargingStatisticeDTO.setEndTime(endLocalDateTime); |
| | | List<TChargingOrder> data1 = chargingOrderClient.getChargingStatistics(chargingStatisticeDTO).getData(); |
| | | List<StationStatsInfo> stationStatsInfos = new ArrayList<>(); |
| | | for (Site datum : data) { |
| | | StationStatsInfo stationStatsInfo = new StationStatsInfo(); |
| | | stationStatsInfo.setStationID(datum.getId().toString()); |
| | | stationStatsInfo.setEquipmentOwnerID("906171535"); |
| | | stationStatsInfo.setOperatorID("906171535"); |
| | | stationStatsInfo.setStationClassification(1); |
| | | stationStatsInfo.setStartTime(start); |
| | | stationStatsInfo.setEndTime(end); |
| | | List<TChargingOrder> chargingOrders = data1.stream().filter(e -> e.getSiteId().equals(datum.getId())).collect(Collectors.toList()); |
| | | // 充电电量 |
| | | BigDecimal electricity = new BigDecimal("0"); |
| | | int chargingCount = 0; |
| | | for (TChargingOrder chargingOrder : chargingOrders) { |
| | | if (chargingOrder.getElectricity()!=null){ |
| | | electricity = electricity.add(chargingOrder.getElectricity()); |
| | | chargingCount++; |
| | | } |
| | | } |
| | | stationStatsInfo.setStationElectricity(electricity.divide(new BigDecimal("24")).setScale(4, BigDecimal.ROUND_DOWN)); |
| | | stationStatsInfo.setStationTotalChargeEnergy(electricity.setScale(4, BigDecimal.ROUND_DOWN)); |
| | | stationStatsInfo.setStationTotalWarningNum(0); |
| | | stationStatsInfo.setStationTotalOtherEnergy(new BigDecimal("0")); |
| | | stationStatsInfo.setStationTotalChargeNum(chargingCount); |
| | | //构建设备统计数据 |
| | | List<EquipmentStatsInfo> EquipmentStatsInfos = new ArrayList<>(); |
| | | Map<Integer, List<TChargingOrder>> collect = chargingOrders.stream().collect(Collectors.groupingBy(TChargingOrder::getChargingPileId)); |
| | | for (Integer integer : collect.keySet()) { |
| | | List<TChargingOrder> tChargingOrders = collect.get(integer); |
| | | BigDecimal reduce1 = tChargingOrders.stream().map(TChargingOrder::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | EquipmentStatsInfo equipmentStatsInfo = new EquipmentStatsInfo(); |
| | | equipmentStatsInfo.setEquipmentClassification(1); |
| | | long chargingTime = 0L; |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | // 累加充电时长 |
| | | LocalDateTime startTime = tChargingOrder.getStartTime(); |
| | | LocalDateTime endTime = tChargingOrder.getEndTime(); |
| | | // 计算时间差 单位分钟 |
| | | chargingTime += ChronoUnit.SECONDS.between(startTime, endTime)/60; |
| | | } |
| | | equipmentStatsInfo.setEquipmentTotalChargeTime(chargingTime); |
| | | equipmentStatsInfo.setEquipmentTotalChargeNum(tChargingOrders.size()); |
| | | equipmentStatsInfo.setEquipmentTotalWarningNum(0); |
| | | equipmentStatsInfo.setEquipmentID(integer.toString()); |
| | | equipmentStatsInfo.setEquipmentElectricity(reduce1); |
| | | //构建设备接口统计数据 |
| | | Map<Integer, List<TChargingOrder>> collect2 = tChargingOrders.stream().collect(Collectors.groupingBy(TChargingOrder::getChargingGunId)); |
| | | List<ConnectorStatsInfo> ConnectorStatsInfos = new ArrayList<>(); |
| | | for (Integer integer1 : collect2.keySet()) { |
| | | List<TChargingOrder> tChargingOrders1 = collect2.get(integer1); |
| | | BigDecimal reduce2 = tChargingOrders1.stream().map(TChargingOrder::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(integer1).getData(); |
| | | ConnectorStatsInfo connectorStatsInfo = new ConnectorStatsInfo(); |
| | | connectorStatsInfo.setConnectorID(chargingGun.getFullNumber()); |
| | | connectorStatsInfo.setConnectorElectricity(reduce2); |
| | | ConnectorStatsInfos.add(connectorStatsInfo); |
| | | } |
| | | equipmentStatsInfo.setConnectorStatsInfos(ConnectorStatsInfos); |
| | | EquipmentStatsInfos.add(equipmentStatsInfo); |
| | | } |
| | | stationStatsInfo.setEquipmentStatsInfos(EquipmentStatsInfos); |
| | | stationStatsInfos.add(stationStatsInfo); |
| | | } |
| | | } |
| | | /** |
| | | * 推送充换电站实时功率 |
| | | * @return |
| | | */ |
| | | @PostMapping("/supervise_notification_realtime_power_info") |
| | | public void superviseNotificationRealtimePowerInfo(){ |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 推送充换电站信息 |
| | | * @param datum |
| | | * @return |
| | | */ |
| | | @PostMapping("/supervise_notification_station_info") |
| | | public void superviseNotificationStationInfo(@RequestBody Site datum){ |
| | | BaseResult baseResult = new BaseResult(); |
| | | StationInfo stationInfo = new StationInfo(); |
| | | List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(Collections.singletonList(datum.getId())).getData(); |
| | | List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList()); |
| | | List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(collect1).getData(); |
| | | String serviceTel = systemConfigurationClient.getServerPhone().getData(); |
| | | stationInfo.setAreaCodeCountryside(datum.getAreaCodeCountryside()); |
| | | stationInfo.setStationClassification(datum.getStationClassification()); |
| | | stationInfo.setGeneralApplicationType(datum.getGeneralApplicationType()); |
| | | if (org.springframework.util.StringUtils.hasLength(datum.getSwapMatchCars())){ |
| | | stationInfo.setSwapMatchCars(Arrays.asList(datum.getSwapMatchCars().split(","))); |
| | | } |
| | | stationInfo.setBusineHours(datum.getStartServiceTime()); |
| | | stationInfo.setRoundTheClock(datum.getRoundTheClock()); |
| | | stationInfo.setParkType(datum.getParkType()); |
| | | stationInfo.setElectricityFee("{"+datum.getElectricityFee()+"}"); |
| | | stationInfo.setServiceFee("{"+datum.getServiceFee()+"}"); |
| | | stationInfo.setParkFee("{\"rules\":"+datum.getParkFee()+","+"\"freeDuration\":"+datum.getParkFeeFree()+"}"); |
| | | stationInfo.setElectricityType(datum.getElectricityType()); |
| | | stationInfo.setBusinessExpandType(datum.getBusinessExpandType()); |
| | | stationInfo.setCapacity(datum.getCapacity()); |
| | | stationInfo.setRatedPower(datum.getRatedPower()); |
| | | stationInfo.setPeriodFee(datum.getPeriodFee()); |
| | | stationInfo.setOfficialRunTime(datum.getOfficialRunTime()); |
| | | stationInfo.setStationOrientation(datum.getStationOrientation()); |
| | | stationInfo.setStationArea(datum.getStationArea()); |
| | | stationInfo.setHavePerson(datum.getHavePerson()); |
| | | stationInfo.setVideoMonitor(datum.getVideoMonitor()); |
| | | if (StringUtils.isNotEmpty(datum.getSupportingFacilities())){ |
| | | String[] split = datum.getSupportingFacilities().split(","); |
| | | List<Integer> collect = Arrays.stream(split).map(Integer::parseInt).collect(Collectors.toList()); |
| | | stationInfo.setSupportingFacilities(collect); |
| | | } |
| | | stationInfo.setPrinterFlag(datum.getPrinterFlag()); |
| | | stationInfo.setBarrierFlag(datum.getBarrierFlag()); |
| | | stationInfo.setParkingLockFlag(datum.getParkingLockFlag()); |
| | | stationInfo.setEquipmentOwnerName(datum.getEquipmentOwnerName()); |
| | | stationInfo.setResidentNo(datum.getResidentNo()); |
| | | stationInfo.setSupplyType(datum.getSupplyType()); |
| | | stationInfo.setWattHourMeterNo(datum.getWattHourMeterNo()); |
| | | BigDecimal forwardPower = datum.getForwardPower(); |
| | | if (forwardPower!=null){ |
| | | stationInfo.setForwardPower(forwardPower.setScale(4, BigDecimal.ROUND_HALF_UP).toString()); |
| | | } |
| | | stationInfo.setRecordUniqueNo(datum.getRecordUniqueNo()); |
| | | stationInfo.setStationID(datum.getId().toString()); |
| | | stationInfo.setOperatorID("906171535"); |
| | | stationInfo.setEquipmentOwnerID("906171535"); |
| | | stationInfo.setStationName(datum.getName()); |
| | | stationInfo.setCountryCode(StringUtils.isNotEmpty(datum.getCountryCode()) ? datum.getCountryCode() : "CN"); |
| | | stationInfo.setAreaCode(datum.getDistrictsCode()); |
| | | stationInfo.setAddress(datum.getAddress()); |
| | | stationInfo.setStationTel(datum.getPhone()); |
| | | stationInfo.setServiceTel(serviceTel); |
| | | switch (datum.getSiteType()){ |
| | | case 0: |
| | | stationInfo.setStationType(StationTypeEnum.OTHER.getType()); |
| | | break; |
| | | case 1: |
| | | stationInfo.setStationType(StationTypeEnum.PUBLIC.getType()); |
| | | break; |
| | | case 2: |
| | | stationInfo.setStationType(StationTypeEnum.PERSONAGE.getType()); |
| | | break; |
| | | case 3: |
| | | stationInfo.setStationType(StationTypeEnum.BUS_SPECIFIC.getType()); |
| | | break; |
| | | case 4: |
| | | stationInfo.setStationType(StationTypeEnum.SANITATION_SPECIFIC.getType()); |
| | | break; |
| | | case 5: |
| | | stationInfo.setStationType(StationTypeEnum.LOGISTICS_SPECIFIC.getType()); |
| | | break; |
| | | case 6: |
| | | stationInfo.setStationType(StationTypeEnum.TEXT_SPECIFIC.getType()); |
| | | break; |
| | | } |
| | | if(datum.getStatus() == 1){ |
| | | stationInfo.setStationStatus(StationStatusEnum.NORMAL_USE.getStatus()); |
| | | } |
| | | if(datum.getStatus() == 2){ |
| | | stationInfo.setStationStatus(StationStatusEnum.MAINTAIN.getStatus()); |
| | | } |
| | | if(datum.getStatus() == 3){ |
| | | stationInfo.setStationStatus(StationStatusEnum.OFF_LINE.getStatus()); |
| | | } |
| | | stationInfo.setParkNums(datum.getParkingSpace()); |
| | | stationInfo.setStationLat(new BigDecimal(datum.getLat()).setScale(6, RoundingMode.DOWN)); |
| | | stationInfo.setStationLng(new BigDecimal(datum.getLon()).setScale(6, RoundingMode.DOWN)); |
| | | stationInfo.setConstruction(datum.getConstructionSite() == 0 ? ConstructionEnum.OTHER.getType() : datum.getConstructionSite()); |
| | | stationInfo.setPictures(StringUtils.isNotEmpty(datum.getImgUrl()) ? Arrays.asList(datum.getImgUrl().split(",")) : new ArrayList<>()); |
| | | stationInfo.setSiteGuide(datum.getGuide()); |
| | | stationInfo.setMatchCars(datum.getVehicleDescription()); |
| | | stationInfo.setElectricityFee(datum.getRateDescription()); |
| | | //构建充电设备信息数据 |
| | | stationInfo.setEquipmentInfos(buildEquipmentInfo(datum.getId(), tChargingPiles, chargingGunList)); |
| | | // 推送 |
| | | HttpRequest post = HttpUtil.createPost(url + "supervise_notification_station_info"); |
| | | buildBody(post, stationInfo); |
| | | HttpResponse execute = post.execute(); |
| | | if(200 != execute.getStatus()){ |
| | | log.error("推送监管平台电站信息失败:" + execute.body()); |
| | | return ; |
| | | } |
| | | log.info("推送监管平台电站信息响应:" + execute.body()); |
| | | String data = baseResult.getData(); |
| | | // 转化为json |
| | | if(!data.contains("0")){ |
| | | log.error("推送监管平台电站信息失败:" + baseResult.getMsg()); |
| | | // 重试 |
| | | for (int i = 1; i <= 3; i++) { |
| | | try { |
| | | Thread.sleep(5000); |
| | | HttpRequest post1 = HttpUtil.createPost(url + "supervise_notification_station_info"); |
| | | buildBody(post1, stationInfo); |
| | | HttpResponse execute1 = post1.execute(); |
| | | if(200 == execute1.getStatus()){ |
| | | log.info("重试次数:"+i+"推送监管平台电站信息响应:" + execute1.body()); |
| | | BaseResult baseResult2 = JSON.parseObject(execute1.body(), BaseResult.class); |
| | | String data1 = baseResult2.getData(); |
| | | if (data1.contains("0")){ |
| | | break; |
| | | } |
| | | } |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 构建请求参数和消息头 |
| | | * @param post |
| | | * @param o |
| | | */ |
| | | public static void buildBody(HttpRequest post, Object o){ |
| | | Long timeStamp = Long.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
| | | post.contentType("application/json;charset=utf-8"); |
| | | // post.header("Authorization", "Bearer " + getToken(operator)); |
| | | BaseRequest baseRequest = new BaseRequest(); |
| | | baseRequest.setOperatorID("906171535"); |
| | | baseRequest.setTimeStamp(timeStamp); |
| | | baseRequest.setSeq("0001"); |
| | | String jsonString = JacksonUtils.toJson(o); |
| | | String encrypt = AESUtil.encrypt(jsonString, ourDataSecret, ourDataSecretIv); |
| | | baseRequest.setData(encrypt); |
| | | baseRequest.setSig(TCECUtil.ourBuildSign(baseRequest)); |
| | | log.info("监管平台推送参数:" + JacksonUtils.toJson(baseRequest)); |
| | | String request_json = JacksonUtils.toJson(baseRequest); |
| | | post.body(request_json); |
| | | |
| | | } |
| | | |
| | | // |
| | | // |
| | | // /** |
| | | // * 构建站点数据 |
| | | // * @param sites |
| | | // * @return |
| | | // */ |
| | | // public List<StationInfo> superviseBuildSite(List<TParkingLot> parkingLots, List<Site> sites){ |
| | | // List<Integer> siteIds = sites.stream().map(Site::getId).collect(Collectors.toList()); |
| | | // List<TChargingPile> tChargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData(); |
| | | // List<Integer> collect1 = tChargingPiles.stream().map(TChargingPile::getId).collect(Collectors.toList()); |
| | | // List<TChargingGun> chargingGunList = chargingGunClient.getChargingGunByChargingPileIds(collect1).getData(); |
| | | // String serviceTel = systemConfigurationClient.getServerPhone().getData(); |
| | | // List<StationInfo> StationInfos = new ArrayList<>(); |
| | | // for (Site datum : sites) { |
| | | // StationInfo stationInfo = new StationInfo(); |
| | | // stationInfo.setStationID(datum.getId().toString()); |
| | | // stationInfo.setStationUniqueNumber(datum.getDistrictsCode() + "906171535" + datum.getId()); |
| | | // stationInfo.setOperatorID("906171535"); |
| | | // stationInfo.setEquipmentOwnerID("906171535"); |
| | | // stationInfo.setStationName(datum.getName()); |
| | | // stationInfo.setCountryCode(StringUtils.isNotEmpty(datum.getCountryCode()) ? datum.getCountryCode() : "CN"); |
| | | // stationInfo.setAreaCode(datum.getDistrictsCode()); |
| | | // stationInfo.setAreaCodeCountryside(); |
| | | // stationInfo.setAddress(datum.getAddress()); |
| | | // stationInfo.setStationTel(datum.getPhone()); |
| | | // stationInfo.setServiceTel(serviceTel); |
| | | // switch (datum.getSiteType()){ |
| | | // case 0: |
| | | // stationInfo.setStationType(StationTypeEnum.OTHER.getType()); |
| | | // break; |
| | | // case 1: |
| | | // stationInfo.setStationType(StationTypeEnum.PUBLIC.getType()); |
| | | // break; |
| | | // case 2: |
| | | // stationInfo.setStationType(StationTypeEnum.PERSONAGE.getType()); |
| | | // break; |
| | | // case 3: |
| | | // stationInfo.setStationType(StationTypeEnum.BUS_SPECIFIC.getType()); |
| | | // break; |
| | | // case 4: |
| | | // stationInfo.setStationType(StationTypeEnum.SANITATION_SPECIFIC.getType()); |
| | | // break; |
| | | // case 5: |
| | | // stationInfo.setStationType(StationTypeEnum.LOGISTICS_SPECIFIC.getType()); |
| | | // break; |
| | | // case 6: |
| | | // stationInfo.setStationType(StationTypeEnum.TEXT_SPECIFIC.getType()); |
| | | // break; |
| | | // } |
| | | // if(datum.getStatus() == 1){ |
| | | // stationInfo.setStationStatus(StationStatusEnum.NORMAL_USE.getStatus()); |
| | | // } |
| | | // if(datum.getStatus() == 2){ |
| | | // stationInfo.setStationStatus(StationStatusEnum.MAINTAIN.getStatus()); |
| | | // } |
| | | // if(datum.getStatus() == 3){ |
| | | // stationInfo.setStationStatus(StationStatusEnum.OFF_LINE.getStatus()); |
| | | // } |
| | | // stationInfo.setParkNums(datum.getParkingSpace()); |
| | | // stationInfo.setStationLat(new BigDecimal(datum.getLat()).setScale(6, RoundingMode.DOWN)); |
| | | // stationInfo.setStationLng(new BigDecimal(datum.getLon()).setScale(6, RoundingMode.DOWN)); |
| | | // stationInfo.setConstruction(datum.getConstructionSite() == 0 ? ConstructionEnum.OTHER.getType() : datum.getConstructionSite()); |
| | | // stationInfo.setPictures(StringUtils.isNotEmpty(datum.getImgUrl()) ? Arrays.asList(datum.getImgUrl().split(",")) : new ArrayList<>()); |
| | | // stationInfo.setSiteGuide(datum.getGuide()); |
| | | // stationInfo.setMatchCars(datum.getVehicleDescription()); |
| | | // stationInfo.setBusineHours(datum.getStartServiceTime() + "-" + datum.getEndServiceTime()); |
| | | // stationInfo.setElectricityFee(datum.getRateDescription()); |
| | | // //添加停车费信息 |
| | | // Optional<TParkingLot> first = parkingLots.stream().filter(s -> s.getSiteId().equals(datum.getId())).findFirst(); |
| | | // if(first.isPresent()){ |
| | | // TParkingLot tParkingLot = first.get(); |
| | | // superviseBuildPlaceHolder(tParkingLot, stationInfo); |
| | | // } |
| | | // |
| | | // //构建充电设备信息数据 |
| | | // stationInfo.setEquipmentInfos(superviseBuildEquipmentInfo(datum.getId(), tChargingPiles, chargingGunList)); |
| | | // StationInfos.add(stationInfo); |
| | | // |
| | | // } |
| | | // return StationInfos; |
| | | // } |
| | | // |
| | | // |
| | | // /** |
| | | // * 构建停车费信息 |
| | | // * @param tParkingLot |
| | | // * @param stationInfo |
| | | // */ |
| | | // public void superviseBuildPlaceHolder(TParkingLot tParkingLot, StationInfo stationInfo){ |
| | | // stationInfo.setOvertimeFee(tParkingLot.getName() + "停车费"); |
| | | // PlaceHolder placeHolder = new PlaceHolder(); |
| | | // placeHolder.setFreeTime(tParkingLot.getChargeFreeDuration()); |
| | | // placeHolder.setMaxFee(tParkingLot.getChargeCapping()); |
| | | // List<PlaceHolderPrice> PlaceHolderPrices = new ArrayList<>(); |
| | | // PlaceHolderPrice placeHolderPrice = new PlaceHolderPrice(); |
| | | // placeHolderPrice.setStartTime("00:00"); |
| | | // placeHolderPrice.setEndTime("23:59"); |
| | | // placeHolderPrice.setPrice(tParkingLot.getChargeRate()); |
| | | // PlaceHolderPrices.add(placeHolderPrice); |
| | | // placeHolder.setPlaceHolderPrices(PlaceHolderPrices); |
| | | // stationInfo.setPlaceHolder(placeHolder); |
| | | // } |
| | | // |
| | | // |
| | | // |
| | | // |
| | | // /** |
| | | // * 构建桩数据 |
| | | // * @param tChargingPiles |
| | | // * @return |
| | | // */ |
| | | // public List<EquipmentInfo> superviseBuildEquipmentInfo(Integer siteId, List<TChargingPile> tChargingPiles, List<TChargingGun> chargingGunList){ |
| | | // List<EquipmentInfo> equipmentInfos = new ArrayList<>(); |
| | | // List<TChargingPile> collect = tChargingPiles.stream().filter(s -> s.getSiteId().equals(siteId)).collect(Collectors.toList()); |
| | | // for (TChargingPile tChargingPile : collect) { |
| | | // EquipmentInfo equipmentInfo = new EquipmentInfo(); |
| | | // equipmentInfo.setEquipmentID(tChargingPile.getId().toString()); |
| | | // equipmentInfo.setManufacturerID(tChargingPile.getManufacturerCode()); |
| | | // equipmentInfo.setManufacturerName(tChargingPile.getManufacturer()); |
| | | // equipmentInfo.setEquipmentModel(tChargingPile.getEquipmentType()); |
| | | // if(null != tChargingPile.getProductionDate()){ |
| | | // equipmentInfo.setProductionDate(tChargingPile.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | // } |
| | | // switch (tChargingPile.getType()){ |
| | | // case 0: |
| | | // equipmentInfo.setEquipmentType(EquipmentTypeEnum.OTHER.getType()); |
| | | // break; |
| | | // case 1: |
| | | // equipmentInfo.setEquipmentType(EquipmentTypeEnum.DIRECT_CURRENT.getType()); |
| | | // break; |
| | | // case 2: |
| | | // equipmentInfo.setEquipmentType(EquipmentTypeEnum.ALTERNATING_CURRENT.getType()); |
| | | // break; |
| | | // case 3: |
| | | // equipmentInfo.setEquipmentType(EquipmentTypeEnum.ALTERNATING_DIRECT.getType()); |
| | | // break; |
| | | // case 4: |
| | | // equipmentInfo.setEquipmentType(EquipmentTypeEnum.WIRELESS_DEVICE.getType()); |
| | | // break; |
| | | // } |
| | | // |
| | | // //构建设备接口信息 |
| | | // equipmentInfo.setConnectorInfos(superviseBuildConnectorInfos(tChargingPile.getId(), tChargingPile.getCode(), chargingGunList)); |
| | | // equipmentInfo.setPower(tChargingPile.getRatedPower()); |
| | | // equipmentInfos.add(equipmentInfo); |
| | | // } |
| | | // return equipmentInfos; |
| | | // } |
| | | // |
| | | // |
| | | // /** |
| | | // * 构建接口数据 |
| | | // * @param chargingGunList |
| | | // * @return |
| | | // */ |
| | | // public List<ConnectorInfo> superviseBuildConnectorInfos(Integer chargingPileId, String code, List<TChargingGun> chargingGunList){ |
| | | // List<ConnectorInfo> connectorInfos = new ArrayList<>(); |
| | | // List<TChargingGun> collect = chargingGunList.stream().filter(s -> s.getChargingPileId().equals(chargingPileId)).collect(Collectors.toList()); |
| | | // for (TChargingGun chargingGun : collect) { |
| | | // ConnectorInfo connectorInfo = new ConnectorInfo(); |
| | | // connectorInfo.setConnectorID(chargingGun.getFullNumber()); |
| | | // connectorInfo.setConnectorName(chargingGun.getName()); |
| | | // switch (chargingGun.getType()){ |
| | | // case 0: |
| | | // connectorInfo.setConnectorType(ConnectorTypeEnum.OTHER.getType()); |
| | | // break; |
| | | // case 1: |
| | | // connectorInfo.setConnectorType(ConnectorTypeEnum.HOUSEHOLD_SOCKET.getType()); |
| | | // break; |
| | | // case 2: |
| | | // connectorInfo.setConnectorType(ConnectorTypeEnum.AC_SOCKET.getType()); |
| | | // break; |
| | | // case 3: |
| | | // connectorInfo.setConnectorType(ConnectorTypeEnum.AC_INTERFACE_PLUG.getType()); |
| | | // break; |
| | | // case 4: |
| | | // connectorInfo.setConnectorType(ConnectorTypeEnum.DC_INTERFACE_GUN_HEAD.getType()); |
| | | // break; |
| | | // case 5: |
| | | // connectorInfo.setConnectorType(ConnectorTypeEnum.WIRELESS_CHARGING_STAND.getType()); |
| | | // break; |
| | | // } |
| | | // connectorInfo.setVoltageUpperLimits(chargingGun.getUpperRatedVoltage().intValue()); |
| | | // connectorInfo.setVoltageLowerLimits(chargingGun.getLowerLimitOfRatedVoltage().intValue()); |
| | | // connectorInfo.setCurrent(chargingGun.getRatedCurrent().intValue()); |
| | | // connectorInfo.setPower(chargingGun.getRatedPower()); |
| | | // connectorInfo.setParkNo(chargingGun.getParkingNumber()); |
| | | // connectorInfo.setNationalStandard(Integer.valueOf(chargingGun.getNationalStandard())); |
| | | // connectorInfo.setQRCode("https://mxcd.zhinenganguan.com?No=" + code + chargingGun.getCode()); |
| | | // connectorInfos.add(connectorInfo); |
| | | // } |
| | | // return connectorInfos; |
| | | // } |
| | | |
| | | } |