目前实现:

----普通查询路径
/viewShow/viewShow/list.htm
----Echarts查询路劲
/viewShow/viewShow/echarts.htm

1.自定义查询条件

2.自定义展示数据

3.右击数据单列 求和、求平均

4.Echarts饼图、折现图、柱状图

5.指定导出模板

传参条件:

//视图名称,一般用大写,如 JX_VIEW_YGJC
view_name
//指定模板位置,如 E:/AppServer/sunbmp/export/JX_VIEW_YGJC.xlsx
export
//模板写入数据开始行号,如 4
data
 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/commons/page/codegen.jsp" %>
<script type="text/javascript" src="${ctx}/js/lc/platform/utils/SelectorDialog.js"></script>
<script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShow.js"></script>
<script type="text/javascript"> var colNames=[],colModel=[],view_name="${view_name}",colist=${colist},export_="${export_}",data="${data}";
for(var i in colist) {
if(colist[i]) {
// colist[i].width =(document.getElementById('gview_viewShowGrid').style.width)/12;
colNames.push(colist[i].colName);
colModel.push(colist[i]);
}
}
</script>
<style type="text/css">
.form-horizontal .form-group {
margin-right: 0px;
margin-left: 0px;
}
.fr-form-control[disabled], .fr-form-control[readonly], fieldset[disabled] .fr-orm-control {
opacity: 1;
border: 0;
}
th.ui-th-column div{
white-space:normal !important;
height:auto !important;
padding:0px;
}
ui-th-column ui-th-ltr { }
</style>
<title>管理列表</title>
</head>
<body id="viewbody">
<div class="wrapper wrapper-content animated fadeInRight col-sm-12">
<form class="form-horizontal">
<c:if test="${isadmin}">
<div class="panel">
<div class="tabs-container tabs-x">
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#tab-1" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询</a>
</li>
<li >
<a data-toggle="tab" href="#tab-2" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询管理</a>
</li>
</ul>
</div>
</div>
</c:if>
<div class="tab-content">
<div id="tab-1" class="tab-pane active">
<div class="panel-body">
<div class="toolbar-panel ">
<div class="toolbar-box">
<div class="toolbar-head clearfix">
<!-- 顶部按钮 -->
<div class="buttons">
<a class="btn btn-primary fa fa-search" onclick="javascript:$('#isQuery').val('YES')" href="javascript:void(0);" ><span>搜索</span></a>
<a class="btn btn-primary fa fa-export" href="javascript:void(0);" ><span>导出</span></a>
<c:if test="${isadmin}">
<a class="btn btn-primary fa fa-lock" href="javascript:void(0);" ><span>锁定</span></a>
<a class="btn btn-primary fa fa-unlock" href="javascript:void(0);" ><span>解锁</span></a>
</c:if>
<%-- <a class="btn btn-primary fa fa-add" href="${ctx}/platform/viewShow/viewShow/edit.htm" ><span>添加</span></a>
<a class="btn btn-primary fa fa-edit" href="javascript:void(0);" action="${ctx}/platform/viewShow/viewShow/edit.htm" ><span>编辑</span></a>
<a class="btn btn-primary fa fa-remove" href="javascript:void(0);" action="${ctx}/platform/viewShow/viewShow/remove.htm"><span>删除</span></a> --%>
</div>
<!-- 收缩 -->
<div class="tools">
<a href="javascript:void(0);" class="collapse">
<i class="bigger-180 fa fa-angle-double-up"></i>
</a>
</div>
</div>
<!-- #查询条件3-->
<div class="toolbar-body" >
<form></form>
<!-- role="form" -->
<form id="searchForm" class="search-form">
<input type="hidden" name="isQuery" id="isQuery" value="No">
<div class="form-inline p-xxs">
<c:forEach items="${list}" var="item">
<%@include file="viewShowSelecter.jsp" %>
</c:forEach>
</div>
</form>
</div><!--/ 查询条件-->
</div>
</div><!--/ 操作、查询-->
<div id="tableGrid" class="jqGrid_wrapper">
<table id="viewShowGrid" ></table>
<div id="viewShowPager"></div>
</div>
</div>
</div>
<c:if test="${isadmin}">
<div id="tab-2" class="tab-pane <c:if test="${false}">active</c:if>">
<div class="panel-body">
<div class="panel-toolbar ">
<div class="buttons">
<a href="javascript:void(0);" class="btn btn-primary fa fa-save" ><span>保存</span></a>
<a href="list.htm?view_name=${view_name}" class="btn btn-primary fa fa-back" ><span>返回</span></a>
</div>
</div>
<div class="">
<form class="fr-form" id="viewShowForm" action="save.htm" >
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">视图名</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:viewCode" readonly="readonly" value="${viewShow.viewCode}" title="${viewShow.viewCode}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">视图备注</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:viewName" value="${viewShow.viewName}" title="${viewShow.viewName}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">对应表名</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:tableCode" readonly="readonly" value="${viewShow.tableCode}" title="${viewShow.tableCode}" validate="{required:false}"/> </div>
</div>
</div>
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">对应表备注</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:tableName" value="${viewShow.tableName}" title="${viewShow.tableName}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">序号</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">字段名</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">字段备注</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">字段排序</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">显示设置</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">查询方式</label>
</div>
</div>
<c:forEach items="${list}" var="view">
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">序号</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:remarks_${view.colCode}" readonly="readonly" value="${view.id}" title="${view.id}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">字段名</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:colCode_${view.colCode}" readonly="readonly" value="${view.colCode}" title="${view.colCode}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">字段备注</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:colName_${view.colCode}" value="${view.colName}" title="${view.colName}" validate="{required:false}"/> </div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">字段排序</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="number" class="fr-form-control" name="m:viewShow:colRank_${view.colCode}" min="0" value="${view.colRank}" title="${view.colRank}" validate="{required:false}"/> </div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">显示设置</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:isShow_${view.colCode}" value="${view.isShow}" validate="{required:false}">
<option value="">--请选择--</option>
<option value="0" <c:if test="${view.isShow=='0'}">selected="selected"</c:if>>隐藏</option>
<option value="1" <c:if test="${view.isShow=='1'}">selected="selected"</c:if>>居中</option>
<option value="2" <c:if test="${view.isShow=='2'}">selected="selected"</c:if>>居左</option>
<option value="3" <c:if test="${view.isShow=='3'}">selected="selected"</c:if>>居右</option>
</select> </div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">查询方式</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:queryType_${view.colCode}" value="${view.queryType}" validate="{required:false}">
<option value="">--请选择--</option>
<%@include file="viewShowOptions.jsp" %>
</select>
</div>
</div>
</div>
</c:forEach>
</form>
</div>
</div>
</div>
</c:if>
</div>
</form>
</div>
</body>
</html>

viewShowList.jsp

 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html" %> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/commons/include/desktop.jsp" %>
<%@include file="/commons/page/codegen.jsp" %>
<script type="text/javascript" src="${ctx}/js/lc/platform/utils/SelectorDialog.js"></script>
<script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShow.js"></script>
<script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShowEcharts.js"></script>
<script type="text/javascript">
var view_name="${view_name}";
function show(v) {
switch (v) {
case "bar":
$("#tableName").val("单一横轴,数据列");
break;
case "pie":
$("#tableName").val("单一横轴,单一数据列");
break;
case "line":
$("#tableName").val("单一横轴,数据列");
break;
default:
$("#tableName").val("");
break;
}
} </script>
<title>管理列表</title>
</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight col-sm-12">
<form class="form-horizontal"><form></form>
<div class="panel">
<div class="tabs-container tabs-x">
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#tab-1" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询</a>
</li>
<li >
<a data-toggle="tab" href="#tab-2" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询管理</a>
</li>
</ul>
</div>
</div>
<div class="tab-content">
<div id="tab-1" class="tab-pane active">
<div class="panel-body">
<div class="toolbar-panel ">
<div class="toolbar-box">
<div class="toolbar-head clearfix">
<!-- 顶部按钮 -->
<div class="buttons">
<a id="fa-search" class="btn btn-primary fa fa-searchs" href="javascript:void(0);" onclick="javascript:$('#isQuery').val('YES')" ><span>搜索</span></a>
</div>
<!-- 收缩 -->
<div class="tools">
<a href="javascript:void(0);" class="collapse">
<i class="bigger-180 fa fa-angle-double-up"></i>
</a>
</div>
</div>
<!-- #查询条件3-->
<div class="toolbar-body" >
<form></form>
<!-- role="form" -->
<form id="searchForm" class="search-form">
<div class="form-inline p-xxs">
<input type="hidden" name="isQuery" id="isQuery" value="No">
<c:forEach items="${list}" var="item">
<%@include file="viewShowSelecter.jsp" %>
</c:forEach>
</div>
</form>
</div><!--/ 查询条件-->
</div>
</div><!--/ 操作、查询-->
<div class="jqGrid_wrapper">
<div id="echarts"></div>
</div>
</div>
</div>
<c:if test="${isadmin}">
<div id="tab-2" class="tab-pane <c:if test="${false}">active</c:if>">
<div class="panel-body">
<div class="panel-toolbar ">
<div class="buttons">
<a href="javascript:void(0);" class="btn btn-primary fa fa-save" ><span>保存</span></a>
<a href="list.htm?view_name=${view_name}" class="btn btn-primary fa fa-back" ><span>返回</span></a>
</div>
</div>
<div class="">
<form class="fr-form" id="viewShowForm" action="save.htm" >
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">视图名</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:viewCode" readonly="readonly" value="${viewShow.viewCode}" title="${viewShow.viewCode}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">视图备注</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:viewName" value="${viewShow.viewName}" title="${viewShow.viewName}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">统计图类型</label>
<div class="fr-form-block" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:tableCode" onchange="show(this.value);" value="${viewShow.tableCode}" validate="{required:false}">
<option value="">--请选择--</option>
<option value="bar" <c:if test="${viewShow.tableCode == 'bar'}">selected="selected"</c:if> >柱状图</option>
<option value="pie" <c:if test="${viewShow.tableCode == 'pie'}">selected="selected"</c:if> >南丁格尔饼图</option>
<option value="line" <c:if test="${viewShow.tableCode == 'line'}">selected="selected"</c:if> >折线图</option>
</select>
</div>
</div>
</div>
<div class="fr_response_field col-sm-6" >
<div class="fr-form-group">
<label class="fr-control-label">统计图说明</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" id="tableName" name="m:viewShow:tableName" value="${viewShow.tableName}" readonly="readonly" title="${viewShow.tableName}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">序号</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">字段名</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">字段备注</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">是否横轴</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">是否数据</label>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">查询方式</label>
</div>
</div>
<c:forEach items="${list}" var="view">
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">序号</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:remarks_${view.colCode}" readonly="readonly" value="${view.id}" title="${view.id}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">字段名</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:colCode_${view.colCode}" readonly="readonly" value="${view.colCode}" title="${view.colCode}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">字段备注</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:colName_${view.colCode}" value="${view.colName}" title="${view.colName}" validate="{required:false}"/> </div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">是否横轴</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:colRank_${view.colCode}" value="${view.colRank}" validate="{required:false}">
<option value="">--请选择--</option>
<option value="0" <c:if test="${view.colRank=='0'}">selected="selected"</c:if>>否</option>
<option value="1" <c:if test="${view.colRank=='1'}">selected="selected"</c:if>>是</option>
</select>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">是否数据</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:isShow_${view.colCode}" value="${view.isShow}" validate="{required:false}">
<option value="">--请选择--</option>
<option value="0" <c:if test="${view.isShow=='0'}">selected="selected"</c:if>>否</option>
<option value="1" <c:if test="${view.isShow=='1'}">selected="selected"</c:if>>是</option>
</select> </div>
</div>
</div>
<div class="fr_response_field col-sm-2" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">查询方式</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:queryType_${view.colCode}" value="${view.queryType}" validate="{required:false}">
<option value="">--请选择--</option>
<%@include file="viewShowOptions.jsp" %>
</select>
</div>
</div>
</div>
</c:forEach>
</form>
</div>
</div>
</div>
</c:if>
</div>
</form>
</div>
</body>
</html>
<% out.clear();out = pageContext.pushBody(); %>

viewShowEcharts.jsp

 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<c:if test="${item.queryType == '1'}">
