update 海南省平台

This commit is contained in:
Lemon
2025-05-14 13:48:49 +08:00
parent deabdd30a1
commit ebdfbc51fd

View File

@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum; import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
@@ -20,6 +21,8 @@ import com.jsowell.pile.domain.*;
import com.jsowell.pile.domain.ykcCommond.StartChargingCommand; import com.jsowell.pile.domain.ykcCommond.StartChargingCommand;
import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.*;
import com.jsowell.pile.service.*; import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.EquipmentInfo;
import com.jsowell.pile.thirdparty.ZDLEquipmentInfo; import com.jsowell.pile.thirdparty.ZDLEquipmentInfo;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO;
@@ -32,10 +35,8 @@ import com.jsowell.pile.vo.web.EchoBillingTemplateVO;
import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO;
import com.jsowell.thirdparty.lianlian.domain.*; import com.jsowell.thirdparty.lianlian.domain.*;
import com.jsowell.thirdparty.lianlian.vo.EquipmentAuthVO; import com.jsowell.thirdparty.lianlian.vo.*;
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO; import com.jsowell.thirdparty.platform.domain.SupStationInfo;
import com.jsowell.thirdparty.lianlian.vo.QueryStartChargeVO;
import com.jsowell.thirdparty.lianlian.vo.QueryStopChargeVO;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
import com.jsowell.thirdparty.platform.domain.HNStationInfo; import com.jsowell.thirdparty.platform.domain.HNStationInfo;
@@ -56,6 +57,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -76,6 +78,9 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired @Autowired
private PileStationInfoService pileStationInfoService; private PileStationInfoService pileStationInfoService;
@Autowired
private RedisCache redisCache;
@Autowired @Autowired
private PileBasicInfoService pileBasicInfoService; private PileBasicInfoService pileBasicInfoService;
@@ -113,6 +118,68 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
System.out.println("当前类名:" + this.getClass().getSimpleName()); System.out.println("当前类名:" + this.getClass().getSimpleName());
} }
/**
* 请求令牌 query_token
* @param dto
* @return
*/
@Override
public Map<String, String> queryToken(CommonParamsDTO dto) {
AccessTokenVO vo = new AccessTokenVO();
// 0:成功1:失败
int succStat = 0;
// 0:无1:无此对接平台2:密钥错误; 399:自定义
int failReason = 0;
String operatorId = dto.getOperatorID();
// token缓存key值
String redisKey = operatorId + "_token:";
// 通过operatorId 查出 operatorSecret
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHaiNanPlatformSecretInfo();
if (thirdPartySecretInfoVO == null) {
failReason = 1;
succStat = 1;
} else {
String ourOperatorSecret = thirdPartySecretInfoVO.getOurOperatorSecret();
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("OperatorSecret");
}
// 对比密钥
if (!StringUtils.equals(ourOperatorSecret, inputOperatorSecret)) {
failReason = 1;
succStat = 1;
} else {
// 先查缓存中是否有已生成的token
String token = redisCache.getCacheObject(redisKey);
int expiredTime = (int) redisCache.getExpire(redisKey);
if (StringUtils.isBlank(token)){
// 生成token
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.setOperatorID(operatorId);
vo.setFailReason(failReason);
vo.setSuccStat(succStat);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getOurDataSecret()
, thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getOurSigSecret());
return resultMap;
}
public String pushStationInfoV2(PushStationInfoDTO dto) { public String pushStationInfoV2(PushStationInfoDTO dto) {
return zdlService.pushStationInfoV2(dto); return zdlService.pushStationInfoV2(dto);
} }
@@ -123,22 +190,12 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
*/ */
@Override @Override
public Map<String, String> queryStationsInfo(QueryStationInfoDTO dto) { public Map<String, String> queryStationsInfo(QueryStationInfoDTO dto) {
// 查询出要查询的充电站id并set进 dto 的stationIds
if (StringUtils.isNotBlank(dto.getThirdPlatformType())) {
List<ThirdPartyStationRelation> xdtList = thirdPartyStationRelationService.selectThirdPartyStationRelationList(dto.getThirdPlatformType());
if (CollectionUtils.isNotEmpty(xdtList)) {
List<String> stationList = xdtList.stream()
.map(x -> String.valueOf(x.getStationId()))
.collect(Collectors.toList());
dto.setStationIds(stationList);
}
}
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo(); int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
dto.setThirdPlatformType(thirdPlatformType);
PageUtils.startPage(pageNo, pageSize); PageUtils.startPage(pageNo, pageSize);
List<ThirdPartyStationInfoVO> stationInfos = pileStationInfoService.getStationInfosByThirdParty(dto); List<ThirdPartyStationInfoVO> stationInfos = pileStationInfoService.selectStationInfosByThirdParty(dto);
if (CollectionUtils.isEmpty(stationInfos)) { if (CollectionUtils.isEmpty(stationInfos)) {
// 未查到数据 // 未查到数据
return null; return null;
@@ -146,36 +203,33 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHaiNanPlatformSecretInfo(); ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHaiNanPlatformSecretInfo();
PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos); PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
List<HNStationInfo> resultList = new ArrayList<>(); List<SupStationInfo> resultList = new ArrayList<>();
HNStationInfo stationInfo = null;
for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) { for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) {
stationInfo = new HNStationInfo();
String stationId = String.valueOf(pileStationInfo.getId()); String stationId = String.valueOf(pileStationInfo.getId());
stationInfo.setStationId(stationId); SupStationInfo stationInfo = SupStationInfo.builder()
stationInfo.setOperatorId(Constants.OPERATORID_JIANG_SU); // 组织机构代码 .stationID(stationId)
String organizationCode = pileStationInfo.getOrganizationCode(); .operatorID(Constants.OPERATORID_JIANG_SU)
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { .equipmentOwnerID(ThirdPartyPlatformUtils.extractEquipmentOwnerID(pileStationInfo.getOrganizationCode()))
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); .stationName(pileStationInfo.getStationName())
stationInfo.setEquipmentOwnerId(equipmentOwnerId); .countryCode(pileStationInfo.getCountryCode())
} else { .address(pileStationInfo.getAddress())
stationInfo.setEquipmentOwnerId(Constants.OPERATORID_JIANG_SU); .serviceTel(pileStationInfo.getStationTel())
} .stationType(Integer.parseInt(pileStationInfo.getStationType()))
stationInfo.setStationName(pileStationInfo.getStationName()); .stationStatus(Integer.parseInt(pileStationInfo.getStationStatus()))
stationInfo.setCountryCode(pileStationInfo.getCountryCode()); .parkNums(Integer.parseInt(pileStationInfo.getParkNums()))
.stationLng(new BigDecimal(pileStationInfo.getStationLng()))
.stationLat(new BigDecimal(pileStationInfo.getStationLat()))
.construction(Integer.parseInt(pileStationInfo.getConstruction()))
.build();
String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213
// 根据逗号分组 // 根据逗号分组
String[] split = StringUtils.split(areaCode, ","); String[] split = StringUtils.split(areaCode, ",");
// 只取最后一部分 330213 // 只取最后一部分 330213
String subAreaCode = split[split.length - 1]; String subAreaCode = split[split.length - 1];
stationInfo.setAreaCode(subAreaCode); stationInfo.setAreaCode(subAreaCode);
stationInfo.setAddress(pileStationInfo.getAddress());
stationInfo.setServiceTel(pileStationInfo.getStationTel());
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.parseInt(pileStationInfo.getConstruction()));
// 停车费率描述 // 停车费率描述
if (StringUtils.isNotBlank(pileStationInfo.getParkFeeDescribe())) { if (StringUtils.isNotBlank(pileStationInfo.getParkFeeDescribe())) {
stationInfo.setParkFee(pileStationInfo.getParkFeeDescribe()); stationInfo.setParkFee(pileStationInfo.getParkFeeDescribe());
@@ -187,7 +241,7 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
stationInfo.setPictures(Lists.newArrayList()); stationInfo.setPictures(Lists.newArrayList());
} }
List<ZDLEquipmentInfo> pileList = pileBasicInfoService.getPileListForZDL(stationId); List<EquipmentInfo> pileList = pileBasicInfoService.getPileListForLianLian(stationId);
if (CollectionUtils.isNotEmpty(pileList)) { if (CollectionUtils.isNotEmpty(pileList)) {
stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表 stationInfo.setEquipmentInfos(pileList); // 充电设备信息列表
} }
@@ -211,6 +265,11 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
return resultMap; return resultMap;
} }
/**
* 获取充电费用
* @param stationId
* @return
*/
private Map<String, String> getPriceDescription(String stationId) { private Map<String, String> getPriceDescription(String stationId) {
Map<String, String> resultMap = Maps.newHashMap(); Map<String, String> resultMap = Maps.newHashMap();
StringBuilder electricityFee = new StringBuilder("电费:"); StringBuilder electricityFee = new StringBuilder("电费:");
@@ -275,19 +334,14 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
String thirdPartyType = dto.getThirdPartyType(); String thirdPartyType = dto.getThirdPartyType();
String pileConnectorCode = dto.getPileConnectorCode(); String pileConnectorCode = dto.getPileConnectorCode();
String status = dto.getStatus(); String status = dto.getStatus();
// 通过第三方类型查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHaiNanPlatformSecretInfo();
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
relation.setThirdPartyType(thirdPartyType); String operatorId = thirdPartySecretInfoVO.getOurOperatorId();
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
if (relationInfo == null) { String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
return null; String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
} String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
String operatorId = relationInfo.getOperatorId(); String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
String operatorSecret = relationInfo.getOperatorSecret();
String signSecret = relationInfo.getSignSecret();
String dataSecret = relationInfo.getDataSecret();
String dataSecretIv = relationInfo.getDataSecretIv();
String urlAddress = relationInfo.getUrlAddress();
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue(); String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue();
ConnectorStatusInfo info = ConnectorStatusInfo.builder() ConnectorStatusInfo info = ConnectorStatusInfo.builder()
@@ -373,7 +427,6 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
String dataSecret = secretInfoVO.getTheirDataSecret(); String dataSecret = secretInfoVO.getTheirDataSecret();
String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); String dataSecretIv = secretInfoVO.getTheirDataSecretIv();
String urlAddress = secretInfoVO.getTheirUrlPrefix(); String urlAddress = secretInfoVO.getTheirUrlPrefix();
String thirdPartyType = secretInfoVO.getPlatformType();
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue(); String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
@@ -670,21 +723,14 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
if (orderInfo == null) { if (orderInfo == null) {
return null; return null;
} }
// 通过第三方平台类型查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHaiNanPlatformSecretInfo();
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
relation.setThirdPartyType(orderInfo.getThirdPartyType()); String operatorId = thirdPartySecretInfoVO.getOurOperatorId();
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
// ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderBasicInfo.getStationId())); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
if (relationInfo == null) { String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
return null; String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
} String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
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 thirdPartyType = relationInfo.getThirdPartyType();
// 推送启动充电结果(调用接口 notification_start_charge_result) // 推送启动充电结果(调用接口 notification_start_charge_result)
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue(); String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue();
@@ -847,27 +893,20 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
public String notificationEquipChargeStatus(String orderCode) { public String notificationEquipChargeStatus(String orderCode) {
// 根据订单号查询订单信息 // 根据订单号查询订单信息
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
// 通过第三方平台类型查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHaiNanPlatformSecretInfo();
ThirdPartyStationRelation relation = new ThirdPartyStationRelation();
relation.setThirdPartyType(orderInfo.getThirdPartyType()); String operatorId = thirdPartySecretInfoVO.getOurOperatorId();
ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
// ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderInfo.getStationId())); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
if (relationInfo == null) { String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
return null; String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
} String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
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 thirdPartyType = relationInfo.getThirdPartyType();
// 调用 查询充电状态方法 // 调用 查询充电状态方法
QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO(); QueryEquipChargeStatusDTO dto = new QueryEquipChargeStatusDTO();
dto.setStartChargeSeq(orderCode); dto.setStartChargeSeq(orderCode);
// 根据type获取operatorId // 根据type获取operatorId
String operatorIdByType = ThirdPartyOperatorIdEnum.getOperatorIdByType(thirdPartyType); String operatorIdByType = ThirdPartyOperatorIdEnum.getOperatorIdByType(thirdPartySecretInfoVO.getTheirOperatorId());
dto.setOperatorID(operatorIdByType); dto.setOperatorID(operatorIdByType);
Map<String, String> map = queryEquipChargeStatus(dto); Map<String, String> map = queryEquipChargeStatus(dto);
if (map == null) { if (map == null) {
@@ -875,7 +914,6 @@ public class HaiNanPlatformServiceImpl implements ThirdPartyPlatformService {
} }
String data = map.get("Data"); String data = map.get("Data");
// 解密data (此处解密需用 thirdparty_platform_config 的密钥配置) // 解密data (此处解密需用 thirdparty_platform_config 的密钥配置)
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getHaiNanPlatformSecretInfo();
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data), byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data),
thirdPartySecretInfoVO.getOurDataSecret().getBytes(), thirdPartySecretInfoVO.getOurDataSecretIv().getBytes()); thirdPartySecretInfoVO.getOurDataSecret().getBytes(), thirdPartySecretInfoVO.getOurDataSecretIv().getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8); String dataStr = new String(plainText, StandardCharsets.UTF_8);