@@ -1359,16 +1359,12 @@ public List<User> resolveApprovers(String userId, String orgId, ApproverTypeEnum
13591359
13601360 // 获取当前用户的组织用户信息
13611361 OrganizationUser currentUser = getOrganizationUser (userId , orgId );
1362- if (currentUser == null ) {
1363- return List .of ();
1364- }
1365-
13661362 return switch (approverType ) {
13671363 case MEMBER -> resolveMemberApprovers (orgId , approverList );
13681364 case ROLE -> resolveRoleApprovers (orgId , approverList );
13691365 case SUPERIOR -> resolveSuperiorApprovers (orgId , currentUser , approverList );
13701366 case MULTIPLE_SUPERIOR -> resolveMultipleSuperiorApprovers (orgId , currentUser , approverList );
1371- case DEPT_HEAD -> resolveDeptHeadApprovers (orgId , currentUser . getDepartmentId () , approverList );
1367+ case DEPT_HEAD -> resolveDeptHeadApprovers (orgId , currentUser , approverList );
13721368 case MULTIPLE_DEPT_HEAD -> resolveMultipleDeptHeadApprovers (orgId , currentUser , approverList );
13731369 };
13741370 }
@@ -1410,6 +1406,9 @@ private List<User> resolveRoleApprovers(String orgId, List<String> roleIds) {
14101406 * 解析指定上级审批人
14111407 */
14121408 private List <User > resolveSuperiorApprovers (String orgId , OrganizationUser currentUser , List <String > approverList ) {
1409+ if (currentUser == null ) {
1410+ return List .of ();
1411+ }
14131412 // 值是单选
14141413 Integer approvalLevel = getValidLevel (approverList );
14151414
@@ -1439,6 +1438,9 @@ private List<User> resolveSuperiorApprovers(String orgId, OrganizationUser curre
14391438 * 解析多级上级审批人
14401439 */
14411440 private List <User > resolveMultipleSuperiorApprovers (String orgId , OrganizationUser currentUser , List <String > approverList ) {
1441+ if (currentUser == null ) {
1442+ return List .of ();
1443+ }
14421444 // 值是单选
14431445 Integer approvalLevel = getValidLevel (approverList );
14441446
@@ -1483,7 +1485,11 @@ private Integer getValidLevel(List<String> approverList) {
14831485 /**
14841486 * 解析部门负责人审批人
14851487 */
1486- private List <User > resolveDeptHeadApprovers (String orgId , String departmentId , List <String > approverList ) {
1488+ private List <User > resolveDeptHeadApprovers (String orgId , OrganizationUser currentUser , List <String > approverList ) {
1489+ if (currentUser == null ) {
1490+ return List .of ();
1491+ }
1492+ String departmentId = currentUser .getDepartmentId ();
14871493 if (StringUtils .isBlank (departmentId )) {
14881494 return List .of ();
14891495 }
@@ -1523,6 +1529,9 @@ private String getDeptCommander(String orgId, String departmentId) {
15231529 * 解析多级部门负责人审批人
15241530 */
15251531 private List <User > resolveMultipleDeptHeadApprovers (String orgId , OrganizationUser currentUser , List <String > approverList ) {
1532+ if (currentUser == null ) {
1533+ return List .of ();
1534+ }
15261535 String departmentId = currentUser .getDepartmentId ();
15271536 if (StringUtils .isBlank (departmentId )) {
15281537 return List .of ();
@@ -1586,6 +1595,18 @@ public List<User> getCurrentNodeApproverList(String currentNodeId, String userId
15861595 return resolveApprovers (userId , currentOrgId , ApproverTypeEnum .valueOf (nodeApprover .getApproverType ()), JSON .parseArray (nodeApprover .getApproverList (), String .class ));
15871596 }
15881597
1598+ /**
1599+ * 获取当前实例节点审批人
1600+ * @param approverType 审批类型
1601+ * @param approverList 审批人集合
1602+ * @param userId 用户ID
1603+ * @param currentOrgId 当前组织ID
1604+ * @return 审批人ID集合
1605+ */
1606+ public List <User > getCurrentNodeApproverList (String approverType , List <String > approverList , String userId , String currentOrgId ) {
1607+ return resolveApprovers (userId , currentOrgId , ApproverTypeEnum .valueOf (approverType ), approverList );
1608+ }
1609+
15891610 /**
15901611 * 获取当前实例节点抄送人
15911612 * @param currentNodeId 当前节点ID
@@ -1598,6 +1619,18 @@ public List<User> getCurrentNodeCcList(String currentNodeId, String userId, Stri
15981619 return resolveApprovers (userId , currentOrgId , ApproverTypeEnum .valueOf (nodeApprover .getCcType ()), JSON .parseArray (nodeApprover .getCcList (), String .class ));
15991620 }
16001621
1622+ /**
1623+ * 获取当前实例节点抄送人
1624+ * @param ccType 抄送类型
1625+ * @param ccList 抄送人集合
1626+ * @param userId 用户ID
1627+ * @param currentOrgId 当前组织ID
1628+ * @return 抄送人ID集合
1629+ */
1630+ public List <User > getCurrentNodeCcList (String ccType , List <String > ccList , String userId , String currentOrgId ) {
1631+ return resolveApprovers (userId , currentOrgId , ApproverTypeEnum .valueOf (ccType ), ccList );
1632+ }
1633+
16011634 /**
16021635 * 获取当前资源审批实例第一个节点
16031636 * @param instance 审批实例
@@ -1643,8 +1676,8 @@ private ApprovalNodeResponse getNextNodeWithExceptionHandler(ApprovalInstance in
16431676 ApprovalNodeApproverResponse nextApproverNode = (ApprovalNodeApproverResponse ) nextNode ;
16441677 if (ApprovalTypeEnum .valueOf (nextApproverNode .getApprovalType ()) == ApprovalTypeEnum .AUTO_PASS ) {
16451678 // 自动通过, 插入审批记录, 获取下一个节点
1646- saveAutoRecord (instance .getId (), nodeId , ApprovalStatus .APPROVED , null );
1647- return getNextNodeWithExceptionHandler (instance , nodeId , fieldValues , currentOrgId );
1679+ saveAutoRecord (instance .getId (), nextApproverNode . getId () , ApprovalStatus .APPROVED , null );
1680+ return getNextNodeWithExceptionHandler (instance , nextApproverNode . getId () , fieldValues , currentOrgId );
16481681 }
16491682 if (ApprovalTypeEnum .valueOf (nextApproverNode .getApprovalType ()) == ApprovalTypeEnum .AUTO_REJECT ) {
16501683 // 自动驳回, 插入审批记录
@@ -1654,8 +1687,8 @@ private ApprovalNodeResponse getNextNodeWithExceptionHandler(ApprovalInstance in
16541687 return exNode ;
16551688 }
16561689 // 人工审批, 异常处理
1657- List <User > nextApprovers = getCurrentNodeApproverList (nextApproverNode .getId (), instance .getSubmitterId (), currentOrgId );
1658- List <User > nextCcList = getCurrentNodeCcList (nextApproverNode .getId (), instance .getSubmitterId (), currentOrgId );
1690+ List <User > nextApprovers = getCurrentNodeApproverList (nextApproverNode .getApproverType (), nextApproverNode . getApproverList (), instance .getSubmitterId (), currentOrgId );
1691+ List <User > nextCcList = getCurrentNodeCcList (nextApproverNode .getCcType (), nextApproverNode . getCcList (), instance .getSubmitterId (), currentOrgId );
16591692 nextApproverNode .setApproverList (nextApprovers .stream ().map (User ::getId ).collect (Collectors .toList ()));
16601693 nextApproverNode .setCcList (nextCcList .stream ().map (User ::getId ).collect (Collectors .toList ()));
16611694 // 审批人为空
@@ -1664,8 +1697,8 @@ private ApprovalNodeResponse getNextNodeWithExceptionHandler(ApprovalInstance in
16641697 switch (emptyAction ) {
16651698 case AUTO_PASS -> {
16661699 // 自动通过, 插入审批记录, 获取下一个节点
1667- saveAutoRecord (instance .getId (), nodeId , ApprovalStatus .APPROVED , "审批人为空,自动通过" );
1668- return getNextNodeWithExceptionHandler (instance , nodeId , fieldValues , currentOrgId );
1700+ saveAutoRecord (instance .getId (), nextApproverNode . getId () , ApprovalStatus .APPROVED , "审批人为空,自动通过" );
1701+ return getNextNodeWithExceptionHandler (instance , nextApproverNode . getId () , fieldValues , currentOrgId );
16691702 }
16701703 case ASSIGN_SPECIFIC -> {
16711704 //指定人员处理: 返回人员列表
0 commit comments