<!-- 文本输入框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>: <input
type="text" name="Q^${item.colCode}^SL" class="form-control" />
</div>
</c:if>
<c:if test="${item.queryType == '2'}">
<!-- 字典下拉框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>:
<div class="input-group">
<input type="hidden" id="${item.colCode}" name="Q^${item.colCode}^SL" />
<input type="text" readonly="readonly" class="form-control comboTree"
data-toggle="dictionary" data-dic="${item.colCode}"
data-key="#${item.colCode}"
value="${f:getDictLabel2(solution.targetType,'${item.colCode}', 'key','','', '')}" />
</div>
</div>
</c:if>
<!-- "LL".equals(type)) || ("NL".equals(type)) || ("DBL".equals(type)) || ("BDL".equals(type)) || ("FTL".equals(type)) || ("SNL".equals(type)) || ("DL" -->
<c:if test="${item.queryType == '3'}">
<!-- 时间间隔框 -->
<div class="form-group">
<label class="search-label">${item.colName}起</label>: <input
type="text" name="Q^${item.colCode}^DL" class="form-control wdateTime" />
</div>
<!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { -->
<div class="form-group">
<label class="search-label">${item.colName}止</label>: <input
type="text" name="Q^${item.colCode}^DG" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '31'}">
<!-- 时间间隔框【数据下发】 -->
<div class="form-group">
<label class="search-label">${item.colName}起</label>: <input
type="text" name="Q^${item.colCode}^DL" datefmt="yyyyMMdd" class="form-control wdateTime" />
</div>
<!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { -->
<div class="form-group">
<label class="search-label">${item.colName}止</label>: <input
type="text" name="Q^${item.colCode}^DG" datefmt="yyyyMMdd" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '4'}">
<!-- 时间选择框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>: <input
type="text" name="Q^${item.colCode}^SL" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '41'}">
<!-- 时间选择框【数据下发】 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>: <input
type="text" name="Q^${item.colCode}^SL" datefmt="yyyyMMdd" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '5'}">
<!-- 人员下拉框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>:
<div class="input-group ">
<input type="hidden" name="Q^${item.colCode}^SL"
id="id_${item.colCode}" value=""> <input type="text"
class="form-control search-selector" id="name_${item.colCode}"
name="name_${item.colCode}" readonly="readonly"> <span
class="input-group-btn">
<button type="button" class="btn btn-info btn-mm"
data-toggle="selector" data-type="user"
data-id="#id_${item.colCode}" data-name="#name_${item.colCode}">
<i class="fa fa-user"></i>
</button>&nbsp;&nbsp;
<button type="button" class="btn btn-info btn-mm"
data-toggle="clear" data-id="#id_${item.colCode}"
data-name="#name_${item.colCode}">
<i class="fa fa-times"></i>
</button>
</span>
</div>
</div>
</c:if>
<c:if test="${item.queryType == '12'}">
<!-- 人员下拉框【权限】 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>:
<div class="input-group " <c:if test="${!isadmin}">style="pointer-events: none;"</c:if>>
<input type="hidden" name="Q^${item.colCode}^SL"
id="id_${item.colCode}" <c:if test="${!isadmin}">value="${f:getUser().getId()}"</c:if>> <input type="text"
class="form-control search-selector" id="name_${item.colCode}"
name="name_${item.colCode}" <c:if test="${!isadmin}">value="${f:getUser().getName()}"</c:if> readonly="readonly"> <span
class="input-group-btn">
<button type="button" class="btn btn-info btn-mm"
data-toggle="selector" data-type="user"
data-id="#id_${item.colCode}" data-name="#name_${item.colCode}">
<i class="fa fa-user"></i>
</button>&nbsp;&nbsp;
<button type="button" class="btn btn-info btn-mm"
data-toggle="clear" data-id="#id_${item.colCode}"
data-name="#name_${item.colCode}">
<i class="fa fa-times"></i>
</button>
</span>
</div>
</div>
</c:if> <c:if test="${item.queryType == '13'}">
<!-- 网点下拉框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>:
<div class="input-group ">
<input type="hidden" name="Q^${item.colCode}^SL"
id="id_${item.colCode}">
<input type="text" class="form-control search-selector"
id="name_${item.colCode}"
name="name_${item.colCode}" readonly="readonly"> <span
class="input-group-btn">
<button type="button" class="btn btn-info btn-mm"
data-toggle="selector" data-type="org"
data-id="#id_${item.colCode}" data-name="#name_${item.colCode}">
<i class="fa fa-user"></i>
</button>&nbsp;&nbsp;
<button type="button" class="btn btn-info btn-mm"
data-toggle="clear" data-id="#id_${item.colCode}"
data-name="#name_${item.colCode}">
<i class="fa fa-times"></i>
</button>
</span>
</div>
</div>
</c:if>
<c:if test="${item.queryType == '6'}">
<!-- 网点下拉框【权限】 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>:
<div class="input-group "
<c:if test="${!isadmin}">style="pointer-events: none;"</c:if>>
<input type="hidden" name="Q^${item.colCode}^SL"
id="id_${item.colCode}"
<c:if test="${!isadmin}">value="${f:getUser().getGroupID()}"</c:if>>
<input type="text" class="form-control search-selector"
id="name_${item.colCode}"
<c:if test="${!isadmin}">value="${f:getUser().getOrgName()}"</c:if>
name="name_${item.colCode}" readonly="readonly"> <span
class="input-group-btn">
<button type="button" class="btn btn-info btn-mm"
data-toggle="selector" data-type="org"
data-id="#id_${item.colCode}" data-name="#name_${item.colCode}">
<i class="fa fa-user"></i>
</button>&nbsp;&nbsp;
<button type="button" class="btn btn-info btn-mm"
data-toggle="clear" data-id="#id_${item.colCode}"
data-name="#name_${item.colCode}">
<i class="fa fa-times"></i>
</button>
</span>
</div>
</div>
</c:if>
<c:if test="${item.queryType == '7'}">
<!-- 岗位下拉框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>:
<div class="input-group ">
<input type="hidden" name="Q^${item.colCode}^SL"
id="id_${item.colCode}" value=""> <input type="text"
class="form-control search-selector" id="name_${item.colCode}"
name="name_${item.colCode}" readonly="readonly"> <span
class="input-group-btn">
<button type="button" class="btn btn-info btn-mm"
data-toggle="selector" data-type="position"
data-id="#id_${item.colCode}" data-name="#name_${item.colCode}">
<i class="fa fa-user"></i>
</button>&nbsp;&nbsp;
<button type="button" class="btn btn-info btn-mm"
data-toggle="clear" data-id="#id_${item.colCode}"
data-name="#name_${item.colCode}">
<i class="fa fa-times"></i>
</button>
</span>
</div>
</div>
</c:if>
<!-- "LL".equals(type)) || ("NL".equals(type)) || ("DBL".equals(type)) || ("BDL".equals(type)) || ("FTL".equals(type)) || ("SNL".equals(type)) || ("DL" -->
<c:if test="${item.queryType == '8'}">
<!-- 月度间隔框 -->
<div class="form-group">
<label class="search-label">${item.colName}起</label>: <input
type="text" name="Q^${item.colCode}^DL" datefmt="yyyy-MM" class="form-control wdateTime" />
</div>
<!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { -->
<div class="form-group">
<label class="search-label">${item.colName}止</label>: <input
type="text" name="Q^${item.colCode}^DG" datefmt="yyyy-MM" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '81'}">
<!-- 月度间隔框【数据下发】 -->
<div class="form-group">
<label class="search-label">${item.colName}起</label>: <input
type="text" name="Q^${item.colCode}^DL" datefmt="yyyyMM" class="form-control wdateTime" />
</div>
<!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { -->
<div class="form-group">
<label class="search-label">${item.colName}止</label>: <input
type="text" name="Q^${item.colCode}^DG" datefmt="yyyyMM" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '9'}">
<!-- 月度选择框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>: <input
type="text" name="Q^${item.colCode}^SL" datefmt="yyyy-MM" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '91'}">
<!-- 月度选择框【数据下发】 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>: <input
type="text" name="Q^${item.colCode}^SL" datefmt="yyyyMM" class="form-control wdateTime" />
</div>
</c:if>
<!-- "LL".equals(type)) || ("NL".equals(type)) || ("DBL".equals(type)) || ("BDL".equals(type)) || ("FTL".equals(type)) || ("SNL".equals(type)) || ("DL" -->
<c:if test="${item.queryType == '10'}">
<!-- 年度间隔框 -->
<div class="form-group">
<label class="search-label">${item.colName}起</label>: <input
type="text" name="Q^${item.colCode}^DL" datefmt="yyyy" class="form-control wdateTime" />
</div>
<!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { -->
<div class="form-group">
<label class="search-label">${item.colName}止</label>: <input
type="text" name="Q^${item.colCode}^DG" datefmt="yyyy" class="form-control wdateTime" />
</div>
</c:if>
<c:if test="${item.queryType == '11'}">
<!-- 年度选择框 -->
<div class="form-group">
<label class="search-label">${item.colName}</label>: <input
type="text" name="Q^${item.colCode}^SL" datefmt="yyyy" class="form-control wdateTime" />
</div>
</c:if>

viewShowSelecter.jsp

 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<option value="0" <c:if test="${view.queryType=='0'}">selected="selected"</c:if>>否</option>
<option value="1" <c:if test="${view.queryType=='1'}">selected="selected"</c:if>>文本输入框</option>
<option value="2" <c:if test="${view.queryType=='2'}">selected="selected"</c:if>>字典下拉框</option>
<option value="3" <c:if test="${view.queryType=='3'}">selected="selected"</c:if>>日期间隔框</option>
<option value="31" <c:if test="${view.queryType=='31'}">selected="selected"</c:if>>日期间隔框【数据下发】</option>
<option value="4" <c:if test="${view.queryType=='4'}">selected="selected"</c:if>>日期选择框</option>
<option value="41" <c:if test="${view.queryType=='41'}">selected="selected"</c:if>>日期选择框【数据下发】</option>
<option value="8" <c:if test="${view.queryType=='8'}">selected="selected"</c:if>>月份间隔框</option>
<option value="81" <c:if test="${view.queryType=='81'}">selected="selected"</c:if>>月份间隔框【数据下发】</option>
<option value="9" <c:if test="${view.queryType=='9'}">selected="selected"</c:if>>月份选择框</option>
<option value="91" <c:if test="${view.queryType=='91'}">selected="selected"</c:if>>月份选择框【数据下发】</option>
<option value="10" <c:if test="${view.queryType=='10'}">selected="selected"</c:if>>年份间隔框</option>
<option value="11" <c:if test="${view.queryType=='11'}">selected="selected"</c:if>>年份选择框</option>
<option value="5" <c:if test="${view.queryType=='5'}">selected="selected"</c:if>>人员下拉框</option>
<option value="12" <c:if test="${view.queryType=='12'}">selected="selected"</c:if>>人员下拉框【权限】</option>
<option value="13" <c:if test="${view.queryType=='13'}">selected="selected"</c:if>>网点下拉框</option>
<option value="6" <c:if test="${view.queryType=='6'}">selected="selected"</c:if>>网点下拉框【权限】</option>
<option value="7" <c:if test="${view.queryType=='7'}">selected="selected"</c:if>>岗位下拉框</option>

viewShowOptions.jsp

 /**
* TD_PAMS_VIEWSHOW
*
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:29
*</pre>
*/
$(function() {
viewShow = new ViewShow();
viewShow.init(); formUrl = viewShow.formUrl; $(window).resize(function(){
viewShow._initGridList();
});
$('#viewbody').bind('contextmenu',function(){
return false;
}); }); (function() {
//定义常量
var _consts = {
GRID : "#viewShowGrid",// 列表对象
PAGER : "#viewShowPager",// 列表分页
FORM : '#viewShowForm',// 表单form
FORMGET : '#viewShowFormGet',// 表单form
SEARCHFORM : "#searchForm"//查询表单form };
/**
* TD_PAMS_VIEWSHOW 对象
* @returns {ViewShow}
*/
ViewShow = function() {
//定义属性
}; /**
* 方法
*/
ViewShow.prototype = {
consts: _consts, /**
* 初始化
*/
init : function() {
superme=this;
if (this.hasInit) // 是否已初始化
return false;
this.hasInit = true;
this._initForm();
if ($(this.consts.GRID).length > 0){//列表
this._initGridList();
this._setsum();
}
if ($(this.consts.FORM).length > 0){//表单
this._initData();
this._initOffice('e');
}
if ($(this.consts.FORMGET).length > 0){// 明细页面office控件初始化
this._initOffice('r');
}
},
_initOffice : function(_rights){
}, /**
* 初始列表
*/
_initGridList : function() {
var me = this;
var shrinkToFit = true;
if(colNames.length>$("#tableGrid").width()/150) shrinkToFit=false;
$(this.consts.GRID).GridList(
{
url : __ctx+'/platform/viewShow/viewShow/listJson.htm?view_name='+view_name,
pager :this.consts.PAGER,
multiselect : false,
shrinkToFit : shrinkToFit,
autoScroll : false,
colNames: colNames,
colModel: colModel,
onRightClickRow : function(rowid,iRow,iCol,e) {
var num=0;//jQuery("#viewShowGrid").jqGrid('getCol',iCol,true,"count");
var sum=0;//jQuery("#viewShowGrid").jqGrid('getCol',iCol,true,"sum");
var avg=0;//jQuery("#viewShowGrid").jqGrid('getCol',iCol,true,"avg");
var col = jQuery("#viewShowGrid").jqGrid('getCol',iCol);
var size=0;
//DialogUtil.msg(col);
for(var i in col) {
sum+=parseFloat(col[i]);
var indx = col[i].indexOf(".")>=0?col[i].indexOf(".")+1:0;
indx = indx==0?0:col[i].length-indx;
size=size>indx?size:indx;
num++;
}
avg = num>0?sum/num:"";
num = isNaN(num)?"":num;
sum = isNaN(sum)?"":sum.toFixed(size);
avg = isNaN(avg)?"":avg.toFixed(size);
superme._setsum(colNames[iCol],num,sum,avg);
// DialogUtil.confirm('当前列['+colNames[iCol]+'],是否合计?',
// function(rtn) {
// if(!rtn) return;
// var num=jQuery("#viewShowGrid").jqGrid('getCol',iCol,false,"count");
// var sum=jQuery("#viewShowGrid").jqGrid('getCol',iCol,false,"sum");
// superme._setsum(colNames[iCol],num,sum);
// }
// );
},
gridComplete : function () {
superme._setsum("","","","");
// console.log($("#last_viewShowPager").next())
// $("#last_viewShowPager").next().html("<select class='ui-pg-selbox form-control' role='listbox' title='每页记录数'><option role='option' value='10'>10</option><option role='option' value='20'>20</option><option role='option' value='50'>50</option><option role='option' value='100'>100</option><option role='option' value='2012'>2012</option></select>");
}
});
$(this.consts.GRID).closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "scroll" });
},
/**
* 显示合计项
*/
_setsum : function(name,num,sum,avg) {
var str = "["+name+"]合计:"+sum+",计数:"+num+"条"+",平均:"+avg;
$("#viewShowPager_center").html("<td id='viewShowPager_center' align='center' style='white-space:pre;'><label>"+str+"</label></td>");
},
/**
* 初始化表单
*/
_initForm : function() {
var me = this, form = $(this.consts.FORM), frm = form.form();
me.formUrl = new com.lc.form.FormData(form);
// 触发表单验证
frm.valid();
// 处理表单保存
//$("#fa-save").on('click',function(){
$(document).on('click', 'a.fa-save', function() {
var $el = $(this);
$el.button('loading');
// office提交
OfficePlugin.submit();
me.formUrl.submit(me._showResponse, $el);
});
//查询结果
//$("#fa-search").on('click',function(){
$(document).on('click', 'a.fa-search', function() {
superme.search(this);
});
//TODO 导出结果
//$("#fa-export").on('click',function(){
$(document).on('click', 'a.fa-export', function() {
var url = __ctx+'/platform/viewShow/viewShow/export.htm?view_name='+view_name+'&export_='+export_+'&data='+data;
$("#searchForm").attr("action",url);
$("#searchForm").attr("method",'post');
$("#searchForm").submit();
});
//TODO 查询结果锁定
//$("#fa-lock").on('click',function(){
$(document).on('click', 'a.fa-lock', function() {
var obj=this;
if ($(obj).hasClass('disabled'))
return;
var searchForm = $(obj).closest("div .toolbar-panel").find(
".search-form");
if (searchForm.length == 0)
return;
var data = superme._serializeObject(searchForm);
DialogUtil.confirm('保存当前查询结果,是否继续操作',
function(rtn) {
if(!rtn) return;
$.ajax({
type : "POST",
url : __ctx+'/platform/viewShow/viewShow/clock.htm?view_name='+view_name,
data : data,
success : function(responseText) {
var resultMessage = new com.lc.form.ResultMessage(responseText);
if (resultMessage.isSuccess()) {
DialogUtil.msg(resultMessage.getMessage(),true);
} else {
DialogUtil.error(resultMessage.getMessage());
}
},
errror : function(error) {
DialogUtil.error(error);
}
}); }
);
});
//TODO 查询结果解锁
//$("#fa-unlock").on('click',function(){
$(document).on('click', 'a.fa-unlock', function() {
var obj=this;
if ($(obj).hasClass('disabled'))
return;
var searchForm = $(obj).closest("div .toolbar-panel").find(
".search-form");
if (searchForm.length == 0)
return;
var data = superme._serializeObject(searchForm);
DialogUtil.confirm('从保存记录中剔除当前查询结果,是否继续操作',
function(rtn) {
if(!rtn) return;
$.ajax({
type : "POST",
url : __ctx+'/platform/viewShow/viewShow/unclock.htm?view_name='+view_name,
data : data,
success : function(responseText) {
var resultMessage = new com.lc.form.ResultMessage(responseText);
if (resultMessage.isSuccess()) {
DialogUtil.mas(resultMessage.getMessage(),true);
} else {
DialogUtil.error(resultMessage.getMessage());
}
},
errror : function(error) {
DialogUtil.error(error);
}
}); }
);
});
},
/**
* 初始化数据
*/
_initData : function(){
if(!$.isEmpty(frameElement)
&& !$.isEmpty(frameElement.dialog)
&& !$.isEmpty(frameElement.dialog.params)
&& !$.isEmpty(frameElement.dialog.params.data)){
var data = frameElement.dialog.params.data;
this.formUrl.setData("[name^='m:']", data);
AttachementControl.initDataTo($("div[name='div_attachment_container']")); //附件初始化
}else{
$("[name^='m:']", $(_consts.FORM)).each(function(){
var data = $(this);
// 单选框特殊处理
if(data.is('input') && "radio" == data.attr("type")){
var defaultVal = data.attr("defaultVal");
var defaultValue = data.attr("defaultValue");
if(defaultValue=="true"&&defaultVal=="true"){
data.prop("checked", "checked");
}
}
});
} this.formUrl.validate();
},
/**
* 表单成功返回信息
*
* @param responseText
*/
_showResponse : function(responseText) {
var msg = new com.lc.form.ResultMessage(responseText);
if (msg.isSuccess()) {
DialogUtil.confirm(msg.getMessage() + ',是否继续操作',
function(rtn) {
if(rtn)
window.location.reload(true);
/*else
window.location.href = __ctx+'/platform/viewShow/viewShow/list.htm';*/
});
} else {
DialogUtil.error(msg.getMessage());
}
},
/**
*
* @param form
* @returns {___anonymous4353_4354}
*/
_serializeObject : function(form) {
var o = {}, a = $(form).serializeArray();
// var o = {}, a = $(form).ghostsf_serialize();
var $radio = $('input[type=radio],input[type=checkbox]', form);
var temp = {};
$.each($radio, function () {
if (!temp.hasOwnProperty(this.name)) {
if ($("input[name='" + this.name + "']:checked").length == 0) {
temp[this.name] = "";
a.push({name: this.name, value: ""});
}
}
});
$.each(a, function() {
var v = this.value || '';
if (o[this.name]) {
o[this.name] = o[this.name] +","+ v;
} else {
o[this.name] =v;
}
}); return o;
},
/**
* 查询
* @param obj
*/
search : function(obj) {
if ($(obj).hasClass('disabled'))
return;
var searchForm = $(obj).closest("div .toolbar-panel").find(
".search-form");
if (searchForm.length == 0)
return;
var data = superme._serializeObject(searchForm);
// $(this.consts.GRID).trigger("reloadGrid", {
// fromServer: true,
// postData : data,
// page: 1
// }); $(this.consts.GRID).jqGrid().setGridParam({
datatype:'json',
postData : data,
}).trigger('reloadGrid'); // $(this.consts.GRID).GridList('setGridParam', {
// url : __ctx+'/platform/viewShow/viewShow/listJson.htm?view_name='+view_name,
// postData : data, // 发送数据
// page : 1
// }).trigger("reloadGrid"); // 重新载入
},
};
})();

viewShow.js

 /**
* TD_PAMS_VIEWSHOW
*
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:29
*</pre>
*/
$(function() {
viewShowEcharts = new viewShowEcharts();
viewShowEcharts.init();
formUrl = viewShowEcharts.formUrl;
}); (function() {
//定义常量
var _consts = {
FORM : '#viewShowForm',// 表单form
};
/**
* TD_PAMS_VIEWSHOW 对象
* @returns {ViewShow}
*/
viewShowEcharts = function() {
//定义属性
}; /**
* 方法
*/
viewShowEcharts.prototype = {
consts: _consts, /**
* 初始化
*/
init : function() {
superme=this;
if (this.hasInit) // 是否已初始化
return false;
this.hasInit = true;
this._showEcharts();
},
_showEcharts: function() {
$("#fa-search").on('click',function(){
var form = $(this).closest("div .toolbar-panel").find(".search-form");
var o = {}, a = $(form).serializeArray();
var $radio = $('input[type=radio],input[type=checkbox]', form);
var temp = {};
$.each($radio, function () {
if (!temp.hasOwnProperty(this.name)) {
if ($("input[name='" + this.name + "']:checked").length == 0) {
temp[this.name] = "";
a.push({name: this.name, value: ""});
}
}
});
$.each(a, function() {
var v = this.value || '';
if (o[this.name]) {
o[this.name] = o[this.name] +","+ v;
} else {
o[this.name] =v;
}
});
$.ajaxSettings.async = true;
$.ajax({
type : "POST",
url : __ctx+'/platform/viewShow/viewShow/echartsJosn.htm?view_name='+view_name,
data : o,
success : function(option) {
$("#echarts").height($(window).height()*0.7);
var myChart = echarts.init(document.getElementById('echarts')).setOption(option[0]);
},
errror : function(error) {
DialogUtil.error(error);
}
});
}); }
};
})();

viewShowEcharts.js

package com.lc.ibps.platform.viewShow.controller;

