easyui datagrid以及oracle中的多行合并一行

页面显示:

前端代码:

<table style="margin-top: 50px;" id="dgs" title="大箱码关联信息列表" class="easyui-datagrid" 
                    toolbar="#toolbar" rownumbers="true"  singleSelect="true" fitColumns="true">  
                <thead>  
                    <tr> 
                         <th data-options="field:'storecode',width:100,align:'center'">大箱码</th>
                            <th data-options="field:'casecode',width:300,align:'center'">关联的箱码(不同箱码用分号分开,相同箱码用逗号分开)</th>
                         <th data-options="field:'count',align:'center'">关联数量</th>
                     </tr>  
                </thead>  
                </table>  
                
             <div id="pp" class="easyui-pagination" style="border:1px solid #ccc;"  
                data-options="  
                    total: 0,pageSize:15,Pagelist: [15,30,50,100],onSelectPage: function(pageNumber,pageSize){ // 页面切换动作  
                            getDataByPageRows(pageNumber,pageSize);     
                    }">  
            </div>

js:

function getDataByPageRows(pageNum,rowsLimit){  
        $("#pp").show();
               pageNum = pageNum || 1;     // 设置认的页号  
               rowsLimit = rowsLimit || 2;// 设置认的每页记录数  
               $.ajax({  
                   type: "POST",dataType: 'json',// 注意格式是html,不是json  
                   url:"<%=basePath%>outdata/querydetaillist",data: {  
                       startdate: $("#startdate").datetimeBox('getValue'),enddate: $("#enddate").datetimeBox('getValue'),storecode: $("#storecode").val(),page: pageNum,rows: rowsLimit
                   },success: function(data){   // 请求成功,将返回的数据(一页的记录数)绑定到 datagrid控件  
                       var count = data.total;   // 总记录个数  
                       var daTarow = data.rows;  //获取条数;
                       $('#dgs').datagrid('loadData',daTarow);  
                       $('#pp').pagination({  
                           total: count,// 由于显示 ”共XXX条记录” 等信息用  
                           pageNumber: pageNum    //   
                       });  
                   }  
               });//ajax         
           }

controller:

@RequestMapping(value="/querydetaillist")
    @ResponseBody
    public String querydetaillist(Model model,HttpServletResponse response,HttpServletRequest request,@RequestParam(value = "page",required = false,defaultValue = "") String page,@RequestParam(value = "storecode",defaultValue = "") String storecode,@RequestParam(value = "startdate",defaultValue = "") String startdate,@RequestParam(value = "enddate",defaultValue = "") String enddate,@RequestParam(value = "rows",defaultValue = "") String rows){
        
        
        int endindex=Integer.valueOf(page)*Integer.valueOf(rows);
        int startindex=(Integer.valueOf(page)-1)*Integer.valueOf(rows);
        Map<String,Object> params = new HashMap<String,Object>();
        if(!storecode.equals("")){
            storecode = storecode.replaceFirst("^0*",""); 
        }
        if(!startdate.equals("")){
            startdate = startdate.replaceAll(" ","");
        }
        if(!enddate.equals("")){
            enddate = enddate.replaceAll(" ","");
        }
        params.put("endindex",endindex);
        params.put("storecode",storecode);
        params.put("startIndex",startindex);
        params.put("startdate",startdate);
        params.put("enddate",enddate);
        

        List<Store> datalist=outdataDao.querydetaillist(params);
        String total=outdataDao.querydetaillistcount(params);
        JSONObject obj=new JSONObject();
        obj.put("total",total);
        obj.put("rows",datalist);
        return obj.toJSONString();
    }

xml:

<select id="querydetaillist" resultType="Store" parameterType="Map">
          select  * from  (
        select tt1.*,ROWNUM as rowno
        from ( 
         
         select storecode,listagg(casecode,';') within group (order by casecode) as casecode,count(casecode) as "count" from
                (
                  select s.storecode,c.caseid,listagg(c.casecode,',')  within group (order by c.casecode,c.caseid) as casecode,count(distinct caseid)
                  from ys_store s
                  left join ys_case c on s.id=c.storeid
                  where 1=1 and casecode is not null 
                 <if test="startdate != null   and startdate != ''"> and to_char(s.gldate,'yyyy-MM-dd')>='${startdate}'</if>
                 <if test="enddate != null   and enddate != ''"> and to_char(s.gldate,'yyyy-MM-dd')&lt;='${enddate}'</if>
                 <if test="storecode != null   and storecode != ''"> and s.storecode=${storecode}</if>
                  group by s.storecode,c.caseid
                )
                group by storecode
        
         ) tt1
                   where ROWNUM &lt;= '${endindex}') tt2
            where tt2.rowno > '${startIndex}'
    
    </select>
    
    <select id="querydetaillistcount" resultType="String" parameterType="Map">
        select count(*) from(
             select storecode,c.caseid
                )
                group by storecode
        )
    </select>

参考文档:

easyui 中文网:http://www.jeasyui.net/plugin...
oracle多行合并成一行: listagg within group:http://blog.csdn.net/baojiang...

相关文章

Java Oracle 结果集是Java语言中处理数据库查询结果的一种方...
Java AES和Oracle AES是现代加密技术中最常使用的两种AES加密...
Java是一种广泛应用的编程语言,具备可靠性、安全性、跨平台...
随着移动互联网的发展,抽奖活动成为了营销活动中不可或缺的...
Java和Oracle都是在计算机领域应用非常广泛的技术,他们经常...
Java 是一门非常流行的编程语言,它可以运行于各种操作系统上...