通知第三方平台重构

This commit is contained in:
2024-04-20 17:18:21 +08:00
parent 6a7bd665cc
commit e06762ea0c
5 changed files with 410 additions and 22 deletions

View File

@@ -5,6 +5,8 @@ import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -18,6 +20,7 @@ import java.util.List;
*/
@Service
public class NotificationService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ThirdpartySecretInfoService thirdpartySecretInfoService;
@@ -34,9 +37,13 @@ public class NotificationService {
}
// 调用相应平台的处理方法
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
// platformService.printServiceName();
platformService.notificationStationInfo(stationId);
try {
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
// platformService.printServiceName();
platformService.notificationStationInfo(stationId);
} catch (Exception e) {
logger.error("充电站信息变化推送error", e);
}
}
}
@@ -52,9 +59,13 @@ public class NotificationService {
}
// 调用相应平台的处理方法
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
// 根据平台类型获取Service
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
platformService.notificationStationStatus(stationId, pileConnectorCode, status, secretInfoVO);
try {
// 根据平台类型获取Service
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
platformService.notificationStationStatus(stationId, pileConnectorCode, status, secretInfoVO);
} catch (Exception e) {
logger.error("设备状态变化推送error", e);
}
}
}
@@ -63,23 +74,65 @@ public class NotificationService {
* notification_connector_charge_status
* notification_equip_charge_status
*/
public void notificationConnectorChargeStatus() {
public void notificationConnectorChargeStatus(String stationId, String orderCode) {
// 通过stationId 查询该站点需要对接的平台配置
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
if (CollectionUtils.isEmpty(secretInfoVOS)) {
return;
}
// 调用相应平台的处理方法
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
try {
// 根据平台类型获取Service
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
platformService.notificationConnectorChargeStatus(orderCode, secretInfoVO);
} catch (Exception e) {
logger.error("设备充电中状态变化推送error", e);
}
}
}
/**
* 订单信息推送
* 充电订单信息推送
* notification_orderInfo/notification_charge_order_info
*/
public void notificationOrderInfo() {
public void notificationChargeOrderInfo(String stationId, String orderCode) {
// 通过stationId 查询该站点需要对接的平台配置
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
if (CollectionUtils.isEmpty(secretInfoVOS)) {
return;
}
// 调用相应平台的处理方法
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
try {
// 根据平台类型获取Service
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
platformService.notificationChargeOrderInfo(orderCode, secretInfoVO);
} catch (Exception e) {
logger.error("设备充电中状态变化推送error", e);
}
}
}
/**
* 站点费率变化推送
* notification_stationFee
*/
public void notificationStationFee() {
public void notificationStationFee(String stationId) {
// 通过stationId 查询该站点需要对接的平台配置
List<ThirdPartySecretInfoVO> secretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
if (CollectionUtils.isEmpty(secretInfoVOS)) {
return;
}
// 调用相应平台的处理方法
for (ThirdPartySecretInfoVO secretInfoVO : secretInfoVOS) {
try {
// 根据平台类型获取Service
ThirdPartyPlatformService platformService = ThirdPartyPlatformFactory.getInvokeStrategy(secretInfoVO.getPlatformType());
platformService.notificationStationFee(stationId, secretInfoVO);
} catch (Exception e) {
logger.error("设备充电中状态变化推送error", e);
}
}
}
}