瀏覽代碼

转审修改

wangliang 7 月之前
父節點
當前提交
95ad5c780f

+ 57 - 3
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -134,6 +134,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     @Resource
     SysMessageService sysMessageService;
     SysMessageService sysMessageService;
 
 
+    @Resource
+    SysUserRoleService sysUserRoleService;
+
     /**
     /**
      * 根据deploymentId查找processDefinitionId
      * 根据deploymentId查找processDefinitionId
      *
      *
@@ -762,6 +765,43 @@ public class ActivitiServiceImpl implements ActivitiService {
 
 
             boolean replace = false;
             boolean replace = false;
             String oldUserId = null;
             String oldUserId = null;
+            List<Long> originalUserIdList = new ArrayList<>();
+            List<Task> taskList = taskService.createTaskQuery()
+                    .processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
+            if (!CollectionUtils.isEmpty(taskList) && taskList.size() > 1) {
+                for (Task t : taskList) {
+                    if (Objects.nonNull(t.getAssignee())) {
+                        originalUserIdList.add(Long.parseLong(t.getAssignee()));
+                    } else {
+                        List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(t.getId());
+                        if (!CollectionUtils.isEmpty(identityLinkList)) {
+                            for (IdentityLink i : identityLinkList) {
+                                originalUserIdList.add(Long.parseLong(i.getUserId()));
+                            }
+                        }
+                    }
+                }
+            } else {
+                if (Objects.nonNull(taskList.get(0).getAssignee())) {
+                    originalUserIdList.add(Long.parseLong(taskList.get(0).getAssignee()));
+                } else {
+                    List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(taskList.get(0).getId());
+                    if (!CollectionUtils.isEmpty(identityLinkList)) {
+                        for (IdentityLink i : identityLinkList) {
+                            originalUserIdList.add(Long.parseLong(i.getUserId()));
+                        }
+                    }
+                }
+            }
+            if (!CollectionUtils.isEmpty(originalUserIdList)) {
+                List<SysRole> sysRoleList = sysUserRoleService.listRoleByUserIds(originalUserIdList);
+                List<SysRole> sysRoleTempList = sysRoleList.stream()
+                        .filter(s -> s.getType() == RoleTypeEnum.EFFECT_ENGINEER
+                                || s.getType() == RoleTypeEnum.ASSISTANT_ENGINEER).collect(Collectors.toList());
+                if (CollectionUtils.isEmpty(sysRoleTempList)) {
+                    return false;
+                }
+            }
             if (!multiInstance) {
             if (!multiInstance) {
                 oldUserId = task.getAssignee();
                 oldUserId = task.getAssignee();
                 if (Objects.nonNull(task.getAssignee())) {
                 if (Objects.nonNull(task.getAssignee())) {
@@ -793,11 +833,25 @@ public class ActivitiServiceImpl implements ActivitiService {
             if (!replace) {
             if (!replace) {
                 return true;
                 return true;
             }
             }
-            List<Task> taskList = taskService.createTaskQuery()
-                    .processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
+            taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId()))
+                    .list();
             String pendApproveIds = null;
             String pendApproveIds = null;
             if (!CollectionUtils.isEmpty(taskList) && taskList.size() > 1) {
             if (!CollectionUtils.isEmpty(taskList) && taskList.size() > 1) {
-                List<String> list = taskList.stream().map(s -> s.getAssignee()).collect(Collectors.toList());
+                List<String> list = new ArrayList<>();
+                for (Task t : taskList) {
+                    if (Objects.nonNull(t.getAssignee())) {
+                        list.add(t.getAssignee());
+                        originalUserIdList.add(Long.parseLong(t.getAssignee()));
+                    } else {
+                        List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(t.getId());
+                        if (!CollectionUtils.isEmpty(identityLinkList)) {
+                            for (IdentityLink i : identityLinkList) {
+                                list.add(i.getUserId());
+                                originalUserIdList.add(Long.parseLong(i.getUserId()));
+                            }
+                        }
+                    }
+                }
                 pendApproveIds = list.toString().replaceAll("\\[", "").replaceAll("\\]", "").replaceAll(", ", ",");
                 pendApproveIds = list.toString().replaceAll("\\[", "").replaceAll("\\]", "").replaceAll(", ", ",");
             } else {
             } else {
                 pendApproveIds = String.valueOf(userId);
                 pendApproveIds = String.valueOf(userId);

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/SysUserRoleMapper.java

@@ -18,6 +18,7 @@ import java.util.List;
  * @since 2023-07-17
  * @since 2023-07-17
  */
  */
 public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
 public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
