|
@@ -1,37 +1,24 @@
|
|
|
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;
|
|
|
-import com.lantone.common.util.StringUtil;
|
|
|
import com.lantone.common.util.SysUserUtils;
|
|
|
import com.lantone.common.vo.CheckSolveRegionVO;
|
|
|
-import com.lantone.common.vo.GetDeptListVO;
|
|
|
import com.lantone.common.vo.SaveRegionVO;
|
|
|
import com.lantone.common.vo.GetRegionVO;
|
|
|
import com.lantone.common.vo.UpdateRegionVO;
|
|
|
-import com.lantone.dblayermbg.entity.Dept;
|
|
|
import com.lantone.dblayermbg.entity.Region;
|
|
|
import com.lantone.dblayermbg.entity.RegionDept;
|
|
|
-import com.lantone.dblayermbg.facade.DeptFacade;
|
|
|
import com.lantone.dblayermbg.facade.RegionFacade;
|
|
|
import com.lantone.dblayermbg.service.RegionDeptService;
|
|
|
import com.lantone.common.enums.IsDeleteEnum;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -45,8 +32,6 @@ public class RegionManagementFacade {
|
|
|
private RegionDeptService regionDeptService;
|
|
|
@Autowired
|
|
|
private RegionFacade regionFacade;
|
|
|
- @Autowired
|
|
|
- private DeptFacade deptFacade;
|
|
|
|
|
|
/**
|
|
|
* @Description: 新增病区
|
|
@@ -60,8 +45,9 @@ public class RegionManagementFacade {
|
|
|
getCheckRegion(saveRegionVo);
|
|
|
Region sysRegion = new Region();
|
|
|
BeanUtils.copyProperties(saveRegionVo, sysRegion);
|
|
|
- List<RegionDept> sysRegionDepts = new ArrayList<>();
|
|
|
- return addRegion(saveRegionVo, sysRegion, sysRegionDepts);
|
|
|
+ sysRegion.setGmtCreate(new Date());
|
|
|
+ sysRegion.setCreator(saveRegionVo.getUserId().toString());
|
|
|
+ return regionFacade.save(sysRegion);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -74,27 +60,17 @@ public class RegionManagementFacade {
|
|
|
public Object updateRegion(UpdateRegionVO updateRegionVO) {
|
|
|
updateRegionVO.setHospitalId(SysUserUtils.getCurrentHospitalId());
|
|
|
updateRegionVO.setUserId(SysUserUtils.getCurrentPrincipleId());
|
|
|
- if(1==updateRegionVO.getMark()){
|
|
|
+ //回显
|
|
|
+ if (1 == updateRegionVO.getMark()) {
|
|
|
GetRegionVO getRegionVO = new GetRegionVO();
|
|
|
BeanUtils.copyProperties(updateRegionVO, getRegionVO);
|
|
|
- IPage<ViewRegionDTO> region = regionFacade.getWard(getRegionVO);
|
|
|
- List<ViewRegionDTO> records = region.getRecords();
|
|
|
- if(ListUtil.isNotEmpty(records) && records.size() == 1){
|
|
|
- ViewRegionDTO viewRegionDTO = records.get(0);
|
|
|
- String deptName = viewRegionDTO.getDeptName();
|
|
|
- List<String> deptNameList = viewRegionDTO.getDeptNameList();
|
|
|
- if(StringUtils.isNotBlank(deptName) && deptName.contains(",")){
|
|
|
- for (String str : deptName.split(",")) {
|
|
|
- deptNameList.add(str);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return region;
|
|
|
+ return regionFacade.getWard(getRegionVO);
|
|
|
}
|
|
|
Region sysRegion = new Region();
|
|
|
BeanUtils.copyProperties(updateRegionVO, sysRegion);
|
|
|
- List<RegionDept> sysRegionDepts = new ArrayList<>();
|
|
|
- return updateRegion(updateRegionVO, sysRegion, sysRegionDepts);
|
|
|
+ sysRegion.setGmtModified(new Date());
|
|
|
+ sysRegion.setModifier(updateRegionVO.getUserId().toString());
|
|
|
+ return regionFacade.updateById(sysRegion);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -107,20 +83,7 @@ public class RegionManagementFacade {
|
|
|
public IPage<ViewRegionDTO> getRegion(GetRegionVO getRegionVO) {
|
|
|
getRegionVO.setHospitalId(SysUserUtils.getCurrentHospitalId());
|
|
|
getRegionVO.setUserId(SysUserUtils.getCurrentPrincipleId());
|
|
|
- IPage<ViewRegionDTO> page = regionFacade.getWard(getRegionVO);
|
|
|
- List<ViewRegionDTO> wardList = page.getRecords();
|
|
|
- if (ListUtil.isNotEmpty(wardList) && StringUtil.isNotEmpty(getRegionVO.getDeptName())) {
|
|
|
- IPage pageOne = new Page();
|
|
|
- List<ViewRegionDTO> viewRegionDTOS = new ArrayList<>();
|
|
|
- wardList.forEach(obj -> {
|
|
|
- if (StringUtil.isNotEmpty(obj.getDeptName()) && obj.getDeptName().contains(getRegionVO.getDeptName())) {
|
|
|
- viewRegionDTOS.add(obj);
|
|
|
- }
|
|
|
- });
|
|
|
- pageOne.setRecords(viewRegionDTOS);
|
|
|
- return pageOne;
|
|
|
- }
|
|
|
- return page;
|
|
|
+ return regionFacade.getWard(getRegionVO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -132,15 +95,10 @@ public class RegionManagementFacade {
|
|
|
*/
|
|
|
public Boolean deleteRegion(Integer id) {
|
|
|
Long hospitalId = SysUserUtils.getCurrentHospitalId();
|
|
|
- regionFacade.lambdaUpdate()
|
|
|
- .eq(Region::getId,id)
|
|
|
+ boolean flag = regionFacade.lambdaUpdate()
|
|
|
+ .eq(Region::getId, id)
|
|
|
.eq(Region::getHospitalId, hospitalId)
|
|
|
- .set(Region::getIsDeleted,IsDeleteEnum.Y.getKey())
|
|
|
- .update();
|
|
|
- boolean flag = regionDeptService.lambdaUpdate()
|
|
|
- .eq(RegionDept::getRegionId, id)
|
|
|
- .eq(RegionDept::getHospitalId, hospitalId)
|
|
|
- .set(RegionDept::getIsDeleted,IsDeleteEnum.Y.getKey())
|
|
|
+ .set(Region::getIsDeleted, IsDeleteEnum.Y.getKey())
|
|
|
.update();
|
|
|
return flag;
|
|
|
}
|
|
@@ -155,78 +113,14 @@ public class RegionManagementFacade {
|
|
|
public void getCheckRegion(SaveRegionVO saveRegionVo) {
|
|
|
saveRegionVo.setHospitalId(SysUserUtils.getCurrentHospitalId());
|
|
|
saveRegionVo.setUserId(SysUserUtils.getCurrentPrincipleId());
|
|
|
- int count = regionFacade.lambdaQuery()
|
|
|
- .eq(Region::getIsDeleted, IsDeleteEnum.N.getKey())
|
|
|
- .eq(Region::getName, saveRegionVo.getName())
|
|
|
- .eq(Region::getHospitalId, saveRegionVo.getHospitalId())
|
|
|
- .count();
|
|
|
- if(count>0){
|
|
|
- throw new ApiException("当前组织和病区已重复");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description: 新增病区
|
|
|
- * @Param: [saveRegionVo, sysRegion, sysRegionDepts]
|
|
|
- * @return: java.lang.Boolean
|
|
|
- * @Author: cy
|
|
|
- * @Date: 2021/7/30
|
|
|
- */
|
|
|
- public Boolean addRegion(SaveRegionVO saveRegionVo, Region sysRegion, List<RegionDept> sysRegionDepts) {
|
|
|
- sysRegion.setGmtCreate(new Date());
|
|
|
- sysRegion.setCreator(saveRegionVo.getUserId().toString());
|
|
|
- regionFacade.save(sysRegion);
|
|
|
- if (ListUtil.isNotEmpty(saveRegionVo.getDeptIds())) {
|
|
|
- saveRegionVo.getDeptIds().forEach(obj -> {
|
|
|
- RegionDept sysRegionDept = new RegionDept();
|
|
|
- BeanUtils.copyProperties(saveRegionVo, sysRegionDept);
|
|
|
- sysRegionDept.setDeptId(obj);
|
|
|
- sysRegionDept.setRegionId(sysRegion.getId());
|
|
|
- sysRegionDept.setGmtCreate(new Date());
|
|
|
- sysRegionDept.setCreator(saveRegionVo.getUserId().toString());
|
|
|
- sysRegionDepts.add(sysRegionDept);
|
|
|
- });
|
|
|
- return regionDeptService.saveBatch(sysRegionDepts);
|
|
|
+ int count = regionFacade.lambdaQuery()
|
|
|
+ .eq(Region::getIsDeleted, IsDeleteEnum.N.getKey())
|
|
|
+ .eq(Region::getName, saveRegionVo.getName())
|
|
|
+ .eq(Region::getHospitalId, saveRegionVo.getHospitalId())
|
|
|
+ .count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new ApiException("上级组织和病区名称已重复");
|
|
|
}
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description: 修改病区
|
|
|
- * @Param: [saveRegionVo, sysRegion, sysRegionDepts]
|
|
|
- * @return: java.lang.Boolean
|
|
|
- * @Author: cy
|
|
|
- * @Date: 2021/7/30
|
|
|
- */
|
|
|
- public Boolean updateRegion(UpdateRegionVO updateRegionVO, Region sysRegion, List<RegionDept> sysRegionDepts) {
|
|
|
- sysRegion.setGmtModified(new Date());
|
|
|
- sysRegion.setModifier(updateRegionVO.getUserId().toString());
|
|
|
- regionFacade.updateById(sysRegion);
|
|
|
- if (ListUtil.isNotEmpty(updateRegionVO.getDeptIds())) {
|
|
|
- Region region = regionFacade.lambdaQuery()
|
|
|
- .eq(Region::getId, updateRegionVO.getId())
|
|
|
- .eq(Region::getIsDeleted, IsDeleteEnum.N.getKey()).one();
|
|
|
- regionDeptService.lambdaUpdate()
|
|
|
- .eq(RegionDept::getHospitalId, updateRegionVO.getHospitalId())
|
|
|
- .eq(RegionDept::getIsDeleted, IsDeleteEnum.N.getKey())
|
|
|
- .eq(RegionDept::getRegionId, updateRegionVO.getId()).remove();
|
|
|
- updateRegionVO.getDeptIds().forEach(obj -> {
|
|
|
- RegionDept sysRegionDeptEntry = new RegionDept();
|
|
|
- BeanUtils.copyProperties(updateRegionVO, sysRegionDeptEntry);
|
|
|
- sysRegionDeptEntry.setId(null);
|
|
|
- sysRegionDeptEntry.setDeptId(obj);
|
|
|
- sysRegionDeptEntry.setRegionId(updateRegionVO.getId());
|
|
|
- if (null != region) {
|
|
|
- sysRegionDeptEntry.setGmtCreate(region.getGmtCreate());
|
|
|
- sysRegionDeptEntry.setCreator(region.getCreator());
|
|
|
- }
|
|
|
- sysRegionDeptEntry.setGmtModified(new Date());
|
|
|
- sysRegionDeptEntry.setModifier(updateRegionVO.getUserId().toString());
|
|
|
- sysRegionDepts.add(sysRegionDeptEntry);
|
|
|
- });
|
|
|
- return regionDeptService.saveBatch(sysRegionDepts);
|
|
|
- }
|
|
|
- return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -241,12 +135,12 @@ public class RegionManagementFacade {
|
|
|
checkSolveRegionVO.setUserId(SysUserUtils.getCurrentPrincipleId());
|
|
|
//禁用校验
|
|
|
if (null != checkSolveRegionVO.getId() && 0 == checkSolveRegionVO.getMark()) {
|
|
|
- List<Long> collectList = regionDeptService.lambdaQuery()
|
|
|
+ long count = 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());
|
|
|
- if (ListUtil.isNotEmpty(collectList)) {
|
|
|
+ .eq(RegionDept::getRegionId, checkSolveRegionVO.getId())
|
|
|
+ .eq(RegionDept::getHospitalId, checkSolveRegionVO.getHospitalId())
|
|
|
+ .list().stream().count();
|
|
|
+ if (count>0) {
|
|
|
//当前病区存在与之关联的科室
|
|
|
return 1;
|
|
|
}
|
|
@@ -255,54 +149,19 @@ public class RegionManagementFacade {
|
|
|
|
|
|
//禁用-启用病区处理
|
|
|
if (null != checkSolveRegionVO.getId() && (1 == checkSolveRegionVO.getMark() || 2 == checkSolveRegionVO.getMark())) {
|
|
|
- LambdaUpdateChainWrapper<Region> regionLambdaUpdate= regionFacade.lambdaUpdate();
|
|
|
+ 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();
|
|
|
+ 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();
|
|
|
+ if (2 == checkSolveRegionVO.getMark()) {
|
|
|
+ regionLambdaUpdate.set(Region::getStatus, 1).update();
|
|
|
}
|
|
|
- regionLambdaUpdate.set(Region::getModifier,checkSolveRegionVO.getUserId().toString()).update();
|
|
|
- regionLambdaUpdate.set(Region::getGmtModified,new Date()).update();
|
|
|
+ regionLambdaUpdate.set(Region::getModifier, checkSolveRegionVO.getUserId().toString()).update();
|
|
|
+ regionLambdaUpdate.set(Region::getGmtModified, new Date()).update();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * @Description:科室id,name返回
|
|
|
- * @Param: [hospitalId]
|
|
|
- * @return: java.util.List<com.lantone.dblayermbg.entity.Dept>
|
|
|
- * @Author: cy
|
|
|
- * @Date: 2021/8/2
|
|
|
- */
|
|
|
- public List<DeptListDTO> getDept(GetDeptListVO getDeptListVO){
|
|
|
- getDeptListVO.setHospitalId(SysUserUtils.getCurrentHospitalId());
|
|
|
- getDeptListVO.setUserId(SysUserUtils.getCurrentPrincipleId());
|
|
|
- List<DeptListDTO> deptListDTOS = new ArrayList<>();
|
|
|
- List<Long> depts = regionDeptService.lambdaQuery()
|
|
|
- .eq(RegionDept::getHospitalId, getDeptListVO.getHospitalId())
|
|
|
- .eq(RegionDept::getIsDeleted,IsDeleteEnum.N.getKey())
|
|
|
- .eq(RegionDept::getCreator, getDeptListVO.getUserId())
|
|
|
- .list().stream().map(RegionDept::getDeptId).collect(Collectors.toList());
|
|
|
- LambdaQueryChainWrapper<Dept> lambdaQueryChainWrapper = deptFacade.lambdaQuery();
|
|
|
- lambdaQueryChainWrapper.eq(Dept::getHospitalId,getDeptListVO.getHospitalId());
|
|
|
- lambdaQueryChainWrapper.eq(Dept::getIsDeleted,IsDeleteEnum.N.getKey());
|
|
|
- if(ListUtil.isNotEmpty(depts)){
|
|
|
- lambdaQueryChainWrapper.in(Dept::getId,depts);
|
|
|
- }
|
|
|
- if(StringUtil.isNotEmpty(getDeptListVO.getDeptName())){
|
|
|
- lambdaQueryChainWrapper.like(Dept::getName,getDeptListVO.getDeptName());
|
|
|
- }
|
|
|
- lambdaQueryChainWrapper.select(Dept::getId, Dept::getName).list().forEach(
|
|
|
- obj->{
|
|
|
- DeptListDTO deptListDTO = new DeptListDTO();
|
|
|
- BeanUtils.copyProperties(obj,deptListDTO);
|
|
|
- deptListDTOS.add(deptListDTO);
|
|
|
- }
|
|
|
- );
|
|
|
- return deptListDTOS;
|
|
|
- }
|
|
|
}
|