|
|
@@ -20,6 +20,7 @@ import cc.smtweb.system.bpm.web.sys.user.dept.DeptCache; |
|
|
|
import cc.smtweb.system.bpm.web.sys.user.party.Party; |
|
|
|
import cc.smtweb.system.bpm.web.sys.user.party.PartyCache; |
|
|
|
import cc.smtweb.system.bpm.web.sys.user.user.UserCache; |
|
|
|
import cc.smtweb.system.bpm.web.sys.user.userGroup.UserGroupHelper; |
|
|
|
import lombok.Data; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
@@ -164,8 +165,8 @@ public class FlowInstance { |
|
|
|
procInst.setTaskId(actInst.getEntityId()); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
|
|
|
|
DbEngine.getInstance().findDao(Task.ENTITY_NAME).updateEntity(actInst); |
|
|
|
DbEngine.getInstance().findDao(ProcInst.ENTITY_NAME).updateEntity(procInst); |
|
|
|
getTaskDao().updateEntity(actInst); |
|
|
|
getProcInstDao().updateEntity(procInst); |
|
|
|
|
|
|
|
buildBillLog(FlowConst.Button.HANDLE.value, actInst, null); |
|
|
|
// comp.transCallback(FlowConst.FlowOptType.RETAKE.value, act_inst, null); |
|
|
@@ -204,10 +205,12 @@ public class FlowInstance { |
|
|
|
if (task_id > 0L) return task_id; |
|
|
|
Task curTask = provider.findTask(task_id); |
|
|
|
if (EntityHelper.isEmpty(curTask) || curTask.getStatu() != FlowConst.ActivityStatu.WAIT.value) return task_id; |
|
|
|
Task preAct = provider.findBeforeTask(task_id); |
|
|
|
if (EntityHelper.isEmpty(preAct)) return task_id; |
|
|
|
if (preAct.getHandler() == us.getUserId()) { |
|
|
|
return preAct.getId(); |
|
|
|
List<Task> preActs = provider.findBeforeTasks(task_id); |
|
|
|
if (CommUtil.isEmpty(preActs)) return task_id; |
|
|
|
for (Task act: preActs) { |
|
|
|
if (act.getHandler() == us.getUserId()) { |
|
|
|
return act.getId(); |
|
|
|
} |
|
|
|
} |
|
|
|
return task_id; |
|
|
|
} |
|
|
@@ -385,7 +388,7 @@ public class FlowInstance { |
|
|
|
boolean handler_make = isHandleMakeEx(act); |
|
|
|
|
|
|
|
//当前任务是我办理的(我的待办任务,前面读取的时候也已经写了办理人为我了): |
|
|
|
if (act == null || act.getActType() == FlowConst.ActivityType.endEvent.value) { |
|
|
|
if (act == null || act.getType() == FlowConst.ActivityType.END.value) { |
|
|
|
if (isAdmin) buttons.put(FlowConst.Button.RETAKE, 1); |
|
|
|
buttons.put(FlowConst.Button.DISUSE, 0); |
|
|
|
} else if (user_id.equalsIgnoreCase(actInst.getHandler()) || isAdmin) { |
|
|
@@ -478,7 +481,7 @@ public class FlowInstance { |
|
|
|
List<Candidate> listInsertCand = new ArrayList<>(); |
|
|
|
|
|
|
|
for (Activity act : new_acts) { |
|
|
|
// buildTask(act, listInsertTask, listInsertCand, listTaskRel, user_id); todo |
|
|
|
buildTask(act, listInsertTask, listInsertCand, listTaskRel, user_id); |
|
|
|
} |
|
|
|
|
|
|
|
actInst.setHandler(user_id); |
|
|
@@ -517,115 +520,105 @@ public class FlowInstance { |
|
|
|
* |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
/* |
|
|
|
public void submit(AbsBillWfComponent comp) { |
|
|
|
String user_id = context.getLoginInfo().getUserId(); |
|
|
|
public void submit() { |
|
|
|
long user_id = us.getUserId(); |
|
|
|
//校验权限,当前人员有权限干不,没权限直接抛异常 |
|
|
|
checkPermission(); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.SUBMIT.value) { |
|
|
|
throw new DfpException("当前任务已经提交,不能重复提交"); |
|
|
|
throw new BizException("当前任务已经提交,不能重复提交"); |
|
|
|
} |
|
|
|
|
|
|
|
ActinstDao actDao = new ActinstDao(); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && !actDao.isMyWaitedTask(actInst.getEntityId(), user_id) && !UserBaseEntityBuffer.getInstance().isAdmin(user_id)) { |
|
|
|
throw new DfpException("您不是当前任务的办理人,不允许提交"); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && !FlowHelper.isMyWaitedTask(actInst.getEntityId(), user_id)) { |
|
|
|
throw new BizException("您不是当前任务的办理人,不允许提交"); |
|
|
|
} |
|
|
|
//校验完毕,接下来干活。todo:流程定义需要控制一下,非判断/并发分支不允许多个出口 |
|
|
|
List<ActivityEntity> new_acts = BillHelper.getNextActivity(comp); |
|
|
|
//校验完毕,接下来干活。 |
|
|
|
List<Activity> new_acts = FlowHelper.getNextActivity(this); |
|
|
|
|
|
|
|
//待新增任务 |
|
|
|
List<Task> listInsertTask = new ArrayList<>(); |
|
|
|
List<ActinstRelEntity> listTaskRel = new ArrayList<>(); |
|
|
|
List<TaskRel> listTaskRel = new ArrayList<>(); |
|
|
|
//待新增任务候选人 |
|
|
|
List<CandidateEntity> listInsertCand = new ArrayList<>(); |
|
|
|
List<Candidate> listInsertCand = new ArrayList<>(); |
|
|
|
|
|
|
|
for (ActivityEntity act : new_acts) { |
|
|
|
for (Activity act : new_acts) { |
|
|
|
buildTask(act, listInsertTask, listInsertCand, listTaskRel, user_id); |
|
|
|
} |
|
|
|
|
|
|
|
actInst.setHandler(user_id); |
|
|
|
actInst.setStartTime(UtilDateTime.nowDateTimeString()); |
|
|
|
actInst.setstatu(FlowConst.ActivityStatu.SUBMIT.value); |
|
|
|
actInst.setStartTime(DateUtil.nowDateTimeLong()); |
|
|
|
actInst.setStatu(FlowConst.ActivityStatu.SUBMIT.value); |
|
|
|
actInst.setRetake(true); |
|
|
|
|
|
|
|
if (listInsertTask.size() > 0) { |
|
|
|
procInst.setTaskId(listInsertTask.get(0).getEntityId()); |
|
|
|
procInst.setTaskName(ActivityEntityBuffer.getInstance().getNameById(listInsertTask.get(0).getActId())); |
|
|
|
} else { |
|
|
|
procInst.setTaskId(actInst.getEntityId()); |
|
|
|
procInst.setTaskName(ActivityEntityBuffer.getInstance().getNameById(actInst.getActId())); |
|
|
|
} |
|
|
|
|
|
|
|
if (new_acts.size() == 1 && new_acts.get(0).getActType() == FlowConst.ActivityType.endEvent.value) { |
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.FINISH.value); |
|
|
|
procInst.setEndTime(UtilDateTime.nowDateTimeString()); |
|
|
|
if (new_acts.size() == 1 && new_acts.get(0).getType() == FlowConst.ActivityType.END.value) { |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.FINISH.value); |
|
|
|
procInst.setEndTime(DateUtil.nowDateTimeLong()); |
|
|
|
} else { |
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
} |
|
|
|
|
|
|
|
//保存入库 |
|
|
|
if (!listInsertTask.isEmpty()) { |
|
|
|
actDao.batchInsert(listInsertTask); |
|
|
|
new CandidateDao().batchInsert(listInsertCand); |
|
|
|
new ActinstRelDao().batchInsert(listTaskRel); |
|
|
|
getTaskDao().batchInsertEntity(listInsertTask); |
|
|
|
getCandidateDao().batchInsertEntity(listInsertCand); |
|
|
|
getTaskRelDao().batchInsertEntity(listTaskRel); |
|
|
|
} |
|
|
|
actDao.update(actInst); |
|
|
|
new ProcinstDao().update(procInst); |
|
|
|
getTaskDao().updateEntity(actInst); |
|
|
|
getProcInstDao().updateEntity(procInst); |
|
|
|
|
|
|
|
buildBillLog(FlowConst.FlowOptType.SUBMIT.value, actInst, listInsertTask); |
|
|
|
comp.transCallback(FlowConst.FlowOptType.SUBMIT.value, actInst, listInsertTask); |
|
|
|
buildBillLog(FlowConst.Button.SUBMIT.value, actInst, listInsertTask); |
|
|
|
// comp.transCallback(FlowConst.Button.SUBMIT.value, actInst, listInsertTask); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void checkSubmit(AbsBillWfComponent comp) { |
|
|
|
String user_id = context.getLoginInfo().getUserId(); |
|
|
|
public void checkSubmit() { |
|
|
|
long user_id = us.getUserId(); |
|
|
|
//校验权限,当前人员有权限干不,没权限直接抛异常 |
|
|
|
checkPermission(); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.SUBMIT.value) { |
|
|
|
throw new DfpException("当前任务已经提交,不能重复提交"); |
|
|
|
throw new BizException("当前任务已经提交,不能重复提交"); |
|
|
|
} |
|
|
|
ActinstDao actDao = new ActinstDao(); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && !actDao.isMyWaitedTask(actInst.getEntityId(), user_id) && !UserBaseEntityBuffer.getInstance().isAdmin(user_id)) { |
|
|
|
throw new DfpException("您不是当前任务的办理人,不允许提交"); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && !FlowHelper.isMyWaitedTask(actInst.getEntityId(), user_id)) { |
|
|
|
throw new BizException("您不是当前任务的办理人,不允许提交"); |
|
|
|
} |
|
|
|
comp.checkSubmit(FlowConst.FlowOptType.SUBMIT.value, actInst); |
|
|
|
//comp.checkSubmit(FlowConst.FlowOptType.SUBMIT.value, actInst); |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 作废 |
|
|
|
* |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
/* |
|
|
|
public void disuse(AbsBillWfComponent comp) { |
|
|
|
String user_id = context.getLoginInfo().getUserId(); |
|
|
|
public void disuse() { |
|
|
|
long user_id = us.getUserId(); |
|
|
|
//校验权限,当前人员有权限干不,没权限直接抛异常 |
|
|
|
checkPermission(); |
|
|
|
if (procInst.getStatu() == FlowConst.InstanceStatu.FINISH.value) { |
|
|
|
throw new DfpException("当前单据已审批完成,不能作废单据"); |
|
|
|
throw new BizException("当前单据已审批完成,不能作废单据"); |
|
|
|
} |
|
|
|
|
|
|
|
ActinstDao actDao = new ActinstDao(); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && !actDao.isMyWaitedTask(actInst.getEntityId(), user_id) && !UserBaseEntityBuffer.getInstance().isAdmin(user_id)) { |
|
|
|
throw new DfpException("您不是当前任务的办理人,不允许作废"); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && !FlowHelper.isMyWaitedTask(actInst.getEntityId(), user_id)) { |
|
|
|
throw new BizException("您不是当前任务的办理人,不允许作废"); |
|
|
|
} |
|
|
|
|
|
|
|
actInst.setHandler(user_id); |
|
|
|
actInst.setStartTime(UtilDateTime.nowDateTimeString()); |
|
|
|
actInst.setstatu(FlowConst.ActivityStatu.DISUSE.value); |
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.DISUSE.value); |
|
|
|
procInst.setEndTime(UtilDateTime.nowDateTimeString()); |
|
|
|
actInst.setStartTime(DateUtil.nowDateTimeLong()); |
|
|
|
actInst.setStatu(FlowConst.ActivityStatu.DISUSE.value); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.DISUSE.value); |
|
|
|
procInst.setEndTime(DateUtil.nowDateTimeLong()); |
|
|
|
|
|
|
|
actDao.update(actInst); |
|
|
|
new ProcinstDao().update(procInst); |
|
|
|
getTaskDao().updateEntity(actInst); |
|
|
|
getProcInstDao().updateEntity(procInst); |
|
|
|
|
|
|
|
buildBillLog(FlowConst.FlowOptType.DISUSE.value, actInst, null); |
|
|
|
comp.transCallback(FlowConst.FlowOptType.DISUSE.value, actInst, null); |
|
|
|
buildBillLog(FlowConst.Button.DISUSE.value, actInst, null); |
|
|
|
// comp.transCallback(FlowConst.FlowOptType.DISUSE.value, actInst, null); |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交创建任务 |
|
|
|
* |
|
|
@@ -635,237 +628,215 @@ public class FlowInstance { |
|
|
|
* @param listTaskRel |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
/* |
|
|
|
private void buildTask(ActivityEntity act, List<Task> listInsertTask, List<CandidateEntity> listInsertCand, List<ActinstRelEntity> listTaskRel, String submit_user) { |
|
|
|
private void buildTask(Activity act, List<Task> listInsertTask, List<Candidate> listInsertCand, List<TaskRel> listTaskRel, long submit_user) { |
|
|
|
Task task = new Task(); |
|
|
|
listInsertTask.add(task); |
|
|
|
task.init(); |
|
|
|
task.setEntityId(PKGenerator.newId()); |
|
|
|
task.setBillId(procInst.getEntityId()); |
|
|
|
task.setProcDefId(procDef.getEntityId()); |
|
|
|
task.setActId(act.getEntityId()); |
|
|
|
task.setStartTime(UtilDateTime.nowDateTimeString()); |
|
|
|
task.setstatu(FlowConst.ActivityStatu.WAIT.value); |
|
|
|
task.setEntityId(DbEngine.getInstance().nextId()); |
|
|
|
task.setPriId(procInst.getId()); |
|
|
|
task.setPriId(procDef.getId()); |
|
|
|
task.setActId(act.getId()); |
|
|
|
task.setStartTime(DateUtil.nowDateTimeLong()); |
|
|
|
task.setStatu(FlowConst.ActivityStatu.WAIT.value); |
|
|
|
task.setMake(false); |
|
|
|
task.setSign(false); |
|
|
|
task.setReject(false); |
|
|
|
task.setRetake(false); |
|
|
|
task.setAuto(false); |
|
|
|
task.setIsAuto(false); |
|
|
|
|
|
|
|
ActinstRelEntity rel = new ActinstRelEntity(); |
|
|
|
rel.setEntityId(PKGenerator.newId()); |
|
|
|
rel.setBillId(task.getBillId()); |
|
|
|
rel.setTaskId(task.getEntityId()); |
|
|
|
rel.setBeforeTaskBid(actInst.getEntityId()); |
|
|
|
TaskRel rel = new TaskRel(); |
|
|
|
rel.setEntityId(DbEngine.getInstance().nextId()); |
|
|
|
rel.setPriId(task.getPriId()); |
|
|
|
rel.setDstTaskId(task.getId()); |
|
|
|
rel.setSrcTaskId(actInst.getId()); |
|
|
|
listTaskRel.add(rel); |
|
|
|
|
|
|
|
if (act.getActType() != FlowConst.ActivityType.endEvent.value) { |
|
|
|
boolean handler_make = isHandleMakeEx(act); |
|
|
|
Set<String> listHander = new HashSet<>(); |
|
|
|
if (handler_make) { |
|
|
|
listHander.add(procInst.getUserId()); |
|
|
|
} else { |
|
|
|
String hanlder_group = BillFlowWfHelper.getPropStr(procInst.getProcDefId(), act.getEntityId(), FlowConst.ProcProperty.HANDLER); |
|
|
|
int handler_range = BillFlowWfHelper.getPropInt(procInst.getProcDefId(), act.getActId(), FlowConst.ProcProperty.HANDLER_RANGE); |
|
|
|
//获取所有候选人 |
|
|
|
listHander = UserGroupHelper.getUserIdList(hanlder_group, procInst, handler_range, context); |
|
|
|
} |
|
|
|
if (UserBaseEntityBuffer.getInstance().isAdmin(context.getLoginInfo().getUserId()) && UtilPub.isEmpty(listHander)) { |
|
|
|
listHander = new HashSet<>(); |
|
|
|
listHander.add(context.getLoginInfo().getUserId()); |
|
|
|
} |
|
|
|
if (UtilPub.isEmpty(listHander)) { |
|
|
|
throw new DfpException("没有符合条件的主办人!" + act.getActName()); |
|
|
|
if (act.getType() != FlowConst.ActivityType.END.value) { |
|
|
|
Set<Long> listHander = new HashSet<>(); |
|
|
|
|
|
|
|
long hanlder_group = act.getHandler().getUserGroup(); |
|
|
|
int handler_range = act.getHandler().getFilter(); |
|
|
|
//获取所有候选人 |
|
|
|
listHander = UserGroupHelper.getUserIdList(hanlder_group, procInst, handler_range, us); |
|
|
|
|
|
|
|
if (CommUtil.isEmpty(listHander)) { |
|
|
|
throw new BizException("没有符合条件的主办人!" + act.getLabel()); |
|
|
|
} |
|
|
|
for (String user_id : listHander) { |
|
|
|
if (act.getActIgnore() && user_id.equals(submit_user)) continue; |
|
|
|
CandidateEntity cand = new CandidateEntity(); |
|
|
|
for (Long user_id : listHander) { |
|
|
|
// if (act.getHandler().getIgnore() && user_id == submit_user) continue; |
|
|
|
Candidate cand = new Candidate(); |
|
|
|
cand.init(); |
|
|
|
cand.setEntityId(PKGenerator.newId()); |
|
|
|
cand.setBillId(task.getBillId()); |
|
|
|
cand.setTaskId(task.getEntityId()); |
|
|
|
cand.setEntityId(DbEngine.getInstance().nextId()); |
|
|
|
cand.setPriId(task.getPriId()); |
|
|
|
cand.setTskId(task.getId()); |
|
|
|
cand.setUserId(user_id); |
|
|
|
|
|
|
|
listInsertCand.add(cand); |
|
|
|
} |
|
|
|
if (UtilPub.isEmpty(listInsertCand)) { |
|
|
|
throw new DfpException("没有符合条件的主办人!" + act.getActName()); |
|
|
|
if (CommUtil.isEmpty(listInsertCand)) { |
|
|
|
throw new BizException("没有符合条件的主办人!" + act.getLabel()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 取回 |
|
|
|
* |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
/* |
|
|
|
public void retake(AbsBillWfComponent comp) { |
|
|
|
String user_id = context.getLoginInfo().getUserId(); |
|
|
|
public void retake() { |
|
|
|
long user_id = us.getUserId(); |
|
|
|
//校验权限,当前人员有权限干不,没权限直接抛异常 |
|
|
|
checkPermission(); |
|
|
|
if (actInst.getStatu() != FlowConst.ActivityStatu.SUBMIT.value && !UserBaseEntityBuffer.getInstance().isAdmin(user_id)) { |
|
|
|
throw new DfpException("当前任务非提交状态,不能取回!"); |
|
|
|
if (actInst.getStatu() != FlowConst.ActivityStatu.SUBMIT.value) { |
|
|
|
throw new BizException("当前任务非提交状态,不能取回!"); |
|
|
|
} |
|
|
|
ActinstDao actDao = new ActinstDao(); |
|
|
|
ActivityEntity activityEntity = ActivityEntityBuffer.getInstance().get(actInst.getActId()); |
|
|
|
if (activityEntity.getActType() == FlowConst.ActivityType.endEvent.value) {//从结束取回 |
|
|
|
List<Task> new_acts = actDao.findBeforeTasks(actInst.getEntityId()); |
|
|
|
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(UtilDateTime.nowDateTimeString()); |
|
|
|
actInst.setstatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
actInst.setStartTime(DateUtil.nowDateTimeLong()); |
|
|
|
actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
if (actInst.isMake()) { |
|
|
|
actInst.setHandler(comp.billEntity.getBillUser()); |
|
|
|
actInst.setHandler(user_id); |
|
|
|
} |
|
|
|
|
|
|
|
procInst.setTaskId(actInst.getEntityId()); |
|
|
|
procInst.setTaskName(ActivityEntityBuffer.getInstance().getNameById(actInst.getActId())); |
|
|
|
procInst.setstatu(actInst.isMake() ? FlowConst.InstanceStatu.BEGIN.value : FlowConst.InstanceStatu.RUNING.value); |
|
|
|
procInst.setStatu(actInst.isMake() ? FlowConst.InstanceStatu.BEGIN.value : FlowConst.InstanceStatu.RUNING.value); |
|
|
|
|
|
|
|
actDao.update(actInst); |
|
|
|
actDao.delete(old_act); |
|
|
|
new ActinstRelDao().deleteAll("where before_task_bid=?", old_act.getEntityId()); |
|
|
|
new ProcinstDao().update(procInst); |
|
|
|
taskDao.updateEntity(actInst); |
|
|
|
taskDao.deleteEntity(old_act); |
|
|
|
getTaskRelDao().deleteEntity("where trl_src_task_id=?", old_act.getId()); |
|
|
|
getProcInstDao().updateEntity(procInst); |
|
|
|
new_acts.clear(); |
|
|
|
new_acts.add(old_act); |
|
|
|
buildBillLog(FlowConst.FlowOptType.RETAKE.value, actInst, new_acts); |
|
|
|
comp.transCallback(FlowConst.FlowOptType.RETAKE.value, actInst, new_acts); |
|
|
|
buildBillLog(FlowConst.Button.RETAKE.value, actInst, new_acts); |
|
|
|
// comp.transCallback(FlowConst.Button.RETAKE.value, actInst, new_acts); |
|
|
|
} else { |
|
|
|
|
|
|
|
List<Task> new_acts = actDao.findAfterTasks(actInst.getEntityId()); |
|
|
|
List<Task> new_acts = provider.findAfterTasks(actInst.getId()); |
|
|
|
|
|
|
|
for (Task act : new_acts) { |
|
|
|
if (act.getStatu() != FlowConst.ActivityStatu.WAIT.value) { |
|
|
|
throw new DfpException("后续任务[" + ActivityEntityBuffer.getInstance().getNameById(act.getActId()) + "]已经办理,不能取回!"); |
|
|
|
throw new BizException("后续任务[" + procDef.getProcInfo().getActNameById(act.getActId()) + "]已经办理,不能取回!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
actInst.setHandler(user_id); |
|
|
|
actInst.setStartTime(UtilDateTime.nowDateTimeString()); |
|
|
|
actInst.setstatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
actInst.setStartTime(DateUtil.nowDateTimeLong()); |
|
|
|
actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
|
|
|
|
procInst.setTaskId(actInst.getEntityId()); |
|
|
|
procInst.setTaskName(ActivityEntityBuffer.getInstance().getNameById(actInst.getActId())); |
|
|
|
|
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
if (actInst.isMake()) procInst.setstatu(FlowConst.InstanceStatu.BEGIN.value); |
|
|
|
actDao.update(actInst); |
|
|
|
actDao.batchDelete(new_acts); |
|
|
|
new ActinstRelDao().deleteAll("where before_task_bid=?", actInst.getEntityId()); |
|
|
|
new ProcinstDao().update(procInst); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
if (actInst.isMake()) procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); |
|
|
|
|
|
|
|
taskDao.updateEntity(actInst); |
|
|
|
taskDao.batchDelete(new_acts); |
|
|
|
getTaskRelDao().deleteEntity("where trl_src_task_id=?", actInst.getEntityId()); |
|
|
|
getProcInstDao().updateEntity(procInst); |
|
|
|
|
|
|
|
buildBillLog(FlowConst.FlowOptType.RETAKE.value, actInst, new_acts); |
|
|
|
comp.transCallback(FlowConst.FlowOptType.RETAKE.value, actInst, new_acts); |
|
|
|
buildBillLog(FlowConst.Button.RETAKE.value, actInst, new_acts); |
|
|
|
// comp.transCallback(FlowConst.FlowOptType.RETAKE.value, actInst, new_acts); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 驳回 |
|
|
|
* |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
/* |
|
|
|
public void reject(AbsBillWfComponent comp) { |
|
|
|
String user_id = context.getLoginInfo().getUserId(); |
|
|
|
public void reject() { |
|
|
|
long user_id = us.getUserId(); |
|
|
|
//校验权限,当前人员有权限干不,没权限直接抛异常 |
|
|
|
checkPermission(); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.SUBMIT.value) { |
|
|
|
throw new DfpException("当前任务已提交,不能驳回!"); |
|
|
|
throw new BizException("当前任务已提交,不能驳回!"); |
|
|
|
} |
|
|
|
|
|
|
|
ActinstDao actDao = new ActinstDao(); |
|
|
|
//获取前置任务,前置任务需要置为被驳回的办理状态,同时,前置任务的其他后置任务需要删除 |
|
|
|
List<Task> new_acts = actDao.findBeforeTasks(actInst.getEntityId()); |
|
|
|
if (UtilPub.isEmpty(new_acts)) { |
|
|
|
throw new DfpException("没有找到前续任务,驳回失败!"); |
|
|
|
List<Task> new_acts = provider.findBeforeTasks(actInst.getEntityId()); |
|
|
|
if (CommUtil.isEmpty(new_acts)) { |
|
|
|
throw new BizException("没有找到前续任务,驳回失败!"); |
|
|
|
} |
|
|
|
//记录需要被删除后续任务的任务id |
|
|
|
StringBuilder sqlIn = new StringBuilder(128); |
|
|
|
//设为被驳回状态 |
|
|
|
for (Task act : new_acts) { |
|
|
|
act.setstatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
act.setStatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
act.setReject(true); |
|
|
|
|
|
|
|
sqlIn.append(",").append(act.getEntityId()); |
|
|
|
} |
|
|
|
|
|
|
|
actInst.setstatu(FlowConst.ActivityStatu.REJECT.value); |
|
|
|
actInst.setStatu(FlowConst.ActivityStatu.REJECT.value); |
|
|
|
|
|
|
|
procInst.setTaskId(new_acts.get(0).getEntityId()); |
|
|
|
procInst.setTaskName(ActivityEntityBuffer.getInstance().getNameById(new_acts.get(0).getActId())); |
|
|
|
if (new_acts.size() == 1 && new_acts.get(0).isMake()) { |
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.BEGIN.value); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); |
|
|
|
} else { |
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
} |
|
|
|
//删除这些任务的后续任务 |
|
|
|
List<Task> del_acts = actDao.findAfterTasks(sqlIn.substring(1)); |
|
|
|
actDao.batchDelete(del_acts); |
|
|
|
actDao.batchUpdate(new_acts); |
|
|
|
new ActinstRelDao().deleteAll("where before_task_bid in (" + sqlIn.substring(1) + ")"); |
|
|
|
new ProcinstDao().update(procInst); |
|
|
|
List<Task> del_acts = provider.findAfterTasks(sqlIn.substring(1)); |
|
|
|
EntityDao<Task> taskDao = getTaskDao(); |
|
|
|
taskDao.batchDelete(del_acts); |
|
|
|
taskDao.batchUpdateEntity(new_acts); |
|
|
|
getTaskRelDao().deleteEntity("where trl_src_task_id in (" + sqlIn.substring(1) + ")"); |
|
|
|
getProcInstDao().updateEntity(procInst); |
|
|
|
|
|
|
|
buildBillLog(FlowConst.FlowOptType.REJECT.value, actInst, new_acts); |
|
|
|
comp.transCallback(FlowConst.FlowOptType.REJECT.value, actInst, new_acts); |
|
|
|
buildBillLog(FlowConst.Button.REJECT.value, actInst, new_acts); |
|
|
|
// comp.transCallback(FlowConst.FlowOptType.REJECT.value, actInst, new_acts); |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 驳回到制单 |
|
|
|
* |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
/* |
|
|
|
public void rejectToMake(AbsBillWfComponent comp) { |
|
|
|
public void rejectToMake() { |
|
|
|
//校验权限,当前人员有权限干不,没权限直接抛异常 |
|
|
|
checkPermission(); |
|
|
|
if (actInst.getStatu() == FlowConst.ActivityStatu.SUBMIT.value) { |
|
|
|
throw new DfpException("当前任务已提交,不能驳回!"); |
|
|
|
throw new BizException("当前任务已提交,不能驳回!"); |
|
|
|
} |
|
|
|
|
|
|
|
ActinstDao actDao = new ActinstDao(); |
|
|
|
//获取前置任务,前置任务需要置为被驳回的办理状态,同时,前置任务的其他后置任务需要删除 |
|
|
|
Task make_act = actDao.findMakeTask(actInst.getBillId()); |
|
|
|
if (EntityUtil.isNull(make_act)) { |
|
|
|
throw new DfpException("没有找到制单任务,驳回到制单失败!"); |
|
|
|
Task make_act = provider.findMakeTask(actInst.getPriId()); |
|
|
|
if (EntityHelper.isEmpty(make_act)) { |
|
|
|
throw new BizException("没有找到制单任务,驳回到制单失败!"); |
|
|
|
} |
|
|
|
|
|
|
|
//设为被驳回状态 |
|
|
|
make_act.setstatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
make_act.setStatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
make_act.setReject(true); |
|
|
|
|
|
|
|
actInst.setstatu(FlowConst.ActivityStatu.REJECT.value); |
|
|
|
actInst.setStatu(FlowConst.ActivityStatu.REJECT.value); |
|
|
|
|
|
|
|
procInst.setTaskId(make_act.getEntityId()); |
|
|
|
procInst.setTaskName(ActivityEntityBuffer.getInstance().getNameById(make_act.getActId())); |
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.BEGIN.value); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); |
|
|
|
|
|
|
|
actDao.update(make_act); |
|
|
|
EntityDao<Task> taskDao = getTaskDao(); |
|
|
|
taskDao.updateEntity(make_act); |
|
|
|
//删除非制单步骤 |
|
|
|
actDao.deleteAll("where bill_id = ? and task_id <> ? ", make_act.getBillId(), make_act.getEntityId()); |
|
|
|
new ActinstRelDao().deleteAll("where bill_id = ? and task_id <> ?", make_act.getBillId(), make_act.getEntityId()); |
|
|
|
new ProcinstDao().update(procInst); |
|
|
|
taskDao.deleteEntity("where tsk_pri_id = ? and tsk_id <> ? ", make_act.getPriId(), make_act.getId()); |
|
|
|
getTaskRelDao().deleteEntity("where trl_pri_id = ? and trl_tsk_id <> ?", make_act.getPriId(), make_act.getId()); |
|
|
|
getProcInstDao().updateEntity(procInst); |
|
|
|
//删除候选人 |
|
|
|
new CandidateDao().deleteAll(" where bill_id = ? and task_id <> ?", make_act.getBillId(), make_act.getEntityId()); |
|
|
|
getCandidateDao().deleteEntity(" where cnd_pri_id = ? and cnd_tsk_id <> ?", make_act.getPriId(), make_act.getId()); |
|
|
|
|
|
|
|
List<Task> make_acts = new ArrayList<>(); |
|
|
|
make_acts.add(make_act); |
|
|
|
|
|
|
|
buildBillLog(FlowConst.FlowOptType.REJECT.value, actInst, make_acts); |
|
|
|
comp.transCallback(FlowConst.FlowOptType.REJECT.value, actInst, make_acts); |
|
|
|
buildBillLog(FlowConst.Button.REJECT.value, actInst, make_acts); |
|
|
|
// comp.transCallback(FlowConst.FlowOptType.REJECT.value, actInst, make_acts); |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* 办理 |
|
|
|
* |
|
|
@@ -877,19 +848,19 @@ public class FlowInstance { |
|
|
|
//校验权限,当前人员有权限干不,没权限直接抛异常 |
|
|
|
checkPermission(); |
|
|
|
if (actInst.getStatu() != FlowConst.ActivityStatu.WAIT.value) { |
|
|
|
throw new DfpException("当前任务非待办状态,不能办理失败!"); |
|
|
|
throw new BizException("当前任务非待办状态,不能办理失败!"); |
|
|
|
} |
|
|
|
|
|
|
|
ActinstDao actDao = new ActinstDao(); |
|
|
|
|
|
|
|
actInst.setHandler(user_id); |
|
|
|
actInst.setStartTime(UtilDateTime.nowDateTimeString()); |
|
|
|
actInst.setstatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
actInst.setStartTime(DateUtil.nowDateTimeLong()); |
|
|
|
actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); |
|
|
|
|
|
|
|
procInst.setTaskId(actInst.getEntityId()); |
|
|
|
procInst.setTaskName(ActivityEntityBuffer.getInstance().getNameById(actInst.getActId())); |
|
|
|
|
|
|
|
procInst.setstatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); |
|
|
|
|
|
|
|
actDao.update(actInst); |
|
|
|
new ProcinstDao().update(procInst); |
|
|
|