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

This commit is contained in:
Guoqs
2024-11-26 16:46:33 +08:00
13 changed files with 3675 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package com.jsowell.api.thirdparty;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
@@ -29,6 +30,8 @@ import java.util.Map;
public class GanSuController extends ThirdPartyBaseController{
private final String platformName = "甘肃省平台";
private final String platformType = ThirdPlatformTypeEnum.GAN_SU_PLATFORM.getTypeCode();
@Autowired
@Qualifier("ganSuPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic;
@@ -62,6 +65,7 @@ public class GanSuController extends ThirdPartyBaseController{
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {
@@ -95,6 +99,7 @@ public class GanSuController extends ThirdPartyBaseController{
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {

View File

@@ -0,0 +1,153 @@
package com.jsowell.api.thirdparty;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* 贵州省平台
*/
@Anonymous
@RestController
@RequestMapping("/guizhou")
public class GuiZhouPlatformController extends ThirdPartyBaseController {
private final String platformName = "贵州省平台";
@Autowired
@Qualifier("guiZhouPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic;
/**
* getToken
*/
@PostMapping("/v1/query_token")
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
// logger.info("{}-请求令牌 params:{}", platformName, JSON.toJSONString(dto));
try {
Map<String, String> map = platformLogic.queryToken(dto);
logger.info("{}-请求令牌, params:{}, result:{}", platformName, JSON.toJSONString(dto), JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-获取token接口, 异常, params:{}", platformName, JSON.toJSONString(dto), e);
return CommonResult.failed("获取token发生异常");
}
}
/**
* 查询运营商信息
* supervise_query_operator_info
*/
@PostMapping("/v1/supervise_query_operator_info")
public CommonResult<?> queryOperatorInfo(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-查询运营商信息 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
boolean verifyToken = verifyToken(request.getHeader("Authorization"));
if (!verifyToken) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryOperatorInfoDTO paramDTO = parseParamsDTO(dto, QueryOperatorInfoDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryOperatorInfo(paramDTO);
logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map));
return CommonResult.success(0, "操作成功!", map.get("Data"), map.get("Sig"));
} catch (BusinessException e) {
return CommonResult.failed(Integer.parseInt(e.getCode()), e.getMessage());
} catch (Exception e) {
logger.error("{}-查询运营商信息 异常", platformName, e);
return CommonResult.failed("查询运营商信息发生异常");
}
}
/**
* 查询充电站信息
* supervise_query_stations_info
*/
@PostMapping("/v1/supervise_query_stations_info")
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-查询充电站信息 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryStationsInfo(queryStationInfoDTO);
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("{}-查询充电站信息 error:", platformName, e);
}
return CommonResult.failed("查询充电站信息发生异常");
}
/**
* 查询充电站状态信息
* supervise_query_station_status
*/
@PostMapping("/v1/supervise_query_station_status")
public CommonResult<?> queryStationStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-查询充电站状态信息 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryStationStatus(queryStationInfoDTO);
return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-查询充电站状态信息 error:", platformName, e);
}
return CommonResult.failed("查询充电站状态信息发生异常");
}
}

View File

@@ -3,6 +3,7 @@ package com.jsowell.api.thirdparty;
import com.alibaba.fastjson2.JSON;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
@@ -28,6 +29,8 @@ public class NingXiaController extends ThirdPartyBaseController {
private final String platformName = "宁夏平台";
private final String platformType = ThirdPlatformTypeEnum.NING_XIA_PLATFORM.getTypeCode();
@Autowired
@Qualifier("ningXiaPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic;
@@ -66,6 +69,7 @@ public class NingXiaController extends ThirdPartyBaseController {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {
@@ -105,6 +109,7 @@ public class NingXiaController extends ThirdPartyBaseController {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {
@@ -134,6 +139,7 @@ public class NingXiaController extends ThirdPartyBaseController {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {

View File

@@ -58,8 +58,15 @@ public class ThirdPartyBaseController extends BaseController {
protected <T> T parseParamsDTO(CommonParamsDTO dto, Class<T> targetClass) throws NoSuchFieldException, IllegalAccessException {
// 解密
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
ThirdPartySecretInfoVO secretInfoVO;
if (StringUtils.isNotBlank(dto.getPlatformType())) {
// type不为空按照type查
secretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(dto.getPlatformType());
}else {
secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
}
// 通过operatorId 查出 operatorSecret
ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
// ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
if (secretInfoVO == null) {
throw new BusinessException("1", "无此对接平台");
}
@@ -186,7 +193,13 @@ public class ThirdPartyBaseController extends BaseController {
protected boolean verifySignature(CommonParamsDTO dto, String signSecret) {
// 查询密钥
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
ThirdPartySecretInfoVO secretInfoVO;
if (StringUtils.isNotBlank(dto.getPlatformType())) {
// type不为空按照type查
secretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(dto.getPlatformType());
}else {
secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
}
if (secretInfoVO == null) {
throw new BusinessException("1", "无此对接平台");
}