郑根木 пре 2 година
родитељ
комит
5c10cefdfd
1 измењених фајлова са 36 додато и 55 уклоњено
  1. +36
    -55
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java

+ 36
- 55
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java Прегледај датотеку

@@ -52,6 +52,9 @@ public class FlowInstance {

private FlowListener listener;

//提交驳回等之后的,属于我的新任务
private Task nextMyTask;

public static FlowInstance createById(UserSession us, FlowListener listener, long billId, long taskId) {
FlowInstance flowInstance = new FlowInstance(listener, us);
flowInstance.load(billId, taskId);
@@ -261,9 +264,13 @@ public class FlowInstance {
for (Task act : list) {
//如果办理人是当前用户,则置此任务为当前任务
//我办理中的任务:非待办,且是我的任务
if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && FlowHelper.isMyWaitedTask(act.getId(), us.getUserId())) {
//我的待办任务,设下值,为后面的按钮判断减轻负担
act.setHandler(us.getUserId());
if (act.getId() == actInst.getId()) {
act = actInst;

if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && FlowHelper.isMyWaitedTask(act.getId(), us.getUserId())) {
//我的待办任务,设下值,为后面的按钮判断减轻负担
act.setHandler(us.getUserId());
}
}
//如果当前任务为待办理,那么要找其前置任务,作为活动任务,方便取回
if (act.getStatu() == FlowConst.ActivityStatu.WAIT.value && !act.isReject() && !act.isRetake()) {
@@ -528,13 +535,8 @@ public class FlowInstance {
actInst.setStatu(FlowConst.ActivityStatu.SUBMIT.value);
actInst.setRetake(false);

if (listInsertTask.size() > 0) {
procInst.setTaskId(listInsertTask.get(0).getEntityId());
procInst.setActName(listInsertTask.get(0).getActName());
} else {
procInst.setTaskId(actInst.getEntityId());
procInst.setActName(actInst.getActName());
}
procInst.setTaskId(listInsertTask.get(0).getEntityId());
procInst.setActName(listInsertTask.get(0).getActName());

if (new_acts.size() == 1 && new_acts.get(0).getType() == FlowConst.ActivityType.END.value) {
procInst.setStatu(FlowConst.InstanceStatu.FINISH.value);
@@ -544,7 +546,6 @@ public class FlowInstance {
}

//保存入库
if (!listInsertTask.isEmpty()) {
getTaskDao().batchInsertEntity(listInsertTask);
getCandidateDao().batchInsertEntity(listInsertCand);
getTaskRelDao().batchInsertEntity(listTaskRel);
@@ -552,13 +553,16 @@ public class FlowInstance {
if (!listTaskComment.isEmpty()) {
getCommentDao().batchInsertEntity(listTaskComment);
}
}
getTaskDao().updateEntity(actInst);
getProcInstDao().updateEntity(procInst);

updateComment(comment, FlowConst.Button.SUBMIT.value);
buildBillLog(FlowConst.Button.SUBMIT.value, comment, actInst, listInsertTask);
listener.afterSubmit(actInst, listInsertTask);

//设置当前步骤
actInst = nextMyTask != null ? nextMyTask : listInsertTask.get(0);
}

/**
@@ -646,6 +650,9 @@ public class FlowInstance {
}
for (Long user_id : listHander) {
// if (act.getHandler().getIgnore() && user_id == submit_user) continue;
if (nextMyTask == null && user_id == us.getUserId()) {
nextMyTask = task;
}
Candidate cand = new Candidate();
cand.init();
cand.setEntityId(DbEngine.getInstance().nextId());
@@ -679,34 +686,7 @@ public class FlowInstance {
}
Activity activityEntity = procDef.getProcInfo().findActivity(actInst.getActId());
EntityDao<Task> taskDao = getTaskDao();
if (activityEntity.getType() == FlowConst.ActivityType.END.value) {//从结束取回
List<Task> new_acts = provider.findBeforeTasks(actInst.getId());
Task old_act = (Task) actInst.clone();
old_act.setEntityId(actInst.getEntityId());

actInst = new_acts.get(0);
actInst.setHandler(user_id);
actInst.setStartTime(DateUtil.nowDateTimeLong());
actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value);
if (actInst.isMake()) {
actInst.setHandler(user_id);
}

procInst.setTaskId(actInst.getEntityId());
procInst.setActName(actInst.getActName());
procInst.setStatu(actInst.isMake() ? FlowConst.InstanceStatu.BEGIN.value: FlowConst.InstanceStatu.RUNING.value);

taskDao.updateEntity(actInst);
taskDao.deleteEntity(old_act);
getTaskRelDao().deleteEntity("where trl_src_task_id=?", old_act.getId());
getProcInstDao().updateEntity(procInst);
getCommentDao().deleteEntity("where cmt_tsk_id=?", old_act.getId());
new_acts.clear();
new_acts.add(old_act);
buildBillLog(FlowConst.Button.RETAKE.value, "TODO", actInst, new_acts);
listener.afterRetake(actInst, new_acts);
// comp.transCallback(FlowConst.Button.RETAKE.value, actInst, new_acts);
} else {
List<Task> new_acts = provider.findAfterTasks(actInst.getId());

for (Task act : new_acts) {
@@ -734,7 +714,6 @@ public class FlowInstance {
updateComment(null, FlowConst.Button.RETAKE.value);
buildBillLog(FlowConst.Button.RETAKE.value, "TODO", actInst, new_acts);
listener.afterRetake(actInst, new_acts);
}
}

/**
@@ -767,6 +746,7 @@ public class FlowInstance {
//待新增任务候选人
List<Candidate> listInsertCand = new ArrayList<>();

nextMyTask = null;
//校验完毕,接下来干活。
//并发考虑:找到此任务的前置任务,创建对应的新任务,原流程其他未办理任务删除,办理中及已提交的,置为
for (String dstTaskId : dstTasks) {
@@ -778,31 +758,30 @@ public class FlowInstance {
buildRejectTask(toTask, listInsertTask, listInsertCand, listTaskRel, listTaskComment);
}
actInst.setStatu(FlowConst.ActivityStatu.REJECT.value);
if (listInsertTask.size() > 0) {
procInst.setTaskId(listInsertTask.get(0).getEntityId());
procInst.setActName(listInsertTask.get(0).getActName());
} else {
procInst.setTaskId(actInst.getEntityId());
procInst.setActName(actInst.getActName());
}

procInst.setTaskId(listInsertTask.get(0).getEntityId());
procInst.setActName(listInsertTask.get(0).getActName());

//先停止其他待办或办理中的任务
FlowHelper.stopTask(procInst.getId(), actInst.getId());
//保存入库
if (!listInsertTask.isEmpty()) {
getTaskDao().batchInsertEntity(listInsertTask);
getCandidateDao().batchInsertEntity(listInsertCand);
getTaskRelDao().batchInsertEntity(listTaskRel);

if (!listTaskComment.isEmpty()) {
getCommentDao().batchInsertEntity(listTaskComment);
}
getTaskDao().batchInsertEntity(listInsertTask);
getCandidateDao().batchInsertEntity(listInsertCand);
getTaskRelDao().batchInsertEntity(listTaskRel);

if (!listTaskComment.isEmpty()) {
getCommentDao().batchInsertEntity(listTaskComment);
}

getTaskDao().updateEntity(actInst);
getProcInstDao().updateEntity(procInst);

updateComment(comment, FlowConst.Button.REJECT.value);
buildBillLog(FlowConst.Button.SUBMIT.value, comment, actInst, listInsertTask);
listener.afterSubmit(actInst, listInsertTask);

actInst = nextMyTask != null ? nextMyTask: listInsertTask.get(0);
}

private void buildRejectTask(Task oldTask, List<Task> listInsertTask, List<Candidate> listInsertCand, List<TaskRel> listTaskRel, List<Comment> listTaskComment) {
@@ -827,7 +806,9 @@ public class FlowInstance {
cand.setPriId(task.getPriId());
cand.setTskId(task.getId());
cand.setUserId(oldTask.getHandler());

if (nextMyTask == null && task.getHandler() == us.getUserId()) {
nextMyTask = task;
}
listInsertCand.add(cand);

//创建新的审批意见


Loading…
Откажи
Сачувај