2018-06-03 22:26:41 +08:00

171 lines
6.6 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@page import="com.amarsoft.biz.formatdoc.model.FormatDocHelp"%>
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/IncludeBeginMD.jsp"%><%
/*
Author: xdhou 2005.02.25
Content: 从FORMATDOC_DATA生成文件
Input Param:
DocID: formatdoc_catalog中的文档类别调查报告贷后检查报告...)
ObjectNo业务流水号
Output param:
History Log: cdeng 2009-02-12 修改文档存储路径,增加以当年年份命名的目录
*/
//获得组件参数
String sObjectNo = CurPage.getParameter("ObjectNo");
String sObjectType = CurPage.getParameter("ObjectType");
String sDocID = CurPage.getParameter("DocID");
String sCustomerID = CurPage.getParameter("CustomerID");
String sAttribute = CurPage.getParameter("Attribute");
String sOrgID = FormatDocHelp.getBranchOrgID(CurOrg.getOrgID());
%>
<html>
<head>
<title>调查报告</title>
<script type="text/javascript">
function mykd1(){
//F3:F5:F11:FullScreen
if(event.keyCode==114 || event.keyCode==116 || event.keyCode==122 || (event.keyCode==78 && event.ctrlKey) ){
event.keyCode=0;
event.returnValue=false;
return false;
}
}
function mykd2(){
if(myprint10.event.keyCode==114 || myprint10.event.keyCode==116 || myprint10.event.keyCode==122 || (myprint10.event.keyCode==78 && myprint10.event.ctrlKey) ) //F3:F11:FullScreen
{
myprint10.event.keyCode=0;
myprint10.event.returnValue=false;
return false;
}
}
</script>
</head>
<body onkeydown=mykd1 >
<font color=red style="font-size: 16pt;FONT-FAMILY:'宋体';color:red;background-color:#FFFFFF">正在打开报告,请稍候......</font>
<BR>
<iframe name="myprint10" width=0% height=0% style="display:none" frameborder=1></iframe>
</body>
</html>
<script type="text/javascript">
try { document.body.onkeydown=mykd1; } catch(e) {var a=1;}
try { document.onkeydown=mykd1; } catch(e) {var a=1;}
try { myprint10.document.body.onkeydown=mykd2; } catch(e) {var a=1;}
try { myprint10.document.onkeydown=mykd2; } catch(e) {var a=1;}
</script>
<%
StringTokenizer st = null;
String sDirID = "";
String sSql = "",sSerialNo="";
String Produce="Yes";
int i=0; //已完成报告页数
st = new StringTokenizer(sAttribute,",");
while(st.hasMoreTokens()){
sDirID += "'"+st.nextToken()+"',";
}
if(sDirID.length()>=1)
sDirID = sDirID.substring(0,sDirID.length()-1);
else{
Produce="No";
}
if(Produce.equals("Yes")){
sSql = " select O.serialno,O.objectno,O.docid,O.dirid,O.dirname,f2.jspfilename " +
" from O,jbo.formatdoc.FORMATDOC_DEF f2" +
" where f2.docid=O.docid and f2.dirid =O.dirid and O.dirid in ("+sDirID+")"+
" and O.objectno='"+sObjectNo+"' and O.objecttype='"+sObjectType+"' and O.docid='"+sDocID+"' "+
" and f2.JspFileName is not null and f2.JspFileName <>'NULL'"+
" order by treeno ";
//out.println(sSql);
List<BizObject> list = JBOFactory.createBizObjectQuery("jbo.formatdoc.FORMATDOC_DATA", sSql).getResultList(false);
String sFirstSection = "1";
for(BizObject bo : list){
sSerialNo = bo.getAttribute("serialno").getString();
String sJspFileName = DataConvert.toString(bo.getAttribute("jspfilename").getString());
String sDirName = DataConvert.toString(bo.getAttribute("dirname").getString());
out.println("*************"+sDirName+"***********************完成"+"<br>");
if(!sJspFileName.trim().equals("")){
i++;
if(i==list.size()){
//尾页
sFirstSection = "END";
}else if(i>1){
sFirstSection = "0";
}
%>
<script type="text/javascript">
PopPageAjax("<%=sJspFileName%>?DocID=<%=sDocID%>&ObjectNo=<%=sObjectNo%>&ObjectType=<%=sObjectType%>&SerialNo=<%=sSerialNo%>&CustomerID=<%=sCustomerID%>&Method=4&FirstSection=<%=sFirstSection%>&Attribute=<%=sAttribute%>&rand="+randomNumber(),"myprint10","dialogWidth=10;dialogHeight=1;status:no;center:yes;help:no;minimize:yes;maximize:no;border:thin;statusbar:no");
</script>
<%
}else{ //如果没有jsp,仅为一个标题
String sSerialNoNew = MessageDigest.getDigestAsUpperHexString("MD5", sDocID+sObjectNo+sObjectType);
//判断路径是否存在,如果不存在自动创建;文档存储路径中增加以当年年份命名的目录 cdeng 2009-02-12
java.io.File dFile=null;
String sBasePath = CurConfig.getConfigure("WorkDocSavePath");
if(sBasePath ==null || sBasePath.equals(""))
sBasePath=application.getRealPath("/FormatDoc/WorkDoc");
String sFileSavePath=sBasePath+"/"+StringFunction.getToday().substring(0,4);
try {
dFile=new java.io.File(sFileSavePath);
if(!dFile.exists()) {
dFile.mkdirs();
}
}catch (Exception e) {
ARE.getLog().error(e.getMessage(),e);
throw e;
}
String sFileName = sFileSavePath+"/"+sSerialNoNew+".html";
java.io.File file = new java.io.File(sFileName);
java.io.FileOutputStream fileOut = null;
String sSql1="",sSavePath="",sfSerialNo="",sSql2="";
BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.formatdoc.FORMATDOC_RECORD");
BizObject boRD = null;
if(sFirstSection.equals("1")){
sSql1=" select SerialNo,SavePath from O where ObjectType=:ObjectType and ObjectNo=:ObjectNo and DocID=:DocID";
boRD = bm.createQuery(sSql1).setParameter("ObjectType", sObjectType).setParameter("ObjectNo", sObjectNo).setParameter("DocID", sDocID).getSingleResult(true);
if(boRD != null){
sfSerialNo = boRD.getAttribute("SerialNo").getString();
sSavePath = boRD.getAttribute("SavePath").getString();
}
if(sfSerialNo==null) sfSerialNo="";
if(sSavePath==null) sSavePath="";
if(sfSerialNo.equals("")){
boRD = bm.newObject();
boRD.setAttributeValue("SerialNo", sSerialNo).setAttributeValue("ObjectType", sObjectType).setAttributeValue("ObjectNo", sObjectNo)
.setAttributeValue("DocID", sDocID).setAttributeValue("SavePath", sFileName);
}else if(!sfSerialNo.equals("") && !sSavePath.equals(sFileName)){
boRD.setAttributeValue("SavePath", sFileName);
}
}
if(sFirstSection.equals("1")){
fileOut = new java.io.FileOutputStream(file,false);
sFirstSection = "0";
}else{
fileOut = new java.io.FileOutputStream(file,true);
}
String sContent = bo.getAttribute("dirname").getString()+"<br>";
fileOut.write(sContent.getBytes());
fileOut.close();
if(sFirstSection.equals("1")){
bm.saveObject(boRD);
}
}
}
}
%>
<script type="text/javascript">
if("<%=Produce%>"=='Yes'){
OpenPage("/FormatDoc/PreviewFile.jsp?DocID=<%=sDocID%>&ObjectNo=<%=sObjectNo%>&ObjectType=<%=sObjectType%>","_self");
}else{
alert("无打印节点,请选择打印节点!");
self.close();
}
</script>
<%@ include file="/IncludeEnd.jsp"%>