zoukankan      html  css  js  c++  java
  • jeecg自定义CriteriaQuery查询组装

    复制代码

    @RequestMapping(params = "datagrid")
        public void datagrid(TbTendUserEntity tbTendUser, HttpServletRequest request, HttpServletResponse response,
                DataGrid dataGrid) {
            
            CriteriaQuery cq = new CriteriaQuery(TbTendUserEntity.class, dataGrid);
            // 查询条件组装器
            org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tbTendUser, request.getParameterMap());
            try {
                String sql1=" SELECT t.id,t.create_name createName,t.create_by createBy,t.create_date createDate, " + 
                        "t.update_name updateName,t.update_by updateBy,t.update_date updateDate,t.sys_org_code sysOrgCode, " + 
                        "t.sys_company_code sysCompanyCode,t.bpm_status bpmStatus,t.tend_user_id tendUserId,t.user_name userName, " + 
                        "t.pass_word passWord,t.begin_date beginDate,t.end_date endDate,t.id_card_num idCardNum,t.fingerprint_data fingerprintData, " + 
                        "t.photograph_data photographData,t.sex,t.age,t.duty,t.`status`,t.will1,t.will2,t.will3,t.user_real userReal, " + 
                        "t.schedule_status scheduleStatus,t.group_status groupStatus,t.domicile_location domicileLocation,t.work_location workLocation " + 
                        "FROM tb_tend_user t where 1=1 ";
                String sql2=" SELECT COUNT(1) FROM tb_tend_user t where 1=1 ";
                if(StringUtil.isNotEmpty(tbTendUser.getDomicileLocation())) {//户籍所在地过滤
                    sql1+="and (domicile_location <> '"+tbTendUser.getDomicileLocation()+"' or domicile_location is null) ";
                    sql2+="and (domicile_location <> '"+tbTendUser.getDomicileLocation()+"' or domicile_location is null) ";
                }
                if(StringUtil.isNotEmpty(tbTendUser.getWorkLocation())) {//工作地过滤
                    sql1+="and (work_location <> '"+tbTendUser.getWorkLocation()+"' or work_location is null) ";
                    sql2+="and (work_location <> '"+tbTendUser.getWorkLocation()+"' or work_location is null) ";
                }
                if(StringUtil.isNotEmpty(tbTendUser.getGroupStatus())) {//分组状态
                    sql1+="and (group_status = '"+tbTendUser.getGroupStatus()+"' or group_status is null) ";
                    sql2+="and (group_status = '"+tbTendUser.getGroupStatus()+"' or group_status is null) ";
                }
                if(StringUtil.isNotEmpty(tbTendUser.getUserReal())) {//姓名
                    sql1+="and (user_real = '"+tbTendUser.getUserReal()+"') ";
                    sql2+="and (user_real = '"+tbTendUser.getUserReal()+"') ";
                }
                /*获取总数,用于分页使用*/
                long countMwo = systemService.getCountForJdbc(sql2);
                /*转换为 int 整形*/
                int allCounts = (int)countMwo;
                
                int pageSize = cq.getPageSize();/*每页显示数*/
                int curPageNO = PagerUtil.getcurPageNo(allCounts, cq.getCurPage(),pageSize);/*当前页*/
                
                /*获取数据列表,参数一:查询的sql、参数二三:当前页码、数据总数*/
                List<Map<String, Object>> listMwo=systemService.findForJdbc(sql1, curPageNO, pageSize);
                
                cq.getDataGrid().setResults(listMwo);
                cq.getDataGrid().setTotal(allCounts);
                
            } catch (Exception e) {
                throw new BusinessException(e.getMessage());
            }
            TagUtil.datagrid(response, dataGrid);
        }
  • 相关阅读:
    网卡驱动-BD详解(缓存描述符 Buffer Description)
    break&&continue
    C++解析六-继承
    C++解析五-this 指针,指向类的指针
    1-find
    C++解析四-友员函数、内联函数、静态成员
    树形结构节点求和,以及set排序
    java.util.ConcurrentModificationException 解决和for循环时对集合remove操作
    eclipse保存卡死和内存溢出
    关于Eclipse安装了反编译插件,无法查看源码问题
  • 原文地址:https://www.cnblogs.com/Jeely/p/12613197.html
Copyright © 2011-2022 走看看