Bladeren bron

流程引擎

4.0
郑根木 2 jaren geleden
bovenliggende
commit
ae17aa5f11
8 gewijzigde bestanden met toevoegingen van 378 en 210 verwijderingen
  1. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcHelper.java
  2. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowHelper.java
  3. +153
    -182
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java
  4. +28
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowProvider.java
  5. +8
    -10
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java
  6. +164
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/userGroup/UserGroupHelper.java
  7. +12
    -4
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java
  8. +9
    -4
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DefaultEntity.java

+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcHelper.java Bestand weergeven

@@ -130,6 +130,7 @@ public class ModelProcHelper {
return listRet;
}


/**
* 获取流程定义属性值
*


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowHelper.java Bestand weergeven

@@ -49,7 +49,7 @@ public class FlowHelper {
* @param act_id
* @return
*/
public static List<Activity> getNextActivity(FlowInstance flowInstance) throws Exception {
public static List<Activity> getNextActivity(FlowInstance flowInstance) {
Activity act = ModelProcHelper.getNextActivity(flowInstance.getActInst().getPrcId(), flowInstance.getActInst().getActId());
if (act == null) {
throw new BizException("未找到可用的活动节点定义!");
@@ -62,7 +62,7 @@ public class FlowHelper {
return listRet;
}

/**
/**
* 递归处理,兼容判断后面加判断,并发后面跟并发
*
* @param act
@@ -70,7 +70,7 @@ public class FlowHelper {
* @param listRet
* @throws Exception
*/
private static void buildNextActivityRes(Activity act, FlowInstance flowInstance, List<Activity> listRet) throws Exception {
private static void buildNextActivityRes(Activity act, FlowInstance flowInstance, List<Activity> listRet) {
//待返回的结果集
// if (act.getActType() == FlowConst.ActivityType.scriptTask) 自动任务暂不支持
ProcInfo proc = flowInstance.getProcDef().getProcInfo();


+ 153
- 182
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java Bestand weergeven

@@ -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);


+ 28
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowProvider.java Bestand weergeven

@@ -54,15 +54,13 @@ public class FlowProvider extends AbstractCompProvider {
}

//获取指定任务的前置任务
public Task findBeforeTask(long taskId) {
public List<Task> findBeforeTasks(long taskId) {
return doGetData("ab_" + taskId, () -> {
EntityDao<Task> bdao = DbEngine.getInstance().findDao(Task.class);
List<Task> list = bdao.queryEx(" t," + EntityHelper.getSchemaTableName(TaskRel.ENTITY_NAME) + " r " +
"where t.task_id=r.before_task_bid and r.task_id = ?", taskId);
"where t.tsk_id=r.trl_src_task_id and r.trl_dst_task_id = ?", taskId);
if (CommUtil.isEmpty(list)) throw new BizException("没有找到指定流程前置任务(id=" + taskId + ")!");
Task bean = list.get(0);
EntityHelper.loadBeanText(bean.getTableName(), bean.getData(), null);
return bean;
return list;
});
}

@@ -70,10 +68,29 @@ public class FlowProvider extends AbstractCompProvider {
public List<Task> findBeforeTasks(String taskIds) {
EntityDao<Task> bdao = DbEngine.getInstance().findDao(Task.class);
List<Task> list = bdao.queryEx(" t," + EntityHelper.getSchemaTableName(TaskRel.ENTITY_NAME) + " r " +
"where t.task_id=r.before_task_bid and r.task_id in (" + taskIds + ")");
"where t.task_id=r.trl_src_task_id and r.trl_dst_task_id in (" + taskIds + ")");
if (CommUtil.isEmpty(list)) return new ArrayList<>();
return list;
}

//获取指定任务的前置任务
public List<Task> findAfterTasks(long taskId) {
return doGetData("ab_" + taskId, () -> {
EntityDao<Task> bdao = DbEngine.getInstance().findDao(Task.class);
List<Task> list = bdao.queryEx(" t," + EntityHelper.getSchemaTableName(TaskRel.ENTITY_NAME) + " r " +
"where t.tsk_id=r.trl_dst_task_id and r.trl_src_task_id = ?", taskId);
if (CommUtil.isEmpty(list)) throw new BizException("没有找到指定流程前置任务(id=" + taskId + ")!");
return list;
});
}

//获取指定任务的前置任务
public List<Task> findAfterTasks(String taskIds) {
EntityDao<Task> bdao = DbEngine.getInstance().findDao(Task.class);
List<Task> list = bdao.queryEx(" t," + EntityHelper.getSchemaTableName(TaskRel.ENTITY_NAME) + " r " +
"where t.task_id=r.trl_src_task_id and r.trl_dst_task_id in (" + taskIds + ")");
if (CommUtil.isEmpty(list)) return new ArrayList<>();
return list;
}

//根据id,获取流程实例
@@ -85,4 +102,9 @@ public class FlowProvider extends AbstractCompProvider {
return list;
});
}

//寻找流程的制单任务
public Task findMakeTask(long bill_id) {
return DbEngine.getInstance().findDao(Task.class).queryEntityWhere("where tsk_pri_id = ? and is_make = 1 ", bill_id);
}
}

+ 8
- 10
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java Bestand weergeven

@@ -50,16 +50,14 @@ public class AuthService {
@SwPerm()
public R userInfo(@SwBody SwMap params, UserSession us) {
SwMap data = new SwMap();
try {
User user = (User) UserCache.getInstance().get(us.getUserId()).clone();
user.setId(us.getUserId());
user.put("create_time", PubUtil.checkLastTime(user.getCreate()));
user.put("sur_party", PartyCache.getInstance().get(us.getPartyId()));
user.put("sur_roles", RoleCache.getInstance().getNamesByIds(UserRoleCache.getInstance().getRoleIdByUP(us.getUserId(), us.getPartyId())));
data.put("userInfo", user);
} catch (CloneNotSupportedException e) {
data.put("userInfo", new SwMap());
}

User user = (User) UserCache.getInstance().get(us.getUserId()).clone();
user.setId(us.getUserId());
user.put("create_time", PubUtil.checkLastTime(user.getCreate()));
user.put("sur_party", PartyCache.getInstance().get(us.getPartyId()));
user.put("sur_roles", RoleCache.getInstance().getNamesByIds(UserRoleCache.getInstance().getRoleIdByUP(us.getUserId(), us.getPartyId())));
data.put("userInfo", user);

return R.success(data);
}



+ 164
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/userGroup/UserGroupHelper.java Bestand weergeven

@@ -1,8 +1,15 @@
package cc.smtweb.system.bpm.web.sys.user.userGroup;

import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst;
import org.apache.commons.lang3.StringUtils;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;

import java.util.List;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

/**
* Created by Akmm at 2022-08-02 20:19
@@ -27,4 +34,160 @@ public class UserGroupHelper {

return true;
}

/**
* 获取分组下的所有用户信息
*
* @param group_id
* @return
*/
public static Set<Long> getUserIdList(long group_id, ProcInst pro_inst, int handle_range, UserSession us) {
if (group_id <= 0L) return null;//未设置分组,默认true
return null;
/*
List<UserGroupItemEntity> items = UserGroupItemEntityBuffer.getInstance().getListByGroup(group_id);
//设置了却没有找到分组,默认无权限
if (UtilPub.isEmpty(items)) {
return null;
}

DepartmentDataRightHandler depRight = new DepartmentDataRightHandler(context);
List<String> listRet = new ArrayList();

//include系列
Map<String, Boolean> mapPartyInc = new HashMap<>();
Map<String, Boolean> mapDeptInc = new HashMap<>();
Map<String, Boolean> mapRoleInc = new HashMap<>();
Set<String> mapUserInc = new HashSet<>();
//exclude系列
Map<String, Boolean> mapPartyExc = new HashMap<>();
Map<String, Boolean> mapDeptExc = new HashMap<>();
Map<String, Boolean> mapRoleExc = new HashMap<>();
Set<String> mapUserExc = new HashSet<>();
//先分门归类
for (UserGroupItemEntity item : items) {
//单位
if (item.getTypeCode() == CmEnum.UserGroupType.PARTY.value) {
if (!item.isRecursion()) {//不含下级
if (item.isInclude()) {
mapPartyInc.put(item.getValue(), false);
} else {
mapPartyExc.put(item.getValue(), false);
}
} else {
if (item.isInclude()) {
mapPartyInc.put(item.getValue(), true);
} else {
mapPartyExc.put(item.getValue(), true);
}
}
} else if (item.getTypeCode() == CmEnum.UserGroupType.PARTY_TYPE.value) {
//单位性质
List<PartyEntity> listAllParty = PartyEntityBuffer.getInstance().getCacheList(null);
for (PartyEntity p : listAllParty) {
if (item.getValue().equals(p.getPartyType())) {
if (item.isInclude()) {
mapPartyInc.put(item.getValue(), false);
} else {
mapPartyExc.put(item.getValue(), false);
}
}
}
} else if (item.getTypeCode() == CmEnum.UserGroupType.DEPT.value) {
//部门
if (!item.isRecursion()) {//不含下级
if (item.isInclude()) {
mapDeptInc.put(item.getValue(), false);
} else {
mapDeptExc.put(item.getValue(), false);
}
} else {
if (item.isInclude()) {
mapDeptInc.put(item.getValue(), true);
} else {
mapDeptExc.put(item.getValue(), true);
}
}
} else if (item.getTypeCode() == CmEnum.UserGroupType.DEPT_TYPE.value) {
//部门性质
List<DepartmentEntity> listAllParty = DepartmentEntityBuffer.getInstance().getCacheList(null);
for (DepartmentEntity p : listAllParty) {
if (item.getValue().equals(p.getDeptType())) {
if (item.isInclude()) {
mapDeptInc.put(item.getValue(), false);
} else {
mapDeptExc.put(item.getValue(), false);
}
}
}
} else if (item.getTypeCode() == CmEnum.UserGroupType.ROLE.value) {
//角色
if (item.isInclude() && depRight.hasRight(item.getValue(), pro_inst.getDeptId())) {
mapRoleInc.put(item.getValue(), false);
} else {
mapRoleExc.put(item.getValue(), false);
}
} else if (item.getTypeCode() == CmEnum.UserGroupType.USER.value) {
//用户
if (item.isInclude()) {
mapUserInc.add(item.getValue());
} else {
mapUserExc.add(item.getValue());
}
}
}
//再一个个的找
StringBuilder sqlPartyId = new StringBuilder(256);
for (String id : mapPartyInc.keySet()) {
buildPartyIn(id, mapPartyInc.get(id), sqlPartyId, mapPartyExc);
}
StringBuilder sqlDeptId = new StringBuilder(256);
for (String id : mapDeptInc.keySet()) {
buildDeptIn(id, mapDeptInc.get(id), sqlPartyId, mapDeptExc);
}

//用户结果集
Set<String> setUsers = new HashSet<>();
//按单位和部门的
if (sqlPartyId.length() > 0 || sqlDeptId.length() > 0) {
StringBuilder sql = new StringBuilder(256);
sql.append("select distinct e.user_id from " + EntityDaoHelper.getSchemaTable(UserExEntity.ENTITY_NAME) + " e\n");
boolean b = false;
if (sqlPartyId.length() > 0) {
sql.append("where party_id in (" + sqlPartyId.substring(1) + ")");
b = true;
}
if (sqlDeptId.length() > 0) {
if (b) sql.append(" or ");
else sql.append(" where ");
sql.append("where dept_id in (" + sqlDeptId.substring(1) + ")");
}
DbEngine.query(sql.toString(), new ResultSetExtractor<Object>() {
@Override
public Object extractData(ResultSet resultSet) throws SQLException, DataAccessException {
while (resultSet.next()) {
setUsers.add(resultSet.getString(1));
}
return null;
}
});
}
//有包含角色权限的
buildRole(mapRoleInc, true, setUsers);
buildRole(mapRoleExc, false, setUsers);

setUsers.addAll(mapUserInc);
setUsers.removeAll(mapUserExc);

Set<String> userRange = new HashSet<>();
if (handle_range == CmEnum.HandlerRange.DEPT.value) {
buildDeptRange(userRange, pro_inst.getDeptId());
}
if (handle_range == CmEnum.HandlerRange.PARTY.value) {
buildPartyRange(userRange, pro_inst.getPartyId());
}
if (UtilPub.isNotEmpty(userRange)) setUsers.retainAll(userRange);
return setUsers;
*/
}
}

+ 12
- 4
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java Bestand weergeven

@@ -8,7 +8,6 @@ import cc.smtweb.framework.core.db.jdbc.JdbcEngine;
import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.PubUtil;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@@ -201,13 +200,13 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
}

