苏州市平台新增 推送告警信息接口

This commit is contained in:
Lemon
2024-09-26 17:02:56 +08:00
parent 05d0b319bc
commit e42bd1ebd0
6 changed files with 280 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ import com.jsowell.pile.dto.PushStationInfoDTO;
import com.jsowell.pile.dto.ThirdPartyCommonStartChargeDTO;
import com.jsowell.pile.dto.ThirdPartyCommonStopChargeDTO;
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
import com.jsowell.pile.dto.ruanjie.UseCouponDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
@@ -40,6 +41,7 @@ import com.jsowell.thirdparty.platform.service.impl.HaiNanPlatformServiceImpl;
import com.jsowell.thirdparty.platform.service.impl.NingXiaPlatformServiceImpl;
import com.jsowell.thirdparty.platform.service.impl.QingHaiPlatformServiceImpl;
import com.jsowell.thirdparty.platform.util.HttpRequestUtil;
import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils;
import com.jsowell.thirdparty.ruanjie.service.RJService;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import com.jsowell.thirdparty.xindiantu.service.XDTService;
@@ -525,6 +527,31 @@ public class CommonService {
}
}
/**
* 统一推送告警信息
* @param pileConnectorCode
* @param connectorStatus
*/
public void commonPushAlarmInfo(String pileConnectorCode, String connectorStatus) {
// 查询站点信息
PileStationVO stationVO = pileStationInfoService.getStationInfoByPileConnectorCode(pileConnectorCode);
String stationId = stationVO.getId();
// 查询该站点是否推送第三方平台
List<ThirdPartySecretInfoVO> relationInfoList = thirdpartySecretInfoService.queryStationToPlatformList(stationId);
if (CollectionUtils.isEmpty(relationInfoList)) {
return;
}
for (ThirdPartySecretInfoVO relationVO : relationInfoList) {
NotificationDTO notificationDTO = new NotificationDTO();
notificationDTO.setStatus(connectorStatus);
notificationDTO.setPileConnectorCode(pileConnectorCode);
notificationDTO.setStationId(stationId);
notificationDTO.setPlatformType(relationVO.getPlatformType());
notificationService.notificationAlarmInfo(notificationDTO);
}
}
/**
* 统一推送启动充电结果

View File

@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory;
@@ -259,4 +260,41 @@ public class NotificationService {
}
}
}
/**
* 充电设备告警信息推送
* @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());
PushAlarmInfoDTO pushAlarmInfoDTO = new PushAlarmInfoDTO();
pushAlarmInfoDTO.setPileConnectorCode(pileConnectorCode);
pushAlarmInfoDTO.setConnectorStatus(status);
platformService.notificationAlarmInfo(pushAlarmInfoDTO);
} catch (Exception e) {
logger.error("充电设备告警信息推送error", e);
}
}
}
}

View File

@@ -0,0 +1,52 @@
package com.jsowell.thirdparty.platform.common;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 充电设备告警信息
*
* @author Lemon
* @Date 2024/9/26 13:41:01
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class AlarmInfo {
@JSONField(name = "OperatorID")
private String operatorId;
@JSONField(name = "ConnectorID")
private String connectorId;
/**
* 告警时间
*/
@JSONField(name = "Alert_time")
private String alertTime;
/**
* 告警代码
*/
@JSONField(name = "Alert_code")
private String alertCode;
/**
* 描述
*/
@JSONField(name = "Describe")
private String describe;
/**
* 状态
* 告警发生0
* 告警恢复1
*/
@JSONField(name = "Status")
private String status;
}

View File

@@ -4,10 +4,13 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.lianlian.StationPaymentEnum;
import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.PileErrorCodeAlarmEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
@@ -19,6 +22,7 @@ import com.jsowell.pile.domain.OrderDetail;
import com.jsowell.pile.domain.PileStationInfo;
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.dto.nanrui.PushAlarmInfoDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.EquipmentInfo;
@@ -34,6 +38,7 @@ import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo;
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
import com.jsowell.thirdparty.platform.common.AlarmInfo;
import com.jsowell.thirdparty.platform.common.ChargeOrderInfo;
import com.jsowell.thirdparty.platform.common.StationInfo;
import com.jsowell.thirdparty.platform.domain.SupEquipChargeStatusInfo;
@@ -79,6 +84,9 @@ public class SuZhouPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired
private PileStationInfoService pileStationInfoService;
@Autowired
private RedisCache redisCache;
Logger logger = LoggerFactory.getLogger(this.getClass());
// 平台类型
@@ -139,6 +147,65 @@ public class SuZhouPlatformServiceImpl implements ThirdPartyPlatformService {
return resultMap;
}
/**
* 推送告警信息
* @param dto
* @return
*/
@Override
public String notificationAlarmInfo(PushAlarmInfoDTO dto) {
String pileConnectorCode = dto.getPileConnectorCode();
String connectorStatus = dto.getConnectorStatus();
String alertCode = "";
String alertStatus = Constants.ZERO;
if (!StringUtils.equals(connectorStatus, Constants.ONE)) {
// 如果不是故障则告警状态要改为1-告警恢复
alertStatus = Constants.ONE;
}
// 通过枪口编号查询故障原因
String redisKey = CacheConstants.PILE_HARDWARE_FAULT + pileConnectorCode;
String faultReason = redisCache.getCacheObject(redisKey);
if (StringUtils.isBlank(faultReason)) {
// 未查到故障告警状态也要改为1-告警恢复
alertStatus = Constants.ONE;
}else {
// 通过故障原因查询告警码
String alarmCodeByReason = PileErrorCodeAlarmEnum.getThirdPartyAlarmCodeByfaultReason(faultReason);
if (StringUtils.isBlank(alarmCodeByReason)) {
// 未找到对应故障码
alertCode = "120"; // 预留
}else {
alertCode = alarmCodeByReason;
}
}
AlarmInfo alarmInfo = AlarmInfo.builder()
.operatorId(Constants.OPERATORID_JIANG_SU)
.connectorId(pileConnectorCode)
.alertCode(alertCode)
.describe(faultReason)
.alertTime(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS))
.status(alertStatus)
.build();
// 查询相关配置信息
ThirdPartySecretInfoVO suZhouSecretInfo = getSuZhouSecretInfo();
String operatorId = suZhouSecretInfo.getOurOperatorId();
String operatorSecret = suZhouSecretInfo.getTheirOperatorSecret();
String signSecret = suZhouSecretInfo.getTheirSigSecret();
String dataSecret = suZhouSecretInfo.getTheirDataSecret();
String dataSecretIv = suZhouSecretInfo.getTheirDataSecretIv();
String urlAddress = suZhouSecretInfo.getTheirUrlPrefix();
String url = urlAddress + "notification_alarmInfo";
String jsonString = JSON.toJSONString(alarmInfo);
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
return result;
}
/**
* 查询站点信息 query_stationInfo
* @param dto 查询站点信息dto