forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-12 89e716d623a2b773591ba020acb8c5affc1db9cc
dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUnitService.java
@@ -13,14 +13,17 @@
import cn.huge.module.ctuser.domain.po.CtUnit;
import cn.huge.module.ctuser.domain.po.CtUser;
import cn.huge.module.ctuser.domain.po.CtUserole;
import cn.huge.module.ctuser.dto.AppearUnitDTO;
import cn.huge.module.ctuser.dto.CtUnitWeChatCountDTO;
import cn.huge.module.cust.constant.RoleBaseEnum;
import cn.huge.module.cust.constant.UserBaseConsts;
import cn.huge.module.cust.dto.CtUnitDTO;
import cn.huge.module.cust.dto.CtUserDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
@@ -467,4 +470,27 @@
            return new ArrayList<>();
        }
    }
    /**
     * 获取上级综治中心
     * @param unitId 当前单位编号
     * @return
     */
    public CtUnitDTO getParentZzzx(String unitId){
        try{
            // 查询当前单位的上级综治中心
            QueryWrapper<CtUnit> ctUnitQueryWrapper = new QueryWrapper<>();
            ctUnitQueryWrapper.eq("id", unitId).select("parent_id");
            CtUnit loginCtUnit = mapper.selectOne(ctUnitQueryWrapper);
            ctUnitQueryWrapper.clear();
            ctUnitQueryWrapper.eq("id", loginCtUnit.getParentId()).eq("unit_type", UserBaseConsts.UNIT_TYPE_1);
            CtUnit zzzxCtUnit = mapper.selectOne(ctUnitQueryWrapper);
            CtUnitDTO ctUnitDTO = new CtUnitDTO();
            BeanUtils.copyProperties(zzzxCtUnit, ctUnitDTO);
            return ctUnitDTO;
        }catch (Exception e){
            log.error("[CtUnitService.getParentZzzx]调用失败,异常信息:"+e, e);
            throw new ServiceException("CtUnitService.getParentZzzx", e);
        }
    }
}