1
0

feat: 优化任务执行逻辑

This commit is contained in:
2025-09-06 15:14:41 +08:00
parent 0ad9d8239c
commit 2c889462c6
5 changed files with 29 additions and 63 deletions

View File

@@ -2,6 +2,7 @@ package com.lanyuanxiaoyao.leopard.server.service;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
@@ -79,18 +80,23 @@ public class QuartzService {
@Slf4j
public static class TaskExecutionJob extends QuartzJobBean {
private final TaskService taskService;
private final TaskTemplateService taskTemplateService;
private final FlowExecutor flowExecutor;
public TaskExecutionJob(TaskService taskService) {
this.taskService = taskService;
public TaskExecutionJob(TaskTemplateService taskTemplateService, FlowExecutor flowExecutor) {
this.taskTemplateService = taskTemplateService;
this.flowExecutor = flowExecutor;
}
@Override
protected void executeInternal(JobExecutionContext context) {
var dataMap = context.getMergedJobDataMap();
var templateId = dataMap.getLong("template_id");
var parms = (Map<String, Object>) dataMap.getOrDefault("params", Map.of());
taskService.execute(templateId, parms);
if (ObjectUtil.isNotNull(templateId)) {
var template = taskTemplateService.detail(templateId);
var params = (Map<String, Object>) dataMap.getOrDefault("params", Map.of());
flowExecutor.execute2Resp(template.getChain(), params, context);
}
}
}

View File

@@ -8,7 +8,6 @@ import Test from './pages/Test.tsx'
import StockList from './pages/stock/StockList.tsx'
import StockDetail from './pages/stock/StockDetail.tsx'
import TaskList from './pages/task/TaskList.tsx'
import TaskAdd from './pages/task/TaskAdd.tsx'
import TaskTemplateList from './pages/task/TaskTemplateList.tsx'
import TaskTemplateSave from './pages/task/TaskTemplateSave.tsx'
import TaskScheduleList from './pages/task/TaskScheduleList.tsx'
@@ -51,10 +50,6 @@ const routes: RouteObject[] = [
path: 'list',
Component: TaskList,
},
{
path: 'add',
Component: TaskAdd,
},
{
path: 'template',
children: [

View File

@@ -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)

View File

@@ -24,32 +24,7 @@ function TaskList() {
},
},
...crudCommonOptions(),
...paginationTemplate(
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')
},
},
],
},
},
},
],
),
...paginationTemplate(15),
columns: [
{
name: 'name',

View File

@@ -60,6 +60,23 @@ function TaskScheduleSave() {
label: '重置',
actionType: 'reset',
},
{
type: 'action',
label: '返回',
onEvent: {
click: {
actions: [
{
actionType: 'custom',
// @ts-ignore
script: (context, action, event) => {
navigate(-1)
},
},
],
},
},
}
],
},
],