帆软文件上传
来自ling
目录
帆软文件上传
安装
- 将commons-fileupload-1.3.2.jar和commons-io-2.5.jar上传至安装目录的WEB-INF/lib下
- 将com.deloitte.tms.base.core.servlet.TemplateUpload编译好的文件保持目录copy到WEB-INF/classes
- 在web.xml中配置sevlet,basepath按实际情况部署
C:\workspace\deloitte_tr\rpt\out\production\rpt\com\deloitte\tms\base\core\servlet /home/dttserver/server/tomcat8080/webapps/rpt/WEB-INF/classes/com/deloitte/tms/base/core/servlet
<servlet>
<servlet-name>TemplateUpload</servlet-name>
<servlet-class>
com.deloitte.tms.base.core.servlet.TemplateUpload
</servlet-class>
<init-param>
<param-name>basePath</param-name>
<param-value>C:\\workspace\\deloitte_tr\\rpt\\web\\WEB-INF\\reportlets</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>TemplateUpload</servlet-name>
<url-pattern>/Servlet/TemplateUpload</url-pattern>
</servlet-mapping>
使用
上传页面示例
- 上传成功返回内容
如果存在redirect则跳转到redirect页面并在rul中添加结果realPath=realPath&result=true 否则返回以下json内容
{result:true,realPath:realPath}
- 失败返回内容
如果存在redirect则跳转到redirect页面并在rul中添加结果message=message&result=true 否则返回以下json内容
{result;false,message:message}
jsp示例
java模拟上传文件
- 依赖jar包commons-httpclient-3.1.jar
生效代码参考
报表管理相关概念
select * from T_BASE_RPT_def; select * from T_BASE_RPT_TMPL;
- 子系统名决定帆软报表模板的目录
- 报表代码决定所对应的报表模板,并有时间范围确定相应的模板
- 一个子系统有多个报表,一个报表有多个模板
- T_BASE_RPT_def 报表定义:模板代码有事干嘛
一个模板有多个版本 模板的编码目前没有用到 版本的确定由时间范围
报表代码决定所对应的报表模板 什么意思? 在报表的头表中有一个报表模板列表的字段 里面是{ “rptCode: templateID", ......} 所有由code决定template ID
code 就是报表的编码
获取帆软报表信息接口
- 设计文档
- 代码ReportInfoController#saveInvoice
- 请求类型:HTTP
- 请求地址:http://172.16.150.162:8080/newBase/rpttmpl.do
- 请求方式:POST
- 数据类型:JSON
- 响应类型:JSON
- 请求参数
rptDate true string 报表填报时间(yyyy-mm-dd) rptCode true string 报表编码
- 返回
code true string 返回代码 message true string 返回消息 resultList true array[object] 返回模板列表 rptDate false string 报表日期 templateId true string 报表模板标识 templateName true string 报表模板名称 fileId true string 报表模板文件标识 rptId true string 报表标识 templateCode true string 报表模板编码
例子
{
"code": "200",
"message": "Get report templates successfully.",
"resultList": [ {
"rptDate": "2017-05-08",
"rptCode": "EITWP",
"templateId": "46AF3E0F-93F4-4071-8C05-5A2B81CE827B",
"templateName": "2015",
"fileId": null,
"rptId": "0E761840-5E10-4767-8BB5-60D21A33AE7D",
"templateCode": "EIT_WP_RW",
"description": "2015",
"version": 1,
"templateType": ""
}]
}
获取报表文件信息接口
- 代码ReportInfoController#getRptTmplDetail
- 注意这里因为无法获取servlet返回的body信息,所以根据了返回的statu判断是否生效成功,所以先在传递报表文件前生成了相对路径,然后将相对路径和报表文件传递给帆软的servlet,生效成功后借用了file的filename2字段保存了模板存放的相对路径.更多参考USRBaseRptTmplService
- 请求类型:HTTP
- 请求地址:http://localhost:8080/newBase/rpttmpldetail.do?templateId=5D49322A-6910-4C67-BF91-580F1494D229
- 请求方式:GET
- 响应类型:JSON
- 请求参数
templateId true string 模板id
- 返回
成功
{"code":"200","message":null,"resultList":[{"rptPath":"EITRPT\\20170517041508.xls"}]}
失败
{"code":"400","message":"ibz没有查询到数据,错误的主键","resultList":null}
报表文件上传
更新模板文件
- 进入报表模板管理
- 选择需要更新的报表,并点击模板管理
- 选择需要更新的版本,并点击更新模板
- 点击文件名称上的X删除原来的文件,点击上传更新文件
- 点击生效
客户端使用
- 将ReportTmplUtils,HttpClientUtil,PropertiesUtils_ibz,[[]]添加到项目
- 配置文件中配置baseurl和rpturl内容,例如
rpturl=http://10.173.20.11:8882/rpt baseurl=http://10.173.20.11:8882/newBase
- 根据报表code获取所用模板路径
try{
String tmplPath=ReportTmplUtils.getReportPath(filing.getPeriodEndDate(), "DTA_ANNUAL");
reportType=tmplPath+"&VERSION="+filing.getVersion()+"&FILLINGID="+filing.getId()+"&entityID="+filing.getLegalEntityId()+"&USERID="+WebContext.getCurrentUserId()+"&op=write";
}catch(Exception e){
erro=e.getMessage();
}
- 根据返回情况进行页面跳转
<script type="text/javascript">
function autoLoad(){
<%if(AssertHelper.notEmpty(erro)){%>
<%--var erro='<%=erro%>';--%>
<%--document.getElementById("erro").in(erro);--%>
<%}else{%>
var reportURL="<%=rpturl%>/ReportServer?reportlet=<%=reportType%>";
//将新的报表路径赋给报表所在iframe的src
document.getElementById("reportFrame").src = reportURL;
<%}%>
}
//加载网页时调用autoLoad方法
window.onload = autoLoad;
</script>
- iframe
<%@page import="com.deloitte.tms.reporttmpl.utils.AssertHelper"%>
<%@page import="com.deloitte.tms.reporttmpl.utils.PropertiesUtils"%>
<%@page import="java.util.Date"%>
<%@page import="com.deloitte.tms.reporttmpl.utils.ReportTmplUtils"%>
<%@include file="../common-rpt-resource.jsp"%>
<div class="fr">
<%
String reportType=null;
String erro=null;
String rpturl=PropertiesUtils.getProperty("rpturl");
try{
String tmplPath=ReportTmplUtils.getReportPath(new Date(), "TMS_MIS_PRO_CALDETAIL_VIEW");
reportType=tmplPath+"&USERID="+"&op=write";
}catch(Exception e){
erro=e.getMessage();
}
%>
<%if(AssertHelper.notEmpty(erro)){%>
<%=erro %>
<%}else{%>
<!--<iframe id="rfiframe" style="width: 100%; border: 0px; height: 400px;"
src="<%=rpturl%>/ReportServer?reportlet=<%=reportType%>"
frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes">
</iframe>-->
<iframe id="rfiframe" style="width: 100%; border: 0px; height: 400px;"
src="<%=fineRptUrl%>?reportlet=<%=reportType%>"
frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes">
</iframe>
<%}%>
</div>
- 更多参考ReportTmplUtils