危化品全生命周期管理后端
“djh”
2025-04-21 437f8e2b89a18363a1073fdbb3ab99bcd840a757
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzProductFlowServiceImpl.java
@@ -37,9 +37,14 @@
    public CommonPage selectProductFlowList(HzProductFlow productFlow) {
        SysUser currentUser = SecurityUtils.getLoginUser().getUser();
        checkUserAllowed(null,currentUser);
        //设置分表id
        IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
        productFlow.setCompanyId(currentUser.getCompanyId());
        if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){
            IdTableNameHandler.setCurrentId(productFlow.getCompanyId());
        }else {
            //设置分表id
            //todo
            IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
            productFlow.setCompanyId(currentUser.getCompanyId());
        }
        PageUtils.startPage();
        List<HzProductFlow> flowList = baseMapper.selectProductFlowList(productFlow);
        IdTableNameHandler.removeCurrentId();
@@ -92,15 +97,20 @@
    }
    @Override
    public List<HzProductFlow> selectAllProductFlowByCode(String code) {
    public List<HzProductFlow> selectAllProductFlowByCode(String code,Long companyId) {
        SysUser currentUser=SecurityUtils.getLoginUser().getUser();
        checkUserAllowed(null,currentUser);
        if(!code.startsWith(CodePrexEnum.GOOD.getCode())){
            throw new ApiException("条码格式不正确");
        }
        //设置分表id
        IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
        HzProduct product=productMapper.selectProductByCode(code,currentUser.getCompanyId());
        if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){
            IdTableNameHandler.setCurrentId(companyId);
        }else {
            //设置分表id
            IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
        }
        HzProduct product=productMapper.selectProductByCode(code,currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())?companyId:currentUser.getCompanyId());
        if(product==null){
            throw new ApiException("成品条码数据不存在");
        }
@@ -125,11 +135,15 @@
    }
    @Override
    public List<HzProductFlow> getAllProductFlowByProductId(Long productId) {
    public List<HzProductFlow> getAllProductFlowByProductId(Long productId,Long companyId) {
        SysUser currentUser=SecurityUtils.getLoginUser().getUser();
        checkUserAllowed(null,currentUser);
        //设置分表id
        IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
        if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){
            IdTableNameHandler.setCurrentId(companyId);
        }else {
            //设置分表id
            IdTableNameHandler.setCurrentId(currentUser.getCompanyId());
        }
        HzProduct product=productMapper.selectById(productId);
        if(product==null){
            throw new ApiException("成品数据不存在");
@@ -145,8 +159,10 @@
            throw new ApiException("管理员不能操作");
        }
        if(productFlow!=null){
            if(!Objects.equals(user.getCompanyId(), productFlow.getCompanyId())){
                throw new ApiException("无权限操作其他企业数据");
            if (!user.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())) {
                if (!Objects.equals(user.getCompanyId(), productFlow.getCompanyId())) {
                    throw new ApiException("无权限操作其他企业数据");
                }
            }
        }
    }