新增 深圳平台 查询充电站列表接口

This commit is contained in:
Lemon
2024-05-15 14:31:56 +08:00
parent 659818ed43
commit 2ae8bc39b6
2 changed files with 92 additions and 19 deletions

View File

@@ -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();

View File

@@ -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<String, String> 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<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, secretInfoVO);
return resultMap;
}
/**
* 查询充电站信息 query_stations_info
* @param dto 查询站点信息dto
* @return
*/
@Override
public Map<String, String> queryStationsInfo(QueryStationInfoDTO dto) {
List<StationInfo> resultList = new ArrayList<>();
// 查询出要查询的充电站id并set进 dto 的stationIds
if (StringUtils.isNotBlank(dto.getThirdPlatformType())) {
List<ThirdPartyStationRelation> relationList = thirdPartyStationRelationService.selectThirdPartyStationRelationList(dto.getThirdPlatformType());
if (CollectionUtils.isNotEmpty(relationList)) {
List<String> 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<ThirdPartyStationInfoVO> stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto);
if (CollectionUtils.isEmpty(stationInfos)) {
// 未查到数据
return null;
}
PageInfo<ThirdPartyStationInfoVO> 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<EquipmentInfo> 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<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(jsonObject, shenZhenSecretInfo);
return resultMap;
}
/**
* 获取深圳平台相关密钥信息
* @return