update 第三方平台相关方法

This commit is contained in:
Lemon
2025-02-25 14:49:04 +08:00
parent 382622e187
commit ee0414e2b0
26 changed files with 1381 additions and 1687 deletions

View File

@@ -33,13 +33,13 @@ public interface NRService {
* @return
* @throws UnsupportedEncodingException
*/
Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException;
// Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException;
/**
* 校验签名
* @param dto
*/
Map<String, String> checkoutSign(CommonParamsDTO dto);
// Map<String, String> checkoutSign(CommonParamsDTO dto);
/**
* 推送充电站信息

View File

@@ -11,7 +11,10 @@ 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.JiangSuConstructionEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.PileStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.PageUtils;
import com.jsowell.common.util.StringUtils;
@@ -24,6 +27,7 @@ import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.nanrui.NRQueryOrderDTO;
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
import com.jsowell.pile.service.*;
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;
@@ -35,12 +39,10 @@ import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.thirdparty.common.CommonService;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.service.LianLianService;
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.nanrui.domain.*;
import com.jsowell.thirdparty.nanrui.service.NRService;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomStringUtils;
@@ -88,10 +90,7 @@ public class NRServiceImpl implements NRService {
private ThirdPartyStationRelationService thirdPartyStationRelationService;
@Autowired
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
@Autowired
private ThirdPartySettingInfoService thirdPartySettingInfoService;
private ThirdpartySecretInfoService thirdpartySecretInfoService;
@Autowired
private LianLianService lianLianService;
@@ -120,15 +119,15 @@ public class NRServiceImpl implements NRService {
dataSecretIv, signSecret, dataSecret);
}
@Override
public Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException {
return lianLianService.generateToken(dto);
}
// @Override
// public Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException {
// return lianLianService.generateToken(dto);
// }
@Override
public Map<String, String> checkoutSign(CommonParamsDTO dto) {
return lianLianService.checkoutSign(dto);
}
// @Override
// public Map<String, String> checkoutSign(CommonParamsDTO dto) {
// return lianLianService.checkoutSign(dto);
// }
/**
* 推送充电站信息
@@ -254,14 +253,14 @@ public class NRServiceImpl implements NRService {
// 通过第三方配置类型查询相关配置信息
ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo();
settingInfo.setType(dto.getThirdPartyType());
ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo);
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getJiangSuPlatformSecretInfo();
String operatorId = thirdPartySettingInfo.getOperatorId();
String operatorSecret = thirdPartySettingInfo.getOperatorSecret();
String signSecret = thirdPartySettingInfo.getSignSecret();
String dataSecret = thirdPartySettingInfo.getDataSecret();
String dataSecretIv = thirdPartySettingInfo.getDataSecretIv();
String urlAddress = thirdPartySettingInfo.getUrlAddress();
String operatorId = thirdPartySecretInfoVO.getTheirOperatorId();
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();
String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv();
String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix();
// 拼装南瑞平台所需参数
NRStationInfo nrStationInfo = NRStationInfo.builder()
@@ -366,10 +365,8 @@ public class NRServiceImpl implements NRService {
// 未查到数据
return null;
}
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
if (configInfo == null) {
return null;
}
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getJiangSuPlatformSecretInfo();
PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) {
// 拼装参数
@@ -431,17 +428,8 @@ public class NRServiceImpl implements NRService {
map.put("StationInfos", resultList);
// 加密
Map<String, String> resultMap = Maps.newLinkedHashMap();
// 加密数据
byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(),
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
String encryptData = Encodes.encodeBase64(encryptText);
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
resultMap.put("Sig", resultSign);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
return resultMap;
}
@@ -588,10 +576,8 @@ public class NRServiceImpl implements NRService {
public Map<String, String> query_station_status(QueryStationInfoDTO dto) {
List<String> stationIds = dto.getStationIds();
List<NRStationStatusInfo> resultList = new ArrayList<>();
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
if (configInfo == null) {
return null;
}
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getJiangSuPlatformSecretInfo();
// 将 stationIdList 转换成 List<Long>
List<Long> stationLongList = stationIds.stream()
.map(Long::parseLong)
@@ -651,17 +637,8 @@ public class NRServiceImpl implements NRService {
map.put("StationStatusInfos", resultList);
// 加密
Map<String, String> resultMap = Maps.newLinkedHashMap();
// 加密数据
byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(map).getBytes(),
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
String encryptData = Encodes.encodeBase64(encryptText);
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
resultMap.put("Sig", resultSign);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(map, thirdPartySecretInfoVO.getOurDataSecret(),
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
return resultMap;
}
@@ -718,10 +695,8 @@ public class NRServiceImpl implements NRService {
@Override
public Map<String, String> query_order_info(NRQueryOrderDTO dto) {
List<JiangSuOrderInfo> resultList = new ArrayList<>();
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
if (configInfo == null) {
return null;
}
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getJiangSuPlatformSecretInfo();
List<JiangSuOrderInfoVO> nrOrderInfos = orderBasicInfoService.getNROrderInfos(dto);
if (CollectionUtils.isEmpty(nrOrderInfos)) {
return Maps.newLinkedHashMap();
@@ -731,17 +706,8 @@ public class NRServiceImpl implements NRService {
resultList.add(jiangSuOrderInfo);
}
// 加密
Map<String, String> resultMap = Maps.newLinkedHashMap();
// 加密数据
byte[] encryptText = Cryptos.aesEncrypt(JSON.toJSONString(resultList).getBytes(),
configInfo.getDataSecret().getBytes(), configInfo.getDataSecretIv().getBytes());
String encryptData = Encodes.encodeBase64(encryptText);
resultMap.put("Data", encryptData);
// 生成sig
String resultSign = GBSignUtils.sign(resultMap, configInfo.getSignSecret());
resultMap.put("Sig", resultSign);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(resultList, thirdPartySecretInfoVO.getOurDataSecret(),
thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret());
return resultMap;
}
@@ -872,4 +838,19 @@ public class NRServiceImpl implements NRService {
}
return resultList;
}
/**
* 获取江苏省平台配置密钥信息
*
* @return
*/
private ThirdPartySecretInfoVO getJiangSuPlatformSecretInfo() {
// 通过第三方平台类型查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getTypeCode());
if (thirdPartySecretInfoVO == null) {
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
}
thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU);
return thirdPartySecretInfoVO;
}
}