update 海南平台对接

This commit is contained in:
2024-01-25 16:00:35 +08:00
parent 77777b07ea
commit 6e37a276bf
8 changed files with 87 additions and 34 deletions

View File

@@ -60,8 +60,8 @@ public class HaiNanPlatformController extends BaseController {
logger.info("海南平台查询充电站信息 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -103,8 +103,7 @@ public class HaiNanPlatformController extends BaseController {
logger.info("海南平台查询统计信息 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -146,8 +145,8 @@ public class HaiNanPlatformController extends BaseController {
logger.info("海南平台设备接口状态查询 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -188,8 +187,8 @@ public class HaiNanPlatformController extends BaseController {
logger.info("请求设备认证 param:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -214,7 +213,6 @@ public class HaiNanPlatformController extends BaseController {
return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("请求设备认证 error:", e);
e.printStackTrace();
}
return CommonResult.failed("请求设备认证发生异常");
}
@@ -230,8 +228,8 @@ public class HaiNanPlatformController extends BaseController {
logger.info("查询业务策略信息 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -258,7 +256,6 @@ public class HaiNanPlatformController extends BaseController {
return CommonResult.success(0, "查询业务策略信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("查询业务策略信息 error:", e);
e.printStackTrace();
}
return CommonResult.failed("查询业务策略信息发生异常");
}
@@ -274,8 +271,7 @@ public class HaiNanPlatformController extends BaseController {
logger.info("海南平台请求启动充电 params :{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -339,8 +335,8 @@ public class HaiNanPlatformController extends BaseController {
logger.info("【{}】查询充电状态 params :{}", this.getClass().getSimpleName(), JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -404,8 +400,8 @@ public class HaiNanPlatformController extends BaseController {
logger.info("请求停止充电 params :{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(request)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
@@ -435,7 +431,7 @@ public class HaiNanPlatformController extends BaseController {
}
/**
* 新电途推送停止充电结果
* 推送停止充电结果
* http://localhost:8080/hainan/notificationStopChargeResult
* @param orderCode
* @return

View File

@@ -0,0 +1,38 @@
package com.jsowell.common.enums.thirdparty;
/**
* 业务信息交换enum
*/
public enum BusinessInformationExchangeEnum {
NOTIFICATION_STATION_STATUS("notification_stationStatus", "设备状态变化推送"),
NOTIFICATION_CHARGE_ORDER_INFO("notification_charge_order_info", "推送充电订单信息"),
NOTIFICATION_START_CHARGE_RESULT("notification_start_charge_result", "推送启动充电结果"),
NOTIFICATION_EQUIP_CHARGE_STATUS("notification_equip_charge_status", "推送充电状态"),
NOTIFICATION_STOP_CHARGE_RESULT("notification_stop_charge_result", "推送停止充电结果"),
CHECK_CHARGE_ORDERS("check_charge_orders", "推送订单对账结果信息"),
;
private String value;
private String label;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
BusinessInformationExchangeEnum(String value, String label) {
this.value = value;
this.label = label;
}
}

View File

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.DatatypeConverter;
import java.security.Key;
import java.util.Date;
@@ -128,6 +129,11 @@ public class JWTUtils {
return claims.getId();
}
/**
* 校验第三方平台token
* @param token 第三方平台token
* @return
*/
public static boolean checkThirdPartyToken(String token) {
token = getToken(token);
if (StringUtils.isBlank(token)) {
@@ -137,6 +143,15 @@ public class JWTUtils {
return StringUtils.isNotBlank(claims.getId());
}
public static boolean checkThirdPartyToken(HttpServletRequest request) {
if (request == null) {
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
}
// 校验令牌
String token = request.getHeader("Authorization");
return checkThirdPartyToken(token);
}
/**
* 替换Bearer
*

View File

@@ -6,6 +6,7 @@ import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.parkplatform.ParkingEnum;
import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.enums.ykc.StartModeEnum;
@@ -379,7 +380,7 @@ public class CommonService {
String thirdPartyType = relationInfo.getThirdPartyType();
// 推送启动充电结果(调用接口 notification_start_charge_result)
String url = urlAddress + "notification_start_charge_result";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue();
// String orderStatus = orderInfo.getOrderStatus();
// // 订单状态统一

View File

@@ -13,6 +13,7 @@ import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum;
import com.jsowell.common.enums.lianlian.PayChannelEnum;
import com.jsowell.common.enums.lianlian.StationPaymentEnum;
import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.OrderPayModeEnum;
@@ -58,7 +59,6 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Service
@@ -1053,7 +1053,7 @@ public class LianLianServiceImpl implements LianLianService {
String urlAddress = relationInfo.getUrlAddress();
String thirdPartyType = relationInfo.getThirdPartyType();
String url = urlAddress + "notification_stationStatus";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue();
ConnectorStatusInfo info = ConnectorStatusInfo.builder()
.connectorID(pileConnectorCode)
.status(Integer.parseInt(status))
@@ -1243,7 +1243,7 @@ public class LianLianServiceImpl implements LianLianService {
String thirdPartyType = relationInfo.getThirdPartyType();
// 推送启动充电结果(调用接口 notification_start_charge_result)
String url = urlAddress + "notification_start_charge_result";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue();
// String orderStatus = orderInfo.getOrderStatus();
// // 订单状态统一
@@ -1331,7 +1331,7 @@ public class LianLianServiceImpl implements LianLianService {
// 转成对应的对象
QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class);
String url = urlAddress + "notification_equip_charge_status";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue();
// 调用联联平台接口
String jsonString = JSONObject.toJSONString(vo);
@@ -1386,7 +1386,7 @@ public class LianLianServiceImpl implements LianLianService {
String urlAddress = relationInfo.getUrlAddress();
String thirdPartyType = relationInfo.getThirdPartyType();
String url = urlAddress + "notification_stop_charge_result";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STOP_CHARGE_RESULT.getValue();
// String orderStatus = orderInfo.getOrderStatus();
// String successFlag = "0";
@@ -1460,7 +1460,7 @@ public class LianLianServiceImpl implements LianLianService {
String urlAddress = relationInfo.getUrlAddress();
String thirdPartyType = relationInfo.getThirdPartyType();
String url = urlAddress + "notification_charge_order_info";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
JSONObject json = new JSONObject();
json.put("StartChargeSeq", orderCode);
@@ -1621,7 +1621,7 @@ public class LianLianServiceImpl implements LianLianService {
String dataSecretIv = relationInfo.getDataSecretIv();
String urlAddress = relationInfo.getUrlAddress();
String url = urlAddress + "check_charge_orders";
String url = urlAddress + BusinessInformationExchangeEnum.CHECK_CHARGE_ORDERS.getValue();
JSONObject json = new JSONObject();
json.put("CheckOrderSeq", orderCode);

View File

@@ -8,6 +8,7 @@ import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
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.ykc.PileStatusEnum;
import com.jsowell.common.util.DateUtils;
@@ -531,7 +532,7 @@ public class NRServiceImpl implements NRService {
String dataSecretIv = relationInfo.getDataSecretIv();
String urlAddress = relationInfo.getUrlAddress();
String url = urlAddress + "notification_stationStatus";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue();
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);

View File

@@ -105,6 +105,7 @@ public abstract class AbsInterfaceWithPlatformLogic implements InitializingBean
/////////////////////////////////
/**
* 请求设备认证
* 业务信息交换
*/
public abstract Map<String, String> queryEquipAuth(QueryEquipmentDTO dto);

View File

@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
@@ -181,7 +182,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
String dataSecretIv = relationInfo.getDataSecretIv();
String urlAddress = relationInfo.getUrlAddress();
String url = urlAddress + "notification_stationStatus";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STATION_STATUS.getValue();
ConnectorStatusInfo info = ConnectorStatusInfo.builder()
.connectorID(pileConnectorCode)
.status(Integer.parseInt(status))
@@ -224,7 +225,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
String urlAddress = relationInfo.getUrlAddress();
String thirdPartyType = relationInfo.getThirdPartyType();
String url = urlAddress + "notification_charge_order_info";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
JSONObject json = new JSONObject();
json.put("StartChargeSeq", orderCode);
json.put("ConnectorID", orderBasicInfo.getPileConnectorCode());
@@ -581,7 +582,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
String thirdPartyType = relationInfo.getThirdPartyType();
// 推送启动充电结果(调用接口 notification_start_charge_result)
String url = urlAddress + "notification_start_charge_result";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_START_CHARGE_RESULT.getValue();
// String orderStatus = orderInfo.getOrderStatus();
// // 订单状态统一
@@ -800,7 +801,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
// 转成对应的对象
QueryChargingStatusVO vo = JSONObject.parseObject(dataStr, QueryChargingStatusVO.class);
String url = urlAddress + "notification_equip_charge_status";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getValue();
// 调用联联平台接口
String jsonString = JSONObject.toJSONString(vo);
@@ -889,7 +890,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
String urlAddress = relationInfo.getUrlAddress();
String thirdPartyType = relationInfo.getThirdPartyType();
String url = urlAddress + "notification_stop_charge_result";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_STOP_CHARGE_RESULT.getValue();
// 拼装联联平台参数
JSONObject json = new JSONObject();
@@ -933,7 +934,7 @@ public class HaiNanPlatformLogic extends AbsInterfaceWithPlatformLogic {
String urlAddress = relationInfo.getUrlAddress();
String thirdPartyType = relationInfo.getThirdPartyType();
String url = urlAddress + "notification_charge_order_info";
String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue();
JSONObject json = new JSONObject();
json.put("StartChargeSeq", orderCode);