Commit 3bf10e80 by 翁国栋

草稿箱发布审批流程bug

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