Commit 3bf10e80 by 翁国栋

草稿箱发布审批流程bug

parent 0fd43ef2
......@@ -1249,7 +1249,7 @@ public class SpmkController {
.set("initiator", ygglMainEmp.getName())
.set("headUrl", ygglMainEmp.getHeadUrl())
.set("id", userBean.getEmpNum());
RouterUtils.NextNode(listRouter, jSONObject, ISFIRST);
RouterUtils.NextNode(listRouter, jSONObject, ISFIRST,true);
List<FlowChildren> listFlowChildren = new ArrayList<FlowChildren>();
RouterUtils.getIsFlowChildren(listRouter,listFlowChildren);
......
......@@ -41,7 +41,7 @@ import cn.timer.api.dto.spmk.User;
/**
* 流程节点工具类
*
*
* @author Administrator
*
*/
......@@ -91,8 +91,8 @@ public class RouterUtils {
}
// 执行下一个节点
public static List<Router> NextNode(List<Router> listRouter,JSONObject obj, boolean isFirse, boolean isAuditNext) throws NumberFormatException, ConvertException, Exception {
public static List<Router> NextNode(List<Router> listRouter,JSONObject obj, boolean isFirse, boolean isAuditNext,boolean... isDrafts) throws NumberFormatException, ConvertException, Exception {
Router router;
if (CollectionUtil.isNotEmpty(listRouter)) {
// 非条件节点
......@@ -110,7 +110,7 @@ public class RouterUtils {
Console.log("发起人逻辑");
router.setExecute(EXECUTED);
router.setFlow(true);
List<User> users = new ArrayList<User>();
User userFirst = User.builder()
.name(obj.getStr("initiator"))
......@@ -122,30 +122,30 @@ public class RouterUtils {
List<Relation> relations = new ArrayList<Relation>();
Relation relation = Relation.builder().type("user").users(users).build();
relations.add(relation);
router.setRelation(relations);
// router.getRelation().get(0).setName(obj.getStr("initiator"));
NextNode(router.getChildren(),obj, isFirse, isAuditNext);
break;
case AUDIT:
Console.log("审批人逻辑");
router.setFlow(true);
Relation r = CollectionUtil.isNotEmpty(router.getRelation()) ? router.getRelation().get(0) : null;
// if (r != null && RELATION_TYPE_EXECUTIVE.equals(r.getType())) {
// Integer leaderId = selectLeaderEmpNumById(
// obj.getInt("orgCode"),
// obj.getInt("id"),
// obj.getInt("orgCode"),
// obj.getInt("id"),
// r.getUpward());
//
//
// if (leaderId != null) {
// YgglMainEmp emp = YgglMainEmp.builder().build();
// emp = emp.selectOne(new QueryWrapper<YgglMainEmp>().lambda()
// .select(YgglMainEmp::getName, YgglMainEmp::getEmpNum, YgglMainEmp::getHeadUrl)
// .eq(YgglMainEmp::getEmpNum, leaderId)
// .eq(YgglMainEmp::getOrgCode, obj.getInt("orgCode")));
//
//
// if (emp != null) {
// User user = User.builder()
// .name(emp.getName())
......@@ -153,16 +153,17 @@ public class RouterUtils {
// .headUrl(emp.getHeadUrl())
// .execute(EXECUTING)
// .build();
//
//
// router.getRelation().get(0).setUsers(ListUtil.toList(user));
// }
// }
// }
if (!isAuditNext) {
router.setExecute(EXECUTING);
//此处如果是草稿就不需要更改
if(isDrafts!=null) {
router.setExecute(EXECUTING);
}
if(router.getRelation().size() > 0) {
// if (r != null && RELATION_TYPE_USERS.equals(r.getType())) {
List<User> listUser = router.getRelation().get(0).getUsers();
......@@ -175,7 +176,9 @@ public class RouterUtils {
}
switch (execute) {
case UNEXECUTED:
listUser.get(i).setExecute(EXECUTING);
if(isDrafts!=null) {
listUser.get(i).setExecute(EXECUTING);
}
// 首次发起申请时,写入 审批人名称 至 obj 中
if (isFirse && obj.getStr("current_approver") == null ) {
obj.set("current_approver", listUser.get(i).getName());
......@@ -183,18 +186,18 @@ public class RouterUtils {
isAuditNext = true;
break user;
}
}
}else {
throw new Exception("发起审批有误");
}
// }
}else {
throw new Exception("审批流程配置有误,请联系管理员");
}
}
NextNode(router.getChildren(), obj , isFirse, isAuditNext);
break;
case COPY:
......@@ -207,13 +210,13 @@ public class RouterUtils {
for (int i = 0; i < listRelations.size(); i++) {
// 装配 部门人员
if (RELATION_TYPE_DEPARTMENT.equals(listRelations.get(i).getType()) && listRelations.get(i).getDepartmentId() != null) {
String asd = listRelations.get(i).getDepartmentId();
asd = asd.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\\"", "");
// List<YgglMainEmp> listYgglMainEmp = selectOtherlistent(Integer.parseInt(obj.get("orgCode",FromData.class).getValue().trim()), Integer.valueOf(listRelations.get(i).getDepartmentId().trim()));
List<YgglMainEmp> listYgglMainEmp = selectOtherlistent(Integer.parseInt(obj.get("orgCode").toString()), Integer.valueOf(asd));
if (listYgglMainEmp != null && listYgglMainEmp.size() > 0) {
List<User> listUsers = new ArrayList<User>();
for (YgglMainEmp emp : listYgglMainEmp) {
......@@ -226,8 +229,8 @@ public class RouterUtils {
}else {
listRelations.get(i).setUsers(null);
}
}else if (RELATION_TYPE_USERS.equals(listRelations.get(i).getType())) {
}
......@@ -257,11 +260,11 @@ public class RouterUtils {
break;
}
}
if (executeFlog) {
router.setExecute(EXECUTED);
}
}
NextNode(router.getChildren(),obj , isFirse, isAuditNext);
break;
......@@ -272,7 +275,7 @@ public class RouterUtils {
NextNode(router.getChildren(),obj , isFirse, isAuditNext);
break;
}
} else {
// 条件节点
rulefor:
......@@ -305,7 +308,7 @@ public class RouterUtils {
}
}
}
routerRule.setFlow(condition_b);
routerRule.setExecute(EXECUTED);
if (routerRule.getFlow()) {
......@@ -319,9 +322,9 @@ public class RouterUtils {
}
break rulefor;
}
}
Console.log("最后节点");
}
}
......@@ -329,24 +332,24 @@ public class RouterUtils {
return listRouter;
};
public static Integer selectLeaderEmpNumById(Integer orgCode, Integer id, Integer leave) {
YgglMainEmp mainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.select(YgglMainEmp::getBmgwId)
.eq(YgglMainEmp::getEmpNum, id)
.eq(YgglMainEmp::getOrgCode, orgCode));
Integer gWId = mainEmp != null ? mainEmp.getBmgwId() : null;
// 企业所有部门岗位
List<ZzglBmgwM> listBM = ZzglBmgwM.builder().build()
.selectList(new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getOrgCode, orgCode));
// 岗位
ZzglBmgwM gW = CollUtil.getFirst(listBM.stream().filter(bM -> bM.getId().equals(gWId)).collect(Collectors.toList()));
// 岗位id
Integer baseBmgwId = gW != null ? gW.getUpId() : null;
// 指定 主管id
Integer leaderId = null;
Integer bmgwLeaderId;
......@@ -357,16 +360,16 @@ public class RouterUtils {
leaderId = bmgwLeaderId;
}
}
return leaderId;
}
public static ZzglBmgwM getLeaderEmp(List<ZzglBmgwM> listBM, Integer baseBmgwId) {
ZzglBmgwM zzglBmgwM = baseBmgwId != null ?
ZzglBmgwM zzglBmgwM = baseBmgwId != null ?
CollUtil.getFirst(listBM.stream().filter(bM -> bM.getId().equals(baseBmgwId)).collect(Collectors.toList())) : null;
return zzglBmgwM;
}
public static List<YgglMainEmp> selectOtherlistent(Integer orgCode, Integer id){
ArrayList<Integer> list = new ArrayList<Integer>();
List<ZzglBmgwM> zzglBmgwMs = ZzglBmgwM.builder().build().selectList(new QueryWrapper<ZzglBmgwM>().lambda()
......@@ -387,13 +390,13 @@ public class RouterUtils {
}
}
public static void getIsFlowChildren(List<Router> listRouter, List<FlowChildren> listFlowChildren) {
// TODO Auto-generated method stub
Router router;
if (listRouter != null && listRouter.size() == 1) {
router = listRouter.get(0);
if(router.getRelation() != null) {
for (Relation relation : router.getRelation()) {
if (relation != null) {
......@@ -417,7 +420,7 @@ public class RouterUtils {
//未开发
}
}
}
}
}
}
// Relation relation = CollectionUtil.getFirst(router.getRelation());
......@@ -430,10 +433,10 @@ public class RouterUtils {
}
};
// 审批执行记录 持久化
public static void insertogExecuteRecord(List<FlowChildren> listFlowChildren,Integer asId) throws Exception{
......@@ -443,7 +446,7 @@ public class RouterUtils {
i++;
continue;
}
// ClassName 区分参与审批流程人的角色 CREATOR(发起人)、AUDIT(审核人)、COPY(抄送人)
// 各个角色的逻辑不同
switch (listFlowChildren.get(i).getClassName()) {
......@@ -457,7 +460,7 @@ public class RouterUtils {
.build();
// 新增 审批执行记录
aer.insert();
// 新增 执行人
User user = listFlowChildren.get(i).getRelation().get(0).getUsers().get(0);
SpmkExecutor.builder()
......@@ -548,10 +551,10 @@ public class RouterUtils {
aer3.insert();
List<Relation> listRelation = listFlowChildren.get(i).getRelation();
for (Relation relation : listRelation) {
List<User> listUser2 = relation.getUsers();
// 新增 执行人
for (User user2 : listUser2) {
SpmkExecutor executor = SpmkExecutor.builder()
......@@ -568,7 +571,7 @@ public class RouterUtils {
}
}
}
/**
* 审批持久化
* @param listFlowChildren 节点
......@@ -748,7 +751,7 @@ public class RouterUtils {
}
}
// 无下一个审批人 则更新 节点状态 为 EXECUTED(已执行)
if (!hasNextApprover && es<=1) {
SpmkApproveExecuteRecord aer = SpmkApproveExecuteRecord
......@@ -780,7 +783,7 @@ public class RouterUtils {
.build();
// 新增 审批执行记录
aer.insert();
// 新增 执行人
User user = listFlowChildren.get(i).getRelation().get(0).getUsers().get(0);
SpmkExecutor.builder()
......@@ -791,7 +794,7 @@ public class RouterUtils {
.sts(ExecutorSts.AGREE.ordinal())
.build()
.insert();
listFlowChildren.get(i).setExecute(EXECUTED);
break;
case AUDIT://审批中
......@@ -875,7 +878,7 @@ public class RouterUtils {
aer3.insert();
List<Relation> listRelation = listFlowChildren.get(i).getRelation();
for (Relation relation : listRelation) {
List<User> listUser2 = relation.getUsers();
if (listUser2 != null) {
......@@ -892,7 +895,7 @@ public class RouterUtils {
}
}
}
listFlowChildren.get(i).setExecute(EXECUTED);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment