From 7767d8cdf1b7cac9b678ef4fb77f19363123df04 Mon Sep 17 00:00:00 2001 From: "MMP\\29473" Date: Tue, 19 Nov 2024 09:51:39 +0800 Subject: [PATCH 01/12] update --- .../impl/GuiZhouPlatformServiceImpl.java | 919 ++++++++++++++++++ 1 file changed, 919 insertions(+) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java new file mode 100644 index 000000000..749f51b8f --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -0,0 +1,919 @@ +package com.jsowell.thirdparty.platform.service.impl; + +import cn.hutool.core.util.PageUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.enums.lianlian.StationPaymentEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; +import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.util.DateUtils; +import com.jsowell.common.util.JWTUtils; +import com.jsowell.common.util.PageUtils; +import com.jsowell.common.util.StringUtils; +import com.jsowell.pile.domain.*; +import com.jsowell.pile.dto.PushRealTimeInfoDTO; +import com.jsowell.pile.dto.QueryConnectorListDTO; +import com.jsowell.pile.dto.QueryOperatorInfoDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.service.*; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.util.MerchantUtils; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.pile.vo.base.ConnectorInfoVO; +import com.jsowell.pile.vo.base.MerchantInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileMerchantInfoVO; +import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; +import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; +import com.jsowell.thirdparty.platform.domain.*; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; + +import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.platform.util.GBSignUtils; +import com.jsowell.thirdparty.platform.util.HttpRequestUtil; +import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import com.yi.business.geo.GeoCodeInfo; +import com.yi.business.geo.TermRelationTreeCoordinate; +import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { + private final String thirdPlatformType = ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode(); + + @Autowired + private PileStationInfoService pileStationInfoService; + + @Autowired + private ThirdPartyStationRelationService thirdPartyStationRelationService; + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Autowired + private PileMerchantInfoService pileMerchantInfoService; + + @Autowired + private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + /** + * query_token 获取token,提供给第三方平台使用 + * + * @param dto + * @return + */ + @Override + public Map queryToken(CommonParamsDTO dto) { + AccessTokenVO vo = new AccessTokenVO(); + // 0:成功;1:失败 + int succStat = 0; + // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + int failReason = 0; + + String operatorId = dto.getPlatformID(); + // 通过operatorId 查出 operatorSecret + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (thirdPartySecretInfoVO == null) { + failReason = 1; + succStat = 1; + } else { + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + if (StringUtils.isBlank(decrypt)) { + failReason = 2; + succStat = 1; + } else { + String inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); + // 对比密钥 + if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) { + failReason = 2; + succStat = 1; + } else { + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); + vo.setAccessToken(token); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + } + } + } + // 组装返回参数 + vo.setPlatformId(operatorId); + vo.setFailReason(failReason); + vo.setSuccStat(succStat); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 查询运营商信息 query_operator_info + * supervise_query_operator_info + * + * @param dto 查询运营商信息DTO + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryOperatorInfo(QueryOperatorInfoDTO dto) { + PageHelper.startPage(dto.getPageNo(), dto.getPageSize()); + List merchantList = thirdPartyStationRelationService.selectMerchantList(thirdPlatformType); + PageInfo pageInfo = new PageInfo<>(merchantList); + List operatorInfos = Lists.newArrayList(); + if (CollectionUtils.isNotEmpty(pageInfo.getList())) { + SupOperatorInfo supOperatorInfo; + for (MerchantInfoVO merchantInfoVO : pageInfo.getList()) { + supOperatorInfo = new SupOperatorInfo(); + supOperatorInfo.setOperatorID(MerchantUtils.getOperatorID(merchantInfoVO.getOrganizationCode())); + supOperatorInfo.setOperatorUSCID(merchantInfoVO.getOrganizationCode()); + supOperatorInfo.setOperatorName(merchantInfoVO.getMerchantName()); + supOperatorInfo.setOperatorTel1(merchantInfoVO.getMerchantTel()); + supOperatorInfo.setOperatorRegAddress(merchantInfoVO.getMerchantAddress()); + operatorInfos.add(supOperatorInfo); + } + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + + // 组装结果集 + Map map = Maps.newHashMap(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", pageInfo.getTotal()); + map.put("OperatorInfos", operatorInfos); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + return resultMap; + } + /** + * 查询充电站信息 query_stations_info + * supervise_query_operator_info + * 此接口用于查询对接平台的充电站的信息 + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); + int pageSize = dto.getPageSize() == null ? 50 : dto.getPageSize(); + + PageUtils.startPage(pageNo, pageSize); + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); + if (CollectionUtils.isEmpty(stationInfos)) { + // 未查到数据 + return null; + } + // ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + if (thirdPartySecretInfoVO == null) { + return null; + } + PageInfo pageInfo = new PageInfo<>(stationInfos); + List resultList = new ArrayList<>(); + for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { + SupStationInfo stationInfo = new SupStationInfo(); + String stationId = String.valueOf(pileStationInfo.getId()); + stationInfo.setStationID(stationId); + // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setOperatorID(Constants.OPERATORID_LIANLIAN); // 组织机构代码 + stationInfo.setEquipmentOwnerID(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setStationName(pileStationInfo.getStationName()); + stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())); + stationInfo.setIsPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())); + stationInfo.setCountryCode(pileStationInfo.getCountryCode()); + stationInfo.setAreaCode(pileStationInfo.getAreaCode()); + stationInfo.setAddress(pileStationInfo.getAddress()); + stationInfo.setServiceTel(pileStationInfo.getStationTel()); + stationInfo.setStationType(Integer.valueOf(pileStationInfo.getStationType())); + stationInfo.setParkNums(Integer.valueOf(pileStationInfo.getParkNums())); + stationInfo.setStationLng(new BigDecimal(pileStationInfo.getStationLng())); + stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat())); + stationInfo.setConstruction(Integer.valueOf(pileStationInfo.getConstruction())); + stationInfo.setOpenAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())); + // stationInfo.setMinElectricityPrice(pileStationInfo); // 最低充电电费率 + // stationInfo.setElectricityFee(); // 电费 xx元/度 + // stationInfo.setServiceFee(); // 服务费 xx元/度 + stationInfo.setParkFree(Integer.valueOf(pileStationInfo.getParkFree())); + stationInfo.setPayment(pileStationInfo.getPayment()); + stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())); + // stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型 + stationInfo.setToiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())); + stationInfo.setStoreFlag(Integer.valueOf(pileStationInfo.getStoreFlag())); + stationInfo.setRestaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())); + stationInfo.setLoungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())); + stationInfo.setCanopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())); + stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())); + stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())); + stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())); + List pileList = pileBasicInfoService.getPileListForLianLian(stationId); + if (CollectionUtils.isNotEmpty(pileList)) { + stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 + } + resultList.add(stationInfo); + } + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", pageInfo.getTotal()); + map.put("StationInfos", resultList); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + return resultMap; + } + + + // 获取平台配置密钥信息 + private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() { + // 通过第三方平台类型查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.ZHE_JIANG_PLATFORM.getTypeCode()); + if (thirdPartySecretInfoVO == null) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + return thirdPartySecretInfoVO; + } + /** + * 推送充电站信息 + * supervise_notification_station_info + */ + @Override + public String notificationStationInfo(String stationId) { + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); + + // 查询第三方平台配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuiZhouPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + // 组装所需要的数据格式 + SupStationInfo info = SupStationInfo.builder() + .stationID(stationId) + .operatorID(operatorId) + .stationName(pileStationInfo.getStationName()) + .isAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())) + .isPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())) + .countryCode(pileStationInfo.getCountryCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationType(Integer.valueOf(pileStationInfo.getStationType())) + .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) + .parkNums(Integer.valueOf(pileStationInfo.getParkNums())) + .stationLng(new BigDecimal(pileStationInfo.getStationLng())) + .stationLat(new BigDecimal(pileStationInfo.getStationLat())) + .construction(Integer.valueOf(pileStationInfo.getConstruction())) + .openAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())) + .minElectricityPrice(new BigDecimal(Constants.ZERO)) + .electricityFee(Constants.ZERO) + .serviceFee(Constants.ZERO) + .parkFree(Integer.valueOf(pileStationInfo.getParkFree())) + .supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())) + .parkFeeType(0) + .toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())) + .storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag())) + .restaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())) + .loungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())) + .canopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())) + .printerFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())) + .barrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())) + .parkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())) + .build(); + String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 + // 根据逗号分组 + String[] split = StringUtils.split(areaCode, ","); + // 只取最后一部分 330213 + String subAreaCode = split[split.length - 1]; + info.setAreaCode(subAreaCode); + // 截取运营商组织机构代码(去除最后一位后的最后九位) + String organizationCode = ""; + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(), thirdPlatformType)) { + // 联联平台先使用自己运营商的组织机构代码 + organizationCode = Constants.OPERATORID_LIANLIAN; + info.setEquipmentOwnerID(organizationCode); + } else { + MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId())); + organizationCode = merchantInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + info.setEquipmentOwnerID(equipmentOwnerId); + } + } + + info.setPayment(StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment())); + if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) { + info.setIsPublicParkingLot(1); + info.setParkingLotNumber(pileStationInfo.getParkingNumber()); + } + // 户号 + if (StringUtils.isNotBlank(pileStationInfo.getAccountNumber())) { + info.setAccountNumber(pileStationInfo.getAccountNumber()); + } + + // 容量 + if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getCapacity()))) { + info.setCapacity(pileStationInfo.getCapacity().setScale(4, RoundingMode.HALF_UP)); + } + List pileList = pileBasicInfoService.getPileListForLianLian(stationId); + if (CollectionUtils.isNotEmpty(pileList)) { + info.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + // areaCodeCountryside + GeoCodeInfo geoCode = TermRelationTreeCoordinate.completeGeoCode(pileStationInfo.getAddress()); + if (geoCode != null) { + String areaCodeCountryside = geoCode.getCounty_code(); + info.setAreaCodeCountryside(areaCodeCountryside); + } + + // 调用联联平台接口 + String url = urlAddress + "supervise_notification_station_info"; + + JSONObject data = new JSONObject(); + data.put("SupStationInfo", info); + + String jsonString = JSON.toJSONString(info); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** + * 查询站点状态信息 + *supervise_query_station_status + * @param dto + */ + @Override + public Map queryStationStatus(QueryStationInfoDTO dto) { + List stationIds = dto.getStationIds(); + List StationStatusInfos = new ArrayList<>(); + List ConnectorStatusInfos = new ArrayList<>(); + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + if (configInfo == null) { + return null; + } + ConnectorStatusInfo connectorStatusInfo; + for (String stationId : stationIds) { + StationStatusInfo stationStatusInfo = new StationStatusInfo(); + stationStatusInfo.setStationId(stationId); + // 根据站点id查询 + List list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId)); + for (ConnectorInfoVO connectorInfoVO : list) { + + String connectorStatus = connectorInfoVO.getConnectorStatus(); + if (StringUtils.equals(connectorStatus, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) { + // 充电中 + ConnectorChargeStatusInfo info = new ConnectorChargeStatusInfo(); + OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(connectorInfoVO.getPileConnectorCode()); + if (orderBasicInfo == null) { + continue; + } + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode()); + if (CollectionUtils.isNotEmpty(chargingRealTimeData)) { + RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); + + info.setStartChargeSeq(orderBasicInfo.getOrderCode()); + info.setConnectorID(orderBasicInfo.getPileConnectorCode()); + info.setConnectorStatus(Integer.valueOf(connectorInfoVO.getConnectorStatus())); + info.setCurrentA(new BigDecimal(realTimeMonitorData.getOutputCurrent())); + info.setVoltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage())); + info.setSoc(new BigDecimal(realTimeMonitorData.getSOC())); + info.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); + info.setEndTime(DateUtils.getDateTime()); // 本次采样时间 + info.setTotalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())); // 累计充电量 + // info.setElecMoney(); // 累计电费 + // info.setSeviceMoney(); // 累计服务费 + info.setTotalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount())); + + ConnectorStatusInfos.add(info); + } + } else { + // 其他 + connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); + + ConnectorStatusInfos.add(connectorStatusInfo); + } + } + stationStatusInfo.setConnectorStatusInfos(ConnectorStatusInfos); + StationStatusInfos.add(stationStatusInfo); + } + // 将 StationStatusInfos 分页 + int pageNum = 1; + int pageSize = 10; + List collect = StationStatusInfos.stream() + .skip((pageNum - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + int total = StationStatusInfos.size(); + int pages = PageUtil.totalPage(total, pageSize); + + Map map = new LinkedHashMap<>(); + map.put("Total", total); + map.put("StationStatusInfos", collect); + + Map resultMap = Maps.newLinkedHashMap(); + // 加密数据 + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(map), configInfo.getDataSecret(), configInfo.getDataSecretIv()); + resultMap.put("Data", encryptData); + // 生成sig + String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); + resultMap.put("Sig", resultSign); + return resultMap; + } + + @Override + public String notificationStationStatus(PushRealTimeInfoDTO dto) { + String pileConnectorCode = dto.getPileConnectorCode(); + String status = dto.getStatus(); + ThirdPartySecretInfoVO xiaPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); + // 查询充电枪口状态 + PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); + if (Objects.isNull(connectorInfo)) { + throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR); + } + + String merchantId = connectorInfo.getMerchantId(); + MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(merchantId); + if (Objects.isNull(merchantInfoVO)) { + throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR); + } + + SupConnectorStatusInfo info = SupConnectorStatusInfo.builder() + .operatorID(Constants.JSOWELL_OPERATORID) + .equipmentOwnerID(MerchantUtils.getOperatorID(merchantInfoVO.getOrganizationCode())) + .stationID(connectorInfo.getStationId()) + .equipmentID(connectorInfo.getPileSn()) + .connectorID(pileConnectorCode) + .equipmentClassification(Constants.ONE) + .status(Integer.parseInt(status)) + .statusDesc(PileConnectorDataBaseStatusEnum.getStatusDescription(status)) + .parkStatus(Constants.zero) + .lockStatus(Constants.zero) + .batteryStatus(Constants.ZERO) + .batteryPackID("") + .lastChangeTime(DateUtils.getDateTime()) + .build(); + + // 调用联联平台接口 + String operatorId = xiaPlatformSecretInfo.getOurOperatorId(); + String operatorSecret = xiaPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = xiaPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = xiaPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = xiaPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = xiaPlatformSecretInfo.getTheirUrlPrefix(); + String url = urlAddress + "supervise_notification_station_status"; + + // JSONObject json = new JSONObject(); + // json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(info); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** + * 推送充电状态 notification_equip_charge_status + * 推送充电状态信息 supervise_notification_equip_charge_status + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationEquipChargeStatus(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 查询枪口状态 + PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + BigDecimal current = info.getCurrent() == null ? BigDecimal.ZERO : info.getCurrent(); + BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage(); + String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC(); + // 查询相关配置信息 + ThirdPartySecretInfoVO zheJiangPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); + + String operatorId = zheJiangPlatformSecretInfo.getOurOperatorId(); + String operatorSecret = zheJiangPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = zheJiangPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = zheJiangPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = zheJiangPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = zheJiangPlatformSecretInfo.getTheirUrlPrefix(); + + String dateTime = DateUtils.getDateTime(); + SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() + .operatorID(Constants.OPERATORID_JIANG_SU) + .equipmentOwnerID(Constants.OPERATORID_JIANG_SU) + .stationID(orderInfo.getStationId()) + .equipmentID(orderInfo.getPileSn()) + .connectorID(orderInfo.getPileConnectorCode()) + .orderNo(orderInfo.getOrderCode()) + .orderStatus(2) + .pushTimeStamp(dateTime) + .connectorStatus(info.getStatus()) // 3-充电中 + .currentA(current.setScale(1, BigDecimal.ROUND_HALF_UP)) + .voltageA(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) + .soc(new BigDecimal(soc)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(dateTime) + .totalPower(info.getChargingDegree()) + .eventTime(dateTime) + .chargeVoltage(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) + .chargeCurrent(current.setScale(1, BigDecimal.ROUND_HALF_UP)) + .build(); + + // 查询运营商信息 + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationId()); + String organizationCode = pileMerchantInfoVO.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + supEquipChargeStatusInfo.setEquipmentOwnerID(equipmentOwnerId); + } + + String url = urlAddress + "supervise_notification_equip_charge_status"; + // 调用平台接口 + String jsonString = JSON.toJSONString(supEquipChargeStatusInfo); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** + * 推送充电订单信息 + * supervise_notification_charge_order_info + */ + @Override + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderBasicInfo == null) { + return null; + } + + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + + // 根据订单号查询订单详情 + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + if (orderDetail == null) { + return null; + } + + // 推送地址 + String url = urlAddress + "supervise_notification_charge_order_info"; + + // 拼装成平台所需格式对象 + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationID()); + String organizationCode = pileMerchantInfoVO.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + equipmentOwnerID = ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileMerchantInfoVO.getOrganizationCode()); + }else { + equipmentOwnerID = Constants.OPERATORID_JIANG_SU; + } + } + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + String jsonString = JSON.toJSONString(orderInfo); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 推送充电站历史充电订单信息 supervise_notification_charge_order_info_history + * + * @param orderCode + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationChargeOrderInfoHistory(String orderCode) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + + // 通过站点id查询相关配置信息 + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + if (relationInfo == null) { + return null; + } + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + String operatorId = relationInfo.getOperatorId(); + String operatorSecret = relationInfo.getOperatorSecret(); + String signSecret = relationInfo.getSignSecret(); + String dataSecret = relationInfo.getDataSecret(); + String dataSecretIv = relationInfo.getDataSecretIv(); + String urlAddress = relationInfo.getUrlAddress(); + + String url = urlAddress + "supervise_notification_charge_order_info_history"; + + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + equipmentOwnerID = Constants.OPERATORID_LIANLIAN; + } + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + /** + * 推送充换电站实时功率 supervise_notification_realtime_power_info + * + * @return + */ + public String notificationPowerInfo(List stationIds) { + com.jsowell.thirdparty.platform.common.SupStationPowerInfo supStationPowerInfo = null; + List list = new ArrayList<>(); + String dateTimeNow = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS); + + List supPileInfoList = null; + com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo supPileInfo = null; + + List connectorPowerInfoList; + com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo connectorPowerInfo; + for (String stationId : stationIds) { + BigDecimal stationPower = BigDecimal.ZERO; + supStationPowerInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo(); + + supStationPowerInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); + supStationPowerInfo.setStationId(stationId); + supStationPowerInfo.setDataTime(dateTimeNow); + supStationPowerInfo.setStationClassification(Constants.one); + // 查询运营商基本信息 + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(stationId); + String organizationCode = pileMerchantInfoVO.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + supStationPowerInfo.setEquipmentOwnerID(equipmentOwnerId); + } else { + supStationPowerInfo.setEquipmentOwnerID(Constants.OPERATORID_JIANG_SU); + } + + // 根据站点id查询桩信息 + List pileList = pileBasicInfoService.getPileListByStationId(stationId); + if (CollectionUtils.isEmpty(pileList)) { + logger.error("推送充换电站实时功率 error, 查询桩列表信息为空"); + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + // 将桩id筛选出来用于批量查询枪口数据 + List pileIds = pileList.stream() + .map(PileBasicInfo::getId) + .collect(Collectors.toList()); + QueryConnectorListDTO dto = new QueryConnectorListDTO(); + dto.setPileIds(pileIds); + List connectorList = pileConnectorInfoService.getConnectorInfoListByParams(dto); + if (CollectionUtils.isEmpty(connectorList)) { + logger.error("推送充换电站实时功率 error, 查询枪口列表信息为空"); + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + supPileInfoList = new ArrayList<>(); + for (PileBasicInfo pileBasicInfo : pileList) { + supPileInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo(); + supPileInfo.setEquipmentID(pileBasicInfo.getSn()); + supPileInfo.setEquipmentClassification(Constants.one); + supPileInfo.setDataTime(dateTimeNow); + BigDecimal pileInstantPower = BigDecimal.ZERO; + connectorPowerInfoList = new ArrayList<>(); + for (PileConnectorInfoVO pileConnectorInfoVO : connectorList) { + if (!StringUtils.equals(pileBasicInfo.getSn(), pileConnectorInfoVO.getPileSn())) { + continue; + } + BigDecimal instantPower = pileConnectorInfoVO.getInstantPower() == null ? BigDecimal.ZERO : pileConnectorInfoVO.getInstantPower(); + connectorPowerInfo = new com.jsowell.thirdparty.platform.common.SupStationPowerInfo.EquipmentPowerInfo.ConnectorPowerInfo(); + connectorPowerInfo.setConnectorID(pileConnectorInfoVO.getPileConnectorCode()); + connectorPowerInfo.setEquipmentClassification(Constants.one); + connectorPowerInfo.setDataTime(dateTimeNow); + BigDecimal InstantPower = instantPower.setScale(1, BigDecimal.ROUND_HALF_UP); + connectorPowerInfo.setConnectorRealTimePower(InstantPower); + // 计算桩此时实时功率 + pileInstantPower = pileInstantPower.add(InstantPower); + + connectorPowerInfoList.add(connectorPowerInfo); + } + supPileInfo.setConnectorPowerInfos(connectorPowerInfoList); + // 桩实时功率 + supPileInfo.setEquipRealTimePower(pileInstantPower); + stationPower = stationPower.add(pileInstantPower); + + supPileInfoList.add(supPileInfo); + } + supStationPowerInfo.setEquipmentPowerInfos(supPileInfoList); + supStationPowerInfo.setStationRealTimePower(stationPower); + } + list.add(supStationPowerInfo); + + // 获取推送配置密钥信息 + ThirdPartyStationRelationVO settingInfo = getGuizhouSettingInfo(); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + String urlAddress = settingInfo.getUrlAddress(); + + String url = urlAddress + "supervise_notification_realtime_power_info"; + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + JSONObject json = new JSONObject(); + json.put("SupStationPowerInfos", list); + String jsonString = JSON.toJSONString(json); + // 发送请求 + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + + + // 获取贵州平台配置密钥信息 + private ThirdPartyStationRelationVO getGuizhouSettingInfo() { + // 通过第三方平台类型查询相关配置信息 + ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + relation.setThirdPartyType(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode()); + ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + return relationInfo; + } + /** + * 转换充电站充电订单信息 + * @param orderBasicInfo + * @param orderDetail + * @return + */ + private ChargeOrderInfo transformChargeOrderInfo(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) { + ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder() + .stationID(orderBasicInfo.getStationId()) + .equipmentID(orderBasicInfo.getPileSn()) + .orderNo(orderBasicInfo.getOrderCode()) + .connectorID(orderBasicInfo.getPileConnectorCode()) + .licensePlate(orderBasicInfo.getPlateNumber()) + .vin(orderBasicInfo.getVinCode()) + .startSOC(orderBasicInfo.getStartSoc()) + .endSOC(orderBasicInfo.getEndSoc()) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) + .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) + .totalPower(orderDetail.getTotalUsedElectricity()) + .cuspElect(orderDetail.getSharpUsedElectricity()) + .peakElect(orderDetail.getSharpUsedElectricity()) + .flatElect(orderDetail.getFlatUsedElectricity()) + .valleyElect(orderDetail.getValleyUsedElectricity()) + .pushTimeStamp(DateUtils.getDateTime()) + .totalElecMoney(orderDetail.getTotalElectricityAmount()) + .totalSeviceMoney(orderDetail.getTotalServiceAmount()) + .totalMoney(orderDetail.getTotalOrderAmount()) + .stopReason(0) + .stopDesc(orderBasicInfo.getReason()) // TODO 停止原因 + .sumPeriod(0) + .build(); + return chargeOrderInfo; + } + /** + * 转换时段充电明细 + * @param orderDetail + * @param billingList + * @return + */ + private List transformSupChargeDetails(OrderDetail orderDetail, List billingList) { + List resultList = Lists.newArrayList(); + SupChargeDetails detail; + for (BillingPriceVO billingPriceVO : billingList) { + detail = new SupChargeDetails(); + if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.SHARP.getValue())) { + // 尖时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getSharpUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getSharpElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.PEAK.getValue())) { + // 峰时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getPeakUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.FLAT.getValue())) { + // 平时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getFlatUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.VALLEY.getValue())) { + // 谷时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getValleyUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice()); + } + resultList.add(detail); + } + return resultList; + + } +} + From 893bd6c182ac0fb5cd8f6d37258b7d1f22c6ab1d Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 19 Nov 2024 10:22:43 +0800 Subject: [PATCH 02/12] =?UTF-8?q?update=20=20=E7=94=98=E8=82=83=E7=9C=81?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thirdparty/ThirdPlatformTypeEnum.java | 1 + .../impl/GuiZhouPlatformServiceImpl.java | 129 +++++++++++------- 2 files changed, 77 insertions(+), 53 deletions(-) diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index a837c7532..f8a054c6f 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -26,6 +26,7 @@ public enum ThirdPlatformTypeEnum { ZHE_JIANG_PLATFORM("15", "浙江省平台", "002485048"), SU_ZHOU_PLATFORM("16", "苏州市平台", "MAC1MFJ1X"), GAN_SU_PLATFORM("17", "甘肃省平台", ""), + GUI_ZHOU_PLATFORM("18", "贵州省平台", ""), ; private String typeCode; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java index 749f51b8f..ceb5b3976 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -62,9 +62,12 @@ import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; +/** + * 贵州平台Service + */ @Service public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { - private final String thirdPlatformType = ThirdPlatformTypeEnum.NEI_MENG_GU_PLATFORM.getTypeCode(); + private final String thirdPlatformType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode(); @Autowired private PileStationInfoService pileStationInfoService; @@ -177,7 +180,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { operatorInfos.add(supOperatorInfo); } } - ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuiZhouPlatformSecretInfo(); // 组装结果集 Map map = Maps.newHashMap(); @@ -189,6 +192,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); return resultMap; } + /** * 查询充电站信息 query_stations_info * supervise_query_operator_info @@ -209,10 +213,12 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { return null; } // ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); - ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); - if (thirdPartySecretInfoVO == null) { - return null; - } + // ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); + // if (thirdPartySecretInfoVO == null) { + // return null; + // } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuiZhouPlatformSecretInfo(); + PageInfo pageInfo = new PageInfo<>(stationInfos); List resultList = new ArrayList<>(); for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { @@ -265,17 +271,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { return resultMap; } - - // 获取平台配置密钥信息 - private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() { - // 通过第三方平台类型查询相关配置信息 - ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.ZHE_JIANG_PLATFORM.getTypeCode()); - if (thirdPartySecretInfoVO == null) { - throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); - } - thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); - return thirdPartySecretInfoVO; - } /** * 推送充电站信息 * supervise_notification_station_info @@ -387,9 +382,11 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } + /** * 查询站点状态信息 - *supervise_query_station_status + * supervise_query_station_status + * * @param dto */ @Override @@ -523,6 +520,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } + /** * 推送充电状态 notification_equip_charge_status * 推送充电状态信息 supervise_notification_equip_charge_status @@ -540,14 +538,14 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage(); String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC(); // 查询相关配置信息 - ThirdPartySecretInfoVO zheJiangPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); + ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); - String operatorId = zheJiangPlatformSecretInfo.getOurOperatorId(); - String operatorSecret = zheJiangPlatformSecretInfo.getTheirOperatorSecret(); - String signSecret = zheJiangPlatformSecretInfo.getTheirSigSecret(); - String dataSecret = zheJiangPlatformSecretInfo.getTheirDataSecret(); - String dataSecretIv = zheJiangPlatformSecretInfo.getTheirDataSecretIv(); - String urlAddress = zheJiangPlatformSecretInfo.getTheirUrlPrefix(); + String operatorId = guiZhouPlatformSecretInfo.getOurOperatorId(); + String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = guiZhouPlatformSecretInfo.getTheirUrlPrefix(); String dateTime = DateUtils.getDateTime(); SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() @@ -588,6 +586,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } + /** * 推送充电订单信息 * supervise_notification_charge_order_info @@ -627,7 +626,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { String organizationCode = pileMerchantInfoVO.getOrganizationCode(); if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { equipmentOwnerID = ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileMerchantInfoVO.getOrganizationCode()); - }else { + } else { equipmentOwnerID = Constants.OPERATORID_JIANG_SU; } } @@ -663,18 +662,19 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); // 通过站点id查询相关配置信息 - ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); - if (relationInfo == null) { - return null; - } + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); + // if (relationInfo == null) { + // return null; + // } + ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); - String operatorId = relationInfo.getOperatorId(); - String operatorSecret = relationInfo.getOperatorSecret(); - String signSecret = relationInfo.getSignSecret(); - String dataSecret = relationInfo.getDataSecret(); - String dataSecretIv = relationInfo.getDataSecretIv(); - String urlAddress = relationInfo.getUrlAddress(); + String operatorId = guiZhouPlatformSecretInfo.getTheirOperatorId(); + String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = guiZhouPlatformSecretInfo.getTheirUrlPrefix(); String url = urlAddress + "supervise_notification_charge_order_info_history"; @@ -707,6 +707,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } + /** * 推送充换电站实时功率 supervise_notification_realtime_power_info * @@ -794,16 +795,18 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { list.add(supStationPowerInfo); // 获取推送配置密钥信息 - ThirdPartyStationRelationVO settingInfo = getGuizhouSettingInfo(); - if (settingInfo == null) { - return null; - } - String operatorId = settingInfo.getOperatorId(); - String operatorSecret = settingInfo.getOperatorSecret(); - String signSecret = settingInfo.getSignSecret(); - String dataSecret = settingInfo.getDataSecret(); - String dataSecretIv = settingInfo.getDataSecretIv(); - String urlAddress = settingInfo.getUrlAddress(); + // ThirdPartyStationRelationVO settingInfo = getGuizhouSettingInfo(); + // if (settingInfo == null) { + // return null; + // } + ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); + + String operatorId = guiZhouPlatformSecretInfo.getTheirOperatorId(); + String operatorSecret = guiZhouPlatformSecretInfo.getTheirOperatorSecret(); + String signSecret = guiZhouPlatformSecretInfo.getTheirSigSecret(); + String dataSecret = guiZhouPlatformSecretInfo.getTheirDataSecret(); + String dataSecretIv = guiZhouPlatformSecretInfo.getTheirDataSecretIv(); + String urlAddress = guiZhouPlatformSecretInfo.getTheirUrlPrefix(); String url = urlAddress + "supervise_notification_realtime_power_info"; // 获取令牌 @@ -819,18 +822,36 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + /** + * 获取贵州平台配置密钥信息 + * + * @return + */ + // private ThirdPartyStationRelationVO getGuizhouSettingInfo() { + // // 通过第三方平台类型查询相关配置信息 + // ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + // relation.setThirdPartyType(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode()); + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + // return relationInfo; + // } - - // 获取贵州平台配置密钥信息 - private ThirdPartyStationRelationVO getGuizhouSettingInfo() { + /** + * 获取甘肃省平台配置密钥信息 + * @return + */ + private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() { // 通过第三方平台类型查询相关配置信息 - ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); - relation.setThirdPartyType(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode()); - ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); - return relationInfo; + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode()); + if (thirdPartySecretInfoVO == null) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + return thirdPartySecretInfoVO; } + /** * 转换充电站充电订单信息 + * * @param orderBasicInfo * @param orderDetail * @return @@ -862,8 +883,10 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { .build(); return chargeOrderInfo; } + /** * 转换时段充电明细 + * * @param orderDetail * @param billingList * @return From a4b002ca509f2fd3cb1afd233caedbf01afa3343 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Sat, 23 Nov 2024 11:46:45 +0800 Subject: [PATCH 03/12] update --- .../impl/GuiZhouPlatformServiceImpl.java | 105 +- .../YongChengbochePlatfromServicelmpl.java | 909 ++++++++++++++++++ 2 files changed, 940 insertions(+), 74 deletions(-) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java index ceb5b3976..407991493 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -10,15 +10,13 @@ import com.google.common.collect.Maps; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.enums.lianlian.StationPaymentEnum; +import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; -import com.jsowell.common.util.DateUtils; -import com.jsowell.common.util.JWTUtils; -import com.jsowell.common.util.PageUtils; -import com.jsowell.common.util.StringUtils; +import com.jsowell.common.util.*; import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.PushRealTimeInfoDTO; import com.jsowell.pile.dto.QueryConnectorListDTO; @@ -32,18 +30,18 @@ import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; -import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileMerchantInfoVO; +import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.platform.domain.*; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; -import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.GBSignUtils; import com.jsowell.thirdparty.platform.util.HttpRequestUtil; @@ -212,11 +210,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { // 未查到数据 return null; } - // ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); - // ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType); - // if (thirdPartySecretInfoVO == null) { - // return null; - // } ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuiZhouPlatformSecretInfo(); PageInfo pageInfo = new PageInfo<>(stationInfos); @@ -427,8 +420,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { info.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); info.setEndTime(DateUtils.getDateTime()); // 本次采样时间 info.setTotalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())); // 累计充电量 - // info.setElecMoney(); // 累计电费 - // info.setSeviceMoney(); // 累计服务费 info.setTotalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount())); ConnectorStatusInfos.add(info); @@ -470,51 +461,41 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { return resultMap; } + /** + * 设备状态变化推送 notification_stationStatus + * 推送充电设备接口状态信息 supervise_notification_station_status + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ @Override public String notificationStationStatus(PushRealTimeInfoDTO dto) { - String pileConnectorCode = dto.getPileConnectorCode(); String status = dto.getStatus(); - ThirdPartySecretInfoVO xiaPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); - // 查询充电枪口状态 - PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); - if (Objects.isNull(connectorInfo)) { - throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR); - } + String pileConnectorCode = dto.getPileConnectorCode(); - String merchantId = connectorInfo.getMerchantId(); - MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(merchantId); - if (Objects.isNull(merchantInfoVO)) { - throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR); - } + // 查出该桩所属哪个站点 + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn); + // 通过站点id查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuiZhouPlatformSecretInfo(); - SupConnectorStatusInfo info = SupConnectorStatusInfo.builder() - .operatorID(Constants.JSOWELL_OPERATORID) - .equipmentOwnerID(MerchantUtils.getOperatorID(merchantInfoVO.getOrganizationCode())) - .stationID(connectorInfo.getStationId()) - .equipmentID(connectorInfo.getPileSn()) + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() .connectorID(pileConnectorCode) - .equipmentClassification(Constants.ONE) .status(Integer.parseInt(status)) - .statusDesc(PileConnectorDataBaseStatusEnum.getStatusDescription(status)) - .parkStatus(Constants.zero) - .lockStatus(Constants.zero) - .batteryStatus(Constants.ZERO) - .batteryPackID("") - .lastChangeTime(DateUtils.getDateTime()) .build(); - // 调用联联平台接口 - String operatorId = xiaPlatformSecretInfo.getOurOperatorId(); - String operatorSecret = xiaPlatformSecretInfo.getTheirOperatorSecret(); - String signSecret = xiaPlatformSecretInfo.getTheirSigSecret(); - String dataSecret = xiaPlatformSecretInfo.getTheirDataSecret(); - String dataSecretIv = xiaPlatformSecretInfo.getTheirDataSecretIv(); - String urlAddress = xiaPlatformSecretInfo.getTheirUrlPrefix(); - String url = urlAddress + "supervise_notification_station_status"; - - // JSONObject json = new JSONObject(); - // json.put("ConnectorStatusInfo", info); - String jsonString = JSON.toJSONString(info); + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); // 获取令牌 String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); @@ -661,11 +642,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { // 根据订单号查询出信息 OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); - // 通过站点id查询相关配置信息 - // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(orderBasicInfo.getStationId()); - // if (relationInfo == null) { - // return null; - // } ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); @@ -793,12 +769,6 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { supStationPowerInfo.setStationRealTimePower(stationPower); } list.add(supStationPowerInfo); - - // 获取推送配置密钥信息 - // ThirdPartyStationRelationVO settingInfo = getGuizhouSettingInfo(); - // if (settingInfo == null) { - // return null; - // } ThirdPartySecretInfoVO guiZhouPlatformSecretInfo = getGuiZhouPlatformSecretInfo(); String operatorId = guiZhouPlatformSecretInfo.getTheirOperatorId(); @@ -823,20 +793,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { } /** - * 获取贵州平台配置密钥信息 - * - * @return - */ - // private ThirdPartyStationRelationVO getGuizhouSettingInfo() { - // // 通过第三方平台类型查询相关配置信息 - // ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); - // relation.setThirdPartyType(ThirdPlatformTypeEnum.QING_HAI_PLATFORM.getTypeCode()); - // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); - // return relationInfo; - // } - - /** - * 获取甘肃省平台配置密钥信息 + * 获取贵州省平台配置密钥信息 * @return */ private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() { diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java new file mode 100644 index 000000000..429764302 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java @@ -0,0 +1,909 @@ +package com.jsowell.thirdparty.platform.service.impl; + +import cn.hutool.core.util.PageUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; +import com.jsowell.common.enums.ykc.OrderStatusEnum; +import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.util.*; +import com.jsowell.pile.domain.OrderBasicInfo; +import com.jsowell.pile.domain.OrderDetail; +import com.jsowell.pile.domain.PileBasicInfo; +import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; +import com.jsowell.pile.dto.*; +import com.jsowell.pile.service.*; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.util.MerchantUtils; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.pile.vo.base.ConnectorInfoVO; +import com.jsowell.pile.vo.base.MerchantInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileMerchantInfoVO; +import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; +import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; +import com.jsowell.thirdparty.lianlian.vo.*; +import com.jsowell.thirdparty.platform.domain.*; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.*; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 甬城泊车 + */ +@Service +public class YongChengbochePlatfromServicelmpl implements ThirdPartyPlatformService { + private final String thirdPlatformType = ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getTypeCode(); + + @Autowired + private PileStationInfoService pileStationInfoService; + + @Autowired + private YKCPushCommandService ykcPushCommandService; + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Autowired + private PileMerchantInfoService pileMerchantInfoService; + + @Autowired + private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + @Autowired + private PileRemoteService pileRemoteService; + + @Autowired + private ThirdPartyStationRelationService thirdPartyStationRelationService; + + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + /** + * query_token 获取token,提供给第三方平台使用 + * + * @param dto + * @return + */ + @Override + public Map queryToken(CommonParamsDTO dto) { + AccessTokenVO vo = new AccessTokenVO(); + // 0:成功;1:失败 + int succStat = 0; + // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + int failReason = 0; + + String operatorId = dto.getPlatformID(); + // 通过operatorId 查出 operatorSecret + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (thirdPartySecretInfoVO == null) { + failReason = 1; + succStat = 1; + } else { + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + String inputOperatorSecret = null; + if (StringUtils.isNotBlank(decrypt)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); + } + // 对比密钥 + if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) { + failReason = 1; + succStat = 1; + } else { + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); + vo.setAccessToken(token); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + } + } + // 组装返回参数 + vo.setPlatformId(operatorId); + vo.setFailReason(failReason); + vo.setSuccStat(succStat); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 查询充电站信息 query_stations_info + * supervise_query_operator_info + * 此接口用于查询对接平台的充电站的信息 + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); + int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); + + PageUtils.startPage(pageNo, pageSize); + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); + if (CollectionUtils.isEmpty(stationInfos)) { + // 未查到数据 + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getYongChengbochePlatformSecretInfo(); + + PageInfo pageInfo = new PageInfo<>(stationInfos); + List resultList = new ArrayList<>(); + for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { + SupStationInfo stationInfo = new SupStationInfo(); + String stationId = String.valueOf(pileStationInfo.getId()); + stationInfo.setStationID(stationId); + // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setOperatorID(Constants.OPERATORID_LIANLIAN); // 组织机构代码 + stationInfo.setEquipmentOwnerID(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setStationName(pileStationInfo.getStationName()); + stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())); + stationInfo.setIsPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())); + stationInfo.setCountryCode(pileStationInfo.getCountryCode()); + stationInfo.setAreaCode(pileStationInfo.getAreaCode()); + stationInfo.setAddress(pileStationInfo.getAddress()); + stationInfo.setServiceTel(pileStationInfo.getStationTel()); + stationInfo.setStationType(Integer.valueOf(pileStationInfo.getStationType())); + stationInfo.setParkNums(Integer.valueOf(pileStationInfo.getParkNums())); + stationInfo.setStationLng(new BigDecimal(pileStationInfo.getStationLng())); + stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat())); + stationInfo.setConstruction(Integer.valueOf(pileStationInfo.getConstruction())); + stationInfo.setOpenAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())); + // stationInfo.setMinElectricityPrice(pileStationInfo); // 最低充电电费率 + // stationInfo.setElectricityFee(); // 电费 xx元/度 + // stationInfo.setServiceFee(); // 服务费 xx元/度 + stationInfo.setParkFree(Integer.valueOf(pileStationInfo.getParkFree())); + stationInfo.setPayment(pileStationInfo.getPayment()); + stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())); + // stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型 + stationInfo.setToiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())); + stationInfo.setStoreFlag(Integer.valueOf(pileStationInfo.getStoreFlag())); + stationInfo.setRestaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())); + stationInfo.setLoungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())); + stationInfo.setCanopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())); + stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())); + stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())); + stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())); + List pileList = pileBasicInfoService.getPileListForLianLian(stationId); + if (CollectionUtils.isNotEmpty(pileList)) { + stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 + } + resultList.add(stationInfo); + } + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", pageInfo.getTotal()); + map.put("StationInfos", resultList); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 设备接口状态查询 query_station_status + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationStatus(QueryStationInfoDTO dto) { + List stationIds = dto.getStationIds(); + List StationStatusInfos = new ArrayList<>(); + List ConnectorStatusInfos = new ArrayList<>(); + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); + if (configInfo == null) { + return null; + } + ConnectorStatusInfo connectorStatusInfo; + for (String stationId : stationIds) { + StationStatusInfo stationStatusInfo = new StationStatusInfo(); + stationStatusInfo.setStationId(stationId); + // 根据站点id查询 + List list = pileConnectorInfoService.getConnectorListForLianLian(Long.parseLong(stationId)); + for (ConnectorInfoVO connectorInfoVO : list) { + + String connectorStatus = connectorInfoVO.getConnectorStatus(); + if (StringUtils.equals(connectorStatus, PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue())) { + // 充电中 + ConnectorChargeStatusInfo info = new ConnectorChargeStatusInfo(); + OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(connectorInfoVO.getPileConnectorCode()); + if (orderBasicInfo == null) { + continue; + } + List chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(orderBasicInfo.getTransactionCode()); + if (CollectionUtils.isNotEmpty(chargingRealTimeData)) { + RealTimeMonitorData realTimeMonitorData = chargingRealTimeData.get(0); + + info.setStartChargeSeq(orderBasicInfo.getOrderCode()); + info.setConnectorID(orderBasicInfo.getPileConnectorCode()); + info.setConnectorStatus(Integer.valueOf(connectorInfoVO.getConnectorStatus())); + info.setCurrentA(new BigDecimal(realTimeMonitorData.getOutputCurrent())); + info.setVoltageA(new BigDecimal(realTimeMonitorData.getOutputVoltage())); + info.setSoc(new BigDecimal(realTimeMonitorData.getSOC())); + info.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())); + info.setEndTime(DateUtils.getDateTime()); // 本次采样时间 + info.setTotalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())); // 累计充电量 + // info.setElecMoney(); // 累计电费 + // info.setSeviceMoney(); // 累计服务费 + info.setTotalMoney(new BigDecimal(realTimeMonitorData.getChargingAmount())); + + ConnectorStatusInfos.add(info); + } + } else { + // 其他 + connectorStatusInfo = new ConnectorStatusInfo(); + connectorStatusInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + connectorStatusInfo.setStatus(Integer.parseInt(connectorInfoVO.getConnectorStatus())); + + ConnectorStatusInfos.add(connectorStatusInfo); + } + } + stationStatusInfo.setConnectorStatusInfos(ConnectorStatusInfos); + StationStatusInfos.add(stationStatusInfo); + } + // 将 StationStatusInfos 分页 + int pageNum = 1; + int pageSize = 10; + List collect = StationStatusInfos.stream() + .skip((pageNum - 1) * pageSize) + .limit(pageSize) + .collect(Collectors.toList()); + + int total = StationStatusInfos.size(); + int pages = PageUtil.totalPage(total, pageSize); + + Map map = new LinkedHashMap<>(); + map.put("Total", total); + map.put("StationStatusInfos", collect); + + Map resultMap = Maps.newLinkedHashMap(); + // 加密数据 + String encryptData = Cryptos.aesEncrypt(JSON.toJSONString(map), configInfo.getDataSecret(), configInfo.getDataSecretIv()); + resultMap.put("Data", encryptData); + // 生成sig + String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); + resultMap.put("Sig", resultSign); + return resultMap; + } + + /** + * 设备状态变化推送 notification_stationStatus + * 推送充电设备接口状态信息 supervise_notification_station_status + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationStatus(PushRealTimeInfoDTO dto) { + String status = dto.getStatus(); + String pileConnectorCode = dto.getPileConnectorCode(); + + // 查出该桩所属哪个站点 + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn); + // 通过站点id查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getYongChengbochePlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(Integer.parseInt(status)) + .build(); + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 查询业务策略 query_equip_business_policy + * + * @param dto 请求启动充电DTO + * @return + */ + @Override + public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { + List policyInfoList = new ArrayList<>(); + String pileConnectorCode = dto.getConnectorID(); + ThirdPartySecretInfoVO yongChengbochePlatformSecretInfo = getYongChengbochePlatformSecretInfo(); + + // 截取桩号 + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + // 查询该桩的站点id + PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + // 根据桩号查询正在使用的计费模板 + List billingPriceVOList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileBasicInfo.getStationId())); + + if (CollectionUtils.isEmpty(billingPriceVOList)) { + return null; + } + EquipBusinessPolicyVO.PolicyInfo policyInfo = null; + for (BillingPriceVO billingPriceVO : billingPriceVOList) { + // 将时段开始时间、电费、服务费信息进行封装 + policyInfo = new EquipBusinessPolicyVO.PolicyInfo(); + String startTime = billingPriceVO.getStartTime() + ":00"; // 00:00:00 格式 + // 需要将中间的冒号去掉,改为 000000 格式 + String replace = StringUtils.replace(startTime, ":", ""); + policyInfo.setStartTime(replace); + policyInfo.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + policyInfo.setServicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + + policyInfoList.add(policyInfo); + } + + // 拼装所需要的数据格式 + EquipBusinessPolicyVO vo = EquipBusinessPolicyVO.builder() + .equipBizSeq(dto.getEquipBizSeq()) + .connectorId(dto.getConnectorID()) + .succStat(0) + .failReason(0) + .sumPeriod(policyInfoList.size()) + .policyInfos(policyInfoList) + + .build(); + return ThirdPartyPlatformUtils.generateResultMap(vo, yongChengbochePlatformSecretInfo); + } + + /** + * 请求设备认证 + * + * @param dto + * @return + */ + @Override + public Map queryEquipAuth(QueryEquipmentDTO dto) { + Map resultMap = Maps.newLinkedHashMap(); + EquipmentAuthVO vo = new EquipmentAuthVO(); + + String equipAuthSeq = dto.getEquipAuthSeq(); // MA1X78KH5202311071202015732 + String pileConnectorCode = ThirdPartyPlatformUtils.extractConnectorID(dto.getConnectorID()); + // 先查询配置密钥相关信息 + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorID()); + if (configInfo == null) { + return null; + } + // 根据桩编号查询数据 + // String merchantId = StringUtils.substring(equipAuthSeq, 0, 9); + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + // vo.setSuccStat(1); // 1-失败 0-成功 默认失败 + int succStat = 1; + int failReason = 0; + String failReasonMsg = ""; + PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + if (pileBasicInfo != null) { + // 查询当前枪口数据 + PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); + if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), String.valueOf(connectorInfo.getStatus())) + || StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), String.valueOf(connectorInfo.getStatus())) + || StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), String.valueOf(connectorInfo.getStatus())) + ) { + succStat = 0; + failReason = 0; + } else { + succStat = 1; + // 1- 此设备尚未插枪; + failReason = 1; + } + vo.setEquipAuthSeq(equipAuthSeq); + vo.setConnectorID(pileConnectorCode); + } else { + // 设备检测失败 + failReason = 2; + failReasonMsg = "未查到该桩的数据"; + } + vo.setSuccStat(succStat); + vo.setFailReason(failReason); // 设备检测失败 + vo.setFailReasonMsg(failReasonMsg); + // 加密数据 + byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), + configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); + String encryptData = Encodes.encodeBase64(encryptText); + + resultMap.put("Data", encryptData); + // 生成sig + String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); + resultMap.put("Sig", resultSign); + + return resultMap; + } + + /** + * 请求启动充电 query_start_charge + * + * @param dto 请求启动充电DTO + * @return + */ + @Override + public Map queryStartCharge(QueryStartChargeDTO dto) { + // 通过传过来的订单号和枪口号生成订单 + String pileConnectorCode = dto.getConnectorID(); + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq()); + if (orderInfo != null) { + // 平台已存在订单 + return null; + } + ThirdPartySecretInfoVO yongChengbochePlatformSecretInfoVO = getYongChengbochePlatformSecretInfo(); + // 生成订单 + Map map = orderBasicInfoService.generateOrderForThirdParty(dto); + String orderCode = (String) map.get("orderCode"); + String transactionCode = (String) map.get("transactionCode"); + OrderBasicInfo orderBasicInfo = (OrderBasicInfo) map.get("orderBasicInfo"); + + // 发送启机指令 + StartChargingCommand command = StartChargingCommand.builder() + .pileSn(orderBasicInfo.getPileSn()) + .connectorCode(orderBasicInfo.getConnectorCode()) + .transactionCode(transactionCode) + .chargeAmount(orderBasicInfo.getPayAmount()) + .logicCardNum(null) + .physicsCardNum(null) + .build(); + ykcPushCommandService.pushStartChargingCommand(command); + + // 拼装对应的数据并返回 + QueryStartChargeVO vo = QueryStartChargeVO.builder() + .startChargeSeq(orderCode) + .startChargeSeqStat(2) // 1、启动中 ;2、充电中;3、停止中;4、已结束;5、未知 + .connectorID(pileConnectorCode) + .succStat(0) + .failReason(0) + + .build(); + return ThirdPartyPlatformUtils.generateResultMap(vo, yongChengbochePlatformSecretInfoVO); + } + + /** + * 推送启动充电结果 notification_start_charge_result + * + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStartChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getYongChengbochePlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + // 推送启动充电结果(调用接口 notification_start_charge_result) + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue(); + // 拼装参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("StartChargeSeqStat", 2); // 一定要给 2-充电中 + json.put("StartTime", DateUtils.getDateTime()); + + String jsonString = JSON.toJSONString(json); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 查询充电状态 + * + * @param dto 查询充电状态DTO + * @return + */ + @Override + public Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) { + String operatorID = dto.getOperatorID(); + // 通过订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq()); + // logger.info(operatorName + "查询订单信息 orderInfo:{}", orderInfo); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO yongChengbochePlatformSecretInfoVO = getYongChengbochePlatformSecretInfo(); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); + // 通过订单号查询实时数据 + List realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + QueryChargingStatusVO vo; + if (CollectionUtils.isEmpty(realTimeData)) { + vo = new QueryChargingStatusVO(); + } else { + RealTimeMonitorData data = realTimeData.get(0); + String orderStatus = orderInfo.getOrderStatus(); + if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) { + // 充电中 + orderStatus = "2"; + } else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) { + // 充电完成 + orderStatus = "4"; + } else { + // 直接给 5-未知 + orderStatus = "5"; + } + String status = data.getConnectorStatus(); + int connectorStatus = 0; + if (StringUtils.isBlank(status)) { + // 查询当前枪口状态 + PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + connectorStatus = connectorInfoVO.getStatus(); + } else { + connectorStatus = Integer.parseInt(status); + } + BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount(); + BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount(); + // 拼装联联平台数据 + vo = QueryChargingStatusVO.builder() + .startChargeSeq(dto.getStartChargeSeq()) // 订单号 + .startChargeSeqStat(Integer.parseInt(orderStatus)) // 订单状态 + .connectorID(orderInfo.getPileConnectorCode()) // 枪口编码 + .connectorStatus(connectorStatus) // 枪口状态 + .currentA(new BigDecimal(data.getOutputCurrent())) // 电流 + .voltageA(new BigDecimal(data.getOutputVoltage())) // 电压 + .soc(new BigDecimal(data.getSOC())) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) // 开始时间 + .endTime(DateUtils.getDateTime()) // 本次采样时间 + .totalPower(new BigDecimal(data.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计充电量 + .elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费 + .seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费 + .totalMoney(new BigDecimal(data.getChargingAmount())) // 已充金额 + + .build(); + } + return ThirdPartyPlatformUtils.generateResultMap(vo, yongChengbochePlatformSecretInfoVO); + } + + /** + * 推送充电状态 notification_equip_charge_status + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationEquipChargeStatus(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 查询枪口状态 + PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + BigDecimal current = info.getCurrent() == null ? BigDecimal.ZERO : info.getCurrent(); + BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage(); + String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC(); + // 查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getYongChengbochePlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + String dateTime = DateUtils.getDateTime(); + SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() + .operatorID(Constants.OPERATORID_JIANG_SU) + .equipmentOwnerID(Constants.OPERATORID_JIANG_SU) + .stationID(orderInfo.getStationId()) + .equipmentID(orderInfo.getPileSn()) + .connectorID(orderInfo.getPileConnectorCode()) + .orderNo(orderInfo.getOrderCode()) + .orderStatus(2) + .pushTimeStamp(dateTime) + .connectorStatus(info.getStatus()) // 3-充电中 + .currentA(current.setScale(1, BigDecimal.ROUND_HALF_UP)) + .voltageA(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) + .soc(new BigDecimal(soc)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(dateTime) + .totalPower(info.getChargingDegree()) + .eventTime(dateTime) + .chargeVoltage(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) + .chargeCurrent(current.setScale(1, BigDecimal.ROUND_HALF_UP)) + .build(); + + // 查询运营商信息 + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationId()); + String organizationCode = pileMerchantInfoVO.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + supEquipChargeStatusInfo.setEquipmentOwnerID(equipmentOwnerId); + } + + String url = urlAddress + "supervise_notification_equip_charge_status"; + // 调用平台接口 + String jsonString = JSON.toJSONString(supEquipChargeStatusInfo); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 请求停止充电 query_stop_charge + * @param dto + * @return + */ + @Override + public Map queryStopCharge(QueryStartChargeDTO dto) { + QueryStopChargeVO vo = new QueryStopChargeVO(); + String orderCode = dto.getStartChargeSeq(); + + ThirdPartySecretInfoVO yongChengbochePlatformSecretInfo = getYongChengbochePlatformSecretInfo(); + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + // 若状态为充电中,则发送停机指令 + if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderInfo.getOrderStatus())) { + // 充电中 + pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode()); + vo.setStartChargeSeq(orderCode); + vo.setStartChargeSeqStat(4); // 1、启动中 ;2、充电中;3、停止中;4、已结束;5、未知 + } + vo.setSuccStat(0); + vo.setFailReason(0); + + return ThirdPartyPlatformUtils.generateResultMap(vo, yongChengbochePlatformSecretInfo); + } + + /** + * 推送停止充电结果 notification_stop_charge_result + * + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStopChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getYongChengbochePlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STOP_CHARGE_RESULT.getValue(); + + // 拼装联联平台参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("StartChargeSeqStat", 4); // 只能给 4-已结束 + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("SuccStat", 0); + json.put("FailReason", 0); + + String jsonString = JSON.toJSONString(json); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 推送充电站历史充电订单信息 supervise_notification_charge_order_info_history + * + * @param orderCode + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationChargeOrderInfoHistory(String orderCode) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getYongChengbochePlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + "supervise_notification_charge_order_info_history"; + + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + equipmentOwnerID = Constants.OPERATORID_LIANLIAN; + } + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ChargeOrderInfo", orderInfo); + String jsonString = JSON.toJSONString(json); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + + /** + * 获取甬城泊车平台配置密钥信息 + * + * @return + */ + private ThirdPartySecretInfoVO getYongChengbochePlatformSecretInfo() { + // 通过第三方平台类型查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getTypeCode()); + if (thirdPartySecretInfoVO == null) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + return thirdPartySecretInfoVO; + } + + /** + * 转换充电站充电订单信息 + * + * @param orderBasicInfo + * @param orderDetail + * @return + */ + private ChargeOrderInfo transformChargeOrderInfo(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) { + ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder() + .stationID(orderBasicInfo.getStationId()) + .equipmentID(orderBasicInfo.getPileSn()) + .orderNo(orderBasicInfo.getOrderCode()) + .connectorID(orderBasicInfo.getPileConnectorCode()) + .licensePlate(orderBasicInfo.getPlateNumber()) + .vin(orderBasicInfo.getVinCode()) + .startSOC(orderBasicInfo.getStartSoc()) + .endSOC(orderBasicInfo.getEndSoc()) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) + .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) + .totalPower(orderDetail.getTotalUsedElectricity()) + .cuspElect(orderDetail.getSharpUsedElectricity()) + .peakElect(orderDetail.getSharpUsedElectricity()) + .flatElect(orderDetail.getFlatUsedElectricity()) + .valleyElect(orderDetail.getValleyUsedElectricity()) + .pushTimeStamp(DateUtils.getDateTime()) + .totalElecMoney(orderDetail.getTotalElectricityAmount()) + .totalSeviceMoney(orderDetail.getTotalServiceAmount()) + .totalMoney(orderDetail.getTotalOrderAmount()) + .stopReason(0) + .stopDesc(orderBasicInfo.getReason()) // TODO 停止原因 + .sumPeriod(0) + .build(); + return chargeOrderInfo; + } + + /** + * 转换时段充电明细 + * + * @param orderDetail + * @param billingList + * @return + */ + private List transformSupChargeDetails(OrderDetail orderDetail, List billingList) { + List resultList = Lists.newArrayList(); + SupChargeDetails detail; + for (BillingPriceVO billingPriceVO : billingList) { + detail = new SupChargeDetails(); + if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.SHARP.getValue())) { + // 尖时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getSharpUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getSharpElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.PEAK.getValue())) { + // 峰时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getPeakUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.FLAT.getValue())) { + // 平时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getFlatUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.VALLEY.getValue())) { + // 谷时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getValleyUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice()); + } + resultList.add(detail); + } + return resultList; + } +} From 3ce277be2b312a0f2409eafbb48ffaff4c618df6 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Sat, 23 Nov 2024 13:47:40 +0800 Subject: [PATCH 04/12] update --- .../impl/GuiZhouPlatformServiceImpl.java | 14 +- .../impl/XinDiantuPlatfromServicelmpl.java | 914 ++++++++++++++++++ .../YongChengbochePlatfromServicelmpl.java | 6 +- 3 files changed, 917 insertions(+), 17 deletions(-) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServicelmpl.java diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java index 407991493..4bb2cd216 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -40,7 +40,6 @@ import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.platform.domain.*; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; - import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.GBSignUtils; @@ -66,36 +65,26 @@ import java.util.stream.Collectors; @Service public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { private final String thirdPlatformType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode(); - + Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private PileStationInfoService pileStationInfoService; - @Autowired private ThirdPartyStationRelationService thirdPartyStationRelationService; - @Autowired private ThirdpartySecretInfoService thirdpartySecretInfoService; - @Autowired private PileBasicInfoService pileBasicInfoService; - @Autowired private PileMerchantInfoService pileMerchantInfoService; - @Autowired private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; - @Autowired private PileConnectorInfoService pileConnectorInfoService; - @Autowired private OrderBasicInfoService orderBasicInfoService; - @Autowired private PileBillingTemplateService pileBillingTemplateService; - Logger logger = LoggerFactory.getLogger(this.getClass()); - @Override public void afterPropertiesSet() throws Exception { ThirdPartyPlatformFactory.register(thirdPlatformType, this); @@ -794,6 +783,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { /** * 获取贵州省平台配置密钥信息 + * * @return */ private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() { diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServicelmpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServicelmpl.java new file mode 100644 index 000000000..0eea30caa --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServicelmpl.java @@ -0,0 +1,914 @@ +package com.jsowell.thirdparty.platform.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; +import com.jsowell.common.enums.ykc.OrderStatusEnum; +import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.util.*; +import com.jsowell.pile.domain.OrderBasicInfo; +import com.jsowell.pile.domain.OrderDetail; +import com.jsowell.pile.domain.PileBasicInfo; +import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; +import com.jsowell.pile.dto.*; +import com.jsowell.pile.service.*; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.util.MerchantUtils; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; +import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO; +import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileMerchantInfoVO; +import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; +import com.jsowell.thirdparty.lianlian.domain.ConnectorStatsInfo; +import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; +import com.jsowell.thirdparty.lianlian.domain.EquipmentStatsInfo; +import com.jsowell.thirdparty.lianlian.domain.StationStatsInfo; +import com.jsowell.thirdparty.lianlian.vo.*; +import com.jsowell.thirdparty.platform.domain.ChargeOrderInfo; +import com.jsowell.thirdparty.platform.domain.SupChargeDetails; +import com.jsowell.thirdparty.platform.domain.SupEquipChargeStatusInfo; +import com.jsowell.thirdparty.platform.domain.SupStationInfo; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.*; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 新电途 + */ +@Service +public class XinDiantuPlatfromServicelmpl implements ThirdPartyPlatformService { + private final String thirdPlatformType = ThirdPlatformTypeEnum.XIN_DIAN_TU.getTypeCode(); + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private PileStationInfoService pileStationInfoService; + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + @Autowired + private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + + @Autowired + private YKCPushCommandService ykcPushCommandService; + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + @Autowired + private PileMerchantInfoService pileMerchantInfoService; + + @Autowired + private PileRemoteService pileRemoteService; + + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + /** + * query_token 获取token,提供给第三方平台使用 + * + * @param dto + * @return + */ + @Override + public Map queryToken(CommonParamsDTO dto) { + AccessTokenVO vo = new AccessTokenVO(); + // 0:成功;1:失败 + int succStat = 0; + // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + int failReason = 0; + + String operatorId = dto.getPlatformID(); + // 通过operatorId 查出 operatorSecret + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (thirdPartySecretInfoVO == null) { + failReason = 1; + succStat = 1; + } else { + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + String inputOperatorSecret = null; + if (StringUtils.isNotBlank(decrypt)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); + } + // 对比密钥 + if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) { + failReason = 1; + succStat = 1; + } else { + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); + vo.setAccessToken(token); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + } + } + // 组装返回参数 + vo.setPlatformId(operatorId); + vo.setFailReason(failReason); + vo.setSuccStat(succStat); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 查询充电站信息 query_stations_info + * 此接口用于查询对接平台的充电站的信息 + * + * @param dto 查询站点信息dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); + int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); + + PageUtils.startPage(pageNo, pageSize); + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); + if (CollectionUtils.isEmpty(stationInfos)) { + // 未查到数据 + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinDiantuPlatformSecretInfo(); + + PageInfo pageInfo = new PageInfo<>(stationInfos); + List resultList = new ArrayList<>(); + for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { + SupStationInfo stationInfo = new SupStationInfo(); + String stationId = String.valueOf(pileStationInfo.getId()); + stationInfo.setStationID(stationId); + // MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfo(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setOperatorID(Constants.OPERATORID_LIANLIAN); // 组织机构代码 + stationInfo.setEquipmentOwnerID(String.valueOf(pileStationInfo.getMerchantId())); + stationInfo.setStationName(pileStationInfo.getStationName()); + stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())); + stationInfo.setIsPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())); + stationInfo.setCountryCode(pileStationInfo.getCountryCode()); + stationInfo.setAreaCode(pileStationInfo.getAreaCode()); + stationInfo.setAddress(pileStationInfo.getAddress()); + stationInfo.setServiceTel(pileStationInfo.getStationTel()); + stationInfo.setStationType(Integer.valueOf(pileStationInfo.getStationType())); + stationInfo.setParkNums(Integer.valueOf(pileStationInfo.getParkNums())); + stationInfo.setStationLng(new BigDecimal(pileStationInfo.getStationLng())); + stationInfo.setStationLat(new BigDecimal(pileStationInfo.getStationLat())); + stationInfo.setConstruction(Integer.valueOf(pileStationInfo.getConstruction())); + stationInfo.setOpenAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())); + // stationInfo.setMinElectricityPrice(pileStationInfo); // 最低充电电费率 + // stationInfo.setElectricityFee(); // 电费 xx元/度 + // stationInfo.setServiceFee(); // 服务费 xx元/度 + stationInfo.setParkFree(Integer.valueOf(pileStationInfo.getParkFree())); + stationInfo.setPayment(pileStationInfo.getPayment()); + stationInfo.setSupportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())); + // stationInfo.setParkFeeType(pileStationInfo); // 停车收费类型 + stationInfo.setToiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())); + stationInfo.setStoreFlag(Integer.valueOf(pileStationInfo.getStoreFlag())); + stationInfo.setRestaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())); + stationInfo.setLoungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())); + stationInfo.setCanopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())); + stationInfo.setPrinterFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())); + stationInfo.setBarrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())); + stationInfo.setParkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())); + List pileList = pileBasicInfoService.getPileListForLianLian(stationId); + if (CollectionUtils.isNotEmpty(pileList)) { + stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 + } + resultList.add(stationInfo); + } + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", pageInfo.getTotal()); + map.put("StationInfos", resultList); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 查询统计信息 query_station_stats + * + * @param dto 查询站点信息dto + * @return + */ + @Override + public Map queryStationStats(QueryStationInfoDTO dto) { + ThirdPartySecretInfoVO ningBoSecretInfoVO = getXinDiantuPlatformSecretInfo(); + // 根据站点id 查出这段时间的充电量 + List list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto); + if (CollectionUtils.isEmpty(list)) { + return null; + } + + // 根据充电桩编号分组 key=充电桩编号 + Map> pileMap = list.stream() + .collect(Collectors.groupingBy(AccumulativeInfoVO::getPileSn)); + + // 存放所有充电桩设备 + List equipmentStatsInfoList = Lists.newArrayList(); + // 站点用电量 + BigDecimal stationElectricity = BigDecimal.ZERO; + // 用于记录枪口用电量 在循环每个枪口的时候初始化 + BigDecimal pileElec; + for (String pileSn : pileMap.keySet()) { + // 该充电桩下 所有枪口的用电数据 + List accumulativeInfoVOS = pileMap.get(pileSn); + if (CollectionUtils.isEmpty(accumulativeInfoVOS)) { + continue; + } + + // 存放充电桩用电量 + pileElec = BigDecimal.ZERO; + + // key=枪口编号 value 该枪口的用电数据 + Map> collect = accumulativeInfoVOS.stream() + .collect(Collectors.groupingBy(AccumulativeInfoVO::getPileConnectorCode)); + + List connectorStatsInfos = Lists.newArrayList(); + for (Map.Entry> entry : collect.entrySet()) { + String pileConnectorCode = entry.getKey(); + List value = entry.getValue(); + // 枪口用电量求和 + BigDecimal connectorElec = value.stream() + .map(AccumulativeInfoVO::getConnectorElectricity) + .map(BigDecimal::new) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + connectorStatsInfos.add( + ConnectorStatsInfo.builder() + .connectorID(pileConnectorCode) + .connectorElectricity(connectorElec) + .build() + ); + // 充电桩电量为枪口用电量累计 + pileElec = pileElec.add(connectorElec); + } + + EquipmentStatsInfo build = EquipmentStatsInfo.builder() + .equipmentID(pileSn) + .equipmentElectricity(pileElec) + .connectorStatsInfos(connectorStatsInfos) + .build(); + equipmentStatsInfoList.add(build); + + // 所有充电桩用电量之和 + stationElectricity = stationElectricity.add(pileElec); + } + + StationStatsInfo stationStatsInfo = StationStatsInfo.builder() + .stationID(dto.getStationID()) + .startTime(dto.getStartTime()) + .endTime(dto.getEndTime()) + .stationElectricity(stationElectricity) + .equipmentStatsInfos(equipmentStatsInfoList) // 设备列表 + .build(); + + Map map = new LinkedHashMap<>(); + map.put("StationStats", stationStatsInfo); + + return ThirdPartyPlatformUtils.generateResultMap(map, ningBoSecretInfoVO); + } + + /** + * 请求设备认证 + * + * @param dto + * @return + */ + @Override + public Map queryEquipAuth(QueryEquipmentDTO dto) { + Map resultMap = Maps.newLinkedHashMap(); + EquipmentAuthVO vo = new EquipmentAuthVO(); + + String equipAuthSeq = dto.getEquipAuthSeq(); // MA1X78KH5202311071202015732 + String pileConnectorCode = ThirdPartyPlatformUtils.extractConnectorID(dto.getConnectorID()); + // 先查询配置密钥相关信息 + ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorID()); + if (configInfo == null) { + return null; + } + // 根据桩编号查询数据 + // String merchantId = StringUtils.substring(equipAuthSeq, 0, 9); + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + // vo.setSuccStat(1); // 1-失败 0-成功 默认失败 + int succStat = 1; + int failReason = 0; + String failReasonMsg = ""; + PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + if (pileBasicInfo != null) { + // 查询当前枪口数据 + PileConnectorInfoVO connectorInfo = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(pileConnectorCode); + if (StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), String.valueOf(connectorInfo.getStatus())) + || StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_CHARGING.getValue(), String.valueOf(connectorInfo.getStatus())) + || StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_RESERVED_LOCK.getValue(), String.valueOf(connectorInfo.getStatus())) + ) { + succStat = 0; + failReason = 0; + } else { + succStat = 1; + // 1- 此设备尚未插枪; + failReason = 1; + } + vo.setEquipAuthSeq(equipAuthSeq); + vo.setConnectorID(pileConnectorCode); + } else { + // 设备检测失败 + failReason = 2; + failReasonMsg = "未查到该桩的数据"; + } + vo.setSuccStat(succStat); + vo.setFailReason(failReason); // 设备检测失败 + vo.setFailReasonMsg(failReasonMsg); + // 加密数据 + byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), + configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes()); + String encryptData = Encodes.encodeBase64(encryptText); + + resultMap.put("Data", encryptData); + // 生成sig + String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret()); + resultMap.put("Sig", resultSign); + + return resultMap; + } + + /** + * 请求启动充电 query_start_charge + * + * @param dto 请求启动充电DTO + * @return + */ + @Override + public Map queryStartCharge(QueryStartChargeDTO dto) { + // 通过传过来的订单号和枪口号生成订单 + String pileConnectorCode = dto.getConnectorID(); + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq()); + if (orderInfo != null) { + // 平台已存在订单 + return null; + } + ThirdPartySecretInfoVO xindiantuPlatformSecretInfoVO = getXinDiantuPlatformSecretInfo(); + // 生成订单 + Map map = orderBasicInfoService.generateOrderForThirdParty(dto); + String orderCode = (String) map.get("orderCode"); + String transactionCode = (String) map.get("transactionCode"); + OrderBasicInfo orderBasicInfo = (OrderBasicInfo) map.get("orderBasicInfo"); + + // 发送启机指令 + StartChargingCommand command = StartChargingCommand.builder() + .pileSn(orderBasicInfo.getPileSn()) + .connectorCode(orderBasicInfo.getConnectorCode()) + .transactionCode(transactionCode) + .chargeAmount(orderBasicInfo.getPayAmount()) + .logicCardNum(null) + .physicsCardNum(null) + .build(); + ykcPushCommandService.pushStartChargingCommand(command); + + // 拼装对应的数据并返回 + QueryStartChargeVO vo = QueryStartChargeVO.builder() + .startChargeSeq(orderCode) + .startChargeSeqStat(2) // 1、启动中 ;2、充电中;3、停止中;4、已结束;5、未知 + .connectorID(pileConnectorCode) + .succStat(0) + .failReason(0) + + .build(); + return ThirdPartyPlatformUtils.generateResultMap(vo, xindiantuPlatformSecretInfoVO); + } + + /** + * 查询业务策略 query_equip_business_policy + * + * @param dto 请求启动充电DTO + * @return + */ + @Override + public Map queryEquipBusinessPolicy(QueryStartChargeDTO dto) { + List policyInfoList = new ArrayList<>(); + String pileConnectorCode = dto.getConnectorID(); + ThirdPartySecretInfoVO xinDiantuPlatformSecretInfo = getXinDiantuPlatformSecretInfo(); + + // 截取桩号 + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + // 查询该桩的站点id + PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn); + // 根据桩号查询正在使用的计费模板 + List billingPriceVOList = pileBillingTemplateService.queryBillingPrice(String.valueOf(pileBasicInfo.getStationId())); + + if (CollectionUtils.isEmpty(billingPriceVOList)) { + return null; + } + EquipBusinessPolicyVO.PolicyInfo policyInfo = null; + for (BillingPriceVO billingPriceVO : billingPriceVOList) { + // 将时段开始时间、电费、服务费信息进行封装 + policyInfo = new EquipBusinessPolicyVO.PolicyInfo(); + String startTime = billingPriceVO.getStartTime() + ":00"; // 00:00:00 格式 + // 需要将中间的冒号去掉,改为 000000 格式 + String replace = StringUtils.replace(startTime, ":", ""); + policyInfo.setStartTime(replace); + policyInfo.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + policyInfo.setServicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + + policyInfoList.add(policyInfo); + } + + // 拼装所需要的数据格式 + EquipBusinessPolicyVO vo = EquipBusinessPolicyVO.builder() + .equipBizSeq(dto.getEquipBizSeq()) + .connectorId(dto.getConnectorID()) + .succStat(0) + .failReason(0) + .sumPeriod(policyInfoList.size()) + .policyInfos(policyInfoList) + + .build(); + return ThirdPartyPlatformUtils.generateResultMap(vo, xinDiantuPlatformSecretInfo); + } + + /** + * 设备状态变化推送 notification_stationStatus + * 推送充电设备接口状态信息 supervise_notification_station_status + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationStatus(PushRealTimeInfoDTO dto) { + String status = dto.getStatus(); + String pileConnectorCode = dto.getPileConnectorCode(); + + // 查出该桩所属哪个站点 + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn); + // 通过站点id查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinDiantuPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(Integer.parseInt(status)) + .build(); + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 推送充电订单信息 + * supervise_notification_charge_order_info + */ + @Override + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + // 根据订单号查询出信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderBasicInfo == null) { + return null; + } + + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = secretInfoVO.getTheirOperatorSecret(); + String signSecret = secretInfoVO.getTheirSigSecret(); + String dataSecret = secretInfoVO.getTheirDataSecret(); + String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); + String urlAddress = secretInfoVO.getTheirUrlPrefix(); + + // 根据订单号查询订单详情 + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + if (orderDetail == null) { + return null; + } + + // 推送地址 + String url = urlAddress + "supervise_notification_charge_order_info"; + + // 拼装成平台所需格式对象 + ChargeOrderInfo orderInfo = transformChargeOrderInfo(orderBasicInfo, orderDetail); + orderInfo.setOperatorID(operatorId); + String equipmentOwnerID; + if (MerchantUtils.isXiXiaoMerchant(orderBasicInfo.getMerchantId())) { + equipmentOwnerID = Constants.OPERATORID_XI_XIAO; + } else { + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationID()); + String organizationCode = pileMerchantInfoVO.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + equipmentOwnerID = ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileMerchantInfoVO.getOrganizationCode()); + } else { + equipmentOwnerID = Constants.OPERATORID_JIANG_SU; + } + } + orderInfo.setEquipmentOwnerID(equipmentOwnerID); + + List billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId()); + // 先将list按照 尖、峰、平、谷 时段排序 + // List collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList()); + // 再循环该list,拼装对应的充电价格、费率 + List chargeDetails = transformSupChargeDetails(orderDetail, billingList); + orderInfo.setChargeDetails(chargeDetails); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + // 调用联联平台接口 + String jsonString = JSON.toJSONString(orderInfo); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 查询充电状态 + * + * @param dto 查询充电状态DTO + * @return + */ + @Override + public Map queryEquipChargeStatus(QueryEquipChargeStatusDTO dto) { + String operatorID = dto.getOperatorID(); + // 通过订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getStartChargeSeq()); + // logger.info(operatorName + "查询订单信息 orderInfo:{}", orderInfo); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO xinDiantuPlatformSecretInfo = getXinDiantuPlatformSecretInfo(); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode()); + // 通过订单号查询实时数据 + List realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode()); + QueryChargingStatusVO vo; + if (CollectionUtils.isEmpty(realTimeData)) { + vo = new QueryChargingStatusVO(); + } else { + RealTimeMonitorData data = realTimeData.get(0); + String orderStatus = orderInfo.getOrderStatus(); + if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) { + // 充电中 + orderStatus = "2"; + } else if (StringUtils.equals(orderStatus, OrderStatusEnum.ORDER_COMPLETE.getValue())) { + // 充电完成 + orderStatus = "4"; + } else { + // 直接给 5-未知 + orderStatus = "5"; + } + String status = data.getConnectorStatus(); + int connectorStatus = 0; + if (StringUtils.isBlank(status)) { + // 查询当前枪口状态 + PileConnectorInfoVO connectorInfoVO = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + connectorStatus = connectorInfoVO.getStatus(); + } else { + connectorStatus = Integer.parseInt(status); + } + BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalElectricityAmount(); + BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount() == null ? BigDecimal.ZERO : orderDetail.getTotalServiceAmount(); + // 拼装联联平台数据 + vo = QueryChargingStatusVO.builder() + .startChargeSeq(dto.getStartChargeSeq()) // 订单号 + .startChargeSeqStat(Integer.parseInt(orderStatus)) // 订单状态 + .connectorID(orderInfo.getPileConnectorCode()) // 枪口编码 + .connectorStatus(connectorStatus) // 枪口状态 + .currentA(new BigDecimal(data.getOutputCurrent())) // 电流 + .voltageA(new BigDecimal(data.getOutputVoltage())) // 电压 + .soc(new BigDecimal(data.getSOC())) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) // 开始时间 + .endTime(DateUtils.getDateTime()) // 本次采样时间 + .totalPower(new BigDecimal(data.getChargingDegree()).setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计充电量 + .elecMoney(totalElectricityAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计电费 + .seviceMoney(totalServiceAmount.setScale(2, BigDecimal.ROUND_HALF_UP)) // 累计服务费 + .totalMoney(new BigDecimal(data.getChargingAmount())) // 已充金额 + + .build(); + } + return ThirdPartyPlatformUtils.generateResultMap(vo, xinDiantuPlatformSecretInfo); + } + + /** + * 请求停止充电 query_stop_charge + * + * @param dto + * @return + */ + @Override + public Map queryStopCharge(QueryStartChargeDTO dto) { + QueryStopChargeVO vo = new QueryStopChargeVO(); + String orderCode = dto.getStartChargeSeq(); + + ThirdPartySecretInfoVO xinDiantuPlatformSecretInfo = getXinDiantuPlatformSecretInfo(); + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + // 若状态为充电中,则发送停机指令 + if (StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderInfo.getOrderStatus())) { + // 充电中 + pileRemoteService.remoteStopCharging(orderInfo.getPileSn(), orderInfo.getConnectorCode(), orderInfo.getTransactionCode()); + vo.setStartChargeSeq(orderCode); + vo.setStartChargeSeqStat(4); // 1、启动中 ;2、充电中;3、停止中;4、已结束;5、未知 + } + vo.setSuccStat(0); + vo.setFailReason(0); + + return ThirdPartyPlatformUtils.generateResultMap(vo, xinDiantuPlatformSecretInfo); + } + + /** + * 推送启动充电结果 notification_start_charge_result + * + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStartChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinDiantuPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + // 推送启动充电结果(调用接口 notification_start_charge_result) + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue(); + // 拼装参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("StartChargeSeqStat", 2); // 一定要给 2-充电中 + json.put("StartTime", DateUtils.getDateTime()); + + String jsonString = JSON.toJSONString(json); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 推送停止充电结果 notification_stop_charge_result + * + * @param orderCode 订单编号 + * @return + */ + @Override + public String notificationStopChargeResult(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderInfo == null) { + return null; + } + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinDiantuPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STOP_CHARGE_RESULT.getValue(); + + // 拼装联联平台参数 + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("StartChargeSeqStat", 4); // 只能给 4-已结束 + json.put("ConnectorID", orderInfo.getPileConnectorCode()); + json.put("SuccStat", 0); + json.put("FailReason", 0); + + String jsonString = JSON.toJSONString(json); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + /** + * 推送充电状态 notification_equip_charge_status + * + * @param orderCode 订单编号 + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationEquipChargeStatus(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 查询枪口状态 + PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(orderInfo.getPileConnectorCode()); + BigDecimal current = info.getCurrent() == null ? BigDecimal.ZERO : info.getCurrent(); + BigDecimal voltage = info.getVoltage() == null ? BigDecimal.ZERO : info.getVoltage(); + String soc = info.getSOC() == null ? Constants.ZERO : info.getSOC(); + // 查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinDiantuPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + String dateTime = DateUtils.getDateTime(); + SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() + .operatorID(Constants.OPERATORID_JIANG_SU) + .equipmentOwnerID(Constants.OPERATORID_JIANG_SU) + .stationID(orderInfo.getStationId()) + .equipmentID(orderInfo.getPileSn()) + .connectorID(orderInfo.getPileConnectorCode()) + .orderNo(orderInfo.getOrderCode()) + .orderStatus(2) + .pushTimeStamp(dateTime) + .connectorStatus(info.getStatus()) // 3-充电中 + .currentA(current.setScale(1, BigDecimal.ROUND_HALF_UP)) + .voltageA(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) + .soc(new BigDecimal(soc)) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) + .endTime(dateTime) + .totalPower(info.getChargingDegree()) + .eventTime(dateTime) + .chargeVoltage(voltage.setScale(1, BigDecimal.ROUND_HALF_UP)) + .chargeCurrent(current.setScale(1, BigDecimal.ROUND_HALF_UP)) + .build(); + + // 查询运营商信息 + PileMerchantInfoVO pileMerchantInfoVO = pileMerchantInfoService.queryMerchantInfoByStationId(orderInfo.getStationId()); + String organizationCode = pileMerchantInfoVO.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + supEquipChargeStatusInfo.setEquipmentOwnerID(equipmentOwnerId); + } + + String url = urlAddress + "supervise_notification_equip_charge_status"; + // 调用平台接口 + String jsonString = JSON.toJSONString(supEquipChargeStatusInfo); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 获取新电途平台配置密钥信息 + * + * @return + */ + private ThirdPartySecretInfoVO getXinDiantuPlatformSecretInfo() { + // 通过第三方平台类型查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.XIN_DIAN_TU.getTypeCode()); + if (thirdPartySecretInfoVO == null) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + return thirdPartySecretInfoVO; + } + + /** + * 转换充电站充电订单信息 + * + * @param orderBasicInfo + * @param orderDetail + * @return + */ + private ChargeOrderInfo transformChargeOrderInfo(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) { + ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder() + .stationID(orderBasicInfo.getStationId()) + .equipmentID(orderBasicInfo.getPileSn()) + .orderNo(orderBasicInfo.getOrderCode()) + .connectorID(orderBasicInfo.getPileConnectorCode()) + .licensePlate(orderBasicInfo.getPlateNumber()) + .vin(orderBasicInfo.getVinCode()) + .startSOC(orderBasicInfo.getStartSoc()) + .endSOC(orderBasicInfo.getEndSoc()) + .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) + .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) + .totalPower(orderDetail.getTotalUsedElectricity()) + .cuspElect(orderDetail.getSharpUsedElectricity()) + .peakElect(orderDetail.getSharpUsedElectricity()) + .flatElect(orderDetail.getFlatUsedElectricity()) + .valleyElect(orderDetail.getValleyUsedElectricity()) + .pushTimeStamp(DateUtils.getDateTime()) + .totalElecMoney(orderDetail.getTotalElectricityAmount()) + .totalSeviceMoney(orderDetail.getTotalServiceAmount()) + .totalMoney(orderDetail.getTotalOrderAmount()) + .stopReason(0) + .stopDesc(orderBasicInfo.getReason()) // TODO 停止原因 + .sumPeriod(0) + .build(); + return chargeOrderInfo; + } + + /** + * 转换时段充电明细 + * + * @param orderDetail + * @param billingList + * @return + */ + private List transformSupChargeDetails(OrderDetail orderDetail, List billingList) { + List resultList = Lists.newArrayList(); + SupChargeDetails detail; + for (BillingPriceVO billingPriceVO : billingList) { + detail = new SupChargeDetails(); + if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.SHARP.getValue())) { + // 尖时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getSharpUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getSharpElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.PEAK.getValue())) { + // 峰时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getPeakUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.FLAT.getValue())) { + // 平时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getFlatUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice()); + } else if (StringUtils.equals(billingPriceVO.getTimeType(), BillingTimeTypeEnum.VALLEY.getValue())) { + // 谷时段 + detail.setDetailStartTime(billingPriceVO.getStartTime()); + detail.setDetailEndTime(billingPriceVO.getEndTime()); + detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); + detail.setDetailPower(orderDetail.getValleyUsedElectricity()); + detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice()); + detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice()); + } + resultList.add(detail); + } + return resultList; + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java index 429764302..ee33af942 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java @@ -9,7 +9,6 @@ import com.google.common.collect.Maps; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; -import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; import com.jsowell.common.enums.ykc.OrderStatusEnum; @@ -29,9 +28,7 @@ import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.pile.util.MerchantUtils; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO; -import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; -import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileMerchantInfoVO; @@ -47,8 +44,6 @@ import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.util.*; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; import org.apache.commons.collections4.CollectionUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -683,6 +678,7 @@ public class YongChengbochePlatfromServicelmpl implements ThirdPartyPlatformServ /** * 请求停止充电 query_stop_charge + * * @param dto * @return */ From 0a23c947d4dd876b290224ea82f9207663807808 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Sat, 23 Nov 2024 15:22:32 +0800 Subject: [PATCH 05/12] update --- .../thirdparty/ThirdPlatformTypeEnum.java | 1 + .../service/ThirdPartyPlatformService.java | 10 + .../impl/NanRuiPlatfromServicelmp.java | 738 ++++++++++++++++++ 3 files changed, 749 insertions(+) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index f8a054c6f..ff74716db 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -27,6 +27,7 @@ public enum ThirdPlatformTypeEnum { SU_ZHOU_PLATFORM("16", "苏州市平台", "MAC1MFJ1X"), GAN_SU_PLATFORM("17", "甘肃省平台", ""), GUI_ZHOU_PLATFORM("18", "贵州省平台", ""), + NAN_RUI_PLATFORM("19", "南瑞平台", ""), ; private String typeCode; diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java index 9e1eb30f9..3c5decb1f 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java @@ -405,6 +405,16 @@ public interface ThirdPartyPlatformService extends InitializingBean { throw new UnsupportedOperationException("This method is not yet implemented"); } + /** + * 充电电量信息推送 + * 当运营商平台完成一次充电时,将充电电量信息推送至省、市两级监管平台 + * @param orderCode + * @return + */ + default String pushOrderInfo(String orderCode) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + // -------------------------------------- 以下是公用方法 --------------------------------------- // /** * 从联联平台获取令牌 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java new file mode 100644 index 000000000..3b8fc8a1b --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java @@ -0,0 +1,738 @@ +package com.jsowell.thirdparty.platform.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jsowell.common.constant.CacheConstants; +import com.jsowell.common.constant.Constants; +import com.jsowell.common.enums.lianlian.StationPaymentEnum; +import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.enums.ykc.PileStatusEnum; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.common.util.*; +import com.jsowell.pile.domain.*; +import com.jsowell.pile.domain.nanrui.JiangSuOrderInfo; +import com.jsowell.pile.dto.PushRealTimeInfoDTO; +import com.jsowell.pile.dto.QueryConnectorListDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO; +import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO; +import com.jsowell.pile.service.*; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.pile.vo.base.MerchantInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import com.jsowell.pile.vo.nanrui.JiangSuOrderInfoVO; +import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails; +import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.PileModelInfoVO; +import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; +import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; +import com.jsowell.thirdparty.nanrui.domain.*; +import com.jsowell.thirdparty.platform.domain.SupStationInfo; +import com.jsowell.thirdparty.platform.dto.QueryOrderDTO; +import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.util.Cryptos; +import com.jsowell.thirdparty.platform.util.HttpRequestUtil; +import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; +import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; +import com.yi.business.geo.GeoCodeInfo; +import com.yi.business.geo.TermRelationTreeCoordinate; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.jsowell.common.core.redis.RedisCache; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 南瑞 + */ +@Service +public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { + + private final String thirdPlatformType = ThirdPlatformTypeEnum.NAN_RUI_PLATFORM.getTypeCode(); + + @Autowired + private ThirdpartySecretInfoService thirdpartySecretInfoService; + + @Autowired + private PileBasicInfoService pileBasicInfoService; + + @Autowired + private PileStationInfoService pileStationInfoService; + + @Autowired + private PileMerchantInfoService pileMerchantInfoService; + + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + @Autowired + private PileConnectorInfoService pileConnectorInfoService; + + @Autowired + private PileModelInfoService pileModelInfoService; + + @Autowired + private RedisCache redisCache; + + @Autowired + private OrderBasicInfoService orderBasicInfoService; + + @Autowired + private ThirdPartyStationRelationService thirdPartyStationRelationService; + + + @Override + public void afterPropertiesSet() throws Exception { + ThirdPartyPlatformFactory.register(thirdPlatformType, this); + } + + /** + * query_token 获取token,提供给第三方平台使用 + * + * @param dto + * @return + */ + @Override + public Map queryToken(CommonParamsDTO dto) { + AccessTokenVO vo = new AccessTokenVO(); + // 0:成功;1:失败 + int succStat = 0; + // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 + int failReason = 0; + + String operatorId = dto.getPlatformID(); + // 通过operatorId 查出 operatorSecret + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + if (thirdPartySecretInfoVO == null) { + failReason = 1; + succStat = 1; + } else { + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); + // 解密data 获取参数中的OperatorSecret + String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); + String inputOperatorSecret = null; + if (StringUtils.isNotBlank(decrypt)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); + } + // 对比密钥 + if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) { + failReason = 1; + succStat = 1; + } else { + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); + vo.setAccessToken(token); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + } + } + // 组装返回参数 + vo.setPlatformId(operatorId); + vo.setFailReason(failReason); + vo.setSuccStat(succStat); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + return resultMap; + } + + /** + * 推送充电站信息 + * supervise_notification_station_info + */ + @Override + public String notificationStationInfo(String stationId) { + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); + + // 查询第三方平台配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNanRuiPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + // 组装所需要的数据格式 + SupStationInfo info = SupStationInfo.builder() + .stationID(stationId) + .operatorID(operatorId) + .stationName(pileStationInfo.getStationName()) + .isAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())) + .isPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())) + .countryCode(pileStationInfo.getCountryCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationType(Integer.valueOf(pileStationInfo.getStationType())) + .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) + .parkNums(Integer.valueOf(pileStationInfo.getParkNums())) + .stationLng(new BigDecimal(pileStationInfo.getStationLng())) + .stationLat(new BigDecimal(pileStationInfo.getStationLat())) + .construction(Integer.valueOf(pileStationInfo.getConstruction())) + .openAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())) + .minElectricityPrice(new BigDecimal(Constants.ZERO)) + .electricityFee(Constants.ZERO) + .serviceFee(Constants.ZERO) + .parkFree(Integer.valueOf(pileStationInfo.getParkFree())) + .supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())) + .parkFeeType(0) + .toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())) + .storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag())) + .restaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())) + .loungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())) + .canopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())) + .printerFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())) + .barrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())) + .parkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())) + .build(); + String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 + // 根据逗号分组 + String[] split = StringUtils.split(areaCode, ","); + // 只取最后一部分 330213 + String subAreaCode = split[split.length - 1]; + info.setAreaCode(subAreaCode); + // 截取运营商组织机构代码(去除最后一位后的最后九位) + String organizationCode = ""; + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(), thirdPlatformType)) { + // 联联平台先使用自己运营商的组织机构代码 + organizationCode = Constants.OPERATORID_LIANLIAN; + info.setEquipmentOwnerID(organizationCode); + } else { + MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId())); + organizationCode = merchantInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + info.setEquipmentOwnerID(equipmentOwnerId); + } + } + + info.setPayment(StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment())); + if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) { + info.setIsPublicParkingLot(1); + info.setParkingLotNumber(pileStationInfo.getParkingNumber()); + } + // 户号 + if (StringUtils.isNotBlank(pileStationInfo.getAccountNumber())) { + info.setAccountNumber(pileStationInfo.getAccountNumber()); + } + + // 容量 + if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getCapacity()))) { + info.setCapacity(pileStationInfo.getCapacity().setScale(4, RoundingMode.HALF_UP)); + } + List pileList = pileBasicInfoService.getPileListForLianLian(stationId); + if (CollectionUtils.isNotEmpty(pileList)) { + info.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + // areaCodeCountryside + GeoCodeInfo geoCode = TermRelationTreeCoordinate.completeGeoCode(pileStationInfo.getAddress()); + if (geoCode != null) { + String areaCodeCountryside = geoCode.getCounty_code(); + info.setAreaCodeCountryside(areaCodeCountryside); + } + + // 调用联联平台接口 + String url = urlAddress + "supervise_notification_station_info"; + + JSONObject data = new JSONObject(); + data.put("SupStationInfo", info); + + String jsonString = JSON.toJSONString(info); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 获取充电站信息 + * @param dto + * @return + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + List resultList = new ArrayList<>(); + int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); + int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); + + PageUtils.startPage(pageNo, pageSize); + List stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); + if (CollectionUtils.isEmpty(stationInfos)) { + // 未查到数据 + return null; + } + ThirdPartySecretInfoVO NanRuiSecretInfo = getNanRuiPlatformSecretInfo(); + + PageInfo pageInfo = new PageInfo<>(stationInfos); + for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { + // 拼装参数 + NRStationInfo nrStationInfo = NRStationInfo.builder() + .stationId(String.valueOf(pileStationInfo.getId())) + .operatorID(Constants.OPERATORID_JIANG_SU) + .equipmentOwnerID(Constants.OPERATORID_JIANG_SU) + .stationName(pileStationInfo.getStationName()) + .countryCode(pileStationInfo.getCountryCode()) + .areaCode(pileStationInfo.getAreaCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationStatus(Integer.parseInt(pileStationInfo.getStationStatus())) + .parkNums(0) + .stationLng(new BigDecimal(pileStationInfo.getStationLng()).setScale(6, BigDecimal.ROUND_HALF_UP)) + .stationLat(new BigDecimal(pileStationInfo.getStationLat()).setScale(6, BigDecimal.ROUND_HALF_UP)) + .openForBusinessDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileStationInfo.getCreateTime())) + .openAllDay(Integer.parseInt(pileStationInfo.getOpenAllDay())) + .busineHours(pileStationInfo.getBusinessHours()) + .build(); + // 站点费率 + // 查计费模板 + CurrentTimePriceDetails currentTimePriceDetails = pileBillingTemplateService.getCurrentTimePriceDetails(String.valueOf(pileStationInfo.getId())); + if (currentTimePriceDetails == null) { + // 未设置计费模板 + continue; + } + String electricityPrice = currentTimePriceDetails.getElectricityPrice(); + electricityPrice = StringUtils.isBlank(electricityPrice) ? "0" : electricityPrice; + + String servicePrice = currentTimePriceDetails.getServicePrice(); + servicePrice = StringUtils.isBlank(servicePrice) ? "0" : servicePrice; + + BigDecimal price = new BigDecimal(electricityPrice).add(new BigDecimal(servicePrice)); + nrStationInfo.setMinElectricityPrice(price); + + // 站点图片 + if (StringUtils.isNotBlank(pileStationInfo.getPictures())) { + nrStationInfo.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(","))); + } + // 站点类型 + String stationType = pileStationInfo.getStationType(); + if (!StringUtils.equals("1", stationType) && !StringUtils.equals("255", stationType)) { + // 不为1-公共并且不为255-其他,都为专用 + stationType = "2"; + } + nrStationInfo.setStationType(Integer.parseInt(stationType)); + nrStationInfo.setConstruction(255); + + List nrEquipmentInfos = getEquipmentInfo(String.valueOf(pileStationInfo.getId())); + nrStationInfo.setEquipmentInfos(nrEquipmentInfos); + + resultList.add(nrStationInfo); + } + Map map = new LinkedHashMap<>(); + map.put("PageNo", pageInfo.getPageNum()); + map.put("PageCount", pageInfo.getPages()); + map.put("ItemSize", resultList.size()); + map.put("StationInfos", resultList); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, getNanRuiPlatformSecretInfo()); + return resultMap; + } + + /** + * 推送告警信息 + * @param dto + * @return + */ + @Override + public String notificationAlarmInfo(PushAlarmInfoDTO dto) { + List nrAlarmInfos = new ArrayList<>(); + + ThirdPartySecretInfoVO jiangSuSecretInfo = getNanRuiPlatformSecretInfo(); + + String operatorId = jiangSuSecretInfo.getOurOperatorId(); + String operatorSecret = jiangSuSecretInfo.getTheirOperatorSecret(); + String signSecret = jiangSuSecretInfo.getTheirSigSecret(); + String dataSecret = jiangSuSecretInfo.getTheirDataSecret(); + String dataSecretIv = jiangSuSecretInfo.getTheirDataSecretIv(); + String urlAddress = jiangSuSecretInfo.getTheirUrlPrefix(); + + // 从缓存中获取故障原因 + String redisKey = CacheConstants.PILE_HARDWARE_FAULT + dto.getPileConnectorCode(); + String faultReason = redisCache.getCacheObject(redisKey); + int status = 0; + if (StringUtils.equals(dto.getConnectorStatus(), "01")) { + // 故障 + status = 1; + } + // 封装对象 + NRAlarmInfo alarmInfo = NRAlarmInfo.builder() + .connectorId(dto.getPileConnectorCode()) + .alertTime(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS)) + .alertCode(120) // 120-预留 + .describe(faultReason) + .status(status) + + .build(); + nrAlarmInfos.add(alarmInfo); + + // 发送请求 + String url = urlAddress + "notification_alarmInfo"; + + JSONObject data = new JSONObject(); + data.put("AlarmInfos", nrAlarmInfos); + + String jsonString = JSON.toJSONString(data); + System.out.println("jsonString : " + jsonString); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 设备状态变化推送 notification_stationStatus + * 推送充电设备接口状态信息 supervise_notification_station_status + * + * @param dto + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationStatus(PushRealTimeInfoDTO dto) { + String status = dto.getStatus(); + String pileConnectorCode = dto.getPileConnectorCode(); + + // 查出该桩所属哪个站点 + // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); + String pileSn = YKCUtils.getPileSn(pileConnectorCode); + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn); + // 通过站点id查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNanRuiPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); + ConnectorStatusInfo info = ConnectorStatusInfo.builder() + .connectorID(pileConnectorCode) + .status(Integer.parseInt(status)) + .build(); + // 调用联联平台接口 + JSONObject json = new JSONObject(); + json.put("ConnectorStatusInfo", info); + String jsonString = JSON.toJSONString(json); + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 查询设备接口状态 + * 此接口用于批量查询设备实时状态 + * 由充电运营商方实现此接口,省、市两级监管平台调用。 + * @param dto + * @return + */ + @Override + public Map queryStationStatus(QueryStationInfoDTO dto) { + List stationIds = dto.getStationIds(); + List resultList = new ArrayList<>(); + + ThirdPartySecretInfoVO NanRuiSecretInfo = getNanRuiPlatformSecretInfo(); + + // 将 stationIdList 转换成 List + List stationLongList = stationIds.stream() + .map(Long::parseLong) + .collect(Collectors.toList()); + + QueryConnectorListDTO queryConnectorListDTO = QueryConnectorListDTO.builder() + .stationIdList(stationLongList) + .build(); + List connectorInfoVOS = pileConnectorInfoService.getConnectorInfoListByParams(queryConnectorListDTO); + if (CollectionUtils.isEmpty(connectorInfoVOS)) { + return new LinkedHashMap<>(); + } + // 根据stationId分组 + Map> collect = connectorInfoVOS.stream() + .collect(Collectors.groupingBy(PileConnectorInfoVO::getStationId)); + // 遍历 map + for (Map.Entry> entry : collect.entrySet()) { + String stationId = entry.getKey(); + List connectorList = entry.getValue(); + List connectorStatusInfoList = new ArrayList<>(); + + for (PileConnectorInfoVO connectorInfoVO : connectorList) { + NRConnectorStatusInfo nrConnectorStatusInfo = NRConnectorStatusInfo.builder() + .connectorID(connectorInfoVO.getPileConnectorCode()) + .status(connectorInfoVO.getStatus()) + .currentA(0) + .voltageA(0) + .soc(BigDecimal.ZERO) + .beginTime(null) + .currentKwh(BigDecimal.ZERO) + .timeStamp((int) (System.currentTimeMillis() / 1000)) + + .build(); + if (StringUtils.equals(String.valueOf(connectorInfoVO.getStatus()), "3")) { + // 充电中 + nrConnectorStatusInfo.setCurrentA(connectorInfoVO.getCurrent().intValue()); + nrConnectorStatusInfo.setVoltageA(connectorInfoVO.getVoltage().intValue()); + nrConnectorStatusInfo.setSoc(new BigDecimal(connectorInfoVO.getSOC())); + String chargingTime = connectorInfoVO.getChargingTime(); + Date beginTime = DateUtils.addMinute(new Date(), -Integer.parseInt(chargingTime)); + nrConnectorStatusInfo.setBeginTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, beginTime)); + } + if (StringUtils.equals(String.valueOf(connectorInfoVO.getStatus()), "255")) { + // 故障 + nrConnectorStatusInfo.setStatus(255); + } + connectorStatusInfoList.add(nrConnectorStatusInfo); + } + // 封装参数 + NRStationStatusInfo stationStatusInfo = NRStationStatusInfo.builder() + .stationId(stationId) + .connectorStatusInfos(connectorStatusInfoList) + .build(); + resultList.add(stationStatusInfo); + } + Map map = new LinkedHashMap<>(); + map.put("StationStatusInfos", resultList); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map,NanRuiSecretInfo); + return resultMap; + } + + /** + * 充电电量信息推送 + * 当运营商平台完成一次充电时,将充电电量信息推送至省、市两级监管平台 + * @param orderCode + * @return + */ + @Override + public String pushOrderInfo(String orderCode) { + // 根据订单号查询订单信息 + JiangSuOrderInfoVO nrOrderInfoVO = orderBasicInfoService.getNROrderInfoByOrderCode(orderCode); + JiangSuOrderInfo jiangSuOrderInfo = formatNROrderInfo((nrOrderInfoVO)); + + // 通过三方平台类型查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNanRuiPlatformSecretInfo(); + + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + "notification_orderInfo"; + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + if (StringUtils.isBlank(token)) { + return null; + } + + // 发送请求 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("OrderInfo", jiangSuOrderInfo); + + String jsonString = JSON.toJSONString(jsonObject); + + String result = HttpRequestUtil.nrSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + return result; + } + + /** + * 查询充电电量信息 + * 此接口用于批量查询时间区段内交易记录 + * @param dto + * @return + */ + @Override + public Map queryOrderInfo(QueryOrderDTO dto) { + List resultList = new ArrayList<>(); + ThirdPartySecretInfoVO jiangSuSecretInfo = getNanRuiPlatformSecretInfo(); + NRQueryOrderDTO queryOrderDTO = new NRQueryOrderDTO(); + queryOrderDTO.setOrderCode(dto.getOrderCode()); + queryOrderDTO.setQueryStartTime(dto.getQueryStartTime()); + queryOrderDTO.setQueryEndTime(dto.getQueryEndTime()); + List nrOrderInfos = orderBasicInfoService.getNROrderInfos(queryOrderDTO); + if (CollectionUtils.isEmpty(nrOrderInfos)) { + return Maps.newLinkedHashMap(); + } + for (JiangSuOrderInfoVO nrOrderInfoVO : nrOrderInfos) { + JiangSuOrderInfo jiangSuOrderInfo = formatJiangSuOrderInfo(nrOrderInfoVO); + resultList.add(jiangSuOrderInfo); + } + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(JSONObject.toJSONString(resultList), jiangSuSecretInfo); + return resultMap; + } + + + /** + * 获取设备信息 + * @param stationId + * @return + */ + private List getEquipmentInfo(String stationId) { + List resultList = new ArrayList<>(); + List list = pileBasicInfoService.getPileListByStationId(stationId); + if (CollectionUtils.isEmpty(list)) { + return resultList; + } + for (PileBasicInfo pileBasicInfo : list) { + String pileSn = pileBasicInfo.getSn(); + // 获取桩状态 + Map pileStatusMap = pileConnectorInfoService.getPileStatus(Lists.newArrayList(pileSn)); + String pileStatus = pileStatusMap.get(pileSn); + if (StringUtils.equals(PileStatusEnum.ON_LINE.getValue(), pileStatus)) { + pileStatus = "50"; // 50-正常使用 + } else if (StringUtils.equals(PileStatusEnum.OFF_LINE.getValue(), pileStatus) + || StringUtils.equals(PileStatusEnum.FAULT.getValue(), pileStatus)) { + pileStatus = "6"; // 6-维护中 + } + // 获取桩型号信息 + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + if (modelInfo == null) { + continue; + } + NREquipmentInfo equipmentInfo = NREquipmentInfo.builder() + .equipmentID(pileSn) + .equipmentName(pileSn) + .openForBusinessDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getCreateTime())) + .equipmentType(Integer.parseInt(modelInfo.getSpeedType())) + .equipmentStatus(Integer.parseInt(pileStatus)) + .power(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)) + + .vinFlag(1) + .equipmentPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)) + .newNationalStandard(1) + .constructionTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, pileBasicInfo.getProductionDate())) + .manufacturerID("014406554") + .build(); + // 获取枪口信息 + List connectorInfos = getConnectorInfo(pileSn); + equipmentInfo.setConnectorInfos(connectorInfos); + + resultList.add(equipmentInfo); + } + return resultList; + } + + /** + * 获取枪口信息 + * @param pileSn + * @return + */ + private List getConnectorInfo(String pileSn) { + List resultList = new ArrayList<>(); + List list = pileConnectorInfoService.selectPileConnectorInfoList(pileSn); + if (CollectionUtils.isEmpty(list)) { + return resultList; + } + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3; + // 封装成江苏平台对象 + for (PileConnectorInfo pileConnectorInfo : list) { + NRConnectorInfo connectorInfo = NRConnectorInfo.builder() + .connectorId(pileConnectorInfo.getPileConnectorCode()) + .connectorName(pileConnectorInfo.getPileConnectorCode()) + .connectorType(connectorType) + .voltageUpperLimits(Integer.parseInt(modelInfo.getRatedVoltage())) + .voltageLowerLimits(Integer.parseInt(modelInfo.getRatedVoltage())) + .current(Integer.parseInt(modelInfo.getRatedCurrent())) + .power(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)) + .nationalStandard(2) + + .build(); + resultList.add(connectorInfo); + } + return resultList; + } + + /** + * 获取南瑞平台配置密钥信息 + * + * @return + */ + private ThirdPartySecretInfoVO getNanRuiPlatformSecretInfo() { + // 通过第三方平台类型查询相关配置信息 + ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getTypeCode()); + if (thirdPartySecretInfoVO == null) { + throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL); + } + thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU); + return thirdPartySecretInfoVO; + } + + + private JiangSuOrderInfo formatJiangSuOrderInfo(JiangSuOrderInfoVO nrOrderInfoVO) { + JiangSuOrderInfo jiangSuOrderInfo = JiangSuOrderInfo.builder() + .operatorId(Constants.OPERATORID_JIANG_SU) + .connectorId(nrOrderInfoVO.getConnectorId()) + .startChargeSeq(nrOrderInfoVO.getStartChargeSeq()) + .userChargeType(1) + .elect(nrOrderInfoVO.getElect()) + .cuspElect(nrOrderInfoVO.getCuspElect()) + .peakElect(nrOrderInfoVO.getPeakElect()) + .flatElect(nrOrderInfoVO.getFlatElect()) + .valleyElect(nrOrderInfoVO.getValleyElect()) + .startTime(nrOrderInfoVO.getStartTime()) + .endTime(nrOrderInfoVO.getEndTime()) + + .build(); + // TODO 获取电表总起、止值 + // pileMsgRecordService.getPileFeedList() + + jiangSuOrderInfo.setMeterValueStart(BigDecimal.ZERO); + jiangSuOrderInfo.setMeterValueEnd(BigDecimal.ZERO); + return jiangSuOrderInfo; + } + /** + * 格式化南瑞平台订单对象 + * @param nrOrderInfoVO + * @return + */ + private JiangSuOrderInfo formatNROrderInfo(JiangSuOrderInfoVO nrOrderInfoVO) { + // 将组织机构代码截取后九位 + // String organizationCode = nrOrderInfoVO.getOperatorId(); + // if (StringUtils.isBlank(organizationCode)) { + // return null; + // } + // String operatorId = StringUtils.substring(organizationCode, organizationCode.length() - 9); + + JiangSuOrderInfo jiangSuOrderInfo = JiangSuOrderInfo.builder() + .operatorId(Constants.OPERATORID_JIANG_SU) + .connectorId(nrOrderInfoVO.getConnectorId()) + .startChargeSeq(nrOrderInfoVO.getStartChargeSeq()) + .userChargeType(1) + .elect(nrOrderInfoVO.getElect()) + .cuspElect(nrOrderInfoVO.getCuspElect()) + .peakElect(nrOrderInfoVO.getPeakElect()) + .flatElect(nrOrderInfoVO.getFlatElect()) + .valleyElect(nrOrderInfoVO.getValleyElect()) + .startTime(nrOrderInfoVO.getStartTime()) + .endTime(nrOrderInfoVO.getEndTime()) + + .build(); + // TODO 获取电表总起、止值 + // pileMsgRecordService.getPileFeedList() + + jiangSuOrderInfo.setMeterValueStart(BigDecimal.ZERO); + jiangSuOrderInfo.setMeterValueEnd(BigDecimal.ZERO); + return jiangSuOrderInfo; + } +} From edfb7d4f89d63fe90daf9edf8097cda1fbacb394 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Sat, 23 Nov 2024 15:30:55 +0800 Subject: [PATCH 06/12] update --- .../service/impl/NanRuiPlatfromServicelmp.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java index 3b8fc8a1b..0f7fc5e0f 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java @@ -209,8 +209,7 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { info.setAreaCode(subAreaCode); // 截取运营商组织机构代码(去除最后一位后的最后九位) String organizationCode = ""; - if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode(), thirdPlatformType)) { - // 联联平台先使用自己运营商的组织机构代码 + if (StringUtils.equals(ThirdPlatformTypeEnum.NAN_RUI_PLATFORM.getTypeCode(), thirdPlatformType)) { organizationCode = Constants.OPERATORID_LIANLIAN; info.setEquipmentOwnerID(organizationCode); } else { @@ -264,6 +263,7 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { /** * 获取充电站信息 + * * @param dto * @return */ @@ -347,6 +347,7 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { /** * 推送告警信息 + * * @param dto * @return */ @@ -442,6 +443,7 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { * 查询设备接口状态 * 此接口用于批量查询设备实时状态 * 由充电运营商方实现此接口,省、市两级监管平台调用。 + * * @param dto * @return */ @@ -510,13 +512,14 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { Map map = new LinkedHashMap<>(); map.put("StationStatusInfos", resultList); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map,NanRuiSecretInfo); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, NanRuiSecretInfo); return resultMap; } /** * 充电电量信息推送 * 当运营商平台完成一次充电时,将充电电量信息推送至省、市两级监管平台 + * * @param orderCode * @return */ @@ -557,6 +560,7 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { /** * 查询充电电量信息 * 此接口用于批量查询时间区段内交易记录 + * * @param dto * @return */ @@ -584,6 +588,7 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { /** * 获取设备信息 + * * @param stationId * @return */ @@ -634,6 +639,7 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { /** * 获取枪口信息 + * * @param pileSn * @return */ @@ -701,8 +707,10 @@ public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { jiangSuOrderInfo.setMeterValueEnd(BigDecimal.ZERO); return jiangSuOrderInfo; } + /** * 格式化南瑞平台订单对象 + * * @param nrOrderInfoVO * @return */ From 0174329d6c36182afdfd9f3de8e054d1a0ea06e7 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Mon, 25 Nov 2024 11:36:36 +0800 Subject: [PATCH 07/12] update --- .../thirdparty/GuiZhouPlatformController.java | 153 ++++++++++++++++++ ...lmp.java => NanRuiPlatfromServiceImp.java} | 3 +- ...java => XinDiantuPlatfromServiceImpl.java} | 2 +- ...=> YongChengbochePlatfromServiceImpl.java} | 2 +- 4 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/{NanRuiPlatfromServicelmp.java => NanRuiPlatfromServiceImp.java} (99%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/{XinDiantuPlatfromServicelmpl.java => XinDiantuPlatfromServiceImpl.java} (99%) rename jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/{YongChengbochePlatfromServicelmpl.java => YongChengbochePlatfromServiceImpl.java} (99%) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java new file mode 100644 index 000000000..7aeca9054 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java @@ -0,0 +1,153 @@ +package com.jsowell.api.thirdparty; + + +import com.alibaba.fastjson2.JSON; +import com.jsowell.common.annotation.Anonymous; +import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; +import com.jsowell.common.exception.BusinessException; +import com.jsowell.pile.dto.QueryOperatorInfoDTO; +import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.thirdparty.CommonParamsDTO; +import com.jsowell.thirdparty.lianlian.common.CommonResult; +import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * 浙江省平台 + */ +@Anonymous +@RestController +@RequestMapping("/guizhou") +public class GuiZhouPlatformController extends ThirdPartyBaseController { + private final String platformName = "贵州省平台"; + + @Autowired + @Qualifier("guiZhouPlatformServiceImpl") + private ThirdPartyPlatformService platformLogic; + + /** + * getToken + */ + @PostMapping("/v1/query_token") + public CommonResult queryToken(@RequestBody CommonParamsDTO dto) { + // logger.info("{}-请求令牌 params:{}", platformName, JSON.toJSONString(dto)); + try { + Map map = platformLogic.queryToken(dto); + logger.info("{}-请求令牌, params:{}, result:{}", platformName, JSON.toJSONString(dto), JSON.toJSONString(map)); + return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("{}-获取token接口, 异常, params:{}", platformName, JSON.toJSONString(dto), e); + return CommonResult.failed("获取token发生异常"); + } + } + + /** + * 查询运营商信息 + * supervise_query_operator_info + */ + @PostMapping("/v1/supervise_query_operator_info") + public CommonResult queryOperatorInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询运营商信息 params:{}", platformName, JSON.toJSONString(dto)); + try { + // 校验令牌 + boolean verifyToken = verifyToken(request.getHeader("Authorization")); + if (!verifyToken) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryOperatorInfoDTO paramDTO = parseParamsDTO(dto, QueryOperatorInfoDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryOperatorInfo(paramDTO); + logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map)); + return CommonResult.success(0, "操作成功!", map.get("Data"), map.get("Sig")); + } catch (BusinessException e) { + return CommonResult.failed(Integer.parseInt(e.getCode()), e.getMessage()); + } catch (Exception e) { + logger.error("{}-查询运营商信息 异常", platformName, e); + return CommonResult.failed("查询运营商信息发生异常"); + } + } + + /** + * 查询充电站信息 + * supervise_query_stations_info + */ + @PostMapping("/v1/supervise_query_stations_info") + public CommonResult query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询充电站信息 params:{}", platformName, JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryStationsInfo(queryStationInfoDTO); + + return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.info("{}-查询充电站信息 error:", platformName, e); + } + return CommonResult.failed("查询充电站信息发生异常"); + } + + /** + * 查询充电站状态信息 + * supervise_query_station_status + */ + @PostMapping("/v1/supervise_query_station_status") + public CommonResult queryStationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { + logger.info("{}-查询充电站状态信息 params:{}", platformName, JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryStationStatus(queryStationInfoDTO); + + return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("{}-查询充电站状态信息 error:", platformName, e); + } + return CommonResult.failed("查询充电站状态信息发生异常"); + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServiceImp.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServiceImp.java index 0f7fc5e0f..6b8e64478 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServicelmp.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/NanRuiPlatfromServiceImp.java @@ -27,7 +27,6 @@ import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; -import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.nanrui.JiangSuOrderInfoVO; import com.jsowell.pile.vo.uniapp.customer.CurrentTimePriceDetails; import com.jsowell.pile.vo.web.PileConnectorInfoVO; @@ -60,7 +59,7 @@ import java.util.stream.Collectors; * 南瑞 */ @Service -public class NanRuiPlatfromServicelmp implements ThirdPartyPlatformService { +public class NanRuiPlatfromServiceImp implements ThirdPartyPlatformService { private final String thirdPlatformType = ThirdPlatformTypeEnum.NAN_RUI_PLATFORM.getTypeCode(); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServicelmpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServiceImpl.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServicelmpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServiceImpl.java index 0eea30caa..661a9531c 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServicelmpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServiceImpl.java @@ -61,7 +61,7 @@ import java.util.stream.Collectors; * 新电途 */ @Service -public class XinDiantuPlatfromServicelmpl implements ThirdPartyPlatformService { +public class XinDiantuPlatfromServiceImpl implements ThirdPartyPlatformService { private final String thirdPlatformType = ThirdPlatformTypeEnum.XIN_DIAN_TU.getTypeCode(); @Autowired diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServiceImpl.java similarity index 99% rename from jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java rename to jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServiceImpl.java index ee33af942..7dcd8cbf1 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServicelmpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/YongChengbochePlatfromServiceImpl.java @@ -55,7 +55,7 @@ import java.util.stream.Collectors; * 甬城泊车 */ @Service -public class YongChengbochePlatfromServicelmpl implements ThirdPartyPlatformService { +public class YongChengbochePlatfromServiceImpl implements ThirdPartyPlatformService { private final String thirdPlatformType = ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getTypeCode(); @Autowired From b2c35b8a0f386d4421769619a636caf38df9eedb Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Mon, 25 Nov 2024 15:02:07 +0800 Subject: [PATCH 08/12] update --- .../com/jsowell/api/thirdparty/GuiZhouPlatformController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java index 7aeca9054..649f3805d 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GuiZhouPlatformController.java @@ -21,7 +21,7 @@ import javax.servlet.http.HttpServletRequest; import java.util.Map; /** - * 浙江省平台 + * 贵州省平台 */ @Anonymous @RestController From c424069175f7c650db50aebdf3f878930d59885e Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 26 Nov 2024 13:32:04 +0800 Subject: [PATCH 09/12] =?UTF-8?q?update=20=E7=94=98=E8=82=83=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E3=80=81=E5=AE=81=E5=A4=8F=E5=B9=B3=E5=8F=B0controlle?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jsowell/api/thirdparty/GanSuController.java | 5 +++++ .../com/jsowell/api/thirdparty/NingXiaController.java | 6 ++++++ .../jsowell/api/thirdparty/ThirdPartyBaseController.java | 8 +++++++- .../common/enums/thirdparty/ThirdPlatformTypeEnum.java | 2 +- .../java/com/jsowell/pile/thirdparty/CommonParamsDTO.java | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GanSuController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GanSuController.java index bfeb7cc38..801ccb0dc 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GanSuController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/GanSuController.java @@ -3,6 +3,7 @@ package com.jsowell.api.thirdparty; import com.alibaba.fastjson2.JSON; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; @@ -29,6 +30,8 @@ import java.util.Map; public class GanSuController extends ThirdPartyBaseController{ private final String platformName = "甘肃省平台"; + private final String platformType = ThirdPlatformTypeEnum.GAN_SU_PLATFORM.getTypeCode(); + @Autowired @Qualifier("ganSuPlatformServiceImpl") private ThirdPartyPlatformService platformLogic; @@ -62,6 +65,7 @@ public class GanSuController extends ThirdPartyBaseController{ // 校验失败 return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); } + dto.setPlatformType(platformType); // 校验签名 if (!verifySignature(dto)) { @@ -95,6 +99,7 @@ public class GanSuController extends ThirdPartyBaseController{ // 校验失败 return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); } + dto.setPlatformType(platformType); // 校验签名 if (!verifySignature(dto)) { diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java index 7591672e3..b9d6f9778 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/NingXiaController.java @@ -3,6 +3,7 @@ package com.jsowell.api.thirdparty; import com.alibaba.fastjson2.JSON; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; import com.jsowell.pile.dto.PushRealTimeInfoDTO; @@ -28,6 +29,8 @@ public class NingXiaController extends ThirdPartyBaseController { private final String platformName = "宁夏平台"; + private final String platformType = ThirdPlatformTypeEnum.NING_XIA_PLATFORM.getTypeCode(); + @Autowired @Qualifier("ningXiaPlatformServiceImpl") private ThirdPartyPlatformService platformLogic; @@ -66,6 +69,7 @@ public class NingXiaController extends ThirdPartyBaseController { // 校验失败 return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); } + dto.setPlatformType(platformType); // 校验签名 if (!verifySignature(dto)) { @@ -105,6 +109,7 @@ public class NingXiaController extends ThirdPartyBaseController { // 校验失败 return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); } + dto.setPlatformType(platformType); // 校验签名 if (!verifySignature(dto)) { @@ -134,6 +139,7 @@ public class NingXiaController extends ThirdPartyBaseController { // 校验失败 return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); } + dto.setPlatformType(platformType); // 校验签名 if (!verifySignature(dto)) { diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java index 4a2c25f16..1bfe1e4e2 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java @@ -186,7 +186,13 @@ public class ThirdPartyBaseController extends BaseController { protected boolean verifySignature(CommonParamsDTO dto, String signSecret) { // 查询密钥 String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID(); - ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + ThirdPartySecretInfoVO secretInfoVO; + if (StringUtils.isNotBlank(dto.getPlatformType())) { + // type不为空,按照type查 + secretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(dto.getPlatformType()); + }else { + secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + } if (secretInfoVO == null) { throw new BusinessException("1", "无此对接平台"); } diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index a837c7532..d0d85baeb 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -25,7 +25,7 @@ public enum ThirdPlatformTypeEnum { SHEN_ZHEN_PLATFORM("14", "深圳平台", ""), ZHE_JIANG_PLATFORM("15", "浙江省平台", "002485048"), SU_ZHOU_PLATFORM("16", "苏州市平台", "MAC1MFJ1X"), - GAN_SU_PLATFORM("17", "甘肃省平台", ""), + GAN_SU_PLATFORM("17", "甘肃省平台", "MA01H3BQ9"), ; private String typeCode; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/CommonParamsDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/CommonParamsDTO.java index 1665112b5..0927a69c3 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/CommonParamsDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/CommonParamsDTO.java @@ -27,4 +27,6 @@ public class CommonParamsDTO { @JsonProperty(value = "Sig") private String sig; + + private String platformType; } From 5e0bc183905d640cfd2d4fffdb895dcebc451236 Mon Sep 17 00:00:00 2001 From: Guoqs <123@jsowell.com> Date: Tue, 26 Nov 2024 15:19:35 +0800 Subject: [PATCH 10/12] update --- .../jsowell/netty/decoder/StartAndLengthFieldFrameDecoder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/decoder/StartAndLengthFieldFrameDecoder.java b/jsowell-netty/src/main/java/com/jsowell/netty/decoder/StartAndLengthFieldFrameDecoder.java index f49e34cc8..8f0e0475c 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/decoder/StartAndLengthFieldFrameDecoder.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/decoder/StartAndLengthFieldFrameDecoder.java @@ -17,6 +17,7 @@ public class StartAndLengthFieldFrameDecoder extends ByteToMessageDecoder { // 构造函数,初始化起始标志 public StartAndLengthFieldFrameDecoder() {} + @Override protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List out) throws Exception { // log.info("StartAndLengthFieldFrameDecoder.decode"); // 记录包头开始的index From 1c70a8b02f192bf2b9be9b50c40507028c8244f8 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 26 Nov 2024 15:44:56 +0800 Subject: [PATCH 11/12] =?UTF-8?q?update=20=E7=94=98=E8=82=83=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/thirdparty/ThirdPartyBaseController.java | 9 ++++++++- .../service/impl/GanSuPlatformServiceImpl.java | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java index 1bfe1e4e2..fd1aad5a0 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ThirdPartyBaseController.java @@ -58,8 +58,15 @@ public class ThirdPartyBaseController extends BaseController { protected T parseParamsDTO(CommonParamsDTO dto, Class targetClass) throws NoSuchFieldException, IllegalAccessException { // 解密 String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID(); + ThirdPartySecretInfoVO secretInfoVO; + if (StringUtils.isNotBlank(dto.getPlatformType())) { + // type不为空,按照type查 + secretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(dto.getPlatformType()); + }else { + secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + } // 通过operatorId 查出 operatorSecret - ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + // ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); if (secretInfoVO == null) { throw new BusinessException("1", "无此对接平台"); } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GanSuPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GanSuPlatformServiceImpl.java index 409f5ed05..173295015 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GanSuPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GanSuPlatformServiceImpl.java @@ -160,9 +160,10 @@ public class GanSuPlatformServiceImpl implements ThirdPartyPlatformService { public Map queryStationsInfo(QueryStationInfoDTO dto) { int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); + dto.setThirdPlatformType(thirdPlatformType); PageUtils.startPage(pageNo, pageSize); - List stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); + List stationInfos = pileStationInfoService.selectStationInfosByThirdParty(dto); if (CollectionUtils.isEmpty(stationInfos)) { // 未查到数据 return null; @@ -189,6 +190,17 @@ public class GanSuPlatformServiceImpl implements ThirdPartyPlatformService { // todo .serviceFee() .build(); + JSONObject electricityFee = new JSONObject(); + JSONObject serviceFee = new JSONObject(); + // 查询计费模板 + List priceList = pileBillingTemplateService.queryBillingPrice(stationId); + for (BillingPriceVO billingPriceVO : priceList) { + electricityFee.put(billingPriceVO.getStartTime() + ":00" + "-" + billingPriceVO.getEndTime() + ":00", billingPriceVO.getElectricityPrice()); + serviceFee.put(billingPriceVO.getStartTime() + ":00" + "-" + billingPriceVO.getEndTime() + ":00", billingPriceVO.getServicePrice()); + } + stationInfo.setElectricityFee(electricityFee.toJSONString()); + stationInfo.setServiceFee(serviceFee.toJSONString()); + // busineHours String busineHours = getBusineHours(); stationInfo.setBusineHours(busineHours); From f1143653474b250cfccd8f8c5f3b19531efe3f40 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Tue, 26 Nov 2024 15:48:20 +0800 Subject: [PATCH 12/12] update --- .../impl/GuiZhouPlatformServiceImpl.java | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java index 4bb2cd216..bd7414d11 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -9,6 +9,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; +import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.lianlian.StationPaymentEnum; import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; @@ -57,6 +58,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -84,6 +86,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { private OrderBasicInfoService orderBasicInfoService; @Autowired private PileBillingTemplateService pileBillingTemplateService; + @Autowired + private RedisCache redisCache; @Override public void afterPropertiesSet() throws Exception { @@ -91,7 +95,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { } /** - * query_token 获取token,提供给第三方平台使用 + * 请求令牌 query_token * * @param dto * @return @@ -104,41 +108,50 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 int failReason = 0; - String operatorId = dto.getPlatformID(); + String operatorId = dto.getOperatorID(); + // token缓存key值 + String redisKey = operatorId + "_token:"; // 通过operatorId 查出 operatorSecret - ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuiZhouPlatformSecretInfo(); if (thirdPartySecretInfoVO == null) { failReason = 1; succStat = 1; } else { - String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String ourOperatorSecret = thirdPartySecretInfoVO.getOurOperatorSecret(); String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); // 解密data 获取参数中的OperatorSecret String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv); - if (StringUtils.isBlank(decrypt)) { - failReason = 2; + String inputOperatorSecret = null; + if (StringUtils.isNotBlank(decrypt)) { + inputOperatorSecret = JSON.parseObject(decrypt).getString("OperatorSecret"); + } + // 对比密钥 + if (!StringUtils.equals(ourOperatorSecret, inputOperatorSecret)) { + failReason = 1; succStat = 1; } else { - String inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret"); - // 对比密钥 - if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) { - failReason = 2; - succStat = 1; - } else { + // 先查缓存中是否有已生成的token + String token = redisCache.getCacheObject(redisKey); + int expiredTime = (int) redisCache.getExpire(redisKey); + if (StringUtils.isBlank(token)) { // 生成token - String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); - vo.setAccessToken(token); - vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); + token = JWTUtils.createToken(operatorId, ourOperatorSecret, JWTUtils.ttlMillis); + expiredTime = (int) (JWTUtils.ttlMillis / 1000); } + vo.setAccessToken(token); + vo.setTokenAvailableTime(expiredTime); + // 设置缓存 + redisCache.setCacheObject(redisKey, token, expiredTime, TimeUnit.SECONDS); } } // 组装返回参数 - vo.setPlatformId(operatorId); + vo.setOperatorID(operatorId); vo.setFailReason(failReason); vo.setSuccStat(succStat); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getOurDataSecret() + , thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getOurSigSecret()); return resultMap; } @@ -787,6 +800,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { * @return */ private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() { + String thirdPartyType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode(); // 通过第三方平台类型查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode()); if (thirdPartySecretInfoVO == null) {