From 2ae8bc39b66a2bb3300bf343cd94e7f26f59d8f7 Mon Sep 17 00:00:00 2001 From: Lemon Date: Wed, 15 May 2024 14:31:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E6=B7=B1=E5=9C=B3?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=20=E6=9F=A5=E8=AF=A2=E5=85=85=E7=94=B5?= =?UTF-8?q?=E7=AB=99=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PileBasicInfoServiceImpl.java | 2 + .../impl/ShenZhenPlatformServiceImpl.java | 109 +++++++++++++++--- 2 files changed, 92 insertions(+), 19 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index 932b5fe58..030b66f73 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -1122,6 +1122,8 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { connectorInfo.setVoltageUpperLimits(Integer.valueOf(modelInfo.getRatedVoltage())); connectorInfo.setVoltageLowerLimits(Integer.valueOf(modelInfo.getRatedVoltage())); connectorInfo.setCurrent(Integer.valueOf(modelInfo.getRatedCurrent())); + connectorInfo.setConnectorName(pileConnectorInfo.getPileConnectorCode()); + if (!StringUtils.equals(modelInfo.getConnectorNum(), "1")) { // 如果不是单枪,则枪口功率需要除以枪口数量 String ratedPowerStr = modelInfo.getRatedPower(); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java index 008b420d6..e489f1b33 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ShenZhenPlatformServiceImpl.java @@ -2,6 +2,7 @@ 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; @@ -10,31 +11,37 @@ import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.JWTUtils; +import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.ThirdPartyPlatformConfig; +import com.jsowell.pile.domain.ThirdPartyStationRelation; +import com.jsowell.pile.dto.QueryStationInfoDTO; import com.jsowell.pile.service.PileBasicInfoService; import com.jsowell.pile.service.PileStationInfoService; +import com.jsowell.pile.service.ThirdPartyStationRelationService; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.pile.thirdparty.EquipmentInfo; +import com.jsowell.pile.thirdparty.ZDLStationInfo; import com.jsowell.pile.vo.ThirdPartySecretInfoVO; +import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO; import com.jsowell.thirdparty.platform.common.StationInfo; 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.Encodes; -import com.jsowell.thirdparty.platform.util.GBSignUtils; -import com.jsowell.thirdparty.platform.util.HttpRequestUtil; +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.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 深圳平台 Service @@ -51,6 +58,9 @@ public class ShenZhenPlatformServiceImpl implements ThirdPartyPlatformService { @Autowired private ThirdpartySecretInfoService thirdpartySecretInfoService; + @Autowired + private ThirdPartyStationRelationService thirdPartyStationRelationService; + @Autowired private PileBasicInfoService pileBasicInfoService; @@ -133,9 +143,6 @@ public class ShenZhenPlatformServiceImpl implements ThirdPartyPlatformService { String operatorId = dto.getOperatorID(); // 通过operatorId 查出 相关配置信息 ThirdPartySecretInfoVO secretInfoVO = getShenZhenSecretInfo(); - if (secretInfoVO == null) { - throw new BusinessException("1", "无此对接平台"); - } String operatorSecret = secretInfoVO.getOurOperatorSecret(); String dataSecret = secretInfoVO.getOurDataSecret(); @@ -167,22 +174,86 @@ public class ShenZhenPlatformServiceImpl implements ThirdPartyPlatformService { vo.setFailReason(0); vo.setSuccStat(0); - Map resultMap = Maps.newLinkedHashMap(); - // 加密数据 - byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(vo).getBytes(), - dataSecret.getBytes(), dataSecretIv.getBytes()); - String encryptData = Encodes.encodeBase64(encryptText); // data - resultMap.put("Ret", "0"); - resultMap.put("Msg", "请求令牌成功!"); - resultMap.put("Data", encryptData); - // 生成sig - String resultSign = GBSignUtils.sign(resultMap, signSecret); - resultMap.put("Sig", resultSign); - + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, secretInfoVO); return resultMap; } + /** + * 查询充电站信息 query_stations_info + * @param dto 查询站点信息dto + * @return + */ + @Override + public Map queryStationsInfo(QueryStationInfoDTO dto) { + List resultList = new ArrayList<>(); + // 查询出要查询的充电站id并set进 dto 的stationIds + if (StringUtils.isNotBlank(dto.getThirdPlatformType())) { + List relationList = thirdPartyStationRelationService.selectThirdPartyStationRelationList(dto.getThirdPlatformType()); + if (CollectionUtils.isNotEmpty(relationList)) { + List stationList = relationList.stream() + .map(x -> String.valueOf(x.getStationId())) + .collect(Collectors.toList()); + dto.setStationIds(stationList); + } + } + // 设置分页参数 + 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; + } + + PageInfo pageInfo = new PageInfo<>(stationInfos); + StationInfo stationInfo = null; + for (ThirdPartyStationInfoVO stationVO : pageInfo.getList()) { + Long stationId = stationVO.getId(); + stationInfo = StationInfo.builder() + .stationID(String.valueOf(stationVO.getId())) + .operatorID(Constants.OPERATORID_JIANG_SU) + // .equipmentOwnerID() + .stationName(stationVO.getStationName()) + .countryCode(stationVO.getCountryCode()) + .areaCode(stationVO.getAreaCode()) + .address(stationVO.getAddress()) + .stationType(Integer.parseInt(stationVO.getStationType())) + .stationStatus(Integer.parseInt(stationVO.getStationStatus())) + .parkNums(0) // 默认 0:未知 + .stationLng(new BigDecimal(stationVO.getStationLng())) + .stationLat(new BigDecimal(stationVO.getStationLat())) + .construction(Integer.parseInt(stationVO.getConstruction())) + + .build(); + String stationTel = stationVO.getStationTel(); + if (StringUtils.isNotBlank(stationTel)) { + stationInfo.setStationTel(stationTel); + stationInfo.setServiceTel(stationTel); + } + if (StringUtils.isNotBlank(stationVO.getPictures())) { + stationInfo.setPictures(Lists.newArrayList(stationVO.getPictures().split(","))); + } + // 设备信息列表 + List pileList = pileBasicInfoService.getPileListForLianLian(String.valueOf(stationId)); + stationInfo.setEquipmentInfos(pileList); + + resultList.add(stationInfo); + } + ThirdPartySecretInfoVO shenZhenSecretInfo = getShenZhenSecretInfo(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("PageNo", pageInfo.getPageNum()); + jsonObject.put("PageCount", pageInfo.getPages()); + jsonObject.put("ItemSize", resultList.size()); + jsonObject.put("StationInfos", resultList); + + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(jsonObject, shenZhenSecretInfo); + return resultMap; + } + /** * 获取深圳平台相关密钥信息 * @return