目前实现:
----普通查询路径 /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
1 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 2 <%@include file="/commons/include/html_doctype.html" %> 3 <html> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 6 <%@include file="/commons/page/codegen.jsp" %> 7 <script type="text/javascript" src="${ctx}/js/lc/platform/utils/SelectorDialog.js"></script> 8 <script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShow.js"></script> 9 <script type="text/javascript"> 10 11 12 13 var colNames=[],colModel=[],view_name="${view_name}",colist=${colist},export_="${export_}",data="${data}"; 14 for(var i in colist) { 15 if(colist[i]) { 16 // colist[i].width =(document.getElementById(‘gview_viewShowGrid‘).style.width)/12; 17 colNames.push(colist[i].colName); 18 colModel.push(colist[i]); 19 } 20 } 21 </script> 22 <style type="text/css"> 23 .form-horizontal .form-group { 24 margin-right: 0px; 25 margin-left: 0px; 26 } 27 .fr-form-control[disabled], .fr-form-control[readonly], fieldset[disabled] .fr-orm-control { 28 opacity: 1; 29 border: 0; 30 } 31 th.ui-th-column div{ 32 white-space:normal !important; 33 height:auto !important; 34 padding:0px; 35 } 36 ui-th-column ui-th-ltr { 37 38 } 39 </style> 40 <title>管理列表</title> 41 </head> 42 <body id="viewbody"> 43 <div class="wrapper wrapper-content animated fadeInRight col-sm-12"> 44 <form class="form-horizontal"> 45 <c:if test="${isadmin}"> 46 <div class="panel"> 47 <div class="tabs-container tabs-x"> 48 <ul class="nav nav-tabs"> 49 <li class="active"> 50 <a data-toggle="tab" href="#tab-1" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询</a> 51 </li> 52 <li > 53 <a data-toggle="tab" href="#tab-2" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询管理</a> 54 </li> 55 </ul> 56 </div> 57 </div> 58 </c:if> 59 <div class="tab-content"> 60 <div id="tab-1" class="tab-pane active"> 61 <div class="panel-body"> 62 <div class="toolbar-panel "> 63 <div class="toolbar-box"> 64 <div class="toolbar-head clearfix"> 65 <!-- 顶部按钮 --> 66 <div class="buttons"> 67 <a class="btn btn-primary fa fa-search" onclick="javascript:$(‘#isQuery‘).val(‘YES‘)" href="javascript:void(0);" ><span>搜索</span></a> 68 <a class="btn btn-primary fa fa-export" href="javascript:void(0);" ><span>导出</span></a> 69 <c:if test="${isadmin}"> 70 <a class="btn btn-primary fa fa-lock" href="javascript:void(0);" ><span>锁定</span></a> 71 <a class="btn btn-primary fa fa-unlock" href="javascript:void(0);" ><span>解锁</span></a> 72 </c:if> 73 <%-- <a class="btn btn-primary fa fa-add" href="${ctx}/platform/viewShow/viewShow/edit.htm" ><span>添加</span></a> 74 <a class="btn btn-primary fa fa-edit" href="javascript:void(0);" action="${ctx}/platform/viewShow/viewShow/edit.htm" ><span>编辑</span></a> 75 <a class="btn btn-primary fa fa-remove" href="javascript:void(0);" action="${ctx}/platform/viewShow/viewShow/remove.htm"><span>删除</span></a> --%> 76 </div> 77 <!-- 收缩 --> 78 <div class="tools"> 79 <a href="javascript:void(0);" class="collapse"> 80 <i class="bigger-180 fa fa-angle-double-up"></i> 81 </a> 82 </div> 83 </div> 84 <!-- #查询条件3--> 85 <div class="toolbar-body" > 86 <form></form> 87 <!-- role="form" --> 88 <form id="searchForm" class="search-form"> 89 <input type="hidden" name="isQuery" id="isQuery" value="No"> 90 <div class="form-inline p-xxs"> 91 <c:forEach items="${list}" var="item"> 92 <%@include file="viewShowSelecter.jsp" %> 93 </c:forEach> 94 </div> 95 </form> 96 </div><!--/ 查询条件--> 97 </div> 98 </div><!--/ 操作、查询--> 99 <div id="tableGrid" class="jqGrid_wrapper"> 100 <table id="viewShowGrid" ></table> 101 <div id="viewShowPager"></div> 102 </div> 103 </div> 104 </div> 105 <c:if test="${isadmin}"> 106 <div id="tab-2" class="tab-pane <c:if test="${false}">active</c:if>"> 107 <div class="panel-body"> 108 <div class="panel-toolbar "> 109 <div class="buttons"> 110 <a href="javascript:void(0);" class="btn btn-primary fa fa-save" ><span>保存</span></a> 111 <a href="list.htm?view_name=${view_name}" class="btn btn-primary fa fa-back" ><span>返回</span></a> 112 </div> 113 </div> 114 <div class=""> 115 <form class="fr-form" id="viewShowForm" action="save.htm" > 116 <div class="fr_response_field col-sm-6" > 117 <div class="fr-form-group"> 118 <label class="fr-control-label">视图名</label> 119 <div class="fr-form-block" data-type="fixed"> 120 <input type="text" class="fr-form-control" name="m:viewShow:viewCode" readonly="readonly" value="${viewShow.viewCode}" title="${viewShow.viewCode}" validate="{required:false}"/> 121 </div> 122 </div> 123 </div> 124 <div class="fr_response_field col-sm-6" > 125 <div class="fr-form-group"> 126 <label class="fr-control-label">视图备注</label> 127 <div class="fr-form-block" data-type="fixed"> 128 <input type="text" class="fr-form-control" name="m:viewShow:viewName" value="${viewShow.viewName}" title="${viewShow.viewName}" validate="{required:false}"/> 129 </div> 130 </div> 131 </div> 132 <div class="fr_response_field col-sm-6" > 133 <div class="fr-form-group"> 134 <label class="fr-control-label">对应表名</label> 135 <div class="fr-form-block" data-type="fixed"> 136 <input type="text" class="fr-form-control" name="m:viewShow:tableCode" readonly="readonly" value="${viewShow.tableCode}" title="${viewShow.tableCode}" validate="{required:false}"/> 137 138 </div> 139 </div> 140 </div> 141 <div class="fr_response_field col-sm-6" > 142 <div class="fr-form-group"> 143 <label class="fr-control-label">对应表备注</label> 144 <div class="fr-form-block" data-type="fixed"> 145 <input type="text" class="fr-form-control" name="m:viewShow:tableName" value="${viewShow.tableName}" title="${viewShow.tableName}" validate="{required:false}"/> 146 </div> 147 </div> 148 </div> 149 <div class="fr_response_field col-sm-2" > 150 <div class="fr-form-group"> 151 <label class="fr-control-label" style="text-align: left;">序号</label> 152 </div> 153 </div> 154 <div class="fr_response_field col-sm-2" > 155 <div class="fr-form-group"> 156 <label class="fr-control-label" style="text-align: left;">字段名</label> 157 </div> 158 </div> 159 <div class="fr_response_field col-sm-2" > 160 <div class="fr-form-group"> 161 <label class="fr-control-label" style="text-align: left;">字段备注</label> 162 </div> 163 </div> 164 <div class="fr_response_field col-sm-2" > 165 <div class="fr-form-group"> 166 <label class="fr-control-label" style="text-align: left;">字段排序</label> 167 </div> 168 </div> 169 <div class="fr_response_field col-sm-2" > 170 <div class="fr-form-group"> 171 <label class="fr-control-label" style="text-align: left;">显示设置</label> 172 </div> 173 </div> 174 <div class="fr_response_field col-sm-2" > 175 <div class="fr-form-group"> 176 <label class="fr-control-label" style="text-align: left;">查询方式</label> 177 </div> 178 </div> 179 <c:forEach items="${list}" var="view"> 180 <div class="fr_response_field col-sm-2" > 181 <div class="fr-form-group"> 182 <!-- <label class="fr-control-label">序号</label> --> 183 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 184 <input type="text" class="fr-form-control" name="m:viewShow:remarks_${view.colCode}" readonly="readonly" value="${view.id}" title="${view.id}" validate="{required:false}"/> 185 </div> 186 </div> 187 </div> 188 <div class="fr_response_field col-sm-2" > 189 <div class="fr-form-group"> 190 <!-- <label class="fr-control-label">字段名</label> --> 191 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 192 <input type="text" class="fr-form-control" name="m:viewShow:colCode_${view.colCode}" readonly="readonly" value="${view.colCode}" title="${view.colCode}" validate="{required:false}"/> 193 </div> 194 </div> 195 </div> 196 <div class="fr_response_field col-sm-2" > 197 <div class="fr-form-group"> 198 <!-- <label class="fr-control-label">字段备注</label> --> 199 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 200 <input type="text" class="fr-form-control" name="m:viewShow:colName_${view.colCode}" value="${view.colName}" title="${view.colName}" validate="{required:false}"/> 201 202 </div> 203 </div> 204 </div> 205 <div class="fr_response_field col-sm-2" > 206 <div class="fr-form-group"> 207 <!-- <label class="fr-control-label">字段排序</label> --> 208 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 209 <input type="number" class="fr-form-control" name="m:viewShow:colRank_${view.colCode}" min="0" value="${view.colRank}" title="${view.colRank}" validate="{required:false}"/> 210 211 </div> 212 </div> 213 </div> 214 <div class="fr_response_field col-sm-2" > 215 <div class="fr-form-group"> 216 <!-- <label class="fr-control-label">显示设置</label> --> 217 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 218 <select class="fr-form-control" name="m:viewShow:isShow_${view.colCode}" value="${view.isShow}" validate="{required:false}"> 219 <option value="">--请选择--</option> 220 <option value="0" <c:if test="${view.isShow==‘0‘}">selected="selected"</c:if>>隐藏</option> 221 <option value="1" <c:if test="${view.isShow==‘1‘}">selected="selected"</c:if>>居中</option> 222 <option value="2" <c:if test="${view.isShow==‘2‘}">selected="selected"</c:if>>居左</option> 223 <option value="3" <c:if test="${view.isShow==‘3‘}">selected="selected"</c:if>>居右</option> 224 </select> 225 226 </div> 227 </div> 228 </div> 229 <div class="fr_response_field col-sm-2" > 230 <div class="fr-form-group"> 231 <!-- <label class="fr-control-label">查询方式</label> --> 232 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 233 <select class="fr-form-control" name="m:viewShow:queryType_${view.colCode}" value="${view.queryType}" validate="{required:false}"> 234 <option value="">--请选择--</option> 235 <%@include file="viewShowOptions.jsp" %> 236 </select> 237 </div> 238 </div> 239 </div> 240 </c:forEach> 241 </form> 242 </div> 243 </div> 244 </div> 245 </c:if> 246 </div> 247 </form> 248 </div> 249 </body> 250 </html>
viewShowList.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 2 <%@include file="/commons/include/html_doctype.html" %> 3 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <%@include file="/commons/include/desktop.jsp" %> 8 <%@include file="/commons/page/codegen.jsp" %> 9 <script type="text/javascript" src="${ctx}/js/lc/platform/utils/SelectorDialog.js"></script> 10 <script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShow.js"></script> 11 <script type="text/javascript" src="${ctx}/js/lc/platform/viewShow/viewShowEcharts.js"></script> 12 <script type="text/javascript"> 13 var view_name="${view_name}"; 14 function show(v) { 15 switch (v) { 16 case "bar": 17 $("#tableName").val("单一横轴,数据列"); 18 break; 19 case "pie": 20 $("#tableName").val("单一横轴,单一数据列"); 21 break; 22 case "line": 23 $("#tableName").val("单一横轴,数据列"); 24 break; 25 default: 26 $("#tableName").val(""); 27 break; 28 } 29 } 30 31 </script> 32 <title>管理列表</title> 33 </head> 34 <body> 35 <div class="wrapper wrapper-content animated fadeInRight col-sm-12"> 36 <form class="form-horizontal"><form></form> 37 <div class="panel"> 38 <div class="tabs-container tabs-x"> 39 <ul class="nav nav-tabs"> 40 <li class="active"> 41 <a data-toggle="tab" href="#tab-1" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询</a> 42 </li> 43 <li > 44 <a data-toggle="tab" href="#tab-2" data-iframe="true" aria-expanded="false">${viewShow.viewName}查询管理</a> 45 </li> 46 </ul> 47 </div> 48 </div> 49 <div class="tab-content"> 50 <div id="tab-1" class="tab-pane active"> 51 <div class="panel-body"> 52 <div class="toolbar-panel "> 53 <div class="toolbar-box"> 54 <div class="toolbar-head clearfix"> 55 <!-- 顶部按钮 --> 56 <div class="buttons"> 57 <a id="fa-search" class="btn btn-primary fa fa-searchs" href="javascript:void(0);" onclick="javascript:$(‘#isQuery‘).val(‘YES‘)" ><span>搜索</span></a> 58 </div> 59 <!-- 收缩 --> 60 <div class="tools"> 61 <a href="javascript:void(0);" class="collapse"> 62 <i class="bigger-180 fa fa-angle-double-up"></i> 63 </a> 64 </div> 65 </div> 66 <!-- #查询条件3--> 67 <div class="toolbar-body" > 68 <form></form> 69 <!-- role="form" --> 70 <form id="searchForm" class="search-form"> 71 <div class="form-inline p-xxs"> 72 <input type="hidden" name="isQuery" id="isQuery" value="No"> 73 <c:forEach items="${list}" var="item"> 74 <%@include file="viewShowSelecter.jsp" %> 75 </c:forEach> 76 </div> 77 </form> 78 </div><!--/ 查询条件--> 79 </div> 80 </div><!--/ 操作、查询--> 81 <div class="jqGrid_wrapper"> 82 <div id="echarts"></div> 83 </div> 84 </div> 85 </div> 86 <c:if test="${isadmin}"> 87 <div id="tab-2" class="tab-pane <c:if test="${false}">active</c:if>"> 88 <div class="panel-body"> 89 <div class="panel-toolbar "> 90 <div class="buttons"> 91 <a href="javascript:void(0);" class="btn btn-primary fa fa-save" ><span>保存</span></a> 92 <a href="list.htm?view_name=${view_name}" class="btn btn-primary fa fa-back" ><span>返回</span></a> 93 </div> 94 </div> 95 <div class=""> 96 <form class="fr-form" id="viewShowForm" action="save.htm" > 97 <div class="fr_response_field col-sm-6" > 98 <div class="fr-form-group"> 99 <label class="fr-control-label">视图名</label> 100 <div class="fr-form-block" data-type="fixed"> 101 <input type="text" class="fr-form-control" name="m:viewShow:viewCode" readonly="readonly" value="${viewShow.viewCode}" title="${viewShow.viewCode}" validate="{required:false}"/> 102 </div> 103 </div> 104 </div> 105 <div class="fr_response_field col-sm-6" > 106 <div class="fr-form-group"> 107 <label class="fr-control-label">视图备注</label> 108 <div class="fr-form-block" data-type="fixed"> 109 <input type="text" class="fr-form-control" name="m:viewShow:viewName" value="${viewShow.viewName}" title="${viewShow.viewName}" validate="{required:false}"/> 110 </div> 111 </div> 112 </div> 113 <div class="fr_response_field col-sm-6" > 114 <div class="fr-form-group"> 115 <label class="fr-control-label">统计图类型</label> 116 <div class="fr-form-block" data-type="fixed"> 117 <select class="fr-form-control" name="m:viewShow:tableCode" onchange="show(this.value);" value="${viewShow.tableCode}" validate="{required:false}"> 118 <option value="">--请选择--</option> 119 <option value="bar" <c:if test="${viewShow.tableCode == ‘bar‘}">selected="selected"</c:if> >柱状图</option> 120 <option value="pie" <c:if test="${viewShow.tableCode == ‘pie‘}">selected="selected"</c:if> >南丁格尔饼图</option> 121 <option value="line" <c:if test="${viewShow.tableCode == ‘line‘}">selected="selected"</c:if> >折线图</option> 122 </select> 123 </div> 124 </div> 125 </div> 126 <div class="fr_response_field col-sm-6" > 127 <div class="fr-form-group"> 128 <label class="fr-control-label">统计图说明</label> 129 <div class="fr-form-block" data-type="fixed"> 130 <input type="text" class="fr-form-control" id="tableName" name="m:viewShow:tableName" value="${viewShow.tableName}" readonly="readonly" title="${viewShow.tableName}" validate="{required:false}"/> 131 </div> 132 </div> 133 </div> 134 <div class="fr_response_field col-sm-2" > 135 <div class="fr-form-group"> 136 <label class="fr-control-label" style="text-align: left;">序号</label> 137 </div> 138 </div> 139 <div class="fr_response_field col-sm-2" > 140 <div class="fr-form-group"> 141 <label class="fr-control-label" style="text-align: left;">字段名</label> 142 </div> 143 </div> 144 <div class="fr_response_field col-sm-2" > 145 <div class="fr-form-group"> 146 <label class="fr-control-label" style="text-align: left;">字段备注</label> 147 </div> 148 </div> 149 <div class="fr_response_field col-sm-2" > 150 <div class="fr-form-group"> 151 <label class="fr-control-label" style="text-align: left;">是否横轴</label> 152 </div> 153 </div> 154 <div class="fr_response_field col-sm-2" > 155 <div class="fr-form-group"> 156 <label class="fr-control-label" style="text-align: left;">是否数据</label> 157 </div> 158 </div> 159 <div class="fr_response_field col-sm-2" > 160 <div class="fr-form-group"> 161 <label class="fr-control-label" style="text-align: left;">查询方式</label> 162 </div> 163 </div> 164 <c:forEach items="${list}" var="view"> 165 <div class="fr_response_field col-sm-2" > 166 <div class="fr-form-group"> 167 <!-- <label class="fr-control-label">序号</label> --> 168 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 169 <input type="text" class="fr-form-control" name="m:viewShow:remarks_${view.colCode}" readonly="readonly" value="${view.id}" title="${view.id}" validate="{required:false}"/> 170 </div> 171 </div> 172 </div> 173 <div class="fr_response_field col-sm-2" > 174 <div class="fr-form-group"> 175 <!-- <label class="fr-control-label">字段名</label> --> 176 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 177 <input type="text" class="fr-form-control" name="m:viewShow:colCode_${view.colCode}" readonly="readonly" value="${view.colCode}" title="${view.colCode}" validate="{required:false}"/> 178 </div> 179 </div> 180 </div> 181 <div class="fr_response_field col-sm-2" > 182 <div class="fr-form-group"> 183 <!-- <label class="fr-control-label">字段备注</label> --> 184 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 185 <input type="text" class="fr-form-control" name="m:viewShow:colName_${view.colCode}" value="${view.colName}" title="${view.colName}" validate="{required:false}"/> 186 187 </div> 188 </div> 189 </div> 190 <div class="fr_response_field col-sm-2" > 191 <div class="fr-form-group"> 192 <!-- <label class="fr-control-label">是否横轴</label> --> 193 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 194 <select class="fr-form-control" name="m:viewShow:colRank_${view.colCode}" value="${view.colRank}" validate="{required:false}"> 195 <option value="">--请选择--</option> 196 <option value="0" <c:if test="${view.colRank==‘0‘}">selected="selected"</c:if>>否</option> 197 <option value="1" <c:if test="${view.colRank==‘1‘}">selected="selected"</c:if>>是</option> 198 </select> 199 </div> 200 </div> 201 </div> 202 <div class="fr_response_field col-sm-2" > 203 <div class="fr-form-group"> 204 <!-- <label class="fr-control-label">是否数据</label> --> 205 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 206 <select class="fr-form-control" name="m:viewShow:isShow_${view.colCode}" value="${view.isShow}" validate="{required:false}"> 207 <option value="">--请选择--</option> 208 <option value="0" <c:if test="${view.isShow==‘0‘}">selected="selected"</c:if>>否</option> 209 <option value="1" <c:if test="${view.isShow==‘1‘}">selected="selected"</c:if>>是</option> 210 </select> 211 212 </div> 213 </div> 214 </div> 215 <div class="fr_response_field col-sm-2" > 216 <div class="fr-form-group"> 217 <!-- <label class="fr-control-label">查询方式</label> --> 218 <div class="fr-form-block" style="margin-left: 0px;min-height: 34px;" data-type="fixed"> 219 <select class="fr-form-control" name="m:viewShow:queryType_${view.colCode}" value="${view.queryType}" validate="{required:false}"> 220 <option value="">--请选择--</option> 221 <%@include file="viewShowOptions.jsp" %> 222 </select> 223 </div> 224 </div> 225 </div> 226 </c:forEach> 227 </form> 228 </div> 229 </div> 230 </div> 231 </c:if> 232 </div> 233 </form> 234 </div> 235 </body> 236 </html> 237 <% out.clear();out = pageContext.pushBody(); %>
viewShowEcharts.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 2 <c:if test="${item.queryType == ‘1‘}"> 3 <!-- 文本输入框 --> 4 <div class="form-group"> 5 <label class="search-label">${item.colName}</label>: <input 6 type="text" name="Q^${item.colCode}^SL" class="form-control" /> 7 </div> 8 </c:if> 9 <c:if test="${item.queryType == ‘2‘}"> 10 <!-- 字典下拉框 --> 11 <div class="form-group"> 12 <label class="search-label">${item.colName}</label>: 13 <div class="input-group"> 14 <input type="hidden" id="${item.colCode}" name="Q^${item.colCode}^SL" /> 15 <input type="text" readonly="readonly" class="form-control comboTree" 16 data-toggle="dictionary" data-dic="${item.colCode}" 17 data-key="#${item.colCode}" 18 value="${f:getDictLabel2(solution.targetType,‘${item.colCode}‘, ‘key‘,‘‘,‘‘, ‘‘)}" /> 19 </div> 20 </div> 21 </c:if> 22 <!-- "LL".equals(type)) || ("NL".equals(type)) || ("DBL".equals(type)) || ("BDL".equals(type)) || ("FTL".equals(type)) || ("SNL".equals(type)) || ("DL" --> 23 <c:if test="${item.queryType == ‘3‘}"> 24 <!-- 时间间隔框 --> 25 <div class="form-group"> 26 <label class="search-label">${item.colName}起</label>: <input 27 type="text" name="Q^${item.colCode}^DL" class="form-control wdateTime" /> 28 </div> 29 <!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { --> 30 <div class="form-group"> 31 <label class="search-label">${item.colName}止</label>: <input 32 type="text" name="Q^${item.colCode}^DG" class="form-control wdateTime" /> 33 </div> 34 </c:if> 35 <c:if test="${item.queryType == ‘31‘}"> 36 <!-- 时间间隔框【数据下发】 --> 37 <div class="form-group"> 38 <label class="search-label">${item.colName}起</label>: <input 39 type="text" name="Q^${item.colCode}^DL" datefmt="yyyyMMdd" class="form-control wdateTime" /> 40 </div> 41 <!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { --> 42 <div class="form-group"> 43 <label class="search-label">${item.colName}止</label>: <input 44 type="text" name="Q^${item.colCode}^DG" datefmt="yyyyMMdd" class="form-control wdateTime" /> 45 </div> 46 </c:if> 47 <c:if test="${item.queryType == ‘4‘}"> 48 <!-- 时间选择框 --> 49 <div class="form-group"> 50 <label class="search-label">${item.colName}</label>: <input 51 type="text" name="Q^${item.colCode}^SL" class="form-control wdateTime" /> 52 </div> 53 </c:if> 54 <c:if test="${item.queryType == ‘41‘}"> 55 <!-- 时间选择框【数据下发】 --> 56 <div class="form-group"> 57 <label class="search-label">${item.colName}</label>: <input 58 type="text" name="Q^${item.colCode}^SL" datefmt="yyyyMMdd" class="form-control wdateTime" /> 59 </div> 60 </c:if> 61 <c:if test="${item.queryType == ‘5‘}"> 62 <!-- 人员下拉框 --> 63 <div class="form-group"> 64 <label class="search-label">${item.colName}</label>: 65 <div class="input-group "> 66 <input type="hidden" name="Q^${item.colCode}^SL" 67 id="id_${item.colCode}" value=""> <input type="text" 68 class="form-control search-selector" id="name_${item.colCode}" 69 name="name_${item.colCode}" readonly="readonly"> <span 70 class="input-group-btn"> 71 <button type="button" class="btn btn-info btn-mm" 72 data-toggle="selector" data-type="user" 73 data-id="#id_${item.colCode}" data-name="#name_${item.colCode}"> 74 <i class="fa fa-user"></i> 75 </button> 76 <button type="button" class="btn btn-info btn-mm" 77 data-toggle="clear" data-id="#id_${item.colCode}" 78 data-name="#name_${item.colCode}"> 79 <i class="fa fa-times"></i> 80 </button> 81 </span> 82 </div> 83 </div> 84 </c:if> 85 <c:if test="${item.queryType == ‘12‘}"> 86 <!-- 人员下拉框【权限】 --> 87 <div class="form-group"> 88 <label class="search-label">${item.colName}</label>: 89 <div class="input-group " <c:if test="${!isadmin}">style="pointer-events: none;"</c:if>> 90 <input type="hidden" name="Q^${item.colCode}^SL" 91 id="id_${item.colCode}" <c:if test="${!isadmin}">value="${f:getUser().getId()}"</c:if>> <input type="text" 92 class="form-control search-selector" id="name_${item.colCode}" 93 name="name_${item.colCode}" <c:if test="${!isadmin}">value="${f:getUser().getName()}"</c:if> readonly="readonly"> <span 94 class="input-group-btn"> 95 <button type="button" class="btn btn-info btn-mm" 96 data-toggle="selector" data-type="user" 97 data-id="#id_${item.colCode}" data-name="#name_${item.colCode}"> 98 <i class="fa fa-user"></i> 99 </button> 100 <button type="button" class="btn btn-info btn-mm" 101 data-toggle="clear" data-id="#id_${item.colCode}" 102 data-name="#name_${item.colCode}"> 103 <i class="fa fa-times"></i> 104 </button> 105 </span> 106 </div> 107 </div> 108 </c:if> 109 110 <c:if test="${item.queryType == ‘13‘}"> 111 <!-- 网点下拉框 --> 112 <div class="form-group"> 113 <label class="search-label">${item.colName}</label>: 114 <div class="input-group "> 115 <input type="hidden" name="Q^${item.colCode}^SL" 116 id="id_${item.colCode}"> 117 <input type="text" class="form-control search-selector" 118 id="name_${item.colCode}" 119 name="name_${item.colCode}" readonly="readonly"> <span 120 class="input-group-btn"> 121 <button type="button" class="btn btn-info btn-mm" 122 data-toggle="selector" data-type="org" 123 data-id="#id_${item.colCode}" data-name="#name_${item.colCode}"> 124 <i class="fa fa-user"></i> 125 </button> 126 <button type="button" class="btn btn-info btn-mm" 127 data-toggle="clear" data-id="#id_${item.colCode}" 128 data-name="#name_${item.colCode}"> 129 <i class="fa fa-times"></i> 130 </button> 131 </span> 132 </div> 133 </div> 134 </c:if> 135 <c:if test="${item.queryType == ‘6‘}"> 136 <!-- 网点下拉框【权限】 --> 137 <div class="form-group"> 138 <label class="search-label">${item.colName}</label>: 139 <div class="input-group " 140 <c:if test="${!isadmin}">style="pointer-events: none;"</c:if>> 141 <input type="hidden" name="Q^${item.colCode}^SL" 142 id="id_${item.colCode}" 143 <c:if test="${!isadmin}">value="${f:getUser().getGroupID()}"</c:if>> 144 <input type="text" class="form-control search-selector" 145 id="name_${item.colCode}" 146 <c:if test="${!isadmin}">value="${f:getUser().getOrgName()}"</c:if> 147 name="name_${item.colCode}" readonly="readonly"> <span 148 class="input-group-btn"> 149 <button type="button" class="btn btn-info btn-mm" 150 data-toggle="selector" data-type="org" 151 data-id="#id_${item.colCode}" data-name="#name_${item.colCode}"> 152 <i class="fa fa-user"></i> 153 </button> 154 <button type="button" class="btn btn-info btn-mm" 155 data-toggle="clear" data-id="#id_${item.colCode}" 156 data-name="#name_${item.colCode}"> 157 <i class="fa fa-times"></i> 158 </button> 159 </span> 160 </div> 161 </div> 162 </c:if> 163 <c:if test="${item.queryType == ‘7‘}"> 164 <!-- 岗位下拉框 --> 165 <div class="form-group"> 166 <label class="search-label">${item.colName}</label>: 167 <div class="input-group "> 168 <input type="hidden" name="Q^${item.colCode}^SL" 169 id="id_${item.colCode}" value=""> <input type="text" 170 class="form-control search-selector" id="name_${item.colCode}" 171 name="name_${item.colCode}" readonly="readonly"> <span 172 class="input-group-btn"> 173 <button type="button" class="btn btn-info btn-mm" 174 data-toggle="selector" data-type="position" 175 data-id="#id_${item.colCode}" data-name="#name_${item.colCode}"> 176 <i class="fa fa-user"></i> 177 </button> 178 <button type="button" class="btn btn-info btn-mm" 179 data-toggle="clear" data-id="#id_${item.colCode}" 180 data-name="#name_${item.colCode}"> 181 <i class="fa fa-times"></i> 182 </button> 183 </span> 184 </div> 185 </div> 186 </c:if> 187 <!-- "LL".equals(type)) || ("NL".equals(type)) || ("DBL".equals(type)) || ("BDL".equals(type)) || ("FTL".equals(type)) || ("SNL".equals(type)) || ("DL" --> 188 <c:if test="${item.queryType == ‘8‘}"> 189 <!-- 月度间隔框 --> 190 <div class="form-group"> 191 <label class="search-label">${item.colName}起</label>: <input 192 type="text" name="Q^${item.colCode}^DL" datefmt="yyyy-MM" class="form-control wdateTime" /> 193 </div> 194 <!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { --> 195 <div class="form-group"> 196 <label class="search-label">${item.colName}止</label>: <input 197 type="text" name="Q^${item.colCode}^DG" datefmt="yyyy-MM" class="form-control wdateTime" /> 198 </div> 199 </c:if> 200 <c:if test="${item.queryType == ‘81‘}"> 201 <!-- 月度间隔框【数据下发】 --> 202 <div class="form-group"> 203 <label class="search-label">${item.colName}起</label>: <input 204 type="text" name="Q^${item.colCode}^DL" datefmt="yyyyMM" class="form-control wdateTime" /> 205 </div> 206 <!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { --> 207 <div class="form-group"> 208 <label class="search-label">${item.colName}止</label>: <input 209 type="text" name="Q^${item.colCode}^DG" datefmt="yyyyMM" class="form-control wdateTime" /> 210 </div> 211 </c:if> 212 <c:if test="${item.queryType == ‘9‘}"> 213 <!-- 月度选择框 --> 214 <div class="form-group"> 215 <label class="search-label">${item.colName}</label>: <input 216 type="text" name="Q^${item.colCode}^SL" datefmt="yyyy-MM" class="form-control wdateTime" /> 217 </div> 218 </c:if> 219 <c:if test="${item.queryType == ‘91‘}"> 220 <!-- 月度选择框【数据下发】 --> 221 <div class="form-group"> 222 <label class="search-label">${item.colName}</label>: <input 223 type="text" name="Q^${item.colCode}^SL" datefmt="yyyyMM" class="form-control wdateTime" /> 224 </div> 225 </c:if> 226 <!-- "LL".equals(type)) || ("NL".equals(type)) || ("DBL".equals(type)) || ("BDL".equals(type)) || ("FTL".equals(type)) || ("SNL".equals(type)) || ("DL" --> 227 <c:if test="${item.queryType == ‘10‘}"> 228 <!-- 年度间隔框 --> 229 <div class="form-group"> 230 <label class="search-label">${item.colName}起</label>: <input 231 type="text" name="Q^${item.colCode}^DL" datefmt="yyyy" class="form-control wdateTime" /> 232 </div> 233 <!-- (("LG".equals(type)) || ("NG".equals(type)) || ("DBG".equals(type)) || ("BDG".equals(type)) || ("FTG".equals(type)) || ("SNG".equals(type)) || ("DG".equals(type))) { --> 234 <div class="form-group"> 235 <label class="search-label">${item.colName}止</label>: <input 236 type="text" name="Q^${item.colCode}^DG" datefmt="yyyy" class="form-control wdateTime" /> 237 </div> 238 </c:if> 239 <c:if test="${item.queryType == ‘11‘}"> 240 <!-- 年度选择框 --> 241 <div class="form-group"> 242 <label class="search-label">${item.colName}</label>: <input 243 type="text" name="Q^${item.colCode}^SL" datefmt="yyyy" class="form-control wdateTime" /> 244 </div> 245 </c:if>
viewShowSelecter.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 2 <option value="0" <c:if test="${view.queryType==‘0‘}">selected="selected"</c:if>>否</option> 3 <option value="1" <c:if test="${view.queryType==‘1‘}">selected="selected"</c:if>>文本输入框</option> 4 <option value="2" <c:if test="${view.queryType==‘2‘}">selected="selected"</c:if>>字典下拉框</option> 5 <option value="3" <c:if test="${view.queryType==‘3‘}">selected="selected"</c:if>>日期间隔框</option> 6 <option value="31" <c:if test="${view.queryType==‘31‘}">selected="selected"</c:if>>日期间隔框【数据下发】</option> 7 <option value="4" <c:if test="${view.queryType==‘4‘}">selected="selected"</c:if>>日期选择框</option> 8 <option value="41" <c:if test="${view.queryType==‘41‘}">selected="selected"</c:if>>日期选择框【数据下发】</option> 9 <option value="8" <c:if test="${view.queryType==‘8‘}">selected="selected"</c:if>>月份间隔框</option> 10 <option value="81" <c:if test="${view.queryType==‘81‘}">selected="selected"</c:if>>月份间隔框【数据下发】</option> 11 <option value="9" <c:if test="${view.queryType==‘9‘}">selected="selected"</c:if>>月份选择框</option> 12 <option value="91" <c:if test="${view.queryType==‘91‘}">selected="selected"</c:if>>月份选择框【数据下发】</option> 13 <option value="10" <c:if test="${view.queryType==‘10‘}">selected="selected"</c:if>>年份间隔框</option> 14 <option value="11" <c:if test="${view.queryType==‘11‘}">selected="selected"</c:if>>年份选择框</option> 15 <option value="5" <c:if test="${view.queryType==‘5‘}">selected="selected"</c:if>>人员下拉框</option> 16 <option value="12" <c:if test="${view.queryType==‘12‘}">selected="selected"</c:if>>人员下拉框【权限】</option> 17 <option value="13" <c:if test="${view.queryType==‘13‘}">selected="selected"</c:if>>网点下拉框</option> 18 <option value="6" <c:if test="${view.queryType==‘6‘}">selected="selected"</c:if>>网点下拉框【权限】</option> 19 <option value="7" <c:if test="${view.queryType==‘7‘}">selected="selected"</c:if>>岗位下拉框</option>
viewShowOptions.jsp
1 /** 2 * TD_PAMS_VIEWSHOW 3 * 4 * 5 *<pre> 6 * 开发公司:湖南泉汇三众科技有限公司 7 * 开发人员:sunson 8 * 邮箱地址:[email protected] 9 * 创建时间:2019-04-04 10:33:29 10 *</pre> 11 */ 12 $(function() { 13 viewShow = new ViewShow(); 14 viewShow.init(); 15 16 formUrl = viewShow.formUrl; 17 18 $(window).resize(function(){ 19 viewShow._initGridList(); 20 }); 21 $(‘#viewbody‘).bind(‘contextmenu‘,function(){ 22 return false; 23 }); 24 25 26 }); 27 28 (function() { 29 //定义常量 30 var _consts = { 31 GRID : "#viewShowGrid",// 列表对象 32 PAGER : "#viewShowPager",// 列表分页 33 FORM : ‘#viewShowForm‘,// 表单form 34 FORMGET : ‘#viewShowFormGet‘,// 表单form 35 SEARCHFORM : "#searchForm"//查询表单form 36 37 }; 38 /** 39 * TD_PAMS_VIEWSHOW 对象 40 * @returns {ViewShow} 41 */ 42 ViewShow = function() { 43 //定义属性 44 }; 45 46 /** 47 * 方法 48 */ 49 ViewShow.prototype = { 50 consts: _consts, 51 52 /** 53 * 初始化 54 */ 55 init : function() { 56 superme=this; 57 if (this.hasInit) // 是否已初始化 58 return false; 59 this.hasInit = true; 60 this._initForm(); 61 if ($(this.consts.GRID).length > 0){//列表 62 this._initGridList(); 63 this._setsum(); 64 } 65 if ($(this.consts.FORM).length > 0){//表单 66 this._initData(); 67 this._initOffice(‘e‘); 68 } 69 if ($(this.consts.FORMGET).length > 0){// 明细页面office控件初始化 70 this._initOffice(‘r‘); 71 } 72 }, 73 _initOffice : function(_rights){ 74 }, 75 76 /** 77 * 初始列表 78 */ 79 _initGridList : function() { 80 var me = this; 81 var shrinkToFit = true; 82 if(colNames.length>$("#tableGrid").width()/150) shrinkToFit=false; 83 $(this.consts.GRID).GridList( 84 { 85 url : __ctx+‘/platform/viewShow/viewShow/listJson.htm?view_name=‘+view_name, 86 pager :this.consts.PAGER, 87 multiselect : false, 88 shrinkToFit : shrinkToFit, 89 autoScroll : false, 90 colNames: colNames, 91 colModel: colModel, 92 onRightClickRow : function(rowid,iRow,iCol,e) { 93 var num=0;//jQuery("#viewShowGrid").jqGrid(‘getCol‘,iCol,true,"count"); 94 var sum=0;//jQuery("#viewShowGrid").jqGrid(‘getCol‘,iCol,true,"sum"); 95 var avg=0;//jQuery("#viewShowGrid").jqGrid(‘getCol‘,iCol,true,"avg"); 96 var col = jQuery("#viewShowGrid").jqGrid(‘getCol‘,iCol); 97 var size=0; 98 //DialogUtil.msg(col); 99 for(var i in col) { 100 sum+=parseFloat(col[i]); 101 var indx = col[i].indexOf(".")>=0?col[i].indexOf(".")+1:0; 102 indx = indx==0?0:col[i].length-indx; 103 size=size>indx?size:indx; 104 num++; 105 } 106 avg = num>0?sum/num:""; 107 num = isNaN(num)?"":num; 108 sum = isNaN(sum)?"":sum.toFixed(size); 109 avg = isNaN(avg)?"":avg.toFixed(size); 110 superme._setsum(colNames[iCol],num,sum,avg); 111 // DialogUtil.confirm(‘当前列[‘+colNames[iCol]+‘],是否合计?‘, 112 // function(rtn) { 113 // if(!rtn) return; 114 // var num=jQuery("#viewShowGrid").jqGrid(‘getCol‘,iCol,false,"count"); 115 // var sum=jQuery("#viewShowGrid").jqGrid(‘getCol‘,iCol,false,"sum"); 116 // superme._setsum(colNames[iCol],num,sum); 117 // } 118 // ); 119 }, 120 gridComplete : function () { 121 superme._setsum("","","",""); 122 // console.log($("#last_viewShowPager").next()) 123 // $("#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>"); 124 } 125 }); 126 $(this.consts.GRID).closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "scroll" }); 127 }, 128 /** 129 * 显示合计项 130 */ 131 _setsum : function(name,num,sum,avg) { 132 var str = "["+name+"]合计:"+sum+",计数:"+num+"条"+",平均:"+avg; 133 $("#viewShowPager_center").html("<td id=‘viewShowPager_center‘ align=‘center‘ style=‘white-space:pre;‘><label>"+str+"</label></td>"); 134 }, 135 /** 136 * 初始化表单 137 */ 138 _initForm : function() { 139 var me = this, form = $(this.consts.FORM), frm = form.form(); 140 me.formUrl = new com.lc.form.FormData(form); 141 // 触发表单验证 142 frm.valid(); 143 // 处理表单保存 144 //$("#fa-save").on(‘click‘,function(){ 145 $(document).on(‘click‘, ‘a.fa-save‘, function() { 146 var $el = $(this); 147 $el.button(‘loading‘); 148 // office提交 149 OfficePlugin.submit(); 150 me.formUrl.submit(me._showResponse, $el); 151 }); 152 //查询结果 153 //$("#fa-search").on(‘click‘,function(){ 154 $(document).on(‘click‘, ‘a.fa-search‘, function() { 155 superme.search(this); 156 }); 157 //TODO 导出结果 158 //$("#fa-export").on(‘click‘,function(){ 159 $(document).on(‘click‘, ‘a.fa-export‘, function() { 160 var url = __ctx+‘/platform/viewShow/viewShow/export.htm?view_name=‘+view_name+‘&export_=‘+export_+‘&data=‘+data; 161 $("#searchForm").attr("action",url); 162 $("#searchForm").attr("method",‘post‘); 163 $("#searchForm").submit(); 164 }); 165 //TODO 查询结果锁定 166 //$("#fa-lock").on(‘click‘,function(){ 167 $(document).on(‘click‘, ‘a.fa-lock‘, function() { 168 var obj=this; 169 if ($(obj).hasClass(‘disabled‘)) 170 return; 171 var searchForm = $(obj).closest("div .toolbar-panel").find( 172 ".search-form"); 173 if (searchForm.length == 0) 174 return; 175 var data = superme._serializeObject(searchForm); 176 DialogUtil.confirm(‘保存当前查询结果,是否继续操作‘, 177 function(rtn) { 178 if(!rtn) return; 179 $.ajax({ 180 type : "POST", 181 url : __ctx+‘/platform/viewShow/viewShow/clock.htm?view_name=‘+view_name, 182 data : data, 183 success : function(responseText) { 184 var resultMessage = new com.lc.form.ResultMessage(responseText); 185 if (resultMessage.isSuccess()) { 186 DialogUtil.msg(resultMessage.getMessage(),true); 187 } else { 188 DialogUtil.error(resultMessage.getMessage()); 189 } 190 }, 191 errror : function(error) { 192 DialogUtil.error(error); 193 } 194 }); 195 196 } 197 ); 198 }); 199 //TODO 查询结果解锁 200 //$("#fa-unlock").on(‘click‘,function(){ 201 $(document).on(‘click‘, ‘a.fa-unlock‘, function() { 202 var obj=this; 203 if ($(obj).hasClass(‘disabled‘)) 204 return; 205 var searchForm = $(obj).closest("div .toolbar-panel").find( 206 ".search-form"); 207 if (searchForm.length == 0) 208 return; 209 var data = superme._serializeObject(searchForm); 210 DialogUtil.confirm(‘从保存记录中剔除当前查询结果,是否继续操作‘, 211 function(rtn) { 212 if(!rtn) return; 213 $.ajax({ 214 type : "POST", 215 url : __ctx+‘/platform/viewShow/viewShow/unclock.htm?view_name=‘+view_name, 216 data : data, 217 success : function(responseText) { 218 var resultMessage = new com.lc.form.ResultMessage(responseText); 219 if (resultMessage.isSuccess()) { 220 DialogUtil.mas(resultMessage.getMessage(),true); 221 } else { 222 DialogUtil.error(resultMessage.getMessage()); 223 } 224 }, 225 errror : function(error) { 226 DialogUtil.error(error); 227 } 228 }); 229 230 } 231 ); 232 }); 233 }, 234 /** 235 * 初始化数据 236 */ 237 _initData : function(){ 238 if(!$.isEmpty(frameElement) 239 && !$.isEmpty(frameElement.dialog) 240 && !$.isEmpty(frameElement.dialog.params) 241 && !$.isEmpty(frameElement.dialog.params.data)){ 242 var data = frameElement.dialog.params.data; 243 this.formUrl.setData("[name^=‘m:‘]", data); 244 AttachementControl.initDataTo($("div[name=‘div_attachment_container‘]")); //附件初始化 245 }else{ 246 $("[name^=‘m:‘]", $(_consts.FORM)).each(function(){ 247 var data = $(this); 248 // 单选框特殊处理 249 if(data.is(‘input‘) && "radio" == data.attr("type")){ 250 var defaultVal = data.attr("defaultVal"); 251 var defaultValue = data.attr("defaultValue"); 252 if(defaultValue=="true"&&defaultVal=="true"){ 253 data.prop("checked", "checked"); 254 } 255 } 256 }); 257 } 258 259 this.formUrl.validate(); 260 }, 261 /** 262 * 表单成功返回信息 263 * 264 * @param responseText 265 */ 266 _showResponse : function(responseText) { 267 var msg = new com.lc.form.ResultMessage(responseText); 268 if (msg.isSuccess()) { 269 DialogUtil.confirm(msg.getMessage() + ‘,是否继续操作‘, 270 function(rtn) { 271 if(rtn) 272 window.location.reload(true); 273 /*else 274 window.location.href = __ctx+‘/platform/viewShow/viewShow/list.htm‘;*/ 275 }); 276 } else { 277 DialogUtil.error(msg.getMessage()); 278 } 279 }, 280 /** 281 * 282 * @param form 283 * @returns {___anonymous4353_4354} 284 */ 285 _serializeObject : function(form) { 286 var o = {}, a = $(form).serializeArray(); 287 // var o = {}, a = $(form).ghostsf_serialize(); 288 var $radio = $(‘input[type=radio],input[type=checkbox]‘, form); 289 var temp = {}; 290 $.each($radio, function () { 291 if (!temp.hasOwnProperty(this.name)) { 292 if ($("input[name=‘" + this.name + "‘]:checked").length == 0) { 293 temp[this.name] = ""; 294 a.push({name: this.name, value: ""}); 295 } 296 } 297 }); 298 $.each(a, function() { 299 var v = this.value || ‘‘; 300 if (o[this.name]) { 301 o[this.name] = o[this.name] +","+ v; 302 } else { 303 o[this.name] =v; 304 } 305 }); 306 307 return o; 308 }, 309 /** 310 * 查询 311 * @param obj 312 */ 313 search : function(obj) { 314 if ($(obj).hasClass(‘disabled‘)) 315 return; 316 var searchForm = $(obj).closest("div .toolbar-panel").find( 317 ".search-form"); 318 if (searchForm.length == 0) 319 return; 320 var data = superme._serializeObject(searchForm); 321 // $(this.consts.GRID).trigger("reloadGrid", { 322 // fromServer: true, 323 // postData : data, 324 // page: 1 325 // }); 326 327 $(this.consts.GRID).jqGrid().setGridParam({ 328 datatype:‘json‘, 329 postData : data, 330 }).trigger(‘reloadGrid‘); 331 332 333 // $(this.consts.GRID).GridList(‘setGridParam‘, { 334 // url : __ctx+‘/platform/viewShow/viewShow/listJson.htm?view_name=‘+view_name, 335 // postData : data, // 发送数据 336 // page : 1 337 // }).trigger("reloadGrid"); // 重新载入 338 }, 339 }; 340 })();
viewShow.js
1 /** 2 * TD_PAMS_VIEWSHOW 3 * 4 * 5 *<pre> 6 * 开发公司:湖南泉汇三众科技有限公司 7 * 开发人员:sunson 8 * 邮箱地址:[email protected] 9 * 创建时间:2019-04-04 10:33:29 10 *</pre> 11 */ 12 $(function() { 13 viewShowEcharts = new viewShowEcharts(); 14 viewShowEcharts.init(); 15 formUrl = viewShowEcharts.formUrl; 16 }); 17 18 19 (function() { 20 //定义常量 21 var _consts = { 22 FORM : ‘#viewShowForm‘,// 表单form 23 }; 24 /** 25 * TD_PAMS_VIEWSHOW 对象 26 * @returns {ViewShow} 27 */ 28 viewShowEcharts = function() { 29 //定义属性 30 }; 31 32 /** 33 * 方法 34 */ 35 viewShowEcharts.prototype = { 36 consts: _consts, 37 38 /** 39 * 初始化 40 */ 41 init : function() { 42 superme=this; 43 if (this.hasInit) // 是否已初始化 44 return false; 45 this.hasInit = true; 46 this._showEcharts(); 47 }, 48 _showEcharts: function() { 49 $("#fa-search").on(‘click‘,function(){ 50 var form = $(this).closest("div .toolbar-panel").find(".search-form"); 51 var o = {}, a = $(form).serializeArray(); 52 var $radio = $(‘input[type=radio],input[type=checkbox]‘, form); 53 var temp = {}; 54 $.each($radio, function () { 55 if (!temp.hasOwnProperty(this.name)) { 56 if ($("input[name=‘" + this.name + "‘]:checked").length == 0) { 57 temp[this.name] = ""; 58 a.push({name: this.name, value: ""}); 59 } 60 } 61 }); 62 $.each(a, function() { 63 var v = this.value || ‘‘; 64 if (o[this.name]) { 65 o[this.name] = o[this.name] +","+ v; 66 } else { 67 o[this.name] =v; 68 } 69 }); 70 $.ajaxSettings.async = true; 71 $.ajax({ 72 type : "POST", 73 url : __ctx+‘/platform/viewShow/viewShow/echartsJosn.htm?view_name=‘+view_name, 74 data : o, 75 success : function(option) { 76 $("#echarts").height($(window).height()*0.7); 77 var myChart = echarts.init(document.getElementById(‘echarts‘)).setOption(option[0]); 78 }, 79 errror : function(error) { 80 DialogUtil.error(error); 81 } 82 }); 83 }); 84 85 86 } 87 }; 88 })();
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 * 邮箱地址:[email protected] * 创建时间: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
1 package com.lc.ibps.performance.service.impl; 2 3 import java.util.ArrayList; 4 import java.util.HashMap; 5 import java.util.List; 6 import java.util.Map; 7 8 import javax.annotation.Resource; 9 10 import org.springframework.stereotype.Service; 11 12 import com.lc.ibps.api.base.query.QueryFilter; 13 import com.lc.ibps.base.core.util.BeanUtils; 14 import com.lc.ibps.base.core.util.JacksonUtil; 15 import com.lc.ibps.base.core.util.string.StringUtil; 16 import com.lc.ibps.performance.persistence.entity.ViewShowPo; 17 import com.lc.ibps.performance.repository.ViewShowRepository; 18 import com.lc.ibps.performance.service.ViewShowQueryService; 19 20 import net.sf.json.JSONArray; 21 22 /** 23 * TD_PAMS_VIEWSHOW 查询服务的实现类 24 * 25 *<pre> 26 * 开发公司:湖南泉汇三众科技有限公司 27 * 开发人员:sunson 28 * 邮箱地址:[email protected] 29 * 创建时间:2019-04-04 10:33:28 30 *</pre> 31 */ 32 @Service("viewShowQueryService") 33 public class ViewShowQueryServiceImpl implements ViewShowQueryService{ 34 35 @Resource 36 private ViewShowRepository viewShowRepository; 37 38 39 40 @Override 41 public String get(String id) { 42 ViewShowPo po = viewShowRepository.get(id); 43 44 return BeanUtils.isEmpty(po) ? null : po.toJsonString(); 45 } 46 47 48 @Override 49 public String query(QueryFilter filter) { 50 Map<String, String> map = new HashMap<>(); 51 map.put("view_name", filter.getParams().get("table").toString()); 52 List<ViewShowPo> list = viewShowRepository.getByViewName(map); 53 List<ViewShowPo> pos = null; 54 if(!list.isEmpty() && StringUtil.isNotEmpty(list.get(0).getTableCode())) { 55 56 Map<String, Object> params = new HashMap<>(); 57 params.put("table", list.get(0).getTableCode()); 58 filter.addParamsFilter(params); 59 pos = viewShowRepository.newQuery(filter); 60 } 61 if(BeanUtils.isEmpty(pos)) { 62 Map<String, Object> params = new HashMap<>(); 63 params.put("table", list.get(0).getViewCode()); 64 filter.addParamsFilter(params); 65 pos = viewShowRepository.newQuery(filter); 66 } 67 return BeanUtils.isEmpty(pos) ? null : pos.toString(); 68 } 69 70 @Override 71 public String findAll() { 72 List<ViewShowPo> pos = viewShowRepository.findAll(); 73 74 return BeanUtils.isEmpty(pos) ? null : JacksonUtil.toJsonString(pos); 75 } 76 77 78 @Override 79 public List<ViewShowPo> getByViewName(String view_name) { 80 Map<String, String> map = new HashMap<>(); 81 map.put("view_name", view_name); 82 List<ViewShowPo> pos = viewShowRepository.getByViewName(map); 83 return BeanUtils.isEmpty(pos) ? null : pos; 84 } 85 86 @Override 87 public List<Map<String, String>> getColByViewName(String view_name) { 88 List<Map<String, String>> data=new ArrayList<>(); 89 List<ViewShowPo> list= getByViewName(view_name); 90 Map<String, String> defaul = new HashMap<>(); 91 defaul.put("colName", "[‘视图不存在或未设置视图‘]"); 92 defaul.put("name", "XX"); 93 defaul.put("index", "XX"); 94 defaul.put("sortable", "false"); 95 list.sort((a, b) -> Integer.parseInt(a.getColRank()==null?"0":a.getColRank()+"") - Integer.parseInt(b.getColRank()==null?"0":b.getColRank()+"")); 96 for(ViewShowPo po:list) { 97 if("0".equals(po.getIsShow())) continue; 98 Map<String, String> map = new HashMap<>(); 99 map.put("colName", po.getColName()); 100 map.put("name", po.getColCode()); 101 map.put("index", po.getColCode()); 102 map.put("width", "150px"); 103 map.put("sortable", "false"); 104 map.put("align", "1".equals(po.getIsShow())?"center":"2".equals(po.getIsShow())?"left":"right"); 105 data.add(map); 106 } 107 if(data.isEmpty()) data.add(defaul); 108 return data; 109 } 110 111 112 @SuppressWarnings("rawtypes") 113 @Override 114 public JSONArray getOption(String view_name, QueryFilter queryFilter) { 115 //获取视图数据 116 Map<String, String> map = new HashMap<>(); 117 map.put("view_name", view_name); 118 List<ViewShowPo> pos = viewShowRepository.getByViewName(map); 119 ViewShowPo view = pos.get(0); 120 //获取查询数据 121 Map<String, Object> params = new HashMap<>(); 122 params.put("table", view_name); 123 queryFilter.addParamsFilter(params); 124 List<ViewShowPo> list = viewShowRepository.newQuery(queryFilter); 125 List<Map> datalist = JacksonUtil.getDTOList(JacksonUtil.getString(list.toString(), "data"), Map.class); 126 //横轴,数据列 127 String xAxisData= ""; 128 List<String> seriesData= new ArrayList<>(); 129 for(ViewShowPo po:pos) { 130 if("1".equals(po.getColRank()+"")) { 131 xAxisData = po.getColCode(); 132 } 133 if("1".equals(po.getIsShow())) { 134 seriesData.add(po.getColCode()); 135 } 136 } 137 switch (view.getTableCode()) { 138 case "bar": 139 return getBar(xAxisData,seriesData,pos,datalist); 140 case "pie": 141 return getPie(xAxisData,seriesData,pos,datalist); 142 case "line": 143 return getLine(xAxisData,seriesData,pos,datalist); 144 default: 145 return null; 146 } 147 } 148 149 150 /** 151 * 单一横轴,数据列 152 * @param xAxisData 横轴 153 * @param seriesData 数据列 154 * @param pos 视图属性 155 * @param datalist 数据集合 156 * @return 157 */ 158 @SuppressWarnings("rawtypes") 159 private JSONArray getLine(String xAxisData, List<String> seriesData, List<ViewShowPo> pos, List<Map> datalist) { 160 Map<String, Object> option= new HashMap<>(); 161 /********************折线****************************/ 162 Map<String, Object> title= new HashMap<>(); 163 option.put("title", title); 164 Map<String, Object> tooltip= new HashMap<>(); 165 tooltip.put("trigger", "axis"); 166 option.put("tooltip", tooltip); 167 Map<String, Object> legend= new HashMap<>(); 168 List<String> legendList = new ArrayList<>(); 169 Map<String, Object> toolbox= new HashMap<>(); 170 Map<String, Object> feature= new HashMap<>(); 171 Map<String, Object> dataView= new HashMap<>(); 172 feature.put("dataView", dataView); 173 Map<String, Object> saveAsImage= new HashMap<>(); 174 saveAsImage.put("pixelRatio", 2); 175 feature.put("saveAsImage", saveAsImage); 176 Map<String, Object> restore= new HashMap<>(); 177 feature.put("restore", restore); 178 toolbox.put("feature", feature); 179 option.put("toolbox", toolbox); 180 Map<String, Object> xAxis= new HashMap<>(); 181 xAxis.put("boundaryGap", false); 182 List<String> xAxisList = new ArrayList<>(); 183 Map<String, Object> yAxis= new HashMap<>(); 184 option.put("yAxis", yAxis); 185 List<Map<String, Object>> series= new ArrayList<>(); 186 seriesData.stream().forEach((str)->{ 187 Map<String, Object> data = new HashMap<>(); 188 List<Object> seriesList = new ArrayList<>(); 189 int count = xAxisList.size(); 190 datalist.stream().forEach((m)->{ 191 seriesList.add(m.get(str)); 192 if(count<=0) { 193 xAxisList.add((String) m.get(xAxisData)); 194 } 195 }); 196 legendList.add(pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName()); 197 data.put("name", pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName()); 198 data.put("type", "line"); 199 data.put("data", seriesList); 200 series.add(data); 201 202 }); 203 xAxis.put("data", xAxisList); 204 legend.put("data", legendList); 205 option.put("legend", legend); 206 option.put("xAxis", xAxis); 207 option.put("series", series); 208 return JSONArray.fromObject(option); 209 } 210 211 212 /** 213 * 单一横轴,数据列 214 * @param xAxisData 横轴 215 * @param seriesData 数据列 216 * @param pos 视图属性 217 * @param datalist 数据集合 218 * @return 219 */ 220 @SuppressWarnings("rawtypes") 221 private JSONArray getPie(String xAxisData, List<String> seriesData, List<ViewShowPo> pos, List<Map> datalist) { 222 Map<String, Object> option= new HashMap<>(); 223 Map<String, Object> series = new HashMap<>(); 224 series.put("roseType", "angle"); 225 series.put("type", "pie"); 226 List<Map<String, Object>> data = new ArrayList<>(); 227 datalist.stream().forEach((m)->{ 228 Map<String, Object> map = new HashMap<>(); 229 map.put("name", m.get(xAxisData)+"-"+m.get(seriesData.get(0))); 230 map.put("value", m.get(seriesData.get(0))); 231 data.add(map); 232 }); 233 series.put("data", data); 234 option.put("series", series); 235 return JSONArray.fromObject(option); 236 } 237 238 239 /** 240 * 数据列 241 * @param xAxisData 横轴 242 * @param seriesData 数据列 243 * @param pos 视图属性 244 * @param datalist 数据集合 245 * @return 246 */ 247 @SuppressWarnings({ "rawtypes" }) 248 private JSONArray getBar(String xAxisData, List<String> seriesData, List<ViewShowPo> pos, List<Map> datalist) { 249 Map<String, Object> option= new HashMap<>(); 250 //数据组装 251 Map<String, Object> title= new HashMap<>(); 252 option.put("title", title); 253 Map<String, Object> tooltip= new HashMap<>(); 254 option.put("tooltip", tooltip); 255 Map<String, Object> legend= new HashMap<>(); 256 List<String> legendList = new ArrayList<>(); 257 Map<String, Object> xAxis= new HashMap<>(); 258 List<String> xAxisList = new ArrayList<>(); 259 Map<String, Object> yAxis= new HashMap<>(); 260 option.put("yAxis", yAxis); 261 List<Map<String, Object>> series= new ArrayList<>(); 262 seriesData.stream().forEach((str)->{ 263 Map<String, Object> data = new HashMap<>(); 264 List<Object> seriesList = new ArrayList<>(); 265 int count = xAxisList.size(); 266 datalist.stream().forEach((m)->{ 267 seriesList.add(m.get(str)); 268 if(count==0) { 269 xAxisList.add((String) m.get(xAxisData)); 270 } 271 }); 272 legendList.add(pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName()); 273 data.put("name", pos.stream().filter(p->str.equals(p.getColCode())).findFirst().get().getColName()); 274 data.put("type", "bar"); 275 data.put("data",seriesList); 276 series.add(data); 277 }); 278 xAxis.put("data", xAxisList); 279 option.put("xAxis", xAxis); 280 legend.put("data", legendList); 281 option.put("legend", legend); 282 option.put("series", series); 283 return JSONArray.fromObject(option); 284 } 285 286 }
ViewShowQueryServiceImpl
1 package com.lc.ibps.performance.service.impl; 2 3 4 import java.util.HashMap; 5 import java.util.List; 6 import java.util.Map; 7 8 import javax.annotation.Resource; 9 10 import org.springframework.stereotype.Service; 11 import org.springframework.transaction.annotation.Transactional; 12 13 import com.lc.ibps.api.base.query.QueryFilter; 14 import com.lc.ibps.base.core.util.BeanUtils; 15 import com.lc.ibps.base.core.util.string.StringUtil; 16 import com.lc.ibps.performance.domain.ViewShow; 17 import com.lc.ibps.performance.persistence.entity.ViewShowPo; 18 import com.lc.ibps.performance.repository.ViewShowRepository; 19 import com.lc.ibps.performance.service.ViewShowService; 20 21 /** 22 * TD_PAMS_VIEWSHOW 服务的实现类 23 * 24 *<pre> 25 * 开发公司:湖南泉汇三众科技有限公司 26 * 开发人员:sunson 27 * 邮箱地址:[email protected] 28 * 创建时间:2019-04-04 10:33:29 29 *</pre> 30 */ 31 @Service("viewShowService") 32 @Transactional 33 public class ViewShowServiceImpl implements ViewShowService{ 34 35 @Resource 36 private ViewShowRepository viewShowRepository; 37 38 39 @Override 40 public void save(String jsonData) { 41 ViewShow viewShow = getDomain(jsonData, null); 42 if(BeanUtils.isEmpty(viewShow) || StringUtil.isEmpty(viewShow.getData().getViewCode())){ 43 return; 44 } 45 //删除 46 viewShow.deleteByViewName(viewShow.getData().getViewCode()); 47 //新增 48 Map<String, String> map = new HashMap<>(); 49 map.put("view_name", viewShow.getData().getViewCode()); 50 List<ViewShowPo> list=viewShowRepository.getByViewName(map); 51 String data=null; 52 for(ViewShowPo po:list) { 53 if(jsonData.contains("_"+po.getColCode())) { 54 data=jsonData.replace("_"+po.getColCode(), ""); 55 getDomain(data, null).save(); 56 } 57 } 58 } 59 60 @Override 61 public void deleteByIds(String[] ids) { 62 ViewShow viewShow = viewShowRepository.newInstance(); 63 viewShow.deleteByIds(ids); 64 } 65 66 67 /*######################### private ###########################*/ 68 69 /** 70 * 获取领域对象 71 * 72 * @param cmd 73 * @return 74 */ 75 private ViewShow getDomain(String busData, String key){ 76 if(BeanUtils.isEmpty(busData)){ 77 return null; 78 } 79 80 ViewShowPo po = ViewShowPo.fromJsonString(busData); 81 if(StringUtil.isNotEmpty(key)){ 82 po.setId(key); 83 } 84 ViewShow viewShow = viewShowRepository.newInstance(po); 85 86 return viewShow; 87 } 88 89 /** 90 * //获取对应的table,若无则创建对应table,并修改td_pams_viewShow的table字段 91 * //删除对应table中的数据 92 * //插入view查询结果 93 */ 94 @Override 95 public void clock(QueryFilter queryFilter) { 96 Map<String, String> map = new HashMap<>(); 97 map.put("view_name", queryFilter.getParams().get("view_name").toString()); 98 List<ViewShowPo> polist = viewShowRepository.getByViewName(map); 99 if(StringUtil.isEmpty(polist.get(0).getTableCode())) { 100 createTable(queryFilter); 101 } 102 for(ViewShowPo po:polist) { 103 po.setTableCode(queryFilter.getParams().get("table").toString()); 104 po.setId(null); 105 viewShowRepository.newInstance(po).save(); 106 } 107 deleteTable(queryFilter); 108 insertTable(queryFilter); 109 } 110 111 @Override 112 public void upclock(QueryFilter queryFilter) { 113 deleteTable(queryFilter); 114 } 115 116 private void insertTable(QueryFilter queryFilter) { 117 ViewShow viewShow = viewShowRepository.newInstance(); 118 119 120 viewShow.insertTable(QueryFilterToMap(queryFilter)); 121 } 122 123 private void deleteTable(QueryFilter queryFilter) { 124 ViewShow viewShow = viewShowRepository.newInstance(); 125 viewShow.deleteTable(QueryFilterToMap(queryFilter)); 126 } 127 128 private void createTable(QueryFilter queryFilter) { 129 ViewShow viewShow = viewShowRepository.newInstance(); 130 viewShow.createTable(QueryFilterToMap(queryFilter)); 131 } 132 133 private Map<String, Object> QueryFilterToMap(QueryFilter queryFilter) { 134 Map<String, Object> map = new HashMap<>(); 135 map.putAll(queryFilter.getParams()); 136 map.put("whereSql",queryFilter.getFieldLogic().getSql()); 137 return map; 138 } 139 140 @Override 141 public void completion() { 142 if(!isExist()) { 143 completionTable(); 144 } 145 } 146 147 private void completionTable() { 148 ViewShow viewShow = viewShowRepository.newInstance(); 149 viewShow.completion(); 150 } 151 152 private boolean isExist() { 153 boolean exist=true; 154 try { 155 Map<String, String> map = new HashMap<>(); 156 map.put("view_name","admin"); 157 viewShowRepository.getByViewName(map); 158 } catch (Exception e) { 159 exist=false; 160 } 161 return exist; 162 } 163 164 }
ViewShowServiceImpl
1 package com.lc.ibps.performance.repository.impl; 2 3 4 import java.util.List; 5 import java.util.Map; 6 7 import javax.annotation.Resource; 8 9 import org.springframework.stereotype.Repository; 10 11 import com.lc.ibps.api.base.query.QueryFilter; 12 import com.lc.ibps.base.core.util.AppUtil; 13 import com.lc.ibps.base.framework.persistence.dao.IQueryDao; 14 import com.lc.ibps.base.framework.repository.AbstractRepository; 15 import com.lc.ibps.performance.domain.ViewShow; 16 import com.lc.ibps.performance.persistence.dao.ViewShowQueryDao; 17 import com.lc.ibps.performance.persistence.entity.ViewShowPo; 18 import com.lc.ibps.performance.repository.ViewShowRepository; 19 20 /** 21 * TD_PAMS_VIEWSHOW 仓库的实现类 22 * 23 *<pre> 24 * 开发公司:湖南泉汇三众科技有限公司 25 * 开发人员:sunson 26 * 邮箱地址:[email protected] 27 * 创建时间:2019-04-04 10:33:28 28 *</pre> 29 */ 30 @Repository 31 public class ViewShowRepositoryImpl extends AbstractRepository<String, ViewShowPo,ViewShow> implements ViewShowRepository{ 32 33 @Resource 34 private ViewShowQueryDao viewShowQueryDao; 35 36 public ViewShow newInstance() { 37 ViewShowPo po = new ViewShowPo(); 38 ViewShow viewShow = AppUtil.getBean(ViewShow.class); 39 viewShow.setData(po); 40 return viewShow; 41 } 42 43 public ViewShow newInstance(ViewShowPo po) { 44 ViewShow viewShow = AppUtil.getBean(ViewShow.class); 45 viewShow.setData(po); 46 return viewShow; 47 } 48 49 @Override 50 protected IQueryDao<String, ViewShowPo> getQueryDao() { 51 return viewShowQueryDao; 52 } 53 54 @Override 55 public List<ViewShowPo> getByViewName(Map<String, String> map) { 56 return viewShowQueryDao.findByKey("getByViewName", map); 57 } 58 59 @Override 60 public List<ViewShowPo> newQuery(QueryFilter filter) { 61 return viewShowQueryDao.queryByQueryFilter(filter); 62 } 63 64 }
ViewShowRepositoryImpl
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 <mapper namespace="com.lc.ibps.performance.persistence.entity.ViewShowPo"> 4 <resultMap id="ViewShowPo" type="com.lc.ibps.performance.persistence.entity.ViewShowPo"> 5 <id property="id" column="ID_" jdbcType="VARCHAR"/> 6 <result property="viewCode" column="VIEW_CODE_" jdbcType="VARCHAR"/> 7 <result property="viewName" column="VIEW_NAME_" jdbcType="VARCHAR"/> 8 <result property="tableCode" column="TABLE_CODE_" jdbcType="VARCHAR"/> 9 <result property="tableName" column="TABLE_NAME_" jdbcType="VARCHAR"/> 10 <result property="colCode" column="COL_CODE_" jdbcType="VARCHAR"/> 11 <result property="colName" column="COL_NAME_" jdbcType="VARCHAR"/> 12 <result property="colRank" column="COL_RANK_" jdbcType="NUMERIC"/> 13 <result property="isShow" column="IS_SHOW_" jdbcType="VARCHAR"/> 14 <result property="queryType" column="QUERY_TYPE_" jdbcType="VARCHAR"/> 15 <result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/> 16 <result property="createDate" column="CREATE_DATE_" jdbcType="TIMESTAMP"/> 17 <result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/> 18 <result property="updateDate" column="UPDATE_DATE_" jdbcType="TIMESTAMP"/> 19 <result property="remarks" column="REMARKS_" jdbcType="VARCHAR"/> 20 <result property="delFlag" column="DEL_FLAG_" jdbcType="VARCHAR"/> 21 </resultMap> 22 23 <sql id="columns"> 24 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_ 25 </sql> 26 27 <insert id="create" parameterType="com.lc.ibps.performance.persistence.entity.ViewShowPo"> 28 INSERT INTO TD_PAMS_VIEWSHOW 29 (<include refid="columns"/>) 30 VALUES 31 (#{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}) 32 </insert> 33 34 <select id="get" parameterType="java.lang.String" resultMap="ViewShowPo"> 35 SELECT <include refid="columns"/> FROM TD_PAMS_VIEWSHOW 36 WHERE 37 ID_=#{id} 38 </select> 39 40 41 <select id="query" parameterType="java.util.Map" resultType="java.util.Map"> 42 SELECT * FROM ${table} 43 <where> 44 <if test="@[email protected](whereSql)"> 45 ${whereSql} 46 </if> 47 </where> 48 <if test="@[email protected](orderBySql)"> 49 ORDER BY ${orderBySql} 50 </if> 51 </select> 52 53 <select id="findByIds" resultMap="ViewShowPo"> 54 SELECT <include refid="columns"/> FROM TD_PAMS_VIEWSHOW 55 WHERE ID_ in 56 <foreach item="id" index="index" collection="ids" open="(" separator="," close=")"> 57 #{id} 58 </foreach> 59 ORDER BY ID_ DESC 60 </select> 61 62 <update id="update" parameterType="com.lc.ibps.performance.persistence.entity.ViewShowPo"> 63 UPDATE TD_PAMS_VIEWSHOW SET 64 VIEW_CODE_=#{viewCode,jdbcType=VARCHAR}, 65 VIEW_NAME_=#{viewName,jdbcType=VARCHAR}, 66 TABLE_CODE_=#{tableCode,jdbcType=VARCHAR}, 67 TABLE_NAME_=#{tableName,jdbcType=VARCHAR}, 68 COL_CODE_=#{colCode,jdbcType=VARCHAR}, 69 COL_NAME_=#{colName,jdbcType=VARCHAR}, 70 COL_RANK_=#{colRank,jdbcType=NUMERIC}, 71 IS_SHOW_=#{isShow,jdbcType=VARCHAR}, 72 QUERY_TYPE_=#{queryType,jdbcType=VARCHAR}, 73 CREATE_DATE_=#{createDate,jdbcType=TIMESTAMP}, 74 UPDATE_BY_=#{updateBy,jdbcType=VARCHAR}, 75 UPDATE_DATE_=#{updateDate,jdbcType=TIMESTAMP}, 76 REMARKS_=#{remarks,jdbcType=VARCHAR}, 77 DEL_FLAG_=#{delFlag,jdbcType=VARCHAR} 78 WHERE 79 ID_=#{id} 80 </update> 81 82 <delete id="remove" parameterType="java.lang.String"> 83 DELETE FROM TD_PAMS_VIEWSHOW 84 WHERE 85 ID_=#{id} 86 </delete> 87 <select id="getByViewName" parameterType="java.util.Map" resultMap="ViewShowPo"> 88 SELECT CC.TABLE_NAME VIEW_CODE_, 89 MAX(NVL(VS.VIEW_NAME_,TC.COMMENTS)) VIEW_NAME_, 90 MAX(VS.TABLE_CODE_) TABLE_CODE_, 91 MAX(VS.TABLE_NAME_) TABLE_NAME_, 92 CC.COLUMN_NAME COL_CODE_, 93 MAX(NVL(VS.COL_NAME_,CC.COMMENTS)) COL_NAME_, 94 MAX(VS.COL_RANK_) COL_RANK_, 95 MAX(VS.IS_SHOW_) IS_SHOW_, 96 MAX(NVL(VS.ID_,ROWNUM)) ID_, 97 MAX(VS.QUERY_TYPE_) QUERY_TYPE_ 98 FROM USER_COL_COMMENTS CC 99 LEFT JOIN TD_PAMS_VIEWSHOW VS 100 ON VS.VIEW_CODE_ = CC.TABLE_NAME 101 AND VS.COL_CODE_ = CC.COLUMN_NAME 102 LEFT JOIN USER_TAB_COMMENTS TC 103 ON TC.TABLE_NAME=CC.TABLE_NAME 104 WHERE CC.TABLE_NAME=UPPER(#{view_name}) 105 GROUP BY CC.TABLE_NAME,CC.COLUMN_NAME 106 ORDER BY COL_RANK_ 107 </select> 108 109 <delete id="deleteByViewName" parameterType="java.util.Map"> 110 DELETE FROM TD_PAMS_VIEWSHOW 111 WHERE 112 VIEW_CODE_=UPPER(#{viewCode}) 113 </delete> 114 115 <update id="createTable" parameterType="java.util.Map"> 116 CREATE TABLE ${table} AS SELECT * FROM ${view_name} WHERE 1=2 117 </update> 118 119 <delete id="deleteTable" parameterType="java.util.Map"> 120 DELETE FROM ${table} 121 <where> 122 <if test="@[email protected](whereSql)"> 123 ${whereSql} 124 </if> 125 </where> 126 </delete> 127 128 <insert id="insertTable" parameterType="java.util.Map"> 129 INSERT INTO ${table} SELECT * FROM ${view_name} 130 <where> 131 <if test="@[email protected](whereSql)"> 132 ${whereSql} 133 </if> 134 </where> 135 </insert> 136 137 <update id="completion"> 138 CREATE TABLE "TD_PAMS_VIEWSHOW" 139 ( "ID_" VARCHAR2(64) NOT NULL ENABLE, 140 "VIEW_CODE_" VARCHAR2(64), 141 "VIEW_NAME_" VARCHAR2(64), 142 "TABLE_CODE_" VARCHAR2(64), 143 "TABLE_NAME_" VARCHAR2(64), 144 "COL_CODE_" VARCHAR2(64), 145 "COL_NAME_" VARCHAR2(64), 146 "COL_RANK_" NUMBER(*,0), 147 "IS_SHOW_" VARCHAR2(32), 148 "QUERY_TYPE_" VARCHAR2(32), 149 "CREATE_BY_" VARCHAR2(64), 150 "CREATE_DATE_" DATE, 151 "UPDATE_BY_" VARCHAR2(64), 152 "UPDATE_DATE_" DATE, 153 "REMARKS_" VARCHAR2(2000), 154 "DEL_FLAG_" VARCHAR2(1), 155 CONSTRAINT "PK_TD_PAMS_VIEWSHOW" PRIMARY KEY ("ID_") 156 ) 157 </update> 158 159 </mapper>
ViewShow.map.xml
原文地址:https://www.cnblogs.com/tangzeqi/p/11428967.html
时间: 2024-11-08 00:49:12