|
@@ -1,5 +1,7 @@
|
|
|
package com.lantone.security.facade;
|
|
|
|
|
|
+import cn.hutool.crypto.digest.BCrypt;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.lantone.common.dto.DownBoxRegionDTO;
|
|
@@ -7,6 +9,7 @@ import com.lantone.common.dto.GetHospitalByIdDTO;
|
|
|
import com.lantone.common.dto.GetHospitalListInfoDTO;
|
|
|
import com.lantone.common.dto.GetHospitalUserDTO;
|
|
|
import com.lantone.common.enums.IsDeleteEnum;
|
|
|
+import com.lantone.common.enums.StatusEnum;
|
|
|
import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.DateUtil;
|
|
|
import com.lantone.common.util.EntityUtil;
|
|
@@ -20,6 +23,7 @@ import com.lantone.common.vo.GetHospitalListInfoVO;
|
|
|
import com.lantone.common.vo.UpdateHospitalVO;
|
|
|
import com.lantone.dblayermbg.entity.DictionaryInfo;
|
|
|
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;
|
|
@@ -67,6 +71,7 @@ public class HospitalManagementFacade {
|
|
|
private RegionFacade regionFacade;
|
|
|
@Autowired
|
|
|
private DictionaryInfoFacade dictionaryInfoFacade;
|
|
|
+
|
|
|
/**
|
|
|
* @param addHospitalVO
|
|
|
* @Description添加组织
|
|
@@ -155,7 +160,7 @@ public class HospitalManagementFacade {
|
|
|
//1.获取用户id
|
|
|
Long userId = hospitalUserFacade.getBaseMapper().getHospitalUserById(hospitalId);
|
|
|
//2.获取角色id
|
|
|
- Long roleId = userRoleFacade.getBaseMapper().getUserRoleById(userId,hospitalId);
|
|
|
+ Long roleId = userRoleFacade.getBaseMapper().getUserRoleById(userId, hospitalId);
|
|
|
if (roleManagementFacade.deleteRole(roleId)) {
|
|
|
//3.删除用户
|
|
|
return userManagementFacade.deleteUser(userId);
|
|
@@ -217,7 +222,7 @@ public class HospitalManagementFacade {
|
|
|
getHospitalByIdDTO.setGetHospitalUserDTO(getHospitalUserDTO);
|
|
|
//3.获取管理角色相关信息
|
|
|
getHospitalByIdDTO.setGetRoleDTO(roleManagementFacade.getRoleById(userRoleFacade.getBaseMapper()
|
|
|
- .getUserRoleById(user.getId(),hospitalId)));
|
|
|
+ .getUserRoleById(user.getId(), hospitalId)));
|
|
|
return getHospitalByIdDTO;
|
|
|
}
|
|
|
|
|
@@ -226,8 +231,8 @@ public class HospitalManagementFacade {
|
|
|
* @Description组织管理列表页管理员下拉框筛选类型、病区查询
|
|
|
* @Return java.util.Map<java.lang.String, java.lang.Object>
|
|
|
*/
|
|
|
- public Map<String, Object> getManagerBoxInfo() {
|
|
|
- Map<String, Object> outMap = new HashMap<>();
|
|
|
+ public Map<Integer, Object> getManagerBoxInfo() {
|
|
|
+ Map<Integer, Object> outMap = new HashMap<>();
|
|
|
Map<Integer, String> hospitalTypeMap = new HashMap<>();
|
|
|
//1.获取当前用户的组织类型
|
|
|
int hospitalType = -1;
|
|
@@ -246,28 +251,13 @@ public class HospitalManagementFacade {
|
|
|
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);
|
|
|
- } 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);
|
|
|
+ outMap.put(DictionaryEnum.REGION.getKey(), downBoxRegions);
|
|
|
+ } else {
|
|
|
+ JSONObject Type = JSONObject.parseObject(dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.HOSPITAL_TYPE.getKey()).get(0).getVal());
|
|
|
+ outMap.put(DictionaryEnum.HOSPITAL_TYPE.getKey(), Type.get(hospitalType));
|
|
|
}
|
|
|
//添加职称信息
|
|
|
- outMap.put(DictionaryEnum.TITLE.getName(),dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.TITLE.getKey()));
|
|
|
+ outMap.put(DictionaryEnum.TITLE.getKey(), dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.TITLE.getKey()));
|
|
|
return outMap;
|
|
|
}
|
|
|
|
|
@@ -287,27 +277,33 @@ public class HospitalManagementFacade {
|
|
|
//单家医院
|
|
|
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;
|
|
|
+ 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<>();
|
|
|
+ if (ListUtil.isNotEmpty(getHospitalListInfoDTO.getDepts())) {
|
|
|
+ getHospitalListInfoDTO.setHasUserFlag(true);
|
|
|
+ }
|
|
|
+ hospitalListInfos.add(getHospitalListInfoDTO);
|
|
|
+ return hospitalListInfos;
|
|
|
//虚拟医院
|
|
|
} else if (hospitalType >= 0) {
|
|
|
List<GetHospitalListInfoDTO> hospitalListInfoDTOS = hospitalFacade.getBaseMapper().getHospitalById(getHospitalListInfoVO);
|
|
|
Map<Long, List<GetHospitalListInfoDTO>> hospitalMaps = EntityUtil.makeEntityListMap(hospitalListInfoDTOS, "parentId");
|
|
|
List<GetHospitalListInfoDTO> hospitalListInfos = hospitalMaps.get(hospital.getParentId());
|
|
|
- for(GetHospitalListInfoDTO bean:hospitalListInfos){
|
|
|
- getSonHospital(bean,hospitalMaps);
|
|
|
+ for (GetHospitalListInfoDTO bean : hospitalListInfos) {
|
|
|
+ //获取该组织是否有子组织、用户
|
|
|
+ getHospitalSonORUser(bean);
|
|
|
+ getSonHospital(bean, hospitalMaps);
|
|
|
}
|
|
|
return hospitalListInfos;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 递归获取医院结构
|
|
|
*
|
|
@@ -316,6 +312,8 @@ public class HospitalManagementFacade {
|
|
|
* @return 空
|
|
|
*/
|
|
|
public void getSonHospital(GetHospitalListInfoDTO hospital, Map<Long, List<GetHospitalListInfoDTO>> hospitalMap) {
|
|
|
+ //获取该组织是否有子组织、用户
|
|
|
+ getHospitalSonORUser(hospital);
|
|
|
List<GetHospitalListInfoDTO> hospitals = hospitalMap.get(hospital.getHospitalId());
|
|
|
if (ListUtil.isNotEmpty(hospitals)) {
|
|
|
hospital.setChildren(hospitals);
|
|
@@ -324,4 +322,33 @@ public class HospitalManagementFacade {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void getHospitalSonORUser(GetHospitalListInfoDTO hospital) {
|
|
|
+ if (hospital != null && hospital.getHospitalId() != null) {
|
|
|
+ //获取该组织用户
|
|
|
+ if(hospitalUserFacade.list(new QueryWrapper<HospitalUser>()
|
|
|
+ .eq("hospital_id",hospital.getHospitalId())
|
|
|
+ .eq("is_deleted",IsDeleteEnum.N.getKey())).size()>1){
|
|
|
+ hospital.setHasUserFlag(true);
|
|
|
+ }
|
|
|
+ //获取该组织子组织
|
|
|
+ if(hospitalFacade.list(new QueryWrapper<Hospital>()
|
|
|
+ .eq("parent_id",hospital.getHospitalId())
|
|
|
+ .eq("status", StatusEnum.Enable.getKey())
|
|
|
+ .eq("is_deleted",IsDeleteEnum.N.getKey())).size()>0){
|
|
|
+ hospital.setHasHospitalFlag(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Description重置密码
|
|
|
+ * @param hospitalId
|
|
|
+ * @Return boolean
|
|
|
+ */
|
|
|
+ public boolean resetPassword(Long hospitalId) {
|
|
|
+ User user = new User();
|
|
|
+ user.setPassword(BCrypt.hashpw(dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.PASSWORD.getKey()).get(0).getVal()));
|
|
|
+ user.setId(userFacade.getBaseMapper().getUserByHospitalId(hospitalId));
|
|
|
+ return userFacade.updateById(user);
|
|
|
+ }
|
|
|
}
|