|
@@ -1,11 +1,13 @@
|
|
|
package com.lantone.security.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.lantone.common.dto.DataAuthDTO;
|
|
|
import com.lantone.common.dto.DataAuthDetailDTO;
|
|
|
+import com.lantone.common.dto.DeptDTO;
|
|
|
import com.lantone.common.dto.HospitalDTO;
|
|
|
import com.lantone.common.dto.RoleDTO;
|
|
|
import com.lantone.common.dto.ServiceRoleDataAuthDetailDTO;
|
|
@@ -19,6 +21,7 @@ import com.lantone.common.vo.ServiceDataAuthVO;
|
|
|
import com.lantone.common.vo.SysServiceVO;
|
|
|
import com.lantone.dblayermbg.entity.DataAuth;
|
|
|
import com.lantone.dblayermbg.entity.DataAuthDetail;
|
|
|
+import com.lantone.dblayermbg.entity.Dept;
|
|
|
import com.lantone.dblayermbg.entity.Hospital;
|
|
|
import com.lantone.dblayermbg.entity.RoleServiceDataAuth;
|
|
|
import com.lantone.dblayermbg.entity.ServiceDataAuth;
|
|
@@ -31,6 +34,7 @@ import com.lantone.dblayermbg.facade.ServiceDataAuthFacade;
|
|
|
import com.lantone.dblayermbg.service.impl.DataAuthServiceImpl;
|
|
|
import com.lantone.security.enums.CRUDEnum;
|
|
|
import com.lantone.security.enums.DataAuthDataTypeEnum;
|
|
|
+import com.lantone.security.enums.DataAuthDetailTypeEnum;
|
|
|
import com.lantone.security.enums.HospitalTypeEnum;
|
|
|
import com.lantone.security.enums.ServiceEnum;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -41,7 +45,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
-import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -69,17 +72,17 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* @Author songxl
|
|
|
- * @Description 数据权限新增or修改方法
|
|
|
+ * @Description 数据权限CRUD方法
|
|
|
* @Date 2021/7/21
|
|
|
* @Param [serviceDataAuthVO]
|
|
|
* @Return void
|
|
|
- * @MethodName addOrUpdate
|
|
|
+ * @MethodName CRUDOperation
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public boolean addOrUpdate(ServiceDataAuthVO serviceDataAuthVO) {
|
|
|
+ public boolean CRUDOperation(ServiceDataAuthVO serviceDataAuthVO) {
|
|
|
//1.入参校验
|
|
|
inputParamCheck(serviceDataAuthVO);
|
|
|
- //2.执行增加、修改操作
|
|
|
+ //2.执行操作
|
|
|
if (CRUDEnum.ADD.getKey() == serviceDataAuthVO.getType()) {
|
|
|
try {
|
|
|
return addDataAuth(serviceDataAuthVO);
|
|
@@ -88,16 +91,101 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, e.toString());
|
|
|
}
|
|
|
} else if (CRUDEnum.UPDATE.getKey() == serviceDataAuthVO.getType()) {
|
|
|
-
|
|
|
+ return updateDataAuth(serviceDataAuthVO);
|
|
|
+ } else if (CRUDEnum.DELETE.getKey() == serviceDataAuthVO.getType()) {
|
|
|
+ return deleteDataAuth(serviceDataAuthVO);
|
|
|
} else {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "操作码错误");
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description修改数据权限
|
|
|
+ * @Date 2021/7/23
|
|
|
+ * @Param [serviceDataAuthVO]
|
|
|
+ * @Return boolean
|
|
|
+ * @MethodName updateDataAuth
|
|
|
+ */
|
|
|
+ private boolean updateDataAuth(ServiceDataAuthVO serviceDataAuthVO) {
|
|
|
+
|
|
|
+ //1.修改数据权限
|
|
|
+ boolean dataAuthUpdate = dataAuthFacade.update(new UpdateWrapper<DataAuth>()
|
|
|
+ .set("auth_name", serviceDataAuthVO.getDataAuthVO().getAuthName())
|
|
|
+ .eq("id", serviceDataAuthVO.getDataAuthVO().getId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ if (dataAuthUpdate) {
|
|
|
+ //2.获取该权限 系统与数据权限信息关联表(sys_service_data_auth)的关联id
|
|
|
+ List<Long> serviceDataAuthIDS = serviceDataAuthFacade.list(new QueryWrapper<ServiceDataAuth>()
|
|
|
+ .eq("data_auth_id", serviceDataAuthVO.getDataAuthVO().getId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(ServiceDataAuth::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(serviceDataAuthIDS)) {
|
|
|
+ //3.获取该权限关联的角色id
|
|
|
+// List<Long> roleIDS = roleServiceDataAuthFacade.list(new QueryWrapper<RoleServiceDataAuth>()
|
|
|
+// .in("service_data_auth_id", serviceDataAuthIDS)
|
|
|
+// .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(RoleServiceDataAuth::getRoleId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //4.通过serviceDataAuthIDS 删除sys_role_service_data_auth和sys_service_data_auth和sys_data_auth_detail 对应关系
|
|
|
+ if (deleteServiceDataAuth(serviceDataAuthIDS)) {
|
|
|
+ //5.插入新建数据权限与系统的关系
|
|
|
+ saveServiceDataAuth(serviceDataAuthVO, serviceDataAuthVO.getDataAuthVO().getId());
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限与系统关系删除失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限修改失败");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description通过serviceDataAuthIDS删除sys_role_service_data_auth和sys_service_data_auth和sys_data_auth_detail对应关系
|
|
|
+ * @Date 2021/7/23
|
|
|
+ * @Param [serviceDataAuthIDS]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName deleteServiceDataAuth
|
|
|
+ */
|
|
|
+ private boolean deleteServiceDataAuth(List<Long> serviceDataAuthIDS) {
|
|
|
+ if (dataAuthDetailFacade.remove(new UpdateWrapper<DataAuthDetail>()
|
|
|
+ .in("service_data_auth_id", serviceDataAuthIDS)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()))) {
|
|
|
+ if (roleServiceDataAuthFacade.remove(new UpdateWrapper<RoleServiceDataAuth>()
|
|
|
+ .in("service_data_auth_id", serviceDataAuthIDS)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()))) {
|
|
|
+ return serviceDataAuthFacade.remove(new UpdateWrapper<ServiceDataAuth>()
|
|
|
+ .in("id", serviceDataAuthIDS)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限与系统、角色关联关系删除失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "系统数据权限与数据权限明细关联关系删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description删除数据权限
|
|
|
+ * @Date 2021/7/23
|
|
|
+ * @Param [serviceDataAuthVO]
|
|
|
+ * @Return boolean
|
|
|
+ * @MethodName deleteDataAuth
|
|
|
+ */
|
|
|
+ private boolean deleteDataAuth(ServiceDataAuthVO serviceDataAuthVO) {
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Author songxl
|
|
|
- * @Description 添加数据权限
|
|
|
+ * @Description添加数据权限
|
|
|
* @Date 2021/7/21
|
|
|
* @Param [serviceDataAuthVO]
|
|
|
* @Return void
|
|
@@ -118,51 +206,7 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())).get(0).getId();
|
|
|
|
|
|
//3.插入新建数据权限与系统的关系
|
|
|
- for (SysServiceVO sysServiceVO : serviceDataAuthVO.getDataAuthVO().getServiceVOS()) {
|
|
|
- ServiceDataAuth serviceDataAuth = new ServiceDataAuth();
|
|
|
- serviceDataAuth.setServiceId(sysServiceVO.getId());
|
|
|
- serviceDataAuth.setDataAuthId(dataAuthId);
|
|
|
- serviceDataAuth.setCreateTime(DateUtil.now());
|
|
|
- serviceDataAuth.setCreator(1l);
|
|
|
- // serviceDataAuth.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
- boolean serviceDataAuthInsert = serviceDataAuthFacade.save(serviceDataAuth);
|
|
|
- if (serviceDataAuthInsert) {
|
|
|
- //4.获取上一步插入时新生成的数据权限名称与系统关联编号service_data_auth _id
|
|
|
- Long serviceDataAuthId = serviceDataAuthFacade.list(new QueryWrapper<ServiceDataAuth>()
|
|
|
- .eq("service_id", sysServiceVO.getId())
|
|
|
- .eq("data_auth_id", dataAuthId)
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())).get(0).getId();
|
|
|
-
|
|
|
- //5.插入数据权限系统关联表与角色管理sys_role_service_data_auth
|
|
|
- for (RoleVO role : serviceDataAuthVO.getRoles()) {
|
|
|
- RoleServiceDataAuth roleServiceDataAuth = new RoleServiceDataAuth();
|
|
|
- roleServiceDataAuth.setRoleId(role.getId());
|
|
|
- roleServiceDataAuth.setServiceDataAuthId(serviceDataAuthId);
|
|
|
- roleServiceDataAuth.setCreateTime(DateUtil.now());
|
|
|
- roleServiceDataAuth.setCreator(1l);
|
|
|
- // roleServiceDataAuth.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
- if (!roleServiceDataAuthFacade.save(roleServiceDataAuth)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "角色对应服务数据权限关系插入失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //6.插入数据权限详细信息。sys_data_auth_detail
|
|
|
- for (DataAuthDetailVO dataAuthDetailVO : sysServiceVO.getDataAuthDetailVOS()) {
|
|
|
- DataAuthDetail dataAuthDetail = new DataAuthDetail();
|
|
|
- BeanUtils.copyProperties(dataAuthDetailVO, dataAuthDetail);
|
|
|
- // dataAuthDetail.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
- dataAuthDetail.setCreator(1l);
|
|
|
- dataAuthDetail.setCreateTime(DateUtil.now());
|
|
|
- dataAuthDetail.setServiceDataAuthId(serviceDataAuthId);
|
|
|
- if (!dataAuthDetailFacade.save(dataAuthDetail)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限明细插入失败");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "服务对应数据权限关系插入失败");
|
|
|
- }
|
|
|
- }
|
|
|
+ saveServiceDataAuth(serviceDataAuthVO, dataAuthId);
|
|
|
|
|
|
} else {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限插入失败");
|
|
@@ -171,6 +215,62 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description插入新建数据权限与系统的关系
|
|
|
+ * @Date 2021/7/23
|
|
|
+ * @Param [serviceDataAuthVO, dataAuthId]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName saveServiceDataAuth
|
|
|
+ */
|
|
|
+ private void saveServiceDataAuth(ServiceDataAuthVO serviceDataAuthVO, Long dataAuthId) {
|
|
|
+ for (SysServiceVO sysServiceVO : serviceDataAuthVO.getDataAuthVO().getServiceVOS()) {
|
|
|
+ ServiceDataAuth serviceDataAuth = new ServiceDataAuth();
|
|
|
+ serviceDataAuth.setServiceId(sysServiceVO.getId());
|
|
|
+ serviceDataAuth.setDataAuthId(dataAuthId);
|
|
|
+ serviceDataAuth.setCreateTime(DateUtil.now());
|
|
|
+ serviceDataAuth.setCreator(1l);
|
|
|
+ // serviceDataAuth.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
+ boolean serviceDataAuthInsert = serviceDataAuthFacade.save(serviceDataAuth);
|
|
|
+ if (serviceDataAuthInsert) {
|
|
|
+ //1.获取上一步插入时新生成的数据权限名称与系统关联编号service_data_auth _id
|
|
|
+ Long serviceDataAuthId = serviceDataAuthFacade.list(new QueryWrapper<ServiceDataAuth>()
|
|
|
+ .eq("service_id", sysServiceVO.getId())
|
|
|
+ .eq("data_auth_id", dataAuthId)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())).get(0).getId();
|
|
|
+
|
|
|
+ //2.插入数据权限系统关联表与角色管理sys_role_service_data_auth
|
|
|
+ for (RoleVO role : serviceDataAuthVO.getRoles()) {
|
|
|
+ RoleServiceDataAuth roleServiceDataAuth = new RoleServiceDataAuth();
|
|
|
+ roleServiceDataAuth.setRoleId(role.getId());
|
|
|
+ roleServiceDataAuth.setServiceDataAuthId(serviceDataAuthId);
|
|
|
+ roleServiceDataAuth.setCreateTime(DateUtil.now());
|
|
|
+ roleServiceDataAuth.setCreator(1l);
|
|
|
+ // roleServiceDataAuth.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
+ if (!roleServiceDataAuthFacade.save(roleServiceDataAuth)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "角色对应服务数据权限关系插入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //3.插入数据权限详细信息。sys_data_auth_detail
|
|
|
+ for (DataAuthDetailVO dataAuthDetailVO : sysServiceVO.getDataAuthDetailVOS()) {
|
|
|
+ DataAuthDetail dataAuthDetail = new DataAuthDetail();
|
|
|
+ BeanUtils.copyProperties(dataAuthDetailVO, dataAuthDetail);
|
|
|
+ // dataAuthDetail.setCreator(Long.parseLong(SysUserUtils.getCurrentPrincipleID()));
|
|
|
+ dataAuthDetail.setCreator(1l);
|
|
|
+ dataAuthDetail.setCreateTime(DateUtil.now());
|
|
|
+ dataAuthDetail.setServiceDataAuthId(serviceDataAuthId);
|
|
|
+ if (!dataAuthDetailFacade.save(dataAuthDetail)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "数据权限明细插入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "服务对应数据权限关系插入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Author songxl
|
|
|
* @Description 入参校验
|
|
@@ -186,15 +286,39 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
if (serviceDataAuthVO.getType() == 0) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "操作码为空");
|
|
|
}
|
|
|
- if (StringUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getAuthName())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限名称为空");
|
|
|
- }
|
|
|
- if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限对应系统未选择");
|
|
|
- }
|
|
|
- if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS().get(0).getDataAuthDetailVOS())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "系统对应数据权限明细未选择");
|
|
|
+ switch (serviceDataAuthVO.getType()) {
|
|
|
+ case 1:
|
|
|
+ if (StringUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getAuthName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限名称为空");
|
|
|
+ }
|
|
|
+ if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限对应系统未选择");
|
|
|
+ }
|
|
|
+ if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS().get(0).getDataAuthDetailVOS())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "系统对应数据权限明细未选择");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (serviceDataAuthVO.getDataAuthVO().getId() == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限ID为空");
|
|
|
+ }
|
|
|
+ if (StringUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getAuthName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限名称为空");
|
|
|
+ }
|
|
|
+ if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "数据权限对应系统未选择");
|
|
|
+ }
|
|
|
+ if (ListUtil.isEmpty(serviceDataAuthVO.getDataAuthVO().getServiceVOS().get(0).getDataAuthDetailVOS())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "系统对应数据权限明细未选择");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -227,20 +351,20 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
|
|
|
List<DataAuthDetailDTO> dataAuthDetailDTOS = new ArrayList<>();
|
|
|
//4.2.1是否获取当前组织-科室信息
|
|
|
- AtomicBoolean selectFalg = new AtomicBoolean(false);
|
|
|
oneServiceRoleDataAuthDetailDTOS.stream().forEach(serviceRoleDataAuthDetailDTO -> {
|
|
|
DataAuthDetailDTO dataAuthDetailDTO = new DataAuthDetailDTO();
|
|
|
dataAuthDetailDTO.setId(serviceRoleDataAuthDetailDTO.getDetail());
|
|
|
dataAuthDetailDTO.setDataType(serviceRoleDataAuthDetailDTO.getDataType());
|
|
|
dataAuthDetailDTO.setDetailType(serviceRoleDataAuthDetailDTO.getDetailType());
|
|
|
dataAuthDetailDTO.setDetailId(serviceRoleDataAuthDetailDTO.getDetailId());
|
|
|
- if (DataAuthDataTypeEnum.CUSTOMIZE.getKey() == serviceRoleDataAuthDetailDTO.getDataType()) {
|
|
|
- selectFalg.set(true);
|
|
|
+ if (DataAuthDataTypeEnum.CUSTOMIZE.getKey() == serviceRoleDataAuthDetailDTO.getDataType()
|
|
|
+ && serviceRoleDataAuthDetailDTO.getDetailType() != null
|
|
|
+ && DataAuthDetailTypeEnum.DEPT.getKey() == serviceRoleDataAuthDetailDTO.getDetailType()) {
|
|
|
+ //4.2.3selectFalg为true时查询组织-科室信息
|
|
|
+ getDeptDetial(dataAuthDetailDTO);
|
|
|
}
|
|
|
dataAuthDetailDTOS.add(dataAuthDetailDTO);
|
|
|
});
|
|
|
- //4.2.3selectFalg为true时查询组织-科室信息
|
|
|
- getDeptDetial(dataAuthDetailDTOS);
|
|
|
sysServiceDTO.setDataAuthDetailDTOS(dataAuthDetailDTOS);
|
|
|
|
|
|
|
|
@@ -269,25 +393,74 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
* @Return void
|
|
|
* @MethodName getDeptDetial
|
|
|
*/
|
|
|
- public void getDeptDetial(List<DataAuthDetailDTO> dataAuthDetailDTOS) {
|
|
|
+ public void getDeptDetial(DataAuthDetailDTO dataAuthDetailDTO) {
|
|
|
//1.获取医院信息
|
|
|
HospitalDTO hospitalDTO = new HospitalDTO();
|
|
|
Hospital hospital = hospitalFacade.list(new QueryWrapper<Hospital>()
|
|
|
- .eq("id", 2l)//###
|
|
|
- .eq("type", "1")//###
|
|
|
+ .eq("id", 1l)//###
|
|
|
+ .eq("type", "0")//###
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())).get(0);
|
|
|
- BeanUtils.copyProperties(hospital,hospitalDTO);
|
|
|
+ BeanUtils.copyProperties(hospital, hospitalDTO);
|
|
|
//获取当前登录用户的组织信息
|
|
|
List<HospitalDTO> hospitalDTOS = getHospitalInfo(hospitalDTO);
|
|
|
getAllHospitalDTO(hospitalDTOS);
|
|
|
//2.获取科室信息
|
|
|
+ getDeptInfo(hospitalDTO, dataAuthDetailDTO);
|
|
|
+ dataAuthDetailDTO.setHospitalDTOS(hospitalDTO);
|
|
|
+
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description获取对应医院的科室信息
|
|
|
+ * @Date 2021/7/23
|
|
|
+ * @Param [hospitalDTO, dataAuthDetailDTOS]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName getDeptInfo
|
|
|
+ */
|
|
|
+ private void getDeptInfo(HospitalDTO hospitalDTO, DataAuthDetailDTO dataAuthDetailDTO) {
|
|
|
+ if (hospitalDTO != null) {
|
|
|
+ if (ListUtil.isNotEmpty(hospitalDTO.getHospitalDTOS())) {
|
|
|
+ for (HospitalDTO oneHospitalDTO : hospitalDTO.getHospitalDTOS()) {
|
|
|
+ //虚拟医院继续递归遍历到真实医院
|
|
|
+ getDeptInfo(oneHospitalDTO, dataAuthDetailDTO);
|
|
|
+ }
|
|
|
+ //真实医院:获取科室
|
|
|
+ } else if ((HospitalTypeEnum.SINGLE_HOSPITAL.getKey() + "").equals(hospitalDTO.getType())) {
|
|
|
+ List<Dept> depts = deptFacade.list(new QueryWrapper<Dept>()
|
|
|
+ .eq("hospital_id", hospitalDTO.getId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ List<DeptDTO> deptDTOS = new ArrayList<>();
|
|
|
+ if (ListUtil.isNotEmpty(depts)) {
|
|
|
+ for (Dept dept : depts) {
|
|
|
+ DeptDTO deptDTO = new DeptDTO();
|
|
|
+ BeanUtils.copyProperties(dept, deptDTO);
|
|
|
+ deptDTOS.add(deptDTO);
|
|
|
+ //该医院和该医院的科室 自定义关联关系为true
|
|
|
+ if (dataAuthDetailDTO.getDetailId() == deptDTO.getId()) {
|
|
|
+ hospitalDTO.setRelationStatus(true);
|
|
|
+ deptDTO.setRelationStatus(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ hospitalDTO.setDepts(deptDTOS);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 获取医院对应的子医院信息
|
|
|
+ * @Date 2021/7/23
|
|
|
+ * @Param [hospitalDTOS]
|
|
|
+ * @Return void
|
|
|
+ * @MethodName getAllHospitalDTO
|
|
|
+ */
|
|
|
private void getAllHospitalDTO(List<HospitalDTO> hospitalDTOS) {
|
|
|
- if(ListUtil.isNotEmpty(hospitalDTOS)){
|
|
|
- for(HospitalDTO tempHospitalDTO:hospitalDTOS){
|
|
|
+ if (ListUtil.isNotEmpty(hospitalDTOS)) {
|
|
|
+ for (HospitalDTO tempHospitalDTO : hospitalDTOS) {
|
|
|
getAllHospitalDTO(getHospitalInfo(tempHospitalDTO));
|
|
|
}
|
|
|
}
|
|
@@ -296,20 +469,20 @@ public class DataAuthHandleFacade extends DataAuthServiceImpl {
|
|
|
/**
|
|
|
* @Author songxl
|
|
|
* @Description获取医院信息
|
|
|
- * @Date 2021/7/22
|
|
|
+ * @Date 2021/7/22
|
|
|
* @Param [parentId]
|
|
|
* @Return java.util.List<com.lantone.common.dto.HospitalDTO>
|
|
|
* @MethodName getHospitalInfo
|
|
|
*/
|
|
|
private List<HospitalDTO> getHospitalInfo(HospitalDTO hospitalDTO) {
|
|
|
List<HospitalDTO> hospitalDTOS = new ArrayList<>();
|
|
|
- if(hospitalDTO.getId()!=null){
|
|
|
+ if (hospitalDTO.getId() != null) {
|
|
|
List<Hospital> hospitals = hospitalFacade.list(new QueryWrapper<Hospital>()
|
|
|
- .eq("parent_id",hospitalDTO.getId())
|
|
|
+ .eq("parent_id", hospitalDTO.getId())
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
hospitals.stream().forEach(hospital -> {
|
|
|
HospitalDTO tempHospitalDTO = new HospitalDTO();
|
|
|
- BeanUtils.copyProperties(hospital,tempHospitalDTO);
|
|
|
+ BeanUtils.copyProperties(hospital, tempHospitalDTO);
|
|
|
hospitalDTOS.add(tempHospitalDTO);
|
|
|
});
|
|
|
hospitalDTO.setHospitalDTOS(hospitalDTOS);
|