diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/XDTController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/XDTController.java index 1a5c2ceeb..b33f3e23d 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/XDTController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/XDTController.java @@ -4,6 +4,7 @@ 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.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; import com.jsowell.pile.dto.*; @@ -54,32 +55,30 @@ public class XDTController extends ThirdPartyBaseController { } } + /** * 推送充电站信息 notification_stationInfo * http://localhost:8080/xindiantu/v1/pushStationInfo * @param dto * @return */ - // @PostMapping("/pushStationInfo") - // public RestApiResponse pushStationInfo(@RequestBody PushStationInfoDTO dto) { - // logger.info("推送新电途平台充电站信息 params:{}", JSON.toJSONString(dto)); - // RestApiResponse response = null; - // try { - // if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) { - // throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); - // } - // xdtService.pushStationInfo(dto); - // response = new RestApiResponse<>(); - // }catch (BusinessException e) { - // logger.error("推送新电途平台充电站信息 error",e); - // response = new RestApiResponse<>(e.getCode(), e.getMessage()); - // }catch (Exception e) { - // logger.error("推送新电途平台充电站信息 error", e); - // response = new RestApiResponse<>(e); - // } - // logger.info("推送新电途平台充电站信息 result:{}", response); - // return response; - // } + @PostMapping("/v1/notification_station_detail") + public RestApiResponse pushStationInfo(@RequestBody PushStationInfoDTO dto) { + logger.info("推送新电途平台充电站信息 params:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + platformLogic.notificationStationInfo(String.valueOf(dto.getStationId())); + response = new RestApiResponse<>(); + }catch (BusinessException e) { + logger.error("推送新电途平台充电站信息 error",e); + response = new RestApiResponse<>(e.getCode(), e.getMessage()); + }catch (Exception e) { + logger.error("推送新电途平台充电站信息 error", e); + response = new RestApiResponse<>(e); + } + logger.info("推送新电途平台充电站信息 result:{}", response); + return response; + } /** * 查询充电站信息 @@ -487,5 +486,5 @@ public class XDTController extends ThirdPartyBaseController { // logger.info("新电途平台设备状态变化推送 result:{}", response); // return response; // } - + } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServiceImpl.java index 0adb4b7c8..e59aba567 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/XinDiantuPlatfromServiceImpl.java @@ -7,6 +7,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.enums.lianlian.StationPaymentEnum; import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.BillingTimeTypeEnum; @@ -20,15 +21,18 @@ 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.ConnectorInfo; import com.jsowell.pile.thirdparty.EquipmentInfo; import com.jsowell.pile.util.MerchantUtils; 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.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.PileModelInfoVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; import com.jsowell.thirdparty.lianlian.domain.ConnectorStatsInfo; @@ -36,6 +40,7 @@ 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.common.StationInfo; import com.jsowell.thirdparty.platform.domain.ChargeOrderInfo; import com.jsowell.thirdparty.platform.domain.SupChargeDetails; import com.jsowell.thirdparty.platform.domain.SupEquipChargeStatusInfo; @@ -94,6 +99,9 @@ public class XinDiantuPlatfromServiceImpl implements ThirdPartyPlatformService { @Autowired private PileRemoteService pileRemoteService; + @Autowired + private PileModelInfoService pileModelInfoService; + @Override public void afterPropertiesSet() throws Exception { ThirdPartyPlatformFactory.register(thirdPlatformType, this); @@ -160,67 +168,110 @@ public class XinDiantuPlatfromServiceImpl 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; } + // ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId()); 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.setStationID(String.valueOf(pileStationInfo.getId())); + stationInfo.setOperatorID(Constants.OPERATORID_JIANG_SU); // 组织机构代码 + String organizationCode = pileStationInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + stationInfo.setEquipmentOwnerID(equipmentOwnerId); + }else { + stationInfo.setEquipmentOwnerID(Constants.OPERATORID_JIANG_SU); + } stationInfo.setStationName(pileStationInfo.getStationName()); - stationInfo.setIsAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())); - stationInfo.setIsPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())); stationInfo.setCountryCode(pileStationInfo.getCountryCode()); - stationInfo.setAreaCode(pileStationInfo.getAreaCode()); + String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 + // 根据逗号分组 + String[] split = StringUtils.split(areaCode, ","); + // 只取最后一部分 330213 + String subAreaCode = split[split.length - 1]; + stationInfo.setAreaCode(subAreaCode); stationInfo.setAddress(pileStationInfo.getAddress()); stationInfo.setServiceTel(pileStationInfo.getStationTel()); - stationInfo.setStationType(Integer.valueOf(pileStationInfo.getStationType())); - stationInfo.setParkNums(Integer.valueOf(pileStationInfo.getParkNums())); + stationInfo.setStationType(Integer.parseInt(pileStationInfo.getStationType())); + stationInfo.setStationStatus(Integer.parseInt(pileStationInfo.getStationStatus())); + stationInfo.setParkNums(Integer.parseInt(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); + stationInfo.setConstruction(Integer.parseInt(pileStationInfo.getConstruction())); + + // 停车费率描述 + if (StringUtils.isNotBlank(pileStationInfo.getParkFeeDescribe())) { + stationInfo.setParkFee(pileStationInfo.getParkFeeDescribe()); + } + // 站点图片 + if (StringUtils.isNotBlank(pileStationInfo.getPictures())) { + stationInfo.setPictures(Lists.newArrayList(pileStationInfo.getPictures().split(","))); + } + + List pileList = getPileList(pileStationInfo); if (CollectionUtils.isNotEmpty(pileList)) { stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 } + resultList.add(stationInfo); } Map map = new LinkedHashMap<>(); - map.put("PageNo", pageInfo.getPageNum()); + map.put("ItemSize", resultList.size()); map.put("PageCount", pageInfo.getPages()); - map.put("ItemSize", pageInfo.getTotal()); + map.put("PageNo", pageInfo.getPageNum()); map.put("StationInfos", resultList); Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); return resultMap; } + + /** + * 充电站信息变化推送 notification_stationInfo + * 新站需要推送。当站点信息发生变化时,推送新的信息通知到市级平台 + * + * @param stationId 充电站id + * @throws UnsupportedOperationException 未实现异常 + */ + @Override + public String notificationStationInfo(String stationId) { + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); + // 通过第三方配置类型查询相关配置信息 + ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo(); + settingInfo.setType(thirdPlatformType); + 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 + "notification_station_detail"; + + JSONObject data = new JSONObject(); + data.put("StationID", stationId); + + String jsonString = JSON.toJSONString(data); + + // 获取令牌 + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + return HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + } + + /** * 查询统计信息 query_station_stats * @@ -932,4 +983,76 @@ public class XinDiantuPlatfromServiceImpl implements ThirdPartyPlatformService { } return resultList; } + + + /** + * 获取桩列表信息 + * + * @param pileStationInfo + * @return + */ + private List getPileList(PileStationInfo pileStationInfo) { + List resultList = new ArrayList<>(); + // 通过站点id查询桩基本信息 + List list = pileBasicInfoService.getPileListByStationId(String.valueOf(pileStationInfo.getId())); + // 封装成中电联平台对象 + for (PileBasicInfo pileBasicInfo : list) { + EquipmentInfo equipmentInfo = new EquipmentInfo(); + String pileSn = pileBasicInfo.getSn(); + + equipmentInfo.setEquipmentID(pileSn); + + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + equipmentInfo.setEquipmentType(Integer.parseInt(modelInfo.getSpeedType())); + equipmentInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + + List connectorList = getConnectorList(pileBasicInfo); + equipmentInfo.setConnectorInfos(connectorList); + + resultList.add(equipmentInfo); + } + return resultList; + } + + /** + * 获取枪口列表 + * + * @param pileBasicInfo + * @return + */ + private List getConnectorList(PileBasicInfo pileBasicInfo) { + List resultList = new ArrayList<>(); + + List list = pileConnectorInfoService.selectPileConnectorInfoList(pileBasicInfo.getSn()); + for (PileConnectorInfo pileConnectorInfo : list) { + ConnectorInfo connectorInfo = new ConnectorInfo(); + + connectorInfo.setConnectorID(pileConnectorInfo.getPileConnectorCode()); + String pileSn = pileConnectorInfo.getPileSn(); + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileSn); + int connectorType = StringUtils.equals("1", modelInfo.getSpeedType()) ? 4 : 3; + + connectorInfo.setConnectorType(connectorType); + // 车位号 + if (StringUtils.isNotBlank(pileConnectorInfo.getParkNo())) { + connectorInfo.setParkNo(pileConnectorInfo.getParkNo()); + } + connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage())); + connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage())); + connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent())); + connectorInfo.setNationalStandard(2); + // if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) { + // // 如果不是单枪,则枪口功率需要除以枪口数量 + // String ratedPowerStr = modelInfo.getRatedPower(); + // BigDecimal ratedPower = new BigDecimal(ratedPowerStr); + // connectorInfo.setPower(ratedPower.divide(new BigDecimal(modelInfo.getConnectorNum()), 1, BigDecimal.ROUND_HALF_UP)); + // }else { + // } + connectorInfo.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + + resultList.add(connectorInfo); + } + + return resultList; + } }