package cn.besteam.modules.medical.service.impl;
|
|
import cn.besteam.common.constant.DepartmentEnum;
|
import cn.besteam.modules.medical.dto.MwCollectionPointDTO;
|
import cn.besteam.modules.medical.entity.MwCollectionPoint;
|
import cn.besteam.modules.medical.mapper.MwCollectionPointMapper;
|
import cn.besteam.modules.medical.service.IMwCollectionPointService;
|
import cn.besteam.modules.medical.vo.MwCollectionPointVO;
|
import cn.besteam.modules.shiro.authc.util.EnvUtils;
|
import cn.besteam.modules.system.entity.SysDepartment;
|
import cn.besteam.modules.system.service.ISysDepartmentService;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import org.apache.commons.collections.CollectionUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* @Description: 收集点位
|
* @author: besteam
|
* @date: 2022-02-09
|
* @version: V1.0
|
*/
|
@Service
|
public class MwCollectionPointServiceImpl extends ServiceImpl<MwCollectionPointMapper, MwCollectionPoint> implements IMwCollectionPointService {
|
|
|
@Autowired
|
private ISysDepartmentService sysDepartmentService;
|
|
@Override
|
public IPage<MwCollectionPointVO> queryPageCollectList(Integer pageNo, Integer pageSize, MwCollectionPointDTO dto) {
|
|
Page<MwCollectionPointVO> page = new Page<>(pageNo, pageSize);
|
List<Integer> hospitalIdList = getSearchHospitalIdList(dto.getHospitalId());
|
if (CollectionUtils.isEmpty(hospitalIdList)) {
|
return page;
|
}
|
dto.setHospitalIdList(hospitalIdList);
|
IPage<MwCollectionPointVO> result = baseMapper.queryPageCollectList(page, dto);
|
return result;
|
}
|
|
@Override
|
public List<MwCollectionPointVO> queryPageCollectList(MwCollectionPointDTO dto) {
|
List<Integer> hospitalIdList = getSearchHospitalIdList(dto.getHospitalId());
|
if (CollectionUtils.isEmpty(hospitalIdList)) {
|
return null;
|
}
|
dto.setHospitalIdList(hospitalIdList);
|
List<MwCollectionPointVO> list=baseMapper.queryPageCollectList(dto);
|
return list;
|
}
|
|
private List<Integer> getSearchHospitalIdList(Integer hospitalId) {
|
|
if (hospitalId == null) {
|
return sysDepartmentService.listMyHospital(EnvUtils.getUser().getId()).stream().map(SysDepartment::getId).collect(Collectors.toList());
|
} else {
|
SysDepartment sysDepartment = sysDepartmentService.getById(hospitalId);
|
if (sysDepartment == null) {
|
return new ArrayList<>();
|
}
|
List<SysDepartment> childrenList = sysDepartmentService.list(new QueryWrapper<SysDepartment>().lambda().likeRight(SysDepartment::getTreeCode, sysDepartment.getTreeCode()).eq(SysDepartment::getOrgType, DepartmentEnum.OrgTypeEnum.HOSPITAL.getType()));
|
if (CollectionUtils.isEmpty(childrenList)) {
|
return new ArrayList<>();
|
}
|
return childrenList.stream().map(SysDepartment::getId).collect(Collectors.toList());
|
}
|
}
|
|
@Override
|
public String getPointOffice(Integer officeId) {
|
return this.baseMapper.getPointOffice(officeId);
|
}
|
}
|