sgj
2026-03-20 58f63e3a124680d0b1f571f5d0a1e3ed308d43be
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/CoreDeptService.java
@@ -3,12 +3,12 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.domain.Dept;
import com.fzzy.igds.domain.PledgeContract;
import com.fzzy.igds.mapper.CoreDeptMapper;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
@@ -23,11 +23,91 @@
public class CoreDeptService {
    @Resource
    private ISysDeptService iSysDeptService;
    @Resource
    private CoreDeptMapper coreDeptMapper;
    @Resource
    private InoutConfService inoutConfService;
    /**
     * 根据用户类型获取对应库区列表信息
     *
     * @param parentId
     * @return
     */
    public List<Dept> getDeptByUserType(String parentId) {
        if(StringUtils.isNotBlank(parentId)){
            //查公司下所有库区
            return this.listDept(null,null, parentId);
        }
        //获取当前登录人
        SysUser user = ContextUtil.getLoginUser();
        if (Constant.USER_TYPE_10.equals(user.getUserType())) {
            //监管用户,直接查询组织下所有库区
            return this.listDept(null,user.getCompanyId(),null);
        }
        if (Constant.USER_TYPE_20.equals(user.getUserType())) {
            //银行用户,根据合同查询银行下所有库区
            return this.getDeptByBank(user.getUserData());
        }
        if (Constant.USER_TYPE_30.equals(user.getUserType())) {
            //库区用户
            String deptId = user.getDeptId() + "";
            if(ContextUtil.isDepotUser(deptId)){
                //查询用户所属库区
                return this.listDept(deptId,null,null);
            }else {
                //查询用户所属公司下所有库区
                return this.listDept(null,null, deptId);
            }
        }
        return this.listDept(null,user.getCompanyId(),null);
    }
    /**
     * 根据用户类型获取对应库区列表信息APP
     *
     * @param
     * @return
     */
    public List<Dept> getDeptByUserTypeApp(String userType,String deptId) {
        if (Constant.USER_TYPE_10.equals(userType)) {
            //监管用户,直接查询组织下所有库区
            return this.listDept(null,userType,null);
        }
        if (Constant.USER_TYPE_20.equals(userType)) {
            //银行用户,根据合同查询银行下所有库区
            return this.getDeptByBank(userType);
        }
        if (Constant.USER_TYPE_30.equals(userType)) {
            //库区用户
            if(ContextUtil.isDepotUser(deptId)){
                //查询用户所属库区
                return this.listDept(deptId,null,null);
            }else {
                //查询用户所属公司下所有库区
                return this.listDept(null,null, deptId);
            }
        }
        return this.listDept(null,ContextUtil.getCompanyId(),null);
    }
    /**
     * 根据银行id,关联合同表查询库区列表
     * @param bankId 银行号
     * @return
     */
    public List<Dept> getDeptByBank(String bankId) {
        if (StringUtils.isBlank(bankId)){
            return null;
        }
        QueryWrapper<PledgeContract> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("c.pledge_bank", bankId);
        return coreDeptMapper.selectDeptByBankId(queryWrapper);
    }
    /**
     * 根据条件查询库区信息
@@ -49,7 +129,7 @@
        if(StringUtils.isNotBlank(parentId)){
            queryWrapper.likeRight("id", parentId);
        }
        queryWrapper.orderByAsc("id");
        return coreDeptMapper.selectList(queryWrapper);
    }
@@ -62,7 +142,7 @@
        if (Constant.USER_TYPE_30.equals(user.getUserType())) {
            return this.listDept(ContextUtil.subDeptId(user),null,null);
        }else {
            return this.listDept(null,null,user.getDeptId() + "%");
            return this.listDept(null,null,user.getDeptId()+"");
        }
    }
@@ -87,7 +167,9 @@
            return;
        }
        Dept dept = new Dept();
        dept.setId(sysDept.getDeptId() + "");
        String deptId = sysDept.getDeptId() + "";
        dept.setId(deptId);
        dept.setParentId(deptId.substring(0, deptId.length() - 3));
        dept.setKqmc(sysDept.getDeptName());
        dept.setCompanyId(sysDept.getCompanyId());