108 changed files with 1910 additions and 582 deletions
@ -0,0 +1,129 @@ |
|||||
|
<template> |
||||
|
<q-dialog ref="seamlessDialogRef" v-model="show" seamless position="top" @before-show="onShow" @hide="onHide"> |
||||
|
<q-card style="width: 600px"> |
||||
|
<q-toolbar class="bg-secondary text-white" style="height: 20px"> |
||||
|
<q-toolbar-title class="text-subtitle2">{{ $t('asyncTasks') }}</q-toolbar-title> |
||||
|
<q-space /> |
||||
|
<q-btn flat round icon="delete_outline" size="sm" @click="clean"> |
||||
|
<q-tooltip :delay="1000">{{ $t('clean') }}</q-tooltip> |
||||
|
</q-btn> |
||||
|
<q-btn v-close-popup flat round icon="close" size="sm"> |
||||
|
<q-tooltip :delay="1000">{{ $t('close') }}</q-tooltip> |
||||
|
</q-btn> |
||||
|
</q-toolbar> |
||||
|
|
||||
|
<q-card-section v-for="task in tasksRef" :key="task.id" class="row items-center no-wrap" style="padding: 4px 10px 4px 10px"> |
||||
|
<q-icon v-if="task.status === 'COMPLETED'" name="check_circle_outline" size="26px" color="green" class="cursor-pointer"> |
||||
|
<q-tooltip :delay="1000">{{ $t('io.sc.platform.system.enums.TaskStatus.COMPLETED') }}</q-tooltip> |
||||
|
</q-icon> |
||||
|
<q-icon v-if="task.status === 'CANCELED'" name="pause_circle_outline" size="26px" color="orange" class="cursor-pointer"> |
||||
|
<q-tooltip :delay="1000">{{ $t('io.sc.platform.system.enums.TaskStatus.CANCELED') }}</q-tooltip> |
||||
|
</q-icon> |
||||
|
<q-icon v-if="task.status === 'ERROR'" name="error_outline" size="26px" color="red" class="cursor-pointer"> |
||||
|
<q-tooltip :delay="1000"> |
||||
|
{{ $t('io.sc.platform.system.enums.TaskStatus.ERROR') + '!' }} <br /> |
||||
|
{{ task.exception ? $t('task.exception') : task.exceptionMessage }} <br /> |
||||
|
</q-tooltip> |
||||
|
</q-icon> |
||||
|
<div> |
||||
|
<q-knob |
||||
|
v-if="task.status === 'STARTED'" |
||||
|
:model-value="(100 * task.currentWeight) / task.totalWeight" |
||||
|
show-value |
||||
|
size="26px" |
||||
|
:thickness="0.3" |
||||
|
color="green" |
||||
|
track-color="grey-5" |
||||
|
> |
||||
|
</q-knob> |
||||
|
<q-tooltip :delay="1000">{{ $t('running') + ' : ' + (100 * task.currentWeight) / task.totalWeight + ' %' }}</q-tooltip> |
||||
|
</div> |
||||
|
<div class="pl-2"> |
||||
|
<a v-if="task.status === 'COMPLETED'" href="javascript:void(0);" class="text-primary underline" @click="handle(task)"> |
||||
|
<div class="truncate" style="width: 350px; max-width: 350px">{{ task.name }}</div> |
||||
|
</a> |
||||
|
<div v-if="task.status !== 'COMPLETED'" class="truncate" style="width: 350px; max-width: 350px">{{ task.name }}</div> |
||||
|
<div v-if="task.status === 'STARTED'" class="truncate" style="width: 350px; max-width: 350px; font-size: 0.8em">{{ task.message }}</div> |
||||
|
<div v-if="task.status === 'ERROR'" class="truncate text-red-500" style="width: 350px; max-width: 350px; font-size: 0.8em"> |
||||
|
{{ task.exception ? $t(task.exception) : task.exceptionMessage }} |
||||
|
</div> |
||||
|
</div> |
||||
|
<q-space /> |
||||
|
<!-- 创建日期 --> |
||||
|
<div class="truncate" style="width: 70px; max-width: 70px; font-size: 0.8em"> |
||||
|
{{ task.createDateAndNowDiff + $t(task.createDateAndNowDiffUnit) + $t('before') }} |
||||
|
<q-tooltip :delay="1000">{{ task.createDate }}</q-tooltip> |
||||
|
</div> |
||||
|
|
||||
|
<q-btn v-if="task.status === 'STARTED'" flat round icon="pause" color="primary" size="sm"> |
||||
|
<q-tooltip :delay="1000">{{ $t('cancel') }}</q-tooltip> |
||||
|
</q-btn> |
||||
|
|
||||
|
<q-btn v-if="task.status !== 'STARTED'" flat round icon="delete_outline" color="primary" size="sm" @click="remove(task)"> |
||||
|
<q-tooltip :delay="1000">{{ $t('remove') }}</q-tooltip> |
||||
|
</q-btn> |
||||
|
</q-card-section> |
||||
|
</q-card> |
||||
|
</q-dialog> |
||||
|
</template> |
||||
|
<script setup lang="ts"> |
||||
|
import { ref } from 'vue'; |
||||
|
import { useInterval } from 'quasar'; |
||||
|
import { $t, axios, Environment, DialogManager, Downloader } from '@/platform'; |
||||
|
|
||||
|
const { registerInterval, removeInterval } = useInterval(); |
||||
|
const seamlessDialogRef = ref(); |
||||
|
const show = ref(false); |
||||
|
const tasksRef = ref([]); |
||||
|
|
||||
|
const open = () => { |
||||
|
show.value = true; |
||||
|
}; |
||||
|
|
||||
|
const close = () => { |
||||
|
seamlessDialogRef.value.hide(); |
||||
|
}; |
||||
|
|
||||
|
const onShow = () => { |
||||
|
refresh(); |
||||
|
registerInterval(refresh, 2000); |
||||
|
}; |
||||
|
|
||||
|
const onHide = () => { |
||||
|
removeInterval(); |
||||
|
}; |
||||
|
|
||||
|
const clean = () => { |
||||
|
DialogManager.confirm($t('cleanAsyncTasksTip'), () => { |
||||
|
axios.post(Environment.apiContextPath('/api/system/task/cleanMyAsyncTaskList')).then((response) => { |
||||
|
refresh(); |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const remove = (task) => { |
||||
|
DialogManager.confirm($t('removeAsyncTaskTip'), () => { |
||||
|
axios.post(Environment.apiContextPath('/api/system/task/removeAsyncTask/' + task.id)).then((response) => { |
||||
|
refresh(); |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const refresh = () => { |
||||
|
console.log('refresh'); |
||||
|
axios.get(Environment.apiContextPath('/api/system/task?page=1&size=10&pageable=true&sortBy=-createDate')).then((response) => { |
||||
|
tasksRef.value = response.data.content; |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const handle = (task: any) => { |
||||
|
if (task.type === 'EXPORT') { |
||||
|
Downloader.get(Environment.apiContextPath(task.exportResourceUrl)); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
defineExpose({ |
||||
|
open, |
||||
|
close, |
||||
|
}); |
||||
|
</script> |
@ -0,0 +1,77 @@ |
|||||
|
package io.sc.platform.orm.service.support; |
||||
|
|
||||
|
import io.sc.platform.orm.service.DaoService; |
||||
|
import io.sc.platform.orm.task.ExportTask; |
||||
|
import io.sc.platform.orm.task.TaskStatus; |
||||
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
||||
|
import org.jxls.common.Context; |
||||
|
import org.jxls.util.JxlsHelper; |
||||
|
|
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.FileOutputStream; |
||||
|
import java.io.InputStream; |
||||
|
|
||||
|
public class ExportExcelThread extends Thread { |
||||
|
protected ExportTask task; |
||||
|
protected DaoService daoService; |
||||
|
protected QueryParameter queryParameter; |
||||
|
|
||||
|
public ExportExcelThread(ExportTask task, DaoService daoService,QueryParameter queryParameter){ |
||||
|
this.task =task; |
||||
|
this.daoService =daoService; |
||||
|
this.queryParameter =queryParameter; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void run() { |
||||
|
try { |
||||
|
//获取模版
|
||||
|
byte[] templateBytes = daoService.getTemplateBytes(daoService.getExportTemplateConfigure()); |
||||
|
//导出
|
||||
|
String outputFilePath = task.getOutputPath(); |
||||
|
Context context = new Context(); |
||||
|
context.putVar("list", daoService.list(queryParameter)); |
||||
|
changeCurrentWeight(task.getTotalWeight()/2); |
||||
|
try ( |
||||
|
InputStream inputStream = new ByteArrayInputStream(templateBytes); |
||||
|
FileOutputStream outputStream = new FileOutputStream(outputFilePath); |
||||
|
) { |
||||
|
JxlsHelper.getInstance().setEvaluateFormulas(true).processTemplate(inputStream, outputStream, context); |
||||
|
} |
||||
|
|
||||
|
//存储到存储服务中
|
||||
|
daoService.getStorageService().add(outputFilePath, outputFilePath); |
||||
|
complete(); |
||||
|
} catch (Exception e) { |
||||
|
error(e.getClass().getName(),e.getMessage(), ExceptionUtils.getStackTrace(e)); |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void startExportTask(){ |
||||
|
String id =daoService.getTaskService().create(task); |
||||
|
task.setId(id); |
||||
|
} |
||||
|
|
||||
|
public void create(){ |
||||
|
daoService.getTaskService().create(task); |
||||
|
} |
||||
|
public void changeStatus(TaskStatus status){ |
||||
|
daoService.getTaskService().changeStatus(task.getId(),status); |
||||
|
} |
||||
|
public void changeCurrentWeight(long currentWeight){ |
||||
|
daoService.getTaskService().changeCurrentWeight(task.getId(),currentWeight); |
||||
|
} |
||||
|
public void changeMessage(String message){ |
||||
|
daoService.getTaskService().changeMessage(task.getId(),message); |
||||
|
} |
||||
|
public void error(String exception,String exceptionMessage,String exceptionStackTrace){ |
||||
|
daoService.getTaskService().error(task.getId(),exception,exceptionMessage,exceptionStackTrace); |
||||
|
} |
||||
|
public void complete(){ |
||||
|
daoService.getTaskService().complete(task.getId()); |
||||
|
} |
||||
|
public boolean isCanceled(){ |
||||
|
return daoService.getTaskService().isCanceled(task.getId()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package io.sc.platform.orm.storage.service; |
||||
|
|
||||
|
import java.io.OutputStream; |
||||
|
|
||||
|
public interface StorageService { |
||||
|
public void add(String path, String sourcePath) throws Exception ; |
||||
|
public void remove(String path) throws Exception ; |
||||
|
public void update(String path,String sourcePath) throws Exception ; |
||||
|
public void write(String path,String targetPath) throws Exception ; |
||||
|
} |
@ -0,0 +1,107 @@ |
|||||
|
package io.sc.platform.orm.storage.service.impl; |
||||
|
|
||||
|
import io.sc.platform.orm.storage.service.StorageService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.jdbc.core.support.AbstractLobCreatingPreparedStatementCallback; |
||||
|
import org.springframework.jdbc.core.support.AbstractLobStreamingResultSetExtractor; |
||||
|
import org.springframework.jdbc.support.lob.DefaultLobHandler; |
||||
|
import org.springframework.jdbc.support.lob.LobCreator; |
||||
|
import org.springframework.jdbc.support.lob.LobHandler; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.util.FileCopyUtils; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.io.FileInputStream; |
||||
|
import java.io.FileOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.ResultSet; |
||||
|
import java.sql.SQLException; |
||||
|
import java.util.Map; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
@Service("io.sc.platform.orm.storage.service.impl.StorageServiceImpl") |
||||
|
public class StorageServiceImpl implements StorageService { |
||||
|
@Autowired private JdbcTemplate jdbcTemplate; |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void add(String path, String sourcePath) throws Exception { |
||||
|
if(!StringUtils.hasText(path) || !StringUtils.hasText(sourcePath)){ |
||||
|
return; |
||||
|
} |
||||
|
if(!storageTypeIsDatabase()){ |
||||
|
return; |
||||
|
} |
||||
|
FileInputStream inputStream =new FileInputStream(sourcePath); |
||||
|
LobHandler lobHandler = new DefaultLobHandler(); |
||||
|
jdbcTemplate.execute("insert into SYS_STORAGE(ID_,PATH_,BYTES_) values (?,?,?)",new AbstractLobCreatingPreparedStatementCallback(lobHandler){ |
||||
|
@Override |
||||
|
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException, DataAccessException { |
||||
|
ps.setString(1, UUID.randomUUID().toString()); |
||||
|
ps.setString(2,path); |
||||
|
ps.setBlob(3,inputStream); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void remove(String path) throws Exception { |
||||
|
if(!StringUtils.hasText(path)){ |
||||
|
return; |
||||
|
} |
||||
|
if(!storageTypeIsDatabase()){ |
||||
|
return; |
||||
|
} |
||||
|
jdbcTemplate.update("delete from SYS_STORAGE where PATH_=?",path); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void update(String path, String sourcePath) throws Exception { |
||||
|
if(!StringUtils.hasText(path) || !StringUtils.hasText(sourcePath)){ |
||||
|
return; |
||||
|
} |
||||
|
if(!storageTypeIsDatabase()){ |
||||
|
return; |
||||
|
} |
||||
|
FileInputStream inputStream =new FileInputStream(sourcePath); |
||||
|
LobHandler lobHandler = new DefaultLobHandler(); |
||||
|
jdbcTemplate.execute("update SYS_STORAGE set BYTES_=? where PATH_=?",new AbstractLobCreatingPreparedStatementCallback(lobHandler){ |
||||
|
@Override |
||||
|
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException, DataAccessException { |
||||
|
ps.setString(2,path); |
||||
|
ps.setBlob(1,inputStream); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void write(String path, String targetPath) throws Exception { |
||||
|
if(!StringUtils.hasText(path)){ |
||||
|
return; |
||||
|
} |
||||
|
if(!storageTypeIsDatabase()){ |
||||
|
return; |
||||
|
} |
||||
|
jdbcTemplate.query("select BYTES_ from SYS_STORAGE where PATH_=?",new Object[]{path},new AbstractLobStreamingResultSetExtractor(){ |
||||
|
@Override |
||||
|
protected void streamData(ResultSet rs) throws SQLException, IOException, DataAccessException { |
||||
|
LobHandler lobHandler = new DefaultLobHandler(); |
||||
|
FileCopyUtils.copy(lobHandler.getBlobAsBinaryStream(rs, 1), new FileOutputStream(targetPath)); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private boolean storageTypeIsDatabase() { |
||||
|
Map<String,Object> row =jdbcTemplate.queryForMap("select VALUE_ from SYS_PARAMETER where CODE_=?","parameter.orm.exportExcel.persistence.type"); |
||||
|
if(row==null || row.isEmpty()){ |
||||
|
return false; |
||||
|
} |
||||
|
return "DATABASE".equals(row.get("VALUE_").toString()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package io.sc.platform.orm.task; |
||||
|
|
||||
|
public class ExportTask extends Task { |
||||
|
protected String outputPath; |
||||
|
protected String exportResourceName; |
||||
|
protected String exportResourceUrl; |
||||
|
|
||||
|
public String getOutputPath() { |
||||
|
return outputPath; |
||||
|
} |
||||
|
|
||||
|
public void setOutputPath(String outputPath) { |
||||
|
this.outputPath = outputPath; |
||||
|
} |
||||
|
|
||||
|
public String getExportResourceName() { |
||||
|
return exportResourceName; |
||||
|
} |
||||
|
|
||||
|
public void setExportResourceName(String exportResourceName) { |
||||
|
this.exportResourceName = exportResourceName; |
||||
|
} |
||||
|
|
||||
|
public String getExportResourceUrl() { |
||||
|
return exportResourceUrl; |
||||
|
} |
||||
|
|
||||
|
public void setExportResourceUrl(String exportResourceUrl) { |
||||
|
this.exportResourceUrl = exportResourceUrl; |
||||
|
} |
||||
|
} |
@ -0,0 +1,171 @@ |
|||||
|
package io.sc.platform.orm.task; |
||||
|
|
||||
|
import io.sc.platform.orm.api.vo.BaseVo; |
||||
|
import io.sc.platform.util.DateUtil; |
||||
|
import io.sc.platform.util.support.DateDiff; |
||||
|
|
||||
|
import java.time.temporal.ChronoUnit; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
public class Task extends BaseVo { |
||||
|
protected String id; |
||||
|
protected String name; |
||||
|
protected TaskExecuteMode executeMode; |
||||
|
protected TaskType type; |
||||
|
protected TaskStatus status; |
||||
|
protected String creator; |
||||
|
protected Date createDate; |
||||
|
protected Date completedDate; |
||||
|
protected Date canceledDate; |
||||
|
protected Long totalWeight; |
||||
|
protected Long currentWeight; |
||||
|
protected String message; |
||||
|
protected String exception; |
||||
|
protected String exceptionMessage; |
||||
|
protected String exceptionStackTrace; |
||||
|
|
||||
|
private long createDateAndNowDiff; |
||||
|
private ChronoUnit createDateAndNowDiffUnit; |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(String id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public TaskExecuteMode getExecuteMode() { |
||||
|
return executeMode; |
||||
|
} |
||||
|
|
||||
|
public void setExecuteMode(TaskExecuteMode executeMode) { |
||||
|
this.executeMode = executeMode; |
||||
|
} |
||||
|
|
||||
|
public TaskType getType() { |
||||
|
return type; |
||||
|
} |
||||
|
|
||||
|
public void setType(TaskType type) { |
||||
|
this.type = type; |
||||
|
} |
||||
|
|
||||
|
public TaskStatus getStatus() { |
||||
|
return status; |
||||
|
} |
||||
|
|
||||
|
public void setStatus(TaskStatus status) { |
||||
|
this.status = status; |
||||
|
} |
||||
|
|
||||
|
public String getCreator() { |
||||
|
return creator; |
||||
|
} |
||||
|
|
||||
|
public void setCreator(String creator) { |
||||
|
this.creator = creator; |
||||
|
} |
||||
|
|
||||
|
public Date getCreateDate() { |
||||
|
return createDate; |
||||
|
} |
||||
|
|
||||
|
public void setCreateDate(Date createDate) { |
||||
|
this.createDate = createDate; |
||||
|
if(this.createDate!=null) { |
||||
|
Date now = new Date(); |
||||
|
DateDiff dateDiff = DateUtil.dateDiff(this.createDate, now); |
||||
|
this.createDateAndNowDiff = dateDiff.getAmount(); |
||||
|
this.createDateAndNowDiffUnit = dateDiff.getUnit(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public Date getCompletedDate() { |
||||
|
return completedDate; |
||||
|
} |
||||
|
|
||||
|
public void setCompletedDate(Date completedDate) { |
||||
|
this.completedDate = completedDate; |
||||
|
} |
||||
|
|
||||
|
public Date getCanceledDate() { |
||||
|
return canceledDate; |
||||
|
} |
||||
|
|
||||
|
public void setCanceledDate(Date canceledDate) { |
||||
|
this.canceledDate = canceledDate; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalWeight() { |
||||
|
return totalWeight; |
||||
|
} |
||||
|
|
||||
|
public void setTotalWeight(Long totalWeight) { |
||||
|
this.totalWeight = totalWeight; |
||||
|
} |
||||
|
|
||||
|
public Long getCurrentWeight() { |
||||
|
return currentWeight; |
||||
|
} |
||||
|
|
||||
|
public void setCurrentWeight(Long currentWeight) { |
||||
|
this.currentWeight = currentWeight; |
||||
|
} |
||||
|
|
||||
|
public String getMessage() { |
||||
|
return message; |
||||
|
} |
||||
|
|
||||
|
public void setMessage(String message) { |
||||
|
this.message = message; |
||||
|
} |
||||
|
|
||||
|
public String getException() { |
||||
|
return exception; |
||||
|
} |
||||
|
|
||||
|
public void setException(String exception) { |
||||
|
this.exception = exception; |
||||
|
} |
||||
|
|
||||
|
public String getExceptionMessage() { |
||||
|
return exceptionMessage; |
||||
|
} |
||||
|
|
||||
|
public void setExceptionMessage(String exceptionMessage) { |
||||
|
this.exceptionMessage = exceptionMessage; |
||||
|
} |
||||
|
|
||||
|
public String getExceptionStackTrace() { |
||||
|
return exceptionStackTrace; |
||||
|
} |
||||
|
|
||||
|
public void setExceptionStackTrace(String exceptionStackTrace) { |
||||
|
this.exceptionStackTrace = exceptionStackTrace; |
||||
|
} |
||||
|
|
||||
|
public long getCreateDateAndNowDiff() { |
||||
|
return createDateAndNowDiff; |
||||
|
} |
||||
|
|
||||
|
public void setCreateDateAndNowDiff(long createDateAndNowDiff) { |
||||
|
this.createDateAndNowDiff = createDateAndNowDiff; |
||||
|
} |
||||
|
|
||||
|
public ChronoUnit getCreateDateAndNowDiffUnit() { |
||||
|
return createDateAndNowDiffUnit; |
||||
|
} |
||||
|
|
||||
|
public void setCreateDateAndNowDiffUnit(ChronoUnit createDateAndNowDiffUnit) { |
||||
|
this.createDateAndNowDiffUnit = createDateAndNowDiffUnit; |
||||
|
} |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
package io.sc.platform.orm.task; |
||||
|
|
||||
|
public enum TaskExecuteMode { |
||||
|
SYNCHRONOUS, //同步
|
||||
|
ASYNCHRONOUS; //异步
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package io.sc.platform.orm.task; |
||||
|
|
||||
|
/** |
||||
|
* 任务状态 |
||||
|
*/ |
||||
|
public enum TaskStatus { |
||||
|
STARTED, //已启动
|
||||
|
COMPLETED, //已完成
|
||||
|
CANCELED, //已取消
|
||||
|
ERROR; //发生错误
|
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package io.sc.platform.orm.task; |
||||
|
|
||||
|
/** |
||||
|
* 任务类型 |
||||
|
*/ |
||||
|
public enum TaskType { |
||||
|
EXPORT; //数据导出
|
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package io.sc.platform.orm.task.service; |
||||
|
|
||||
|
import io.sc.platform.orm.task.Task; |
||||
|
import io.sc.platform.orm.task.TaskStatus; |
||||
|
|
||||
|
public interface TaskService { |
||||
|
public String create(Task task); |
||||
|
public void changeStatus(String taskId,TaskStatus status); |
||||
|
public void changeCurrentWeight(String taskId,long currentWeight); |
||||
|
public void changeMessage(String taskId,String message); |
||||
|
public void error(String taskId,String exception,String exceptionMessage,String exceptionStackTrace); |
||||
|
public void complete(String taskId); |
||||
|
public boolean isCanceled(String taskId); |
||||
|
} |
@ -0,0 +1,99 @@ |
|||||
|
package io.sc.platform.orm.task.service.impl; |
||||
|
|
||||
|
import io.sc.platform.orm.task.ExportTask; |
||||
|
import io.sc.platform.orm.task.Task; |
||||
|
import io.sc.platform.orm.task.TaskStatus; |
||||
|
import io.sc.platform.orm.task.TaskType; |
||||
|
import io.sc.platform.orm.task.service.TaskService; |
||||
|
import io.sc.platform.security.util.SecurityUtil; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.Map; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
@Service("io.sc.platform.orm.task.service.impl.TaskServiceImpl") |
||||
|
public class TaskServiceImpl implements TaskService { |
||||
|
@Autowired private JdbcTemplate jdbcTemplate; |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public String create(Task task) { |
||||
|
String id =UUID.randomUUID().toString(); |
||||
|
String taskSql ="insert into SYS_TASK(ID_,NAME_,TYPE_,EXECUTE_MODE_,STATUS_,CREATOR_,CREATE_DATE_,TOTAL_WEIGHT_,CURRENT_WEIGHT_,MESSAGE_) values(?,?,?,?,?,?,?,?,?,?)"; |
||||
|
String exportTaskSql ="insert into SYS_TASK(ID_,NAME_,TYPE_,EXECUTE_MODE_,STATUS_,CREATOR_,CREATE_DATE_,TOTAL_WEIGHT_,CURRENT_WEIGHT_,MESSAGE_,EXPORT_RESOURCE_NAME_,EXPORT_RESOURCE_URL_) values(?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
if(TaskType.EXPORT.equals(task.getType())){ |
||||
|
ExportTask exportTask =(ExportTask)task; |
||||
|
jdbcTemplate.update(exportTaskSql, |
||||
|
id, |
||||
|
task.getName(), |
||||
|
task.getType().name(), |
||||
|
task.getExecuteMode().name(), |
||||
|
TaskStatus.STARTED.name(), |
||||
|
SecurityUtil.getLoginName(), |
||||
|
new Date(), |
||||
|
task.getTotalWeight(), |
||||
|
task.getCurrentWeight(), |
||||
|
task.getMessage(), |
||||
|
exportTask.getExportResourceName(), |
||||
|
exportTask.getExportResourceUrl() |
||||
|
); |
||||
|
}else{ |
||||
|
jdbcTemplate.update(exportTaskSql, |
||||
|
id, |
||||
|
task.getName(), |
||||
|
task.getType().name(), |
||||
|
task.getExecuteMode().name(), |
||||
|
TaskStatus.STARTED.name(), |
||||
|
SecurityUtil.getLoginName(), |
||||
|
new Date(),task.getTotalWeight(), |
||||
|
task.getCurrentWeight(), |
||||
|
task.getMessage() |
||||
|
); |
||||
|
} |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void changeStatus(String taskId, TaskStatus status) { |
||||
|
jdbcTemplate.update("update SYS_TASK set STATUS_=? where ID_=?",status.name(),taskId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void changeCurrentWeight(String taskId, long currentWeight) { |
||||
|
jdbcTemplate.update("update SYS_TASK set CURRENT_WEIGHT_=? where ID_=?",currentWeight,taskId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void changeMessage(String taskId, String message) { |
||||
|
jdbcTemplate.update("update SYS_TASK set MESSAGE_=? where ID_=?",message,taskId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void error(String taskId, String exception, String exceptionMessage, String exceptionStackTrace) { |
||||
|
jdbcTemplate.update("update SYS_TASK set STATUS_=?,EXCEPTION_=?,EXCEPTION_MESSAGE_=?,EXCEPTION_STACK_TRACE_=? where ID_=?",TaskStatus.ERROR.name(), exception,exceptionMessage,exceptionStackTrace,taskId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void complete(String taskId) { |
||||
|
jdbcTemplate.update("update SYS_TASK set STATUS_=?,COMPLETED_DATE_=? where ID_=?",TaskStatus.COMPLETED.name(),new Date(),taskId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean isCanceled(String taskId) { |
||||
|
Map<String,Object> row =jdbcTemplate.queryForMap("select CANCELED_DATE_ from SYS_TASK where ID_=?",taskId); |
||||
|
if(row==null || row.isEmpty()){ |
||||
|
return false; |
||||
|
} |
||||
|
Object canceledDate =row.get("CANCELED_DATE_"); |
||||
|
return canceledDate==null? false : true; |
||||
|
} |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"includes":[ |
||||
|
"io/sc/platform/orm/i18n/parameter", |
||||
|
"io/sc/platform/orm/task/i18n/task" |
||||
|
] |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
[ |
||||
|
/*系统/同步导出 Excel 最大记录数 */ |
||||
|
{ |
||||
|
"id" :"parameter.orm.exportExcel.synchronousExportMaxCount", |
||||
|
"parentId" :"parameter.system", |
||||
|
"code" :"parameter.orm.exportExcel.synchronousExportMaxCount", |
||||
|
"defaultValue" :"1000", |
||||
|
"order" : 1500 |
||||
|
}, |
||||
|
/*系统/导出 Excel 存储类型*/ |
||||
|
{ |
||||
|
"id" :"parameter.orm.exportExcel.persistence.type", |
||||
|
"parentId" :"parameter.system", |
||||
|
"code" :"parameter.orm.exportExcel.persistence.type", |
||||
|
"defaultValue" :"DISK", |
||||
|
"order" : 1600, |
||||
|
"options" :{ |
||||
|
"DATABASE" : "parameter.system.attachment.persistence.type.DATABASE", |
||||
|
"DISK" : "parameter.system.attachment.persistence.type.DISK" |
||||
|
} |
||||
|
} |
||||
|
] |
@ -0,0 +1,2 @@ |
|||||
|
parameter.orm.exportExcel.persistence.type=Export Excel Persistence Type |
||||
|
parameter.orm.exportExcel.synchronousExportMaxCount=Max Row Count Run In Synchronous |
@ -0,0 +1,2 @@ |
|||||
|
parameter.orm.exportExcel.persistence.type=\u5C0E\u51FA Excel \u5B58\u5132\u985E\u578B |
||||
|
parameter.orm.exportExcel.synchronousExportMaxCount=\u540C\u6B65\u5C0E\u51FA\u6700\u5927\u8A18\u9304\u6578 |
@ -0,0 +1,2 @@ |
|||||
|
parameter.orm.exportExcel.persistence.type=\u5BFC\u51FA Excel \u5B58\u50A8\u7C7B\u578B |
||||
|
parameter.orm.exportExcel.synchronousExportMaxCount=\u540C\u6B65\u5BFC\u51FA\u6700\u5927\u8BB0\u5F55\u6570 |
@ -0,0 +1,9 @@ |
|||||
|
io.sc.platform.orm.task.TaskType.EXPORT=Export |
||||
|
|
||||
|
io.sc.platform.orm.task.TaskExecuteMode.SYNCHRONOUS=Synchronous |
||||
|
io.sc.platform.orm.task.TaskExecuteMode.ASYNCHRONOUS=Asynchronous |
||||
|
|
||||
|
io.sc.platform.orm.task.TaskStatus.STARTED=Started |
||||
|
io.sc.platform.orm.task.TaskStatus.COMPLETED=Completed |
||||
|
io.sc.platform.orm.task.TaskStatus.CANCELED=Canceled |
||||
|
io.sc.platform.orm.task.TaskStatus.ERROR=Error Occur |
@ -0,0 +1,9 @@ |
|||||
|
io.sc.platform.orm.task.TaskType.EXPORT=\u5C0E\u51FA |
||||
|
|
||||
|
io.sc.platform.orm.task.TaskExecuteMode.SYNCHRONOUS=\u540C\u6B65 |
||||
|
io.sc.platform.orm.task.TaskExecuteMode.ASYNCHRONOUS=\u7570\u6B65 |
||||
|
|
||||
|
io.sc.platform.orm.task.TaskStatus.STARTED=\u5DF2\u555F\u52D5 |
||||
|
io.sc.platform.orm.task.TaskStatus.COMPLETED=\u5DF2\u5B8C\u6210 |
||||
|
io.sc.platform.orm.task.TaskStatus.CANCELED=\u5DF2\u53D6\u6D88 |
||||
|
io.sc.platform.orm.task.TaskStatus.ERROR=\u767C\u751F\u932F\u8AA4 |
@ -0,0 +1,9 @@ |
|||||
|
io.sc.platform.orm.task.TaskType.EXPORT=\u5BFC\u51FA |
||||
|
|
||||
|
io.sc.platform.orm.task.TaskExecuteMode.SYNCHRONOUS=\u540C\u6B65 |
||||
|
io.sc.platform.orm.task.TaskExecuteMode.ASYNCHRONOUS=\u5F02\u6B65 |
||||
|
|
||||
|
io.sc.platform.orm.task.TaskStatus.STARTED=\u5DF2\u542F\u52A8 |
||||
|
io.sc.platform.orm.task.TaskStatus.COMPLETED=\u5DF2\u5B8C\u6210 |
||||
|
io.sc.platform.orm.task.TaskStatus.CANCELED=\u5DF2\u53D6\u6D88 |
||||
|
io.sc.platform.orm.task.TaskStatus.ERROR=\u53D1\u751F\u9519\u8BEF |
@ -0,0 +1,24 @@ |
|||||
|
package io.sc.platform.system.api.storage; |
||||
|
|
||||
|
import io.sc.platform.orm.api.vo.BaseVo; |
||||
|
|
||||
|
public class DatabaseStorageVo extends BaseVo { |
||||
|
protected String id; |
||||
|
protected String path; |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(String id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getPath() { |
||||
|
return path; |
||||
|
} |
||||
|
|
||||
|
public void setPath(String path) { |
||||
|
this.path = path; |
||||
|
} |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
<template> |
||||
|
<div style="height: 100%"> |
||||
|
<w-grid |
||||
|
ref="gridRef" |
||||
|
:title="$t('system.task.grid.title')" |
||||
|
:config-button="true" |
||||
|
selection="multiple" |
||||
|
db-click-operation="view" |
||||
|
:checkbox-selection="true" |
||||
|
:data-url="Environment.apiContextPath('/api/system/task')" |
||||
|
:sort-by="['-createDate']" |
||||
|
:toolbar-configure="{ noIcon: false }" |
||||
|
:toolbar-actions="['query', 'refresh', 'separator', 'view']" |
||||
|
:query-form-cols-num="5" |
||||
|
:query-form-fields="[ |
||||
|
{ width: 100, name: 'status', label: $t('status'), type: 'w-select', clearable: true, options: Options.enum(Enums.TaskStatus, false) }, |
||||
|
{ width: 100, name: 'type', label: $t('type'), type: 'w-select', clearable: true, options: Options.enum(Enums.TaskType, false) }, |
||||
|
{ width: 200, name: 'name', label: $t('name'), type: 'w-text', clearable: true }, |
||||
|
{ width: 100, name: 'creator', label: $t('creator'), type: 'w-text', clearable: true }, |
||||
|
]" |
||||
|
:columns="[ |
||||
|
{ |
||||
|
width: 100, |
||||
|
name: 'status', |
||||
|
label: $t('status'), |
||||
|
format: Formater.enum(Enums.TaskStatus), |
||||
|
}, |
||||
|
{ width: 100, name: 'type', label: $t('type'), format: Formater.enum(Enums.TaskType) }, |
||||
|
{ width: 200, name: 'name', label: $t('name') }, |
||||
|
{ width: 100, name: 'creator', label: $t('creator') }, |
||||
|
{ width: 120, name: 'createDate', label: $t('createDate') }, |
||||
|
{ width: 120, name: 'completedDate', label: $t('system.task.grid.entity.completedDate') }, |
||||
|
{ width: 120, name: 'canceledDate', label: $t('system.task.grid.entity.canceledDate') }, |
||||
|
{ width: 200, name: 'exception', label: $t('exception') }, |
||||
|
{ width: 200, name: 'exceptionMessage', label: $t('exceptionMessage') }, |
||||
|
{ width: 200, name: 'exceptionStackTrace', label: $t('exceptionStackTrace') }, |
||||
|
]" |
||||
|
></w-grid> |
||||
|
</div> |
||||
|
</template> |
||||
|
<script setup lang="ts"> |
||||
|
import { Environment, axios, EnumTools, Formater, Options } from 'platform-core'; |
||||
|
|
||||
|
const Enums = await EnumTools.fetch(['io.sc.platform.system.enums.TaskType', 'io.sc.platform.system.enums.TaskStatus']); |
||||
|
</script> |
@ -0,0 +1,15 @@ |
|||||
|
package io.sc.platform.system.storage.controller; |
||||
|
|
||||
|
import io.sc.platform.mvc.controller.support.RestCrudController; |
||||
|
import io.sc.platform.system.api.storage.DatabaseStorageVo; |
||||
|
import io.sc.platform.system.storage.jpa.entity.DatabaseStorageEntity; |
||||
|
import io.sc.platform.system.storage.jpa.repository.DatabaseStorageRepository; |
||||
|
import io.sc.platform.system.storage.service.DatabaseStorageService; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@RestController("io.sc.platform.system.storage.controller.DatabaseStorageWebController") |
||||
|
@RequestMapping("/api/storage") |
||||
|
public class DatabaseStorageWebController extends RestCrudController<DatabaseStorageVo, DatabaseStorageEntity, String, DatabaseStorageRepository, DatabaseStorageService> { |
||||
|
|
||||
|
} |
@ -0,0 +1,49 @@ |
|||||
|
package io.sc.platform.system.storage.jpa.entity; |
||||
|
|
||||
|
import io.sc.platform.orm.entity.BaseEntity; |
||||
|
import io.sc.platform.system.api.storage.DatabaseStorageVo; |
||||
|
import org.hibernate.annotations.GenericGenerator; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
import javax.validation.constraints.Size; |
||||
|
|
||||
|
@Entity |
||||
|
@Table(name="SYS_STORAGE") |
||||
|
public class DatabaseStorageEntity extends BaseEntity<DatabaseStorageVo> { |
||||
|
//主键
|
||||
|
@Id |
||||
|
@GeneratedValue(generator = "system-uuid") |
||||
|
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
||||
|
@Column(name="ID_", length=36) |
||||
|
@Size(max=36) |
||||
|
protected String id; |
||||
|
|
||||
|
@Column(name="PATH_") |
||||
|
protected String path; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public DatabaseStorageVo toVo() { |
||||
|
DatabaseStorageVo vo =new DatabaseStorageVo(); |
||||
|
super.toVo(vo); |
||||
|
vo.setId(this.getId()); |
||||
|
vo.setPath(this.getPath()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(String id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getPath() { |
||||
|
return path; |
||||
|
} |
||||
|
|
||||
|
public void setPath(String path) { |
||||
|
this.path = path; |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
package io.sc.platform.system.storage.jpa.repository; |
||||
|
|
||||
|
import io.sc.platform.orm.repository.DaoRepository; |
||||
|
import io.sc.platform.system.storage.jpa.entity.DatabaseStorageEntity; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
@Repository("io.sc.platform.system.storage.jpa.repository.DatabaseStorageRepository") |
||||
|
public interface DatabaseStorageRepository extends DaoRepository<DatabaseStorageEntity,String> { |
||||
|
|
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
package io.sc.platform.system.storage.service; |
||||
|
|
||||
|
import io.sc.platform.orm.service.DaoService; |
||||
|
import io.sc.platform.system.storage.jpa.entity.DatabaseStorageEntity; |
||||
|
import io.sc.platform.system.storage.jpa.repository.DatabaseStorageRepository; |
||||
|
|
||||
|
public interface DatabaseStorageService extends DaoService<DatabaseStorageEntity, String, DatabaseStorageRepository> { |
||||
|
|
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package io.sc.platform.system.storage.service.impl; |
||||
|
|
||||
|
import io.sc.platform.orm.service.impl.DaoServiceImpl; |
||||
|
import io.sc.platform.system.storage.jpa.entity.DatabaseStorageEntity; |
||||
|
import io.sc.platform.system.storage.jpa.repository.DatabaseStorageRepository; |
||||
|
import io.sc.platform.system.storage.service.DatabaseStorageService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service("io.sc.platform.system.storage.service.impl.DatabaseStorageServiceImpl") |
||||
|
public class DatabaseStorageServiceImpl extends DaoServiceImpl<DatabaseStorageEntity, String, DatabaseStorageRepository> implements DatabaseStorageService { |
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package io.sc.platform.system.task.controller; |
||||
|
|
||||
|
import io.sc.platform.mvc.controller.support.RestCrudController; |
||||
|
import io.sc.platform.orm.task.Task; |
||||
|
import io.sc.platform.system.task.jpa.entity.TaskEntity; |
||||
|
import io.sc.platform.system.task.jpa.repository.TaskRepository; |
||||
|
import io.sc.platform.system.task.service.TaskService; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@RestController("io.sc.platform.system.task.controller.TaskWebController") |
||||
|
@RequestMapping("/api/system/task") |
||||
|
public class TaskWebController extends RestCrudController<Task, TaskEntity, String, TaskRepository, TaskService> { |
||||
|
@PostMapping("cleanMyAsyncTaskList") |
||||
|
public void cleanMyAsyncTaskList(){ |
||||
|
service.cleanMyAsyncTaskList(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("removeAsyncTask/{taskId}") |
||||
|
public void removeAsyncTask(@PathVariable("taskId")String taskId){ |
||||
|
service.removeAsyncTask(taskId); |
||||
|
} |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package io.sc.platform.system.task.jpa.entity; |
||||
|
|
||||
|
import javax.persistence.DiscriminatorValue; |
||||
|
import javax.persistence.Entity; |
||||
|
|
||||
|
/** |
||||
|
* 空任务实体类 |
||||
|
*/ |
||||
|
@Entity |
||||
|
@DiscriminatorValue("EMPTY") |
||||
|
public class EmptyTaskEntity extends TaskEntity { |
||||
|
public EmptyTaskEntity() {} |
||||
|
public EmptyTaskEntity(String id) { |
||||
|
this.id =id; |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,57 @@ |
|||||
|
package io.sc.platform.system.task.jpa.entity; |
||||
|
|
||||
|
import io.sc.platform.orm.task.ExportTask; |
||||
|
import io.sc.platform.orm.task.Task; |
||||
|
|
||||
|
import javax.persistence.Column; |
||||
|
import javax.persistence.DiscriminatorValue; |
||||
|
import javax.persistence.Entity; |
||||
|
import javax.validation.constraints.Size; |
||||
|
|
||||
|
/** |
||||
|
* 空任务实体类 |
||||
|
*/ |
||||
|
@Entity |
||||
|
@DiscriminatorValue("EXPORT") |
||||
|
public class ExportTaskEntity extends TaskEntity { |
||||
|
//导出资源名称
|
||||
|
@Column(name="EXPORT_RESOURCE_NAME_", length=255) |
||||
|
@Size(max=255) |
||||
|
protected String exportResourceName; |
||||
|
|
||||
|
//导出资源URL
|
||||
|
@Column(name="EXPORT_RESOURCE_URL_", length=1024) |
||||
|
@Size(max=1024) |
||||
|
protected String exportResourceUrl; |
||||
|
|
||||
|
public ExportTaskEntity() {} |
||||
|
public ExportTaskEntity(String id) { |
||||
|
this.id =id; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Task toVo() { |
||||
|
ExportTask vo =new ExportTask(); |
||||
|
super.toVo(vo); |
||||
|
vo.setExportResourceName(this.getExportResourceName()); |
||||
|
vo.setExportResourceUrl(this.getExportResourceUrl()); |
||||
|
return vo; |
||||
|
} |
||||
|
|
||||
|
public String getExportResourceName() { |
||||
|
return exportResourceName; |
||||
|
} |
||||
|
|
||||
|
public void setExportResourceName(String exportResourceName) { |
||||
|
this.exportResourceName = exportResourceName; |
||||
|
} |
||||
|
|
||||
|
public String getExportResourceUrl() { |
||||
|
return exportResourceUrl; |
||||
|
} |
||||
|
|
||||
|
public void setExportResourceUrl(String exportResourceUrl) { |
||||
|
this.exportResourceUrl = exportResourceUrl; |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,249 @@ |
|||||
|
package io.sc.platform.system.task.jpa.entity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.fasterxml.jackson.annotation.JsonSubTypes; |
||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo; |
||||
|
import io.sc.platform.orm.entity.BaseEntity; |
||||
|
import io.sc.platform.orm.task.Task; |
||||
|
import io.sc.platform.orm.task.TaskExecuteMode; |
||||
|
import io.sc.platform.orm.task.TaskStatus; |
||||
|
import io.sc.platform.orm.task.TaskType; |
||||
|
import org.hibernate.annotations.GenericGenerator; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
import javax.validation.constraints.Size; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 任务实体类 |
||||
|
*/ |
||||
|
@Entity |
||||
|
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) |
||||
|
@DiscriminatorColumn(name="TYPE_",discriminatorType=DiscriminatorType.STRING,length=20) |
||||
|
@JsonIgnoreProperties(ignoreUnknown=true) |
||||
|
@Table(name="SYS_TASK") |
||||
|
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type",visible=true,defaultImpl = EmptyTaskEntity.class ) |
||||
|
@JsonSubTypes({ |
||||
|
@JsonSubTypes.Type(value = EmptyTaskEntity.class, name = "EMPTY"), |
||||
|
@JsonSubTypes.Type(value = ExportTaskEntity.class, name = "EXPORT") |
||||
|
}) |
||||
|
public class TaskEntity extends BaseEntity<Task> { |
||||
|
//主键
|
||||
|
@Id |
||||
|
@GeneratedValue(generator = "system-uuid") |
||||
|
@GenericGenerator(name = "system-uuid", strategy = "uuid2") |
||||
|
@Column(name="ID_", length=36) |
||||
|
@Size(max=36) |
||||
|
protected String id; |
||||
|
|
||||
|
//名称
|
||||
|
@Column(name="NAME_", length=255) |
||||
|
@Size(max=255) |
||||
|
protected String name; |
||||
|
|
||||
|
//类型
|
||||
|
@Column(name="TYPE_", length=20, insertable=false,updatable=false) |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
protected TaskType type; |
||||
|
|
||||
|
//执行模式
|
||||
|
@Column(name="EXECUTE_MODE_", length=20) |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
protected TaskExecuteMode executeMode; |
||||
|
|
||||
|
//状态
|
||||
|
@Column(name="STATUS_", length=20) |
||||
|
@Enumerated(EnumType.STRING) |
||||
|
protected TaskStatus status; |
||||
|
|
||||
|
//创建人(登录名)
|
||||
|
@Column(name="CREATOR_", length=255, nullable=false) |
||||
|
protected String creator; |
||||
|
|
||||
|
//创建日期
|
||||
|
@Column(name="CREATE_DATE_", nullable=false) |
||||
|
@Temporal(TemporalType.TIMESTAMP) |
||||
|
protected Date createDate; |
||||
|
|
||||
|
//完成日期
|
||||
|
@Column(name="COMPLETED_DATE_") |
||||
|
@Temporal(TemporalType.TIMESTAMP) |
||||
|
protected Date completedDate; |
||||
|
|
||||
|
//取消日期
|
||||
|
@Column(name="CANCELED_DATE_") |
||||
|
@Temporal(TemporalType.TIMESTAMP) |
||||
|
protected Date canceledDate; |
||||
|
|
||||
|
//总计需要执行的数量
|
||||
|
@Column(name="TOTAL_WEIGHT_") |
||||
|
private Long totalWeight; |
||||
|
|
||||
|
//当前已经执行的数量
|
||||
|
@Column(name="CURRENT_WEIGHT_") |
||||
|
private Long currentWeight; |
||||
|
|
||||
|
//执行进度消息
|
||||
|
@Column(name="MESSAGE_") |
||||
|
private String message; |
||||
|
|
||||
|
//执行抛出的违例类名称
|
||||
|
@Column(name="EXCEPTION_",length=255) |
||||
|
@Size(max=255) |
||||
|
protected String exception; |
||||
|
|
||||
|
//执行抛出的违例消息
|
||||
|
@Column(name="EXCEPTION_MESSAGE_",length=1024) |
||||
|
@Size(max=1024) |
||||
|
protected String exceptionMessage; |
||||
|
|
||||
|
//执行抛出的违例栈
|
||||
|
@Column(name="EXCEPTION_STACK_TRACE_") |
||||
|
protected String exceptionStackTrace; |
||||
|
|
||||
|
public TaskEntity() {} |
||||
|
public TaskEntity(String id) { |
||||
|
this.id =id; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void toVo(Task vo) { |
||||
|
super.toVo(vo); |
||||
|
vo.setId(this.getId()); |
||||
|
vo.setName(this.getName()); |
||||
|
vo.setType(this.getType()); |
||||
|
vo.setExecuteMode(this.getExecuteMode()); |
||||
|
vo.setStatus(this.getStatus()); |
||||
|
vo.setCreator(this.getCreator()); |
||||
|
vo.setCreateDate(this.getCreateDate()); |
||||
|
vo.setCompletedDate(this.getCompletedDate()); |
||||
|
vo.setCanceledDate(this.getCanceledDate()); |
||||
|
vo.setTotalWeight(this.getTotalWeight()); |
||||
|
vo.setCurrentWeight(this.getCurrentWeight()); |
||||
|
vo.setMessage(this.getMessage()); |
||||
|
vo.setException(this.getException()); |
||||
|
vo.setExceptionMessage(this.getExceptionMessage()); |
||||
|
vo.setExceptionStackTrace(this.getExceptionStackTrace()); |
||||
|
} |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(String id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public TaskType getType() { |
||||
|
return type; |
||||
|
} |
||||
|
|
||||
|
public void setType(TaskType type) { |
||||
|
this.type = type; |
||||
|
} |
||||
|
|
||||
|
public TaskExecuteMode getExecuteMode() { |
||||
|
return executeMode; |
||||
|
} |
||||
|
|
||||
|
public void setExecuteMode(TaskExecuteMode executeMode) { |
||||
|
this.executeMode = executeMode; |
||||
|
} |
||||
|
|
||||
|
public TaskStatus getStatus() { |
||||
|
return status; |
||||
|
} |
||||
|
|
||||
|
public void setStatus(TaskStatus status) { |
||||
|
this.status = status; |
||||
|
} |
||||
|
|
||||
|
public String getCreator() { |
||||
|
return creator; |
||||
|
} |
||||
|
|
||||
|
public void setCreator(String creator) { |
||||
|
this.creator = creator; |
||||
|
} |
||||
|
|
||||
|
public Date getCreateDate() { |
||||
|
return createDate; |
||||
|
} |
||||
|
|
||||
|
public void setCreateDate(Date createDate) { |
||||
|
this.createDate = createDate; |
||||
|
} |
||||
|
|
||||
|
public Date getCompletedDate() { |
||||
|
return completedDate; |
||||
|
} |
||||
|
|
||||
|
public void setCompletedDate(Date completedDate) { |
||||
|
this.completedDate = completedDate; |
||||
|
} |
||||
|
|
||||
|
public Date getCanceledDate() { |
||||
|
return canceledDate; |
||||
|
} |
||||
|
|
||||
|
public void setCanceledDate(Date canceledDate) { |
||||
|
this.canceledDate = canceledDate; |
||||
|
} |
||||
|
|
||||
|
public Long getTotalWeight() { |
||||
|
return totalWeight; |
||||
|
} |
||||
|
|
||||
|
public void setTotalWeight(Long totalWeight) { |
||||
|
this.totalWeight = totalWeight; |
||||
|
} |
||||
|
|
||||
|
public Long getCurrentWeight() { |
||||
|
return currentWeight; |
||||
|
} |
||||
|
|
||||
|
public void setCurrentWeight(Long currentWeight) { |
||||
|
this.currentWeight = currentWeight; |
||||
|
} |
||||
|
|
||||
|
public String getMessage() { |
||||
|
return message; |
||||
|
} |
||||
|
|
||||
|
public void setMessage(String message) { |
||||
|
this.message = message; |
||||
|
} |
||||
|
|
||||
|
public String getException() { |
||||
|
return exception; |
||||
|
} |
||||
|
|
||||
|
public void setException(String exception) { |
||||
|
this.exception = exception; |
||||
|
} |
||||
|
|
||||
|
public String getExceptionMessage() { |
||||
|
return exceptionMessage; |
||||
|
} |
||||
|
|
||||
|
public void setExceptionMessage(String exceptionMessage) { |
||||
|
this.exceptionMessage = exceptionMessage; |
||||
|
} |
||||
|
|
||||
|
public String getExceptionStackTrace() { |
||||
|
return exceptionStackTrace; |
||||
|
} |
||||
|
|
||||
|
public void setExceptionStackTrace(String exceptionStackTrace) { |
||||
|
this.exceptionStackTrace = exceptionStackTrace; |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,10 @@ |
|||||
|
package io.sc.platform.system.task.jpa.repository; |
||||
|
|
||||
|
import io.sc.platform.orm.repository.DaoRepository; |
||||
|
import io.sc.platform.system.task.jpa.entity.TaskEntity; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
@Repository("io.sc.platform.system.task.jpa.repository.TaskRepository") |
||||
|
public interface TaskRepository extends DaoRepository<TaskEntity,String> { |
||||
|
|
||||
|
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue