commit
309a303e2f
@ -38,4 +38,10 @@ public class ExportCenterController {
|
||||
public void download(@PathVariable String id, HttpServletResponse response) throws Exception {
|
||||
exportCenterService.download(id, response);
|
||||
}
|
||||
|
||||
@PostMapping("/retry/{id}")
|
||||
public void retry(@PathVariable String id){
|
||||
exportCenterService.retry(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -117,11 +117,16 @@ public class ExportCenterService {
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
//文件名称
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + exportTask.getFileName());
|
||||
|
||||
XSSFWorkbook wb = new XSSFWorkbook(exportData_path + id + "/" + exportTask.getFileName());
|
||||
wb.write(outputStream);
|
||||
InputStream fileInputStream = new FileInputStream(exportData_path + id + "/" + exportTask.getFileName());
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
fileInputStream.close();
|
||||
response.flushBuffer();
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
@ -135,6 +140,23 @@ public class ExportCenterService {
|
||||
});
|
||||
}
|
||||
|
||||
public void retry(String id){
|
||||
ExportTask exportTask = exportTaskMapper.selectByPrimaryKey(id);
|
||||
exportTask.setExportStatus("PENDING");
|
||||
exportTask.setExportPogress("0");
|
||||
exportTask.setExportMachineName(hostName());
|
||||
exportTask.setExportTime(System.currentTimeMillis());
|
||||
exportTaskMapper.updateByPrimaryKey(exportTask);
|
||||
FileUtil.deleteDirectoryRecursively(exportData_path + id);
|
||||
if(exportTask.getExportFromType().equalsIgnoreCase("dataset")){
|
||||
DataSetExportRequest request = new Gson().fromJson(exportTask.getParams(), DataSetExportRequest.class);
|
||||
startDatasetTask(exportTask, request);
|
||||
}
|
||||
if(exportTask.getExportFromType().equalsIgnoreCase("chart")){
|
||||
PanelViewDetailsRequest request = new Gson().fromJson(exportTask.getParams(), PanelViewDetailsRequest.class);
|
||||
startViewTask(exportTask, request);
|
||||
}
|
||||
}
|
||||
public List<ExportTaskDTO> exportTasks(String status) {
|
||||
if (!STATUS.contains(status)) {
|
||||
DataEaseException.throwException("Invalid status: " + status);
|
||||
@ -161,7 +183,6 @@ public class ExportCenterService {
|
||||
|
||||
private void setExportFromName(ExportTaskDTO exportTaskDTO) {
|
||||
if (exportTaskDTO.getExportFromType().equalsIgnoreCase("chart")) {
|
||||
|
||||
exportTaskDTO.setExportFromName(panelGroupService.getAbsPath(exportTaskDTO.getExportFrom()));
|
||||
}
|
||||
if (exportTaskDTO.getExportFromType().equalsIgnoreCase("dataset")) {
|
||||
@ -440,6 +461,8 @@ public class ExportCenterService {
|
||||
|
||||
exportTask.setExportPogress("100");
|
||||
exportTask.setExportStatus("SUCCESS");
|
||||
|
||||
setFileSize(dataPath + "/" + dataPath + "/" + request.getViewName() + ".xlsx", exportTask);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
exportTask.setExportStatus("FAILED");
|
||||
@ -647,6 +670,7 @@ public class ExportCenterService {
|
||||
}
|
||||
exportTask.setExportPogress("100");
|
||||
exportTask.setExportStatus("SUCCESS");
|
||||
setFileSize(dataPath + "/" + request.getFilename() + ".xlsx", exportTask);
|
||||
} catch (Exception e) {
|
||||
exportTask.setExportStatus("FAILED");
|
||||
} finally {
|
||||
@ -655,6 +679,27 @@ public class ExportCenterService {
|
||||
});
|
||||
}
|
||||
|
||||
private void setFileSize(String filePath, ExportTask exportTask ){
|
||||
File file = new File(filePath);
|
||||
long length = file.length();
|
||||
String unit = "Mb";
|
||||
Double size = 0.0;
|
||||
if((double) length/1024/1024 > 1){
|
||||
if((double) length/1024/1024 > 1){
|
||||
unit = "Gb";
|
||||
size = Double.valueOf(String.format("%.2f", (double) length/1024/1024/1024));
|
||||
}else {
|
||||
size = Double.valueOf(String.format("%.2f", (double) length/1024/1024));
|
||||
}
|
||||
|
||||
}else {
|
||||
unit = "Kb";
|
||||
size = Double.valueOf(String.format("%.2f", (double) length/1024));
|
||||
}
|
||||
exportTask.setFileSize(size);
|
||||
exportTask.setFileSizeUnit(unit);
|
||||
}
|
||||
|
||||
public Boolean checkEngineTableIsExists(String id) throws Exception {
|
||||
Datasource engine = engineService.getDeEngine();
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
|
||||
@ -1179,8 +1224,6 @@ public class ExportCenterService {
|
||||
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ CREATE TABLE `export_task` (
|
||||
`user_id` bigint(20) NOT NULL ,
|
||||
`file_name` varchar(2048) DEFAULT NULL,
|
||||
`file_size` DOUBLE DEFAULT NULL,
|
||||
`file_size_unit` varchar(255) DEFAULT NULL,
|
||||
`export_from` varchar(255) DEFAULT NULL,
|
||||
`export_status` varchar(255) DEFAULT NULL,
|
||||
`export_from_type` varchar(255) DEFAULT NULL,
|
||||
|
||||
@ -33,6 +33,13 @@
|
||||
<svg-icon style="font-size: 24px;" icon-class="icon_file-excel_colorful"> </svg-icon>
|
||||
<span style="margin-left: 8px">{{ scope.row.fileName }}</span>
|
||||
</div>
|
||||
<div v-show="activeName==='FAILED'">
|
||||
<span style="margin-left: 8px" :style="{ color: 'red' }">导出失败</span>
|
||||
<hr class="red-line" />
|
||||
</div>
|
||||
<div v-show="scope.row.exportStatus==='SUCCESS'">
|
||||
<span style="margin-left: 8px">{{scope.row.fileSize}}{{scope.row.fileSizeUnit}}</span>
|
||||
</div>
|
||||
<el-progress v-show="activeName==='IN_PROGRESS'" :percentage="scope.row.exportPogress"></el-progress>
|
||||
</template>
|
||||
|
||||
@ -59,8 +66,15 @@
|
||||
/>
|
||||
</div>
|
||||
</el-button>
|
||||
<el-button type="text" size="mini" @click="deleteField(scope.row)"
|
||||
>{{ $t("dataset.delete") }}
|
||||
<el-button v-if="scope.row.exportStatus === 'FAILED'" type="text" size="mini" @click="retry(scope.row)">
|
||||
<div class="download-export">
|
||||
<i class="el-icon-refresh-right"></i>
|
||||
</div>
|
||||
</el-button>
|
||||
<el-button type="text" size="mini" @click="deleteField(scope.row)">
|
||||
<div class="download-export">
|
||||
<i class="el-icon-delete"></i>
|
||||
</div>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -85,7 +99,7 @@ export default {
|
||||
mixins: [msgCfm],
|
||||
data() {
|
||||
return {
|
||||
activeName: "IN_PROGRESS",
|
||||
activeName: "ALL",
|
||||
multipleSelection: [],
|
||||
errImg: require("@/assets/none-data.png"),
|
||||
tableData: [{ name: "附件名称" }],
|
||||
@ -113,6 +127,7 @@ export default {
|
||||
name: "ALL",
|
||||
},
|
||||
],
|
||||
loading : false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -124,15 +139,45 @@ export default {
|
||||
this.handleClick()
|
||||
this.timer = setInterval(() => {
|
||||
if(this.activeName === 'IN_PROGRESS'){
|
||||
this.handleClick()
|
||||
post(
|
||||
'/exportCenter/exportTasks/' + this.activeName,{}, true
|
||||
).then(
|
||||
(res) => {
|
||||
this.tabList.forEach( item => {
|
||||
if(item.name === 'ALL'){
|
||||
item.label = '全部' + '(' + res.data.length + ')'
|
||||
}
|
||||
if(item.name === 'IN_PROGRESS'){
|
||||
item.label = '导出中' + '(' + res.data.filter(task => task.exportStatus === 'IN_PROGRESS').length + ')'
|
||||
}
|
||||
if(item.name === 'SUCCESS'){
|
||||
item.label = '成功' + '(' + res.data.filter(task => task.exportStatus === 'SUCCESS').length + ')'
|
||||
}
|
||||
if(item.name === 'FAILED'){
|
||||
item.label = '失败' + '(' + res.data.filter(task => task.exportStatus === 'FAILED').length + ')'
|
||||
}
|
||||
if(item.name === 'PENDING'){
|
||||
item.label = '等待中' + '(' + res.data.filter(task => task.exportStatus === 'PENDING').length + ')'
|
||||
}
|
||||
})
|
||||
if(this.activeName === 'ALL'){
|
||||
this.tableData = res.data
|
||||
}else {
|
||||
this.tableData = res.data.filter(task => task.exportStatus === this.activeName)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}, 5000);
|
||||
},
|
||||
format(percentage) {
|
||||
return '';
|
||||
},
|
||||
handleClick() {
|
||||
request({
|
||||
url: '/exportCenter/exportTasks/' + this.activeName,
|
||||
method: 'post'
|
||||
}).then(
|
||||
this.tableData = []
|
||||
post(
|
||||
'/exportCenter/exportTasks/' + this.activeName,{}, true
|
||||
).then(
|
||||
(res) => {
|
||||
this.tabList.forEach( item => {
|
||||
if(item.name === 'ALL'){
|
||||
@ -156,7 +201,8 @@ export default {
|
||||
}else {
|
||||
this.tableData = res.data.filter(task => task.exportStatus === this.activeName)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
)
|
||||
},
|
||||
downloadClick(item) {
|
||||
@ -174,6 +220,16 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
retry(item) {
|
||||
post(
|
||||
'/exportCenter/retry/' + item.id,{},
|
||||
true
|
||||
).then(
|
||||
(res) => {
|
||||
this.handleClick()
|
||||
}
|
||||
)
|
||||
},
|
||||
deleteField(item) {
|
||||
request({
|
||||
url: '/exportCenter/delete/' + item.id,
|
||||
@ -197,10 +253,14 @@ export default {
|
||||
this.handlerConfirm(options);
|
||||
},
|
||||
delAll() {
|
||||
if(this.multipleSelection.length === 0 ){
|
||||
this.openMessageSuccess("请选择", 'error')
|
||||
return
|
||||
}
|
||||
post(
|
||||
'/exportCenter/delete',
|
||||
this.multipleSelection.map((ele) => ele.id),
|
||||
false
|
||||
true
|
||||
).then(
|
||||
(res) => {
|
||||
this.handleClick()
|
||||
@ -248,6 +308,11 @@ export default {
|
||||
th.el-table__cell.is-leaf {
|
||||
border-color: #1f232926;
|
||||
}
|
||||
|
||||
.red-line {
|
||||
border: 2px solid red;
|
||||
margin: 10px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -13,6 +13,8 @@ public class ExportTask implements Serializable {
|
||||
|
||||
private Double fileSize;
|
||||
|
||||
private String fileSizeUnit;
|
||||
|
||||
private String exportFrom;
|
||||
|
||||
private String exportStatus;
|
||||
|
||||
@ -364,6 +364,76 @@ public class ExportTaskExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitIsNull() {
|
||||
addCriterion("file_size_unit is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitIsNotNull() {
|
||||
addCriterion("file_size_unit is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitEqualTo(String value) {
|
||||
addCriterion("file_size_unit =", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitNotEqualTo(String value) {
|
||||
addCriterion("file_size_unit <>", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitGreaterThan(String value) {
|
||||
addCriterion("file_size_unit >", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("file_size_unit >=", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitLessThan(String value) {
|
||||
addCriterion("file_size_unit <", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitLessThanOrEqualTo(String value) {
|
||||
addCriterion("file_size_unit <=", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitLike(String value) {
|
||||
addCriterion("file_size_unit like", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitNotLike(String value) {
|
||||
addCriterion("file_size_unit not like", value, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitIn(List<String> values) {
|
||||
addCriterion("file_size_unit in", values, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitNotIn(List<String> values) {
|
||||
addCriterion("file_size_unit not in", values, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitBetween(String value1, String value2) {
|
||||
addCriterion("file_size_unit between", value1, value2, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFileSizeUnitNotBetween(String value1, String value2) {
|
||||
addCriterion("file_size_unit not between", value1, value2, "fileSizeUnit");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExportFromIsNull() {
|
||||
addCriterion("export_from is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
||||
<result column="file_name" jdbcType="VARCHAR" property="fileName" />
|
||||
<result column="file_size" jdbcType="DOUBLE" property="fileSize" />
|
||||
<result column="file_size_unit" jdbcType="VARCHAR" property="fileSizeUnit" />
|
||||
<result column="export_from" jdbcType="VARCHAR" property="exportFrom" />
|
||||
<result column="export_status" jdbcType="VARCHAR" property="exportStatus" />
|
||||
<result column="export_from_type" jdbcType="VARCHAR" property="exportFromType" />
|
||||
@ -75,7 +76,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, file_name, file_size, export_from, export_status, export_from_type,
|
||||
id, user_id, file_name, file_size, file_size_unit, export_from, export_status, export_from_type,
|
||||
export_time, export_pogress, export_machine_name
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
@ -131,13 +132,15 @@
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.dataease.plugins.common.base.domain.ExportTask">
|
||||
insert into export_task (id, user_id, file_name,
|
||||
file_size, export_from, export_status,
|
||||
export_from_type, export_time, export_pogress,
|
||||
export_machine_name, params)
|
||||
file_size, file_size_unit, export_from,
|
||||
export_status, export_from_type, export_time,
|
||||
export_pogress, export_machine_name, params
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}, #{fileName,jdbcType=VARCHAR},
|
||||
#{fileSize,jdbcType=DOUBLE}, #{exportFrom,jdbcType=VARCHAR}, #{exportStatus,jdbcType=VARCHAR},
|
||||
#{exportFromType,jdbcType=VARCHAR}, #{exportTime,jdbcType=BIGINT}, #{exportPogress,jdbcType=VARCHAR},
|
||||
#{exportMachineName,jdbcType=VARCHAR}, #{params,jdbcType=LONGVARCHAR})
|
||||
#{fileSize,jdbcType=DOUBLE}, #{fileSizeUnit,jdbcType=VARCHAR}, #{exportFrom,jdbcType=VARCHAR},
|
||||
#{exportStatus,jdbcType=VARCHAR}, #{exportFromType,jdbcType=VARCHAR}, #{exportTime,jdbcType=BIGINT},
|
||||
#{exportPogress,jdbcType=VARCHAR}, #{exportMachineName,jdbcType=VARCHAR}, #{params,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.plugins.common.base.domain.ExportTask">
|
||||
insert into export_task
|
||||
@ -154,6 +157,9 @@
|
||||
<if test="fileSize != null">
|
||||
file_size,
|
||||
</if>
|
||||
<if test="fileSizeUnit != null">
|
||||
file_size_unit,
|
||||
</if>
|
||||
<if test="exportFrom != null">
|
||||
export_from,
|
||||
</if>
|
||||
@ -189,6 +195,9 @@
|
||||
<if test="fileSize != null">
|
||||
#{fileSize,jdbcType=DOUBLE},
|
||||
</if>
|
||||
<if test="fileSizeUnit != null">
|
||||
#{fileSizeUnit,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="exportFrom != null">
|
||||
#{exportFrom,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -233,6 +242,9 @@
|
||||
<if test="record.fileSize != null">
|
||||
file_size = #{record.fileSize,jdbcType=DOUBLE},
|
||||
</if>
|
||||
<if test="record.fileSizeUnit != null">
|
||||
file_size_unit = #{record.fileSizeUnit,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.exportFrom != null">
|
||||
export_from = #{record.exportFrom,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -265,6 +277,7 @@
|
||||
user_id = #{record.userId,jdbcType=BIGINT},
|
||||
file_name = #{record.fileName,jdbcType=VARCHAR},
|
||||
file_size = #{record.fileSize,jdbcType=DOUBLE},
|
||||
file_size_unit = #{record.fileSizeUnit,jdbcType=VARCHAR},
|
||||
export_from = #{record.exportFrom,jdbcType=VARCHAR},
|
||||
export_status = #{record.exportStatus,jdbcType=VARCHAR},
|
||||
export_from_type = #{record.exportFromType,jdbcType=VARCHAR},
|
||||
@ -282,6 +295,7 @@
|
||||
user_id = #{record.userId,jdbcType=BIGINT},
|
||||
file_name = #{record.fileName,jdbcType=VARCHAR},
|
||||
file_size = #{record.fileSize,jdbcType=DOUBLE},
|
||||
file_size_unit = #{record.fileSizeUnit,jdbcType=VARCHAR},
|
||||
export_from = #{record.exportFrom,jdbcType=VARCHAR},
|
||||
export_status = #{record.exportStatus,jdbcType=VARCHAR},
|
||||
export_from_type = #{record.exportFromType,jdbcType=VARCHAR},
|
||||
@ -304,6 +318,9 @@
|
||||
<if test="fileSize != null">
|
||||
file_size = #{fileSize,jdbcType=DOUBLE},
|
||||
</if>
|
||||
<if test="fileSizeUnit != null">
|
||||
file_size_unit = #{fileSizeUnit,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="exportFrom != null">
|
||||
export_from = #{exportFrom,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -333,6 +350,7 @@
|
||||
set user_id = #{userId,jdbcType=BIGINT},
|
||||
file_name = #{fileName,jdbcType=VARCHAR},
|
||||
file_size = #{fileSize,jdbcType=DOUBLE},
|
||||
file_size_unit = #{fileSizeUnit,jdbcType=VARCHAR},
|
||||
export_from = #{exportFrom,jdbcType=VARCHAR},
|
||||
export_status = #{exportStatus,jdbcType=VARCHAR},
|
||||
export_from_type = #{exportFromType,jdbcType=VARCHAR},
|
||||
@ -347,6 +365,7 @@
|
||||
set user_id = #{userId,jdbcType=BIGINT},
|
||||
file_name = #{fileName,jdbcType=VARCHAR},
|
||||
file_size = #{fileSize,jdbcType=DOUBLE},
|
||||
file_size_unit = #{fileSizeUnit,jdbcType=VARCHAR},
|
||||
export_from = #{exportFrom,jdbcType=VARCHAR},
|
||||
export_status = #{exportStatus,jdbcType=VARCHAR},
|
||||
export_from_type = #{exportFromType,jdbcType=VARCHAR},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user