feat: 优化任务执行逻辑
This commit is contained in:
@@ -2,6 +2,7 @@ package com.lanyuanxiaoyao.leopard.server.service;
|
|||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.yomahub.liteflow.core.FlowExecutor;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -79,18 +80,23 @@ public class QuartzService {
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public static class TaskExecutionJob extends QuartzJobBean {
|
public static class TaskExecutionJob extends QuartzJobBean {
|
||||||
private final TaskService taskService;
|
private final TaskTemplateService taskTemplateService;
|
||||||
|
private final FlowExecutor flowExecutor;
|
||||||
|
|
||||||
public TaskExecutionJob(TaskService taskService) {
|
public TaskExecutionJob(TaskTemplateService taskTemplateService, FlowExecutor flowExecutor) {
|
||||||
this.taskService = taskService;
|
this.taskTemplateService = taskTemplateService;
|
||||||
|
this.flowExecutor = flowExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void executeInternal(JobExecutionContext context) {
|
protected void executeInternal(JobExecutionContext context) {
|
||||||
var dataMap = context.getMergedJobDataMap();
|
var dataMap = context.getMergedJobDataMap();
|
||||||
var templateId = dataMap.getLong("template_id");
|
var templateId = dataMap.getLong("template_id");
|
||||||
var parms = (Map<String, Object>) dataMap.getOrDefault("params", Map.of());
|
if (ObjectUtil.isNotNull(templateId)) {
|
||||||
taskService.execute(templateId, parms);
|
var template = taskTemplateService.detail(templateId);
|
||||||
|
var params = (Map<String, Object>) dataMap.getOrDefault("params", Map.of());
|
||||||
|
flowExecutor.execute2Resp(template.getChain(), params, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import Test from './pages/Test.tsx'
|
|||||||
import StockList from './pages/stock/StockList.tsx'
|
import StockList from './pages/stock/StockList.tsx'
|
||||||
import StockDetail from './pages/stock/StockDetail.tsx'
|
import StockDetail from './pages/stock/StockDetail.tsx'
|
||||||
import TaskList from './pages/task/TaskList.tsx'
|
import TaskList from './pages/task/TaskList.tsx'
|
||||||
import TaskAdd from './pages/task/TaskAdd.tsx'
|
|
||||||
import TaskTemplateList from './pages/task/TaskTemplateList.tsx'
|
import TaskTemplateList from './pages/task/TaskTemplateList.tsx'
|
||||||
import TaskTemplateSave from './pages/task/TaskTemplateSave.tsx'
|
import TaskTemplateSave from './pages/task/TaskTemplateSave.tsx'
|
||||||
import TaskScheduleList from './pages/task/TaskScheduleList.tsx'
|
import TaskScheduleList from './pages/task/TaskScheduleList.tsx'
|
||||||
@@ -51,10 +50,6 @@ const routes: RouteObject[] = [
|
|||||||
path: 'list',
|
path: 'list',
|
||||||
Component: TaskList,
|
Component: TaskList,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'add',
|
|
||||||
Component: TaskAdd,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'template',
|
path: 'template',
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import {amisRender, commonInfo} from '../../util/amis.tsx'
|
|
||||||
|
|
||||||
function TaskAdd() {
|
|
||||||
return (
|
|
||||||
<div className="task-add">
|
|
||||||
{amisRender(
|
|
||||||
{
|
|
||||||
type: 'page',
|
|
||||||
title: '任务添加',
|
|
||||||
body: [
|
|
||||||
{
|
|
||||||
debug: commonInfo.debug,
|
|
||||||
type: 'form',
|
|
||||||
wrapWithPanel: false,
|
|
||||||
mode: 'horizontal',
|
|
||||||
labelAlign: 'left',
|
|
||||||
body: [],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default React.memo(TaskAdd)
|
|
||||||
@@ -24,32 +24,7 @@ function TaskList() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
...crudCommonOptions(),
|
...crudCommonOptions(),
|
||||||
...paginationTemplate(
|
...paginationTemplate(15),
|
||||||
15,
|
|
||||||
undefined,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
type: 'action',
|
|
||||||
label: '',
|
|
||||||
icon: 'fa fa-plus',
|
|
||||||
tooltip: '添加任务',
|
|
||||||
tooltipPlacement: 'top',
|
|
||||||
onEvent: {
|
|
||||||
click: {
|
|
||||||
actions: [
|
|
||||||
{
|
|
||||||
actionType: 'custom',
|
|
||||||
// @ts-ignore
|
|
||||||
script: (context, action, event) => {
|
|
||||||
navigate('/task/add')
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
),
|
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
name: 'name',
|
name: 'name',
|
||||||
|
|||||||
@@ -60,6 +60,23 @@ function TaskScheduleSave() {
|
|||||||
label: '重置',
|
label: '重置',
|
||||||
actionType: 'reset',
|
actionType: 'reset',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'action',
|
||||||
|
label: '返回',
|
||||||
|
onEvent: {
|
||||||
|
click: {
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
actionType: 'custom',
|
||||||
|
// @ts-ignore
|
||||||
|
script: (context, action, event) => {
|
||||||
|
navigate(-1)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user