From 28b899fd77e5e0d22a95558481bfe00b9f4a5de0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=A3=95=E8=B4=A2?= Date: Fri, 10 Nov 2023 17:57:29 +0800 Subject: [PATCH] 2.0 --- .../xm/core/service/XmProductQxService.java | 62 +++++++++-------- .../xm/core/service/XmProjectQxService.java | 67 ++++++++++--------- 2 files changed, 65 insertions(+), 64 deletions(-) diff --git a/xm-core/src/main/java/com/xm/core/service/XmProductQxService.java b/xm-core/src/main/java/com/xm/core/service/XmProductQxService.java index fd481b52..cb0dcc96 100644 --- a/xm-core/src/main/java/com/xm/core/service/XmProductQxService.java +++ b/xm-core/src/main/java/com/xm/core/service/XmProductQxService.java @@ -1,18 +1,16 @@ package com.xm.core.service; import com.mdp.core.entity.Tips; -import com.mdp.safe.client.entity.Dept; import com.mdp.safe.client.entity.User; import com.xm.core.QxTool; import com.xm.core.entity.XmProduct; import com.xm.core.service.client.SysClient; +import com.xm.core.vo.XmGroupVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.util.Arrays; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -50,7 +48,7 @@ public class XmProductQxService { */ public Tips checkProductQx(XmProduct xmProduct, int teamType, User head){ Tips tips= this.checkProductScopeQx(xmProduct,teamType,head.getUserid(),head.getUsername(),head.getBranchId()); - return tips; + return tips; } /** * @@ -80,7 +78,7 @@ public class XmProductQxService { String scopeQx= QxTool.getProductScopeQx(xmProduct.getQxCode(),teamType); memUsername=StringUtils.hasText(memUsername)?memUsername:memUserid; - boolean headIsPm=xmGroupService.checkUserIsProductAdm(xmProduct,head.getUserid()); + boolean headIsPm=xmGroupService.checkUserIsProductAdm(xmProduct,head.getUserid()); if("1".equals(scopeQx)){//同组织 if( !headIsPm && !head.getBranchId().equals(xmProduct.getBranchId())){ tips.setErrMsg("pdqx-scope-branch-0",String.format("产品【%s】只开放给同企业人员,【%s】不在企业【%s】中。",xmProduct.getId(),headUsername,xmProduct.getBranchId())); @@ -105,22 +103,22 @@ public class XmProductQxService { }else if("2".equals(scopeQx)){//同产品 - List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); + List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); if( !headIsPm && !xmGroupService.checkUserExistsGroup(groups, head.getUserid())){ tips.setErrMsg("pdqx-scope-product-0",String.format("产品【%s】只开放给同一个产品团队人员,【%s】不在产品团队中。",xmProduct.getId(),headUsername)); return tips; }; - if(xmGroupService.checkUserIsProductAdm(xmProduct,memUserid)){ - return tips; - } - if( xmGroupService.checkUserExistsGroup(groups,memUserid) ){ - return tips; - }; + if(xmGroupService.checkUserIsProductAdm(xmProduct,memUserid)){ + return tips; + } + if( xmGroupService.checkUserExistsGroup(groups,memUserid) ){ + return tips; + }; tips.setErrMsg("pdqx-scope-product-1",String.format("产品【%s】只开放给同一个产品团队人员,【%s】不在产品团队中。",xmProduct.getId(),memUsername)); return tips; }else if("3".equals(scopeQx)){//同小组 - List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); - List headGroups=groups; + List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); + List headGroups=groups; if( !headIsPm ){ headGroups=xmGroupService.getUserGroups(groups,head.getUserid()); @@ -129,14 +127,14 @@ public class XmProductQxService { return tips; } } - - if(xmGroupService.checkUserIsProductAdm(xmProduct,memUserid)){ - return tips; - } - List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); - if( memGroups!=null && memGroups.size()>0 ){ - return tips; - } + + if(xmGroupService.checkUserIsProductAdm(xmProduct,memUserid)){ + return tips; + } + List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); + if( memGroups!=null && memGroups.size()>0 ){ + return tips; + } tips.setErrMsg("pdqx-scope-team-2",String.format("产品【%s】只开放给同一个产品团队下同一个小组人员,【%s】不在产品团队中。",xmProduct.getId(),memUsername)); return tips; } @@ -212,7 +210,7 @@ public class XmProductQxService { return tips; } - List groups=getProductGroupsFromLocalCache(xmProduct.getId()); + List groups=getProductGroupsFromLocalCache(xmProduct.getId()); if(xmGroupService.checkUserIsOtherUserTeamHeadOrAss(groups, head.getUserid(), memUserid)){ return tips; } @@ -231,7 +229,7 @@ public class XmProductQxService { return tips; } return this.checkProductTransmitQxBatch(xmProduct,teamType,head.getUserid(),memUserids); - } + } public Tips checkProductScopeQxBatch(XmProduct xmProduct,int teamType,User head,String ...memUserids){ Tips tips=new Tips("成功"); @@ -274,7 +272,7 @@ public class XmProductQxService { }else if("2".equals(scopeQx)){//同产品 - List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); + List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); if( !headIsPm && !xmGroupService.checkUserExistsGroup(groups, head.getUserid())){ tips.setErrMsg("pdqx-scope-product-0",String.format("产品【%s】只开放给同一个产品团队人员,【%s】不在产品团队中。",xmProduct.getId(),username)); return tips; @@ -290,8 +288,8 @@ public class XmProductQxService { tips.setErrMsg("pdqx-scope-product-1",String.format("产品【%s】只开放给同一个产品团队人员,【%s】不在产品团队中。",xmProduct.getId(),memUseridSet.stream().collect(Collectors.joining(",")))); return tips; }else if("3".equals(scopeQx)){//同小组 - List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); - List headGroups=groups; + List groups=this.getProductGroupsFromLocalCache(xmProduct.getId()); + List headGroups=groups; if( !headIsPm ){ headGroups=xmGroupService.getUserGroups(groups,head.getUserid()); @@ -304,7 +302,7 @@ public class XmProductQxService { if(xmGroupService.checkUserIsProductAdm(xmProduct,memUserid)){ return tips; } - List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); + List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); if( memGroups!=null && memGroups.size()>0 ){ return tips; } @@ -316,8 +314,8 @@ public class XmProductQxService { } - List getProductGroupsFromLocalCache(String deptid){ - List groupVoList =xmGroupService.getSubDeptList(deptid); + List getProductGroupsFromLocalCache(String productId){ + List groupVoList =xmGroupService.getProductGroupVoList(productId); return groupVoList; } @@ -335,7 +333,7 @@ public class XmProductQxService { if(memUseridSet.size()==0){ return tips; } - List groups=getProductGroupsFromLocalCache(xmProduct.getId()); + List groups=getProductGroupsFromLocalCache(xmProduct.getId()); for (String memUserid : memUseridSet) { if(xmGroupService.checkUserIsOtherUserTeamHeadOrAss(groups,headUserid,memUserid)){ return tips; diff --git a/xm-core/src/main/java/com/xm/core/service/XmProjectQxService.java b/xm-core/src/main/java/com/xm/core/service/XmProjectQxService.java index 08a14211..6f168629 100644 --- a/xm-core/src/main/java/com/xm/core/service/XmProjectQxService.java +++ b/xm-core/src/main/java/com/xm/core/service/XmProjectQxService.java @@ -1,18 +1,16 @@ package com.xm.core.service; import com.mdp.core.entity.Tips; -import com.mdp.safe.client.entity.Dept; import com.mdp.safe.client.entity.User; import com.xm.core.QxTool; import com.xm.core.entity.XmProject; import com.xm.core.service.client.SysClient; +import com.xm.core.vo.XmGroupVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.util.Arrays; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -87,7 +85,7 @@ public class XmProjectQxService { String scopeQx= QxTool.getProjectScopeQx(xmProject.getQxCode(),teamType); memUsername=StringUtils.hasText(memUsername)?memUsername:memUserid; - boolean headIsPm=xmGroupService.checkUserIsProjectAdm(xmProject,head.getUserid()); + boolean headIsPm=xmGroupService.checkUserIsProjectAdm(xmProject,head.getUserid()); if("1".equals(scopeQx)){//同组织 if( !headIsPm && !head.getBranchId().equals(xmProject.getBranchId())){ tips.setErrMsg("pdqx-scope-branch-0",String.format("项目【%s】只开放给同企业人员,【%s】不在企业【%s】中。",xmProject.getId(),headUsername,xmProject.getBranchId())); @@ -112,22 +110,22 @@ public class XmProjectQxService { }else if("2".equals(scopeQx)){//同项目 - List groups=this.getProjectGroupsFromLocalCache(xmProject.getDeptid()); + List groups=this.getProjectGroupsFromLocalCache(xmProject.getId()); if( !headIsPm && !xmGroupService.checkUserExistsGroup(groups, head.getUserid())){ tips.setErrMsg("pdqx-scope-product-0",String.format("项目【%s】只开放给同一个项目团队人员,【%s】不在项目团队中。",xmProject.getId(),headUsername)); return tips; }; - if(xmGroupService.checkUserIsProjectAdm(xmProject,memUserid)){ - return tips; - } - if( xmGroupService.checkUserExistsGroup(groups,memUserid) ){ - return tips; - }; + if(xmGroupService.checkUserIsProjectAdm(xmProject,memUserid)){ + return tips; + } + if( xmGroupService.checkUserExistsGroup(groups,memUserid) ){ + return tips; + }; tips.setErrMsg("pdqx-scope-product-1",String.format("项目【%s】只开放给同一个项目团队人员,【%s】不在项目团队中。",xmProject.getId(),memUsername)); return tips; }else if("3".equals(scopeQx)){//同小组 - List groups=this.getProjectGroupsFromLocalCache(xmProject.getId()); - List headGroups=groups; + List groups=this.getProjectGroupsFromLocalCache(xmProject.getId()); + List headGroups=groups; if( !headIsPm ){ headGroups=xmGroupService.getUserGroups(groups,head.getUserid()); @@ -137,13 +135,13 @@ public class XmProjectQxService { } } - if(xmGroupService.checkUserIsProjectAdm(xmProject,memUserid)){ - return tips; - } - List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); - if( memGroups!=null && memGroups.size()>0 ){ - return tips; - } + if(xmGroupService.checkUserIsProjectAdm(xmProject,memUserid)){ + return tips; + } + List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); + if( memGroups!=null && memGroups.size()>0 ){ + return tips; + } tips.setErrMsg("pdqx-scope-team-2",String.format("项目【%s】只开放给同一个项目团队下同一个小组人员,【%s】不在项目团队中。",xmProject.getId(),memUsername)); return tips; } @@ -219,7 +217,10 @@ public class XmProjectQxService { return tips; } - List groups=getProjectGroupsFromLocalCache(xmProject.getId()); + List groups=getProjectGroupsFromLocalCache(xmProject.getId()); + if(xmGroupService.checkUserIsOtherUserTeamHeadOrAss(groups, head.getUserid(), memUserid)){ + return tips; + } tips.setErrMsg("pdqx-transmit-0", String.format("项目【%s】开启了上下级关系检查,您当前账户【%s】不属于账户【%s】的上级,无权操作。",xmProject.getId(),head.getUsername(),memUsername)); @@ -227,12 +228,14 @@ public class XmProjectQxService { } return tips; } - + public Tips checkProjectQxBatch(XmProject xmProject,int teamType,User head,String ...memUserids){ Tips tips=new Tips("成功"); + if(xmGroupService.checkUserIsProjectAdm(xmProject,head.getUserid())){ + return tips; + } - tips=this.checkProjectScopeQxBatch(xmProject,teamType,head,memUserids); if(!tips.isOk()){ return tips; @@ -281,8 +284,8 @@ public class XmProjectQxService { }else if("2".equals(scopeQx)){//同项目 - List groups= xmGroupService.getSubDeptList(xmProject.getDeptid()); - if( !headIsPm && !xmGroupService.checkUserExistsGroup(groups, head.getUserid())){ + List groups=this.getProjectGroupsFromLocalCache(xmProject.getId()); + if( !headIsPm && !xmGroupService.checkUserExistsGroup(groups, head.getUserid())){ tips.setErrMsg("pdqx-scope-product-0",String.format("项目【%s】只开放给同一个项目团队人员,【%s】不在项目团队中。",xmProject.getId(),username)); return tips; }; @@ -297,8 +300,8 @@ public class XmProjectQxService { tips.setErrMsg("pdqx-scope-product-1",String.format("项目【%s】只开放给同一个项目团队人员,【%s】不在项目团队中。",xmProject.getId(),memUseridSet.stream().collect(Collectors.joining(",")))); return tips; }else if("3".equals(scopeQx)){//同小组 - List groups=this.getProjectGroupsFromLocalCache(xmProject.getId()); - List headGroups=groups; + List groups=this.getProjectGroupsFromLocalCache(xmProject.getId()); + List headGroups=groups; if( !headIsPm ){ headGroups=xmGroupService.getUserGroups(groups,head.getUserid()); @@ -311,7 +314,7 @@ public class XmProjectQxService { if(xmGroupService.checkUserIsProjectAdm(xmProject,memUserid)){ return tips; } - List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); + List memGroups=xmGroupService.getUserGroups(headGroups,memUserid); if( memGroups!=null && memGroups.size()>0 ){ return tips; } @@ -323,8 +326,8 @@ public class XmProjectQxService { } - List getProjectGroupsFromLocalCache(String deptid){ - List groupVoList= xmGroupService.getSubDeptList(deptid); + List getProjectGroupsFromLocalCache(String projectId){ + List groupVoList= xmGroupService.getProjectGroupVoList(projectId); return groupVoList; } @@ -343,7 +346,7 @@ public class XmProjectQxService { if(memUseridSet.size()==0){ return tips; } - List groups=getProjectGroupsFromLocalCache(xmProject.getId()); + List groups=getProjectGroupsFromLocalCache(xmProject.getId()); for (String memUserid : memUseridSet) { if(xmGroupService.checkUserIsOtherUserTeamHeadOrAss(groups,headUserid,memUserid)){ return tips;