+
     /**
     /**
      * 根据用户id查询角色集合
      * 根据用户id查询角色集合
      *
      *
@@ -26,6 +27,14 @@ public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
      */
      */
     List<SysRole> listRoleByUserId(@Param("userId") Long userId);
     List<SysRole> listRoleByUserId(@Param("userId") Long userId);
 
 
+    /**
+     * 根据用户ids查询角色集合
+     *
+     * @param userIds 用户id
+     * @return 角色集合
+     */
+    List<SysRole> listRoleByUserIds(@Param("userIds") List<Long> userIds);
+
     /**
     /**
      * 根据角色id查询用户信息
      * 根据角色id查询用户信息
      *
      *

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysUserRoleService.java

@@ -35,6 +35,14 @@ public interface SysUserRoleService extends IService<SysUserRole> {
      */
      */
     List<SysRole> listRoleByUserId(Long userId);
     List<SysRole> listRoleByUserId(Long userId);
 
 
+    /**
+     * 根据用户ids查询该用户所包含的角色集合
+     *
+     * @param userIds 用户ids
+     * @return 角色集合
+     */
+    List<SysRole> listRoleByUserIds(List<Long> userIds);
+
     /**
     /**
      * 用户是否包含某些类型的角色
      * 用户是否包含某些类型的角色
      *
      *

+ 20 - 9
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserRoleServiceImpl.java

@@ -83,6 +83,17 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
         return this.baseMapper.listRoleByUserId(userId);
         return this.baseMapper.listRoleByUserId(userId);
     }
     }
 
 
+    /**
+     * 根据用户ids查询该用户所包含的角色集合
+     *
+     * @param userIds 用户id
+     * @return
+     */
+    @Override
+    public List<SysRole> listRoleByUserIds(List<Long> userIds) {
+        return this.baseMapper.listRoleByUserIds(userIds);
+    }
+
     @Override
     @Override
     public boolean userContainsRoles(Long userId, RoleTypeEnum... roleTypes) {
     public boolean userContainsRoles(Long userId, RoleTypeEnum... roleTypes) {
         boolean result = false;
         boolean result = false;
@@ -189,15 +200,15 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
                     sysDingApproveList.add(s);
                     sysDingApproveList.add(s);
                 }
                 }
             }
             }
-//            for (SysDingObj s : sysDingList) {
-//                if (userArchivesRoleMap.containsKey(s.getRoleId())) {
-//                    userIdList = new ArrayList<>();
-//                    break;
-//                }
-//            }
-//            if (Objects.isNull(userIdList)) {
-//                continue;
-//            }
+            //            for (SysDingObj s : sysDingList) {
+            //                if (userArchivesRoleMap.containsKey(s.getRoleId())) {
+            //                    userIdList = new ArrayList<>();
+            //                    break;
+            //                }
+            //            }
+            //            if (Objects.isNull(userIdList)) {
+            //                continue;
+            //            }
             if (CollectionUtils.isEmpty(sysDingApproveList)) {
             if (CollectionUtils.isEmpty(sysDingApproveList)) {
                 throw ExceptionResultEnum.SERVICE_DING_APPROVE_NO_DATA.exception();
                 throw ExceptionResultEnum.SERVICE_DING_APPROVE_NO_DATA.exception();
             }
             }

+ 11 - 0
sop-business/src/main/resources/mapper/SysUserRoleMapper.xml

@@ -7,6 +7,17 @@
         WHERE EXISTS(SELECT 1 FROM sys_user_role b WHERE a.id = b.role_id AND b.user_id = #{userId})
         WHERE EXISTS(SELECT 1 FROM sys_user_role b WHERE a.id = b.role_id AND b.user_id = #{userId})
     </select>
     </select>
 
 
+    <select id="listRoleByUserIds" resultType="com.qmth.sop.business.entity.SysRole">
+        SELECT distinct * FROM sys_role a
+        WHERE EXISTS(SELECT 1 FROM sys_user_role b WHERE a.id = b.role_id
+        <if test="userIds != null and userIds != '' and userIds.size() > 0">
+            and b.user_id IN
+            <foreach collection="userIds" item="userId" index="index" open="(" separator="," close=")">
+                #{userId}
+            </foreach>)
+        </if>
+    </select>
+
     <select id="listByRoleId" resultType="com.qmth.sop.business.entity.SysUserRole">
     <select id="listByRoleId" resultType="com.qmth.sop.business.entity.SysUserRole">
         select * from sys_user_role sur
         select * from sys_user_role sur
         join sys_user su on su.id = sur.user_id
         join sys_user su on su.id = sur.user_id