Commit dcff51c4 by 龙于生

修复审批 转派、同意等问题

parent 03976617
...@@ -5,6 +5,8 @@ import java.util.Date; ...@@ -5,6 +5,8 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.IdUtil;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -571,13 +573,13 @@ public class RouterUtils { ...@@ -571,13 +573,13 @@ public class RouterUtils {
* @param sts 状态 1执行中 2通过 3拒绝 * @param sts 状态 1执行中 2通过 3拒绝
*/ */
public static void approving(List<FlowChildren> listFlowChildren,Integer asId,Integer executeRecordId, Integer executorId, String opinion,Integer sts,User redeployUser,String signatureImg,Integer empNum,List<User> redeployUserList) throws Exception { public static void approving(List<FlowChildren> listFlowChildren,Integer asId,Integer executeRecordId, Integer executorId, String opinion,Integer sts,User redeployUser,String signatureImg,Integer empNum,List<User> redeployUserList) throws Exception {
boolean hasNextApprover = false;
//是否有下一个审批人
boolean hasNextApprover = false;
//统计并序审批 还有几个执行中的
int es=0; int es=0;
for (int i = 0,n = listFlowChildren.size(); i < n; i++) {
for (int i = 0,n = listFlowChildren.size(); i < n; i++) {
// 新增 执行人 // 新增 执行人
List<User> listUser = CollUtil.toList(); List<User> listUser = CollUtil.toList();
boolean aobl = false;//用于判断是 否并序审批 boolean aobl = false;//用于判断是 否并序审批
...@@ -596,21 +598,27 @@ public class RouterUtils { ...@@ -596,21 +598,27 @@ public class RouterUtils {
} }
} }
//判断大节点的执行状态 0 未执行 1 执行中 2 已执行
//执行中
if (EXECUTING.equals(listFlowChildren.get(i).getExecute())) { if (EXECUTING.equals(listFlowChildren.get(i).getExecute())) {
String currentApprover = "";//存放当前审批人名称
//遍历当前节点审批人
outloop: // 标识 (若内层满足条件直接跳到该层循环)
for (int i_user = 0, n_user = listUser.size(); i_user < n_user; i_user++) { for (int i_user = 0, n_user = listUser.size(); i_user < n_user; i_user++) {
//判断用户执行状态 0 未执行 1 执行中 2 已执行
//已执行
if (EXECUTED.equals(listUser.get(i_user).getExecute())) { if (EXECUTED.equals(listUser.get(i_user).getExecute())) {
}else if (EXECUTING.equals(listUser.get(i_user).getExecute())) {
//执行中
}else if (EXECUTING.equals(listUser.get(i_user).getExecute())) {
//判断当前节点审批人id 等于 操作用户id 则更新执行人信息:审批意见、状态(0未执行 1执行中 2同意 3拒接 4转派)
if (Integer.parseInt(listUser.get(i_user).getId()) == empNum){ if (Integer.parseInt(listUser.get(i_user).getId()) == empNum){
SpmkExecutor.builder() SpmkExecutor.builder()
.id(executorId) .id(executorId)
.opinion(opinion) .opinion(opinion)
.empNum(Integer.parseInt(listUser.get(i_user).getId())) //.empNum(Integer.parseInt(listUser.get(i_user).getId()))
.executorName(listUser.get(i_user).getName()) //.executorName(listUser.get(i_user).getName())
.operatorHeaderUrl(listUser.get(i_user).getHeadUrl()) //.operatorHeaderUrl(listUser.get(i_user).getHeadUrl())
.sts(sts) .sts(sts)
.signatureImg(signatureImg) .signatureImg(signatureImg)
.build() .build()
...@@ -640,8 +648,10 @@ public class RouterUtils { ...@@ -640,8 +648,10 @@ public class RouterUtils {
listFlowChildren.get(i_user).setExecute(EXECUTED); listFlowChildren.get(i_user).setExecute(EXECUTED);
return; return;
//转派 处理 //转派 处理
//在 原审批人 列表中 插入 一个被转派人(审批人) //在 原审批人 列表中 插入 一个或多个被转派人(审批人)
}else if (sts == ExecutorSts.REDEPLOY.ordinal()) { }else if (sts == ExecutorSts.REDEPLOY.ordinal()) {
//新增转派多个人功能
//判断是走派多个人的 否则走旧逻辑
if(redeployUserList.size() >0 ){ if(redeployUserList.size() >0 ){
List<User> users1 = CollectionUtil.sub(listUser, 0, i_user+1); List<User> users1 = CollectionUtil.sub(listUser, 0, i_user+1);
for (User ruser:redeployUserList for (User ruser:redeployUserList
...@@ -652,7 +662,8 @@ public class RouterUtils { ...@@ -652,7 +662,8 @@ public class RouterUtils {
} }
// List<User> users2 = CollectionUtil.sub(listUser, i_user+1, listUser.size()); // List<User> users2 = CollectionUtil.sub(listUser, i_user+1, listUser.size());
// listUser = ListUtils.union(users1, users2);//并集 // listUser = ListUtils.union(users1, users2);//并集
listR.get(0).setApprovalOrder("1"); //listR.get(0).setApprovalOrder("1");
listFlowChildren.get(i).getRelation().get(0).setApprovalOrder("1");
}else { }else {
List<User> users1 = CollectionUtil.sub(listUser, 0, i_user+1); List<User> users1 = CollectionUtil.sub(listUser, 0, i_user+1);
redeployUser.setExecute(UNEXECUTED); redeployUser.setExecute(UNEXECUTED);
...@@ -662,35 +673,34 @@ public class RouterUtils { ...@@ -662,35 +673,34 @@ public class RouterUtils {
n_user = listUser.size(); n_user = listUser.size();
} }
//
// System.out.println(users1); // System.out.println(users1);
// System.out.println(users2); // System.out.println(users2);
// //
// System.out.println(listUser); // System.out.println(listUser);
} }
} }
//未执行
}else if (UNEXECUTED.equals(listUser.get(i_user).getExecute())) { }else if (UNEXECUTED.equals(listUser.get(i_user).getExecute())) {
//新增执行人 执行状态为执行中
SpmkExecutor.builder() SpmkExecutor.builder()
.approveExecuteRecordId(executeRecordId) .approveExecuteRecordId(executeRecordId)
.empNum(Integer.parseInt(listUser.get(i_user).getId())) .empNum(Integer.parseInt(listUser.get(i_user).getId()))
.executorName(listUser.get(i_user).getName()) .executorName(listUser.get(i_user).getName())
.operatorHeaderUrl(listUser.get(i_user).getHeadUrl()) .operatorHeaderUrl(listUser.get(i_user).getHeadUrl())
.sts(ExecutorSts.IN_EXECUTION.ordinal()) .sts(ExecutorSts.IN_EXECUTION.ordinal())
.build() .build()
.insert(); .insert();
hasNextApprover = true; hasNextApprover = true;//标记为有下个审批人
listUser.get(i_user).setExecute(EXECUTING); listUser.get(i_user).setExecute(EXECUTING);
// 当前审批人 // 当前审批人
SpmkApproveSummary.builder().id(asId).currentApprover(listUser.get(i_user).getName()).build().updateById(); SpmkApproveSummary.builder().id(asId).currentApprover(listUser.get(i_user).getName()).build().updateById();
// 处理了 下一个审批人 则跳出循环 // 处理了 下一个审批人 则跳出循环
//break; if(redeployUserList.size() == 0 ){
break;
}
} }
} }
...@@ -709,12 +719,12 @@ public class RouterUtils { ...@@ -709,12 +719,12 @@ public class RouterUtils {
} }
} }
//判断大节点为未执行
}else if (UNEXECUTED.equals(listFlowChildren.get(i).getExecute())) { }else if (UNEXECUTED.equals(listFlowChildren.get(i).getExecute())) {
//判断无下一个审批人 并且 执行中的小于等于1
if (!hasNextApprover && es<=1) { if (!hasNextApprover && es<=1) {
switch (listFlowChildren.get(i).getClassName()) { switch (listFlowChildren.get(i).getClassName()) {
case CREATOR: case CREATOR://发起审批人
SpmkApproveExecuteRecord aer = SpmkApproveExecuteRecord SpmkApproveExecuteRecord aer = SpmkApproveExecuteRecord
.builder() .builder()
.approveSummaryId(asId) .approveSummaryId(asId)
...@@ -738,11 +748,12 @@ public class RouterUtils { ...@@ -738,11 +748,12 @@ public class RouterUtils {
listFlowChildren.get(i).setExecute(EXECUTED); listFlowChildren.get(i).setExecute(EXECUTED);
break; break;
case AUDIT: case AUDIT://审批中
//判断是否是并序
if(aobl){ if(aobl){
String currentApprover = ""; String currentApprover = "";
//遍历当前节点审批人
for (int i_user2 = 0,n_user2 = listUser.size(); i_user2 < n_user2; i_user2++) { for (int i_user2 = 0,n_user2 = listUser.size(); i_user2 < n_user2; i_user2++) {
SpmkApproveExecuteRecord aer2 = SpmkApproveExecuteRecord SpmkApproveExecuteRecord aer2 = SpmkApproveExecuteRecord
.builder() .builder()
.approveSummaryId(asId) .approveSummaryId(asId)
...@@ -753,6 +764,7 @@ public class RouterUtils { ...@@ -753,6 +764,7 @@ public class RouterUtils {
// 新增 审批执行记录 // 新增 审批执行记录
aer2.insert(); aer2.insert();
//新增执行人 并设置状态为执行中
SpmkExecutor executor = SpmkExecutor.builder() SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer2.getId()) .approveExecuteRecordId(aer2.getId())
.empNum(Integer.parseInt(listUser.get(i_user2).getId())) .empNum(Integer.parseInt(listUser.get(i_user2).getId()))
...@@ -782,7 +794,9 @@ public class RouterUtils { ...@@ -782,7 +794,9 @@ public class RouterUtils {
.build(); .build();
// 新增 审批执行记录 // 新增 审批执行记录
aer2.insert(); aer2.insert();
String currentApprover = "";
//遍历当前节点审批人
outloop:
for (int i_user2 = 0,n_user2 = listUser.size(); i_user2 < n_user2; i_user2++) { for (int i_user2 = 0,n_user2 = listUser.size(); i_user2 < n_user2; i_user2++) {
SpmkExecutor executor = SpmkExecutor.builder() SpmkExecutor executor = SpmkExecutor.builder()
.approveExecuteRecordId(aer2.getId()) .approveExecuteRecordId(aer2.getId())
...@@ -791,21 +805,31 @@ public class RouterUtils { ...@@ -791,21 +805,31 @@ public class RouterUtils {
.operatorHeaderUrl(listUser.get(i_user2).getHeadUrl()) .operatorHeaderUrl(listUser.get(i_user2).getHeadUrl())
.sts(ExecutorSts.IN_EXECUTION.ordinal()) .sts(ExecutorSts.IN_EXECUTION.ordinal())
.build(); .build();
//新增执行人
executor.insert(); executor.insert();
listUser.get(i_user2).setExecute(EXECUTING); listUser.get(i_user2).setExecute(EXECUTING);
hasNextApprover = true; hasNextApprover = true;
// 当前审批人 // 当前审批人
SpmkApproveSummary.builder().id(asId).currentApprover(listUser.get(i_user2).getName()).build().updateById(); currentApprover=currentApprover!=""?currentApprover+","+listUser.get(i_user2).getName():listUser.get(i_user2).getName();
SpmkApproveSummary.builder().id(asId).currentApprover(currentApprover).build().updateById();
// 处理了 下一个审批人 则跳出循环 // 处理了 下一个审批人 则跳出循环
break; for (int j = 0; j < redeployUserList.size(); j++) {
User u = redeployUserList.get(j);
if(u.getId() == listUser.get(i_user2).getId()){
if (j == redeployUserList.size() - 1){
break outloop;
}
}
}
//break;
} }
listFlowChildren.get(i).setExecute(EXECUTING); listFlowChildren.get(i).setExecute(EXECUTING);
} }
break; break;
case COPY: case COPY://抄送人
SpmkApproveExecuteRecord aer3 = SpmkApproveExecuteRecord SpmkApproveExecuteRecord aer3 = SpmkApproveExecuteRecord
.builder() .builder()
.approveSummaryId(asId) .approveSummaryId(asId)
......
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