648540858
2022-10-18 1af77ab5f7c11a4b3d59c1989b51b9fca29679ce
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
@@ -16,6 +16,7 @@
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import gov.nist.javax.sip.message.SIPRequest;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,7 +73,7 @@
    private boolean taskQueueHandlerRun = false;
    private final ConcurrentLinkedQueue<SipMsgInfo> taskQueue = new ConcurrentLinkedQueue<>();
    private ConcurrentLinkedQueue<SipMsgInfo> taskQueue = new ConcurrentLinkedQueue<>();
    @Qualifier("taskExecutor")
    @Autowired
@@ -92,13 +93,14 @@
        if (!taskQueueHandlerRun) {
            taskQueueHandlerRun = true;
            taskExecutor.execute(() -> {
                logger.info("[处理报警通知]待处理数量:{}", taskQueue.size() );
                while (!taskQueue.isEmpty()) {
                    SipMsgInfo sipMsgInfo = taskQueue.poll();
                    // 回复200 OK
                    try {
                        responseAck(getServerTransaction(sipMsgInfo.getEvt()), Response.OK);
                        responseAck((SIPRequest) sipMsgInfo.getEvt().getRequest(), Response.OK);
                    } catch (SipException | InvalidArgumentException | ParseException e) {
                        logger.error("[收到报警通知], 回复200OK失败", e);
                        logger.error("[处理报警通知], 回复200OK失败", e);
                    }
                    Element deviceIdElement = sipMsgInfo.getRootElement().element("DeviceID");
@@ -112,7 +114,7 @@
                    deviceAlarm.setAlarmMethod(getText(sipMsgInfo.getRootElement(), "AlarmMethod"));
                    String alarmTime = XmlUtil.getText(sipMsgInfo.getRootElement(), "AlarmTime");
                    if (alarmTime == null) {
                        return;
                        continue;
                    }
                    deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime));
                    String alarmDescription = getText(sipMsgInfo.getRootElement(), "AlarmDescription");
@@ -182,7 +184,7 @@
                            deviceAlarm.setAlarmType(getText(sipMsgInfo.getRootElement().element("Info"), "AlarmType"));
                        }
                    }
                    logger.info("[收到报警通知]内容:{}", JSONObject.toJSON(deviceAlarm));
                    if ("7".equals(deviceAlarm.getAlarmMethod()) ) {
                        // 发送给平台的报警信息。 发送redis通知
                        AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage();
@@ -190,7 +192,7 @@
                        alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription());
                        alarmChannelMessage.setGbId(channelId);
                        redisCatchStorage.sendAlarmMsg(alarmChannelMessage);
                        return;
                        continue;
                    }
                    logger.debug("存储报警信息、报警分类");
@@ -198,7 +200,7 @@
                    if (sipConfig.isAlarm()) {
                        deviceAlarmService.add(deviceAlarm);
                    }
                    logger.info("[收到报警通知]内容:{}", JSONObject.toJSON(deviceAlarm));
                    if (redisCatchStorage.deviceIsOnline(sipMsgInfo.getDevice().getDeviceId())) {
                        publisher.deviceAlarmEventPublish(deviceAlarm);
                    }
@@ -215,13 +217,9 @@
        logger.info("收到来自平台[{}]的报警通知", parentPlatform.getServerGBId());
        // 回复200 OK
        try {
            responseAck(getServerTransaction(evt), Response.OK);
        } catch (SipException e) {
            throw new RuntimeException(e);
        } catch (InvalidArgumentException e) {
            throw new RuntimeException(e);
        } catch (ParseException e) {
            throw new RuntimeException(e);
            responseAck((SIPRequest) evt.getRequest(), Response.OK);
        } catch (SipException | InvalidArgumentException | ParseException e) {
            logger.error("[命令发送失败] 国标级联 报警通知回复: {}", e.getMessage());
        }
        Element deviceIdElement = rootElement.element("DeviceID");
        String channelId = deviceIdElement.getText().toString();