luodangjia
2025-01-02 51f460f3b1a8b9fa365e4195c41bb9c5e16fcb7c
medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java
@@ -1,9 +1,11 @@
package com.sinata.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sinata.common.constant.CacheConstants;
import com.sinata.common.core.domain.entity.SysUser;
import com.sinata.common.entity.PageDTO;
import com.sinata.common.exception.ServiceException;
import com.sinata.common.utils.BeanUtils;
@@ -124,6 +126,45 @@
    public List<SysDepartmentVO> getRegionTree(String keyword) {
        List<SysDepartmentVO> root = new ArrayList<>();
        SysDepartment currentDepartment = getMyDepartment();
        if (Objects.isNull(currentDepartment)) {
            return root;
        }
        if (!currentDepartment.getOrgType().equals(DepartmentEnum.REGION.getCode())) {
            return root;
        }
        Map<Long, List<SysDepartment>> childrenMap = getChildrenDepartmentByOrgType(currentDepartment, Collections.singletonList(DepartmentEnum.REGION.getCode()));
        SysDepartmentVO sysDepartmentVO = fillChildrenTreeModel(currentDepartment, childrenMap);
        root.add(sysDepartmentVO);
        if (StringUtils.isNotBlank(keyword)) {
            treeMatch(root, keyword);
        }
        return root;
    }
    @Override
    public List<SysDepartmentVO> getRegionTree1(String keyword) {
        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        List<SysDepartmentVO> root = new ArrayList<>();
        SysDepartment sysDepartment = this.baseMapper.selectById(sysUser.getDepartmentId());
        SysDepartment currentDepartment = this.baseMapper.selectById(sysDepartment.getParentId());
        if (Objects.isNull(currentDepartment)) {
            return root;
        }
        if (!currentDepartment.getOrgType().equals(DepartmentEnum.REGION.getCode())) {
            return root;
        }
        Map<Long, List<SysDepartment>> childrenMap = getChildrenDepartmentByOrgType(currentDepartment, Collections.singletonList(DepartmentEnum.REGION.getCode()));
        SysDepartmentVO sysDepartmentVO = fillChildrenTreeModel(currentDepartment, childrenMap);
        root.add(sysDepartmentVO);
        if (StringUtils.isNotBlank(keyword)) {
            treeMatch(root, keyword);
        }
        return root;
    }
    public List<SysDepartmentVO> getRegionTree2(String keyword) {
        List<SysDepartmentVO> root = new ArrayList<>();
        SysDepartment currentDepartment = this.baseMapper.selectById(-1);
        if (Objects.isNull(currentDepartment)) {
            return root;
        }
@@ -363,7 +404,18 @@
     */
    @Override
    public PageDTO<MedicalInstitutionVO> pageMedicalList(DepartmentQuery query) {
        String treeCode = getTreeCodeByDepartmentId(query.getDepartmentId());
        String treeCode;
        if (Objects.isNull(query.getDepartmentId())) {
            SysDepartment department = getMyDepartment();
            treeCode = department.getTreeCode();
        } else {
            SysDepartment department = getById(query.getDepartmentId());
            //如果是处置单位,则获取父级部门
            if (department.getOrgType().equals(DepartmentEnum.DISPOSAL_UNIT.getCode())) {
                department = getDepartmentByParentId(department.getParentId());
            }
            treeCode = department.getTreeCode();
        }
        if (StringUtils.isBlank(treeCode)) {
            return PageDTO.empty(0L, 0L);
        }
@@ -657,6 +709,7 @@
                .like(StringUtils.isNotEmpty(query.getDepartmentName()), SysDepartment::getDepartmentName, query.getDepartmentName())
                .like(StringUtils.isNotBlank(query.getContactPerson()), SysDepartment::getContactPerson, query.getContactPerson())
                .like(StringUtils.isNotBlank(query.getContactPhone()), SysDepartment::getContactPhone, query.getContactPhone())
                .eq(SysDepartment::getOrgType, DepartmentEnum.REGULATORY_UNIT.getCode())
                .page(new Page<>(query.getPageCurr(), query.getPageSize()));
        return PageDTO.of(page, RegulatoryUnitVO.class);
    }
@@ -786,4 +839,15 @@
        }
        return null;
    }
    /**
     * 路线关联医院列表
     *
     * @param id
     * @return
     */
    @Override
    public List<MedicalInstitutionVO> getHospitalListByRouteId(Long id) {
        return baseMapper.getHospitalListByRouteId(id);
    }
}