import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import com.lc.ibps.api.base.query.QueryFilter;
import com.lc.ibps.api.base.query.WhereClause;
import com.lc.ibps.base.core.entity.ResultMessage;
import com.lc.ibps.base.core.util.BeanUtils;
import com.lc.ibps.base.core.util.JacksonUtil;
import com.lc.ibps.base.core.util.string.StringUtil;
import com.lc.ibps.base.db.model.DefaultQueryField;
import com.lc.ibps.base.db.mybatis.domain.DefaultPage;
import com.lc.ibps.base.framework.page.PageList;
import com.lc.ibps.base.framework.page.PageResult;
import com.lc.ibps.base.web.controller.GenericController;
import com.lc.ibps.base.web.json.PageJson;
import com.lc.ibps.base.web.util.RequestUtil;
import com.lc.ibps.performance.persistence.entity.ViewShowPo;
import com.lc.ibps.performance.service.ViewShowQueryService;
import com.lc.ibps.performance.service.ViewShowService;
import com.lc.ibps.platform.org.utils.PartyUtil; import net.sf.json.JSONArray; /**
* TD_PAMS_VIEWSHOW 控制类
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:29
*</pre>
*/
@Controller
@RequestMapping("/platform/viewShow/viewShow/")
public class ViewShowController extends GenericController{
@Resource
private ViewShowService viewShowService;
@Resource
private ViewShowQueryService viewShowQueryService; /**
* 初始化界面
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("list")
public ModelAndView list(HttpServletRequest request,HttpServletResponse response) throws Exception{ String preUrl= RequestUtil.getPrePage(request);
List<ViewShowPo> list = new ArrayList<>();
Boolean isadmin=false;
List<Map<String, String>> colist = new ArrayList<>();
String view_name=RequestUtil.getString(request, "view_name");
String export=RequestUtil.getString(request, "export");
String data=RequestUtil.getString(request, "data");
if(StringUtil.isNotEmpty(view_name)) {
//TD_PAMS_SHOWVIEW自动创建
viewShowService.completion();
list = viewShowQueryService.getByViewName(view_name);
isadmin=!"N".equals(PartyUtil.getUser().getIsSuper());
colist = viewShowQueryService.getColByViewName(view_name);
} JSONArray colIst = JSONArray.fromObject(colist);
return getAutoView().addObject("returnUrl", preUrl)
.addObject("view_name", view_name)
.addObject("isadmin", isadmin)
.addObject("colist", colIst)
.addObject("list", list)
.addObject("viewShow", list.get(0))
.addObject("export_", export)
.addObject("data", data)
;
}
/**
* 【TD_PAMS_VIEWSHOW】列表(分页条件查询)数据
*
* @param request
* @param reponse
* @return
* @throws Exception
*/
@SuppressWarnings("rawtypes")
@RequestMapping("listJson")
public @ResponseBody PageJson listJson(HttpServletRequest request,HttpServletResponse reponse) throws Exception{
QueryFilter queryFilter = getQuerFilter(request);
String view_name=RequestUtil.getString(request, "view_name");
try{
String listData = null;
try{
if(StringUtil.isNotEmpty(view_name)) {
// setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
if("YES".equals(request.getParameter("isQuery"))) listData = viewShowQueryService.query(queryFilter);
}
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
PageList<Map> viewShowList = null;
if(JacksonUtil.isJsonObject(listData)){
List<Map> list = JacksonUtil.getDTOList(JacksonUtil.getString(listData, "data"), Map.class);
PageResult pageResult = PageResult.fromJson(JacksonUtil.getString(listData, "pageResult"));
viewShowList = new PageList<Map>(list, pageResult);
}
return new PageJson(viewShowList);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new PageJson();
}
} /**
* 编辑【TD_PAMS_VIEWSHOW】信息页面
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("edit")
public ModelAndView edit(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
String id=RequestUtil.getString(request, "id");
ViewShowPo viewShow=null;
if(StringUtil.isNotEmpty(id)){
String data = null; try{
// setDataSource(); data = viewShowQueryService.get(id);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} viewShow = ViewShowPo.fromJsonString(data);
} return getAutoView().addObject("viewShow", viewShow).addObject("returnUrl", preUrl);
} /**
* 编辑【TD_PAMS_VIEWSHOW】信息页面
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("flowEdit")
public ModelAndView flowEdit(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
String id=RequestUtil.getString(request, "id");
ViewShowPo viewShow=null;
if(StringUtil.isNotEmpty(id)){
String data = null; try{
// setDataSource(); data = viewShowQueryService.get(id);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} viewShow = ViewShowPo.fromJsonString(data);
}
return getAutoView().addObject("viewShow", viewShow).addObject("returnUrl", preUrl);
} /**
* 【TD_PAMS_VIEWSHOW】明细页面
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("get")
public ModelAndView get(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
String id=RequestUtil.getString(request, "id");
ViewShowPo viewShow=null;
if(StringUtil.isNotEmpty(id)){
String data = null; try{
// setDataSource(); data = viewShowQueryService.get(id);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} viewShow = ViewShowPo.fromJsonString(data);
}
return getAutoView().addObject("viewShow", viewShow).addObject("returnUrl", preUrl);
} /**
* 保存【TD_PAMS_VIEWSHOW】信息
*
* @param request
* @param response
* @param viewShow
* @throws Exception
*/
@RequestMapping("save")
public void save(HttpServletRequest request,HttpServletResponse response) throws Exception{
ResultMessage message=null;
try {
String json = RequestUtil.getString(request, "json"); try{
// setDataSource();
viewShowService.save(json);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} message=new ResultMessage(ResultMessage.SUCCESS, "保存成功");
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "对操作失败,"+e.getMessage());
logger.error("操作失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 批量删除【TD_PAMS_VIEWSHOW】记录
*
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("remove")
public void remove(HttpServletRequest request,HttpServletResponse response) throws Exception{
ResultMessage message=null;
try {
//获得待删除的id
String[] ids=RequestUtil.getStringAryByStr(request, "id"); try{
// setDataSource(); viewShowService.deleteByIds(ids);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} message=new ResultMessage(ResultMessage.SUCCESS, "删除成功");
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "删除失败," + e.getMessage());
logger.error("删除失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 锁定当前查询
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("clock")
public void clock(HttpServletRequest request,HttpServletResponse response) throws Exception {
ResultMessage message = null;
QueryFilter queryFilter = getQuerFilter(request);
String view_name=RequestUtil.getString(request, "view_name");
try {
if (StringUtil.isEmpty(view_name)) {
message=new ResultMessage(ResultMessage.FAIL, "锁定失败,查询不存在" );
logger.error("锁定失败,查询不存在");
writeResultMessage(response.getWriter(), message);
return ;
}
try {
// setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", "TD_PAMS_"+view_name);
params.put("view_name", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
viewShowService.clock(queryFilter);
message=new ResultMessage(ResultMessage.SUCCESS, "已锁定当前查询结果" );
logger.error("已锁定当前查询结果");
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "锁定失败," + e.getMessage());
logger.error("锁定失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 锁定当前查询
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("unclock")
public void unclock(HttpServletRequest request,HttpServletResponse response) throws Exception {
ResultMessage message = null;
QueryFilter queryFilter = getQuerFilter(request);
String view_name=RequestUtil.getString(request, "view_name");
try {
if (StringUtil.isEmpty(view_name)) {
message=new ResultMessage(ResultMessage.FAIL, "解锁失败,查询不存在" );
logger.error("解锁失败,查询不存在");
writeResultMessage(response.getWriter(), message);
return ;
}
try {
// setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", "TD_PAMS_"+view_name);
params.put("view_name", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
viewShowService.upclock(queryFilter);
message=new ResultMessage(ResultMessage.SUCCESS, "已从锁定数据中剔除当前查询结果" );
logger.error("已从锁定数据中剔除当前查询结果");
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "解锁失败," + e.getMessage());
logger.error("解锁失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 导出
* @param request
* @param reponse
* @throws Exception
*/
@SuppressWarnings({"rawtypes", "resource"})
@RequestMapping("export")
public void export(HttpServletRequest request,HttpServletResponse reponse) throws Exception {
QueryFilter queryFilter = getQuerFilter(request);
DefaultPage pagess = (DefaultPage) queryFilter.getPage();
pagess.setLimit(2147483646);
String view_name=RequestUtil.getString(request, "view_name");
String export_=RequestUtil.getString(request, "export_");
String data=RequestUtil.getString(request, "data");
if(StringUtil.isEmpty(view_name)) return;
List<ViewShowPo> polist = viewShowQueryService.getByViewName(view_name);
StringBuffer fileTitle= new StringBuffer();
fileTitle.append(StringUtil.isEmpty(polist.get(0).getViewName())?StringUtil.isEmpty(polist.get(0).getTableName())?view_name:polist.get(0).getTableName():polist.get(0).getViewName());
Workbook wb = new XSSFWorkbook();
//获取表头数组
List<Map<String, String>> colist = viewShowQueryService.getColByViewName(view_name);
//获取查询数据
String listData = null;
List<Map> list = new ArrayList<>();
try{
if(StringUtil.isNotEmpty(view_name)) {
setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
listData = viewShowQueryService.query(queryFilter);
}
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
if(JacksonUtil.isJsonObject(listData)){
list = JacksonUtil.getDTOList(JacksonUtil.getString(listData, "data"), Map.class);
} //数据填装
try {
File modelFile = new File(export_);
wb = WorkbookFactory.create(modelFile);
setWorkbookData(wb,list,Integer.parseInt(data));
} catch (Exception e) {
logger.error(e.getMessage(),e);
wb = new XSSFWorkbook();
setWorkbookData(wb,list,colist);
}
//浏览器下载方式导出excl
fileTitle.append(".xlsx");
reponse.setHeader("Content-Disposition", "attachment;filename=" + new String(fileTitle.toString().getBytes(), "iso-8859-1"));
reponse.setContentType("application/vnd.ms-excel;charset=UTF-8");
reponse.setHeader("Pragma", "no-cache");
reponse.setHeader("Cache-Control", "no-cache");
reponse.setDateHeader("Expires", 0);
reponse.getOutputStream().flush();
wb.write(reponse.getOutputStream());
reponse.getOutputStream().close();
} @SuppressWarnings({"rawtypes"})
private void setWorkbookData(Workbook wb, List<Map> list, int rownum) {
if(list==null) list=new ArrayList<>();
int pages = wb.getNumberOfSheets();
for(int i=0;i<pages;i++) {
List<Float> hList = new ArrayList<>();
Sheet sheet = wb.getSheetAt(i);
Row row = sheet.getRow(rownum-1);
if(BeanUtils.isEmpty(row)) continue;
int row_size = row.getRowNum();
int row_num = sheet.getPhysicalNumberOfRows();
List<Row> rowList = new ArrayList<>();
for(int I=row_size+1;I<=row_num;I++) {
final Row r = sheet.getRow(I);
if(BeanUtils.isEmpty(r)) continue;
final float h = r.getHeightInPoints();
hList.add(h);
rowList.add(r);
}
List<String> colist= new ArrayList<>();
for(int l=0;l<row.getPhysicalNumberOfCells();l++) {
colist.add(row.getCell(l).getStringCellValue());
}
int nn = row_num-1;
int mm = 0;
for(int I=i*50000,l=nn+1;I<((i+1)*50000>list.size()?list.size():(i+1)*50000);I++,l++ ) {
//数据
row = sheet.createRow(l);
for(int b =0;b<colist.size();b++) {
Cell cell = row.createCell(b);
CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);
cell.setCellStyle(style);
if(BeanUtils.isEmpty(list.get(I))||StringUtil.isEmpty(colist.get(b)) || list.get(I).get(colist.get(b))==null) continue;
Object value = list.get(I).get(colist.get(b));
try {
cell.setCellValue(Integer.parseInt(value+""));
}
catch (Exception e) {
try {
cell.setCellValue(Double.parseDouble(value+""));
if(value.toString().length()>=15) {
cell.setCellValue(value+"");
}
} catch (Exception e2) {
cell.setCellValue(value+"");
}
}
}
mm = l;
}
for(Row r: rowList) {
if(BeanUtils.isEmpty(r)) continue;
mm++;
row = sheet.createRow(mm);
for (Iterator cellIt = r.cellIterator(); cellIt.hasNext();) {
Cell tmpCell = (Cell) cellIt.next();
XSSFCell newCell = (XSSFCell) row.createCell(tmpCell.getColumnIndex());
newCell.copyCellFrom(tmpCell,new CellCopyPolicy());
}
}
sheet.shiftRows(row_num, sheet.getLastRowNum(), row_size-row_num);
int l = hList.size();
for(float h: hList) {
if(BeanUtils.isEmpty(h)) continue;
sheet.getRow(sheet.getLastRowNum()-l+1).setHeightInPoints(h);
l--;
} }
}
/**
* 数据填装 【普通】
* @param wb
* @param list
* @param colist
*/
@SuppressWarnings({"rawtypes", "deprecation" })
private void setWorkbookData (Workbook wb,List<Map> list,List<Map<String, String>> colist) {
if(list==null) list=new ArrayList<>();
int pages = list.size()/50000+list.size()%50000>0?1:0;
pages=pages<1?pages+1:pages;
CellStyle c_cellStyle = wb.createCellStyle();
c_cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
c_cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
c_cellStyle.setBorderRight(CellStyle.BORDER_THIN);
c_cellStyle.setBorderTop(CellStyle.BORDER_THIN);
c_cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
c_cellStyle.setAlignment(HorizontalAlignment.CENTER);
c_cellStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
CellStyle l_cellStyle = wb.createCellStyle();
l_cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
l_cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
l_cellStyle.setBorderRight(CellStyle.BORDER_THIN);
l_cellStyle.setBorderTop(CellStyle.BORDER_THIN);
l_cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
l_cellStyle.setAlignment(HorizontalAlignment.LEFT);
l_cellStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
CellStyle r_cellStyle = wb.createCellStyle();
r_cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
r_cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
r_cellStyle.setBorderRight(CellStyle.BORDER_THIN);
r_cellStyle.setBorderTop(CellStyle.BORDER_THIN);
r_cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
r_cellStyle.setAlignment(HorizontalAlignment.RIGHT);
r_cellStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
CellStyle headStyle = wb.createCellStyle();
headStyle.setBorderBottom(CellStyle.BORDER_THIN);
headStyle.setBorderLeft(CellStyle.BORDER_THIN);
headStyle.setBorderRight(CellStyle.BORDER_THIN);
headStyle.setBorderTop(CellStyle.BORDER_THIN);
headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
headStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
headStyle.setAlignment(HorizontalAlignment.CENTER);
headStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
headStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
for(int i=0;i<pages;i++) {
Sheet sheet = wb.createSheet();
int nn = 0;
//表头
Row row = sheet.createRow(nn);
for(int b =0;b<colist.size();b++) {
if(BeanUtils.isEmpty(colist.get(b))) continue;
Cell cell = row.createCell(b);
cell.setCellStyle(headStyle);
cell.setCellValue(colist.get(b).get("colName"));
sheet.setColumnWidth(b, 5000);
}
sheet.createFreezePane( 0, nn+1, 0, nn+1 );
for(int I=i*50000,l=nn+1;I<((i+1)*50000>list.size()?list.size():(i+1)*50000);I++,l++ ) {
//数据
row = sheet.createRow(l);
for(int b =0;b<colist.size();b++) {
if(BeanUtils.isEmpty(list.get(I))||BeanUtils.isEmpty(colist.get(b)) || list.get(I).get(colist.get(b).get("name"))==null) continue;
Cell cell = row.createCell(b);
switch (colist.get(b).get("align")) {
case "right":
cell.setCellStyle(r_cellStyle);
break;
case "left":
cell.setCellStyle(l_cellStyle);
break;
default:
cell.setCellStyle(c_cellStyle);
break;
}
Object value = list.get(I).get(colist.get(b).get("name"));
try {
cell.setCellValue(Integer.parseInt(value+""));
}
catch (Exception e) {
try {
cell.setCellValue(Double.parseDouble(value+""));
if(value.toString().length()>=15) {
cell.setCellValue(value+"");
}
} catch (Exception e2) {
cell.setCellValue(value+"");
}
}
}
}
}
} /*********************echarts动态统计图*********************/
/**
* 初始化界面
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("echarts")
public ModelAndView echarts(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
List<ViewShowPo> list = new ArrayList<>();
Boolean isadmin=false;
String view_name=RequestUtil.getString(request, "view_name");
if(StringUtil.isNotEmpty(view_name)) {
//TD_PAMS_SHOWVIEW自动创建
viewShowService.completion();
list = viewShowQueryService.getByViewName(view_name);
isadmin= !"N".equals(PartyUtil.getUser().getIsSuper()); }
return getAutoView().addObject("returnUrl", preUrl)
.addObject("view_name", view_name)
.addObject("isadmin", isadmin)
.addObject("list", list)
.addObject("viewShow", list.get(0))
;
} @RequestMapping("echartsJosn")
public @ResponseBody JSONArray echartsJosn(HttpServletRequest request,HttpServletResponse reponse) throws Exception{
JSONArray options = new JSONArray();
QueryFilter queryFilter = getQuerFilter(request);
DefaultPage pagess = (DefaultPage) queryFilter.getPage();
pagess.setLimit(2147483646);
String view_name=RequestUtil.getString(request, "view_name");
try{
try{
if(StringUtil.isNotEmpty(view_name)) {
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
if("YES".equals(request.getParameter("isQuery")))
options = viewShowQueryService.getOption(view_name,queryFilter);
}
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return options;
} /**
* QueryFilter 参数校正
* @param request
* @param queryFilter
*/
private void resetQueryFilter(HttpServletRequest request,QueryFilter queryFilter) {
Map<String, Object> map = new HashMap<>();
for(String str :request.getParameterMap().keySet()) {
int begin=str.indexOf("^")<0?0:str.indexOf("^")+1;
map.put(str.substring(begin), request.getParameterMap().get(str)[0]);
}
List<WhereClause> whereList = queryFilter.getFieldLogic().getWhereClauses();
for(WhereClause w: whereList) {
DefaultQueryField field = (DefaultQueryField) w;
String value = (String) map.get(field.getField()+"^"+field.getColtype());
field.setValue(value);
}
} private void setDataSource () throws SQLException{
String defaultDsAlias = com.lc.ibps.base.datasource.dynamic.DataSourceUtil.getDefaultDsAlias();
if(!defaultDsAlias.equalsIgnoreCase("dataSource_default"))
{
javax.sql.DataSource dataSource = com.lc.ibps.base.datasource.dynamic.DataSourceUtil.getDataSourceByAlias("dataSource_default");
String dbType = com.lc.ibps.base.datasource.dynamic.DataSourceUtil.getDefaultDbType();
try {
dbType = com.lc.ibps.base.datasource.util.DbUtil.getDbTypeByDataSource(dataSource);
} catch (java.sql.SQLException e) {
throw new com.lc.ibps.base.core.exception.BaseException("数据源异常");
}
com.lc.ibps.base.datasource.dynamic.DbContextHolder.setDataSource("dataSource_default", dbType);
}
} public static void main(String[] org) {
int h=3;
h ^=1;
System.out.println(h);
h |=3;
System.out.println(h);
System.out.println(-2>>>1);
System.out.println(1<<31);
System.out.println(2<<32);
System.out.println(3<<2);
Double num = Math.pow(3, 2);
System.out.println(num); int m=2,n=3,l=n;
if(m-1<=0) n=1; else for(;m>1;m--){ n=n*l;};
System.out.println(n);
} }

ViewShowController

 package com.lc.ibps.performance.service.impl;

 import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.lc.ibps.api.base.query.QueryFilter;
import com.lc.ibps.base.core.util.BeanUtils;
import com.lc.ibps.base.core.util.JacksonUtil;
import com.lc.ibps.base.core.util.string.StringUtil;
import com.lc.ibps.performance.persistence.entity.ViewShowPo;
import com.lc.ibps.performance.repository.ViewShowRepository;
import com.lc.ibps.performance.service.ViewShowQueryService; import net.sf.json.JSONArray; /**
* TD_PAMS_VIEWSHOW 查询服务的实现类
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:28
*</pre>
*/
@Service("viewShowQueryService")
public class ViewShowQueryServiceImpl implements ViewShowQueryService{ @Resource
private ViewShowRepository viewShowRepository; @Override
public String get(String id) {
ViewShowPo po = viewShowRepository.get(id); return BeanUtils.isEmpty(po) ? null : po.toJsonString();
} @Override
public String query(QueryFilter filter) {
Map<String, String> map = new HashMap<>();
map.put("view_name", filter.getParams().get("table").toString());
List<ViewShowPo> list = viewShowRepository.getByViewName(map);
List<ViewShowPo> pos = null;
if(!list.isEmpty() && StringUtil.isNotEmpty(list.get(0).getTableCode())) { Map<String, Object> params = new HashMap<>();
params.put("table", list.get(0).getTableCode());
filter.addParamsFilter(params);
pos = viewShowRepository.newQuery(filter);
}
if(BeanUtils.isEmpty(pos)) {
Map<String, Object> params = new HashMap<>();
params.put("table", list.get(0).getViewCode());
filter.addParamsFilter(params);
pos = viewShowRepository.newQuery(filter);
}
return BeanUtils.isEmpty(pos) ? null : pos.toString();
} @Override
public String findAll() {
List<ViewShowPo> pos = viewShowRepository.findAll(); return BeanUtils.isEmpty(pos) ? null : JacksonUtil.toJsonString(pos);
} @Override
public List<ViewShowPo> getByViewName(String view_name) {
Map<String, String> map = new HashMap<>();
map.put("view_name", view_name);
List<ViewShowPo> pos = viewShowRepository.getByViewName(map);
return BeanUtils.isEmpty(pos) ? null : pos;
} @Override
public List<Map<String, String>> getColByViewName(String view_name) {
List<Map<String, String>> data=new ArrayList<>();
List<ViewShowPo> list= getByViewName(view_name);
Map<String, String> defaul = new HashMap<>();
defaul.put("colName", "['视图不存在或未设置视图']");
defaul.put("name", "XX");
defaul.put("index", "XX");
defaul.put("sortable", "false");
list.sort((a, b) -> Integer.parseInt(a.getColRank()==null?"0":a.getColRank()+"") - Integer.parseInt(b.getColRank()==null?"0":b.getColRank()+""));
for(ViewShowPo po:list) {
if("0".equals(po.getIsShow())) continue;
Map<String, String> map = new HashMap<>();
map.put("colName", po.getColName());
map.put("name", po.getColCode());
map.put("index", po.getColCode());
map.put("width", "150px");
map.put("sortable", "false");
map.put("align", "1".equals(po.getIsShow())?"center":"2".equals(po.getIsShow())?"left":"right");
data.add(map);
}
if(data.isEmpty()) data.add(defaul);
return data;
} @SuppressWarnings("rawtypes")
@Override
public JSONArray getOption(String view_name, QueryFilter queryFilter) {
//获取视图数据
Map<String, String> map = new HashMap<>();
map.put("view_name", view_name);
List<ViewShowPo> pos = viewShowRepository.getByViewName(map);
ViewShowPo view = pos.get(0);
//获取查询数据
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
queryFilter.addParamsFilter(params);
List<ViewShowPo> list = viewShowRepository.newQuery(queryFilter);
List<Map> datalist = JacksonUtil.getDTOList(JacksonUtil.getString(list.toString(), "data"), Map.class);
//横轴,数据列
String xAxisData= "";
List<String> seriesData= new ArrayList<>();
for(ViewShowPo po:pos) {
if("1".equals(po.getColRank()+"")) {
xAxisData = po.getColCode();
}
if("1".equals(po.getIsShow())) {
seriesData.add(po.getColCode());
}
}
switch (view.getTableCode()) {
case "bar":
return getBar(xAxisData,seriesData,pos,datalist);
case "pie":
return getPie(xAxisData,seriesData,pos,datalist);
case "line":
return getLine(xAxisData,seriesData,pos,datalist);
default:
return null;
}
} /**
* 单一横轴,数据列
* @param xAxisData 横轴
* @param seriesData 数据列
* @param pos 视图属性
* @param datalist 数据集合
* @return
*/
@SuppressWarnings("rawtypes")
private JSONArray getLine(String xAxisData, List<String> seriesData, List<ViewShowPo> pos, List<Map> datalist) {
Map<String, Object> option= new HashMap<>();
/********************折线****************************/
Map<String, Object> title= new HashMap<>();
option.put("title", title);
Map<String, Object> tooltip= new HashMap<>();
tooltip.put("trigger", "axis");
option.put("tooltip", tooltip);
Map<String, Object> legend= new HashMap<>();
List<String> legendList = new ArrayList<>();
Map<String, Object> toolbox= new HashMap<>();
Map<String, Object> feature= new HashMap<>();
Map<String, Object> dataView= new HashMap<>();
feature.put("dataView", dataView);
Map<String, Object> saveAsImage= new HashMap<>();
saveAsImage.put("pixelRatio", 2);
feature.put("saveAsImage", saveAsImage);
Map<String, Object> restore= new HashMap<>();
feature.put("restore", restore);
toolbox.put("feature", feature);
option.put("toolbox", toolbox);
Map<String, Object> xAxis= new HashMap<>();
xAxis.put("boundaryGap", false);
List<String> xAxisList = new ArrayList<>();
Map<String, Object> yAxis= new HashMap<>();
option.put("yAxis", yAxis);
List<Map<String, Object>> series= new ArrayList<>();
seriesData.stream().forEach((str)->{
Map<String, Object> data = new HashMap<>();
List<Object> seriesList = new ArrayList<>();
int count = xAxisList.size();
datalist.stream().forEach((m)->{
seriesList.add(m.get(str));
if(count<=0) {
xAxisList.add((String) m.get(xAxisData));
}
});
legendList.add(pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName());
data.put("name", pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName());
data.put("type", "line");
data.put("data", seriesList);
series.add(data); });
xAxis.put("data", xAxisList);
legend.put("data", legendList);
option.put("legend", legend);
option.put("xAxis", xAxis);
option.put("series", series);
return JSONArray.fromObject(option);
} /**
* 单一横轴,数据列
* @param xAxisData 横轴
* @param seriesData 数据列
* @param pos 视图属性
* @param datalist 数据集合
* @return
*/
@SuppressWarnings("rawtypes")
private JSONArray getPie(String xAxisData, List<String> seriesData, List<ViewShowPo> pos, List<Map> datalist) {
Map<String, Object> option= new HashMap<>();
Map<String, Object> series = new HashMap<>();
series.put("roseType", "angle");
series.put("type", "pie");
List<Map<String, Object>> data = new ArrayList<>();
datalist.stream().forEach((m)->{
Map<String, Object> map = new HashMap<>();
map.put("name", m.get(xAxisData)+"-"+m.get(seriesData.get(0)));
map.put("value", m.get(seriesData.get(0)));
data.add(map);
});
series.put("data", data);
option.put("series", series);
return JSONArray.fromObject(option);
} /**
* 数据列
* @param xAxisData 横轴
* @param seriesData 数据列
* @param pos 视图属性
* @param datalist 数据集合
* @return
*/
@SuppressWarnings({ "rawtypes" })
private JSONArray getBar(String xAxisData, List<String> seriesData, List<ViewShowPo> pos, List<Map> datalist) {
Map<String, Object> option= new HashMap<>();
//数据组装
Map<String, Object> title= new HashMap<>();
option.put("title", title);
Map<String, Object> tooltip= new HashMap<>();
option.put("tooltip", tooltip);
Map<String, Object> legend= new HashMap<>();
List<String> legendList = new ArrayList<>();
Map<String, Object> xAxis= new HashMap<>();
List<String> xAxisList = new ArrayList<>();
Map<String, Object> yAxis= new HashMap<>();
option.put("yAxis", yAxis);
List<Map<String, Object>> series= new ArrayList<>();
seriesData.stream().forEach((str)->{
Map<String, Object> data = new HashMap<>();
List<Object> seriesList = new ArrayList<>();
int count = xAxisList.size();
datalist.stream().forEach((m)->{
seriesList.add(m.get(str));
if(count==0) {
xAxisList.add((String) m.get(xAxisData));
}
});
legendList.add(pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName());
data.put("name", pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName());
data.put("type", "bar");
data.put("data",seriesList);
series.add(data);
});
xAxis.put("data", xAxisList);
option.put("xAxis", xAxis);
legend.put("data", legendList);
option.put("legend", legend);
option.put("series", series);
return JSONArray.fromObject(option);
} }

ViewShowQueryServiceImpl

 package com.lc.ibps.performance.service.impl;

 import java.util.HashMap;
import java.util.List;
import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import com.lc.ibps.api.base.query.QueryFilter;
import com.lc.ibps.base.core.util.BeanUtils;
import com.lc.ibps.base.core.util.string.StringUtil;
import com.lc.ibps.performance.domain.ViewShow;
import com.lc.ibps.performance.persistence.entity.ViewShowPo;
import com.lc.ibps.performance.repository.ViewShowRepository;
import com.lc.ibps.performance.service.ViewShowService; /**
* TD_PAMS_VIEWSHOW 服务的实现类
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:29
*</pre>
*/
@Service("viewShowService")
@Transactional
public class ViewShowServiceImpl implements ViewShowService{ @Resource
private ViewShowRepository viewShowRepository; @Override
public void save(String jsonData) {
ViewShow viewShow = getDomain(jsonData, null);
if(BeanUtils.isEmpty(viewShow) || StringUtil.isEmpty(viewShow.getData().getViewCode())){
return;
}
//删除
viewShow.deleteByViewName(viewShow.getData().getViewCode());
//新增
Map<String, String> map = new HashMap<>();
map.put("view_name", viewShow.getData().getViewCode());
List<ViewShowPo> list=viewShowRepository.getByViewName(map);
String data=null;
for(ViewShowPo po:list) {
if(jsonData.contains("_"+po.getColCode())) {
data=jsonData.replace("_"+po.getColCode(), "");
getDomain(data, null).save();
}
}
} @Override
public void deleteByIds(String[] ids) {
ViewShow viewShow = viewShowRepository.newInstance();
viewShow.deleteByIds(ids);
} /*######################### private ###########################*/ /**
* 获取领域对象
*
* @param cmd
* @return
*/
private ViewShow getDomain(String busData, String key){
if(BeanUtils.isEmpty(busData)){
return null;
} ViewShowPo po = ViewShowPo.fromJsonString(busData);
if(StringUtil.isNotEmpty(key)){
po.setId(key);
}
ViewShow viewShow = viewShowRepository.newInstance(po); return viewShow;
} /**
* //获取对应的table,若无则创建对应table,并修改td_pams_viewShow的table字段
* //删除对应table中的数据
* //插入view查询结果
*/
@Override
public void clock(QueryFilter queryFilter) {
Map<String, String> map = new HashMap<>();
map.put("view_name", queryFilter.getParams().get("view_name").toString());
List<ViewShowPo> polist = viewShowRepository.getByViewName(map);
if(StringUtil.isEmpty(polist.get(0).getTableCode())) {
createTable(queryFilter);
}
for(ViewShowPo po:polist) {
po.setTableCode(queryFilter.getParams().get("table").toString());
po.setId(null);
viewShowRepository.newInstance(po).save();
}
deleteTable(queryFilter);
insertTable(queryFilter);
} @Override
public void upclock(QueryFilter queryFilter) {
deleteTable(queryFilter);
} private void insertTable(QueryFilter queryFilter) {
ViewShow viewShow = viewShowRepository.newInstance(); viewShow.insertTable(QueryFilterToMap(queryFilter));
} private void deleteTable(QueryFilter queryFilter) {
ViewShow viewShow = viewShowRepository.newInstance();
viewShow.deleteTable(QueryFilterToMap(queryFilter));
} private void createTable(QueryFilter queryFilter) {
ViewShow viewShow = viewShowRepository.newInstance();
viewShow.createTable(QueryFilterToMap(queryFilter));
} private Map<String, Object> QueryFilterToMap(QueryFilter queryFilter) {
Map<String, Object> map = new HashMap<>();
map.putAll(queryFilter.getParams());
map.put("whereSql",queryFilter.getFieldLogic().getSql());
return map;
} @Override
public void completion() {
if(!isExist()) {
completionTable();
}
} private void completionTable() {
ViewShow viewShow = viewShowRepository.newInstance();
viewShow.completion();
} private boolean isExist() {
boolean exist=true;
try {
Map<String, String> map = new HashMap<>();
map.put("view_name","admin");
viewShowRepository.getByViewName(map);
} catch (Exception e) {
exist=false;
}
return exist;
} }

ViewShowServiceImpl

 package com.lc.ibps.performance.repository.impl;

 import java.util.List;
import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Repository; import com.lc.ibps.api.base.query.QueryFilter;
import com.lc.ibps.base.core.util.AppUtil;
import com.lc.ibps.base.framework.persistence.dao.IQueryDao;
import com.lc.ibps.base.framework.repository.AbstractRepository;
import com.lc.ibps.performance.domain.ViewShow;
import com.lc.ibps.performance.persistence.dao.ViewShowQueryDao;
import com.lc.ibps.performance.persistence.entity.ViewShowPo;
import com.lc.ibps.performance.repository.ViewShowRepository; /**
* TD_PAMS_VIEWSHOW 仓库的实现类
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:28
*</pre>
*/
@Repository
public class ViewShowRepositoryImpl extends AbstractRepository<String, ViewShowPo,ViewShow> implements ViewShowRepository{ @Resource
private ViewShowQueryDao viewShowQueryDao; public ViewShow newInstance() {
ViewShowPo po = new ViewShowPo();
ViewShow viewShow = AppUtil.getBean(ViewShow.class);
viewShow.setData(po);
return viewShow;
} public ViewShow newInstance(ViewShowPo po) {
ViewShow viewShow = AppUtil.getBean(ViewShow.class);
viewShow.setData(po);
return viewShow;
} @Override
protected IQueryDao<String, ViewShowPo> getQueryDao() {
return viewShowQueryDao;
} @Override
public List<ViewShowPo> getByViewName(Map<String, String> map) {
return viewShowQueryDao.findByKey("getByViewName", map);
} @Override
public List<ViewShowPo> newQuery(QueryFilter filter) {
return viewShowQueryDao.queryByQueryFilter(filter);
} }

ViewShowRepositoryImpl

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lc.ibps.performance.persistence.entity.ViewShowPo">
<resultMap id="ViewShowPo" type="com.lc.ibps.performance.persistence.entity.ViewShowPo">
<id property="id" column="ID_" jdbcType="VARCHAR"/>
<result property="viewCode" column="VIEW_CODE_" jdbcType="VARCHAR"/>
<result property="viewName" column="VIEW_NAME_" jdbcType="VARCHAR"/>
<result property="tableCode" column="TABLE_CODE_" jdbcType="VARCHAR"/>
<result property="tableName" column="TABLE_NAME_" jdbcType="VARCHAR"/>
<result property="colCode" column="COL_CODE_" jdbcType="VARCHAR"/>
<result property="colName" column="COL_NAME_" jdbcType="VARCHAR"/>
<result property="colRank" column="COL_RANK_" jdbcType="NUMERIC"/>
<result property="isShow" column="IS_SHOW_" jdbcType="VARCHAR"/>
<result property="queryType" column="QUERY_TYPE_" jdbcType="VARCHAR"/>
<result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/>
<result property="createDate" column="CREATE_DATE_" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
<result property="updateDate" column="UPDATE_DATE_" jdbcType="TIMESTAMP"/>
<result property="remarks" column="REMARKS_" jdbcType="VARCHAR"/>
<result property="delFlag" column="DEL_FLAG_" jdbcType="VARCHAR"/>
</resultMap> <sql id="columns">
ID_,VIEW_CODE_,VIEW_NAME_,TABLE_CODE_,TABLE_NAME_,COL_CODE_,COL_NAME_,COL_RANK_,IS_SHOW_,QUERY_TYPE_,CREATE_BY_,CREATE_DATE_,UPDATE_BY_,UPDATE_DATE_,REMARKS_,DEL_FLAG_
</sql> <insert id="create" parameterType="com.lc.ibps.performance.persistence.entity.ViewShowPo">
INSERT INTO TD_PAMS_VIEWSHOW
(<include refid="columns"/>)
VALUES
(#{id,jdbcType=VARCHAR}, #{viewCode,jdbcType=VARCHAR}, #{viewName,jdbcType=VARCHAR}, #{tableCode,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, #{colCode,jdbcType=VARCHAR}, #{colName,jdbcType=VARCHAR}, #{colRank,jdbcType=NUMERIC}, #{isShow,jdbcType=VARCHAR}, #{queryType,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, #{delFlag,jdbcType=VARCHAR})
</insert> <select id="get" parameterType="java.lang.String" resultMap="ViewShowPo">
SELECT <include refid="columns"/> FROM TD_PAMS_VIEWSHOW
WHERE
ID_=#{id}
</select> <select id="query" parameterType="java.util.Map" resultType="java.util.Map">
SELECT * FROM ${table}
<where>
<if test="@Ognl@isNotEmpty(whereSql)">
${whereSql}
</if>
</where>
<if test="@Ognl@isNotEmpty(orderBySql)">
ORDER BY ${orderBySql}
</if>
</select> <select id="findByIds" resultMap="ViewShowPo">
SELECT <include refid="columns"/> FROM TD_PAMS_VIEWSHOW
WHERE ID_ in
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
ORDER BY ID_ DESC
</select> <update id="update" parameterType="com.lc.ibps.performance.persistence.entity.ViewShowPo">
UPDATE TD_PAMS_VIEWSHOW SET
VIEW_CODE_=#{viewCode,jdbcType=VARCHAR},
VIEW_NAME_=#{viewName,jdbcType=VARCHAR},
TABLE_CODE_=#{tableCode,jdbcType=VARCHAR},
TABLE_NAME_=#{tableName,jdbcType=VARCHAR},
COL_CODE_=#{colCode,jdbcType=VARCHAR},
COL_NAME_=#{colName,jdbcType=VARCHAR},
COL_RANK_=#{colRank,jdbcType=NUMERIC},
IS_SHOW_=#{isShow,jdbcType=VARCHAR},
QUERY_TYPE_=#{queryType,jdbcType=VARCHAR},
CREATE_DATE_=#{createDate,jdbcType=TIMESTAMP},
UPDATE_BY_=#{updateBy,jdbcType=VARCHAR},
UPDATE_DATE_=#{updateDate,jdbcType=TIMESTAMP},
REMARKS_=#{remarks,jdbcType=VARCHAR},
DEL_FLAG_=#{delFlag,jdbcType=VARCHAR}
WHERE
ID_=#{id}
</update> <delete id="remove" parameterType="java.lang.String">
DELETE FROM TD_PAMS_VIEWSHOW
WHERE
ID_=#{id}
</delete>
<select id="getByViewName" parameterType="java.util.Map" resultMap="ViewShowPo">
SELECT CC.TABLE_NAME VIEW_CODE_,
MAX(NVL(VS.VIEW_NAME_,TC.COMMENTS)) VIEW_NAME_,
MAX(VS.TABLE_CODE_) TABLE_CODE_,
MAX(VS.TABLE_NAME_) TABLE_NAME_,
CC.COLUMN_NAME COL_CODE_,
MAX(NVL(VS.COL_NAME_,CC.COMMENTS)) COL_NAME_,
MAX(VS.COL_RANK_) COL_RANK_,
MAX(VS.IS_SHOW_) IS_SHOW_,
MAX(NVL(VS.ID_,ROWNUM)) ID_,
MAX(VS.QUERY_TYPE_) QUERY_TYPE_
FROM USER_COL_COMMENTS CC
LEFT JOIN TD_PAMS_VIEWSHOW VS
ON VS.VIEW_CODE_ = CC.TABLE_NAME
AND VS.COL_CODE_ = CC.COLUMN_NAME
LEFT JOIN USER_TAB_COMMENTS TC
ON TC.TABLE_NAME=CC.TABLE_NAME
WHERE CC.TABLE_NAME=UPPER(#{view_name})
GROUP BY CC.TABLE_NAME,CC.COLUMN_NAME
ORDER BY COL_RANK_
</select> <delete id="deleteByViewName" parameterType="java.util.Map">
DELETE FROM TD_PAMS_VIEWSHOW
WHERE
VIEW_CODE_=UPPER(#{viewCode})
</delete> <update id="createTable" parameterType="java.util.Map">
CREATE TABLE ${table} AS SELECT * FROM ${view_name} WHERE 1=2
</update> <delete id="deleteTable" parameterType="java.util.Map">
DELETE FROM ${table}
<where>
<if test="@Ognl@isNotEmpty(whereSql)">
${whereSql}
</if>
</where>
</delete> <insert id="insertTable" parameterType="java.util.Map">
INSERT INTO ${table} SELECT * FROM ${view_name}
<where>
<if test="@Ognl@isNotEmpty(whereSql)">
${whereSql}
</if>
</where>
</insert> <update id="completion">
CREATE TABLE "TD_PAMS_VIEWSHOW"
( "ID_" VARCHAR2(64) NOT NULL ENABLE,
"VIEW_CODE_" VARCHAR2(64),
"VIEW_NAME_" VARCHAR2(64),
"TABLE_CODE_" VARCHAR2(64),
"TABLE_NAME_" VARCHAR2(64),
"COL_CODE_" VARCHAR2(64),
"COL_NAME_" VARCHAR2(64),
"COL_RANK_" NUMBER(*,0),
"IS_SHOW_" VARCHAR2(32),
"QUERY_TYPE_" VARCHAR2(32),
"CREATE_BY_" VARCHAR2(64),
"CREATE_DATE_" DATE,
"UPDATE_BY_" VARCHAR2(64),
"UPDATE_DATE_" DATE,
"REMARKS_" VARCHAR2(2000),
"DEL_FLAG_" VARCHAR2(1),
CONSTRAINT "PK_TD_PAMS_VIEWSHOW" PRIMARY KEY ("ID_")
)
</update> </mapper>

ViewShow.map.xml

 
 

第二期改版:

加入EXCL模板功能,通过自定义EXCL表格模板,定义复杂表头:
/platform/viewShow/viewShow/forms.htm?view_name=视图名称

改版内容:

1.调整配置界面,尽可能在同一界面显示所有配置信息;
2.补充了模板的上传,每个功能按钮可自定义别名,考虑权限问题,暂不在配置界面处理按钮权限;
3.数据支持批量导入,单元格数据支持编辑;
4.列统计功能:右键统计当前页某列,或者通过配置界面配置预定的统计列;

  

改版效果:

代码区:

/**
* TD_PAMS_VIEWSHOW
*
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:29
*</pre>
*/ $(function() {
viewShow = new ViewShow();
viewShow.init(); formUrl = viewShow.formUrl; viewShow.resertTableHeight()
$(window).resize(function(){
viewShow._initGridList();
viewShow.resertTableHeight()
});
$('#viewbody').bind('contextmenu',function(){
return false;
}); //监听元素变化classList
//监听元素变化className
//方法一
var tab2Interval = setInterval(function(){
if(!!($('#tab-2').get(0).className) && ($('#tab-2').get(0).className).includes('active')) {
viewShow.resertTableHeight();
clearInterval(tab2Interval);
}
},10);
//方法二
// Object.defineProperty($('#tab-2').get(0),'classList', {
// get: function () {
// return classList;
// },
// set: function (newValue) {
// viewShow.resertTableHeight();//变更后触发
// }
// }); }); (function() {
//定义常量
var _consts = {
GRID : "#viewShowGrid",// 列表对象
PAGER : "#viewShowPager",// 列表分页
FORM : '#viewShowForm',// 表单form
FORMGET : '#viewShowFormGet',// 表单form
SEARCHFORM : "#searchForm"//查询表单form };
/**
* TD_PAMS_VIEWSHOW 对象
* @returns {ViewShow}
*/
ViewShow = function() {
//定义属性
}; /**
* 方法
*/
ViewShow.prototype = {
consts: _consts, /**
* 初始化
*/
init : function() {
superme=this;
superme.rowList = [10,20,50,100];
superme.rowNum = 20;
if (this.hasInit) // 是否已初始化
return false;
this.hasInit = true;
this._initForm();
if ($(this.consts.GRID).length > 0){//列表
this._initGridList();
this._groupHeaders();
this._setsum();
}
if ($(this.consts.FORM).length > 0){//表单
this._initData();
this._initOffice('e');
}
if ($(this.consts.FORMGET).length > 0){// 明细页面office控件初始化
this._initOffice('r');
}
},
_initOffice : function(_rights){
}, /**
* 初始列表
*/
_initGridList : function() {
var me = this;
var shrinkToFit = true;
var widths = 0;
colModel.forEach(function(o,i){
if(o.hidden == 'false' || !o.hidden)
widths+=parseInt((!!o.width?o.width:0));
});
if(widths>$("#tableGrid").width()) shrinkToFit=false;
$(this.consts.GRID).GridList(
{
url : __ctx+'/platform/viewShow/viewShow/listJson.htm?view_name='+view_name,
pager :this.consts.PAGER,
cellEdit : true,
cellsubmit : 'clientArray',
multiselect : false,
shrinkToFit : shrinkToFit,
autoScroll : false,
colNames: colNames,
colModel: colModel,
rowList : superme.rowList,
onRightClickRow : function(rowid,iRow,iCol,e) {
var num=0;//jQuery("#viewShowGrid").jqGrid('getCol',iCol,true,"count");
var sum=0;//jQuery("#viewShowGrid").jqGrid('getCol',iCol,true,"sum");
var avg=0;//jQuery("#viewShowGrid").jqGrid('getCol',iCol,true,"avg");
var col = jQuery("#viewShowGrid").jqGrid('getCol',iCol);
var size=0;
//DialogUtil.msg(col);
for(var i in col) {
sum+=parseFloat(!!col[i]?col[i]:0);
var indx = col[i].indexOf(".")>=0?col[i].indexOf(".")+1:0;
indx = indx==0?0:col[i].length-indx;
size=size>indx?size:indx;
num++;
} avg = num>0?sum/num:"";
num = isNaN(num)?"":num;
sum = isNaN(sum)?"":sum.toFixed(size);
size +=(num+"").length;
avg = isNaN(avg)?"":avg.toFixed(size);
superme._setsum(colNames[iCol],num,sum,avg);
// DialogUtil.confirm('当前列['+colNames[iCol]+'],是否合计?',
// function(rtn) {
// if(!rtn) return;
// var num=jQuery("#viewShowGrid").jqGrid('getCol',iCol,false,"count");
// var sum=jQuery("#viewShowGrid").jqGrid('getCol',iCol,false,"sum");
// superme._setsum(colNames[iCol],num,sum);
// }
// );
},
loadComplete : function (data) {
superme.gridData = data;
if(data.records>100) {
$("#rowList").val(superme.rowNum);
superme.rowList = [10,20,50,100,data.records];
$("#last_viewShowPager").next().html("<select id='rowList' class='ui-pg-selbox form-control' role='listbox' title='每页记录数'><option role='option' value='10'>10</option><option role='option' value='20'>20</option><option role='option' value='50'>50</option><option role='option' value='100'>100</option><option role='option' value='"+data.records+"'>"+data.records+"</option></select>");
$("#viewShowGrid").jqGrid("setGridParam", {
rowList : superme.rowList,
}).trigger('reloadGrid');
}
},
gridComplete : function () {
var str = "";
if(!!mySum) {
mySum.forEach(function(iCol,o) {
var num=0;
var sum=0;
var avg=0;
var name = "";
colModel.forEach(function(i,o){
if(i['index'] == iCol ) name = i['colName'];
})
var col = jQuery("#viewShowGrid").jqGrid('getCol',iCol);
var size=0;
for(var i in col) {
sum+=parseFloat(!!col[i]?col[i]:0);
var indx = col[i].indexOf(".")>=0?col[i].indexOf(".")+1:0;
indx = indx==0?0:col[i].length-indx;
size=size>indx?size:indx;
num++;
} if(col.length>0) {
avg = num>0?sum/num:"";
num = isNaN(num)?"":num;
sum = isNaN(sum)?"":sum.toFixed(size);
size +=(num+"").length;
avg = isNaN(avg)?"":avg.toFixed(size);
str +="<div style='white-space:pre;'><label>"+"["+name+"]合计:"+sum+",计数:"+num+"条"+",平均:"+avg+"</label></div>" ;
}
})}
$("#viewShowPager_center").html(str);
},
afterSaveCell : function(rowid,name,value) {
var cell = $("#viewShowGrid").jqGrid("getRowData",rowid);
var id = cell.ID_;
if(id) {
var data = {};
data.value = value;
data.id = cell.ID_;
data.name = name;
$.ajax({
type : "POST",
url : __ctx+'/platform/viewShow/viewShow/editCell.htm?view_name='+view_name,
data : data,
success : function(responseText) {
var resultMessage = new com.lc.form.ResultMessage(responseText);
if (resultMessage.isSuccess()) {
DialogUtil.msg("修改成功!");
} else {
DialogUtil.error(resultMessage.getMessage());
}
},
errror : function(error) {
DialogUtil.error(error);
}
});
}else {
DialogUtil.msg("当前数据为临时数据,修改值将不会保存!请联系管理员");
} }
});
$(this.consts.GRID).closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "scroll" });
},
_groupHeaders : function() {
//设置多级表头
for (var i in head) {
var row = head[i];
var groupHeaders = [];
for(var j=0;j<row.length;j++) {
if(!row[j]) continue;
var map = {};
map.startColumnName = row[j].id;
map.numberOfColumns = row[j].num;
map.titleText = row[j].name;
groupHeaders.push(map);
}
$('#viewShowGrid').jqGrid('setGroupHeaders', {
    useColSpanStyle: true,
    groupHeaders:groupHeaders
});
}
},
/**
* 显示合计项
*/
_setsum : function(name,num,sum,avg) { var str = "["+name+"]合计:"+sum+",计数:"+num+"条"+",平均:"+avg;
$("#viewShowPager_center").html("<td id='viewShowPager_center' align='center' style='white-space:pre;'><label>"+str+"</label></td>");
},
/**
* 初始化表单
*/
_initForm : function() {
var me = this, form = $(this.consts.FORM), frm = form.form();
me.formUrl = new com.lc.form.FormData(form);
// 触发表单验证
frm.valid();
// 处理表单保存
//$("#fa-save").on('click',function(){
$(document).on('click', 'a.fa-save', function() {
var judge = JSON.parse($("#file").val());
$("#exclId").val($("#file").val());
var $el = $(this);
DialogUtil.load("....");
$el.button('loading');
// office提交
OfficePlugin.submit();
me.formUrl.submit(me._showResponse, $el);
});
//查询结果
//$("#fa-search").on('click',function(){
$(document).on('click', 'a.fa-search', function() {
superme.search(this);
});
$(document).on('change', '#rowList', function(o,n,l) {
superme.rowNum = $("#rowList").val();
$("#viewShowGrid").jqGrid("setGridParam", {
rowNum : superme.rowNum,
}).trigger('reloadGrid');
});
//TODO 导入
$(document).on("click", "a.fa-upload", function(){
if ($(this).hasClass('disabled'))
return false;
DialogUtil.dialog({
content : __ctx+'/platform/viewShow/viewShow/import.htm',
params : {
formKey : null,
fields : null,
saveUrl : __ctx+'/platform/viewShow/viewShow/upload.htm?view_name='+view_name,
},
area : [ '60%', '80%' ],
title : "导入数据",
callback : function(rtn) {
if (rtn) {
DialogUtil.msg("导入成功!");
}
}
});
}); //TODO 导出结果
//$("#fa-export").on('click',function(){
$(document).on('click', 'a.fa-export', function() {
var url = __ctx+'/platform/viewShow/viewShow/exportForms.htm?view_name='+view_name+'&export_='+export_+'&data='+data;
$("#searchForm").attr("action",url);
$("#searchForm").attr("method",'post');
$("#searchForm").submit();
});
//TODO 查询结果锁定
//$("#fa-lock").on('click',function(){
$(document).on('click', 'a.fa-lock', function() {
var obj=this;
if ($(obj).hasClass('disabled'))
return;
var searchForm = $(obj).closest("div .toolbar-panel").find(
".search-form");
if (searchForm.length == 0)
return;
var data = superme._serializeObject(searchForm);
DialogUtil.confirm('保存当前查询结果,是否继续操作',
function(rtn) {
if(!rtn) return;
DialogUtil.load("....");
$.ajax({
type : "POST",
url : __ctx+'/platform/viewShow/viewShow/clock.htm?view_name='+view_name,
data : data,
success : function(responseText) {
DialogUtil.closeAll();
var resultMessage = new com.lc.form.ResultMessage(responseText);
if (resultMessage.isSuccess()) {
DialogUtil.msg(resultMessage.getMessage(),true);
} else {
DialogUtil.error(resultMessage.getMessage());
}
},
errror : function(error) {
DialogUtil.error(error);
}
}); }
);
});
//TODO 查询结果解锁
//$("#fa-unlock").on('click',function(){
$(document).on('click', 'a.fa-unlock', function() {
var obj=this;
if ($(obj).hasClass('disabled'))
return;
var searchForm = $(obj).closest("div .toolbar-panel").find(
".search-form");
if (searchForm.length == 0)
return;
var data = superme._serializeObject(searchForm);
DialogUtil.confirm('从保存记录中剔除当前查询结果,是否继续操作',
function(rtn) {
if(!rtn) return;
DialogUtil.load("....");
$.ajax({
type : "POST",
url : __ctx+'/platform/viewShow/viewShow/unclock.htm?view_name='+view_name,
data : data,
success : function(responseText) {
DialogUtil.closeAll();
var resultMessage = new com.lc.form.ResultMessage(responseText);
if (resultMessage.isSuccess()) {
DialogUtil.mas(resultMessage.getMessage(),true);
} else {
DialogUtil.error(resultMessage.getMessage());
}
},
errror : function(error) {
DialogUtil.error(error);
}
}); }
);
});
},
/**
* 初始化数据
*/
_initData : function(){
if(!$.isEmpty(frameElement)
&& !$.isEmpty(frameElement.dialog)
&& !$.isEmpty(frameElement.dialog.params)
&& !$.isEmpty(frameElement.dialog.params.data)){
var data = frameElement.dialog.params.data;
this.formUrl.setData("[name^='m:']", data);
AttachementControl.initDataTo($("div[name='div_attachment_container']")); //附件初始化
}else{
$("[name^='m:']", $(_consts.FORM)).each(function(){
var data = $(this);
// 单选框特殊处理
if(data.is('input') && "radio" == data.attr("type")){
var defaultVal = data.attr("defaultVal");
var defaultValue = data.attr("defaultValue");
if(defaultValue=="true"&&defaultVal=="true"){
data.prop("checked", "checked");
}
}
});
} this.formUrl.validate();
},
/**
* 表单成功返回信息
*
* @param responseText
*/
_showResponse : function(responseText) {
DialogUtil.closeAll();
var msg = new com.lc.form.ResultMessage(responseText);
if (msg.isSuccess()) {
DialogUtil.confirm(msg.getMessage() + ',是否继续操作',
function(rtn) {
if(rtn)
window.location.reload(true);
/*else
window.location.href = __ctx+'/platform/viewShow/viewShow/list.htm';*/
});
} else {
DialogUtil.error(msg.getMessage());
}
},
/**
*
* @param form
* @returns {___anonymous4353_4354}
*/
_serializeObject : function(form) {
var o = {}, a = $(form).serializeArray();
// var o = {}, a = $(form).ghostsf_serialize();
var $radio = $('input[type=radio],input[type=checkbox]', form);
var temp = {};
$.each($radio, function () {
if (!temp.hasOwnProperty(this.name)) {
if ($("input[name='" + this.name + "']:checked").length == 0) {
temp[this.name] = "";
a.push({name: this.name, value: ""});
}
}
});
$.each(a, function() {
var v = this.value || '';
if (o[this.name]) {
o[this.name] = o[this.name] +","+ v;
} else {
o[this.name] =v;
}
}); return o;
},
/**
* 查询
* @param obj
*/
search : function(obj) {
if ($(obj).hasClass('disabled'))
return;
var searchForm = $(obj).closest("div .toolbar-panel").find(
".search-form");
if (searchForm.length == 0)
return;
var data = superme._serializeObject(searchForm);
// $(this.consts.GRID).trigger("reloadGrid", {
// fromServer: true,
// postData : data,
// page: 1
// }); $(this.consts.GRID).jqGrid().setGridParam({
datatype:'json',
postData : data,
}).trigger('reloadGrid'); // $(this.consts.GRID).GridList('setGridParam', {
// url : __ctx+'/platform/viewShow/viewShow/listJson.htm?view_name='+view_name,
// postData : data, // 发送数据
// page : 1
// }).trigger("reloadGrid"); // 重新载入
},
resertTableHeight: function() {
var heightList = $(parent.window.document).find('iframe');
var last = heightList.toArray().pop();
($('#tableData').get(0).style)['maxHeight'] = last.clientHeight-42-5-40-10-30-56-40-10+'px';
if(($($('#tableData').get(0)).find('table').get(0)).clientHeight > $('#tableData').get(0).clientHeight) {
if(!!($($('#tableHead').get(0)).find('table').get(0)).clientHeight) ($('#tableHead').get(0).style)['maxHeight'] = ($($('#tableHead').get(0)).find('table').get(0)).clientHeight+'px';
} else {
if(!!($($('#tableHead').get(0)).find('table').get(0)).clientHeight)
($('#tableHead').get(0).style)['maxHeight'] = ($($('#tableHead').get(0)).find('table').get(0)).clientHeight+2+'px';
}
}
};
})();

viewShowForm.js

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/commons/page/codegen.jsp" %>
<script type="text/javascript" src="${ctx}/js/lc/platform/utils/SelectorDialog.js"></script>
<script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShowForms.js?v=1"></script>
<script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShowDialog.js"></script>
<script type="text/javascript"> var colNames=[],colModel=[],view_name="${view_name}",colist=${colist},head =${head},mySum =${mySum},export_="${export_}",data="${data}",dataNum="${viewShow.dataNum}";
for(var i in colist) {
if(colist[i]) {
colNames.push(colist[i].colName);
if("true" == colist[i].sortable) colist[i].sortable=true;
if("false" == colist[i].sortable) colist[i].sortable=false;
if("true" == colist[i].editable) colist[i].editable=true;
if("false" == colist[i].editable) colist[i].editable=false;
if("true" == colist[i].key) colist[i].key=true;
if("false" == colist[i].key) colist[i].key=false;
if("true" == colist[i].hidden) colist[i].hidden=true;
if("false" == colist[i].hidden) colist[i].hidden=false;
colModel.push(colist[i]);
}
} $(function(){
$(".search-select").select2({
language : "zh-CN",
minimumInputLength : 0,
placeholder:"请选择",//默认值
allowClear: true
}); var selectList = $("select[name^='m:viewShow:queryType_']");
if(selectList.length>0) {
$.each(selectList,function(i,p) {
selectList.eq(i).on('change',function(e){
if(e.target.value == '20') {
var name = $(this).get(0).name+"";
name = name.replace('m:viewShow:queryType_','');
new ViewShowDialog({
title : "联动查询设置",
url : __ctx+'/platform/viewShow/viewShow/params.htm?view_name='+view_name+'&colCode='+name,
isObj : true,
callback : function(obj){ }
}).show();
}
});
});
} var selects = $('.tangzeqi');
for(var i=0;i<selects.length;i++) {
var select = selects.eq(i);
var options = select.get(0).attributes;
var data = {};
$.each(options,function(i,option){
if(option.nodeName.includes('data-'))
data[option.nodeName.replace('data-','')]=option.nodeValue;
});
select.append("<option value=''>--请选择--</option>");
$.ajaxSettings.async = false;
$.post(__ctx+data.url,data,function(result) {
$.each(result,function(o,row){
select.append("<option value='"+row.id+"' <c:if test='"+(row.id==data.value)+"'>selected='selected'</c:if>>"+row.name+"</option>");
});
});
select.on('change',function(e) {
var me = $(this);
var options = me.get(0).attributes;
var data = {};
$.each(options,function(i,option){
if(option.nodeName.includes('data-'))
data[option.nodeName.replace('data-','')]=option.nodeValue;
});
if(data.to != null && data.to !='undefind' && data.to !="" ) {
var select = $(data.to);
select.empty();
var thisData = {};
$.each(select.get(0).attributes,function(i,option){
if(option.nodeName.includes('data-'))
thisData[option.nodeName.replace('data-','')]=option.nodeValue;
});
if(!thisData.defautkey)
thisData.findkey = e.target.value;
else thisData.findId = e.target.value;
$.post(__ctx+thisData.url,thisData,function(result) {
select.append("<option value=''>--请选择--</option>");
$.each(result,function(o,row){
select.append("<option value='"+row.id+"' <c:if test='"+(row.id==data.value)+"'>selected='selected'</c:if>>"+row.name+"</option>");
});
});
}
});
}
});
</script>
<style type="text/css">
.form-horizontal .form-group {
margin-right: 0px;
margin-left: 0px;
}
.fr-form-control[disabled], .fr-form-control[readonly], fieldset[disabled] .fr-orm-control {
opacity: 1;
border: 0;
}
th.ui-th-column div{
white-space:normal !important;
height:auto !important;
padding:0px;
}
ui-th-column ui-th-ltr { }
.file-select-trigger label .select-text{
padding: 0;
}
.file-select-trigger{
border: 0;
}
.fr-file{
border: 0;
}
.fr-file .status{
margin-top: 7px;
}
.fr-file .preview-area{
margin: 2px;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance:none;
}
input[type="number"] {
-moz-appearance: textfield;
}
.dropdown .dropdown-menu li>a{display:inline-block;padding:0;}
.ui-jqgrid .ui-jqgrid-htable thead th {border-bottom:1px solid #DDDDDD;}
.select2-container--default .select2-selection--single {
background-color: #fff;
border: 1px solid #e5e6e7;
border-radius: 0px;
}
.select2-container .select2-selection--single {
box-sizing: border-box;
cursor: pointer;
display: block;
height: 34px;
user-select: none;
-webkit-user-select: none;
}
.file-select-trigger {
display: none;
}
.first th,#resultAllotGrid .std{
border: 1px solid #e7e7e7;
line-height: 1.42857;
background-color: #F5F5F6;
font-size: 14px;
font-weight: 600;
height: 38px;
padding: 8px;
vertical-align: middle;
text-align: center;
display: table-cell;
border-left: 0px none !important;
}
.viewTable{
border: 1px solid #EBEBEB;
border-left: 0px none !important;
border-top: 0px none !important;
margin-bottom: 0px;
table-layout: fixed;
background-color: transparent;
border-collapse:collapse;
min-height: 56px;
}
.viewTable .std{
font-weight: 500;
}
.std ~ td{
border: 1px solid #EBEBEB;
border-left: 0px none !important;
text-align: center;
}
#_bdiv{
margin-left: 21px;
position: relative;
border: 1px solid #ddd;
float: left;
margin-top: 1px;
border-top: 0px;
}
.lable-text {
height: 36px;
border: ridge;
text-align: center;
}
.lable-value {
height: 36px;
border: 0;
padding-right: 20px;
padding-left: 20px;
width: -webkit-fill-available;
font-size: xx-small;
}
#_div{
position: relative;
line-height: 1.42857143;
box-sizing: border-box;
margin: 0;
padding: 0;
overflow-y: auto;
overflow-x: hidden;
}
td#viewShowPager_center div {
text-align: left;
padding-left: 30%;
}
.unedit {
background-color: #F5F5F6;
}
</style>
<title>管理列表</title>
</head>
<body id="viewbody">
<div class="wrapper wrapper-content animated fadeInRight col-sm-12">
<form class="form-horizontal">
<c:if test="${isadmin}">
<div class="panel">
<div class="tabs-container tabs-x">
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#tab-1" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询</a>
</li>
<li >
<a data-toggle="tab" href="#tab-2" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询管理</a>
</li>
</ul>
</div>
</div>
</c:if>
<div class="tab-content">
<div id="tab-1" class="tab-pane active">
<div class="panel-body">
<div class="toolbar-panel ">
<div class="toolbar-box">
<div class="toolbar-head clearfix">
<!-- 顶部按钮 -->
<div class="buttons">
<f:a alias="${view_name}_search" classes="btn btn-primary fa fa-search" onclick="javascript:$('#isQuery').val('YES')" href="javascript:void(0);" ><span>${ empty viewShow.vSearch?'搜索':viewShow.vSearch }</span></f:a>
<f:a alias="${view_name}_upload" classes="btn btn-primary fa fa-upload" href="javascript:void(0);" ><span>${ empty viewShow.vUpload?'导入':viewShow.vUpload }</span></f:a>
<f:a alias="${view_name}_export" classes="btn btn-primary fa fa-export" href="javascript:void(0);" ><span>${ empty viewShow.vExport?'导出':viewShow.vExport }</span></f:a>
<f:a alias="${view_name}_lock" classes="btn btn-primary fa fa-lock" href="javascript:void(0);" ><span>${ empty viewShow.vLock?'锁定':viewShow.vLock }</span></f:a>
<f:a alias="${view_name}_unlock" classes="btn btn-primary fa fa-unlock" href="javascript:void(0);" ><span>${ empty viewShow.vUnlock?'解锁':viewShow.vUnlock }</span></f:a>
<%-- <f:a alias="${view_name}_search" classes="btn btn-primary fa fa-search" onclick="javascript:$('#isQuery').val('YES')" href="javascript:void(0);" ><span>搜索</span></f:a>
<f:a alias="${view_name}_upload" classes="btn btn-primary fa fa-upload" href="javascript:void(0);" ><span>导入</span></f:a>
<f:a alias="${view_name}_export" classes="btn btn-primary fa fa-export" href="javascript:void(0);" ><span>导出</span></f:a>
<f:a alias="${view_name}_lock" classes="btn btn-primary fa fa-lock" href="javascript:void(0);" ><span>锁定</span></f:a>
<f:a alias="${view_name}_unlock" classes="btn btn-primary fa fa-unlock" href="javascript:void(0);" ><span>解锁</span></f:a> --%> <%-- <a class="btn btn-primary fa fa-search" onclick="javascript:$('#isQuery').val('YES')" href="javascript:void(0);" ><span>搜索</span></a>
<a class="btn btn-primary fa fa-upload" href="javascript:void(0);" ><span>导入</span></a>
<a class="btn btn-primary fa fa-export" href="javascript:void(0);" ><span>导出</span></a>
<c:if test="${isadmin}">
<a class="btn btn-primary fa fa-lock" href="javascript:void(0);" ><span>锁定</span></a>
<a class="btn btn-primary fa fa-unlock" href="javascript:void(0);" ><span>解锁</span></a>
</c:if> --%>
<%-- <a class="btn btn-primary fa fa-add" href="${ctx}/platform/viewShow/viewShow/edit.htm" ><span>添加</span></a>
<a class="btn btn-primary fa fa-edit" href="javascript:void(0);" action="${ctx}/platform/viewShow/viewShow/edit.htm" ><span>编辑</span></a>
<a class="btn btn-primary fa fa-remove" href="javascript:void(0);" action="${ctx}/platform/viewShow/viewShow/remove.htm"><span>删除</span></a> --%>
</div>
<!-- 收缩 -->
<div class="tools">
<a href="javascript:void(0);" class="collapse">
<i class="bigger-180 fa fa-angle-double-up"></i>
</a>
</div>
</div>
<!-- #查询条件3-->
<div class="toolbar-body" >
<form></form>
<!-- role="form" -->
<form id="searchForm" class="search-form">
<input type="hidden" name="isQuery" id="isQuery" value="No">
<div class="form-inline p-xxs">
<c:forEach items="${list}" var="item">
<%@include file="viewShowSelecter.jsp" %>
</c:forEach>
</div>
</form>
</div><!--/ 查询条件-->
</div>
</div><!--/ 操作、查询-->
<div id="tableGrid" class="jqGrid_wrapper">
<table id="viewShowGrid" ></table>
<div id="viewShowPager"></div>
</div>
</div>
</div>
<c:if test="${isadmin}">
<div id="tab-2" onshow="viewShow.resertTableHeight()" class="tab-pane <c:if test="${false}">active</c:if>">
<div class="panel-body">
<div class="panel-toolbar ">
<div class="buttons">
<a href="javascript:void(0);" class="btn btn-primary fa fa-save" ><span>保存</span></a>
<a href="forms.htm?view_name=${view_name}" class="btn btn-primary fa fa-back" ><span>返回</span></a>
</div>
</div>
<div class="">
<form class="fr-form" id="viewShowForm" action="save.htm" >
<div class="fr_response_field col-sm-4" style="float: right;">
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">视图名</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control unedit" placeholder="菜单标识,视图不同数据不同" name="m:viewShow:viewCode" readonly="readonly" value="${viewShow.viewCode}" title="${viewShow.viewCode}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">视图备注</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" placeholder="功能别名,作为导出文件名称" name="m:viewShow:viewName" value="${viewShow.viewName}" title="${viewShow.viewName}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">对应表名</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control unedit" placeholder="物理化数据存储位置" name="m:viewShow:tableCode" readonly="readonly" value="${viewShow.tableCode}" title="${viewShow.tableCode}" validate="{required:false}"/> </div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">对应表备注</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:tableName" placeholder="常用于备注数据说明" value="${viewShow.tableName}" title="${viewShow.tableName}" validate="{required:false}"/>
</div>
</div>
</div> <div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">对应报表</label>
<div class="fr-form-block" data-type="fixed">
<input type="hidden" id="exclId" class="fr-form-control" name="m:viewShow:exclId" value="" title="${viewShow.exclId}" validate="{required:false}"/>
<div name="div_attachment_container" class="fr-form-control" data-media="xlsx,xls"
data-media_type="xlsx" data-max_file_size=""
<%-- <c:if test="${not empty viewShow.exclId}"> data-rights="r" </c:if> --%>
data-max_file_quantity="1">
<div class="fr-files" ></div>
<textarea style="display: none" data-control="attachment"
id="file"
validate="{required:false}">${viewShow.exclId}</textarea>
</div>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">数据行号</label>
<div class="fr-form-block" data-type="fixed">
<input type="number" class="fr-form-control" name="m:viewShow:dataNum" placeholder="数据起始行号对用表格行号" value="${viewShow.dataNum}" title="${viewShow.dataNum}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">表头起始行</label>
<div class="fr-form-block" data-type="fixed">
<input type="number" class="fr-form-control" name="m:viewShow:headStart" placeholder="多表头起始行号对用表格行号" value="${viewShow.headStart}" title="${viewShow.headStart}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">表头结束行</label>
<div class="fr-form-block" data-type="fixed">
<input type="number" class="fr-form-control" name="m:viewShow:headEnd" placeholder="多表头结束行号对用表格行号" value="${viewShow.headEnd}" title="${viewShow.headEnd}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">搜索功能</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:vSearch" placeholder="功能按钮别名" value="${viewShow.vSearch}" title="${viewShow.vSearch}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">导入功能</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:vUpload" placeholder="功能按钮别名" value="${viewShow.vUpload}" title="${viewShow.vUpload}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">导出功能</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:vExport" placeholder="功能按钮别名" value="${viewShow.vExport}" title="${viewShow.vExport}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">锁定功能</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:vLock" placeholder="功能按钮别名" value="${viewShow.vLock}" title="${viewShow.vLock}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-12" >
<div class="fr-form-group">
<label class="fr-control-label">解锁功能</label>
<div class="fr-form-block" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:vUnlock" placeholder="功能按钮别名" value="${viewShow.vUnlock}" title="${viewShow.vUnlock}" validate="{required:false}"/>
</div>
</div>
</div>
</div>
<div class="fr_response_field col-sm-8">
<div id="_bdiv">
<div id="_div">
<div style="position:relative;">
<div id="tableHead" style="overflow-y: auto;max-height: 55px" >
<table class = "viewTable" style="width: 100%">
<tr class ="first">
<th width="15%">字段名</th>
<th width="15%">字段备注</th>
<th width="10%">报表对应列</th>
<th width="10%">列宽</th>
<th width="10%">是否编辑</th>
<th width="10%">是否统计</th>
<th width="10%">显示设置</th>
<th width="20%">查询方式</th>
</tr>
</table>
</div>
<div id="tableData" style="overflow-y: auto;" >
<table class = "viewTable" style="width: 100%">
<c:forEach items="${list}" var="view">
<tr>
<td class="lable-text unedit" width="15%"><input type="text" class="lable-value unedit" name="m:viewShow:colCode_${view.colCode}" readonly="readonly" value="${view.colCode}" title="${view.colCode}" validate="{required:false}"/></td>
<td class="lable-text" width="15%"><input type="text" placeholder="查询条件别名" class="lable-value" name="m:viewShow:colName_${view.colCode}" value="${view.colName}" title="${view.colName}" validate="{required:false}"/></td>
<td class="lable-text" width="10%"><input type="number" class="lable-value" name="m:viewShow:colRank_${view.colCode}" min="0" value="${view.colRank}" title="${view.colRank}" validate="{required:false}"/></td>
<td class="lable-text" width="10%"><input type="number" class="lable-value" name="m:viewShow:colWidth_${view.colCode}" min="0" value="${view.colWidth}" title="${view.colWidth}" validate="{required:false}"/></td>
<td class="lable-text" width="10%">
<select class="lable-value" name="m:viewShow:isEdit_${view.colCode}" value="${view.isEdit}" validate="{required:false}">
<option value="0" <c:if test="${view.isEdit=='0'}">selected="selected"</c:if>>否</option>
<option value="1" <c:if test="${view.isEdit=='1'}">selected="selected"</c:if>>是</option>
</select>
</td>
<td class="lable-text" width="10%">
<select class="lable-value" name="m:viewShow:isSum_${view.colCode}" value="${view.isSum}" validate="{required:false}">
<option value="0" <c:if test="${view.isSum=='0'}">selected="selected"</c:if>>否</option>
<option value="1" <c:if test="${view.isSum=='1'}">selected="selected"</c:if>>是</option>
</select>
</td>
<td class="lable-text" width="10%">
<select class="lable-value" name="m:viewShow:isShow_${view.colCode}" value="${view.isShow}" validate="{required:false}">
<option value="0" <c:if test="${view.isShow=='0' or empty view.isShow}">selected="selected"</c:if>>隐藏</option>
<option value="2" <c:if test="${view.isShow=='2' or empty view.isShow}">selected="selected"</c:if>>居左</option>
<option value="3" <c:if test="${view.isShow=='3' or empty view.isShow}">selected="selected"</c:if>>居右</option>
<option value="1" <c:if test="${view.isShow=='1' or empty view.isShow }">selected="selected"</c:if>>居中</option>
</select>
</td>
<td class="lable-text" width="20%">
<select class="lable-value" name="m:viewShow:queryType_${view.colCode}" value="${view.queryType}" validate="{required:false}">
<%@include file="viewShowOptions.jsp" %>
</select>
</td>
</tr>
</c:forEach>
</table>
</div>
</div>
</div>
</div>
</div> <%-- <div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">字段名</label>
</div>
</div>
<div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">字段备注</label>
</div>
</div>
<div class="fr_response_field col-sm-1 tableview" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">报表对应列</label>
</div>
</div>
<div class="fr_response_field col-sm-1 tableview" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">是否编辑</label>
</div>
</div>
<div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">显示设置</label>
</div>
</div>
<div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<label class="fr-control-label" style="text-align: left;">查询方式</label>
</div>
</div>
<c:forEach items="${list}" var="view">
<div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">字段名</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:colCode_${view.colCode}" readonly="readonly" value="${view.colCode}" title="${view.colCode}" validate="{required:false}"/>
</div>
</div>
</div>
<div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">字段备注</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="text" class="fr-form-control" name="m:viewShow:colName_${view.colCode}" value="${view.colName}" title="${view.colName}" validate="{required:false}"/> </div>
</div>
</div>
<div class="fr_response_field col-sm-1 tableview" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">对应报表列</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<input type="number" class="fr-form-control" name="m:viewShow:colRank_${view.colCode}" min="0" value="${view.colRank}" title="${view.colRank}" validate="{required:false}"/> </div>
</div>
</div>
<div class="fr_response_field col-sm-1 tableview" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">是否编辑</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:isEdit_${view.colCode}" value="${view.isEdit}" validate="{required:false}">
<option value="">--请选择--</option>
<option value="0" <c:if test="${view.isEdit=='0'}">selected="selected"</c:if>>否</option>
<option value="1" <c:if test="${view.isEdit=='1'}">selected="selected"</c:if>>是</option>
</select> </div>
</div>
</div>
<div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">显示设置</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:isShow_${view.colCode}" value="${view.isShow}" validate="{required:false}">
<option value="">--请选择--</option>
<option value="0" <c:if test="${view.isShow=='0'}">selected="selected"</c:if>>隐藏</option>
<option value="1" <c:if test="${view.isShow=='1'}">selected="selected"</c:if>>居中</option>
<option value="2" <c:if test="${view.isShow=='2'}">selected="selected"</c:if>>居左</option>
<option value="3" <c:if test="${view.isShow=='3'}">selected="selected"</c:if>>居右</option>
</select> </div>
</div>
</div>
<div class="fr_response_field col-sm-2 tableview" >
<div class="fr-form-group">
<!-- <label class="fr-control-label">查询方式</label> -->
<div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed">
<select class="fr-form-control" name="m:viewShow:queryType_${view.colCode}" value="${view.queryType}" validate="{required:false}">
<option value="">--请选择--</option>
<%@include file="viewShowOptions.jsp" %>
</select>
</div>
</div>
</div>
</c:forEach> --%>
</form>
</div>
</div>
</div>
</c:if>
</div>
</form>
</div>
</body>
</html>

viewShowForm.jsp

package com.lc.ibps.platform.viewShow.controller;

import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import com.lc.ibps.api.base.query.QueryFilter;
import com.lc.ibps.api.base.query.WhereClause;
import com.lc.ibps.base.core.entity.ResultMessage;
import com.lc.ibps.base.core.util.BeanUtils;
import com.lc.ibps.base.core.util.JacksonUtil;
import com.lc.ibps.base.core.util.string.StringUtil;
import com.lc.ibps.base.db.model.DefaultQueryField;
import com.lc.ibps.base.db.mybatis.domain.DefaultPage;
import com.lc.ibps.base.framework.page.PageList;
import com.lc.ibps.base.framework.page.PageResult;
import java.lang.reflect.Method;
import com.lc.ibps.base.web.controller.GenericController;
import com.lc.ibps.base.web.json.PageJson;
import com.lc.ibps.base.web.util.AppFileUtil;
import com.lc.ibps.base.web.util.RequestUtil;
import com.lc.ibps.performance.persistence.entity.ViewShowPo;
import com.lc.ibps.performance.service.ViewShowQueryService;
import com.lc.ibps.performance.service.ViewShowService;
import com.lc.ibps.platform.org.utils.PartyUtil; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; /**
* TD_PAMS_VIEWSHOW 控制类
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:29
*</pre>
*/
@Controller
@RequestMapping("/platform/viewShow/viewShow/")
public class ViewShowController extends GenericController{
@Resource
private ViewShowService viewShowService;
@Resource
private ViewShowQueryService viewShowQueryService; public @interface returnTwo {
String value();
String name() default "2323" ; } public static void main(String[] org) {
Method[] methods = ViewShowController.class.getDeclaredMethods();
for(Method method:methods) {
if(method.isAnnotationPresent(returnTwo.class)) {
String str = method.getAnnotation(returnTwo.class).value();
System.out.println(str);
}
} } /**
*TODO 视图查询界面
* @param request
* @param response
* @throws Exception
* @param view_name 视图名
* @param export 导出模板路径
* @param data 导出模板数据起始行
*/
@returnTwo(value="999")
@RequestMapping("list")
public ModelAndView list(HttpServletRequest request,HttpServletResponse response) throws Exception{ String preUrl= RequestUtil.getPrePage(request);
List<ViewShowPo> list = new ArrayList<>();
Boolean isadmin=false;
List<Map<String, String>> colist = new ArrayList<>();
String view_name=RequestUtil.getString(request, "view_name");
String export=RequestUtil.getString(request, "export");
String data=RequestUtil.getString(request, "data");
if(StringUtil.isNotEmpty(view_name)) {
//TD_PAMS_SHOWVIEW自动创建
viewShowService.completion();
list = viewShowQueryService.getByViewName(view_name);
isadmin=!"N".equals(PartyUtil.getUser().getIsSuper());
colist = viewShowQueryService.getColByViewName(view_name);
} JSONArray colIst = JSONArray.fromObject(colist);
return getAutoView().addObject("returnUrl", preUrl)
.addObject("view_name", view_name)
.addObject("isadmin", isadmin)
.addObject("colist", colIst)
.addObject("list", list)
.addObject("viewShow", list.get(0))
.addObject("export_", export)
.addObject("data", data)
;
}
/**
* 【TD_PAMS_VIEWSHOW】列表(分页条件查询)数据
*
* @param request
* @param reponse
* @return
* @throws Exception
*/
@SuppressWarnings("rawtypes")
@RequestMapping("listJson")
public @ResponseBody PageJson listJson(HttpServletRequest request,HttpServletResponse reponse) throws Exception{
QueryFilter queryFilter = getQuerFilter(request);
String view_name=RequestUtil.getString(request, "view_name");
try{
String listData = null;
try{
if(StringUtil.isNotEmpty(view_name)) {
// setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
if("YES".equals(request.getParameter("isQuery"))) listData = viewShowQueryService.query(queryFilter);
}
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
PageList<Map> viewShowList = null;
if(JacksonUtil.isJsonObject(listData)){
List<Map> list = JacksonUtil.getDTOList(JacksonUtil.getString(listData, "data"), Map.class);
PageResult pageResult = PageResult.fromJson(JacksonUtil.getString(listData, "pageResult"));
viewShowList = new PageList<Map>(list, pageResult);
}
return new PageJson(viewShowList);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new PageJson();
}
} /**
* 编辑【TD_PAMS_VIEWSHOW】信息页面
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("edit")
public ModelAndView edit(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
String id=RequestUtil.getString(request, "id");
ViewShowPo viewShow=null;
if(StringUtil.isNotEmpty(id)){
String data = null; try{
// setDataSource(); data = viewShowQueryService.get(id);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} viewShow = ViewShowPo.fromJsonString(data);
} return getAutoView().addObject("viewShow", viewShow).addObject("returnUrl", preUrl);
} /**
* 编辑【TD_PAMS_VIEWSHOW】信息页面
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("flowEdit")
public ModelAndView flowEdit(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
String id=RequestUtil.getString(request, "id");
ViewShowPo viewShow=null;
if(StringUtil.isNotEmpty(id)){
String data = null; try{
// setDataSource(); data = viewShowQueryService.get(id);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} viewShow = ViewShowPo.fromJsonString(data);
}
return getAutoView().addObject("viewShow", viewShow).addObject("returnUrl", preUrl);
} /**
* 【TD_PAMS_VIEWSHOW】明细页面
*
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("get")
public ModelAndView get(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
String id=RequestUtil.getString(request, "id");
ViewShowPo viewShow=null;
if(StringUtil.isNotEmpty(id)){
String data = null; try{
// setDataSource(); data = viewShowQueryService.get(id);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} viewShow = ViewShowPo.fromJsonString(data);
}
return getAutoView().addObject("viewShow", viewShow).addObject("returnUrl", preUrl);
} /**
* 保存【TD_PAMS_VIEWSHOW】信息
*
* @param request
* @param response
* @param viewShow
* @throws Exception
*/
@RequestMapping("save")
public void save(HttpServletRequest request,HttpServletResponse response) throws Exception{
ResultMessage message=null;
try {
String json = RequestUtil.getString(request, "json"); try{
// setDataSource();
viewShowService.save(json);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} message=new ResultMessage(ResultMessage.SUCCESS, "保存成功");
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "对操作失败,"+e.getMessage());
logger.error("操作失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 批量删除【TD_PAMS_VIEWSHOW】记录
*
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("remove")
public void remove(HttpServletRequest request,HttpServletResponse response) throws Exception{
ResultMessage message=null;
try {
//获得待删除的id
String[] ids=RequestUtil.getStringAryByStr(request, "id"); try{
// setDataSource(); viewShowService.deleteByIds(ids);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
} message=new ResultMessage(ResultMessage.SUCCESS, "删除成功");
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "删除失败," + e.getMessage());
logger.error("删除失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 锁定当前查询
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("clock")
public void clock(HttpServletRequest request,HttpServletResponse response) throws Exception {
ResultMessage message = null;
QueryFilter queryFilter = getQuerFilter(request);
String view_name=RequestUtil.getString(request, "view_name");
try {
if (StringUtil.isEmpty(view_name)) {
message=new ResultMessage(ResultMessage.FAIL, "锁定失败,查询不存在" );
logger.error("锁定失败,查询不存在");
writeResultMessage(response.getWriter(), message);
return ;
}
try {
// setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", "TD_PAMS_"+view_name);
params.put("view_name", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
viewShowService.clock(queryFilter);
message=new ResultMessage(ResultMessage.SUCCESS, "已锁定当前查询结果" );
logger.error("已锁定当前查询结果");
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "锁定失败," + e.getMessage());
logger.error("锁定失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 锁定当前查询
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("unclock")
public void unclock(HttpServletRequest request,HttpServletResponse response) throws Exception {
ResultMessage message = null;
QueryFilter queryFilter = getQuerFilter(request);
String view_name=RequestUtil.getString(request, "view_name");
try {
if (StringUtil.isEmpty(view_name)) {
message=new ResultMessage(ResultMessage.FAIL, "解锁失败,查询不存在" );
logger.error("解锁失败,查询不存在");
writeResultMessage(response.getWriter(), message);
return ;
}
try {
// setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", "TD_PAMS_"+view_name);
params.put("view_name", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
viewShowService.upclock(queryFilter);
message=new ResultMessage(ResultMessage.SUCCESS, "已从锁定数据中剔除当前查询结果" );
logger.error("已从锁定数据中剔除当前查询结果");
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "解锁失败," + e.getMessage());
logger.error("解锁失败," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 导出
* @param request
* @param reponse
* @throws Exception
*/
@SuppressWarnings({"rawtypes", "resource"})
@RequestMapping("export")
public void export(HttpServletRequest request,HttpServletResponse reponse) throws Exception {
QueryFilter queryFilter = getQuerFilter(request);
DefaultPage pagess = (DefaultPage) queryFilter.getPage();
pagess.setLimit(2147483646);
String view_name=RequestUtil.getString(request, "view_name");
String export_=RequestUtil.getString(request, "export_");
String data=RequestUtil.getString(request, "data");
if(StringUtil.isEmpty(view_name)) return;
List<ViewShowPo> polist = viewShowQueryService.getByViewName(view_name);
StringBuffer fileTitle= new StringBuffer();
fileTitle.append(StringUtil.isEmpty(polist.get(0).getViewName())?StringUtil.isEmpty(polist.get(0).getTableName())?view_name:polist.get(0).getTableName():polist.get(0).getViewName());
Workbook wb = new XSSFWorkbook();
//获取表头数组
List<Map<String, String>> colist = viewShowQueryService.getColByViewName(view_name);
//获取查询数据
String listData = null;
List<Map> list = new ArrayList<>();
try{
if(StringUtil.isNotEmpty(view_name)) {
setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
listData = viewShowQueryService.query(queryFilter);
}
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
if(JacksonUtil.isJsonObject(listData)){
list = JacksonUtil.getDTOList(JacksonUtil.getString(listData, "data"), Map.class);
} //数据填装
try {
File modelFile = new File(export_);
wb = WorkbookFactory.create(modelFile);
setWorkbookData(wb,list,Integer.parseInt(data));
} catch (Exception e) {
logger.error(e.getMessage(),e);
wb = new XSSFWorkbook();
setWorkbookData(wb,list,colist);
}
//浏览器下载方式导出excl
fileTitle.append(".xlsx");
reponse.setHeader("Content-Disposition", "attachment;filename=" + new String(fileTitle.toString().getBytes(), "iso-8859-1"));
reponse.setContentType("application/vnd.ms-excel;charset=UTF-8");
reponse.setHeader("Pragma", "no-cache");
reponse.setHeader("Cache-Control", "no-cache");
reponse.setDateHeader("Expires", 0);
reponse.getOutputStream().flush();
wb.write(reponse.getOutputStream());
reponse.getOutputStream().close();
} @SuppressWarnings({"rawtypes"})
private void setWorkbookData(Workbook wb, List<Map> list, int rownum) {
if(list==null) list=new ArrayList<>();
int pages = wb.getNumberOfSheets();
for(int i=0;i<pages;i++) {
List<Float> hList = new ArrayList<>();
Sheet sheet = wb.getSheetAt(i);
Row row = sheet.getRow(rownum-1);
if(BeanUtils.isEmpty(row)) continue;
int row_size = row.getRowNum();
int row_num = sheet.getPhysicalNumberOfRows();
List<Row> rowList = new ArrayList<>();
for(int I=row_size+1;I<=row_num;I++) {
final Row r = sheet.getRow(I);
if(BeanUtils.isEmpty(r)) continue;
final float h = r.getHeightInPoints();
hList.add(h);
rowList.add(r);
}
List<String> colist= new ArrayList<>();
for(int l=0;l<row.getPhysicalNumberOfCells();l++) {
colist.add(row.getCell(l).getStringCellValue());
}
int nn = row_num-1;
int mm = 0;
for(int I=i*50000,l=nn+1;I<((i+1)*50000>list.size()?list.size():(i+1)*50000);I++,l++ ) {
//数据
row = sheet.createRow(l);
for(int b =0;b<colist.size();b++) {
Cell cell = row.createCell(b);
CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);
cell.setCellStyle(style);
if(BeanUtils.isEmpty(list.get(I))||StringUtil.isEmpty(colist.get(b)) || list.get(I).get(colist.get(b))==null) continue;
Object value = list.get(I).get(colist.get(b));
try {
cell.setCellValue(Integer.parseInt(value+""));
}
catch (Exception e) {
try {
cell.setCellValue(Double.parseDouble(value+""));
if(value.toString().length()>=15) {
cell.setCellValue(value+"");
}
} catch (Exception e2) {
cell.setCellValue(value+"");
}
}
}
mm = l;
}
for(Row r: rowList) {
if(BeanUtils.isEmpty(r)) continue;
mm++;
row = sheet.createRow(mm);
for (Iterator cellIt = r.cellIterator(); cellIt.hasNext();) {
Cell tmpCell = (Cell) cellIt.next();
XSSFCell newCell =(XSSFCell) row.createCell(tmpCell.getColumnIndex());
newCell.copyCellFrom(tmpCell,new CellCopyPolicy());
}
}
sheet.shiftRows(row_num, sheet.getLastRowNum(), row_size-row_num);
int l = hList.size();
for(float h: hList) {
if(BeanUtils.isEmpty(h)) continue;
sheet.getRow(sheet.getLastRowNum()-l+1).setHeightInPoints(h);
l--;
} }
}
/**
* 数据填装 【普通】
* @param wb
* @param list
* @param colist
*/
@SuppressWarnings({"rawtypes", "deprecation" })
private void setWorkbookData (Workbook wb,List<Map> list,List<Map<String, String>> colist) {
if(list==null) list=new ArrayList<>();
int pages = list.size()/50000+list.size()%50000>0?1:0;
pages=pages<1?pages+1:pages;
CellStyle c_cellStyle = wb.createCellStyle();
c_cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
c_cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
c_cellStyle.setBorderRight(CellStyle.BORDER_THIN);
c_cellStyle.setBorderTop(CellStyle.BORDER_THIN);
c_cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
c_cellStyle.setAlignment(HorizontalAlignment.CENTER);
c_cellStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
CellStyle l_cellStyle = wb.createCellStyle();
l_cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
l_cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
l_cellStyle.setBorderRight(CellStyle.BORDER_THIN);
l_cellStyle.setBorderTop(CellStyle.BORDER_THIN);
l_cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
l_cellStyle.setAlignment(HorizontalAlignment.LEFT);
l_cellStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
CellStyle r_cellStyle = wb.createCellStyle();
r_cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
r_cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
r_cellStyle.setBorderRight(CellStyle.BORDER_THIN);
r_cellStyle.setBorderTop(CellStyle.BORDER_THIN);
r_cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
r_cellStyle.setAlignment(HorizontalAlignment.RIGHT);
r_cellStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
CellStyle headStyle = wb.createCellStyle();
headStyle.setBorderBottom(CellStyle.BORDER_THIN);
headStyle.setBorderLeft(CellStyle.BORDER_THIN);
headStyle.setBorderRight(CellStyle.BORDER_THIN);
headStyle.setBorderTop(CellStyle.BORDER_THIN);
headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置单元格垂直居中
headStyle.setDataFormat(wb.createDataFormat().getFormat("######################################"));//设置单元格格式
headStyle.setAlignment(HorizontalAlignment.CENTER);
headStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
headStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
for(int i=0;i<pages;i++) {
Sheet sheet = wb.createSheet();
int nn = 0;
//表头
Row row = sheet.createRow(nn);
for(int b =0;b<colist.size();b++) {
if(BeanUtils.isEmpty(colist.get(b))) continue;
Cell cell = row.createCell(b);
cell.setCellStyle(headStyle);
cell.setCellValue(colist.get(b).get("colName"));
sheet.setColumnWidth(b, 5000);
}
sheet.createFreezePane( 0, nn+1, 0, nn+1 );
for(int I=i*50000,l=nn+1;I<((i+1)*50000>list.size()?list.size():(i+1)*50000);I++,l++ ) {
//数据
row = sheet.createRow(l);
for(int b =0;b<colist.size();b++) {
if(BeanUtils.isEmpty(list.get(I))||BeanUtils.isEmpty(colist.get(b)) || list.get(I).get(colist.get(b).get("name"))==null) continue;
Cell cell = row.createCell(b);
switch (colist.get(b).get("align")) {
case "right":
cell.setCellStyle(r_cellStyle);
break;
case "left":
cell.setCellStyle(l_cellStyle);
break;
default:
cell.setCellStyle(c_cellStyle);
break;
}
Object value = list.get(I).get(colist.get(b).get("name"));
try {
cell.setCellValue(Integer.parseInt(value+""));
}
catch (Exception e) {
try {
cell.setCellValue(Double.parseDouble(value+""));
if(value.toString().length()>=15) {
cell.setCellValue(value+"");
}
} catch (Exception e2) {
cell.setCellValue(value+"");
}
}
}
}
}
} /**
* TODO echarts动态统计图
* @param request
* @param response
* @return
* @throws Exception
* @param view_name 视图名称
*/
@RequestMapping("echarts")
public ModelAndView echarts(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
List<ViewShowPo> list = new ArrayList<>();
Boolean isadmin=false;
String view_name=RequestUtil.getString(request, "view_name");
if(StringUtil.isNotEmpty(view_name)) {
//TD_PAMS_SHOWVIEW自动创建
viewShowService.completion();
list = viewShowQueryService.getByViewName(view_name);
isadmin= !"N".equals(PartyUtil.getUser().getIsSuper()); }
return getAutoView().addObject("returnUrl", preUrl)
.addObject("view_name", view_name)
.addObject("isadmin", isadmin)
.addObject("list", list)
.addObject("viewShow", list.get(0))
;
} @RequestMapping("echartsJosn")
public @ResponseBody JSONArray echartsJosn(HttpServletRequest request,HttpServletResponse reponse) throws Exception{
JSONArray options = new JSONArray();
QueryFilter queryFilter = getQuerFilter(request);
DefaultPage pagess = (DefaultPage) queryFilter.getPage();
pagess.setLimit(2147483646);
String view_name=RequestUtil.getString(request, "view_name");
try{
try{
if(StringUtil.isNotEmpty(view_name)) {
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
if("YES".equals(request.getParameter("isQuery")))
options = viewShowQueryService.getOption(view_name,queryFilter);
}
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return options;
} /**
* QueryFilter 参数校正
* @param request
* @param queryFilter
*/
private void resetQueryFilter(HttpServletRequest request,QueryFilter queryFilter) {
Map<String, Object> map = new HashMap<>();
for(String str :request.getParameterMap().keySet()) {
int begin=str.indexOf("^")<0?0:str.indexOf("^")+1;
map.put(str.substring(begin), request.getParameterMap().get(str)[0]);
}
List<WhereClause> whereList = queryFilter.getFieldLogic().getWhereClauses();
for(WhereClause w: whereList) {
DefaultQueryField field = (DefaultQueryField) w;
String value = (String) map.get(field.getField()+"^"+field.getColtype());
field.setValue(value);
}
} /**
*TODO 自定义报表
* @param request
* @param response
* @throws Exception
* @param view_name 视图名
*/
@RequestMapping("forms")
public ModelAndView forms(HttpServletRequest request,HttpServletResponse response) throws Exception{
String preUrl= RequestUtil.getPrePage(request);
List<ViewShowPo> list = new ArrayList<>();
Boolean isadmin=false;
Map<String, Object> colist = new HashMap<>();
String view_name=RequestUtil.getString(request, "view_name");
if(StringUtil.isNotEmpty(view_name)) {
//TD_PAMS_SHOWVIEW自动创建
viewShowService.completion();
list = viewShowQueryService.getByViewName(view_name);
isadmin=!"N".equals(PartyUtil.getUser().getIsSuper());
colist = viewShowQueryService.getColByViewName(view_name,list.get(0).getExclId());
}
return getAutoView().addObject("returnUrl", preUrl)
.addObject("view_name", view_name)
.addObject("isadmin", isadmin)
.addObject("colist", JSONArray.fromObject(colist.get("data")))
.addObject("head", JSONArray.fromObject(colist.get("head")))
.addObject("mySum", JSONArray.fromObject(colist.get("mySum")))
.addObject("list", list)
.addObject("viewShow", list.get(0))
;
} /**
* 导出
* @param request
* @param reponse
* @throws Exception
*/
@SuppressWarnings({"rawtypes", "resource"})
@RequestMapping("exportForms")
public void exportForms(HttpServletRequest request,HttpServletResponse reponse) throws Exception {
QueryFilter queryFilter = getQuerFilter(request);
DefaultPage pagess = (DefaultPage) queryFilter.getPage();
pagess.setLimit(2147483646);
String view_name=RequestUtil.getString(request, "view_name");
if(StringUtil.isEmpty(view_name)) return;
List<ViewShowPo> polist = viewShowQueryService.getByViewName(view_name);
StringBuffer fileTitle= new StringBuffer();
fileTitle.append(StringUtil.isEmpty(polist.get(0).getViewName())?StringUtil.isEmpty(polist.get(0).getTableName())?view_name:polist.get(0).getTableName():polist.get(0).getViewName());
JSONArray jsonlist = JSONArray.fromObject(polist.get(0).getExclId());
JSONObject json = jsonlist.getJSONObject(0);
Map<String, String> jsonmap = (Map<String, String>) JSONObject.toBean(json, Map.class);
String export_ = AppFileUtil.basePath+"/"+jsonmap.get("filePath");
String data = polist.get(0).getDataNum();
Workbook wb = new XSSFWorkbook();
//获取表头数组
Map<String, Object> colMap = viewShowQueryService.getColByViewName(view_name,polist.get(0).getExclId());
List<Map<String, String>> colist = (List<Map<String, String>>) colMap.get("data");
//获取查询数据
String listData = null;
List<Map> list = new ArrayList<>();
try{
if(StringUtil.isNotEmpty(view_name)) {
setDataSource();
Map<String, Object> params = new HashMap<>();
params.put("table", view_name);
resetQueryFilter(request,queryFilter);
queryFilter.addParamsFilter(params);
listData = viewShowQueryService.query(queryFilter);
}
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
if(JacksonUtil.isJsonObject(listData)){
list = JacksonUtil.getDTOList(JacksonUtil.getString(listData, "data"), Map.class);
}
//数据填装
try {
File modelFile = new File(export_);
wb = WorkbookFactory.create(modelFile);
setWorkbookData(wb,list,colist,Integer.parseInt(data));
} catch (Exception e) {
logger.error(e.getMessage(),e);
wb = new XSSFWorkbook();
setWorkbookData(wb,list,colist);
}
//浏览器下载方式导出excl
fileTitle.append(export_.substring(export_.indexOf(".")));
reponse.setHeader("Content-Disposition", "attachment;filename=" + new String(fileTitle.toString().getBytes(), "iso-8859-1"));
reponse.setContentType("application/vnd.ms-excel;charset=UTF-8");
reponse.setHeader("Pragma", "no-cache");
reponse.setHeader("Cache-Control", "no-cache");
reponse.setDateHeader("Expires", 0);
reponse.getOutputStream().flush();
wb.write(reponse.getOutputStream());
reponse.getOutputStream().close();
} @SuppressWarnings({"rawtypes"})
private void setWorkbookData(Workbook wb, List<Map> list,List<Map<String, String>> colList,int rownum) {
rownum = rownum-1;
if(list==null) list=new ArrayList<>();
int pages = wb.getNumberOfSheets();
for(int i=0;i<pages;i++) {
Sheet sheet = wb.getSheetAt(i);
Row row = null;
int endNum = sheet.getLastRowNum(); List<String> colist= new ArrayList<>();
try {
for(Map<String, String> map:colList) {
if(BeanUtils.isEmpty(map)) continue;
if("true".equals(map.get("hidden"))) continue;
colist.add(((Object)(map.get("name"))).toString());
}
} catch (Exception e) {
e.printStackTrace();
} int row_num = sheet.getPhysicalNumberOfRows();
int nn = row_num-1;
int mm = 0;
for(int I=i*50000,l=nn+1;I<((i+1)*50000>list.size()?list.size():(i+1)*50000);I++,l++ ) {
//数据
row = sheet.createRow(l);
for(int b =0;b<colist.size();b++) {
Cell cell = row.createCell(b);
CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);
cell.setCellStyle(style);
if(BeanUtils.isEmpty(list.get(I))||StringUtil.isEmpty(colist.get(b)) || list.get(I).get(colist.get(b))==null) continue;
Object value = list.get(I).get(colist.get(b));
try {
cell.setCellValue(Integer.parseInt(value+""));
}
catch (Exception e) {
try {
cell.setCellValue(Double.parseDouble(value+""));
if(value.toString().length()>=15) {
cell.setCellValue(value+"");
}
} catch (Exception e2) {
cell.setCellValue(value+"");
}
}
}
mm = l;
}
//以数据行为分割点,,,实现导出模板填充
int size = sheet.getLastRowNum();
if(size-endNum>0) {
//下移表尾,追加一行数据行
sheet.shiftRows(rownum, endNum,size-rownum+1 );
//上移数据,追加一行数据行
int nowSize = sheet.getLastRowNum();
sheet.shiftRows(endNum+1, nowSize,rownum-endNum-1);
}
}
}
/**
* 修改单元格
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("editCell")
public void editCell(HttpServletRequest request,HttpServletResponse response) throws Exception {
ResultMessage message = null;
QueryFilter queryFilter = getQuerFilter(request);
String view_name=RequestUtil.getString(request, "view_name");
Map<String, Object> params = RequestUtil.getParameterValueMap(request, false, false);
try {
if (StringUtil.isEmpty(view_name)) {
message=new ResultMessage(ResultMessage.FAIL, "修改失败,查询不存在" );
logger.error("修改失败,查询不存在");
writeResultMessage(response.getWriter(), message);
return ;
}
try {
// setDataSource();
params.put("table", "TD_PAMS_"+view_name);
viewShowService.updateCell(params);
message=new ResultMessage(ResultMessage.SUCCESS, "修改成功" );
logger.error("修改成功");
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "修改失败," + e.getMessage());
logger.error("修改成功," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} /**
* 修改单元格
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("upload")
public void upload(HttpServletRequest request,HttpServletResponse response) throws Exception {
ResultMessage message = null;
String view_name=RequestUtil.getString(request, "view_name");
Map<String, Object> params = RequestUtil.getParameterValueMap(request, false, false);
try {
if (StringUtil.isEmpty(view_name)) {
message=new ResultMessage(ResultMessage.FAIL, "导入失败,数据源异常" );
logger.error("导入失败,数据源异常");
writeResultMessage(response.getWriter(), message);
return ;
}
try {
// setDataSource();
params.put("table", "TD_PAMS_"+view_name);
viewShowService.upload(params);
message=new ResultMessage(ResultMessage.SUCCESS, "导入成功" );
logger.error("导入成功");
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
message=new ResultMessage(ResultMessage.FAIL, "导入失败," + e.getMessage());
logger.error("导入成功," + e.getMessage(),e);
}
writeResultMessage(response.getWriter(), message);
} private void setDataSource () throws SQLException{
String defaultDsAlias = com.lc.ibps.base.datasource.dynamic.DataSourceUtil.getDefaultDsAlias();
if(!defaultDsAlias.equalsIgnoreCase("dataSource_default"))
{
javax.sql.DataSource dataSource = com.lc.ibps.base.datasource.dynamic.DataSourceUtil.getDataSourceByAlias("dataSource_default");
String dbType = com.lc.ibps.base.datasource.dynamic.DataSourceUtil.getDefaultDbType();
try {
dbType = com.lc.ibps.base.datasource.util.DbUtil.getDbTypeByDataSource(dataSource);
} catch (java.sql.SQLException e) {
throw new com.lc.ibps.base.core.exception.BaseException("数据源异常");
}
com.lc.ibps.base.datasource.dynamic.DbContextHolder.setDataSource("dataSource_default", dbType);
}
} /**
* TODO 检查问题列表
*
* @param request
* @param reponse
* @return
* @throws Exception
*/
@SuppressWarnings("finally")
@RequestMapping("msgDataList")
public @ResponseBody List<ViewShowPo> msgDataList(HttpServletRequest request,HttpServletResponse reponse) throws Exception{
Map<String, Object> map = RequestUtil.getParameterValueMap(request, false, false);
List<ViewShowPo> list= new ArrayList<ViewShowPo>();
try{
try{
setDataSource();
list = viewShowQueryService.findByKey(map.get("findkey"),map);
} finally {
com.lc.ibps.base.datasource.dynamic.DbContextHolder.clearDataSource();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
return list;
}
} }

ViewShowController.java

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lc.ibps.performance.persistence.entity.ViewShowPo">
<resultMap id="ViewShowPo" type="com.lc.ibps.performance.persistence.entity.ViewShowPo">
<id property="id" column="ID_" jdbcType="VARCHAR"/>
<result property="viewCode" column="VIEW_CODE_" jdbcType="VARCHAR"/>
<result property="viewName" column="VIEW_NAME_" jdbcType="VARCHAR"/>
<result property="tableCode" column="TABLE_CODE_" jdbcType="VARCHAR"/>
<result property="tableName" column="TABLE_NAME_" jdbcType="VARCHAR"/>
<result property="colCode" column="COL_CODE_" jdbcType="VARCHAR"/>
<result property="colName" column="COL_NAME_" jdbcType="VARCHAR"/>
<result property="colRank" column="COL_RANK_" jdbcType="NUMERIC"/>
<result property="isShow" column="IS_SHOW_" jdbcType="VARCHAR"/>
<result property="queryType" column="QUERY_TYPE_" jdbcType="VARCHAR"/>
<result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/>
<result property="createDate" column="CREATE_DATE_" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
<result property="updateDate" column="UPDATE_DATE_" jdbcType="TIMESTAMP"/>
<result property="remarks" column="REMARKS_" jdbcType="VARCHAR"/>
<result property="isEdit" column="IS_EDIT" jdbcType="VARCHAR"/>
<result property="isSum" column="IS_SUM" jdbcType="VARCHAR"/>
<result property="colWidth" column="COL_WIDTH" jdbcType="VARCHAR"/>
<result property="exclId" column="EXCL_ID" jdbcType="VARCHAR"/>
<result property="dataNum" column="DATA_NUM" jdbcType="VARCHAR"/>
<result property="headStart" column="HEAD_START" jdbcType="VARCHAR"/>
<result property="headEnd" column="HEAD_END" jdbcType="VARCHAR"/>
<result property="delFlag" column="DEL_FLAG_" jdbcType="VARCHAR"/> <result property="vSearch" column="V_SEARCH_" jdbcType="VARCHAR"/>
<result property="vUpload" column="V_UPLOAD_" jdbcType="VARCHAR"/>
<result property="vExport" column="V_EXPORT_" jdbcType="VARCHAR"/>
<result property="vLock" column="V_LOCK_" jdbcType="VARCHAR"/>
<result property="vUnlock" column="V_UNLOCK_" jdbcType="VARCHAR"/>
</resultMap> <sql id="columns">
ID_,VIEW_CODE_,VIEW_NAME_,TABLE_CODE_,TABLE_NAME_,COL_CODE_,
COL_NAME_,COL_RANK_,IS_SHOW_,QUERY_TYPE_,CREATE_BY_,CREATE_DATE_,
UPDATE_BY_,UPDATE_DATE_,REMARKS_,IS_EDIT,IS_SUM,EXCL_ID,
DATA_NUM,HEAD_START,HEAD_END,DEL_FLAG_,COL_WIDTH,V_SEARCH_,V_UPLOAD_,V_EXPORT_,V_LOCK_,V_UNLOCK_
</sql> <insert id="create" parameterType="com.lc.ibps.performance.persistence.entity.ViewShowPo">
INSERT INTO TD_PAMS_VIEWSHOW
(<include refid="columns"/>)
VALUES
(#{id,jdbcType=VARCHAR}, #{viewCode,jdbcType=VARCHAR}, #{viewName,jdbcType=VARCHAR}, #{tableCode,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, #{colCode,jdbcType=VARCHAR}, #{colName,jdbcType=VARCHAR}, #{colRank,jdbcType=NUMERIC}, #{isShow,jdbcType=VARCHAR}, #{queryType,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP},
#{remarks,jdbcType=VARCHAR},
#{isEdit,jdbcType=VARCHAR},
#{isSum,jdbcType=VARCHAR},
#{exclId,jdbcType=VARCHAR},
#{dataNum,jdbcType=VARCHAR},
#{headStart,jdbcType=VARCHAR},
#{headEnd,jdbcType=VARCHAR},
#{delFlag,jdbcType=VARCHAR},
#{colWidth,jdbcType=VARCHAR},
#{vSearch,jdbcType=VARCHAR},
#{vUpload,jdbcType=VARCHAR},
#{vExport,jdbcType=VARCHAR},
#{vLock,jdbcType=VARCHAR},
#{vUnlock,jdbcType=VARCHAR}
)
</insert> <select id="get" parameterType="java.lang.String" resultMap="ViewShowPo">
SELECT <include refid="columns"/> FROM TD_PAMS_VIEWSHOW
WHERE
ID_=#{id}
</select> <select id="query" parameterType="java.util.Map" resultType="java.util.Map">
SELECT * FROM ${table}
<where>
<if test="@Ognl@isNotEmpty(whereSql)">
${whereSql}
</if>
</where>
<if test="@Ognl@isNotEmpty(orderBySql)">
ORDER BY ${orderBySql}
</if>
</select> <select id="findByIds" resultMap="ViewShowPo">
SELECT <include refid="columns"/> FROM TD_PAMS_VIEWSHOW
WHERE ID_ in
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
ORDER BY ID_ DESC
</select>
<select id="findAllTableOrView" resultMap="ViewShowPo">
select TABLE_NAME id_,TABLE_NAME name_ from user_tables
union all
select VIEW_NAME,VIEW_NAME from user_views
</select> <update id="update" parameterType="com.lc.ibps.performance.persistence.entity.ViewShowPo">
UPDATE TD_PAMS_VIEWSHOW SET
VIEW_CODE_=#{viewCode,jdbcType=VARCHAR},
VIEW_NAME_=#{viewName,jdbcType=VARCHAR},
TABLE_CODE_=#{tableCode,jdbcType=VARCHAR},
TABLE_NAME_=#{tableName,jdbcType=VARCHAR},
COL_CODE_=#{colCode,jdbcType=VARCHAR},
COL_NAME_=#{colName,jdbcType=VARCHAR},
COL_RANK_=#{colRank,jdbcType=NUMERIC},
IS_SHOW_=#{isShow,jdbcType=VARCHAR},
QUERY_TYPE_=#{queryType,jdbcType=VARCHAR},
CREATE_DATE_=#{createDate,jdbcType=TIMESTAMP},
UPDATE_BY_=#{updateBy,jdbcType=VARCHAR},
UPDATE_DATE_=#{updateDate,jdbcType=TIMESTAMP},
REMARKS_=#{remarks,jdbcType=VARCHAR},
IS_EDIT=#{isEdit,jdbcType=VARCHAR},
IS_SUM=#{isSum,jdbcType=VARCHAR},
EXCL_ID=#{exclId,jdbcType=VARCHAR},
DATA_NUM=#{dataNum,jdbcType=VARCHAR},
HEAD_START=#{headStart,jdbcType=VARCHAR},
HEAD_END=#{headEnd,jdbcType=VARCHAR},
COL_WIDTH=#{colWidth,jdbcType=VARCHAR},
DEL_FLAG_=#{delFlag,jdbcType=VARCHAR},
V_SEARCH_=#{vSearch,jdbcType=VARCHAR},
V_UPLOAD_=#{vUpload,jdbcType=VARCHAR},
V_EXPORT_=#{vExport,jdbcType=VARCHAR},
V_LOCK_=#{vLock,jdbcType=VARCHAR},
V_UNLOCK_=#{vUnlock,jdbcType=VARCHAR}
WHERE
ID_=#{id}
</update> <delete id="remove" parameterType="java.lang.String">
DELETE FROM TD_PAMS_VIEWSHOW
WHERE
ID_=#{id}
</delete>
<select id="getByViewName" parameterType="java.util.Map" resultMap="ViewShowPo">
SELECT CC.TABLE_NAME VIEW_CODE_,
MAX(NVL(VS.VIEW_NAME_,TC.COMMENTS)) VIEW_NAME_,
MAX(VS.TABLE_CODE_) TABLE_CODE_,
MAX(VS.TABLE_NAME_) TABLE_NAME_,
CC.COLUMN_NAME COL_CODE_,
MAX(NVL(VS.COL_NAME_,CC.COMMENTS)) COL_NAME_,
MAX(VS.COL_RANK_) COL_RANK_,
MAX(VS.IS_SHOW_) IS_SHOW_,
MAX(VS.COL_WIDTH) COL_WIDTH,
MAX(NVL(VS.ID_,ROWNUM)) ID_,
MAX(VS.QUERY_TYPE_) QUERY_TYPE_,
MAX(VS.EXCL_ID) EXCL_ID,
MAX(VS.DATA_NUM) DATA_NUM,
MAX(VS.IS_EDIT) IS_EDIT,
MAX(VS.IS_SUM) IS_SUM,
MAX(VS.HEAD_START) HEAD_START,
MAX(VS.HEAD_END) HEAD_END,
MAX(VS.V_SEARCH_) V_SEARCH_,
MAX(VS.V_UPLOAD_) V_UPLOAD_,
MAX(VS.V_EXPORT_) V_EXPORT_,
MAX(VS.V_LOCK_) V_LOCK_,
MAX(VS.V_UNLOCK_) V_UNLOCK_
FROM USER_COL_COMMENTS CC
LEFT JOIN TD_PAMS_VIEWSHOW VS
ON VS.VIEW_CODE_ = CC.TABLE_NAME
AND VS.COL_CODE_ = CC.COLUMN_NAME
LEFT JOIN USER_TAB_COMMENTS TC
ON TC.TABLE_NAME=CC.TABLE_NAME
WHERE CC.TABLE_NAME=UPPER(#{view_name})
GROUP BY CC.TABLE_NAME,CC.COLUMN_NAME
ORDER BY COL_RANK_
</select> <delete id="deleteByViewName" parameterType="java.util.Map">
DELETE FROM TD_PAMS_VIEWSHOW
WHERE
VIEW_CODE_=UPPER(#{viewCode})
</delete> <update id="createTable" parameterType="java.util.Map">
CREATE TABLE ${table} AS SELECT sys_guid()||'' ID_,t.* FROM ${view_name} t WHERE 1=2
</update> <delete id="deleteTable" parameterType="java.util.Map">
DELETE FROM ${table}
<where>
<if test="@Ognl@isNotEmpty(whereSql)">
${whereSql}
</if>
</where>
</delete> <insert id="insertTable" parameterType="java.util.Map">
INSERT INTO ${table} SELECT sys_guid()||'',t.* FROM ${view_name} t
<where>
<if test="@Ognl@isNotEmpty(whereSql)">
${whereSql}
</if>
</where>
</insert> <update id="updateCell" parameterType="java.util.Map">
update ${table} set ${name}=#{value} where id_=#{id}
</update> <update id="updateCellNothing" parameterType="java.util.Map">
update ${table} set ${name}=#{value} where id_=#{id}
</update> <update id="completion">
CREATE TABLE "TD_PAMS_VIEWSHOW"
( "ID_" VARCHAR2(64) NOT NULL ENABLE,
"VIEW_CODE_" VARCHAR2(64),
"VIEW_NAME_" VARCHAR2(64),
"TABLE_CODE_" VARCHAR2(64),
"TABLE_NAME_" VARCHAR2(64),
"COL_CODE_" VARCHAR2(64),
"COL_NAME_" VARCHAR2(64),
"COL_RANK_" NUMBER(*,0),
"IS_SHOW_" VARCHAR2(32),
"QUERY_TYPE_" VARCHAR2(32),
"CREATE_BY_" VARCHAR2(64),
"CREATE_DATE_" DATE,
"UPDATE_BY_" VARCHAR2(64),
"UPDATE_DATE_" DATE,
"REMARKS_" VARCHAR2(2000),
"DEL_FLAG_" VARCHAR2(1),
"IS_EDIT" VARCHAR2(1),
"IS_SUM" VARCHAR2(1),
"EXCL_ID" VARCHAR2(2000),
"DATA_NUM" VARCHAR2(64),
"HEAD_START" VARCHAR2(64),
"HEAD_END" VARCHAR2(64),
"COL_WIDTH" VARCHAR2(64),
"V_SEARCH_" VARCHAR2(2000),
"V_UPLOAD_" VARCHAR2(2000),
"V_EXPORT_" VARCHAR2(2000),
"V_LOCK_" VARCHAR2(2000),
"V_UNLOCK_" VARCHAR2(2000),
CONSTRAINT "PK_TD_PAMS_VIEWSHOW" PRIMARY KEY ("ID_")
)
</update> </mapper>

ViewShow.map.xml

package com.lc.ibps.performance.persistence.entity;

import java.util.Date;

import com.lc.ibps.base.framework.persistence.entity.AbstractPo;

/**
* TD_PAMS_VIEWSHOW 表对象
*
*<pre>
* 开发公司:湖南泉汇三众科技有限公司
* 开发人员:sunson
* 邮箱地址:1807788283@qq.com
* 创建时间:2019-04-04 10:33:27
*</pre>
*/
@SuppressWarnings("serial")
public class ViewShowTbl extends AbstractPo<String>{
protected String id; /*主键ID*/
protected String viewCode; /*视图名*/
protected String viewName; /*视图备注*/
protected String tableCode; /*对应表名*/
protected String tableName; /*对应表备注*/
protected String colCode; /*字段名*/
protected String colName; /*字段备注*/
protected Long colRank; /*字段排序*/
protected String isShow; /*是否显示*/
protected String queryType; /*查询方式*/
@com.fasterxml.jackson.annotation.JsonFormat(pattern = "yyyy-MM-dd")
protected Date createDate; /*创建日期*/
@com.fasterxml.jackson.annotation.JsonFormat(pattern = "yyyy-MM-dd")
protected Date updateDate; /*修改日期*/
protected String remarks; /*备注*/
protected String isEdit; /*是否编辑(0否1是)*/
protected String isSum; /*是否统计(0否1是)*/
protected String exclId; /*模板ID*/
protected String dataNum; /*数据起始行*/
protected String colWidth; /*数据起始行*/
protected String headStart; /*表头起始行*/
protected String headEnd; /*表头结束行*/
protected String delFlag; /*删除标识(0否1是)*/ protected String vSearch; /*查询功能别名*/
protected String vUpload; /*导入功能别名*/
protected String vExport; /*导出功能别名*/
protected String vLock; /*锁定功能别名*/
protected String vUnlock; /*解锁功能别名*/ public void setId(String id)
{
this.id = id;
}
/**
* 返回 主键ID
* @return
*/
public String getId()
{
return this.id;
}
public void setViewCode(String viewCode)
{
this.viewCode = viewCode;
}
/**
* 返回 视图名
* @return
*/
public String getViewCode()
{
return this.viewCode;
}
public void setViewName(String viewName)
{
this.viewName = viewName;
}
/**
* 返回 视图备注
* @return
*/
public String getViewName()
{
return this.viewName;
}
public void setTableCode(String tableCode)
{
this.tableCode = tableCode;
}
/**
* 返回 对应表名
* @return
*/
public String getTableCode()
{
return this.tableCode;
}
public void setTableName(String tableName)
{
this.tableName = tableName;
}
/**
* 返回 对应表备注
* @return
*/
public String getTableName()
{
return this.tableName;
}
public void setColCode(String colCode)
{
this.colCode = colCode;
}
/**
* 返回 字段名
* @return
*/
public String getColCode()
{
return this.colCode;
}
public void setColName(String colName)
{
this.colName = colName;
}
/**
* 返回 字段备注
* @return
*/
public String getColName()
{
return this.colName;
}
public void setColRank(Long colRank)
{
this.colRank = colRank;
}
/**
* 返回 字段排序
* @return
*/
public Long getColRank()
{
return this.colRank;
}
public void setIsShow(String isShow)
{
this.isShow = isShow;
}
/**
* 返回 是否显示
* @return
*/
public String getIsShow()
{
return this.isShow;
}
public void setQueryType(String queryType)
{
this.queryType = queryType;
}
/**
* 返回 查询方式
* @return
*/
public String getQueryType()
{
return this.queryType;
}
public void setCreateDate(Date createDate)
{
this.createDate = createDate;
}
/**
* 返回 创建日期
* @return
*/
public Date getCreateDate()
{
return this.createDate;
}
public void setUpdateDate(Date updateDate)
{
this.updateDate = updateDate;
}
/**
* 返回 修改日期
* @return
*/
public Date getUpdateDate()
{
return this.updateDate;
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
/**
* 返回 备注
* @return
*/
public String getRemarks()
{
return this.remarks;
}
/**
* 返回 是否编辑(0否1是)
* @return
*/
public String getIsEdit() {
return isEdit;
}
public void setIsEdit(String isEdit) {
this.isEdit = isEdit;
}
/**
* 返回 模板ID
* @return
*/
public String getExclId() {
return exclId;
}
public void setExclId(String exclId) {
this.exclId = exclId;
}
/**
* 返回 数据起始行号
* @return
*/
public String getDataNum() {
return dataNum;
}
public void setDataNum(String dataNum) {
this.dataNum = dataNum;
}
/**
* 返回 表头起始行号
* @return
*/
public String getHeadStart() {
return headStart;
}
public void setHeadStart(String headStart) {
this.headStart = headStart;
}
/**
* 返回 表头结束行号
* @return
*/
public String getHeadEnd() {
return headEnd;
}
public void setHeadEnd(String headEnd) {
this.headEnd = headEnd;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
/**
* 返回 删除标识(0否1是)
* @return
*/
public String getDelFlag()
{
return this.delFlag;
}
public String getIsSum() {
return isSum;
}
public void setIsSum(String isSum) {
this.isSum = isSum;
}
public String getColWidth() {
return colWidth;
}
public void setColWidth(String colWidth) {
this.colWidth = colWidth;
}
public String getvSearch() {
return vSearch;
}
public void setvSearch(String vSearch) {
this.vSearch = vSearch;
}
public String getvUpload() {
return vUpload;
}
public void setvUpload(String vUpload) {
this.vUpload = vUpload;
}
public String getvExport() {
return vExport;
}
public void setvExport(String vExport) {
this.vExport = vExport;
}
public String getvLock() {
return vLock;
}
public void setvLock(String vLock) {
this.vLock = vLock;
}
public String getvUnlock() {
return vUnlock;
}
public void setvUnlock(String vUnlock) {
this.vUnlock = vUnlock;
} }

ViewShowTbl.java

通过视图实现自定义查询<持续完善中。。。>的更多相关文章

  1. 2018年最新Java面试题及答案整理(持续完善中…)

    2018年最新Java面试题及答案整理(持续完善中…) 基础篇 基本功 面向对象特征 封装,继承,多态和抽象 封装封装给对象提供了隐藏内部特性和行为的能力.对象提供一些能被其他对象访问的方法来改变它内 ...

  2. linux 命令学习(持续完善中...)

    linux 命令学习(持续完善中...) 主要是记录一些开发过程中用到的linux命令,慢慢补充 一.用户 1.添加用户: useradd 用户名 2.设置密码:passwd 用户名 ,然后按照提示输 ...

  3. Spring 框架(持续完善中)

    目录标题 一.Spring 框架 Spring 是什么? Spring Framework 核心概念 了解Spring 框架的架构图 二.Spring Framework 之 IOC 开发的步骤流程 ...

  4. kubernetes 控制器详解【持续完善中】

    目录 资源创建详解 一:Pod及常用参数 1.简介 2.模板 3.删除pod 4.设置Pod主机名 5.镜像拉取策略(ImagePullPolicy) 二:RC 1.简介 2.模板 三:Deploym ...

  5. Scrapy爬虫导图(持续完善中)

    Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中.

  6. 采用WPF开发第二版OFD阅读器,持续完善中,敬请期待!

    本人研究OFD多年,采用C#和QT开发了一系列ofd相关软件.在这些产品中,阅读器始终占据着非常重要的位置.可以说,阅读器是直接面向最终客户的产品.是集OFD各类知识之大成的产品.市面上的阅读器产品林 ...

  7. 我的主站 SHARELIST -分享列表 (功能持续完善中 2019-11-24 版本0.3)

    网站地址: http://www.sharelist.link 网站地址二维码: 网站介绍和更新: http://106.13.105.156/sharelist.php?listid=5dbda96 ...

  8. Python之Django之views中视图代码重复查询的优化

    Django框架中views视图中如果多个函数都有同样的查询语句,例如: allcategory = Category.objects.all() remen = Article.objects.fi ...

  9. Mysql基础代码(不断完善中)

    Mysql基础代码,不断完善中~ /* 启动MySQL */ net start mysql /* 连接与断开服务器 */ mysql -h 地址 -P 端口 -u 用户名 -p 密码 /* 跳过权限 ...

随机推荐

  1. [leetcode] #239 Sliding Window Maximum (Hard)

    原题链接 题意: 给定一个数组数字,有一个大小为k的滑动窗口,它从数组的最左边移动到最右边.你只能在窗口看到k个数字.每次滑动窗口向右移动一个位置. 记录每一次窗口内的最大值,返回记录的值. 思路: ...

  2. 简单分析ThreadPoolExecutor回收工作线程的原理

    最近阅读了JDK线程池ThreadPoolExecutor的源码,对线程池执行任务的流程有了大体了解,实际上这个流程也十分通俗易懂,就不再赘述了,别人写的比我好多了. 不过,我倒是对线程池是如何回收工 ...

  3. JAVA项目从运维部署到项目开发(五. Nginx)

    <Nginx与Nginx-rtmp-module搭建RTMP视频直播和点播服务器>一文简单介绍了关于直播数据流的nginx相关配置,下面简单介绍下各种项目如何配置nginx. web项目. ...

  4. PHP正则匹配到2个字符串之间的内容,匹配HTML便签内容

    PHP正则匹配到2个字符串之间的内容 $preg= '/xue[\s\S]*?om/i'; preg_match_all($preg,"学并思网址xuebingsi.com",$r ...

  5. (读论文)推荐系统之ctr预估-NFM模型解析

    本系列的第六篇,一起读论文~ 本人才疏学浅,不足之处欢迎大家指出和交流. 今天要分享的是另一个Deep模型NFM(串行结构).NFM也是用FM+DNN来对问题建模的,相比于之前提到的Wide& ...

  6. .NET加水印/验证码的NuGet包

    .NET加水印/验证码的NuGet包 我的在前两篇文章(水印,验证码)中,我介绍了使用Direct2D给图片加水印/验证码,今天我将其进行了封装,发布了一个NuGet包Sdcb.Imaging: &l ...

  7. HashMap、Hash Table、ConcurrentHashMap

    这个这个...本王最近由于开始找实习工作了,所以就在牛客网上刷一些公司的面试题,大多都是一些java,前端HTML,js,jquery,以及一些好久没有碰的算法题,说实话,有点难受,其实在我不知道的很 ...

  8. 证明线程池ThreadPoolExecutor的核心线程数,最大线程数,队列长度的关系

    关于线程池的几个参数,很多人不是很清楚如何配置,他们之间是什么关系,我用代码来证明一下. package www.itbac.com; import java.util.concurrent.*; p ...

  9. scrapyd schedule.json setting 传入多个值

    使用案例: import requests adder='http://127.0.0.1:6800' data = { 'project':'v1', 'version':'12379', 'set ...

  10. C#开发可播放摄像头及任意格式视频的播放器

    前言 本文主要讲述,在WPF中,借助Vlc.DotNet调用VLC类库,实现视频播功能,下面我们先来做开发前的准备工作. 准备工作 首先,我们创建一个项目WpfVLC,然后,进入Neget搜索Vlc. ...