mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-01 16:40:04 +08:00
update 第三方平台相关方法
This commit is contained in:
@@ -21,7 +21,7 @@ public interface NXJTService {
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException;
|
||||
// Map<String, String> generateToken(CommonParamsDTO dto) throws UnsupportedEncodingException;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.jsowell.thirdparty.ningxiajiaotou.service.impl;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
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.DateUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -10,6 +14,7 @@ import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryOrdersInfoDTO;
|
||||
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.ningxiajiaotou.NXJTOrderVO;
|
||||
import com.jsowell.pile.vo.ningxiajiaotou.NXJTStationInfoVO;
|
||||
@@ -20,6 +25,8 @@ 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.ningxiajiaotou.service.NXJTService;
|
||||
import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils;
|
||||
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -43,7 +50,7 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
||||
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
@@ -60,10 +67,10 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
@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);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取令牌
|
||||
@@ -90,10 +97,7 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNXJTPlatformSecretInfo();
|
||||
// 分页
|
||||
PageUtils.startPage(pageNo, pageSize);
|
||||
List<NXJTStationInfoVO> stationInfos = pileStationInfoService.NXJTQueryStationsInfo(dto);
|
||||
@@ -106,17 +110,8 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
map.put("stationInfos", pageInfo.getList());
|
||||
|
||||
// 加密
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -127,10 +122,8 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> queryFreePileNumber(NXJTQueryStationInfoDTO dto) {
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNXJTPlatformSecretInfo();
|
||||
|
||||
long stationId = Long.parseLong(dto.getStationId());
|
||||
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.getUniAppConnectorList(stationId);
|
||||
// 先根据pileSn分组,获取设备总数
|
||||
@@ -153,17 +146,8 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
map.put("freePileNum", freePileNumber);
|
||||
|
||||
// 加密
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -178,10 +162,8 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
int pageNo = dto.getPageNo() == null ? 1 : dto.getPageNo();
|
||||
int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize();
|
||||
|
||||
ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (configInfo == null) {
|
||||
return null;
|
||||
}
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getNXJTPlatformSecretInfo();
|
||||
|
||||
// 如果开始时间、结束时间为空,则默认为一个月内
|
||||
if (StringUtils.isBlank(dto.getStartTime()) && StringUtils.isBlank(dto.getEndTime())) {
|
||||
dto.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.addMonths(new Date(), -1)));
|
||||
@@ -212,17 +194,8 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
map.put("orderInfos", 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;
|
||||
}
|
||||
|
||||
@@ -238,4 +211,19 @@ public class NXJTServiceImpl implements NXJTService {
|
||||
return queryOrdersInfoByPlateNumber(dto);
|
||||
// return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取宁夏交投平台配置密钥信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ThirdPartySecretInfoVO getNXJTPlatformSecretInfo() {
|
||||
// 通过第三方平台类型查询相关配置信息
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.NING_XIA_JIAO_TOU.getTypeCode());
|
||||
if (thirdPartySecretInfoVO == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_SELECT_INFO_IS_NULL);
|
||||
}
|
||||
thirdPartySecretInfoVO.setOurOperatorId(Constants.OPERATORID_JIANG_SU);
|
||||
return thirdPartySecretInfoVO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user