From db0b7644a9a5a62ac2da3cf571fee41bb8b6974f Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 25 九月 2025 15:54:15 +0800 Subject: [PATCH] 添加E路通推送数据功能 --- ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java | 302 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 250 insertions(+), 52 deletions(-) diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java index 7d58d32..4347bdb 100644 --- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java +++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java @@ -24,6 +24,8 @@ import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.integration.api.elutong.model.*; +import com.ruoyi.integration.api.feignClient.ELuTongClient; import com.ruoyi.integration.api.feignClient.IntegrationClient; import com.ruoyi.integration.api.feignClient.TCECClient; import com.ruoyi.other.api.domain.TVip; @@ -41,7 +43,11 @@ import javax.annotation.Resource; import java.math.BigDecimal; +import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -90,6 +96,8 @@ @Resource private TCECClient tcecClient; + + @Resource ELuTongClient eLuTongClient; /** @@ -196,10 +204,176 @@ } site.setMark(0); this.save(site); - // 推送充电站数据给监管平台 + + if(StringUtils.isNotEmpty(site.getSerAreaCode())){ + ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); + threadPoolExecutor.execute(()->{ + StationInfoReq stationInfoReq = new StationInfoReq(); + stationInfoReq.setOperatorId("91510903906171535D"); + stationInfoReq.setStationId(site.getId().toString()); + OperatorInfo operatorInfo = new OperatorInfo(); + operatorInfo.setOperatorId("91510903906171535D"); + operatorInfo.setOperatorName("四川明星新能源科技有限公司"); + operatorInfo.setOperatorTel1("18683346252"); + operatorInfo.setOperatorTel2("13982508784"); + operatorInfo.setOperatorRegAddress("遂宁市船山区渠河南路18号"); + stationInfoReq.setOperatorInfo(operatorInfo); + List<StationInfo> stationInfos = new ArrayList<>(); + stationInfos.add(buildStationInfo(site)); + stationInfoReq.setItemSize(stationInfos.size()); + stationInfoReq.setStationInfos(stationInfos); + R r = eLuTongClient.pushStationInfo(stationInfoReq); + if(200 != r.getCode()){ + System.out.println(r.getMsg()); + } + }); + } return AjaxResult.success(); } - + + + private StationInfo buildStationInfo(Site site){ + StationInfo stationInfo = new StationInfo(); + stationInfo.setSerAreaCode(site.getSerAreaCode()); + stationInfo.setOperatorId("91510903906171535D"); + stationInfo.setStationId(site.getId().toString()); + stationInfo.setStationName(site.getName()); + stationInfo.setStationMode("CD"); + stationInfo.setAreaCode(site.getDistrictsCode()); + stationInfo.setServiceTel(site.getServicePhone()); + switch (site.getSiteType()){ + case 0: + stationInfo.setStationType(255); + break; + case 1: + stationInfo.setStationType(1); + break; + case 2: + stationInfo.setStationType(50); + break; + case 3: + stationInfo.setStationType(100); + break; + case 4: + stationInfo.setStationType(101); + break; + case 5: + stationInfo.setStationType(102); + break; + case 6: + stationInfo.setStationType(103); + break; + } + switch (site.getStatus()){ + case 3: + stationInfo.setStationStatus(5); + break; + case 2: + stationInfo.setStationStatus(6); + break; + case 1: + stationInfo.setStationStatus(50); + break; + } + stationInfo.setParkNums(site.getParkingSpace()); + stationInfo.setStationLng(Double.parseDouble(site.getLon())); + stationInfo.setStationLat(Double.parseDouble(site.getLat())); + stationInfo.setSiteGuide(site.getGuide()); + switch (site.getConstructionSite()){ + case 1: + stationInfo.setConstruction(1); + break; + case 2: + stationInfo.setConstruction(2); + break; + case 3: + stationInfo.setConstruction(3); + break; + case 4: + stationInfo.setConstruction(4); + break; + case 5: + stationInfo.setConstruction(5); + break; + case 6: + stationInfo.setConstruction(6); + break; + case 7: + stationInfo.setConstruction(7); + break; + case 8: + stationInfo.setConstruction(8); + break; + case 9: + stationInfo.setConstruction(9); + break; + case 10: + stationInfo.setConstruction(10); + break; + case 11: + stationInfo.setConstruction(11); + break; + case 0: + stationInfo.setConstruction(255); + break; + } + if(StringUtils.isNotEmpty(site.getImgUrl())){ + stationInfo.setPictures(Arrays.asList(site.getImgUrl().split(","))); + } + stationInfo.setMatchCars(site.getVehicleDescription()); + stationInfo.setBusineHours(site.getStartServiceTime() + " - " + site.getEndServiceTime()); + stationInfo.setEquipmentInfos(buildEquipmentInfo(site)); + return stationInfo; + } + + private List<EquipmentInfo> buildEquipmentInfo(Site site){ + List<TChargingPile> list = chargingPileService.list(new LambdaQueryWrapper<TChargingPile>() + .eq(TChargingPile::getSiteId, site.getId()).eq(TChargingPile::getDelFlag, 0)); + return new ArrayList<EquipmentInfo>(){{ + for (TChargingPile chargingPile : list) { + EquipmentInfo equipmentInfo = new EquipmentInfo(); + equipmentInfo.setEquipmentId(chargingPile.getId().toString()); + equipmentInfo.setEquipmentName(chargingPile.getName()); + equipmentInfo.setManufacturerId(chargingPile.getManufacturerCode()); + equipmentInfo.setManufacturerName(chargingPile.getManufacturer()); + equipmentInfo.setEquipmentModel(chargingPile.getEquipmentType()); + if(null != chargingPile.getProductionDate()){ + equipmentInfo.setProductionDate(chargingPile.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); + } + equipmentInfo.setEquipmentType(0 == chargingPile.getType() ? 5 : chargingPile.getType()); + if(StringUtils.isNotEmpty(chargingPile.getEquipmentLng())){ + equipmentInfo.setEquipmentLng(Double.parseDouble(chargingPile.getEquipmentLng())); + } + if(StringUtils.isNotEmpty(chargingPile.getEquipmentLat())){ + equipmentInfo.setEquipmentLat(Double.parseDouble(chargingPile.getEquipmentLat())); + } + equipmentInfo.setPower(chargingPile.getRatedPower().doubleValue()); + equipmentInfo.setConnectorInfos(buildConnectorInfo(chargingPile)); + add(equipmentInfo); + } + }}; + } + + + private List<ConnectorInfo> buildConnectorInfo(TChargingPile chargingPile){ + List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>() + .eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)); + return new ArrayList<ConnectorInfo>(){{ + for (TChargingGun chargingGun : list) { + ConnectorInfo connectorInfo = new ConnectorInfo(); + connectorInfo.setConnectorId(chargingGun.getId().toString()); + connectorInfo.setConnectorName(chargingGun.getName()); + connectorInfo.setConnectorType(0 == chargingGun.getType() ? 6 : chargingGun.getType()); + connectorInfo.setVoltageUpperLimits(chargingGun.getUpperRatedVoltage().intValue()); + connectorInfo.setVoltageLowerLimits(chargingGun.getLowerLimitOfRatedVoltage().intValue()); + connectorInfo.setCurrent(chargingGun.getRatedCurrent().intValue()); + connectorInfo.setPower(chargingGun.getRatedPower().doubleValue()); + connectorInfo.setParkNo(chargingGun.getParkingNumber()); + connectorInfo.setNationalStandard(Integer.parseInt(chargingGun.getNationalStandard())); + add(connectorInfo); + } + }}; + } /** * 编辑站点 @@ -227,6 +401,30 @@ } this.updateById(site); + tcecClient.superviseNotificationStationInfo(site.getId()); + if(StringUtils.isNotEmpty(site.getSerAreaCode())){ + ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); + threadPoolExecutor.execute(()->{ + StationInfoReq stationInfoReq = new StationInfoReq(); + stationInfoReq.setOperatorId("91510903906171535D"); + stationInfoReq.setStationId(site.getId().toString()); + OperatorInfo operatorInfo = new OperatorInfo(); + operatorInfo.setOperatorId("91510903906171535D"); + operatorInfo.setOperatorName("四川明星新能源科技有限公司"); + operatorInfo.setOperatorTel1("18683346252"); + operatorInfo.setOperatorTel2("13982508784"); + operatorInfo.setOperatorRegAddress("遂宁市船山区渠河南路18号"); + stationInfoReq.setOperatorInfo(operatorInfo); + List<StationInfo> stationInfos = new ArrayList<>(); + stationInfos.add(buildStationInfo(site)); + stationInfoReq.setItemSize(stationInfos.size()); + stationInfoReq.setStationInfos(stationInfos); + R r = eLuTongClient.pushStationInfo(stationInfoReq); + if(200 != r.getCode()){ + System.out.println(r.getMsg()); + } + }); + } return AjaxResult.success(); } @@ -280,56 +478,56 @@ if(null == site.getSort()){ return AjaxResult.error("排序不能为空"); } - if(StringUtils.isEmpty(site.getAreaCodeCountryside())){ - return AjaxResult.error("充换电站所在县以下行政区划代码不能为空"); - } - if(null == site.getStationClassification()){ - return AjaxResult.error("请选择站点分类"); - } - if(null == site.getGeneralApplicationType()){ - return AjaxResult.error("请选择通用类型"); - } - if(null == site.getParkType()){ - return AjaxResult.error("请选择停车费类型"); - } - if(null == site.getRoundTheClock()){ - return AjaxResult.error("请选择是否7*24h营业"); - } - if (site.getStationClassification()!=1&& (!org.springframework.util.StringUtils.hasLength(site.getSwapMatchCars()))){ - return AjaxResult.error("服务车型描述不能为空"); - } - if(null == site.getElectricityType()){ - return AjaxResult.error("请选择电费类型"); - } - if(null == site.getBusinessExpandType()){ - return AjaxResult.error("请选择报装类型"); - } - if(null == site.getCapacity()){ - return AjaxResult.error("报装电源容量不能为空"); - } - if(null == site.getRatedPower()){ - return AjaxResult.error("站点额定总功率不能为空"); - } - if(StringUtils.isEmpty(site.getOfficialRunTime())){ - return AjaxResult.error("请选择正式投运时间"); - } - if(null == site.getPeriodFee()){ - return AjaxResult.error("请选择峰谷时分"); - } - if(null == site.getVideoMonitor()){ - return AjaxResult.error("请选择视频监控配套情况"); - } - if(StringUtils.isEmpty(site.getEquipmentOwnerName())){ - return AjaxResult.error("设备所属方名称不能为空"); - } - if(null == site.getSupplyType()){ - return AjaxResult.error("请选择供电类型"); - } - if(site.getSupplyType()==1){ - if (StringUtils.isEmpty(site.getResidentNo())){ - return AjaxResult.error("供电局用户编号不能为空"); - } - } +// if(StringUtils.isEmpty(site.getAreaCodeCountryside())){ +// return AjaxResult.error("充换电站所在县以下行政区划代码不能为空"); +// } +// if(null == site.getStationClassification()){ +// return AjaxResult.error("请选择站点分类"); +// } +// if(null == site.getGeneralApplicationType()){ +// return AjaxResult.error("请选择通用类型"); +// } +// if(null == site.getParkType()){ +// return AjaxResult.error("请选择停车费类型"); +// } +// if(null == site.getRoundTheClock()){ +// return AjaxResult.error("请选择是否7*24h营业"); +// } +// if (site.getStationClassification()!=1&& (!org.springframework.util.StringUtils.hasLength(site.getSwapMatchCars()))){ +// return AjaxResult.error("服务车型描述不能为空"); +// } +// if(null == site.getElectricityType()){ +// return AjaxResult.error("请选择电费类型"); +// } +// if(null == site.getBusinessExpandType()){ +// return AjaxResult.error("请选择报装类型"); +// } +// if(null == site.getCapacity()){ +// return AjaxResult.error("报装电源容量不能为空"); +// } +// if(null == site.getRatedPower()){ +// return AjaxResult.error("站点额定总功率不能为空"); +// } +// if(StringUtils.isEmpty(site.getOfficialRunTime())){ +// return AjaxResult.error("请选择正式投运时间"); +// } +// if(null == site.getPeriodFee()){ +// return AjaxResult.error("请选择峰谷时分"); +// } +// if(null == site.getVideoMonitor()){ +// return AjaxResult.error("请选择视频监控配套情况"); +// } +// if(StringUtils.isEmpty(site.getEquipmentOwnerName())){ +// return AjaxResult.error("设备所属方名称不能为空"); +// } +// if(null == site.getSupplyType()){ +// return AjaxResult.error("请选择供电类型"); +// } +// if(site.getSupplyType()==1){ +// if (StringUtils.isEmpty(site.getResidentNo())){ +// return AjaxResult.error("供电局用户编号不能为空"); +// } +// } return AjaxResult.success(); } -- Gitblit v1.7.1