|
@@ -10,6 +10,7 @@ import com.lantone.common.domain.UserDto;
|
|
|
import com.lantone.common.dto.GetDeptTreeDTO;
|
|
|
import com.lantone.common.dto.GetHospitalTreeDTO;
|
|
|
import com.lantone.common.dto.GetUserDTO;
|
|
|
+import com.lantone.common.dto.GetUserHospitalDeptDTO;
|
|
|
import com.lantone.common.dto.GetUserHospitalsDTO;
|
|
|
import com.lantone.common.dto.GetUserPageDTO;
|
|
|
import com.lantone.common.dto.SoftwareDTO;
|
|
@@ -496,16 +497,19 @@ public class UserManagementFacade {
|
|
|
public GetUserDTO getUserById(Long userId) {
|
|
|
GetUserDTO getUserDTO = new GetUserDTO();
|
|
|
//1.获取用户的基本信息
|
|
|
- BeanUtils.copyProperties(userFacade.getById(userId), getUserDTO);
|
|
|
+ User user = userFacade.getById(userId);
|
|
|
+ if(user==null){
|
|
|
+ Asserts.fail("该用户不存在请刷新重试~");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(user, getUserDTO);
|
|
|
//2.获取当前用户的组织类型
|
|
|
Hospital hospital = hospitalFacade.getById(SysUserUtils.getCurrentHospitalId());
|
|
|
//3.获取查询用户的科室id列表、医院id列表
|
|
|
List<Long> hospitals = hospitalUserFacade.list(new QueryWrapper<HospitalUser>()
|
|
|
.eq("user_id", userId)
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(HospitalUser::getHospitalId).collect(Collectors.toList());
|
|
|
- List<Long> depts = deptUserFacade.list(new QueryWrapper<DeptUser>()
|
|
|
- .eq("user_id", userId)
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(DeptUser::getDeptId).collect(Collectors.toList());
|
|
|
+ //如果用户属于某医院但是没有科室信息默认为全院
|
|
|
+ List<GetUserHospitalDeptDTO> userHospitalDepts = hospitalUserFacade.getBaseMapper().getUserHospitaDeptById(userId);
|
|
|
//3.2获取当前登录用户的组织机构树
|
|
|
//获取当前医院的树状结构
|
|
|
List<GetHospitalTreeDTO> hospitalTrees = hospitalFacade.getBaseMapper()
|
|
@@ -514,7 +518,7 @@ public class UserManagementFacade {
|
|
|
Map<Long, List<GetHospitalTreeDTO>> hospitalMap = EntityUtil.makeEntityListMap(hospitalTrees, "parentId");
|
|
|
//深度遍历拼装结果
|
|
|
List<GetHospitalTreeDTO> hospitalTree = hospitalMap.get(hospital.getParentId());
|
|
|
- getHospitalDeptInfo(hospitalMap, hospitals, depts, hospitalTree);
|
|
|
+ getHospitalDeptInfo(hospitalMap, hospitals, userHospitalDepts, hospitalTree);
|
|
|
getUserDTO.setHospitals(hospitalTree);
|
|
|
|
|
|
//4.获取用户的角色
|
|
@@ -529,7 +533,7 @@ public class UserManagementFacade {
|
|
|
* @param hospital 当前医院
|
|
|
* @param hospitalMap 医院集
|
|
|
*/
|
|
|
- public void getSonHospital(GetHospitalTreeDTO hospital, Map<Long, List<GetHospitalTreeDTO>> hospitalMap, List<Long> hospitals, List<Long> depts) {
|
|
|
+ public void getSonHospital(GetHospitalTreeDTO hospital, Map<Long, List<GetHospitalTreeDTO>> hospitalMap, List<Long> hospitals, List<GetUserHospitalDeptDTO> userHospitalDepts) {
|
|
|
//通过查询用户所在的医院集添加关联关系
|
|
|
if (hospitals.contains(hospital.getHospitalId())) {
|
|
|
hospital.setRelation(RelationEnum.Y.getName());
|
|
@@ -537,33 +541,46 @@ public class UserManagementFacade {
|
|
|
List<GetHospitalTreeDTO> hospitalTreeDTOS = hospitalMap.get(hospital.getHospitalId());
|
|
|
if (ListUtil.isNotEmpty(hospitalTreeDTOS)) {
|
|
|
hospital.setChildren(hospitalTreeDTOS);
|
|
|
- getHospitalDeptInfo(hospitalMap, hospitals, depts, hospitalTreeDTOS);
|
|
|
+ //获取该医院的子集如果包含hospitals说明已关联
|
|
|
+ List<Long> beanHospitals = hospitalFacade.getBaseMapper().getHospitalTreeInfo(hospital.getHospitalId(),StatusEnum.Enable.getKey())
|
|
|
+ .stream().map(GetHospitalTreeDTO::getHospitalId).collect(Collectors.toList());
|
|
|
+ hospitals.stream().forEach(id->{
|
|
|
+ if(beanHospitals.contains(id)){
|
|
|
+ hospital.setRelation(RelationEnum.Y.getName());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ getHospitalDeptInfo(hospitalMap, hospitals, userHospitalDepts, hospitalTreeDTOS);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param hospitalMap 医院结果级
|
|
|
* @param hospitals 查询用户所在医院集
|
|
|
- * @param depts 查询用户所在科室集
|
|
|
+ * @param userHospitalDepts 查询用户所在科室集
|
|
|
* @param hospitalTreeDTOS 当前遍历医院集
|
|
|
* @Description
|
|
|
* @Return void
|
|
|
*/
|
|
|
- private void getHospitalDeptInfo(Map<Long, List<GetHospitalTreeDTO>> hospitalMap, List<Long> hospitals, List<Long> depts, List<GetHospitalTreeDTO> hospitalTreeDTOS) {
|
|
|
+ private void getHospitalDeptInfo(Map<Long, List<GetHospitalTreeDTO>> hospitalMap, List<Long> hospitals, List<GetUserHospitalDeptDTO> userHospitalDepts, List<GetHospitalTreeDTO> hospitalTreeDTOS) {
|
|
|
|
|
|
for (GetHospitalTreeDTO bean : hospitalTreeDTOS) {
|
|
|
//真实医院添加科室信息
|
|
|
if (HospitalTypeEnum.SINGLE_HOSPITAL.getKey() == Integer.parseInt(bean.getType())) {
|
|
|
List<GetDeptTreeDTO> getDeptTreeDTOList = deptFacade.getBaseMapper().getDeptInfo(bean.getHospitalId());
|
|
|
//通过查询用户所在的科室集添加关联关系
|
|
|
+ List<Long> depts = userHospitalDepts.stream().map(GetUserHospitalDeptDTO::getDeptId).collect(Collectors.toList());
|
|
|
+ List<Long> dHospitals = userHospitalDepts.stream().map(GetUserHospitalDeptDTO::getHospitalId).collect(Collectors.toList());
|
|
|
getDeptTreeDTOList.stream().forEach(getDeptTreeDTO -> {
|
|
|
if (depts.contains(getDeptTreeDTO.getDeptId())) {
|
|
|
getDeptTreeDTO.setRelation(RelationEnum.Y.getName());
|
|
|
+ }else if(hospitals.contains(bean.getHospitalId())&&!dHospitals.contains(bean.getHospitalId())){
|
|
|
+ getDeptTreeDTO.setRelation(RelationEnum.Y.getName());
|
|
|
}
|
|
|
});
|
|
|
bean.setDepts(getDeptTreeDTOList);
|
|
|
}
|
|
|
- getSonHospital(bean, hospitalMap, hospitals, depts);
|
|
|
+ getSonHospital(bean, hospitalMap, hospitals, userHospitalDepts);
|
|
|
}
|
|
|
}
|
|
|
|