2024-05-10 15:30:20 +08:00
|
|
|
|
package com.jsowell.api.thirdparty;
|
2023-04-14 16:50:49 +08:00
|
|
|
|
|
2024-03-19 16:22:40 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
2023-04-14 16:50:49 +08:00
|
|
|
|
import com.jsowell.common.annotation.Anonymous;
|
2024-05-08 19:02:54 +08:00
|
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
|
2024-04-19 15:22:31 +08:00
|
|
|
|
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
2024-03-28 11:07:45 +08:00
|
|
|
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
|
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
|
|
|
|
|
import com.jsowell.common.response.RestApiResponse;
|
|
|
|
|
|
import com.jsowell.common.util.StringUtils;
|
2024-03-28 14:32:01 +08:00
|
|
|
|
import com.jsowell.pile.dto.*;
|
2024-03-27 11:46:11 +08:00
|
|
|
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
2024-03-27 14:40:34 +08:00
|
|
|
|
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
2024-03-27 16:18:33 +08:00
|
|
|
|
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
2023-04-14 16:50:49 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2024-03-27 14:40:34 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
2024-03-28 11:07:45 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2023-04-14 16:50:49 +08:00
|
|
|
|
|
2023-05-29 14:40:46 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
2023-05-26 19:25:35 +08:00
|
|
|
|
import java.util.Map;
|
2023-04-14 16:50:49 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 对接联联平台controller
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author JS-ZZA
|
|
|
|
|
|
* @date 2023/4/10 14:58
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Anonymous
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/LianLian")
|
2024-05-08 18:40:45 +08:00
|
|
|
|
public class LianLianController extends ThirdPartyBaseController {
|
2023-04-14 16:50:49 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2024-03-27 14:40:34 +08:00
|
|
|
|
@Qualifier("lianLianPlatformServiceImpl")
|
|
|
|
|
|
private ThirdPartyPlatformService lianLianService;
|
|
|
|
|
|
|
2023-05-26 08:58:42 +08:00
|
|
|
|
/**
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* 获取token接口
|
|
|
|
|
|
* http://localhost:8080/LianLian/v1/query_token
|
2023-05-26 08:58:42 +08:00
|
|
|
|
*/
|
2024-03-27 14:40:34 +08:00
|
|
|
|
@PostMapping("/v1/query_token")
|
|
|
|
|
|
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台请求令牌 params:{}", JSON.toJSONString(dto));
|
|
|
|
|
|
try {
|
|
|
|
|
|
Map<String, String> map = lianLianService.queryToken(dto);
|
|
|
|
|
|
logger.info("联联平台请求令牌 result:{}", JSON.toJSONString(map));
|
|
|
|
|
|
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("获取token接口 异常");
|
|
|
|
|
|
return CommonResult.failed("获取token发生异常");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-05-26 09:40:24 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* 联联平台查询充电站信息
|
2024-03-27 14:46:20 +08:00
|
|
|
|
* http://localhost:8080/LianLian/v1/query_stations_info
|
2023-05-26 09:40:24 +08:00
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-27 14:40:34 +08:00
|
|
|
|
@PostMapping("/v1/query_stations_info")
|
|
|
|
|
|
public CommonResult<?> query_stations_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台查询充电站信息 params:{}", JSON.toJSONString(dto));
|
2023-05-26 09:40:24 +08:00
|
|
|
|
try {
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验失败
|
2024-05-09 17:54:06 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2023-05-26 09:40:24 +08:00
|
|
|
|
}
|
2024-05-09 17:54:06 +08:00
|
|
|
|
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 签名错误
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
|
|
|
|
}
|
2024-05-08 18:40:45 +08:00
|
|
|
|
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 解析入参
|
|
|
|
|
|
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
2024-03-27 14:40:34 +08:00
|
|
|
|
Map<String, String> map = lianLianService.queryStationsInfo(queryStationInfoDTO);
|
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "查询充电站信息成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.info("联联平台查询充电站信息 error:", e);
|
|
|
|
|
|
e.printStackTrace();
|
2023-05-26 09:40:24 +08:00
|
|
|
|
}
|
2024-03-27 14:40:34 +08:00
|
|
|
|
return CommonResult.failed("查询充电站信息发生异常");
|
2023-05-26 09:40:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-26 10:11:05 +08:00
|
|
|
|
/**
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* 联联平台查询充电站状态信息
|
2024-03-27 14:46:20 +08:00
|
|
|
|
* http://localhost:8080/LianLian/v1/query_station_status
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* @param dto
|
2023-05-26 10:11:05 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-27 14:40:34 +08:00
|
|
|
|
@PostMapping("/v1/query_station_status")
|
|
|
|
|
|
public CommonResult<?> query_station_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台查询充电站状态信息 params:{}", JSON.toJSONString(dto));
|
2023-05-26 10:11:05 +08:00
|
|
|
|
try {
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验失败
|
2024-05-09 17:54:06 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2023-05-26 10:11:05 +08:00
|
|
|
|
}
|
2024-05-09 17:54:06 +08:00
|
|
|
|
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 签名错误
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
|
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
2024-03-27 14:40:34 +08:00
|
|
|
|
Map<String, String> map = lianLianService.queryStationStatus(queryStationInfoDTO);
|
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "查询充电站状态信息成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.info("联联平台查询充电站状态信息 error:", e);
|
|
|
|
|
|
e.printStackTrace();
|
2023-05-26 10:11:05 +08:00
|
|
|
|
}
|
2024-03-27 14:40:34 +08:00
|
|
|
|
return CommonResult.failed("查询充电站状态信息发生异常");
|
2023-05-26 10:11:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* 查询统计信息
|
2024-03-27 14:46:20 +08:00
|
|
|
|
* http://localhost:8080/LianLian/v1/query_station_stats
|
2024-03-27 14:40:34 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param dto
|
2023-05-26 10:11:05 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-27 14:40:34 +08:00
|
|
|
|
@PostMapping("/v1/query_station_stats")
|
|
|
|
|
|
public CommonResult<?> query_station_stats(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台查询统计信息 params:{}", JSON.toJSONString(dto));
|
2023-05-26 10:11:05 +08:00
|
|
|
|
try {
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验失败
|
2024-05-09 17:54:06 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2023-05-26 10:11:05 +08:00
|
|
|
|
}
|
2024-05-09 17:54:06 +08:00
|
|
|
|
|
2024-03-27 14:40:34 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 签名错误
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
|
QueryStationInfoDTO queryStationInfoDTO = parseParamsDTO(dto, QueryStationInfoDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
2024-03-27 14:40:34 +08:00
|
|
|
|
Map<String, String> map = lianLianService.queryStationStats(queryStationInfoDTO);
|
|
|
|
|
|
return CommonResult.success(0, "查询统计信息成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.info("联联平台查询统计信息 error:", e);
|
|
|
|
|
|
e.printStackTrace();
|
2023-05-26 10:11:05 +08:00
|
|
|
|
}
|
2024-03-27 14:40:34 +08:00
|
|
|
|
return CommonResult.failed("查询统计信息发生异常");
|
2023-05-26 10:11:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-14 16:50:49 +08:00
|
|
|
|
/**
|
2024-03-28 14:13:23 +08:00
|
|
|
|
* 充电站信息变化推送 notification_stationInfo
|
2024-03-28 12:04:49 +08:00
|
|
|
|
* http://localhost:8080/LianLian/notificationStationInfo
|
2024-03-28 11:07:45 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/notificationStationInfo")
|
|
|
|
|
|
public RestApiResponse<?> notificationStationInfo(@RequestBody PushInfoParamDTO dto) {
|
|
|
|
|
|
logger.info("联联平台充电站信息变化推送 params:{}", JSON.toJSONString(dto));
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
|
try {
|
2024-03-28 12:04:49 +08:00
|
|
|
|
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
2024-03-28 11:07:45 +08:00
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
String result = lianLianService.notificationStationInfo(dto.getStationId());
|
|
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
}catch (BusinessException e) {
|
|
|
|
|
|
logger.error("联联平台充电站信息变化推送 error",e);
|
|
|
|
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台充电站信息变化推送 error", e);
|
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("联联平台充电站信息变化推送 result:{}", response);
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 联联平台设备状态变化推送 notification_stationStatus
|
|
|
|
|
|
* http://localhost:8080/LianLian/notificationStationStatus
|
2023-04-14 16:50:49 +08:00
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 11:07:45 +08:00
|
|
|
|
@PostMapping("/notificationStationStatus")
|
|
|
|
|
|
public RestApiResponse<?> notificationStationStatus(@RequestBody PushInfoParamDTO dto) {
|
|
|
|
|
|
logger.info("联联平台设备状态变化推送 params:{}", JSON.toJSONString(dto));
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (StringUtils.isBlank(String.valueOf(dto.getPileConnectorCode())) ||
|
|
|
|
|
|
StringUtils.isBlank(String.valueOf(dto.getStatus()))) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
|
}
|
2024-04-19 15:22:31 +08:00
|
|
|
|
PushRealTimeInfoDTO pushRealTimeInfoDTO = new PushRealTimeInfoDTO();
|
|
|
|
|
|
pushRealTimeInfoDTO.setStatus(dto.getStatus());
|
|
|
|
|
|
pushRealTimeInfoDTO.setPileConnectorCode(dto.getPileConnectorCode());
|
|
|
|
|
|
pushRealTimeInfoDTO.setThirdPartyType(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getTypeCode());
|
|
|
|
|
|
String result = lianLianService.notificationStationStatus(pushRealTimeInfoDTO);
|
2024-03-28 11:07:45 +08:00
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
}catch (BusinessException e) {
|
|
|
|
|
|
logger.error("联联平台设备状态变化推送 error",e);
|
|
|
|
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台设备状态变化推送 error", e);
|
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("联联平台设备状态变化推送 result:{}", response);
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
2023-04-14 16:50:49 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-03-28 11:07:45 +08:00
|
|
|
|
* 站点费率变化推送 notification_stationFee
|
2024-03-28 12:04:49 +08:00
|
|
|
|
* http://localhost:8080/LianLian/notificationStationFee
|
2024-03-28 11:07:45 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/notificationStationFee")
|
|
|
|
|
|
public RestApiResponse<?> notificationStationFee(@RequestBody PushInfoParamDTO dto) {
|
|
|
|
|
|
logger.info("联联平台站点费率变化推送 params:{}", JSON.toJSONString(dto));
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
|
try {
|
2024-03-28 12:04:49 +08:00
|
|
|
|
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) {
|
2024-03-28 11:07:45 +08:00
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
String result = lianLianService.notificationStationFee(dto.getStationId());
|
|
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
}catch (BusinessException e) {
|
|
|
|
|
|
logger.error("联联平台站点费率变化推送 error",e);
|
|
|
|
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台站点费率变化推送 error", e);
|
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("联联平台站点费率变化推送 result:{}", response);
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 设备充电中状态变化推送 notification_connector_charge_status
|
2024-03-28 12:04:49 +08:00
|
|
|
|
* http://localhost:8080/LianLian/notificationConnectorChargeStatus
|
2023-04-14 16:50:49 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 11:07:45 +08:00
|
|
|
|
@GetMapping("/notificationConnectorChargeStatus/{orderCode}")
|
|
|
|
|
|
public RestApiResponse<?> notificationConnectorChargeStatus(@PathVariable("orderCode")String orderCode) {
|
|
|
|
|
|
logger.info("联联平台设备充电中状态变化推送 params:{}", orderCode);
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (StringUtils.isBlank(orderCode)) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
// String result = lianLianService.pushPileChargeStatusChange(orderCode);
|
|
|
|
|
|
String result = lianLianService.notificationConnectorChargeStatus(orderCode);
|
|
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
}catch (BusinessException e) {
|
|
|
|
|
|
logger.error("联联平台设备充电中状态变化推送 error",e);
|
|
|
|
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台设备充电中状态变化推送 error", e);
|
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("联联平台设备充电中状态变化推送 result:{}", response);
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
2023-04-18 16:45:49 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-03-28 11:07:45 +08:00
|
|
|
|
* 推送订单信息 notification_orderInfo
|
2024-03-28 12:04:49 +08:00
|
|
|
|
* http://localhost:8080/LianLian/notificationOrderInfo/
|
2024-03-28 11:07:45 +08:00
|
|
|
|
* @param orderCode
|
2023-04-18 16:45:49 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 11:07:45 +08:00
|
|
|
|
@GetMapping("/notificationOrderInfo/{orderCode}")
|
|
|
|
|
|
public RestApiResponse<?> notificationOrderInfo(@PathVariable("orderCode")String orderCode) {
|
|
|
|
|
|
logger.info("联联平台推送订单信息 params:{}", orderCode);
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (StringUtils.isBlank(orderCode)) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
|
|
|
|
|
}
|
2024-04-08 11:13:13 +08:00
|
|
|
|
String result = lianLianService.notificationChargeOrderInfo(orderCode);
|
2024-03-28 11:07:45 +08:00
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
}catch (BusinessException e) {
|
|
|
|
|
|
logger.error("联联平台推送订单信息 error",e);
|
|
|
|
|
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台推送订单信息 error", e);
|
|
|
|
|
|
response = new RestApiResponse<>(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
logger.info("联联平台推送订单信息 result:{}", response);
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
2023-04-24 13:55:33 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 请求设备认证
|
2024-05-08 14:41:26 +08:00
|
|
|
|
* http://localhost:8080/LianLian/v1/query_equip_auth
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* @param request
|
2023-04-24 13:55:33 +08:00
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 14:32:01 +08:00
|
|
|
|
@PostMapping("/v1/query_equip_auth")
|
|
|
|
|
|
public CommonResult<?> query_equip_auth(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台请求设备认证 param:{}", JSON.toJSONString(dto));
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 校验失败
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 签名错误
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
|
QueryEquipmentDTO queryEquipmentDTO = parseParamsDTO(dto, QueryEquipmentDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
2024-03-28 14:32:01 +08:00
|
|
|
|
Map<String, String> map = lianLianService.queryEquipAuth(queryEquipmentDTO);
|
|
|
|
|
|
return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
2024-04-01 16:30:50 +08:00
|
|
|
|
logger.error("联联平台请求设备认证 error:", e);
|
2024-03-28 14:32:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
return CommonResult.failed("请求设备认证发生异常");
|
|
|
|
|
|
}
|
2023-05-31 14:17:13 +08:00
|
|
|
|
|
2023-04-29 10:33:16 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 请求启动充电
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* @param request
|
2023-04-29 10:33:16 +08:00
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 14:32:01 +08:00
|
|
|
|
@PostMapping("/v1/query_start_charge")
|
|
|
|
|
|
public CommonResult<?> query_start_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台请求启动充电 params :{}", JSON.toJSONString(dto));
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-05-08 18:42:07 +08:00
|
|
|
|
// 校验失败
|
2024-05-08 19:02:54 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2024-05-08 18:42:07 +08:00
|
|
|
|
}
|
2024-05-08 18:40:45 +08:00
|
|
|
|
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-08 18:55:11 +08:00
|
|
|
|
// 签名错误
|
2024-05-08 19:02:54 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
2024-05-08 18:55:11 +08:00
|
|
|
|
}
|
2024-05-08 18:40:45 +08:00
|
|
|
|
|
2024-05-08 18:55:11 +08:00
|
|
|
|
// 解析入参
|
2024-05-08 18:40:45 +08:00
|
|
|
|
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class);
|
2024-05-08 19:03:30 +08:00
|
|
|
|
|
2024-05-08 18:55:11 +08:00
|
|
|
|
// 执行逻辑
|
2024-03-28 14:32:01 +08:00
|
|
|
|
Map<String, String> map = lianLianService.queryStartCharge(queryStartChargeDTO);
|
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台请求启动充电 error", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
return CommonResult.failed("请求启动充电发生异常");
|
|
|
|
|
|
}
|
2023-05-31 14:43:58 +08:00
|
|
|
|
|
2023-04-25 11:20:43 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询充电状态
|
2023-05-10 08:49:01 +08:00
|
|
|
|
* http://localhost:8080/LianLian/query_equip_charge_status/{startChargeSeq}
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* @param dto
|
2023-04-25 11:20:43 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 14:32:01 +08:00
|
|
|
|
@PostMapping("/v1/query_equip_charge_status")
|
|
|
|
|
|
public CommonResult<?> query_equip_charge_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台查询充电状态 params :{}", JSON.toJSONString(dto));
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验失败
|
2024-05-09 17:54:06 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2024-03-28 14:32:01 +08:00
|
|
|
|
}
|
2024-05-09 17:54:06 +08:00
|
|
|
|
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 签名错误
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
|
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = parseParamsDTO(dto, QueryEquipChargeStatusDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
2024-03-28 14:32:01 +08:00
|
|
|
|
Map<String, String> map = lianLianService.queryEquipChargeStatus(queryEquipChargeStatusDTO);
|
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台查询充电状态 error", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
return CommonResult.failed("联联平台查询充电状态发生异常");
|
|
|
|
|
|
}
|
2023-05-31 15:24:18 +08:00
|
|
|
|
|
2023-04-25 14:03:09 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 请求停止充电
|
2024-03-27 14:40:34 +08:00
|
|
|
|
* @param request
|
2023-04-25 14:03:09 +08:00
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 14:32:01 +08:00
|
|
|
|
@PostMapping("/v1/query_stop_charge")
|
|
|
|
|
|
public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台请求停止充电 params :{}", JSON.toJSONString(dto));
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验失败
|
2024-05-09 17:54:06 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2024-03-28 14:32:01 +08:00
|
|
|
|
}
|
2024-05-09 17:54:06 +08:00
|
|
|
|
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 签名错误
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
|
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
2024-03-28 14:32:01 +08:00
|
|
|
|
Map<String, String> map = lianLianService.queryStopCharge(queryStartChargeDTO);
|
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("联联平台请求停止充电 error", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
return CommonResult.failed("联联平台请求停止充电发生异常");
|
|
|
|
|
|
}
|
2023-05-31 15:33:50 +08:00
|
|
|
|
|
2023-04-25 14:03:09 +08:00
|
|
|
|
|
2023-05-27 15:56:26 +08:00
|
|
|
|
|
2023-06-02 11:37:30 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 推送订单结算信息 (联联推给我们)
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-28 14:32:01 +08:00
|
|
|
|
@PostMapping("/v1/notification_order_settlement_info")
|
|
|
|
|
|
public CommonResult<?> notification_order_settlement_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
|
|
|
|
|
logger.info("联联平台推送订单结算信息 params:{}", JSON.toJSONString(dto));
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 校验令牌
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifyToken(request.getHeader("Authorization"))) {
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验失败
|
2024-05-09 17:54:06 +08:00
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
2024-03-28 14:32:01 +08:00
|
|
|
|
}
|
2024-05-09 17:54:06 +08:00
|
|
|
|
|
2024-03-28 14:32:01 +08:00
|
|
|
|
// 校验签名
|
2024-05-10 15:02:33 +08:00
|
|
|
|
if (!verifySignature(dto)) {
|
2024-05-09 17:54:06 +08:00
|
|
|
|
// 签名错误
|
|
|
|
|
|
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 解析入参
|
|
|
|
|
|
PushOrderSettlementDTO pushOrderSettlementDTO = parseParamsDTO(dto, PushOrderSettlementDTO.class);
|
|
|
|
|
|
|
|
|
|
|
|
// 执行逻辑
|
2024-03-28 14:32:01 +08:00
|
|
|
|
Map<String, String> map = lianLianService.notificationOrderSettlementInfo(pushOrderSettlementDTO);
|
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(0, "推送订单结算信息成功!", map.get("Data"), map.get("Sig"));
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.info("联联平台推送订单结算信息 error:", e);
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
return CommonResult.failed("推送订单结算信息发生异常");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/pushStationFee/{stationId}")
|
|
|
|
|
|
public RestApiResponse<?> pushStationFee(@PathVariable("stationId") String stationId) {
|
|
|
|
|
|
RestApiResponse<?> response = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
// String result = lianLianService.pushStationFee(stationId);
|
|
|
|
|
|
String result = lianLianService.notificationStationFee(stationId);
|
|
|
|
|
|
response = new RestApiResponse<>(result);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
2024-03-05 15:09:43 +08:00
|
|
|
|
|
2023-04-14 16:50:49 +08:00
|
|
|
|
}
|