修复历史文件拉取异常

This commit is contained in:
zxb 2023-08-21 16:55:00 +08:00
parent af97ee8729
commit a623e7a387
2 changed files with 20 additions and 24 deletions

View File

@ -9,12 +9,11 @@ import gov.nist.javax.sip.stack.SIPTransactionStack;
import javax.sip.SipStack;
import java.util.Properties;
@SuppressWarnings("unused")
public class ServerLoggerImpl implements ServerLogger {
private boolean showLog = true;
private SIPTransactionStack sipStack;
protected StackLogger stackLogger;
@Override
@ -27,12 +26,8 @@ public class ServerLoggerImpl implements ServerLogger {
if (!showLog) {
return;
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(sender? "发送:目标--->" + from:"接收:来自--->" + to)
.append("\r\n")
.append(message);
this.stackLogger.logInfo(stringBuilder.toString());
String log = (sender ? "发送: 目标 => " + to : "接收: 来自 => " + from) + "\r\n" + message;
this.stackLogger.logInfo(log);
}
@Override
@ -40,11 +35,8 @@ public class ServerLoggerImpl implements ServerLogger {
if (!showLog) {
return;
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(sender? "发送: 目标->" + from :"接收:来自->" + to)
.append("\r\n")
.append(message);
this.stackLogger.logInfo(stringBuilder.toString());
String log = (sender ? "发送: 目标 => " + to : "接收: 来自 => " + from) + "\r\n" + message;
this.stackLogger.logInfo(log);
}
@Override
@ -52,11 +44,8 @@ public class ServerLoggerImpl implements ServerLogger {
if (!showLog) {
return;
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(sender? "发送: 目标->" + from :"接收:来自->" + to)
.append("\r\n")
.append(message);
this.stackLogger.logInfo(stringBuilder.toString());
String log = (sender ? "发送: 目标 => " + to : "接收: 来自 => " + from) + "\r\n" + message;
this.stackLogger.logInfo(log);
}
@Override
@ -84,8 +73,7 @@ public class ServerLoggerImpl implements ServerLogger {
return;
}
if(sipStack instanceof SIPTransactionStack) {
this.sipStack = (SIPTransactionStack)sipStack;
this.stackLogger = CommonLogger.getLogger(SIPTransactionStack.class);
this.stackLogger = CommonLogger.getLogger(sipStack.getClass());
}
}
}

View File

@ -6,6 +6,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import java.util.Map;
@ -22,7 +24,7 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class);
private Map<String, RecordEndEventHandler> handlerMap = new ConcurrentHashMap<>();
private final static Map<String, RecordEndEventHandler> handlerMap = new ConcurrentHashMap<>();
public interface RecordEndEventHandler{
void handler(RecordInfo recordInfo);
}
@ -33,13 +35,17 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
String channelId = event.getRecordInfo().getChannelId();
int count = event.getRecordInfo().getCount();
int sumNum = event.getRecordInfo().getSumNum();
logger.info("录像查询完成事件触发deviceId{}, channelId: {}, 录像数量{}/{}条", event.getRecordInfo().getDeviceId(),
logger.info("录像查询完成事件触发deviceId{}, channelId: {}, 录像数量{}/{}条",
event.getRecordInfo().getDeviceId(),
event.getRecordInfo().getChannelId(), count,sumNum);
logger.debug("handlerMap.size => {}", handlerMap.size());
if (handlerMap.size() > 0) {
logger.debug("handlerMap.keys => {}", handlerMap.keySet());
RecordEndEventHandler handler = handlerMap.get(deviceId + channelId);
if (handler !=null){
logger.debug("handler => {}", handler);
if (handler != null){
handler.handler(event.getRecordInfo());
if (count ==sumNum){
if (count >= sumNum){
handlerMap.remove(deviceId + channelId);
}
}
@ -53,6 +59,7 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
* @param recordEndEventHandler
*/
public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) {
logger.debug("RecordEndEventListener addEndEventHandler => deviceId: {}, channelId: {}", device,channelId);
handlerMap.put(device + channelId, recordEndEventHandler);
}
/**
@ -61,6 +68,7 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
* @param channelId
*/
public void delEndEventHandler(String device, String channelId) {
logger.debug("RecordEndEventListener delEndEventHandler => deviceId: {}, channelId: {}", device,channelId);
handlerMap.remove(device + channelId);
}