648540858
3 years ago
11 changed files with 286 additions and 8 deletions
@ -0,0 +1,50 @@ |
|||
package com.genersoft.iot.vmp.service.impl; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
|||
import com.genersoft.iot.vmp.service.IStreamPushService; |
|||
import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> { |
|||
|
|||
private IStreamPushService pushService; |
|||
private String defaultMediaServerId; |
|||
private List<StreamPushItem> streamPushItems = new ArrayList<>(); |
|||
|
|||
public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId) { |
|||
this.pushService = pushService; |
|||
this.defaultMediaServerId = defaultMediaServerId; |
|||
} |
|||
|
|||
@Override |
|||
public void invoke(StreamPushExcelDto streamPushExcelDto, AnalysisContext analysisContext) { |
|||
StreamPushItem streamPushItem = new StreamPushItem(); |
|||
streamPushItem.setApp(streamPushExcelDto.getApp()); |
|||
streamPushItem.setStream(streamPushExcelDto.getStream()); |
|||
streamPushItem.setGbId(streamPushExcelDto.getGbId()); |
|||
streamPushItem.setStatus(false); |
|||
streamPushItem.setStreamType("push"); |
|||
streamPushItem.setCreateStamp(System.currentTimeMillis()); |
|||
streamPushItem.setMediaServerId(defaultMediaServerId); |
|||
streamPushItem.setName(streamPushExcelDto.getName()); |
|||
streamPushItem.setOriginType(2); |
|||
streamPushItem.setOriginTypeStr("rtsp_push"); |
|||
streamPushItem.setTotalReaderCount("0"); |
|||
streamPushItems.add(streamPushItem); |
|||
if (streamPushItems.size() > 300) { |
|||
pushService.batchAdd(streamPushItems); |
|||
// 存储完成清理 list
|
|||
streamPushItems.clear(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
|||
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
|
|||
pushService.batchAdd(streamPushItems); |
|||
} |
|||
} |
@ -0,0 +1,50 @@ |
|||
package com.genersoft.iot.vmp.vmanager.bean; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
|
|||
public class StreamPushExcelDto { |
|||
|
|||
@ExcelProperty("名称") |
|||
private String name; |
|||
|
|||
@ExcelProperty("应用名") |
|||
private String app; |
|||
|
|||
@ExcelProperty("流ID") |
|||
private String stream; |
|||
|
|||
@ExcelProperty("国标ID") |
|||
private String gbId; |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getApp() { |
|||
return app; |
|||
} |
|||
|
|||
public void setApp(String app) { |
|||
this.app = app; |
|||
} |
|||
|
|||
public String getStream() { |
|||
return stream; |
|||
} |
|||
|
|||
public void setStream(String stream) { |
|||
this.stream = stream; |
|||
} |
|||
|
|||
public String getGbId() { |
|||
return gbId; |
|||
} |
|||
|
|||
public void setGbId(String gbId) { |
|||
this.gbId = gbId; |
|||
} |
|||
} |
@ -0,0 +1,84 @@ |
|||
<template> |
|||
<div id="importChannel" v-loading="isLoging"> |
|||
<el-dialog |
|||
title="导入通道数据" |
|||
width="30rem" |
|||
top="2rem" |
|||
:append-to-body="true" |
|||
:close-on-click-modal="false" |
|||
:visible.sync="showDialog" |
|||
:destroy-on-close="true" |
|||
@close="close()" |
|||
> |
|||
<div> |
|||
<el-upload |
|||
class="upload-box" |
|||
drag |
|||
action="debug/api/push/upload" |
|||
name="file" |
|||
> |
|||
<i class="el-icon-upload"></i> |
|||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
|||
<div class="el-upload__tip" slot="tip">只能上传 csv / xls / xlsx 文件</div> |
|||
</el-upload> |
|||
</div> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
|
|||
export default { |
|||
name: "importChannel", |
|||
computed: {}, |
|||
created() {}, |
|||
data() { |
|||
return { |
|||
submitCallback: null, |
|||
showDialog: false, |
|||
isLoging: false, |
|||
isEdit: false, |
|||
}; |
|||
}, |
|||
methods: { |
|||
openDialog: function (callback) { |
|||
this.showDialog = true; |
|||
this.submitCallback = callback; |
|||
}, |
|||
onSubmit: function () { |
|||
console.log("onSubmit"); |
|||
console.log(this.form); |
|||
this.$axios({ |
|||
method:"post", |
|||
url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`, |
|||
data: this.form |
|||
}) |
|||
.then((res)=> { |
|||
if (res.data.code === 0) { |
|||
console.log("添加/修改成功") |
|||
if (this.submitCallback)this.submitCallback() |
|||
}else { |
|||
this.$message({ |
|||
showClose: true, |
|||
message: res.data.msg, |
|||
type: "error", |
|||
}); |
|||
} |
|||
this.close(); |
|||
}) |
|||
.catch((error)=> { |
|||
console.log(error); |
|||
}); |
|||
}, |
|||
close: function () { |
|||
this.showDialog = false; |
|||
this.$refs.form.resetFields(); |
|||
}, |
|||
}, |
|||
}; |
|||
</script> |
|||
<style> |
|||
.upload-box{ |
|||
text-align: center; |
|||
} |
|||
</style> |
Loading…
Reference in new issue