2024-05-10 15:46:01 +08:00
|
|
|
|
package com.jsowell.api.thirdparty;
|
|
|
|
|
|
|
2024-05-10 16:05:35 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
2024-05-10 15:46:01 +08:00
|
|
|
|
import com.jsowell.common.annotation.Anonymous;
|
2024-05-10 16:05:35 +08:00
|
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
|
|
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
2024-05-30 09:38:29 +08:00
|
|
|
|
import com.jsowell.common.response.RestApiResponse;
|
|
|
|
|
|
import com.jsowell.pile.dto.PushRealTimeInfoDTO;
|
2024-05-10 16:05:35 +08:00
|
|
|
|
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;
|
2024-05-10 15:46:01 +08:00
|
|
|
|
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
2024-05-30 09:38:29 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2024-05-10 15:46:01 +08:00
|
|
|
|
|
2024-05-10 16:05:35 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
2024-05-10 15:46:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 宁夏平台Controller
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Anonymous
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/ningxia")
|
|
|
|
|
|
public class NingXiaController extends ThirdPartyBaseController {
|
2024-05-10 16:05:35 +08:00
|
|
|
|
|
2024-05-28 11:21:50 +08:00
|
|
|
|
private final String platformName = "宁夏平台";
|
2024-05-10 16:05:35 +08:00
|
|
|
|
|
2024-05-10 15:46:01 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
@Qualifier("ninaXiaPlatformServiceImpl")
|
2024-05-10 16:05:35 +08:00
|
|
|
|
private ThirdPartyPlatformService platformLogic;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取token接口
|
|
|
|
|
|
* http://localhost:8080/evcs/v1/query_token
|
|
|
|
|
|
*/
|
|
|
|
|
|
@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("{}-请求令牌 result:{}", platformName, JSON.toJSONString(map));
|
|
|
|
|
|
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("{}- 请求令牌接口 异常", platformName, e);
|
|
|
|
|
|
return CommonResult.failed("获取token发生异常");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询运营商信息
|
|
|
|
|
|
* 接口名称:supervise_query_operator_info
|
|
|
|
|
|
* 使用方法:由数据提供方实现此接口,数据需求方调用
|
|
|
|
|
|
* 接口频率:每天一次或多次
|
|
|
|
|
|
* 超时时间:120秒
|
|
|
|
|
|
*/
|
|
|
|
|
|
@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
|
|
|
|
|
|
* 使用方法:由数据提供方实现此接口,数据需求方调用
|
|
|
|
|
|
* 接口频率:每天一次或多次
|
|
|
|
|
|
* 超时时间:120秒
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/v1/supervise_query_stations_info")
|
|
|
|
|
|
public CommonResult<?> queryStationsInfo(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);
|
|
|
|
|
|
}
|
|
|
|
|
|
QueryStationInfoDTO paramDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
|
|
|
|
|
Map<String, String> map = platformLogic.queryStationsInfo(paramDTO);
|
|
|
|
|
|
logger.info("{}-查询运营商信息 result:{}", platformName, JSON.toJSONString(map));
|
|
|
|
|
|
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.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 paramDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
|
|
|
|
|
Map<String, String> map = platformLogic.queryStationStatus(paramDTO);
|
|
|
|
|
|
logger.info("{}-查询充换电站状态信息 result:{}", platformName, JSON.toJSONString(map));
|
|
|
|
|
|
return CommonResult.success(0, "查询充换电站状态信息成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("{}-查询充换电站状态信息异常", platformName, e);
|
|
|
|
|
|
return CommonResult.failed("查询充换电站状态信息发生异常");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-10 15:46:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-05-30 09:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 推送充电设备接口状态信息
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/v1/supervise_notification_station_status")
|
|
|
|
|
|
public RestApiResponse<?> superviseNotificationStationStatus(@RequestBody PushRealTimeInfoDTO dto) {
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
2024-05-30 14:17:09 +08:00
|
|
|
|
String result = null;
|
2024-05-30 09:38:29 +08:00
|
|
|
|
try {
|
2024-05-30 14:17:09 +08:00
|
|
|
|
result = platformLogic.notificationStationStatus(dto);
|
2024-05-30 09:38:29 +08:00
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("宁夏平台推送充电设备接口状态信息 error", e);
|
|
|
|
|
|
return new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
2024-05-30 14:17:09 +08:00
|
|
|
|
logger.info("宁夏平台推送充电设备接口状态信息 result:{}", result);
|
2024-05-30 09:38:29 +08:00
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 推送充电状态信息
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/v1/supervise_notification_equip_charge_status/{orderCode}")
|
|
|
|
|
|
public RestApiResponse<?> superviseNotificationEquipChargeStatus(@PathVariable("orderCode") String orderCode) {
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
2024-05-30 14:17:09 +08:00
|
|
|
|
String result = null;
|
2024-05-30 09:38:29 +08:00
|
|
|
|
try {
|
2024-05-30 14:17:09 +08:00
|
|
|
|
result = platformLogic.notificationEquipChargeStatus(orderCode);
|
2024-05-30 09:38:29 +08:00
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("宁夏平台推送充电状态信息 error", e);
|
|
|
|
|
|
return new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
2024-05-30 14:17:09 +08:00
|
|
|
|
logger.info("宁夏平台推送充电状态信息 result:{}", result);
|
2024-05-30 09:38:29 +08:00
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 推送充电站历史充电订单信息
|
|
|
|
|
|
* @param orderCode
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-05-30 13:52:19 +08:00
|
|
|
|
@GetMapping("/v1/supervise_notification_charge_order_info_history/{orderCode}")
|
2024-05-30 09:38:29 +08:00
|
|
|
|
public RestApiResponse<?> notificationChargeOrderInfoHistory(@PathVariable("orderCode") String orderCode) {
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
2024-05-30 14:17:09 +08:00
|
|
|
|
String result = null;
|
2024-05-30 09:38:29 +08:00
|
|
|
|
try {
|
2024-05-30 14:17:09 +08:00
|
|
|
|
result = platformLogic.notificationChargeOrderInfoHistory(orderCode);
|
2024-05-30 09:38:29 +08:00
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("宁夏平台推送充电站历史充电订单信息 error", e);
|
|
|
|
|
|
return new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
2024-05-30 14:17:09 +08:00
|
|
|
|
logger.info("宁夏平台推送充电站历史充电订单信息 result:{}", result);
|
2024-05-30 09:38:29 +08:00
|
|
|
|
return response;
|
|
|
|
|
|
}
|
2024-05-10 15:46:01 +08:00
|
|
|
|
}
|