Просмотр исходного кода

[task-1840]系统管理角色看不到和检验科同级的其他临床科室

szjbdgzl 1 год назад
Родитель
Сommit
330e908592

+ 19 - 18
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/org/provider/PartyPositionProvider.java

@@ -6,6 +6,9 @@ import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
+import com.lc.ibps.org.party.domain.PartyRole;
+import com.lc.ibps.org.party.persistence.entity.*;
+import com.lc.ibps.org.party.repository.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -38,21 +41,6 @@ import com.lc.ibps.org.party.builder.PartyEntityTreeBuilder;
 import com.lc.ibps.org.party.builder.PartyParamsValidator;
 import com.lc.ibps.org.party.builder.PartyPositionBuilder;
 import com.lc.ibps.org.party.domain.PartyPosition;
-import com.lc.ibps.org.party.persistence.entity.PartyEmployeePo;
-import com.lc.ibps.org.party.persistence.entity.PartyEntityPo;
-import com.lc.ibps.org.party.persistence.entity.PartyEntityTreePo;
-import com.lc.ibps.org.party.persistence.entity.PartyLevelPo;
-import com.lc.ibps.org.party.persistence.entity.PartyOrgPo;
-import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
-import com.lc.ibps.org.party.persistence.entity.PartyRelPo;
-import com.lc.ibps.org.party.persistence.entity.PartyUserPo;
-import com.lc.ibps.org.party.repository.PartyEmployeeRepository;
-import com.lc.ibps.org.party.repository.PartyEntityRepository;
-import com.lc.ibps.org.party.repository.PartyLevelRepository;
-import com.lc.ibps.org.party.repository.PartyOrgRepository;
-import com.lc.ibps.org.party.repository.PartyPositionRepository;
-import com.lc.ibps.org.party.repository.PartyRelRepository;
-import com.lc.ibps.org.party.repository.PartyUserRepository;
 import com.lc.ibps.org.util.PartyUtil;
 import com.lc.ibps.org.vo.IdKeyVo;
 
@@ -91,6 +79,9 @@ public class PartyPositionProvider extends GenericProvider implements IPartyPosi
 	@Resource
 	private PartyEmployeeRepository partyEmployeeRepository;
 
+	@Resource
+	private PartyRoleRepository partyRoleRepository;
+
 	@ApiOperation(value = "岗位列表", notes = "根据传入参数查询,并返回岗位列表")
 	@Override
 	public APIResult<APIPageList<PartyPositionPo>> query(
@@ -828,19 +819,29 @@ public class PartyPositionProvider extends GenericProvider implements IPartyPosi
 			@RequestBody(required = true) APIRequest request) {
 		APIResult<List<PartyEntityTreePo>> result = new APIResult<>();
 		List<PartyEntityTreePo> groupTreeList = new ArrayList<>();
+		// 超管--查看所有  系统管理员--当前用户分院下所有部门  普通用户--当前用户科室下所有部门
 		try{
 			String postId = RequestUtil.getString(request, "posId");
 			if(ContextUtil.isSuper()){
+				// 超管--查看所有
 				groupTreeList = partyEntityRepository.findAllPosition(PartyType.POSITION.getValue(),postId,"");
 			}else {
-				// 查询本岗位数据
 				String userId = ContextUtil.getCurrentUserId();
 				PartyEmployeePo partyEmployee = partyEmployeeRepository.get(userId);
 				if (BeanUtils.isNotEmpty(partyEmployee) && StringUtil.isNotBlank(partyEmployee.getPositions())) {
 					String position = partyEmployee.getPositions().split(",")[0];
 					PartyEntityPo entityPo = partyEntityRepository.get(position);
-					String path3 = entityPo.getPath().split(StringPool.BACK_SLASH+StringPool.DOT)[2];
-					groupTreeList = partyEntityRepository.findAllPosition(PartyType.POSITION.getValue(),"","%"+path3+"%");
+					List<PartyRolePo> rolePos = partyRoleRepository.findUserRolesByUserId(userId);
+					boolean xtgljs = rolePos.stream().anyMatch(role -> "xtgljs".equals(role.getRoleAlias()));
+					String path = "";
+					if (xtgljs){
+						// 系统管理员--当前用户分院下所有部门
+						path = entityPo.getPath().split(StringPool.BACK_SLASH+StringPool.DOT)[0];
+					}else {
+						// 普通用户--当前用户科室下所有部门
+						path = entityPo.getPath().split(StringPool.BACK_SLASH+StringPool.DOT)[2];
+					}
+					groupTreeList = partyEntityRepository.findAllPosition(PartyType.POSITION.getValue(),"","%"+path+"%");
 					if (BeanUtils.isNotEmpty(groupTreeList)){
 						List<PartyEntityTreePo> entityTreeList = new ArrayList<>();
 						for (int i = 0; i < groupTreeList.size(); i++) {