public void batchUpdateEntity(Collection<T> list) {
if (PubUtil.isEmpty(list)) return;
if (CommUtil.isEmpty(list)) return;
batchUpdateEntity(list, null);
}

//批量更新
public void batchUpdateEntity(Collection<T> list, String fields) {
if (PubUtil.isEmpty(list)) return;
if (CommUtil.isEmpty(list)) return;

List<String> listFields = adjustFields(fields, SwEnum.FieldType.CREATE_TIME.value, SwEnum.FieldType.LAST_TIME.value);
List<String> fieldList = new ArrayList<>();
@@ -279,7 +278,16 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
}

public int deleteEntity(Collection<Long> ids) {
if (PubUtil.isEmpty(ids)) return 0;
if (CommUtil.isEmpty(ids)) return 0;
return deleteEntity(" where " + modelTable.getIdField() + " in (" + CommUtil.getSqlInIds(ids) + ")");
}

public int batchDelete(Collection<? extends DefaultEntity> list) {
if (CommUtil.isEmpty(list)) return 0;
List<Long> ids = new ArrayList<>(list.size());
for (DefaultEntity bean: list) {
ids.add(bean.getEntityId());
}
return deleteEntity(" where " + modelTable.getIdField() + " in (" + CommUtil.getSqlInIds(ids) + ")");
}



+ 9
- 4
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/impl/DefaultEntity.java Bestand weergeven

@@ -4,6 +4,7 @@ import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.framework.core.util.DateUtil;
import org.apache.commons.lang3.StringUtils;

@@ -84,9 +85,13 @@ public class DefaultEntity extends BaseBean implements Serializable, Cloneable {
}

@Override
public DefaultEntity clone() throws CloneNotSupportedException {
DefaultEntity bean = (DefaultEntity) super.clone();
bean.getData().remove(getPkFieldName());
return bean;
public DefaultEntity clone() {
try {
DefaultEntity bean = (DefaultEntity) super.clone();
bean.getData().remove(getPkFieldName());
return bean;
} catch (CloneNotSupportedException e) {
throw new SwException(e);
}
}
}

Laden…
Annuleren
Opslaan