mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
拆分第三方业务代码
This commit is contained in:
503
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/YunWeiPlatformController.java
vendored
Normal file
503
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/YunWeiPlatformController.java
vendored
Normal file
@@ -0,0 +1,503 @@
|
||||
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.*;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
import com.jsowell.thirdparty.platform.dto.RetryOrderDTO;
|
||||
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.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/yunwei")
|
||||
public class YunWeiPlatformController extends ThirdPartyBaseController{
|
||||
|
||||
|
||||
private final String platformName = "运维平台";
|
||||
|
||||
|
||||
private final String platformType = ThirdPlatformTypeEnum.YUN_WEI_PLATFORM.getTypeCode();
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("yunWeiPlatformServiceImpl")
|
||||
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 = zdlService.generateToken(dto);
|
||||
Map<String, String> map = platformLogic.queryToken(dto);
|
||||
logger.info("{}-请求令牌 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求令牌成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-请求令牌 error:" , platformName , 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 {
|
||||
logger.info("{}-携带的token:{}",platformName, request.getHeader("Authorization"));
|
||||
// 校验令牌
|
||||
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);
|
||||
logger.info("{}-查询充电站信息 result:{}" , platformName , JSON.toJSONString(map));
|
||||
return CommonResult.success(0 , "查询充电站信息成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-查询充电站信息 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("查询充电站信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设备状态推送
|
||||
* notification_stationStatus
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/notification_stationStatus")
|
||||
public RestApiResponse<?> notification_stationStatus(@RequestBody PushRealTimeInfoDTO pushRealTimeInfoDTO , HttpServletRequest request) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.notificationStationStatus(pushRealTimeInfoDTO);
|
||||
logger.info("【{}】推送设备状态 result:{}" , this.getClass().getSimpleName() , result);
|
||||
response = new RestApiResponse<>(result);
|
||||
} catch (BusinessException e) {
|
||||
logger.error("【{}】推送设备状态 error:{}" , this.getClass().getSimpleName() , e.getMessage());
|
||||
response = new RestApiResponse<>(e.getCode() , e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("【{}】推送设备状态 error:{}" , this.getClass().getSimpleName() , e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("【{}】推送设备状态 response:{}" , this.getClass().getSimpleName() , response);
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备接口状态查询 query_station_status
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_status")
|
||||
public CommonResult<?> query_stations_status(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);
|
||||
logger.info("{}-设备接口状态查询 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "设备接口状态查询成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-设备接口状态查询 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("设备接口状态查询发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计信息查询 query_station_stats
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_station_stats")
|
||||
public CommonResult<?> query_station_stats(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.queryStationStats(queryStationInfoDTO);
|
||||
logger.info("{}-查询统计信息 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "查询统计信息成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-查询统计信息 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("查询统计信息发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求设备认证
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_equip_auth")
|
||||
public CommonResult<?> query_equip_auth(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);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryEquipmentDTO queryEquipmentDTO = parseParamsDTO(dto , QueryEquipmentDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryEquipAuth(queryEquipmentDTO);
|
||||
logger.info("{}-请求设备认证 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求设备认证成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-请求设备认证 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("请求设备认证发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询业务策略信息
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@RequestMapping("/v1/query_equip_business_policy")
|
||||
public CommonResult<?> query_equip_business_policy(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);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto , QueryStartChargeDTO.class);
|
||||
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryEquipBusinessPolicy(queryStartChargeDTO);
|
||||
logger.info("{}-查询业务策略信息 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "查询业务策略信息成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.info("{}-查询业务策略信息 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("查询业务策略信息发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求启动充电
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_start_charge")
|
||||
public CommonResult<?> query_start_charge(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);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto , QueryStartChargeDTO.class);
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryStartCharge(queryStartChargeDTO);
|
||||
logger.info("{}-请求启动充电 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "请求启动充电成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-请求启动充电 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("请求启动充电发生异常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送启动充电结果
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/notification_start_charge_result/{orderCode}")
|
||||
public RestApiResponse<?> notification_start_charge_result(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("【{}】推送启动充电结果 params:{}" , this.getClass().getSimpleName() , orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.notificationStartChargeResult(orderCode);
|
||||
logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , result);
|
||||
response = new RestApiResponse<>(result);
|
||||
} catch (BusinessException e) {
|
||||
logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e);
|
||||
response = new RestApiResponse<>(e.getCode() , e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("【{}】推送启动充电结果 error" , this.getClass().getSimpleName() , e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("【{}】推送启动充电结果 result:{}" , this.getClass().getSimpleName() , response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电状态
|
||||
* http://localhost:8080/xindiantu/query_equip_charge_status/{startChargeSeq}
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_equip_charge_status")
|
||||
public CommonResult<?> query_equip_charge_status(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);
|
||||
logger.info("{}-查询充电状态 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "查询充电状态成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-查询充电状态 error:" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("查询充电状态发生异常");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电状态
|
||||
* http://localhost:8080/hainan/notificationEquipChargeStatus
|
||||
*
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/notification_equip_charge_status/{orderCode}")
|
||||
public RestApiResponse<?> notification_equip_charge_status(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("推送充电状态 params:{}" , orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.notificationEquipChargeStatus(orderCode);
|
||||
logger.info("推送充电状态 result:{}" , result);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求停止充电
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/query_stop_charge")
|
||||
public CommonResult<?> query_stop_charge(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);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto , QueryStartChargeDTO.class);
|
||||
logger.info("{}-请求停止充电 params :{}" , platformName , JSON.toJSONString(queryStartChargeDTO));
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.queryStopCharge(queryStartChargeDTO);
|
||||
|
||||
return CommonResult.success(0 , "请求停止充电成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-请求停止充电 error" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("{}-请求停止充电发生异常");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送停止充电结果
|
||||
* http://localhost:8080/hainan/notificationStopChargeResult
|
||||
*
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/notification_stop_charge_result/{orderCode}")
|
||||
public RestApiResponse<?> notification_stop_charge_result(@PathVariable("orderCode") String orderCode) {
|
||||
logger.info("推送停止充电结果 params:{}" , orderCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.notificationStopChargeResult(orderCode);
|
||||
logger.info("推送停止充电结果 result:{}" , result);
|
||||
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("/v1/notification_charge_order_info")
|
||||
public RestApiResponse<?> notification_charge_order_info(@RequestBody QueryOrderDTO dto) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = platformLogic.pushOrderInfo(dto);
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电订单信息
|
||||
* retry_notification_order_info
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/retry_notification_order_info")
|
||||
public CommonResult<?> retry_notification_order_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);
|
||||
}
|
||||
// 解析入参
|
||||
RetryOrderDTO retryOrderDTO = parseParamsDTO(dto , RetryOrderDTO.class);
|
||||
// 执行逻辑
|
||||
Map<String, String> map = platformLogic.retryNotificationOrderInfo(retryOrderDTO.getStartChargeSeqs());
|
||||
logger.info("{}-获取充电订单信息 result:{}" , platformName , map);
|
||||
return CommonResult.success(0 , "获取充电订单信息成功!" , map.get("Data") , map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("{}-获取充电订单信息 error" , platformName , e);
|
||||
}
|
||||
return CommonResult.failed("{}-获取充电订单信息发生异常");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public enum ThirdPlatformTypeEnum {
|
||||
CHANG_ZHOU_PLATFORM("25", "新运常畅充", "0585PCW57"),
|
||||
SI_CHUAN_PLATFORM("26", "四川省平台", "MA01H3BQ2"),
|
||||
JI_LIN_PLATFORM("27", "吉林省平台", "723195753"),
|
||||
YUN_WEI_PLATFORM("28", "运维平台", ""),
|
||||
;
|
||||
|
||||
private String typeCode;
|
||||
|
||||
@@ -4,29 +4,29 @@ import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.service.thirdparty.ThirdPartyPlatformApi;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.spring.SpringUtils;
|
||||
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.thirdparty.dubbo.factory.DynamicThirdPartyPlatformFactory;
|
||||
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
|
||||
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
|
||||
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.bouncycastle.crypto.CryptoException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* 主动通知Service
|
||||
* 说明:创建此接口目的是为了简化开发
|
||||
* 在需要通知第三方平台的地方,异步调用此类中对应的方法
|
||||
* 通知方法中应该根据对接平台,自动找到响应的平台处理逻辑
|
||||
* 主动通知Service - 异步改造版
|
||||
*/
|
||||
@Service
|
||||
public class NotificationService {
|
||||
@@ -35,9 +35,43 @@ public class NotificationService {
|
||||
@Autowired
|
||||
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||
|
||||
// 引入线程池
|
||||
private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor");
|
||||
|
||||
|
||||
// 判断是否使用old还是new平台
|
||||
private boolean isRemotePlatform(String platformType) {
|
||||
for (ThirdPlatformTypeEnum item : ThirdPlatformTypeEnum.values()) {
|
||||
if (StringUtils.equals(item.getTypeCode(), platformType)) {
|
||||
return true; // true: 使用old平台
|
||||
}
|
||||
}
|
||||
return false; // false: 使用new平台
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据平台类型获取对应的服务实例
|
||||
*/
|
||||
private Object getPlatformService(String platformType) {
|
||||
if (isRemotePlatform(platformType)) {
|
||||
return ThirdPartyPlatformFactory.getInvokeStrategy(platformType);
|
||||
} else {
|
||||
return DynamicThirdPartyPlatformFactory.getPlatformService(platformType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* VO对象转换
|
||||
*/
|
||||
private com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO getConversion(ThirdPartySecretInfoVO secretInfoVO) {
|
||||
com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversion =
|
||||
new com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO();
|
||||
BeanUtils.copyProperties(secretInfoVO, conversion);
|
||||
return conversion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电站信息变化推送
|
||||
* notification_stationInfo
|
||||
*/
|
||||
public String notificationStationInfo(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
@@ -46,33 +80,58 @@ public class NotificationService {
|
||||
if (StringUtils.isBlank(stationId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return null;
|
||||
return "该站点未绑定任何平台";
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
String currentPlatformType = secretInfoVO.getPlatformType();
|
||||
if (StringUtils.isNotBlank(platformType) && !platformType.equals(currentPlatformType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
String postResult = platformService.notificationStationInfo(stationId);
|
||||
result.append(postResult).append("\n");
|
||||
Object service = getPlatformService(currentPlatformType);
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
String pushResult = ((ThirdPartyPlatformService) service).notificationStationInfo(stationId);
|
||||
result.append("old平台[").append(secretInfoVO.getPlatformName())
|
||||
.append("]推送结果:").append(pushResult).append("\n");
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
CompletableFuture<Void> future = CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
return apiService.notificationStationInfo(stationId);
|
||||
} catch (Exception e) {
|
||||
return "推送失败:" + e.getMessage();
|
||||
}
|
||||
}, executor).thenAccept(pushResult -> {
|
||||
synchronized (result) {
|
||||
result.append("new平台[").append(secretInfoVO.getPlatformName())
|
||||
.append("]推送结果:").append(pushResult).append("\n");
|
||||
}
|
||||
});
|
||||
futures.add(future);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 充电站信息变化推送error:{}",
|
||||
secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, e.getMessage());
|
||||
result.append("平台[").append(secretInfoVO.getPlatformName())
|
||||
.append("]处理异常:").append(e.getMessage()).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
// 等待所有异步任务完成
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备状态变化推送
|
||||
* notification_stationStatus
|
||||
*/
|
||||
public void notificationStationStatus(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
@@ -83,21 +142,35 @@ public class NotificationService {
|
||||
if (StringUtils.isBlank(stationId) || StringUtils.isBlank(pileConnectorCode) || StringUtils.isBlank(status)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
platformService.notificationStationStatus(stationId, pileConnectorCode, status, secretInfoVO);
|
||||
Object service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO);
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
((ThirdPartyPlatformService) service).notificationStationStatus(
|
||||
stationId, pileConnectorCode, status, secretInfoVO);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationStationStatus(stationId, pileConnectorCode, status, conversionVO);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]设备状态推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 枪口编号:{}, 设备状态变化推送error:{}",
|
||||
secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, pileConnectorCode, e.getMessage());
|
||||
@@ -107,153 +180,178 @@ public class NotificationService {
|
||||
|
||||
/**
|
||||
* 设备充电中状态变化推送
|
||||
* notification_connector_charge_status
|
||||
* notification_equip_charge_status
|
||||
*/
|
||||
public void notificationConnectorChargeStatus(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
String orderCode = dto.getOrderCode();
|
||||
String platformType = dto.getPlatformType();
|
||||
|
||||
if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
|
||||
try {
|
||||
platformService.notificationConnectorChargeStatus(orderCode, secretInfoVO);
|
||||
Object service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO);
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
((ThirdPartyPlatformService) service).notificationConnectorChargeStatus(orderCode, secretInfoVO);
|
||||
((ThirdPartyPlatformService) service).notificationEquipChargeStatus(orderCode);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationConnectorChargeStatus(orderCode, conversionVO);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]充电中状态推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationEquipChargeStatus(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]设备充电状态推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("平台类型:{}, 平台名称:{}, 站点id:{}, 订单编号:{}, 设备充电中状态变化推送error:{}",
|
||||
secretInfoVO.getPlatformType(), secretInfoVO.getPlatformName(), stationId, orderCode, e.getMessage());
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
platformService.notificationEquipChargeStatus(orderCode);
|
||||
}catch (Exception e){
|
||||
logger.error("notification_equip_charge_status error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电订单信息推送
|
||||
* notification_orderInfo/notification_charge_order_info
|
||||
*/
|
||||
public void notificationChargeOrderInfo(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
String orderCode = dto.getOrderCode();
|
||||
String platformType = dto.getPlatformType();
|
||||
|
||||
if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService =null;
|
||||
|
||||
Object service = null;
|
||||
try {
|
||||
// 根据平台类型获取Service
|
||||
platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
}catch (Exception e){
|
||||
service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
} catch (Exception e) {
|
||||
logger.error("获取平台服务失败", e);
|
||||
continue;
|
||||
}
|
||||
//充电订单信息推送
|
||||
|
||||
com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO);
|
||||
|
||||
try {
|
||||
if(platformService != null){
|
||||
platformService.notificationChargeOrderInfo(orderCode, secretInfoVO);
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
((ThirdPartyPlatformService) service).notificationChargeOrderInfo(orderCode, secretInfoVO);
|
||||
((ThirdPartyPlatformService) service).notificationChargeOrderInfo(orderCode);
|
||||
((ThirdPartyPlatformService) service).notificationStopChargeResult(orderCode);
|
||||
((ThirdPartyPlatformService) service).notificationPayOrderInfo(orderCode);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationChargeOrderInfo(orderCode, conversionVO);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]充电订单信息推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationChargeOrderInfo(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]订单信息推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationStopChargeResult(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]停止充电结果推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationPayOrderInfo(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]充电账单推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("充电订单信息推送error", e);
|
||||
logger.error("充电订单信息推送异常", e);
|
||||
}
|
||||
//订单信息推送
|
||||
try {
|
||||
if (platformService != null) {
|
||||
platformService.notificationChargeOrderInfo(orderCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("订单信息推送error", e);
|
||||
}
|
||||
//停止充电结果推送
|
||||
try {
|
||||
if (platformService != null) {
|
||||
platformService.notificationStopChargeResult(orderCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("停止充电结果推送error", e);
|
||||
}
|
||||
//推送充换电站用能统计信息
|
||||
/* try {
|
||||
if (platformService != null) {
|
||||
platformService.notificationOperationStatsInfo(stationId);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("推送充换电站用能统计信息error", e);
|
||||
}*/
|
||||
//推送充电账单信息
|
||||
try {
|
||||
if (platformService != null) {
|
||||
platformService.notificationPayOrderInfo(orderCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("推送充电账单信息error", e);
|
||||
}
|
||||
//推送充电历史订单信息
|
||||
/* try {
|
||||
// 根据平台类型获取Service
|
||||
if (platformService != null) {
|
||||
platformService.notificationChargeOrderInfoHistory(orderCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("历史充电订单信息推送error", e);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 开始充电结果推送
|
||||
*/
|
||||
public void commonPushStartChargeResult(NotificationDTO dto) {
|
||||
logger.info("开始调用commonPushStartChargeResult接口");
|
||||
String stationId = dto.getStationId();
|
||||
String orderCode = dto.getOrderCode();
|
||||
String platformType = dto.getPlatformType();
|
||||
|
||||
if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
platformService.notificationStartChargeResult(orderCode);
|
||||
Object service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
((ThirdPartyPlatformService) service).notificationStartChargeResult(orderCode);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationStartChargeResult(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]开始充电结果推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("充电订单信息推送error", e);
|
||||
}
|
||||
@@ -262,26 +360,38 @@ public class NotificationService {
|
||||
|
||||
/**
|
||||
* 站点功率信息推送
|
||||
* notification_orderInfo/notification_charge_order_info
|
||||
*/
|
||||
public void notificationStationPowerInfo(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
String platformType = dto.getPlatformType();
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
platformService.notificationPowerInfo(Lists.newArrayList(stationId));
|
||||
Object service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
List<String> stationIds = Lists.newArrayList(stationId);
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
((ThirdPartyPlatformService) service).notificationPowerInfo(stationIds);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationPowerInfo(stationIds);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]站点功率信息推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("站点功率信息推送error", e);
|
||||
}
|
||||
@@ -290,7 +400,6 @@ public class NotificationService {
|
||||
|
||||
/**
|
||||
* 站点费率变化推送
|
||||
* notification_stationFee
|
||||
*/
|
||||
public void notificationStationFee(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
@@ -299,21 +408,34 @@ public class NotificationService {
|
||||
if (StringUtils.isBlank(stationId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
platformService.notificationStationFee(stationId, secretInfoVO);
|
||||
Object service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO conversionVO = getConversion(secretInfoVO);
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
((ThirdPartyPlatformService) service).notificationStationFee(stationId, secretInfoVO);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationStationFee(stationId, conversionVO);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]站点费率推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("站点费率变化推送error", e);
|
||||
}
|
||||
@@ -322,74 +444,105 @@ public class NotificationService {
|
||||
|
||||
/**
|
||||
* 历史充电订单信息推送
|
||||
* notification_orderInfo/notification_charge_order_info
|
||||
*/
|
||||
public void notificationChargeOrderInfoHistory(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
String orderCode = dto.getOrderCode();
|
||||
String platformType = dto.getPlatformType();
|
||||
|
||||
if (StringUtils.isBlank(stationId) || StringUtils.isBlank(orderCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
try {
|
||||
platformService.notificationChargeOrderInfo(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("历史充电订单信息推送 error", e);
|
||||
}
|
||||
|
||||
try {
|
||||
platformService.notificationChargeOrderInfoHistory(orderCode);
|
||||
Object service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
((ThirdPartyPlatformService) service).notificationChargeOrderInfo(orderCode);
|
||||
((ThirdPartyPlatformService) service).notificationChargeOrderInfoHistory(orderCode);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationChargeOrderInfo(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]历史订单信息推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationChargeOrderInfoHistory(orderCode);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]历史充电订单推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("历史充电订单信息推送error", e);
|
||||
logger.error("历史充电订单信息推送 error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 充电设备告警信息推送
|
||||
* notification_alarmInfo
|
||||
* @param dto
|
||||
*/
|
||||
public void notificationAlarmInfo(NotificationDTO dto) {
|
||||
String stationId = dto.getStationId();
|
||||
String pileConnectorCode = dto.getPileConnectorCode();
|
||||
String status = dto.getStatus();
|
||||
String platformType = dto.getPlatformType();
|
||||
|
||||
if (StringUtils.isBlank(status) || StringUtils.isBlank(pileConnectorCode)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过stationId 查询该站点需要对接的平台配置
|
||||
|
||||
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
|
||||
if (CollectionUtils.isEmpty(secretInfoVOS)) {
|
||||
return;
|
||||
}
|
||||
// 调用相应平台的处理方法
|
||||
|
||||
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
|
||||
if (StringUtils.isNotBlank(platformType) && !StringUtils.equals(platformType, secretInfoVO.getPlatformType())) {
|
||||
// 如果dto中的platformType不为空,并且不等于secretInfoVO.getPlatformType(),continue
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// 根据平台类型获取Service
|
||||
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
|
||||
Object service = getPlatformService(secretInfoVO.getPlatformType());
|
||||
PushAlarmInfoDTO pushAlarmInfoDTO = new PushAlarmInfoDTO();
|
||||
pushAlarmInfoDTO.setPileConnectorCode(pileConnectorCode);
|
||||
pushAlarmInfoDTO.setConnectorStatus(status);
|
||||
|
||||
platformService.notificationAlarmInfo(pushAlarmInfoDTO);
|
||||
com.jsowell.common.service.thirdparty.dto.PushAlarmInfoDTO dtoConvert =
|
||||
new com.jsowell.common.service.thirdparty.dto.PushAlarmInfoDTO();
|
||||
BeanUtils.copyProperties(pushAlarmInfoDTO, dtoConvert);
|
||||
|
||||
if (service instanceof ThirdPartyPlatformService) {
|
||||
|
||||
((ThirdPartyPlatformService) service).notificationAlarmInfo(pushAlarmInfoDTO);
|
||||
} else if (service instanceof ThirdPartyPlatformApi) {
|
||||
// 后续新平台异步处理
|
||||
ThirdPartyPlatformApi apiService = (ThirdPartyPlatformApi) service;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
apiService.notificationAlarmInfo(dtoConvert);
|
||||
} catch (Exception e) {
|
||||
logger.error("new平台[{}]设备告警信息推送失败", secretInfoVO.getPlatformName(), e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("充电设备告警信息推送error", e);
|
||||
}
|
||||
|
||||
109
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/OrderBasicInfoApiImpl.java
vendored
Normal file
109
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/OrderBasicInfoApiImpl.java
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.dto.RealTimeMonitorData;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.domin.OrderBasicInfo;
|
||||
import com.jsowell.common.service.thirdparty.domin.OrderDetail;
|
||||
import com.jsowell.common.service.thirdparty.dto.*;
|
||||
import com.jsowell.common.service.thirdparty.tempservice.OrderBasicInfoApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.*;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@DubboService(group = "thirdparty" , version = "1.0.0")
|
||||
public class OrderBasicInfoApiImpl implements OrderBasicInfoApi {
|
||||
|
||||
@Autowired
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
/**
|
||||
* 转换实体类
|
||||
* @param orderBasicInfo
|
||||
* @return
|
||||
*/
|
||||
public OrderBasicInfo getOrderBasicInfoVO(com.jsowell.pile.domain.OrderBasicInfo orderBasicInfo){
|
||||
OrderBasicInfo orderBasicInfoVO = new OrderBasicInfo();
|
||||
BeanUtils.copyProperties(orderBasicInfo, orderBasicInfoVO);
|
||||
return orderBasicInfoVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OrderBasicInfo getOrderInfoByOrderCode(String orderCode) {
|
||||
com.jsowell.pile.domain.OrderBasicInfo orderInfoByOrderCode = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
return getOrderBasicInfoVO(orderInfoByOrderCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public OrderBasicInfo queryChargingByPileConnectorCode(String pileConnectorCode) {
|
||||
com.jsowell.pile.domain.OrderBasicInfo orderBasicInfo = orderBasicInfoService.queryChargingByPileConnectorCode(pileConnectorCode);
|
||||
|
||||
return getOrderBasicInfoVO(orderBasicInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderDetail getOrderDetailByOrderCode(String orderCode) {
|
||||
com.jsowell.pile.domain.OrderDetail orderDetailByOrderCode = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||||
if (orderDetailByOrderCode == null) {
|
||||
return null;
|
||||
}
|
||||
OrderDetail orderDetail = new OrderDetail();
|
||||
BeanUtils.copyProperties(orderDetailByOrderCode, orderDetail);
|
||||
return orderDetail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<RealTimeMonitorData> getChargingRealTimeData(String transactionCode) {
|
||||
List<com.jsowell.common.core.domain.ykc.RealTimeMonitorData> chargingRealTimeData = orderBasicInfoService.getChargingRealTimeData(transactionCode);
|
||||
List<RealTimeMonitorData> result = new ArrayList<>();
|
||||
chargingRealTimeData.forEach(realTimeMonitorData -> {
|
||||
RealTimeMonitorData monitorData = new RealTimeMonitorData();
|
||||
BeanUtils.copyProperties(realTimeMonitorData, monitorData);
|
||||
result.add(monitorData);
|
||||
});
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AccumulativeInfoVO> getAccumulativeInfoForLianLian(QueryStationInfoDTO dto) {
|
||||
com.jsowell.pile.dto.QueryStationInfoDTO queryStationInfoDTO = new com.jsowell.pile.dto.QueryStationInfoDTO();
|
||||
BeanUtils.copyProperties(dto, queryStationInfoDTO);
|
||||
List<com.jsowell.pile.vo.lianlian.AccumulativeInfoVO> accumulativeInfoForLianLian = orderBasicInfoService.getAccumulativeInfoForLianLian(queryStationInfoDTO);
|
||||
List<AccumulativeInfoVO> result = new ArrayList<>();
|
||||
accumulativeInfoForLianLian.forEach(accumulativeInfoVO -> {
|
||||
AccumulativeInfoVO info = new AccumulativeInfoVO();
|
||||
BeanUtils.copyProperties(accumulativeInfoVO, info);
|
||||
result.add(info);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> generateOrderForThirdParty(QueryStartChargeDTO dto) {
|
||||
com.jsowell.pile.dto.QueryStartChargeDTO queryStartChargeDTO = new com.jsowell.pile.dto.QueryStartChargeDTO();
|
||||
BeanUtils.copyProperties(dto, queryStartChargeDTO);
|
||||
return orderBasicInfoService.generateOrderForThirdParty(queryStartChargeDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tempGetOrderCodes(QueryOrder2DTO dto) {
|
||||
com.jsowell.pile.dto.QueryOrderDTO queryOrderDTO = new com.jsowell.pile.dto.QueryOrderDTO();
|
||||
BeanUtils.copyProperties(dto, queryOrderDTO);
|
||||
return orderBasicInfoService.tempGetOrderCodes(queryOrderDTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
89
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBasicInfoApiImpl.java
vendored
Normal file
89
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileBasicInfoApiImpl.java
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.domin.PileBasicInfo;
|
||||
import com.jsowell.common.service.thirdparty.tempservice.PileBasicInfoApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.PileConnectorDetailVO;
|
||||
import com.jsowell.common.service.thirdparty.vo.PileDetailInfoVO;
|
||||
import com.jsowell.common.vo.PileInfoVO;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@DubboService(group = "thirdparty" , version = "1.0.0")
|
||||
public class PileBasicInfoApiImpl implements PileBasicInfoApi {
|
||||
|
||||
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Override
|
||||
public PileBasicInfo selectPileBasicInfoBySN(String pileSn) {
|
||||
com.jsowell.pile.domain.PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
|
||||
if (pileBasicInfo == null) {
|
||||
return null;
|
||||
}
|
||||
PileBasicInfo result = new PileBasicInfo();
|
||||
BeanUtils.copyProperties(pileBasicInfo, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PileInfoVO selectPileInfoBySn(String pileSn) {
|
||||
com.jsowell.pile.vo.base.PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn);
|
||||
if (pileInfoVO == null) {
|
||||
return null;
|
||||
}
|
||||
PileInfoVO result = new PileInfoVO();
|
||||
BeanUtils.copyProperties(pileInfoVO, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PileConnectorDetailVO queryPileConnectorDetail(String pileConnectorCode) {
|
||||
com.jsowell.pile.vo.uniapp.customer.PileConnectorDetailVO pileConnectorDetailVO = pileBasicInfoService.queryPileConnectorDetail(pileConnectorCode);
|
||||
if (pileConnectorDetailVO == null) {
|
||||
return null;
|
||||
}
|
||||
PileConnectorDetailVO result = new PileConnectorDetailVO();
|
||||
BeanUtils.copyProperties(pileConnectorDetailVO, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<PileDetailInfoVO> getPileDetailInfoList(String stationId) {
|
||||
List<com.jsowell.pile.thirdparty.PileDetailInfoVO> pileDetailInfoList = pileBasicInfoService.getPileDetailInfoList(stationId);
|
||||
if (pileDetailInfoList == null || pileDetailInfoList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PileDetailInfoVO> result = new ArrayList<>();
|
||||
for (com.jsowell.pile.thirdparty.PileDetailInfoVO pileDetailInfoVO : pileDetailInfoList) {
|
||||
PileDetailInfoVO info = new PileDetailInfoVO();
|
||||
BeanUtils.copyProperties(pileDetailInfoVO, info);
|
||||
result.add(info);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PileBasicInfo> getPileListByStationId(String stationId) {
|
||||
List<com.jsowell.pile.domain.PileBasicInfo> pileListByStationId = pileBasicInfoService.getPileListByStationId(stationId);
|
||||
List<PileBasicInfo> result = new ArrayList<>();
|
||||
for (com.jsowell.pile.domain.PileBasicInfo basicInfo : pileListByStationId) {
|
||||
PileBasicInfo pileBasicInfo = new PileBasicInfo();
|
||||
BeanUtils.copyProperties(basicInfo, pileBasicInfo);
|
||||
result.add(pileBasicInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.tempservice.PileBillingTemplateApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.BillingPriceVO;
|
||||
import com.jsowell.common.vo.BillingTemplateVO;
|
||||
import com.jsowell.pile.service.PileBillingTemplateService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@DubboService(group = "thirdparty",version = "1.0.0")
|
||||
public class PileBillingTemplateApiImpl implements PileBillingTemplateApi {
|
||||
|
||||
@Autowired
|
||||
private PileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<BillingPriceVO> queryBillingPrice(String stationId) {
|
||||
List<com.jsowell.pile.vo.uniapp.customer.BillingPriceVO> billingPriceVOS = pileBillingTemplateService.queryBillingPrice(stationId);
|
||||
if (billingPriceVOS == null || billingPriceVOS.isEmpty()){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<BillingPriceVO> billingPriceVOList = new ArrayList<>();
|
||||
for (com.jsowell.pile.vo.uniapp.customer.BillingPriceVO billingPriceVO : billingPriceVOS){
|
||||
BillingPriceVO vo = new BillingPriceVO();
|
||||
BeanUtils.copyProperties(billingPriceVO,vo);
|
||||
}
|
||||
return billingPriceVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BillingTemplateVO selectBillingTemplateDetailByPileSn(String pileSn) {
|
||||
com.jsowell.pile.vo.web.BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
||||
if (billingTemplateVO == null){
|
||||
return null;
|
||||
}
|
||||
BillingTemplateVO vo = new BillingTemplateVO();
|
||||
BeanUtils.copyProperties(billingTemplateVO,vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.domin.PileConnectorInfo;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.tempservice.PileConnectorInfoApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.ConnectorInfoVO;
|
||||
import com.jsowell.common.service.thirdparty.vo.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.service.PileConnectorInfoService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@DubboService(group = "thirdparty" , version = "1.0.0")
|
||||
public class PileConnectorInfoApiImpl implements PileConnectorInfoApi {
|
||||
|
||||
@Autowired
|
||||
private PileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<PileConnectorInfo> selectPileConnectorInfoList(String pileSn) {
|
||||
List<com.jsowell.pile.domain.PileConnectorInfo> pileConnectorInfos = pileConnectorInfoService.selectPileConnectorInfoList(pileSn);
|
||||
if (pileConnectorInfos == null || pileConnectorInfos.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PileConnectorInfo> result = new ArrayList<>();
|
||||
for (com.jsowell.pile.domain.PileConnectorInfo info : pileConnectorInfos) {
|
||||
PileConnectorInfo resultInfo = new PileConnectorInfo();
|
||||
BeanUtils.copyProperties(info, resultInfo);
|
||||
result.add(resultInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PileConnectorInfoVO getPileConnectorInfoByConnectorCode(String connectorCode) {
|
||||
com.jsowell.pile.vo.web.PileConnectorInfoVO info = pileConnectorInfoService.getPileConnectorInfoByConnectorCode(connectorCode);
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
PileConnectorInfoVO resultInfo = new PileConnectorInfoVO();
|
||||
BeanUtils.copyProperties(info, resultInfo);
|
||||
return resultInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConnectorInfoVO> batchSelectConnectorList(List<String> stationIds) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConnectorInfoVO> getConnectorListForLianLian(Long stationId) {
|
||||
List<com.jsowell.pile.vo.base.ConnectorInfoVO> connectorListForLianLian = pileConnectorInfoService.getConnectorListForLianLian(stationId);
|
||||
if (connectorListForLianLian == null || connectorListForLianLian.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ConnectorInfoVO> result = new ArrayList<>();
|
||||
for (com.jsowell.pile.vo.base.ConnectorInfoVO info : connectorListForLianLian) {
|
||||
ConnectorInfoVO resultInfo = new ConnectorInfoVO();
|
||||
BeanUtils.copyProperties(info, resultInfo);
|
||||
result.add(resultInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.tempservice.PileMerchantInfoApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.MerchantInfoVO;
|
||||
import com.jsowell.pile.service.PileMerchantInfoService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@DubboService(group = "thirdparty", version = "1.0.0")
|
||||
public class PileMerchantInfoApiImpl implements PileMerchantInfoApi {
|
||||
|
||||
@Autowired
|
||||
private PileMerchantInfoService pileMerchantInfoService;
|
||||
|
||||
@Override
|
||||
public MerchantInfoVO getMerchantInfoVO(String merchantId) {
|
||||
com.jsowell.pile.vo.base.MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(merchantId);
|
||||
if (merchantInfoVO == null) {
|
||||
return null;
|
||||
}
|
||||
MerchantInfoVO vo = new MerchantInfoVO();
|
||||
BeanUtils.copyProperties(merchantInfoVO, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
}
|
||||
30
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileModelInfoApiImpl.java
vendored
Normal file
30
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileModelInfoApiImpl.java
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
|
||||
import com.jsowell.common.service.thirdparty.tempservice.PileModelInfoApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.PileModelInfoVO;
|
||||
import com.jsowell.pile.service.PileModelInfoService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
@DubboService(group = "thirdparty", version = "1.0.0")
|
||||
public class PileModelInfoApiImpl implements PileModelInfoApi {
|
||||
|
||||
@Autowired
|
||||
private PileModelInfoService pileModelInfoService;
|
||||
|
||||
|
||||
@Override
|
||||
public PileModelInfoVO getPileModelInfoByPileSn(String pileSn) {
|
||||
com.jsowell.pile.vo.web.PileModelInfoVO pileModelInfoByPileSn = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
|
||||
if (pileModelInfoByPileSn == null) {
|
||||
return null;
|
||||
}
|
||||
PileModelInfoVO pileModelInfoVO = new PileModelInfoVO();
|
||||
BeanUtils.copyProperties(pileModelInfoByPileSn, pileModelInfoVO);
|
||||
return pileModelInfoVO;
|
||||
}
|
||||
|
||||
}
|
||||
20
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileRemoteApiImpl.java
vendored
Normal file
20
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/dubbo/api/impl/PileRemoteApiImpl.java
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.tempservice.PileRemoteApi;
|
||||
import com.jsowell.pile.service.PileRemoteService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@DubboService(group = "thirdparty", version = "1.0.0")
|
||||
public class PileRemoteApiImpl implements PileRemoteApi {
|
||||
|
||||
@Resource
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
@Override
|
||||
public void remoteStopCharging(String pileSn , String connectorCode , String transactionCode) {
|
||||
pileRemoteService.remoteStopCharging(pileSn, connectorCode, transactionCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.domin.PileStationInfo;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.dto.QueryStationInfoDTO;
|
||||
import com.jsowell.common.service.thirdparty.tempservice.PileStationInfoApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.ThirdPartyStationInfoVO;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@DubboService(group = "thirdparty", version = "1.0.0")
|
||||
public class PileStationInfoApiImpl implements PileStationInfoApi {
|
||||
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
|
||||
@Override
|
||||
public PileStationInfo selectPileStationInfoById(Long id) {
|
||||
com.jsowell.pile.domain.PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(id);
|
||||
if (pileStationInfo == null) {
|
||||
return null;
|
||||
}
|
||||
PileStationInfo result = new PileStationInfo();
|
||||
BeanUtils.copyProperties(pileStationInfo, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ThirdPartyStationInfoVO> selectStationInfosByThirdParty(QueryStationInfoDTO dto) {
|
||||
com.jsowell.pile.dto.QueryStationInfoDTO dto1 = new com.jsowell.pile.dto.QueryStationInfoDTO();
|
||||
BeanUtils.copyProperties(dto, dto1);
|
||||
List<com.jsowell.pile.vo.base.ThirdPartyStationInfoVO> thirdPartyStationInfoVOS = pileStationInfoService.selectStationInfosByThirdParty(dto1);
|
||||
if (thirdPartyStationInfoVOS == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ThirdPartyStationInfoVO> result = new ArrayList<>();
|
||||
for (com.jsowell.pile.vo.base.ThirdPartyStationInfoVO stationInfo : thirdPartyStationInfoVOS) {
|
||||
ThirdPartyStationInfoVO thirdPartyStationInfoVO = new ThirdPartyStationInfoVO();
|
||||
BeanUtils.copyProperties(stationInfo, thirdPartyStationInfoVO);
|
||||
result.add(thirdPartyStationInfoVO);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.tempservice.ThirdpartySecretInfoApi;
|
||||
import com.jsowell.common.service.thirdparty.vo.StationInfoVO;
|
||||
import com.jsowell.common.service.thirdparty.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@DubboService(group = "thirdparty", version = "1.0.0")
|
||||
public class ThirdpartySecretInfoApiImpl implements ThirdpartySecretInfoApi {
|
||||
|
||||
@Autowired
|
||||
public ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||
|
||||
/**
|
||||
* 通过组织结构代码,查询平台密钥配置信息
|
||||
* @param theirOperatorId 组织结构代码
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId) {
|
||||
com.jsowell.pile.vo.ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(theirOperatorId);
|
||||
if (thirdPartySecretInfoVO == null){
|
||||
return null;
|
||||
}
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO1 = new ThirdPartySecretInfoVO();
|
||||
BeanUtils.copyProperties(thirdPartySecretInfoVO, thirdPartySecretInfoVO1);
|
||||
return thirdPartySecretInfoVO1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过第三方平台类型,查询平台密钥配置信息
|
||||
* @param thirdPlatformType 第三方平台类型, 参见{@link com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum}
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType) {
|
||||
com.jsowell.pile.vo.ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
|
||||
if (thirdPartySecretInfoVO == null){
|
||||
return null;
|
||||
}
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO1 = new ThirdPartySecretInfoVO();
|
||||
BeanUtils.copyProperties(thirdPartySecretInfoVO, thirdPartySecretInfoVO1);
|
||||
return thirdPartySecretInfoVO1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据第三方平台类型查询对接第三方平台的站点列表
|
||||
* @param thirdPlatformType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<StationInfoVO> selectStationList(String thirdPlatformType) {
|
||||
List<com.jsowell.pile.vo.base.StationInfoVO> stationInfoVOS = thirdpartySecretInfoService.selectStationList(thirdPlatformType);
|
||||
if (stationInfoVOS == null || stationInfoVOS.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
List<StationInfoVO> stationInfoVOList = new java.util.ArrayList<>();
|
||||
for (com.jsowell.pile.vo.base.StationInfoVO stationInfoVO : stationInfoVOS){
|
||||
StationInfoVO stationInfoVO1 = new StationInfoVO();
|
||||
BeanUtils.copyProperties(stationInfoVO, stationInfoVO1);
|
||||
stationInfoVOList.add(stationInfoVO1);
|
||||
}
|
||||
return stationInfoVOList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.jsowell.thirdparty.dubbo.api.impl;
|
||||
|
||||
import com.jsowell.common.service.thirdparty.domin.ykcCommond.StartChargingCommand;
|
||||
import com.jsowell.common.service.thirdparty.tempservice.YKCPushCommandApi;
|
||||
import com.jsowell.pile.service.YKCPushCommandService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@DubboService(group = "thirdparty" ,version = "1.0.0")
|
||||
public class YKCPushCommandApiImpl implements YKCPushCommandApi {
|
||||
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcpushCommandService;
|
||||
|
||||
@Override
|
||||
public void pushStartChargingCommand(StartChargingCommand startChargingCommand) {
|
||||
com.jsowell.pile.domain.ykcCommond.StartChargingCommand command = new com.jsowell.pile.domain.ykcCommond.StartChargingCommand();
|
||||
BeanUtils.copyProperties(startChargingCommand, command);
|
||||
ykcpushCommandService.pushStartChargingCommand(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.jsowell.thirdparty.dubbo.factory;
|
||||
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.service.thirdparty.ThirdPartyPlatformApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.ReferenceConfig;
|
||||
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 动态服务工厂
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DynamicThirdPartyPlatformFactory {
|
||||
|
||||
// 缓存已获取的服务代理
|
||||
private static final ConcurrentHashMap<String, ThirdPartyPlatformApi> serviceCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 根据平台类型动态获取远程服务
|
||||
* @param platformType 平台类型(需与远程服务的@DubboService(group)一致)
|
||||
* @return 远程服务代理
|
||||
*/
|
||||
public static ThirdPartyPlatformApi getPlatformService(String platformType) {
|
||||
|
||||
if (platformType == null || platformType.isEmpty()) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
|
||||
// 1. 先从缓存获取
|
||||
ThirdPartyPlatformApi service = serviceCache.get(platformType);
|
||||
|
||||
if (service != null) {
|
||||
return service;
|
||||
}
|
||||
|
||||
// 2. 动态创建服务引用
|
||||
synchronized (DynamicThirdPartyPlatformFactory.class) {
|
||||
service = serviceCache.get(platformType);
|
||||
if (service != null) {
|
||||
return service;
|
||||
}
|
||||
|
||||
try {
|
||||
// 创建ReferenceConfig实例
|
||||
// 要与jsowell-charge-thirdparty的远程服务的@DubboService配置一致
|
||||
ReferenceConfig<ThirdPartyPlatformApi> referenceConfig = new ReferenceConfig<>();
|
||||
referenceConfig.setInterface(ThirdPartyPlatformApi.class);
|
||||
referenceConfig.setGroup(platformType);
|
||||
referenceConfig.setVersion("1.0.0");
|
||||
referenceConfig.setTimeout(10000); // 设置超时时间为10秒,默认为1秒
|
||||
referenceConfig.setRetries(2); //失败重试次数为2
|
||||
// referenceConfig.setAsync(true); //异步调用
|
||||
|
||||
|
||||
// 根据特定的配置,在nacos中寻找jsowell-charge-thirdparty注册的服务
|
||||
// 使用DubboBootstrap注册并获取服务
|
||||
DubboBootstrap
|
||||
.getInstance() // 获取DubboBootstrap实例
|
||||
.reference( // 引用服务配置
|
||||
referenceConfig,
|
||||
DubboBootstrap
|
||||
.getInstance()
|
||||
.getApplicationModel()
|
||||
.getDefaultModule());
|
||||
|
||||
// 获取服务代理
|
||||
service = referenceConfig.get();
|
||||
serviceCache.put(platformType, service);
|
||||
log.info("缓存中有的缓存有: "+ serviceCache.toString());
|
||||
return service;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(ReturnCodeEnum.valueOf("获取平台[" + platformType + "]的服务失败: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*/
|
||||
public static void clearCache() {
|
||||
serviceCache.clear();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user