优化目录查询的WebUI逻辑

dev/多线程性能优化
648540858 2024-11-26 11:20:12 +08:00
parent b8139b63de
commit 4e165fe243
9 changed files with 33 additions and 59 deletions

View File

@ -1,14 +1,10 @@
package com.genersoft.iot.vmp.gb28181.bean;
import lombok.Data;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
/**
* @author lin
@ -19,7 +15,7 @@ public class CatalogData {
*
*/
private int sn;
private int total;
private Integer total;
private Instant time;
private Device device;
private String errorMsg;

View File

@ -1,51 +1,26 @@
package com.genersoft.iot.vmp.gb28181.bean;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
*
* @author lin
*/
@Data
@Schema(description = "摄像机同步状态")
public class SyncStatus {
@Schema(description = "总数")
private int total;
private Integer total;
@Schema(description = "当前更新多少")
private int current;
private Integer current;
@Schema(description = "错误描述")
private String errorMsg;
@Schema(description = "是否同步中")
private boolean syncIng;
private Boolean syncIng;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public int getCurrent() {
return current;
}
public void setCurrent(int current) {
this.current = current;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public boolean isSyncIng() {
return syncIng;
}
public void setSyncIng(boolean syncIng) {
this.syncIng = syncIng;
}
}

View File

@ -413,14 +413,16 @@ public class DeviceQuery {
public WVPResult<SyncStatus> getSyncStatus(@PathVariable String deviceId) {
SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
WVPResult<SyncStatus> wvpResult = new WVPResult<>();
if (channelSyncStatus == null) {
wvpResult.setCode(-1);
if (channelSyncStatus == null || channelSyncStatus.getTotal() == null) {
wvpResult.setCode(0);
wvpResult.setMsg("同步尚未开始");
}else {
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(channelSyncStatus);
if (channelSyncStatus.getErrorMsg() != null) {
if (channelSyncStatus.getErrorMsg() == null) {
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(channelSyncStatus);
}else {
wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg(channelSyncStatus.getErrorMsg());
}
}

View File

@ -330,6 +330,7 @@ public class DeviceServiceImpl implements IDeviceService {
try {
sipCommander.catalogQuery(device, sn, event -> {
String errorMsg = String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg);
log.info("[同步通道]失败,编号: {}, 错误码: {}, {}", device.getDeviceId(), event.statusCode, event.msg);
catalogResponseMessageHandler.setChannelSyncEnd(device.getDeviceId(), sn, errorMsg);
});
} catch (SipException | InvalidArgumentException | ParseException e) {

View File

@ -170,7 +170,7 @@ public class CatalogDataManager implements CommandLineRunner {
syncStatus.setCurrent(catalogData.getRedisKeysForChannel().size());
syncStatus.setTotal(catalogData.getTotal());
syncStatus.setErrorMsg(catalogData.getErrorMsg());
if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) {
if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready) || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) {
syncStatus.setSyncIng(false);
}else {
syncStatus.setSyncIng(true);

View File

@ -981,8 +981,6 @@ public class SIPCommander implements ISIPCommander {
catalogXml.append(" <DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
catalogXml.append("</Query>\r\n");
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);

View File

@ -230,16 +230,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
gbChannelService.add(streamProxy.buildCommonGBChannel());
}
}
// 判断是否需要重启代理
if (!streamProxyInDb.getApp().equals(streamProxy.getApp())
|| !streamProxyInDb.getStream().equals(streamProxy.getStream())
|| (streamProxyInDb.getMediaServerId() != null && streamProxyInDb.getMediaServerId().equals(streamProxy.getMediaServerId()))
|| (streamProxyInDb.getMediaServerId() == null && streamProxy.getMediaServerId() != null)
) {
// 变化则重启代理
playService.stopProxy(streamProxyInDb);
playService.startProxy(streamProxy);
}
return true;
}

View File

@ -246,6 +246,15 @@ export default {
type: 'error'
});
} else {
if (res.data.data && res.data.data.errorMsg) {
that.$message({
showClose: true,
message: res.data.data.errorMsg,
type: 'error'
});
return;
}
this.$refs.syncChannelProgress.openDialog(itemData.deviceId, ()=>{
console.log(32322)
this.initData()

View File

@ -66,7 +66,7 @@ export default {
if (res.data.data != null) {
if (res.data.data.syncIng) {
if (res.data.data.total == 0) {
if (res.data.data.total === 0) {
this.msg = `等待同步中`;
this.timmer = setTimeout(this.getProgress, 300)
}else {
@ -89,6 +89,9 @@ export default {
}, 3000)
}
}
}else {
this.msg = `同步尚未开始`;
this.timmer = setTimeout(this.getProgress, 300)
}
}else {
if (this.syncFlag) {