Skip to content

Commit

Permalink
batch task增加flowId和flowStepId字段,用于和逻辑流TaskFlow关联
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Nov 30, 2024
1 parent a272506 commit 3d8e4be
Show file tree
Hide file tree
Showing 21 changed files with 318 additions and 171 deletions.
4 changes: 2 additions & 2 deletions nop-batch/deploy/sql/mysql/_add_tenant_nop-batch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ alter table nop_batch_file drop primary key;
alter table nop_batch_file add primary key (NOP_TENANT_ID, SID);

alter table nop_batch_record_result drop primary key;
alter table nop_batch_record_result add primary key (NOP_TENANT_ID, TASK_ID,RECORD_KEY);
alter table nop_batch_record_result add primary key (NOP_TENANT_ID, BATCH_TASK_ID,RECORD_KEY);

alter table nop_batch_task drop primary key;
alter table nop_batch_task add primary key (NOP_TENANT_ID, SID);

alter table nop_batch_task_var drop primary key;
alter table nop_batch_task_var add primary key (NOP_TENANT_ID, TASK_ID,FIELD_NAME);
alter table nop_batch_task_var add primary key (NOP_TENANT_ID, BATCH_TASK_ID,FIELD_NAME);


13 changes: 7 additions & 6 deletions nop-batch/deploy/sql/mysql/_create_nop-batch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CREATE TABLE nop_batch_file(
FILE_LENGTH BIGINT NOT NULL COMMENT '文件长度',
FILE_CATEGORY VARCHAR(100) NOT NULL COMMENT '文件分类',
FILE_SOURCE VARCHAR(10) NOT NULL COMMENT '文件来源',
CURRENT_TASK_ID VARCHAR(32) NOT NULL COMMENT '当前处理任务',
PROCESS_STATE INTEGER NOT NULL COMMENT '处理状态',
BATCH_TASK_ID VARCHAR(32) NOT NULL COMMENT '批处理任务',
PROCESS_STATE VARCHAR(10) NOT NULL COMMENT '处理状态',
ACCEPT_DATE DATE NOT NULL COMMENT '文件接收时间',
VERSION BIGINT NOT NULL COMMENT '数据版本',
CREATED_BY VARCHAR(50) NOT NULL COMMENT '创建人',
Expand All @@ -30,6 +30,7 @@ CREATE TABLE nop_batch_task(
WORKER_ID VARCHAR(100) NOT NULL COMMENT '执行者',
INPUT_FILE_ID VARCHAR(32) NULL COMMENT '输入文件',
FLOW_STEP_ID VARCHAR(50) NULL COMMENT '关联流程步骤ID',
FLOW_ID VARCHAR(50) NULL COMMENT '关联流程ID',
RESTART_TIME TIMESTAMP(3) NULL COMMENT '重启时间',
RESULT_STATUS INTEGER NULL COMMENT '返回状态码',
RESULT_CODE VARCHAR(100) NULL COMMENT '返回码',
Expand All @@ -53,7 +54,7 @@ CREATE TABLE nop_batch_task(
);

CREATE TABLE nop_batch_task_var(
TASK_ID VARCHAR(32) NOT NULL COMMENT '主键',
BATCH_TASK_ID VARCHAR(32) NOT NULL COMMENT '主键',
FIELD_NAME VARCHAR(100) NOT NULL COMMENT '变量名',
FIELD_TYPE INTEGER NOT NULL COMMENT '变量类型',
STRING_VALUE VARCHAR(4000) NULL COMMENT '字符串值',
Expand All @@ -66,11 +67,11 @@ CREATE TABLE nop_batch_task_var(
CREATE_TIME TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL COMMENT '创建时间',
UPDATED_BY VARCHAR(50) NOT NULL COMMENT '修改人',
UPDATE_TIME TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL COMMENT '修改时间',
constraint PK_nop_batch_task_var primary key (TASK_ID,FIELD_NAME)
constraint PK_nop_batch_task_var primary key (BATCH_TASK_ID,FIELD_NAME)
);

CREATE TABLE nop_batch_record_result(
TASK_ID VARCHAR(32) NOT NULL COMMENT '主键',
BATCH_TASK_ID VARCHAR(32) NOT NULL COMMENT '主键',
RECORD_KEY VARCHAR(200) NOT NULL COMMENT '记录唯一键',
RESULT_STATUS INTEGER NOT NULL COMMENT '返回状态码',
RESULT_CODE VARCHAR(100) NULL COMMENT '返回码',
Expand All @@ -81,7 +82,7 @@ CREATE TABLE nop_batch_record_result(
CREATE_TIME TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL COMMENT '创建时间',
UPDATED_BY VARCHAR(50) NOT NULL COMMENT '修改人',
UPDATE_TIME TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL COMMENT '修改时间',
constraint PK_nop_batch_record_result primary key (TASK_ID,RECORD_KEY)
constraint PK_nop_batch_record_result primary key (BATCH_TASK_ID,RECORD_KEY)
);


Expand Down
4 changes: 2 additions & 2 deletions nop-batch/deploy/sql/oracle/_add_tenant_nop-batch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ alter table nop_batch_file drop constraint PK_nop_batch_file;
alter table nop_batch_file add constraint PK_nop_batch_file primary key (NOP_TENANT_ID, SID);

alter table nop_batch_record_result drop constraint PK_nop_batch_record_result;
alter table nop_batch_record_result add constraint PK_nop_batch_record_result primary key (NOP_TENANT_ID, TASK_ID,RECORD_KEY);
alter table nop_batch_record_result add constraint PK_nop_batch_record_result primary key (NOP_TENANT_ID, BATCH_TASK_ID,RECORD_KEY);

alter table nop_batch_task drop constraint PK_nop_batch_task;
alter table nop_batch_task add constraint PK_nop_batch_task primary key (NOP_TENANT_ID, SID);

alter table nop_batch_task_var drop constraint PK_nop_batch_task_var;
alter table nop_batch_task_var add constraint PK_nop_batch_task_var primary key (NOP_TENANT_ID, TASK_ID,FIELD_NAME);
alter table nop_batch_task_var add constraint PK_nop_batch_task_var primary key (NOP_TENANT_ID, BATCH_TASK_ID,FIELD_NAME);


21 changes: 12 additions & 9 deletions nop-batch/deploy/sql/oracle/_create_nop-batch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CREATE TABLE nop_batch_file(
FILE_LENGTH NUMBER(20) NOT NULL ,
FILE_CATEGORY VARCHAR2(100) NOT NULL ,
FILE_SOURCE VARCHAR2(10) NOT NULL ,
CURRENT_TASK_ID VARCHAR2(32) NOT NULL ,
PROCESS_STATE INTEGER NOT NULL ,
BATCH_TASK_ID VARCHAR2(32) NOT NULL ,
PROCESS_STATE VARCHAR2(10) NOT NULL ,
ACCEPT_DATE DATE NOT NULL ,
VERSION NUMBER(20) NOT NULL ,
CREATED_BY VARCHAR2(50) NOT NULL ,
Expand All @@ -30,6 +30,7 @@ CREATE TABLE nop_batch_task(
WORKER_ID VARCHAR2(100) NOT NULL ,
INPUT_FILE_ID VARCHAR2(32) ,
FLOW_STEP_ID VARCHAR2(50) ,
FLOW_ID VARCHAR2(50) ,
RESTART_TIME TIMESTAMP ,
RESULT_STATUS INTEGER ,
RESULT_CODE VARCHAR2(100) ,
Expand All @@ -53,7 +54,7 @@ CREATE TABLE nop_batch_task(
);

CREATE TABLE nop_batch_task_var(
TASK_ID VARCHAR2(32) NOT NULL ,
BATCH_TASK_ID VARCHAR2(32) NOT NULL ,
FIELD_NAME VARCHAR2(100) NOT NULL ,
FIELD_TYPE INTEGER NOT NULL ,
STRING_VALUE VARCHAR2(4000) ,
Expand All @@ -66,11 +67,11 @@ CREATE TABLE nop_batch_task_var(
CREATE_TIME TIMESTAMP NOT NULL ,
UPDATED_BY VARCHAR2(50) NOT NULL ,
UPDATE_TIME TIMESTAMP NOT NULL ,
constraint PK_nop_batch_task_var primary key (TASK_ID,FIELD_NAME)
constraint PK_nop_batch_task_var primary key (BATCH_TASK_ID,FIELD_NAME)
);

CREATE TABLE nop_batch_record_result(
TASK_ID VARCHAR2(32) NOT NULL ,
BATCH_TASK_ID VARCHAR2(32) NOT NULL ,
RECORD_KEY VARCHAR2(200) NOT NULL ,
RESULT_STATUS INTEGER NOT NULL ,
RESULT_CODE VARCHAR2(100) ,
Expand All @@ -81,7 +82,7 @@ CREATE TABLE nop_batch_record_result(
CREATE_TIME TIMESTAMP NOT NULL ,
UPDATED_BY VARCHAR2(50) NOT NULL ,
UPDATE_TIME TIMESTAMP NOT NULL ,
constraint PK_nop_batch_record_result primary key (TASK_ID,RECORD_KEY)
constraint PK_nop_batch_record_result primary key (BATCH_TASK_ID,RECORD_KEY)
);


Expand All @@ -99,7 +100,7 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON COLUMN nop_batch_file.FILE_SOURCE IS '文件来源';

COMMENT ON COLUMN nop_batch_file.CURRENT_TASK_ID IS '当前处理任务';
COMMENT ON COLUMN nop_batch_file.BATCH_TASK_ID IS '批处理任务';

COMMENT ON COLUMN nop_batch_file.PROCESS_STATE IS '处理状态';

Expand Down Expand Up @@ -141,6 +142,8 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON COLUMN nop_batch_task.FLOW_STEP_ID IS '关联流程步骤ID';

COMMENT ON COLUMN nop_batch_task.FLOW_ID IS '关联流程ID';

COMMENT ON COLUMN nop_batch_task.RESTART_TIME IS '重启时间';

COMMENT ON COLUMN nop_batch_task.RESULT_STATUS IS '返回状态码';
Expand Down Expand Up @@ -181,7 +184,7 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON TABLE nop_batch_task_var IS '批处理任务状态变量';

COMMENT ON COLUMN nop_batch_task_var.TASK_ID IS '主键';
COMMENT ON COLUMN nop_batch_task_var.BATCH_TASK_ID IS '主键';

COMMENT ON COLUMN nop_batch_task_var.FIELD_NAME IS '变量名';

Expand Down Expand Up @@ -209,7 +212,7 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON TABLE nop_batch_record_result IS '批处理记录结果';

COMMENT ON COLUMN nop_batch_record_result.TASK_ID IS '主键';
COMMENT ON COLUMN nop_batch_record_result.BATCH_TASK_ID IS '主键';

COMMENT ON COLUMN nop_batch_record_result.RECORD_KEY IS '记录唯一键';

Expand Down
4 changes: 2 additions & 2 deletions nop-batch/deploy/sql/postgresql/_add_tenant_nop-batch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ alter table nop_batch_file drop constraint PK_nop_batch_file;
alter table nop_batch_file add constraint PK_nop_batch_file primary key (NOP_TENANT_ID, SID);

alter table nop_batch_record_result drop constraint PK_nop_batch_record_result;
alter table nop_batch_record_result add constraint PK_nop_batch_record_result primary key (NOP_TENANT_ID, TASK_ID,RECORD_KEY);
alter table nop_batch_record_result add constraint PK_nop_batch_record_result primary key (NOP_TENANT_ID, BATCH_TASK_ID,RECORD_KEY);

alter table nop_batch_task drop constraint PK_nop_batch_task;
alter table nop_batch_task add constraint PK_nop_batch_task primary key (NOP_TENANT_ID, SID);

alter table nop_batch_task_var drop constraint PK_nop_batch_task_var;
alter table nop_batch_task_var add constraint PK_nop_batch_task_var primary key (NOP_TENANT_ID, TASK_ID,FIELD_NAME);
alter table nop_batch_task_var add constraint PK_nop_batch_task_var primary key (NOP_TENANT_ID, BATCH_TASK_ID,FIELD_NAME);


21 changes: 12 additions & 9 deletions nop-batch/deploy/sql/postgresql/_create_nop-batch.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CREATE TABLE nop_batch_file(
FILE_LENGTH INT8 NOT NULL ,
FILE_CATEGORY VARCHAR(100) NOT NULL ,
FILE_SOURCE VARCHAR(10) NOT NULL ,
CURRENT_TASK_ID VARCHAR(32) NOT NULL ,
PROCESS_STATE INT4 NOT NULL ,
BATCH_TASK_ID VARCHAR(32) NOT NULL ,
PROCESS_STATE VARCHAR(10) NOT NULL ,
ACCEPT_DATE DATE NOT NULL ,
VERSION INT8 NOT NULL ,
CREATED_BY VARCHAR(50) NOT NULL ,
Expand All @@ -30,6 +30,7 @@ CREATE TABLE nop_batch_task(
WORKER_ID VARCHAR(100) NOT NULL ,
INPUT_FILE_ID VARCHAR(32) ,
FLOW_STEP_ID VARCHAR(50) ,
FLOW_ID VARCHAR(50) ,
RESTART_TIME TIMESTAMP ,
RESULT_STATUS INT4 ,
RESULT_CODE VARCHAR(100) ,
Expand All @@ -53,7 +54,7 @@ CREATE TABLE nop_batch_task(
);

CREATE TABLE nop_batch_task_var(
TASK_ID VARCHAR(32) NOT NULL ,
BATCH_TASK_ID VARCHAR(32) NOT NULL ,
FIELD_NAME VARCHAR(100) NOT NULL ,
FIELD_TYPE INT4 NOT NULL ,
STRING_VALUE VARCHAR(4000) ,
Expand All @@ -66,11 +67,11 @@ CREATE TABLE nop_batch_task_var(
CREATE_TIME TIMESTAMP NOT NULL ,
UPDATED_BY VARCHAR(50) NOT NULL ,
UPDATE_TIME TIMESTAMP NOT NULL ,
constraint PK_nop_batch_task_var primary key (TASK_ID,FIELD_NAME)
constraint PK_nop_batch_task_var primary key (BATCH_TASK_ID,FIELD_NAME)
);

CREATE TABLE nop_batch_record_result(
TASK_ID VARCHAR(32) NOT NULL ,
BATCH_TASK_ID VARCHAR(32) NOT NULL ,
RECORD_KEY VARCHAR(200) NOT NULL ,
RESULT_STATUS INT4 NOT NULL ,
RESULT_CODE VARCHAR(100) ,
Expand All @@ -81,7 +82,7 @@ CREATE TABLE nop_batch_record_result(
CREATE_TIME TIMESTAMP NOT NULL ,
UPDATED_BY VARCHAR(50) NOT NULL ,
UPDATE_TIME TIMESTAMP NOT NULL ,
constraint PK_nop_batch_record_result primary key (TASK_ID,RECORD_KEY)
constraint PK_nop_batch_record_result primary key (BATCH_TASK_ID,RECORD_KEY)
);


Expand All @@ -99,7 +100,7 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON COLUMN nop_batch_file.FILE_SOURCE IS '文件来源';

COMMENT ON COLUMN nop_batch_file.CURRENT_TASK_ID IS '当前处理任务';
COMMENT ON COLUMN nop_batch_file.BATCH_TASK_ID IS '批处理任务';

COMMENT ON COLUMN nop_batch_file.PROCESS_STATE IS '处理状态';

Expand Down Expand Up @@ -141,6 +142,8 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON COLUMN nop_batch_task.FLOW_STEP_ID IS '关联流程步骤ID';

COMMENT ON COLUMN nop_batch_task.FLOW_ID IS '关联流程ID';

COMMENT ON COLUMN nop_batch_task.RESTART_TIME IS '重启时间';

COMMENT ON COLUMN nop_batch_task.RESULT_STATUS IS '返回状态码';
Expand Down Expand Up @@ -181,7 +184,7 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON TABLE nop_batch_task_var IS '批处理任务状态变量';

COMMENT ON COLUMN nop_batch_task_var.TASK_ID IS '主键';
COMMENT ON COLUMN nop_batch_task_var.BATCH_TASK_ID IS '主键';

COMMENT ON COLUMN nop_batch_task_var.FIELD_NAME IS '变量名';

Expand Down Expand Up @@ -209,7 +212,7 @@ CREATE TABLE nop_batch_record_result(

COMMENT ON TABLE nop_batch_record_result IS '批处理记录结果';

COMMENT ON COLUMN nop_batch_record_result.TASK_ID IS '主键';
COMMENT ON COLUMN nop_batch_record_result.BATCH_TASK_ID IS '主键';

COMMENT ON COLUMN nop_batch_record_result.RECORD_KEY IS '记录唯一键';

Expand Down
Binary file modified nop-batch/model/nop-batch.orm.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public interface IBatchTaskContext extends IExecutionContext {

void setTaskKey(String taskKey);

String getFlowStepId();

void setFlowStepId(String flowStepId);

String getFlowId();

void setFlowId(String flowId);

/**
* 外部传入的只读参数,在任务执行过程中不会被修改
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class BatchTaskContextImpl extends ExecutionContextImpl implements IBatch
private IBatchTaskMetrics metrics;
private Boolean allowStartIfComplete;
private int startLimit;
private String flowStepId;
private String flowId;

private final AtomicLong skipItemCount = new AtomicLong();
private final AtomicLong completeItemCount = new AtomicLong();
Expand Down Expand Up @@ -120,6 +122,26 @@ public void setTaskKey(String taskKey) {
this.taskKey = taskKey;
}

@Override
public String getFlowStepId() {
return flowStepId;
}

@Override
public void setFlowStepId(String flowStepId) {
this.flowStepId = flowStepId;
}

@Override
public String getFlowId() {
return flowId;
}

@Override
public void setFlowId(String flowId) {
this.flowId = flowId;
}

@Override
public Map<String, Object> getParams() {
return params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class NopBatchRecordResultPkBuilder{
private Object[] values = new Object[2];


public NopBatchRecordResultPkBuilder setTaskId(java.lang.String value){
public NopBatchRecordResultPkBuilder setBatchTaskId(java.lang.String value){
this.values[0] = value;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class NopBatchTaskVarPkBuilder{
private Object[] values = new Object[2];


public NopBatchTaskVarPkBuilder setTaskId(java.lang.String value){
public NopBatchTaskVarPkBuilder setBatchTaskId(java.lang.String value){
this.values[0] = value;
return this;
}
Expand Down
Loading

0 comments on commit 3d8e4be

Please sign in to comment.