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);
        }
  • 相关阅读:
    Chrome 过滤广告插件暂替办法
    IE8.1将支持Firefox插件,Gecko和Webkit引擎
    Adobe与Facebook联手推出Flash开发工具
    Google Chrome Greasemetal
    vmware虚机下的linux集群
    新版Safari浏览器胜在速度
    Fedora 11 Beta发布
    Sun宣布本周裁员1500人 或为IBM收购做准备
    Opera Mobile9.7将支持Flash Lite和Google Gears
    Red Hat CEO:桌面Linux无用
  • 原文地址:https://www.cnblogs.com/baixiuhua/p/12121006.html
Copyright © 2011-2022 走看看