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

前端之家收集整理的这篇文章主要介绍了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...@H_403_25@oracle多行合并成一行: listagg within group:http://blog.csdn.net/baojiang...

原文链接:https://www.f2er.com/oracle/206422.html

猜你在找的Oracle相关文章