|
@@ -5,15 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.lantone.common.dto.DataAuthDetailDTO;
|
|
import com.lantone.common.dto.DataAuthDetailDTO;
|
|
import com.lantone.common.dto.GetDataAuthByIdDTO;
|
|
import com.lantone.common.dto.GetDataAuthByIdDTO;
|
|
-import com.lantone.common.dto.GetDataAuthDeptDTO;
|
|
|
|
-import com.lantone.common.dto.GetDataAuthDetailDTO;
|
|
|
|
-import com.lantone.common.dto.GetDataAuthDoctorDTO;
|
|
|
|
-import com.lantone.common.dto.GetDataAuthHospitalDTO;
|
|
|
|
import com.lantone.common.dto.GetDataAuthPageDTO;
|
|
import com.lantone.common.dto.GetDataAuthPageDTO;
|
|
import com.lantone.common.dto.GetDataAuthRoleDTO;
|
|
import com.lantone.common.dto.GetDataAuthRoleDTO;
|
|
import com.lantone.common.dto.GetDataAuthSoftwareDTO;
|
|
import com.lantone.common.dto.GetDataAuthSoftwareDTO;
|
|
import com.lantone.common.dto.GetDoctorPageDTO;
|
|
import com.lantone.common.dto.GetDoctorPageDTO;
|
|
import com.lantone.common.dto.SoftwareDataAuthDetail;
|
|
import com.lantone.common.dto.SoftwareDataAuthDetail;
|
|
|
|
+import com.lantone.common.enums.DataAuthDataTypeEnum;
|
|
|
|
+import com.lantone.common.enums.DataAuthDetailTypeEnum;
|
|
import com.lantone.common.exception.Asserts;
|
|
import com.lantone.common.exception.Asserts;
|
|
import com.lantone.common.service.RedisService;
|
|
import com.lantone.common.service.RedisService;
|
|
import com.lantone.common.util.DateUtil;
|
|
import com.lantone.common.util.DateUtil;
|
|
@@ -27,7 +25,6 @@ import com.lantone.common.vo.GetDoctorPageVO;
|
|
import com.lantone.common.vo.UpdateAuthVO;
|
|
import com.lantone.common.vo.UpdateAuthVO;
|
|
import com.lantone.dblayermbg.entity.DataAuth;
|
|
import com.lantone.dblayermbg.entity.DataAuth;
|
|
import com.lantone.dblayermbg.entity.DataAuthDetail;
|
|
import com.lantone.dblayermbg.entity.DataAuthDetail;
|
|
-import com.lantone.dblayermbg.entity.DeptUser;
|
|
|
|
import com.lantone.dblayermbg.entity.Role;
|
|
import com.lantone.dblayermbg.entity.Role;
|
|
import com.lantone.dblayermbg.entity.RoleSoftwareDataAuth;
|
|
import com.lantone.dblayermbg.entity.RoleSoftwareDataAuth;
|
|
import com.lantone.dblayermbg.entity.SoftwareDataAuth;
|
|
import com.lantone.dblayermbg.entity.SoftwareDataAuth;
|
|
@@ -45,18 +42,13 @@ import com.lantone.dblayermbg.facade.SoftwareDataAuthFacade;
|
|
import com.lantone.dblayermbg.facade.UserFacade;
|
|
import com.lantone.dblayermbg.facade.UserFacade;
|
|
import com.lantone.dblayermbg.service.impl.DataAuthDetailServiceImpl;
|
|
import com.lantone.dblayermbg.service.impl.DataAuthDetailServiceImpl;
|
|
import com.lantone.dblayermbg.service.impl.RoleSoftwareDataAuthServiceImpl;
|
|
import com.lantone.dblayermbg.service.impl.RoleSoftwareDataAuthServiceImpl;
|
|
-import com.lantone.security.annotation.DataAuthFilter;
|
|
|
|
-import com.lantone.security.enums.DataAuthDataTypeEnum;
|
|
|
|
-import com.lantone.security.enums.DataAuthDetailTypeEnum;
|
|
|
|
import com.lantone.common.enums.IsDeleteEnum;
|
|
import com.lantone.common.enums.IsDeleteEnum;
|
|
import com.lantone.security.enums.SoftwareEnum;
|
|
import com.lantone.security.enums.SoftwareEnum;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
@@ -250,8 +242,12 @@ public class DataAuthManagementFacade {
|
|
Asserts.fail("该数据权限已存在,请重新输入");
|
|
Asserts.fail("该数据权限已存在,请重新输入");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if (dataAuths.stream().map(DataAuth::getId).collect(Collectors.toList()).contains(id)) {
|
|
|
|
- Asserts.fail("该数据权限已存在,请重新输入");
|
|
|
|
|
|
+ if (ListUtil.isNotEmpty(dataAuths)) {
|
|
|
|
+ dataAuths.stream().forEach(dataAuth -> {
|
|
|
|
+ if (!id.equals(dataAuth.getId())) {
|
|
|
|
+ Asserts.fail("该数据权限已存在,请重新输入");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//绑定角色校验
|
|
//绑定角色校验
|
|
@@ -405,102 +401,4 @@ public class DataAuthManagementFacade {
|
|
getDataAuthPageVO.setCreator(SysUserUtils.getCurrentPrincipleId());
|
|
getDataAuthPageVO.setCreator(SysUserUtils.getCurrentPrincipleId());
|
|
return dataAuthFacade.getBaseMapper().getDataAuthPage(getDataAuthPageVO);
|
|
return dataAuthFacade.getBaseMapper().getDataAuthPage(getDataAuthPageVO);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param
|
|
|
|
- * @Description获取用户数据权限
|
|
|
|
- * @Return void
|
|
|
|
- */
|
|
|
|
- @Async
|
|
|
|
- public void initUserDataAuth(Long userId, Long hospitalId, String softwareId) {
|
|
|
|
- //获取当前用户的数据权限
|
|
|
|
- List<GetDataAuthDetailDTO> dataAuthDetails = dataAuthFacade.getBaseMapper()
|
|
|
|
- .getDataAuth(userId, softwareId);
|
|
|
|
- Map<String, List<Long>> localDataAuthMap = new HashMap<>();
|
|
|
|
- List<Long> users = new ArrayList<>();
|
|
|
|
- List<Long> notUsers = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- List<Long> doctors = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- List<Long> depts = new ArrayList<>();
|
|
|
|
- List<Long> notDepts = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- List<Long> hospitals = new ArrayList<>();
|
|
|
|
- List<Long> notHospitals = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- if (ListUtil.isNotEmpty(dataAuthDetails)) {
|
|
|
|
- Map<Integer, List<GetDataAuthDetailDTO>> dataAuthDetailMap = dataAuthDetails.stream()
|
|
|
|
- .collect(Collectors.groupingBy(GetDataAuthDetailDTO::getDataType));
|
|
|
|
- dataAuthDetailMap.keySet().stream().forEach(dataType -> {
|
|
|
|
- //1:全部组织,2:全部科室,3:全部科室除本科室外,4:本科室,5:本医疗组,6:本人,7:自定义
|
|
|
|
- //全部组织
|
|
|
|
- if (DataAuthDataTypeEnum.ALL_HOSPITAL.getKey() == dataType) {
|
|
|
|
- //获取当前登录用户的医院id
|
|
|
|
- hospitals.add(hospitalId);
|
|
|
|
- }
|
|
|
|
- //全部科室
|
|
|
|
- if (DataAuthDataTypeEnum.ALL_DEPT.getKey() == dataType) {
|
|
|
|
- hospitals.add(hospitalId);
|
|
|
|
- //获取所有科室
|
|
|
|
-// depts.addAll(deptFacade.list(new QueryWrapper<Dept>()
|
|
|
|
-// .in("hospital_id",hospitalId)
|
|
|
|
-// .eq("is_deleted",IsDeleteEnum.N.getKey())).stream().map(Dept::getId).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- //除了本科室外
|
|
|
|
- if (DataAuthDataTypeEnum.ALL_DEPT_NOT_SELF.getKey() == dataType) {
|
|
|
|
- notDepts.addAll(deptUserFacade.list(new QueryWrapper<DeptUser>()
|
|
|
|
- .eq("user_id", userId)
|
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())).stream()
|
|
|
|
- .map(DeptUser::getDeptId).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- //本科室
|
|
|
|
- if (DataAuthDataTypeEnum.ALL_SELF_DEPT.getKey() == dataType) {
|
|
|
|
- depts.addAll(deptUserFacade.list(new QueryWrapper<DeptUser>()
|
|
|
|
- .eq("user_id", userId)
|
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())).stream()
|
|
|
|
- .map(DeptUser::getDeptId).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- //本医疗组
|
|
|
|
- if (DataAuthDataTypeEnum.SELF_MEDOUP.getKey() == dataType) {
|
|
|
|
- doctors.addAll(medoupDoctorFacade.getBaseMapper().getDoctorIdByMedoup(userId));
|
|
|
|
- }
|
|
|
|
- //本人
|
|
|
|
- if (DataAuthDataTypeEnum.SELF_MEDOUP.getKey() == dataType) {
|
|
|
|
- users.add(userId);
|
|
|
|
- }
|
|
|
|
- //自定义
|
|
|
|
- if (DataAuthDataTypeEnum.CUSTOMIZE.getKey() == dataType) {
|
|
|
|
- Map<Integer, List<GetDataAuthDetailDTO>> dataAuthDetailTypeMap = dataAuthDetailMap.get(dataType).stream()
|
|
|
|
- .collect(Collectors.groupingBy(GetDataAuthDetailDTO::getDetailType));
|
|
|
|
- dataAuthDetailTypeMap.keySet().stream().forEach(detailType -> {
|
|
|
|
- List<Long> ids = dataAuthDetailTypeMap
|
|
|
|
- .get(detailType).stream().map(GetDataAuthDetailDTO::getDetailId).collect(Collectors.toList());
|
|
|
|
- //医院
|
|
|
|
- if (DataAuthDetailTypeEnum.HOSPITAL.getKey() == detailType) {
|
|
|
|
- hospitals.addAll(hospitalFacade.getBaseMapper().getHospitals(ids).stream()
|
|
|
|
- .map(GetDataAuthHospitalDTO::getId).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- //科室
|
|
|
|
- if (DataAuthDetailTypeEnum.DEPT.getKey() == detailType) {
|
|
|
|
- depts.addAll(deptFacade.getBaseMapper().getDepts(ids).stream()
|
|
|
|
- .map(GetDataAuthDeptDTO::getId).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- //医生
|
|
|
|
- if (DataAuthDetailTypeEnum.DOCTOR.getKey() == detailType) {
|
|
|
|
- doctors.addAll(deptFacade.getBaseMapper().getDoctors(ids).stream()
|
|
|
|
- .map(GetDataAuthDoctorDTO::getId).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- localDataAuthMap.put("users", users);
|
|
|
|
- localDataAuthMap.put("notUsers", notUsers);
|
|
|
|
- localDataAuthMap.put("doctors", doctors);
|
|
|
|
- localDataAuthMap.put("depts", depts);
|
|
|
|
- localDataAuthMap.put("notDepts", notDepts);
|
|
|
|
- localDataAuthMap.put("hospitals", hospitals);
|
|
|
|
- localDataAuthMap.put("notHospitals", notHospitals);
|
|
|
|
- redisService.hSetAll("dataAuth:"+hospitalId + "_" + userId + "_" + softwareId, localDataAuthMap);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|