| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <%@ page import="org.springframework.jdbc.core.JdbcTemplate,cn.sinobest.framework.util.Util,cn.sinobest.framework.service.ReportService,cn.sinobest.framework.comm.iface.IReportService,cn.sinobest.framework.service.entities.ReportConfig,cn.sinobest.framework.util.DTOUtil,com.runqian.report4.usermodel.Context,cn.sinobest.framework.comm.transcation.DataSourceCallBack,cn.sinobest.framework.comm.transcation.IDataSourceCallBack,cn.sinobest.framework.comm.exception.AppException,com.runqian.report4.dataset.JNDIConnectionFactory,cn.sinobest.framework.util.ConfUtil,cn.sinobest.framework.comm.iface.IReportFeedback,cn.sinobest.framework.comm.iface.IReportResultSet,java.util.Map.Entry,java.sql.Connection,
- cn.sinobest.framework.service.json.JSONUtilities
- "%>
- <%@ taglib uri="/WEB-INF/runqianReport4.tld" prefix="rq"%>
- <%@include file="/jsp/framework/head.jsp"%>
- <%-- 下面的第一段都是判断报表跳转的逻辑,维护报表的时候无需关注,只需要关注第二段q<%--------------------------------------------------------------------------------------------%>
- <%--------------------- 第一段: 判断报表报表打印是否需要跳转到另外的报表服务器 ----------------------%>
- <%--------------------------------------------------------------------------------------------%>
- <%
-
- /**
- * part1. 判断是否要使用报表服务器,和获取报表服务器的URL
- */
- String isUseRepSer = "false";//是否使用报表服务器
- String repSerUrl = "";//报表服务器URL
- //如果IS_USE_REPORT_SERVER不为"true",则表示所有报表打印 不跳转
- isUseRepSer = ConfUtil.getParam("IS_USE_REPORT_SERVER","false").toLowerCase();
- if(!isUseRepSer.equals("true")){
- isUseRepSer = "false";
- }else{
- isUseRepSer = "true";
- }
-
- //如果REPORTURL为空,则表示所有报表打印 不跳转
- repSerUrl = ConfUtil.getParam("REPORTURL","");
- if("".equals(repSerUrl)){
- isUseRepSer = "false";
- repSerUrl = "";
- }
- if("true".equals(isUseRepSer)){
- String redirectUrl=ConfUtil.getDict("RPREDIRECTMAP",request.getServerName()+"."+request.getServerPort());
- if(redirectUrl!=null&&!"".equals(redirectUrl)){
- repSerUrl=redirectUrl;
- }
- }
-
- if("true".equals(isUseRepSer)){
- //如果aa10字典有配置该报表的打印,不管aa01配置如何,都以 aa10的配置为准。URL为空表表示不跳转,URL不为空表示跳转到配置的URL。
- Map<String, Map<String, String>> dict = null;
- ReportConfig reportConf = (ReportConfig)DTOUtil.getObject("reportConfig");
- try{
- dict = ConfUtil.getDictKeyItemCode("REPORTREDIRECT");
- }catch(Exception e){
- dict = null;
- }
- if(null != dict){
- Map<String,String> aa10ReportRedirectConf = dict.get(reportConf.getId());
- if(null != aa10ReportRedirectConf){
- String aa10ReportUrl = aa10ReportRedirectConf.get("AAA103");
- //如果在AA10表AAA103字段配置了URL,则跳转到该URL
- if(null != aa10ReportUrl && !"".equals(aa10ReportUrl)){
- isUseRepSer = "true";
- repSerUrl = aa10ReportUrl;
- }
- //如果在AA10表AAA103字段配置的URL为空,则不跳转。
- else{
- isUseRepSer = "false";
- repSerUrl = "";
- }
- }
- }
- }
- /**
- * part2. 在判断当前报表需要使用报表服务器的前提下,再判断当前服务器是否为报表服务器,如果是报表服务器则不跳转,否则跳转到报表服务器
- */
- String isJump = "false";
- if("true".equals(isUseRepSer) && !repSerUrl.equals("")){
- //当前服务器就是报表服务器,无需跳转
- if("true".equals(ConfUtil.getSysParamOnly("app.isReportServer","false").toLowerCase())){
- isJump = "false";
- }
- //当前服务器不是报表服务器,需要跳转
- else{
- isJump = "true";
- }
- }
- %>
- <%-- 不使用当前服务器,使用另外的报表服务器做打印 --%>
- <%if("true".equalsIgnoreCase(isJump)){%>
- <script>
- var href = location.href;
- var count = 0;
- var pos = -1;
- for(var i=0,len=href.length;i<len;i++){
- if('/'==href.charAt(i)){
- count++;
- }
- if(4 == count){
- pos = i;
- break;
- }
- }
- <%-- var curSerUrl = href.substring(0,pos); --%>
- var curQuery = href.substring(pos);
- <%--动态导入单点登陆所需JS--%>
- CFW.oComm.fnLoadScript({
- url:contextPath + "/js/comm/fw/encrypt.js",
- beforeFunc: function(){return null==document.getElementById("fwencrypt");},//返回true的时候才载入脚本
- afterFunc: function(script){
- if(null != script){
- script.id = "fwencrypt";
- }
- CFW.oComm.fnLoadScript({
- url:contextPath + "/js/comm/fw/encrypt2.js",
- beforeFunc: function(){return null==document.getElementById("fwencrypt2");},//返回true的时候才载入脚本
- afterFunc: function(script){
- if(null != script){
- script.id = "fwencrypt2";
- }
- loginRepSer();
- }
- });
- }
- });
-
- <%--单点登陆到指定报表服务器--%>
- function loginRepSer(){
- ssoLogin("<%=repSerUrl%>",readCookie("LOGINID"),getSsoUid(),
- function(jsonpdata){
- if(jsonpdata.FHZ<0){
- alert(jsonpdata.MSG);
- return;
- }else{
- redirect2RepSer();
- }
- }
- );
- }
- <%--跳转到指定报表服务器--%>
- function redirect2RepSer(){
- href = '<%=repSerUrl%>' + curQuery +"&t="+new Date();
- location.href = href;
- }
- </script>
- <%}%>
- <%--------------------------------------------------------------------------------------------%>
- <%--------------------- 第二段: 报表打印 ----------------------%>
- <%--------------------------------------------------------------------------------------------%>
- <%-- 使用当前服务器做打印 --%>
- <%if("false".equalsIgnoreCase(isJump)){
- //是否显示按钮 跟Globals.js内 reportGenerate 配合使用
- String FWBTNCLOSE =(String)request.getParameter("FWBTNCLOSE")+"";
- String FWBTNBACK =(String)request.getParameter("FWBTNBACK")+"";
- if(FWBTNCLOSE.equals("")||FWBTNCLOSE.equals("null")){FWBTNCLOSE="YES";}
- if(FWBTNBACK.equals("")||FWBTNBACK.equals("null")){FWBTNBACK="YES";}
-
- ReportConfig reportConfig =(ReportConfig)DTOUtil.getObject("reportConfig");
- Context context = new Context();
-
- request.setAttribute( "myContext", context );
- context.setParamValue("configId",reportConfig.getId());
- //拼入参串
- StringBuilder param=new StringBuilder();
- Map<String,String> jsonMap = new HashMap<String,String>();
- Map<String,Object> params = DTOUtil.getData();
- for(Entry<String,Object> entry:params.entrySet()){
- if("needDirectPrint".equals(entry.getKey())||
- "needSelectPrinter".equals(entry.getKey())){
- //去掉本模块辅助的参数,这些在报表中使用不到
- continue;
- }
- if(entry.getValue()==null){
- continue;
- }
- //准备json需要的map,这个用在回调函数里,作为额外的参数传递
- jsonMap.put(entry.getKey(),entry.getValue().toString());
- //把参数拼成name=value;name2=value2;.....的形式
- param.append(entry.getKey()).append("=").append(entry.getValue().toString()).append(";");
- }
- String needDirectPrint = "yes";//默认是直接打印
- if("false".equals( DTOUtil.getValue(" "))){
- needDirectPrint = "no";
- }
- String needSelectPrinter = "no";//默认是不弹出选择打印机的窗口
-
- if("false".equals( DTOUtil.getValue("needSelectPrinter"))){
- needSelectPrinter = "yes";
- }
- String needSaveAsExcel = "no";//默认是不显示"保存为EXCEL"
- if("true".equals(DTOUtil.getValue("needSaveAsExcel"))){
- needSaveAsExcel = "yes";
- }
-
- String needSaveAsWord = "no";//默认是不显示"保存为EXCEL"
- if("true".equals(DTOUtil.getValue("needSaveAsWord"))){
- needSaveAsWord = "yes";
- }
- String excelPageStyle ="1";
- if("false".equals(DTOUtil.getValue("excelPageStyle"))){//默认是按分页导出
- excelPageStyle = "0";
- }
-
- %>
- <table align=center >
- <tr>
- <td >
- <rq:html name="testRpt"
- reportFileName="<%=reportConfig.getTemplateName() %>"
- funcBarLocation="top"
- params="<%=param.toString() %>"
- contextName="myContext"
- generateParamForm="no"
- needDirectPrint="<%=needDirectPrint %>"
- needSelectPrinter="<%=needSelectPrinter %>"
- exceptionPage="/jsp/framework/error.jsp"
- savePrintSetup="yes"
- needPrint="yes"
- needSaveAsExcel="<%=needSaveAsExcel %>"
- needSaveAsWord="<%=needSaveAsWord %>"
- excelPageStyle="<%=excelPageStyle %>"
- >
- </rq:html>
- </td>
- </tr>
- </table>
-
-
-
- <% if(FWBTNBACK.equalsIgnoreCase("YES")){%>
- <p align="center">
- <hnisi:btn id="btnBack" value="返回" onclick="goback()" />
- </p>
- <%}%>
-
- <script type="text/javascript">
-
- function goback(){
- var referer = _getServerUrl(document.referrer).toLowerCase();
- var currentUrl = _getServerUrl(document.location.href).toLowerCase();
- if(referer == currentUrl){
- history.go(-1);
- }else{
- history.go(-2);
- }
-
- function _getServerUrl(url){
- var count = 0;
- var pos = 0;
- for(var i=0;i<url.length;i++){
- if(url.charAt(i) == "/"){
- count++;
- }
- if(count == 4){
- pos = i;
- break;
- }
- }
- return url.substring(0,pos);
- }
- }
- function runqian_printOver(){
- var paramsMap = <%=new JSONUtilities(JSONUtilities.BEAUTY_LOOK).parseObject(jsonMap)%>;
- paramsMap['configId'] = '<%=reportConfig.getId()%>';
- //回调函数
- new Service()
- .appendServices({
- serviceId:'reportService',
- method:'afterPrint',
- parameters:paramsMap
- }).sentAjax('回写打印数据',function(){
- //关闭弹出窗口
- //CFW.oWin.fnAlert('打印结束!');
- if(window.top == window){
- var href = window.location.href;
- window.open(href,"_self","");
- window.close();
- }
- });
- }
-
- $(function(){
-
- <% if(FWBTNCLOSE.equalsIgnoreCase("YES")){%>
- if(window.top==window){
- $('#btnBack').linkbutton({text:'关闭'}).click(function(){
- var href = window.location.href;
- window.open(href,"_self","");
- window.close();
- return false;
- });
- }
- <%}%>
-
- /*url中的.jsp换成.do否则会出异常*/
- if(window['testRpt_turnPageForm']!=null){
- window['testRpt_turnPageForm'].action=
- window['testRpt_turnPageForm'].action.
- replace('/report.jsp?','/report.do?');
- }
- });
- document.body.style.zoom = screen.width/900;
- $("a",$("div").get(0)).each(function(){
- if('打印' == this.innerText){
- this.innerText = '打印设置';
- return;
- }
- });
-
- </script>
- <% }%><%--if("false".equalsIgnoreCase(isUseRepSer)){--%>
- </body>
- </html>
|