|
@@ -2,26 +2,27 @@ package com.lantone.security.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
-import com.graphbuilder.math.func.FactFunction;
|
|
|
import com.lantone.common.dto.DownBoxRegionDTO;
|
|
|
-import com.lantone.common.dto.GetDeptTreeDTO;
|
|
|
import com.lantone.common.dto.GetHospitalByIdDTO;
|
|
|
-import com.lantone.common.dto.GetHospitalTreeDTO;
|
|
|
+import com.lantone.common.dto.GetHospitalListInfoDTO;
|
|
|
import com.lantone.common.dto.GetHospitalUserDTO;
|
|
|
import com.lantone.common.enums.IsDeleteEnum;
|
|
|
import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.DateUtil;
|
|
|
+import com.lantone.common.util.EntityUtil;
|
|
|
+import com.lantone.common.util.ListUtil;
|
|
|
import com.lantone.common.vo.AddHospitalTreeVO;
|
|
|
-import com.lantone.common.vo.AddHospitalUserVO;
|
|
|
import com.lantone.common.vo.AddHospitalVO;
|
|
|
import com.lantone.common.vo.AddRoleVO;
|
|
|
import com.lantone.common.vo.AddUserVO;
|
|
|
+import com.lantone.common.vo.GetHospitalListInfoVO;
|
|
|
import com.lantone.common.vo.UpdateHospitalVO;
|
|
|
import com.lantone.dblayermbg.entity.Hospital;
|
|
|
import com.lantone.dblayermbg.entity.HospitalUser;
|
|
|
import com.lantone.dblayermbg.entity.Region;
|
|
|
import com.lantone.dblayermbg.entity.Role;
|
|
|
import com.lantone.dblayermbg.entity.User;
|
|
|
+import com.lantone.dblayermbg.facade.DeptFacade;
|
|
|
import com.lantone.dblayermbg.facade.HospitalFacade;
|
|
|
import com.lantone.dblayermbg.facade.HospitalUserFacade;
|
|
|
import com.lantone.dblayermbg.facade.RegionFacade;
|
|
@@ -47,6 +48,8 @@ public class HospitalManagementFacade {
|
|
|
@Autowired
|
|
|
private HospitalFacade hospitalFacade;
|
|
|
@Autowired
|
|
|
+ private DeptFacade deptFacade;
|
|
|
+ @Autowired
|
|
|
private HospitalUserFacade hospitalUserFacade;
|
|
|
@Autowired
|
|
|
private UserRoleFacade userRoleFacade;
|
|
@@ -116,17 +119,18 @@ public class HospitalManagementFacade {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * @Description删除组织
|
|
|
* @param hospitalId
|
|
|
+ * @Description删除组织
|
|
|
* @Return boolean
|
|
|
*/
|
|
|
public boolean deleteHospital(Long hospitalId) {
|
|
|
//1.删除组织表sys_hospital
|
|
|
- if(hospitalFacade.removeById(hospitalId)){
|
|
|
+ if (hospitalFacade.removeById(hospitalId)) {
|
|
|
//2.删除该组织的管理用户、角色
|
|
|
return deleteHUserAndRole(hospitalId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
Asserts.fail("组织表删除失败");
|
|
|
}
|
|
|
|
|
@@ -134,18 +138,18 @@ public class HospitalManagementFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description删除该组织的管理用户、角色
|
|
|
* @param hospitalId
|
|
|
+ * @Description删除该组织的管理用户、角色
|
|
|
* @Return boolean
|
|
|
*/
|
|
|
private boolean deleteHUserAndRole(Long hospitalId) {
|
|
|
//1.获取用户id
|
|
|
Long userId = hospitalUserFacade.getBaseMapper().getHospitalUserById(hospitalId);
|
|
|
- if(userManagementFacade.deleteUser(userId)){
|
|
|
+ if (userManagementFacade.deleteUser(userId)) {
|
|
|
//2.获取角色id
|
|
|
Long roleId = userRoleFacade.getBaseMapper().getUserRoleById(userId);
|
|
|
return roleManagementFacade.deleteRole(roleId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
Asserts.fail("管理用户删除失败");
|
|
|
}
|
|
|
|
|
@@ -153,69 +157,69 @@ public class HospitalManagementFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description修改组织信息
|
|
|
* @param updateHospitalVO
|
|
|
+ * @Description修改组织信息
|
|
|
* @Return boolean
|
|
|
*/
|
|
|
public boolean updateHospital(UpdateHospitalVO updateHospitalVO) {
|
|
|
//1.删除该组织关联的管理用户以及角色
|
|
|
- if(deleteHUserAndRole(updateHospitalVO.getId())){
|
|
|
+ if (deleteHUserAndRole(updateHospitalVO.getId())) {
|
|
|
Hospital hospital = new Hospital();
|
|
|
- BeanUtils.copyProperties(updateHospitalVO,hospital);
|
|
|
+ BeanUtils.copyProperties(updateHospitalVO, hospital);
|
|
|
//2.修改组织信息
|
|
|
- if(hospitalFacade.updateById(hospital)){
|
|
|
+ if (hospitalFacade.updateById(hospital)) {
|
|
|
//3.创建组织与管理用户、角色
|
|
|
AddHospitalVO addHospitalVO = new AddHospitalVO();
|
|
|
- BeanUtils.copyProperties(addHospitalVO,updateHospitalVO);
|
|
|
+ BeanUtils.copyProperties(addHospitalVO, updateHospitalVO);
|
|
|
addHospitalVO.setAddHospitalUserVO(updateHospitalVO.getAddHospitalUserVO());
|
|
|
addHospitalVO.setSoftwares(updateHospitalVO.getSoftwares());
|
|
|
- return saveUser(updateHospitalVO.getId(),addHospitalVO);
|
|
|
+ return saveUser(updateHospitalVO.getId(), addHospitalVO);
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description禁用启用组织
|
|
|
* @param hospitalId
|
|
|
* @param status
|
|
|
+ * @Description禁用启用组织
|
|
|
* @Return boolean
|
|
|
*/
|
|
|
public boolean disableHospital(Long hospitalId, String status) {
|
|
|
- return hospitalFacade.update(new UpdateWrapper<Hospital>().set("status",status).eq("id",hospitalId));
|
|
|
+ return hospitalFacade.update(new UpdateWrapper<Hospital>().set("status", status).eq("id", hospitalId));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description通过组织id获取该组织及用户详情
|
|
|
* @param hospitalId
|
|
|
* @param local
|
|
|
+ * @Description通过组织id获取该组织及用户详情
|
|
|
* @Return com.lantone.common.dto.GetHospitalByIdDTO
|
|
|
*/
|
|
|
public GetHospitalByIdDTO getHospitalById(Long hospitalId, Long local) {
|
|
|
GetHospitalByIdDTO getHospitalByIdDTO = new GetHospitalByIdDTO();
|
|
|
//1.获取医院详情
|
|
|
Hospital hospital = hospitalFacade.getById(hospitalId);
|
|
|
- BeanUtils.copyProperties(hospital,getHospitalByIdDTO);
|
|
|
+ BeanUtils.copyProperties(hospital, getHospitalByIdDTO);
|
|
|
getHospitalByIdDTO.setParentName(hospitalFacade.getById(hospital.getParentId()).getName());
|
|
|
//2.获取该医院的管理用户详情
|
|
|
User user = userFacade.getById(hospitalUserFacade.getBaseMapper().getHospitalUserById(hospitalId));
|
|
|
GetHospitalUserDTO getHospitalUserDTO = new GetHospitalUserDTO();
|
|
|
- BeanUtils.copyProperties(user,getHospitalUserDTO);
|
|
|
+ BeanUtils.copyProperties(user, getHospitalUserDTO);
|
|
|
getHospitalByIdDTO.setGetHospitalUserDTO(getHospitalUserDTO);
|
|
|
//3.获取管理角色相关信息
|
|
|
getHospitalByIdDTO.setGetRoleDTO(roleManagementFacade.getRoleById(userRoleFacade.getBaseMapper()
|
|
|
- .getUserRoleById(user.getId())));
|
|
|
+ .getUserRoleById(user.getId())));
|
|
|
return getHospitalByIdDTO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description组织管理列表页管理员下拉框筛选类型、病区查询
|
|
|
* @param
|
|
|
- * @Return java.util.Map<java.lang.String,java.lang.Object>
|
|
|
+ * @Description组织管理列表页管理员下拉框筛选类型、病区查询
|
|
|
+ * @Return java.util.Map<java.lang.String, java.lang.Object>
|
|
|
*/
|
|
|
- public Map<String,Object> getManagerBoxInfo(Long local) {
|
|
|
- Map<String,Object> outMap = new HashMap<>();
|
|
|
- Map<Integer,String> hospitalTypeMap = new HashMap<>();
|
|
|
+ public Map<String, Object> getManagerBoxInfo(Long local) {
|
|
|
+ Map<String, Object> outMap = new HashMap<>();
|
|
|
+ Map<Integer, String> hospitalTypeMap = new HashMap<>();
|
|
|
//1.获取当前用户的组织类型
|
|
|
int hospitalType = -1;
|
|
|
Hospital hospital = hospitalFacade.getById(local);//###当前登录用户的医院id
|
|
@@ -227,36 +231,85 @@ public class HospitalManagementFacade {
|
|
|
//获取病区信息
|
|
|
List<DownBoxRegionDTO> downBoxRegions = new ArrayList<>();
|
|
|
regionFacade.list(new QueryWrapper<Region>()
|
|
|
- .eq("hospital_id",hospital.getId())
|
|
|
+ .eq("hospital_id", hospital.getId())
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())).stream().forEach(region -> {
|
|
|
DownBoxRegionDTO downBoxRegionDTO = new DownBoxRegionDTO();
|
|
|
- BeanUtils.copyProperties(region,downBoxRegionDTO);
|
|
|
+ BeanUtils.copyProperties(region, downBoxRegionDTO);
|
|
|
downBoxRegions.add(downBoxRegionDTO);
|
|
|
});
|
|
|
- outMap.put("所属病区",downBoxRegions);
|
|
|
- }else if (HospitalTypeEnum.AI_PLATFORM.getKey()== hospitalType) {
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.GROUP_HOSPITAL.getKey(),HospitalTypeEnum.GROUP_HOSPITAL.getName());
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(),HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.COMMON_HOSPITAL.getKey(),HospitalTypeEnum.COMMON_HOSPITAL.getName());
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.UNION_HOSPITAL.getKey(),HospitalTypeEnum.UNION_HOSPITAL.getName());
|
|
|
- outMap.put("类型",hospitalTypeMap);
|
|
|
+ outMap.put("所属病区", downBoxRegions);
|
|
|
+ } else if (HospitalTypeEnum.AI_PLATFORM.getKey() == hospitalType) {
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.GROUP_HOSPITAL.getKey(), HospitalTypeEnum.GROUP_HOSPITAL.getName());
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.COMMON_HOSPITAL.getKey(), HospitalTypeEnum.COMMON_HOSPITAL.getName());
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.UNION_HOSPITAL.getKey(), HospitalTypeEnum.UNION_HOSPITAL.getName());
|
|
|
+ outMap.put("类型", hospitalTypeMap);
|
|
|
+ } else if (HospitalTypeEnum.GROUP_HOSPITAL.getKey() == hospitalType) {
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.GROUP_HOSPITAL.getKey(), HospitalTypeEnum.GROUP_HOSPITAL.getName());
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
+ outMap.put("类型", hospitalTypeMap);
|
|
|
+ } else if (HospitalTypeEnum.COMMON_HOSPITAL.getKey() == hospitalType) {
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.COMMON_HOSPITAL.getKey(), HospitalTypeEnum.COMMON_HOSPITAL.getName());
|
|
|
+ outMap.put("类型", hospitalTypeMap);
|
|
|
+ } else if (HospitalTypeEnum.UNION_HOSPITAL.getKey() == hospitalType) {
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
+ hospitalTypeMap.put(HospitalTypeEnum.UNION_HOSPITAL.getKey(), HospitalTypeEnum.UNION_HOSPITAL.getName());
|
|
|
+ outMap.put("类型", hospitalTypeMap);
|
|
|
}
|
|
|
- else if (HospitalTypeEnum.GROUP_HOSPITAL.getKey()== hospitalType) {
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.GROUP_HOSPITAL.getKey(),HospitalTypeEnum.GROUP_HOSPITAL.getName());
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(),HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
- outMap.put("类型",hospitalTypeMap);
|
|
|
+ return outMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param getHospitalListInfoVO
|
|
|
+ * @Description获取当前登录用户的组织结构树
|
|
|
+ * @Return java.util.List<com.lantone.common.dto.GetHospitalListInfoDTO>
|
|
|
+ */
|
|
|
+ public List<GetHospitalListInfoDTO> getHospitalListInfo(GetHospitalListInfoVO getHospitalListInfoVO) {
|
|
|
+ //1.获取当前用户的组织类型
|
|
|
+ int hospitalType = -1;
|
|
|
+ Hospital hospital = hospitalFacade.getById(getHospitalListInfoVO.getHospitalId());//###当前登录用户的医院id
|
|
|
+ if (hospital != null) {
|
|
|
+ hospitalType = Integer.parseInt(hospital.getType());
|
|
|
}
|
|
|
- else if (HospitalTypeEnum.COMMON_HOSPITAL.getKey()== hospitalType) {
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(),HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.COMMON_HOSPITAL.getKey(),HospitalTypeEnum.COMMON_HOSPITAL.getName());
|
|
|
- outMap.put("类型",hospitalTypeMap);
|
|
|
+ //单家医院
|
|
|
+ if (HospitalTypeEnum.SINGLE_HOSPITAL.getKey() == hospitalType) {
|
|
|
+ //1.获取当前登陆用户所在医院的科室信息
|
|
|
+ GetHospitalListInfoDTO getHospitalListInfoDTO = new GetHospitalListInfoDTO();
|
|
|
+ getHospitalListInfoDTO.setHospitalId(hospital.getId());
|
|
|
+ getHospitalListInfoDTO.setHospitalName(hospital.getName());
|
|
|
+ BeanUtils.copyProperties(hospital,getHospitalListInfoDTO);
|
|
|
+ getHospitalListInfoDTO.setDepts(deptFacade.getBaseMapper().getDeptRegion(getHospitalListInfoVO));
|
|
|
+ List<GetHospitalListInfoDTO> hospitalListInfos = new ArrayList<>();
|
|
|
+ hospitalListInfos.add(getHospitalListInfoDTO);
|
|
|
+ return hospitalListInfos;
|
|
|
+ //虚拟医院
|
|
|
+ } else if (hospitalType >= 0) {
|
|
|
+ List<GetHospitalListInfoDTO> hospitalListInfoDTOS = hospitalFacade.getBaseMapper().getHospitalById(getHospitalListInfoVO);//###当前登录用户的医院id
|
|
|
+ Map<Long, List<GetHospitalListInfoDTO>> hospitalMaps = EntityUtil.makeEntityListMap(hospitalListInfoDTOS, "parentId");
|
|
|
+ List<GetHospitalListInfoDTO> hospitalListInfos = hospitalMaps.get(hospital.getParentId());
|
|
|
+ for(GetHospitalListInfoDTO bean:hospitalListInfos){
|
|
|
+ getSonHospital(bean,hospitalMaps);
|
|
|
+ }
|
|
|
+ return hospitalListInfos;
|
|
|
}
|
|
|
- else if (HospitalTypeEnum.UNION_HOSPITAL.getKey()== hospitalType) {
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(),HospitalTypeEnum.SINGLE_HOSPITAL.getName());
|
|
|
- hospitalTypeMap.put(HospitalTypeEnum.UNION_HOSPITAL.getKey(),HospitalTypeEnum.UNION_HOSPITAL.getName());
|
|
|
- outMap.put("类型",hospitalTypeMap);
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 递归获取医院结构
|
|
|
+ *
|
|
|
+ * @param hospital 当前医院
|
|
|
+ * @param hospitalMap 医院集
|
|
|
+ * @return 空
|
|
|
+ */
|
|
|
+ public void getSonHospital(GetHospitalListInfoDTO hospital, Map<Long, List<GetHospitalListInfoDTO>> hospitalMap) {
|
|
|
+ List<GetHospitalListInfoDTO> hospitals = hospitalMap.get(hospital.getHospitalId());
|
|
|
+ if (ListUtil.isNotEmpty(hospitals)) {
|
|
|
+ hospital.setHospitalDTOS(hospitals);
|
|
|
+ for (GetHospitalListInfoDTO bean : hospitals) {
|
|
|
+ getSonHospital(bean, hospitalMap);
|
|
|
+ }
|
|
|
}
|
|
|
- return outMap;
|
|
|
}
|
|
|
-
|
|
|
}
|