新增 新运微平台Controller

This commit is contained in:
Lemon
2025-01-11 16:06:25 +08:00
parent 841ae04fba
commit a094a866d0
3 changed files with 202 additions and 11 deletions

View File

@@ -0,0 +1,191 @@
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.QueryEquipChargeStatusDTO;
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;
/**
* 新运微平台Controller
*
* @author Lemon
* @Date 2025/1/11 15:55:34
*/
@Anonymous
@RestController
@RequestMapping("/xinyunwei")
public class XinYunWeiPlatformController extends ThirdPartyBaseController{
private final String platformName = "新运微平台";
private final String platformType = ThirdPlatformTypeEnum.XIN_YUN_WEI_PLATFORM.getTypeCode();
@Autowired
@Qualifier("xinYunWeiPlatformServiceImpl")
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(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-获取token接口, 异常, params:{}", platformName, JSON.toJSONString(dto), e);
return CommonResult.failed("获取token发生异常");
}
}
/**
* 查询充电站信息
* query_stations_info
*/
@PostMapping("/v1/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);
}
dto.setPlatformType(platformType);
// 校验签名
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(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("{}-查询充电站信息 error:", platformName, e);
}
return CommonResult.failed("查询充电站信息发生异常");
}
/**
* 查询充电站状态信息
* query_station_status
*/
@PostMapping("/v1/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);
}
dto.setPlatformType(platformType);
// 校验签名
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(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-查询充电站状态信息 error:", platformName, e);
}
return CommonResult.failed("查询充电站状态信息发生异常");
}
/**
* 查询充电站统计信息
* query_station_stats
*/
@PostMapping("/v1/query_station_stats")
public CommonResult<?> queryStationStats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-查询充电站统计信息 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryStationStats(queryStationInfoDTO);
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-查询充电站统计信息 error:", platformName, e);
}
return CommonResult.failed("查询充电站统计信息发生异常");
}
/**
* 查询充电状态
* query_equip_charge_status
*/
@PostMapping("/v1/query_equip_charge_status")
public CommonResult<?> queryEquipChargeStatus(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("{}-查询充电状态 params:{}", platformName, JSON.toJSONString(dto));
try {
// 校验令牌
if (!verifyToken(request.getHeader("Authorization"))) {
// 校验失败
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
}
dto.setPlatformType(platformType);
// 校验签名
if (!verifySignature(dto)) {
// 签名错误
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
}
// 解析入参
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = parseParamsDTO(dto, QueryEquipChargeStatusDTO.class);
// 执行逻辑
Map<String, String> map = platformLogic.queryEquipChargeStatus(queryEquipChargeStatusDTO);
return CommonResult.success(Integer.parseInt(map.get("Ret")), map.get("Msg"), map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("{}-查询充电状态 error:", platformName, e);
}
return CommonResult.failed("查询充电状态发生异常");
}
}

View File

@@ -30,7 +30,7 @@ public enum ThirdPlatformTypeEnum {
NAN_RUI_PLATFORM("19", "南瑞平台", ""),
GUANG_XI_PLATFORM("20", "广西平台", "450000000"),
XIN_YUN_PLATFORM("21", "新运平台", ""),
XIN_YUN_WEI_PLATFORM("21", "新运平台", ""),
;
private String typeCode;

View File

@@ -60,7 +60,7 @@ import java.util.stream.Collectors;
* @Date 2025/1/10 8:28:43
*/
@Service
public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
public class XinYunWeiPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired
private PileStationInfoService pileStationInfoService;
@@ -80,7 +80,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
private RedisCache redisCache;
// 平台类型
private final String thirdPlatformType = ThirdPlatformTypeEnum.XIN_YUN_PLATFORM.getTypeCode();
private final String thirdPlatformType = ThirdPlatformTypeEnum.XIN_YUN_WEI_PLATFORM.getTypeCode();
@Override
public void afterPropertiesSet() throws Exception {
@@ -104,7 +104,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
// token缓存key值
String redisKey = operatorId + "_token:";
// 通过operatorId 查出 operatorSecret
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunPlatformSecretInfo();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunWeiPlatformSecretInfo();
if (thirdPartySecretInfoVO == null) {
failReason = 1;
succStat = 1;
@@ -164,7 +164,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
return null;
}
// ThirdPartyPlatformConfig configInfo = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunPlatformSecretInfo();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunWeiPlatformSecretInfo();
PageInfo<ThirdPartyStationInfoVO> pageInfo = new PageInfo<>(stationInfos);
List<SupStationInfo> resultList = new ArrayList<>();
for (ThirdPartyStationInfoVO pileStationInfo : pageInfo.getList()) {
@@ -231,7 +231,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
List<String> stationIds = dto.getStationIds();
List<StationStatusInfo> StationStatusInfos = new ArrayList<>();
List<Object> ConnectorStatusInfos = new ArrayList<>();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunPlatformSecretInfo();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunWeiPlatformSecretInfo();
ConnectorStatusInfo connectorStatusInfo;
for (String stationId : stationIds) {
@@ -299,7 +299,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
*/
@Override
public Map<String, String> queryStationStats(QueryStationInfoDTO dto) {
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunPlatformSecretInfo();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunWeiPlatformSecretInfo();
// 根据站点id 查出这段时间的充电量
List<AccumulativeInfoVO> list = orderBasicInfoService.getAccumulativeInfoForLianLian(dto);
if (CollectionUtils.isEmpty(list)) {
@@ -390,7 +390,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
if (orderInfo == null) {
return null;
}
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunPlatformSecretInfo();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunWeiPlatformSecretInfo();
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderInfo.getOrderCode());
// 通过订单号查询实时数据
List<RealTimeMonitorData> realTimeData = orderBasicInfoService.getChargingRealTimeData(orderInfo.getTransactionCode());
@@ -454,7 +454,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
*/
@Override
public String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) {
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunPlatformSecretInfo();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunWeiPlatformSecretInfo();
String operatorId = Constants.OPERATORID_JIANG_SU;
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
String signSecret = thirdPartySecretInfoVO.getTheirSigSecret();
@@ -512,7 +512,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
BigDecimal voltage = realTimeMonitorData.getOutputVoltage() == null ? BigDecimal.ZERO : new BigDecimal(realTimeMonitorData.getOutputVoltage());
String soc = realTimeMonitorData.getSOC() == null ? Constants.ZERO : realTimeMonitorData.getSOC();
// 查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunPlatformSecretInfo();
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getXinYunWeiPlatformSecretInfo();
String operatorId = Constants.OPERATORID_JIANG_SU;
String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
@@ -621,7 +621,7 @@ public class XinYunPlatformServiceImpl implements ThirdPartyPlatformService {
*
* @return
*/
private ThirdPartySecretInfoVO getXinYunPlatformSecretInfo() {
private ThirdPartySecretInfoVO getXinYunWeiPlatformSecretInfo() {
// 通过第三方平台类型查询相关配置信息
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
if (thirdPartySecretInfoVO == null) {