activity流程数据除脏

activity工作流业务数据被删除了,但是工作流还在流程中,要对这些数据除脏,提供以下SQL进行参考。


-- 筛选出business_key_ 的sql left join的具体表需要根据实际情况修改。workflowdefinitionKey需要根据实际情况修改。

UPDATE act_hi_taskinst
SET end_time_ = NOW(),
 delete_reason_ = 'DELETE'
WHERE
end_time_ IS NULL
AND proc_inst_id_ IN (
SELECT
proc_inst_id_
FROM
act_ru_execution
WHERE
business_key_ IN (
SELECT DISTINCT
are.BUSINESS_KEY_
FROM
act_ru_execution are
LEFT JOIN maint_fault_deferral_request mdr ON are.BUSINESS_KEY_ = mdr.uuid
WHERE
are.PROC_DEF_ID_ LIKE 'SC_Maint_Deferral_WorkFlow:%'
AND mdr.uuid IS NULL
)
AND proc_def_id_ LIKE 'SC_Maint_Deferral_WorkFlow:%'
);



DELETE
FROM
act_ru_task
WHERE
proc_inst_id_ IN (
SELECT
proc_inst_id_
FROM
act_hi_procinst
WHERE
business_key_ IN (
SELECT DISTINCT
are.BUSINESS_KEY_
FROM
act_ru_execution are
LEFT JOIN maint_fault_deferral_request mdr ON are.BUSINESS_KEY_ = mdr.uuid
WHERE
are.PROC_DEF_ID_ LIKE 'SC_Maint_Deferral_WorkFlow:%'
AND mdr.uuid IS NULL
)
AND proc_def_id_ LIKE 'SC_Maint_Deferral_WorkFlow:%'
AND end_time_ IS NULL
);



UPDATE act_hi_procinst
SET end_time_ = NOW(),
 delete_reason_ = 'DELETE'
WHERE
business_key_ IN (
SELECT DISTINCT
are.BUSINESS_KEY_
FROM
act_ru_execution are
LEFT JOIN maint_fault_deferral_request mdr ON are.BUSINESS_KEY_ = mdr.uuid
WHERE
are.PROC_DEF_ID_ LIKE 'SC_Maint_Deferral_WorkFlow:%'
AND mdr.uuid IS NULL
)
AND proc_def_id_ LIKE 'SC_Maint_Deferral_WorkFlow:%'
AND end_time_ IS NULL;

你可能感兴趣的:(java代码)