1. 程式人生 > >處理流程已辦完,選擇一個節點,新增一條待辦

處理流程已辦完,選擇一個節點,新增一條待辦

---找到流程例項id---
select * from ACT_HI_PROCINST t where t.proc_inst_id_ in (select distinct t.proc_inst_id_ from ACT_HI_VARINST t where t.text_='402880e8641c8f260164491e12e800f0')


---確認記錄-----911477
select t.*, t.rowid from ACT_RU_EXECUTION t where t.proc_inst_id_='911477';

---如果沒有,先找最後任務的id----- 如id_為920600
select * from ACT_HI_TASKINST t where t.proc_inst_id_=911477 order by t.start_time_ asc;

----往ACT_RU_EXECUTION插入一條記錄,缺少REV_,BUSINESS_KEY_賦值----注意CACHED_ENT_STATE_ 0代表會籤加號上的節點,2代表一般,7代表會籤的節點
insert into ACT_RU_EXECUTION  (
ID_,PROC_INST_ID_,PROC_DEF_ID_,ACT_ID_,IS_ACTIVE_,IS_CONCURRENT_,IS_SCOPE_,IS_EVENT_SCOPE_,SUSPENSION_STATE_,CACHED_ENT_STATE_
) 
(select 
PROC_INST_ID_,PROC_INST_ID_,PROC_DEF_ID_,TASK_DEF_KEY_,1,0,1,0,1,2 from ACT_HI_TASKINST where ID_=920600);

--BUSINESS_KEY_賦值----
update ACT_RU_EXECUTION set BUSINESS_KEY_=
(
select t0.business_key_ from ACT_HI_PROCINST t0 
where t0.id_=
(
select max(t.id_) from ACT_HI_PROCINST t where t.proc_inst_id_ in (select distinct t.proc_inst_id_ from ACT_HI_VARINST t where t.text_='402880e8641c8f260164491e12e800f0')
)
) where proc_inst_id_='911477' and BUSINESS_KEY_ is null;

----REV_賦值--------
update ACT_RU_EXECUTION set REV_=(
select t.rev_ from ACT_RE_PROCDEF t where t.id_=(select t1.proc_def_id_ from ACT_HI_TASKINST t1 where t1.id_=920600))
where proc_inst_id_='911477' and REV_ is null;

---新增待辦-----
insert into ACT_RU_TASK(ID_,EXECUTION_ID_,PROC_INST_ID_,PROC_DEF_ID_,NAME_,PARENT_TASK_ID_,DESCRIPTION_,TASK_DEF_KEY_,OWNER_,ASSIGNEE_,PRIORITY_,CREATE_TIME_,DUE_DATE_,CATEGORY_,TENANT_ID_,FORM_KEY_)  
(select ID_,EXECUTION_ID_,PROC_INST_ID_,PROC_DEF_ID_,NAME_,PARENT_TASK_ID_,DESCRIPTION_,TASK_DEF_KEY_,OWNER_,ASSIGNEE_,PRIORITY_,START_TIME_,DUE_DATE_,CATEGORY_,TENANT_ID_,FORM_KEY_ from ACT_HI_TASKINST where ID_=920600);


--更新ACT_RU_TASK
UPDATE ACT_RU_TASK t0
SET (REV_,SUSPENSION_STATE_) = (
select t.rev_,t.suspension_state_ from ACT_RE_PROCDEF t where t.id_=(select t1.proc_def_id_ from ACT_HI_TASKINST t1 where t1.id_=920600)
) 
where t0.ID_=920600;


--新增待辦候選人
insert into ACT_RU_IDENTITYLINK(ID_,GROUP_ID_,TYPE_,USER_ID_,TASK_ID_,PROC_INST_ID_)
(select ID_,GROUP_ID_,TYPE_,USER_ID_,TASK_ID_,PROC_INST_ID_ from ACT_HI_IDENTITYLINK t where t.task_id_=920600);