医院废弃物信息化管理平台
“mitao”
2025-12-24 3763145f34d7706923d55edc32f5cfbc8bc08b92
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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);
    }
}