瀏覽代碼

流程权限修改

wangliang 8 月之前
父節點
當前提交
198560fff5

+ 13 - 10
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserServiceImpl.java

@@ -363,14 +363,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 //如果修改了角色,需要重新登录
                 if (count > 0 || dbUserRolesList.size() != userRolesList.size()) {
                     // 如果涉及到区协和工程师身份的互相转变,则需要判断该用户没有在途的sop
-                    Long sysCoordinatorRoleId = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.REGION_COORDINATOR).getRoleId();
-                    Long sysEffectRoleId = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.EFFECT_ENGINEER).getRoleId();
+                    Long sysCoordinatorRoleId = sysRoleService.findRoleInfoByArchivesType(
+                            RoleTypeEnum.REGION_COORDINATOR).getRoleId();
+                    Long sysEffectRoleId = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.EFFECT_ENGINEER)
+                            .getRoleId();
                     Long sysAssistantRoleId = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.ASSISTANT_ENGINEER)
                             .getRoleId();
 
-                    if (userRolesList.contains(sysCoordinatorRoleId) && (dbUserRolesList.contains(sysEffectRoleId) || dbUserRolesList.contains(sysAssistantRoleId))
-                            || ((userRolesList.contains(sysEffectRoleId) || userRolesList.contains(sysAssistantRoleId))
-                            && dbUserRolesList.contains(sysCoordinatorRoleId))) {
+                    if (userRolesList.contains(sysCoordinatorRoleId) && (dbUserRolesList.contains(sysEffectRoleId)
+                            || dbUserRolesList.contains(sysAssistantRoleId)) || (
+                            (userRolesList.contains(sysEffectRoleId) || userRolesList.contains(sysAssistantRoleId))
+                                    && dbUserRolesList.contains(sysCoordinatorRoleId))) {
                         // 判断是否有在途的sop
                         List<String> onPassageSopNoList = this.findOnPassageSopNoByUserId(sysUser.getId());
                         if (!CollectionUtils.isEmpty(onPassageSopNoList)) {
@@ -614,11 +617,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 .eq(TBUserArchivesAllocation::getUserId, userId));
         dto.setHasProjectManager(count > 0);
 
-        if (!dto.getHasProjectManager() && !dto.getHasRegionManager() && !dto.getHasAssistantEngineer()
-                && !dto.getHasAssistantEngineer()) {
-            dto.setHasEffectEngineer(true);
-            dto.setHasAssistantEngineer(true);
-        }
+        //        if (!dto.getHasProjectManager() && !dto.getHasRegionManager() && !dto.getHasAssistantEngineer()
+        //                && !dto.getHasAssistantEngineer() && !dto.getHasQA() && !dto.getHasCustom()) {
+        //            dto.setHasEffectEngineer(true);
+        //            dto.setHasAssistantEngineer(true);
+        //        }
         if (dto.getHasThirdPmo() || dto.getHasDeviceDelivery()) {
             Long supplierId = sysUser.getSupplierId();
             if (supplierId == null || supplierId == 0) {

+ 3 - 3
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBQualityProblemApplyServiceImpl.java

@@ -81,8 +81,7 @@ public class TBQualityProblemApplyServiceImpl extends ServiceImpl<TBQualityProbl
             QualityProblemTypeEnum type, QualityProblemReasonEnum reason, InfluenceDegreeEnum degree, String custom,
             String problemNo, Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        //        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        DataPermissionDto dpr = null;
+        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
         IPage<TBQualityProblemApplyResult> resultIPage = this.baseMapper.query(iPage, serviceId, userId,
                 Objects.nonNull(type) ? type.name() : null, Objects.nonNull(reason) ? reason.name() : null,
                 Objects.nonNull(degree) ? degree.name() : null, custom, problemNo, startTime, endTime, dpr);
@@ -204,7 +203,8 @@ public class TBQualityProblemApplyServiceImpl extends ServiceImpl<TBQualityProbl
             throw ExceptionResultEnum.FLOW_DATA_NOT_ME.exception();
         }
 
-        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(Long.parseLong(task.getProcessInstanceId()));
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(
+                Long.parseLong(task.getProcessInstanceId()));
 
         FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
         LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();

+ 6 - 6
sop-business/src/main/resources/mapper/TBDingApplyMapper.xml

@@ -105,17 +105,17 @@
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <choose>
                     <when test="dpr.hasBusiness">
-                        AND tbs.service_lead_id = #{dpr.requestUserId}
+                        AND (tbs.service_lead_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate'))
                     </when>
                     <otherwise>
                         <choose>
                             <when test="dpr.hasRegionManager">
-                                AND tbc.lead_id = #{dpr.requestUserId}
+                                AND (tbc.lead_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate'))
                             </when>
                             <otherwise>
                                 <choose>
                                     <when test="dpr.hasRegionCoordinator">
-                                        AND tbc.region_coordinator_id = #{dpr.requestUserId}
+                                        AND (tbc.region_coordinator_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate'))
                                     </when>
                                 </choose>
                             </otherwise>
@@ -238,17 +238,17 @@
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <choose>
                     <when test="dpr.hasBusiness">
-                        AND (tbs.service_lead_id = #{dpr.requestUserId} or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId}))
+                        AND (tbs.service_lead_id = #{dpr.requestUserId} or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation not in ('START','EXCHANGE')))
                     </when>
                     <otherwise>
                         <choose>
                             <when test="dpr.hasRegionManager">
-                                AND (tbc.lead_id = #{dpr.requestUserId} or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId}))
+                                AND (tbc.lead_id = #{dpr.requestUserId} or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation not in ('START','EXCHANGE')))
                             </when>
                             <otherwise>
                                 <choose>
                                     <when test="dpr.hasRegionCoordinator">
-                                        AND (tbc.region_coordinator_id = #{dpr.requestUserId} or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId}))
+                                        AND (tbc.region_coordinator_id = #{dpr.requestUserId} or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation not in ('START','EXCHANGE')))
                                     </when>
                                 </choose>
                             </otherwise>

+ 6 - 15
sop-business/src/main/resources/mapper/TBProjectExchangeMapper.xml

@@ -33,8 +33,6 @@
             tfcf.flow_deployment_id as flowDeploymentId,
             tfcfe.id as customFlowEntityid,
             tffa.update_time as flowTime
---             IFNULL((select group_concat(us1.real_name SEPARATOR ';') from sys_user us1
---              where find_in_set(us1.id, (select tffl.pend_approve_id from t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id order by tffl.create_time desc limit 1))),'--') as approveUsersName
         from t_b_project_exchange tbpe
                  left join t_f_custom_flow_entity tfcfe on tfcfe.code = tbpe.exchange_no
                  left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
@@ -93,30 +91,23 @@
                     <otherwise>
                         <choose>
                             <when test="dpr.hasBusiness">
-                                AND tbs.service_lead_id = #{dpr.requestUserId}
+                                AND (tbs.service_lead_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                             </when>
                             <otherwise>
                                 <choose>
                                     <when test="dpr.hasRegionManager">
-                                        AND tbc.lead_id = #{dpr.requestUserId}
+                                        AND (tbc.lead_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                                     </when>
                                     <otherwise>
                                         <choose>
-                                            <when test="dpr.hasProjectManager">
-                                                AND EXISTS(SELECT 1 FROM t_b_user_archives_allocation tbuaa WHERE tbuaa.crm_detail_id = tbcd.id AND tbuaa.user_id = #{dpr.requestUserId} and tbuaa.sop_role_type = 'PROJECT_MANAGER')
+                                            <when test="dpr.hasRegionCoordinator">
+                                                AND (tbc.region_coordinator_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                                             </when>
                                             <otherwise>
                                                 <choose>
-                                                    <when test="dpr.hasRegionCoordinator">
-                                                        AND EXISTS(SELECT 1 FROM t_b_user_archives_allocation tbuaa WHERE tbuaa.crm_detail_id = tbcd.id AND tbuaa.user_id = #{dpr.requestUserId} and tbuaa.sop_role_type = 'REGION_COORDINATOR')
+                                                    <when test="dpr.hasProjectManager or dpr.hasEffectEngineer or dpr.hasAssistantEngineer">
+                                                        AND (EXISTS(SELECT 1 FROM t_b_user_archives_allocation tbuaa WHERE tbuaa.crm_detail_id = tbcd.id AND tbuaa.user_id = #{dpr.requestUserId}) or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = tfcfe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = tfcfe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                                                     </when>
-                                                    <otherwise>
-                                                        <choose>
-                                                            <when test="dpr.hasEffectEngineer or dpr.hasAssistantEngineer">
-                                                                AND EXISTS(SELECT 1 FROM t_b_user_archives_allocation tbuaa WHERE tbuaa.crm_detail_id = tbcd.id AND tbuaa.user_id = #{dpr.requestUserId} and tbuaa.sop_role_type = 'ENGINEER')
-                                                            </when>
-                                                        </choose>
-                                                    </otherwise>
                                                 </choose>
                                             </otherwise>
                                         </choose>

+ 5 - 5
sop-business/src/main/resources/mapper/TBQualityProblemApplyMapper.xml

@@ -75,22 +75,22 @@
                     <otherwise>
                         <choose>
                             <when test="dpr.hasBusiness">
-                                AND tbs.service_lead_id = #{dpr.requestUserId}
+                                AND (tbs.service_lead_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = fe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                             </when>
                             <otherwise>
                                 <choose>
                                     <when test="dpr.hasRegionManager">
-                                        AND tbc.lead_id = #{dpr.requestUserId}
+                                        AND (tbc.lead_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = fe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                                     </when>
                                     <otherwise>
                                         <choose>
                                             <when test="dpr.hasRegionCoordinator">
-                                                AND tbc.region_coordinator_id = #{dpr.requestUserId}
+                                                AND (tbc.region_coordinator_id = #{dpr.requestUserId} or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = fe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                                             </when>
                                             <otherwise>
                                                 <choose>
-                                                    <when test="dpr.hasEffectEngineer or dpr.hasAssistantEngineer">
-                                                        AND EXISTS(SELECT 1 FROM t_b_user_archives_allocation tbuaa WHERE tbc.crm_no = tbuaa.crm_no AND tbuaa.user_id = #{dpr.requestUserId})
+                                                    <when test="dpr.hasProjectManager or dpr.hasEffectEngineer or dpr.hasAssistantEngineer">
+                                                        AND (EXISTS(SELECT 1 FROM t_b_user_archives_allocation tbuaa WHERE tbc.crm_no = tbuaa.crm_no AND tbuaa.user_id = #{dpr.requestUserId}) or exists (select 1 from ACT_RU_TASK art where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ = cast(#{dpr.requestUserId} as char) union all select 1 from ACT_RU_TASK art left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_ where art.PROC_INST_ID_ = fe.flow_id and art.ASSIGNEE_ is null and ari.USER_ID_ = cast(#{dpr.requestUserId} as char) and ari.TYPE_ = 'candidate') or EXISTS(SELECT 1 FROM t_f_flow_log tffl where tffl.flow_id = fe.flow_id and tffl.approve_id = #{dpr.requestUserId} and tffl.approve_operation <![CDATA[ <> ]]> 'EXCHANGE'))
                                                     </when>
                                                 </choose>
                                             </otherwise>