• queryWrapper in like


    //构建条件
            QueryWrapper<ErpGroup> wrapper = new QueryWrapper<>();
    //        wrapper.eq("deleted","0");
    
            String username = userAuthUtil.getUserName().get();
            if(!username.equals("admin")){
                Long user_id = userAuthUtil.getUserId().get();
                List<ErpGroupMember> erpGroupMemberList = erpGroupMemberService.getErpGroupMemberByUserId(user_id);
    
    //            Long[] id_arr = new Long[erpGroupMemberList.size()];
    //            for(int i=0;i<erpGroupMemberList.size();i++){
    //                id_arr[i]=erpGroupMemberList.get(i).getGroupId();
    //            }
    //            List<Long>  idList=Arrays.asList(id_arr);
    
    //            List<Long> idList = new ArrayList<>();
    //            erpGroupMemberList .forEach(n -> idList.add(n.getGroupId()));
    //            wrapper.in("id", idList);
    
    //            queryWrapper.and(Wrapper -> Wrapper.eq(PcmArticle::getAuState, "1").or().eq(PcmArticle::getAuState, "2"));
    //            QueryWrapper<ErpGroup> like_wrapper = new QueryWrapper<>();
    //            for(int i=0;i<erpGroupMemberList.size();i++){
    //                Long group_id = erpGroupMemberList.get(i).getGroupId();
    //                ErpGroup erpGroup = baseMapper.selectById(group_id);
    //                String group_path = erpGroup.getPath();
    //                if(like_wrapper.isEmptyOfWhere()){
    //                    like_wrapper.likeRight("path",erpGroup.getPath());
    //                }else{
    //                    like_wrapper.or().likeRight("path",erpGroup.getPath());
    //                }
    //            }
    //            wrapper.and((Consumer<QueryWrapper<ErpGroup>>) like_wrapper);
    
                wrapper.and(wr->{
    //                String[] deviceIds = StringUtils.split(deviceIdArr, ",");
    //                Arrays.stream(deviceIds).forEach(e->{
    //                    wr.eq("id", e).or();
    //                });
    
    //                for(int i=0;i<erpGroupMemberList.size();i++){
    ////                    ErpGroup erpGroup = baseMapper.selectById( erpGroupMemberList.get(i).getGroupId());
    ////                    if(wr.isEmptyOfWhere()){
    ////                        wr.likeRight("path",erpGroup.getPath());
    ////                    }else{
    ////                        wr.or().likeRight("path",erpGroup.getPath());
    ////                    }
    ////                }
                    erpGroupMemberList.forEach(e->{
                        wr.likeRight("path",baseMapper.selectById(e.getGroupId()).getPath()).or();
                    });
                });
    
            }
    
            Long id = erpGroupQuery.getId();
            if(id != null) wrapper.eq("id", id);
            if (!StringUtils.isEmpty(erpGroupQuery.getCode())){
                wrapper.eq("code", erpGroupQuery.getCode());
            }
            if (!StringUtils.isEmpty(erpGroupQuery.getName())){
                wrapper.eq("name", erpGroupQuery.getName());
            }
            Long parentId = erpGroupQuery.getParentId();
            if(parentId != null) wrapper.eq("parent_id", parentId);
            if (!StringUtils.isEmpty(erpGroupQuery.getPath())){
                wrapper.like("name", erpGroupQuery.getPath());
            }
            if (!StringUtils.isEmpty(erpGroupQuery.getType())){
                wrapper.eq("type", erpGroupQuery.getType());
            }
            Integer groupType = erpGroupQuery.getGroupType();
            if(groupType != null) wrapper.eq("group_type", groupType);
            if (!StringUtils.isEmpty(erpGroupQuery.getDescription())){
                wrapper.eq("description", erpGroupQuery.getDescription());
            }
            Long ownership = erpGroupQuery.getOwnership();
            if(ownership != null) wrapper.eq("ownership", ownership);
            Boolean status = erpGroupQuery.getStatus();
            if(status != null) wrapper.eq("status", status);
            return baseMapper.selectList(wrapper);
  • 相关阅读:
    思达BI软件Style Intelligence实例教程—股票K线图
    思达报表工具Style Report基础教程—参数化查询
    思达报表工具Style Report基础教程—公式表
    思达报表工具Style Report基础教程—交叉表
    思达报表工具Style Report基础教程—分组表
    思达报表工具Style Report基础教程—创建一个带条件的查询
    思达报表工具Style Report基础教程—查询
    思达报表工具Style Report基础教程—参数表单
    .net 详解异步编程
    使用NPOI导入导出Excel
  • 原文地址:https://www.cnblogs.com/mingforyou/p/14678617.html
Copyright © 2020-2023  润新知