update 对接第三方平台

This commit is contained in:
2024-03-28 11:07:45 +08:00
parent f9f03c763e
commit 8482585a21
2 changed files with 128 additions and 74 deletions

View File

@@ -4,8 +4,13 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
import com.jsowell.pile.dto.PushInfoParamDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
@@ -15,10 +20,7 @@ import com.jsowell.thirdparty.platform.util.Cryptos;
import com.jsowell.thirdparty.platform.util.Encodes;
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 org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;
@@ -217,84 +219,134 @@ public class LianLianController extends BaseController {
}
/**
* 联联平台设备状态变化推送
* http://localhost:8080/LianLian/pushStationStatus
* 充电站信息变化推送 notificationStationInfo
*/
@PostMapping("/notificationStationInfo")
public RestApiResponse<?> notificationStationInfo(@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);
}
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
* @param dto
* @return
*/
// @PostMapping("/pushStationStatus")
// public RestApiResponse<?> pushStationStatus(@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);
// }
// String result = lianLianService.notificationStationStatus(dto.getPileConnectorCode(), dto.getStatus());
// 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;
// }
@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);
}
String result = lianLianService.notificationStationStatus(dto.getPileConnectorCode(), dto.getStatus());
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_stationFee
*/
@PostMapping("/notificationStationFee")
public RestApiResponse<?> notificationStationFee(@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);
}
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
* @return
*/
@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;
}
/**
* 推送订单信息 notification_orderInfo
* @param orderCode
* @return
*/
// @GetMapping("/pushOrderInfo/{orderCode}")
// public RestApiResponse<?> pushOrderInfo(@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.notificationOrderInfo(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;
// }
/**
* 设备充电中状态变化推送
* @return
*/
// @GetMapping("/pushPileChargeStatusChange/{orderCode}")
// public RestApiResponse<?> pushPileChargeStatusChange(@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.notificationEquipChargeStatus(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;
// }
@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);
}
String result = lianLianService.notificationOrderInfo(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;
}
/**
* 请求设备认证