diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java index 696d28eee..e331fc026 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java @@ -299,40 +299,44 @@ public class PileStationInfoController extends BaseController { public RestApiResponse pushStationInfo(@RequestBody PushStationInfoDTO dto) { logger.info("推送第三方平台充电站信息 params:{}", JSONObject.toJSONString(dto)); RestApiResponse response = null; + List types = dto.getThirdPartyTypes(); try { if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } String result = ""; - if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { - // 推送联联 - // result = lianLianService.pushStationInfo(dto); - result = lianLianService.pushStationInfoV2(dto); + for (String type : types) { + dto.setThirdPartyType(type); + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { + // 推送联联 + // result = lianLianService.pushStationInfo(dto); + result = lianLianService.pushStationInfoV2(dto); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { + // 中电联 + // result = zdlService.pushStationInfo(dto); + result = zdlService.pushStationInfoV2(dto); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), dto.getThirdPartyType())) { + // 江苏省平台 + // result = nrService.pushStationInfo(dto); + result = nrService.pushStationInfoV2(dto); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), dto.getThirdPartyType())) { + // 甬城泊车平台 + // result = ycbcService.pushStationInfo(dto); + result = ycbcService.pushStationInfoV2(dto); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), dto.getThirdPartyType())) { + // 新电途平台 + xdtService.pushStationInfo(dto); + } + // if(StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), dto.getThirdPartyType())) { + // // 华为 + // result = huaWeiService.notificationOperationSystemInfo(dto); + // } + response = new RestApiResponse<>(result); } - if (StringUtils.equals(ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { - // 中电联 - // result = zdlService.pushStationInfo(dto); - result = zdlService.pushStationInfoV2(dto); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), dto.getThirdPartyType())) { - // 江苏省平台 - // result = nrService.pushStationInfo(dto); - result = nrService.pushStationInfoV2(dto); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), dto.getThirdPartyType())) { - // 甬城泊车平台 - // result = ycbcService.pushStationInfo(dto); - result = ycbcService.pushStationInfoV2(dto); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), dto.getThirdPartyType())) { - // 新电途平台 - xdtService.pushStationInfo(dto); - } - // if(StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), dto.getThirdPartyType())) { - // // 华为 - // result = huaWeiService.notificationOperationSystemInfo(dto); - // } - response = new RestApiResponse<>(result); }catch (BusinessException e) { logger.error("推送第三方平台充电站信息 error",e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java index 6587fa17f..b5f16100f 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java @@ -41,12 +41,14 @@ import com.jsowell.thirdparty.yongchengboche.service.YCBCService; import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; import io.netty.channel.Channel; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.util.Date; +import java.util.List; import java.util.Objects; /** @@ -689,58 +691,61 @@ public class TransactionRecordsRequestHandler extends AbstractHandler { // 联联平台 推送订单信息 notification_orderInfo try { // 查询该站点是否推送第三方平台 - ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); - relation.setStationId(Long.parseLong(orderBasicInfo.getStationId())); - ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); - // ThirdPartySettingInfo infoByStationId = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(stationId)); - if (Objects.isNull(relationInfo)) { + // ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + // relation.setStationId(Long.parseLong(orderBasicInfo.getStationId())); + List relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderBasicInfo.getStationId()); + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + if (CollectionUtils.isEmpty(relationInfoList)) { return; } - String thirdPartyType = relationInfo.getThirdPartyType(); - if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), thirdPartyType)) { - // 联联平台 - // 推送停止充电结果 - lianLianService.pushStopChargeResult(orderBasicInfo.getOrderCode()); - // 推送订单信息 - lianLianService.pushOrderInfo(orderBasicInfo.getOrderCode()); - // 推送充电订单信息 - lianLianService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getCode(), thirdPartyType)) { - // 中电联 - zdlService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), thirdPartyType)) { - // 江苏平台 - // 推送订单信息 - nrService.pushOrderInfo(orderBasicInfo.getOrderCode()); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), thirdPartyType)) { - // 新电途平台 - // 推送停止充电结果 - xdtService.notificationStopChargeResult(orderBasicInfo.getOrderCode()); - // 推送订单信息 - xdtService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), thirdPartyType)) { - // 华为 - // 推送停止充电结果 - huaWeiService.notificationStopChargeResult(orderBasicInfo.getOrderCode()); - // 推送订单信息 - huaWeiService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); - } - - if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) { - if (StringUtils.equals(orderBasicInfo.getStartMode(), StartModeEnum.THIRD_PARTY_PLATFORM.getValue())) { - // 甬城泊车 + for (ThirdPartyStationRelationVO relationVO : relationInfoList) { + String thirdPartyType = relationVO.getThirdPartyType(); + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), thirdPartyType)) { + // 联联平台 // 推送停止充电结果 - ycbcService.pushStopChargeResult(orderBasicInfo.getOrderCode()); + lianLianService.pushStopChargeResult(orderBasicInfo.getOrderCode()); // 推送订单信息 - log.info("甬城泊车平台 推送充电订单信息 param:{}", orderBasicInfo.getOrderCode()); - String result = ycbcService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); - log.info("甬城泊车平台 推送充电订单信息 result:{}", result); + lianLianService.pushOrderInfo(orderBasicInfo.getOrderCode()); + // 推送充电订单信息 + lianLianService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getCode(), thirdPartyType)) { + // 中电联 + zdlService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), thirdPartyType)) { + // 江苏平台 + // 推送订单信息 + nrService.pushOrderInfo(orderBasicInfo.getOrderCode()); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), thirdPartyType)) { + // 新电途平台 + // 推送停止充电结果 + xdtService.notificationStopChargeResult(orderBasicInfo.getOrderCode()); + // 推送订单信息 + xdtService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), thirdPartyType)) { + // 华为 + // 推送停止充电结果 + huaWeiService.notificationStopChargeResult(orderBasicInfo.getOrderCode()); + // 推送订单信息 + huaWeiService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); + } + + if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) { + if (StringUtils.equals(orderBasicInfo.getStartMode(), StartModeEnum.THIRD_PARTY_PLATFORM.getValue())) { + // 甬城泊车 + // 推送停止充电结果 + ycbcService.pushStopChargeResult(orderBasicInfo.getOrderCode()); + // 推送订单信息 + log.info("甬城泊车平台 推送充电订单信息 param:{}", orderBasicInfo.getOrderCode()); + String result = ycbcService.pushChargeOrderInfo(orderBasicInfo.getOrderCode()); + log.info("甬城泊车平台 推送充电订单信息 result:{}", result); + } } } + // 调用相关接口 } catch (Exception e) { log.error("第三方平台 推送订单信息发生异常", e); diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java index b3f76e07e..6da87fadd 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/UploadRealTimeMonitorHandler.java @@ -31,10 +31,12 @@ import com.jsowell.thirdparty.yongchengboche.service.YCBCService; import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; import io.netty.channel.Channel; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; +import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -341,105 +343,110 @@ public class UploadRealTimeMonitorHandler extends AbstractHandler { // return null; // } // 状态不一样,传给第三方平台 + + // ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + // if (StringUtils.isBlank(String.valueOf(pileBasicInfo.getStationId()))) { + // return; + // } + // relation.setStationId(pileBasicInfo.getStationId()); // 查询该站点是否推送第三方平台 - ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); - if (StringUtils.isBlank(String.valueOf(pileBasicInfo.getStationId()))) { - return; - } - relation.setStationId(pileBasicInfo.getStationId()); - ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); - if (Objects.isNull(relationInfo)) { + List list = thirdPartyStationRelationService.getRelationInfoList(String.valueOf(pileBasicInfo.getStationId())); + // ThirdPartyStationRelationVO relationInfo = thirdPartyStationRelationService.selectRelationInfo(relation); + if (CollectionUtils.isEmpty(list)) { return; } String pileConnectorCode = pileSn + connectorCode; // 将枪口状态转换成对接平台的状态 String changedStatus = changeConnectorStatus(connectorStatus, realTimeMonitorData.getPutGunType()); - - if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), relationInfo.getThirdPartyType())) { - // 联联 - OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); - if (orderInfo == null) { - return; - } - // log.info("推送联联平台实时数据 params: orderBasicInfo:{}", JSON.toJSONString(orderInfo)); - // 设备状态变化推送 notification_stationStatus - lianLianService.pushConnectorStatus(pileConnectorCode, changedStatus); - if (StringUtils.equals(connectorStatus, "03")) { - // 充电中 - lianLianService.pushPileChargeStatusChange(orderInfo.getOrderCode()); - } - // 推送充电状态 - lianLianService.pushChargeStatus(orderInfo.getOrderCode()); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getCode(), relationInfo.getThirdPartyType())) { - // 中电联 - // log.info("推送中电联平台实时数据 pileConnectorCode:{}, connectorStatus:{}", pileConnectorCode, connectorStatus); - zdlService.notificationStationStatus(pileConnectorCode, changedStatus); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), relationInfo.getThirdPartyType())) { - // 先判断缓存中是否有数据 - String redisKey = CacheConstants.JIANGSU_PUSH_PILE_STATUS + pileConnectorCode; - Object cacheObject = redisCache.getCacheObject(redisKey); - - // 江苏省平台(充电状态至少一分钟推送一次) - if (StringUtils.equals(connectorStatus, "03")) { - // 充电状态 - // 如果缓存有数据,证明上次推送未超过一分钟,不予推送,若缓存中无数据,说明需要推送 - if (cacheObject == null) { - // log.info("推送江苏省平台 充电状态 params:{}", realTimeMonitorData); - String result = nrService.pushPileStatus(realTimeMonitorData); - redisCache.setCacheObject(redisKey, realTimeMonitorData, 1, TimeUnit.MINUTES); - // log.info("推送江苏省平台 充电状态 result:{}", result); + for (ThirdPartyStationRelationVO vo : list) { + String thirdPartyType = vo.getThirdPartyType(); + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), thirdPartyType)) { + // 联联 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (orderInfo == null) { + return; } - } else { - // 如果不是充电状态,直接推送就可以 - // log.info("推送江苏省平台 非充电状态 params:{}", realTimeMonitorData); - String result = nrService.pushPileStatus(realTimeMonitorData); - // log.info("推送江苏省平台 非充电状态 result:{}", result); + // log.info("推送联联平台实时数据 params: orderBasicInfo:{}", JSON.toJSONString(orderInfo)); + // 设备状态变化推送 notification_stationStatus + lianLianService.pushConnectorStatus(pileConnectorCode, changedStatus); + if (StringUtils.equals(connectorStatus, "03")) { + // 充电中 + lianLianService.pushPileChargeStatusChange(orderInfo.getOrderCode()); + } + // 推送充电状态 + lianLianService.pushChargeStatus(orderInfo.getOrderCode()); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getCode(), thirdPartyType)) { + // 中电联 + // log.info("推送中电联平台实时数据 pileConnectorCode:{}, connectorStatus:{}", pileConnectorCode, connectorStatus); + zdlService.notificationStationStatus(pileConnectorCode, changedStatus); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), thirdPartyType)) { + // 先判断缓存中是否有数据 + String redisKey = CacheConstants.JIANGSU_PUSH_PILE_STATUS + pileConnectorCode; + Object cacheObject = redisCache.getCacheObject(redisKey); + + // 江苏省平台(充电状态至少一分钟推送一次) + if (StringUtils.equals(connectorStatus, "03")) { + // 充电状态 + // 如果缓存有数据,证明上次推送未超过一分钟,不予推送,若缓存中无数据,说明需要推送 + if (cacheObject == null) { + // log.info("推送江苏省平台 充电状态 params:{}", realTimeMonitorData); + String result = nrService.pushPileStatus(realTimeMonitorData); + redisCache.setCacheObject(redisKey, realTimeMonitorData, 1, TimeUnit.MINUTES); + // log.info("推送江苏省平台 充电状态 result:{}", result); + } + } else { + // 如果不是充电状态,直接推送就可以 + // log.info("推送江苏省平台 非充电状态 params:{}", realTimeMonitorData); + String result = nrService.pushPileStatus(realTimeMonitorData); + // log.info("推送江苏省平台 非充电状态 result:{}", result); + } + + // log.info("推送江苏省平台实时数据 result:{}", result); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), thirdPartyType)) { + // 新电途平台 + log.info("新电途平台设备状态变化推送 pileConnectorCode:{}, changedStatus:{}", pileConnectorCode, changedStatus); + String result1 = xdtService.notificationStationStatus(pileConnectorCode, changedStatus); + log.info("新电途平台设备状态变化推送 result:{}", result1); + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (orderInfo == null) { + return; + } + log.info("推送新电途平台 充电状态 params:{}", orderInfo.getOrderCode()); + String result = xdtService.notificationEquipChargeStatus(orderInfo.getOrderCode()); + log.info("推送新电途平台 充电状态 result:{}", result); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), thirdPartyType)) { + // 华为平台 + huaWeiService.notificationStationStatus(pileConnectorCode, changedStatus); + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (orderInfo == null) { + return; + } + huaWeiService.notificationEquipChargeStatus(orderInfo.getOrderCode()); } - // log.info("推送江苏省平台实时数据 result:{}", result); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), relationInfo.getThirdPartyType())) { - // 新电途平台 - log.info("新电途平台设备状态变化推送 pileConnectorCode:{}, changedStatus:{}", pileConnectorCode, changedStatus); - String result1 = xdtService.notificationStationStatus(pileConnectorCode, changedStatus); - log.info("新电途平台设备状态变化推送 result:{}", result1); - OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); - if (orderInfo == null) { - return; + if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), thirdPartyType)) { + // 甬城泊车 + // log.info("推送甬城泊车平台设备状态变化推送 pileConnectorCode:{}, changedStatus:{}", pileConnectorCode, changedStatus); + // 设备状态变化推送 notification_stationStatus + String result1 = ycbcService.notificationStationStatus(pileConnectorCode, changedStatus); + // log.info("推送甬城泊车平台设备状态变化推送 result:{}", result1); + // 推送充电状态 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); + if (orderInfo == null) { + return; + } + if (StringUtils.equals(orderInfo.getStartMode(), StartModeEnum.THIRD_PARTY_PLATFORM.getValue())) { + // log.info("推送甬城泊车充电订单状态 param:{}", orderInfo); + String result2 = ycbcService.pushChargeStatus(orderInfo.getOrderCode()); + // log.info("推送甬城泊车充电订单状态 result:{}", result2); + } } - log.info("推送新电途平台 充电状态 params:{}", orderInfo.getOrderCode()); - String result = xdtService.notificationEquipChargeStatus(orderInfo.getOrderCode()); - log.info("推送新电途平台 充电状态 result:{}", result); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), relationInfo.getThirdPartyType())) { - // 华为平台 - huaWeiService.notificationStationStatus(pileConnectorCode, changedStatus); - OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); - if (orderInfo == null) { - return; - } - huaWeiService.notificationEquipChargeStatus(orderInfo.getOrderCode()); } - if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), relationInfo.getThirdPartyType())) { - // 甬城泊车 - // log.info("推送甬城泊车平台设备状态变化推送 pileConnectorCode:{}, changedStatus:{}", pileConnectorCode, changedStatus); - // 设备状态变化推送 notification_stationStatus - String result1 = ycbcService.notificationStationStatus(pileConnectorCode, changedStatus); - // log.info("推送甬城泊车平台设备状态变化推送 result:{}", result1); - // 推送充电状态 - OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); - if (orderInfo == null) { - return; - } - if (StringUtils.equals(orderInfo.getStartMode(), StartModeEnum.THIRD_PARTY_PLATFORM.getValue())) { - // log.info("推送甬城泊车充电订单状态 param:{}", orderInfo); - String result2 = ycbcService.pushChargeStatus(orderInfo.getOrderCode()); - // log.info("推送甬城泊车充电订单状态 result:{}", result2); - } - } } catch (Exception e) { log.error("推送第三方平台 实时数据 异常", e); }