|
@@ -3,6 +3,8 @@ package com.lantone.security.facade;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.additional.update.impl.LambdaUpdateChainWrapper;
|
|
|
+import com.lantone.common.dto.DeptListDTO;
|
|
|
import com.lantone.common.dto.ViewRegionDTO;
|
|
|
import com.lantone.common.exception.ApiException;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
@@ -116,18 +118,13 @@ public class RegionManagementFacade {
|
|
|
*/
|
|
|
public void getRegion(SaveRegionVO saveRegionVo) {
|
|
|
if (null == saveRegionVo.getId()) {
|
|
|
- List<Long> collects = regionFacade.lambdaQuery()
|
|
|
+ Region region = regionFacade.lambdaQuery()
|
|
|
+ .eq(Region::getIsDeleted, IsDeleteEnum.N.getKey())
|
|
|
.eq(Region::getName, saveRegionVo.getName())
|
|
|
.eq(Region::getHospitalId, saveRegionVo.getHospitalId())
|
|
|
- .list().stream().map(obj -> obj.getId()).collect(Collectors.toList());
|
|
|
- if (ListUtil.isNotEmpty(collects) && ListUtil.isNotEmpty(saveRegionVo.getDeptIds())) {
|
|
|
- Integer count = regionDeptService.lambdaQuery()
|
|
|
- .eq(RegionDept::getHospitalId, saveRegionVo.getHospitalId())
|
|
|
- .in(RegionDept::getRegionId, collects)
|
|
|
- .in(RegionDept::getDeptId, saveRegionVo.getDeptIds()).count();
|
|
|
- if (count > 0) {
|
|
|
- throw new ApiException("当前病区关联科室重复");
|
|
|
- }
|
|
|
+ .one();
|
|
|
+ if(null != region && null != region.getId()){
|
|
|
+ throw new ApiException("当前组织和病区已重复");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -170,9 +167,12 @@ public class RegionManagementFacade {
|
|
|
sysRegion.setModifier("程瑶改");
|
|
|
regionFacade.updateById(sysRegion);
|
|
|
if (ListUtil.isNotEmpty(saveRegionVo.getDeptIds())) {
|
|
|
- List<Region> list = regionFacade.lambdaQuery().eq(Region::getId, saveRegionVo.getId()).list();
|
|
|
+ Region region = regionFacade.lambdaQuery()
|
|
|
+ .eq(Region::getId, saveRegionVo.getId())
|
|
|
+ .eq(Region::getIsDeleted, IsDeleteEnum.N.getKey()).one();
|
|
|
regionDeptService.lambdaUpdate()
|
|
|
.eq(RegionDept::getHospitalId, saveRegionVo.getHospitalId())
|
|
|
+ .eq(RegionDept::getIsDeleted, IsDeleteEnum.N.getKey())
|
|
|
.eq(RegionDept::getRegionId, saveRegionVo.getId()).remove();
|
|
|
saveRegionVo.getDeptIds().forEach(obj -> {
|
|
|
RegionDept sysRegionDeptEntry = new RegionDept();
|
|
@@ -180,9 +180,9 @@ public class RegionManagementFacade {
|
|
|
sysRegionDeptEntry.setId(null);
|
|
|
sysRegionDeptEntry.setDeptId(obj);
|
|
|
sysRegionDeptEntry.setRegionId(saveRegionVo.getId());
|
|
|
- if (ListUtil.isNotEmpty(list)) {
|
|
|
- sysRegionDeptEntry.setGmtCreate(list.get(0).getGmtCreate());
|
|
|
- sysRegionDeptEntry.setCreator(list.get(0).getCreator());
|
|
|
+ if (null != region) {
|
|
|
+ sysRegionDeptEntry.setGmtCreate(region.getGmtCreate());
|
|
|
+ sysRegionDeptEntry.setCreator(region.getCreator());
|
|
|
}
|
|
|
sysRegionDeptEntry.setGmtModified(new Date());
|
|
|
sysRegionDeptEntry.setModifier("后期修改");
|
|
@@ -194,7 +194,7 @@ public class RegionManagementFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @Description: 校验/禁用病区管理
|
|
|
+ * @Description: 校验/禁用-启用病区管理
|
|
|
* @Param: [checkSolveRegionVO]
|
|
|
* @return: java.lang.Object
|
|
|
* @Author: cy
|
|
@@ -204,6 +204,7 @@ public class RegionManagementFacade {
|
|
|
//禁用校验
|
|
|
if (null != checkSolveRegionVO.getId() && 0 == checkSolveRegionVO.getMark()) {
|
|
|
List<Long> collectList = regionDeptService.lambdaQuery()
|
|
|
+ .eq(RegionDept::getIsDeleted, IsDeleteEnum.N.getKey())
|
|
|
.eq(RegionDept::getRegionId,checkSolveRegionVO.getId())
|
|
|
.eq(RegionDept::getHospitalId,checkSolveRegionVO.getHospitalId())
|
|
|
.list().stream().map(obj -> obj.getDeptId()).collect(Collectors.toList());
|
|
@@ -214,12 +215,18 @@ public class RegionManagementFacade {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- //禁用病区处理
|
|
|
- if (null != checkSolveRegionVO.getId() && 1 == checkSolveRegionVO.getMark()) {
|
|
|
- regionFacade.lambdaUpdate()
|
|
|
- .eq(Region::getId,checkSolveRegionVO.getId())
|
|
|
- .eq(Region::getHospitalId,checkSolveRegionVO.getHospitalId())
|
|
|
- .set(Region::getStatus,0).update();
|
|
|
+ //禁用-启用病区处理
|
|
|
+ if (null != checkSolveRegionVO.getId() && (1 == checkSolveRegionVO.getMark() || 2 == checkSolveRegionVO.getMark())) {
|
|
|
+ LambdaUpdateChainWrapper<Region> regionLambdaUpdate= regionFacade.lambdaUpdate();
|
|
|
+ regionLambdaUpdate.eq(Region::getIsDeleted, IsDeleteEnum.N.getKey());
|
|
|
+ regionLambdaUpdate.eq(Region::getId,checkSolveRegionVO.getId());
|
|
|
+ regionLambdaUpdate.eq(Region::getHospitalId,checkSolveRegionVO.getHospitalId());
|
|
|
+ if(1 == checkSolveRegionVO.getMark()){
|
|
|
+ regionLambdaUpdate.set(Region::getStatus,0).update();
|
|
|
+ }
|
|
|
+ if(2 == checkSolveRegionVO.getMark()){
|
|
|
+ regionLambdaUpdate.set(Region::getStatus,1).update();
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -231,45 +238,21 @@ public class RegionManagementFacade {
|
|
|
* @Author: cy
|
|
|
* @Date: 2021/8/2
|
|
|
*/
|
|
|
- public List<Dept> getDept(GetDeptListVO getDeptListVO){
|
|
|
- List<Dept> list = new ArrayList<>();
|
|
|
- if(0 == getDeptListVO.getMark()){
|
|
|
- list = queryMethod(getDeptListVO,null);
|
|
|
- }
|
|
|
-
|
|
|
- //互斥
|
|
|
- if(1 == getDeptListVO.getMark()) {
|
|
|
- //关联或被禁止的科室id
|
|
|
- List<Long> regionDeptIds = regionDeptService.lambdaQuery()
|
|
|
- .eq(RegionDept::getHospitalId,getDeptListVO.getHospitalId())
|
|
|
- .eq(RegionDept::getIsDeleted,IsDeleteEnum.N.getKey())
|
|
|
- .list().stream().map(obj -> obj.getDeptId()).collect(Collectors.toList());
|
|
|
-
|
|
|
- if(ListUtil.isNotEmpty(regionDeptIds)){
|
|
|
- list = queryMethod(getDeptListVO,regionDeptIds);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description: 科室lambdaQueryChainWrapper
|
|
|
- * @Param: [getDeptListVO, regionDeptIds]
|
|
|
- * @return: java.util.List<com.lantone.dblayermbg.entity.Dept>
|
|
|
- * @Author: cy
|
|
|
- * @Date: 2021/8/2
|
|
|
- */
|
|
|
- public List<Dept> queryMethod(GetDeptListVO getDeptListVO, List<Long> regionDeptIds){
|
|
|
+ public List<DeptListDTO> getDept(GetDeptListVO getDeptListVO){
|
|
|
+ List<DeptListDTO> deptListDTOS = new ArrayList<>();
|
|
|
LambdaQueryChainWrapper<Dept> lambdaQueryChainWrapper = deptFacade.lambdaQuery();
|
|
|
lambdaQueryChainWrapper.eq(Dept::getHospitalId,getDeptListVO.getHospitalId());
|
|
|
lambdaQueryChainWrapper.eq(Dept::getIsDeleted,IsDeleteEnum.N.getKey());
|
|
|
- if(ListUtil.isNotEmpty(regionDeptIds)){
|
|
|
- lambdaQueryChainWrapper.notIn(Dept::getId,regionDeptIds);
|
|
|
- }
|
|
|
if(StringUtil.isNotEmpty(getDeptListVO.getDeptName())){
|
|
|
lambdaQueryChainWrapper.like(Dept::getName,getDeptListVO.getDeptName());
|
|
|
}
|
|
|
- return lambdaQueryChainWrapper.select(Dept::getId,Dept::getName).list();
|
|
|
+ lambdaQueryChainWrapper.select(Dept::getId, Dept::getName).list().forEach(
|
|
|
+ obj->{
|
|
|
+ DeptListDTO deptListDTO = new DeptListDTO();
|
|
|
+ BeanUtils.copyProperties(obj,deptListDTO);
|
|
|
+ deptListDTOS.add(deptListDTO);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ return deptListDTOS;
|
|
|
}
|
|
|
}
|