mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-03 17:40:13 +08:00
苏州市平台新增 推送告警信息接口
This commit is contained in:
83
jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/PileErrorCodeAlarmEnum.java
vendored
Normal file
83
jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/PileErrorCodeAlarmEnum.java
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.jsowell.common.enums.thirdparty;
|
||||
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 桩故障码与第三方平台告警码对照枚举
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/9/26 14:03:42
|
||||
*/
|
||||
public enum PileErrorCodeAlarmEnum {
|
||||
|
||||
STOP_BUTTON_FAULT(1, "112", "急停按钮动作故障"),
|
||||
NO_CAN_USE_RECTIFICATION_MODEL_FAULT(2, "", "无可用整流模块"),
|
||||
OUTLET_TEMPERATURE_TOO_HIGH_FAULT(3, "107", "出风口温度过高"),
|
||||
ALTERNATING_LIGHTING_PROTECTION_FAULT(4, "", "交流防雷故障"),
|
||||
DC20_COMMUNICATION_INTERRUPT_FAULT(5, "", "交直流模块 DC20 通信中断"),
|
||||
FC08_COMMUNICATION_INTERRUPT_FAULT(6, "", "交直流模块 FC08 通信中断"),
|
||||
WATT_HOUR_METER_COMMUNICATION_INTERRUPT_FAULT(7, "114", "电度表通信中断"),
|
||||
CARD_READER_COMMUNICATION_INTERRUPT_FAULT(8, "113", "读卡器通信中断"),
|
||||
RC10_COMMUNICATION_INTERRUPT_FAULT(9, "", "RC10 通信中断"),
|
||||
FAN_SPEED_CONTROL_FAULT(10, "111", "风扇调速板故障"),
|
||||
DC_FUSE_FAULT(11, "", "直流熔断器故障"),
|
||||
HIGH_PRESSURE_CONTACTOR_FAULT(12, "", "高压接触器故障"),
|
||||
DOOR_OPEN_FAULT(13, "", "门打开"),
|
||||
;
|
||||
private Integer faultCode;
|
||||
private String thirdPartyAlarmCode;
|
||||
private String faultReason;
|
||||
|
||||
public Integer getFaultCode() {
|
||||
return faultCode;
|
||||
}
|
||||
|
||||
public void setFaultCode(Integer faultCode) {
|
||||
this.faultCode = faultCode;
|
||||
}
|
||||
|
||||
public String getThirdPartyAlarmCode() {
|
||||
return thirdPartyAlarmCode;
|
||||
}
|
||||
|
||||
public void setThirdPartyAlarmCode(String thirdPartyAlarmCode) {
|
||||
this.thirdPartyAlarmCode = thirdPartyAlarmCode;
|
||||
}
|
||||
|
||||
public String getFaultReason() {
|
||||
return faultReason;
|
||||
}
|
||||
|
||||
public void setFaultReason(String faultReason) {
|
||||
this.faultReason = faultReason;
|
||||
}
|
||||
|
||||
PileErrorCodeAlarmEnum(Integer faultCode, String thirdPartyAlarmCode, String faultReason) {
|
||||
this.faultCode = faultCode;
|
||||
this.thirdPartyAlarmCode = thirdPartyAlarmCode;
|
||||
this.faultReason = faultReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ykc故障码获取第三方平台告警码
|
||||
* @param faultCode
|
||||
* @return
|
||||
*/
|
||||
public static String getThirdPartyAlarmCodeByfaultCode(Integer faultCode) {
|
||||
for (PileErrorCodeAlarmEnum item : PileErrorCodeAlarmEnum.values()) {
|
||||
if (faultCode.equals(item.getFaultCode())) {
|
||||
return item.thirdPartyAlarmCode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// 通过故障原因查询告警码
|
||||
public static String getThirdPartyAlarmCodeByfaultReason(String faultReason) {
|
||||
for (PileErrorCodeAlarmEnum item : PileErrorCodeAlarmEnum.values()) {
|
||||
if (StringUtils.equals(faultReason, item.getFaultReason())) {
|
||||
return item.thirdPartyAlarmCode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.netty.handler.yunkuaichong;
|
||||
|
||||
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.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
@@ -336,6 +337,18 @@ public class UploadRealTimeMonitorHandler extends AbstractYkcHandler {
|
||||
}
|
||||
}, executor);
|
||||
|
||||
if (StringUtils.equals(connectorStatus, Constants.ONE)) {
|
||||
// 故障
|
||||
// 异步推送第三方平台告警信息
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
commonService.commonPushAlarmInfo(pileConnectorCode, connectorStatus);
|
||||
} catch (Exception e) {
|
||||
log.error("统一推送第三方平台告警信息 error, ", e);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统一推送启动充电结果
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
52
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/AlarmInfo.java
vendored
Normal file
52
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/AlarmInfo.java
vendored
Normal 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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user