Merge branch 'dev-new' into dev-new-rabbitmq

This commit is contained in:
Guoqs
2025-01-02 09:34:51 +08:00
3 changed files with 39 additions and 6 deletions

View File

@@ -190,6 +190,11 @@ public class CacheConstants {
*/ */
public static final String CHARGING_HANDSHAKE_DATA_BY_TRANSACTION_CODE = "charging_handshake_data_by_transaction_code:"; public static final String CHARGING_HANDSHAKE_DATA_BY_TRANSACTION_CODE = "charging_handshake_data_by_transaction_code:";
/**
* 第三方平台Token缓存
*/
public static final String THIRD_PARTY_TOKEN_BY_OPERATOR_ID = "third_party_token_by_operator_id:";
/** /**
* 充电桩状态前缀 * 充电桩状态前缀
*/ */

View File

@@ -4,10 +4,13 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.bean.BeanUtils;
import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.*;
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO; import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO; import com.jsowell.pile.dto.ningxiajiaotou.NXJTQueryStationInfoDTO;
@@ -22,12 +25,14 @@ import com.jsowell.thirdparty.platform.util.Encodes;
import com.jsowell.thirdparty.platform.util.GBSignUtils; import com.jsowell.thirdparty.platform.util.GBSignUtils;
import org.bouncycastle.crypto.CryptoException; import org.bouncycastle.crypto.CryptoException;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException; import java.security.NoSuchProviderException;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
/** /**
* 第三方平台对接需要的api集合 * 第三方平台对接需要的api集合
@@ -440,6 +445,15 @@ public interface ThirdPartyPlatformService extends InitializingBean {
default String getToken(String urlAddress, String operatorId, String operatorSecret, default String getToken(String urlAddress, String operatorId, String operatorSecret,
String dataSecretIv, String signSecret, String dataSecret) { String dataSecretIv, String signSecret, String dataSecret) {
String token = ""; String token = "";
// 先查询缓存有没有token
String tokenKey = CacheConstants.THIRD_PARTY_TOKEN_BY_OPERATOR_ID + operatorId;
RedisCache redisCache = BeanUtils.getBean(RedisCache.class);
String cacheToken = redisCache.getCacheObject(tokenKey);
if (StringUtils.isNotBlank(cacheToken)) {
token = cacheToken;
return token;
}
try { try {
// 请求地址 // 请求地址
String requestUrl = urlAddress + "query_token"; String requestUrl = urlAddress + "query_token";
@@ -477,8 +491,11 @@ public interface ThirdPartyPlatformService extends InitializingBean {
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()), byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()),
dataSecret.getBytes(), dataSecretIv.getBytes()); dataSecret.getBytes(), dataSecretIv.getBytes());
String dataStr = new String(plainText, StandardCharsets.UTF_8); String dataStr = new String(plainText, StandardCharsets.UTF_8);
Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr); Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(dataStr);
token = resultMap.get("AccessToken"); token = String.valueOf(resultMap.get("AccessToken"));
int tokenAvailableTime = Integer.parseInt(String.valueOf(resultMap.get("TokenAvailableTime")));
// 将token存入缓存
redisCache.setCacheObject(tokenKey, token, tokenAvailableTime, TimeUnit.SECONDS);
// logger.info("token: {}", token); // logger.info("token: {}", token);
} }
// logger.info("获取令牌 result:{}, token: {}", result, token); // logger.info("获取令牌 result:{}, token: {}", result, token);

View File

@@ -500,9 +500,10 @@ public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService {
if (orderDetail == null) { if (orderDetail == null) {
return null; return null;
} }
// 拼装订单编号
String startChargeSeq = Constants.OPERATORID_JIANG_SU + orderCode + DateUtils.dateTimeNow(DateUtils.YYMMDD);
ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder() ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder()
.startChargeSeq(orderCode) .startChargeSeq(startChargeSeq)
// .startChargeType() // .startChargeType()
.connectorId(orderBasicInfo.getPileConnectorCode()) .connectorId(orderBasicInfo.getPileConnectorCode())
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()))
@@ -553,8 +554,10 @@ public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService {
PageInfo<OrderVO> pageInfo = new PageInfo<>(orderVOS); PageInfo<OrderVO> pageInfo = new PageInfo<>(orderVOS);
for (OrderVO orderVO : pageInfo.getList()) { for (OrderVO orderVO : pageInfo.getList()) {
// 拼装订单编号
String startChargeSeq = Constants.OPERATORID_JIANG_SU + orderVO.getOrderCode() + DateUtils.dateTimeNow(DateUtils.YYMMDD);
ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder() ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder()
.startChargeSeq(orderVO.getOrderCode()) .startChargeSeq(startChargeSeq)
// .startChargeType() // .startChargeType()
.connectorId(orderVO.getPileConnectorCode()) .connectorId(orderVO.getPileConnectorCode())
.startTime(orderVO.getStartTime()) .startTime(orderVO.getStartTime())
@@ -645,17 +648,25 @@ public class GuangXiPlatformServiceImpl implements ThirdPartyPlatformService {
String soc = realTimeMonitorData.getSOC() == null ? Constants.ZERO : info.getSOC(); String soc = realTimeMonitorData.getSOC() == null ? Constants.ZERO : info.getSOC();
String dateTime = DateUtils.getDateTime(); String dateTime = DateUtils.getDateTime();
// 拼装订单编号
String startChargeSeq = Constants.OPERATORID_JIANG_SU + orderInfo.getOrderCode() + DateUtils.dateTimeNow(DateUtils.YYMMDD);
SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder() SupEquipChargeStatusInfo supEquipChargeStatusInfo = SupEquipChargeStatusInfo.builder()
.startChargeSeq(orderInfo.getOrderCode()) .startChargeSeq(startChargeSeq)
.startChargeSeqStat(Integer.parseInt(orderStatus)) .startChargeSeqStat(Integer.parseInt(orderStatus))
// .startChargeSeqStat(2)
.connectorID(orderInfo.getPileConnectorCode()) .connectorID(orderInfo.getPileConnectorCode())
.connectorStatus(Integer.parseInt(realTimeMonitorData.getConnectorStatus())) // 3-充电中 .connectorStatus(Integer.parseInt(realTimeMonitorData.getConnectorStatus())) // 3-充电中
// .connectorStatus(3) // 3-充电中
.currentA(current.setScale(1, RoundingMode.HALF_UP)) .currentA(current.setScale(1, RoundingMode.HALF_UP))
// .currentA(new BigDecimal("20.3"))
.voltageA(voltage.setScale(1, RoundingMode.HALF_UP)) .voltageA(voltage.setScale(1, RoundingMode.HALF_UP))
// .voltageA(new BigDecimal("260.7"))
.soc(new BigDecimal(soc)) .soc(new BigDecimal(soc))
// .soc(new BigDecimal("79"))
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())) .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime()))
.endTime(dateTime) .endTime(dateTime)
.totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree())) .totalPower(new BigDecimal(realTimeMonitorData.getChargingDegree()))
// .totalPower(new BigDecimal("5292.21"))
.build(); .build();