单个合同全部文件一键下载

This commit is contained in:
wendongchao 2019-08-05 16:59:19 +08:00
parent 17b1b267ae
commit bad72cf161
4 changed files with 84 additions and 5 deletions

View File

@ -32,15 +32,20 @@
if(sTempletNo==null){
sTempletNo="FlowPayDocList";
}
String type=CurPage.getParameter("type");
if(type==null)type="";
String docClassItemno=CurPage.getParameter("docList");
String[] itemnos=docClassItemno.split(",");
String s="";
String classItemno ="";
for(int i=0;i<itemnos.length;i++){
s+="'"+itemnos[i]+"',";
}
if(s.length()>0){
s=s.substring(0, s.length()-1);
classItemno = s.replace(",", "@");
}
if("ProjectCreditFlow".equals(sObjectType)){
sTempletNo = "FlowPayDocList" ;
@ -61,6 +66,8 @@
docParam.put("inputuserid", CurPage.getUserId());
docParam.put("inputorgid", CurPage.getUser().getOrgID());
String projectId = flow.getAttribute("proj_id").getString();
//判断是否存在,不存在就从配置表倒到临时表
DocListInitAction.initDocList(docParam,other,docClassItemno,CurConfig);
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
@ -91,6 +98,7 @@
sButtons=new String[][]{
{"true","","Button","保存","保存所有修改","saveRecord()","","","",""},
{"true","","Button","ÅúÁ¿ÏÂÔØ","ÅúÁ¿ÏÂÔØ","downloadZipFile()","","","","btn_icon_down"},
};
%>
@ -228,6 +236,18 @@ function deleteFile(id){
reloadSelf();
heping();
}
function downloadZipFile(){
var projectId="<%=projectId%>";
var classItemnos="<%=classItemno%>";
var sParams="projectId="+projectId+",classItemnos="+classItemnos;
var ids = RunJavaMethodTrans("com.tenwa.doc.action.DocListAction","getLibraryIds",sParams);
var filePath="<%=CurConfig.getConfigure("FileSavePath")%>";
var param="&flowunid=<%=flowunid%>&type=<%=type%>&ids="+ids;
if(!frames["downloadTemplate"]) $("<iframe name='downloadTemplate' style='display:none;'></iframe>").appendTo("body");
window.open(sWebRootPath+"/servlet/view/docFlowDownloadZipServlet?CompClientID=<%=sCompClientID%>&filePath="+filePath+param, "downloadTemplate");
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>

View File

@ -13,6 +13,8 @@ import javax.imageio.ImageIO;
import jbo.app.tenwa.doc.LB_DOCATTRIBUTE;
import jbo.app.tenwa.doc.LB_DOCCONFIG;
import jbo.app.tenwa.doc.LB_DOCLIBRARY;
import jbo.app.tenwa.doc.LB_DOCRELATIVE;
import com.amarsoft.are.ARE;
import com.amarsoft.are.jbo.BizObject;
@ -38,6 +40,10 @@ public class DocListAction {
public String lids;
public String classItemnos;
public String projectId;
public String deleteFile(JBOTransaction tx) throws Exception{
if(attId==null||attId==""){
@ -188,9 +194,44 @@ public class DocListAction {
jsonObject.appendElement("height",sourceImg.getHeight());
return JSONEncoder.encode(jsonObject);
}
public String getLibraryIds(JBOTransaction tx) throws JBOException{
String itemnos = classItemnos.replace("@", ",");
String sql = "SELECT O.ID from O "
+ " left join jbo.app.tenwa.doc.LB_DOCRELATIVE rela on rela.id=O.relative_Id"
+ " where rela.proj_id='"+projectId+"' and rela.objecttype='BusinessApplyFlow'"
+ " and O.doc_Class_Itemno in ("+itemnos+")"
+ " ORDER BY DOC_CLASS_ITEMNO,Serial_Num";
BizObjectManager relaBm = JBOFactory
.getBizObjectManager(LB_DOCLIBRARY.CLASS_NAME);
List<BizObject> rela = relaBm.createQuery(sql).getResultList(false);
String libId = "";
for(BizObject biz : rela){
libId += biz.getAttribute("ID").toString()+"@";
}
libId = libId.substring(0, libId.length()-1);
return libId;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getClassItemnos() {
return classItemnos;
}
public void setClassItemnos(String classItemnos) {
this.classItemnos = classItemnos;
}
public String getConfigid() {
return configid;
}

View File

@ -77,7 +77,7 @@ import com.tenwa.util.ZipFileUtil;
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
for(BizObject lib:libs){
@SuppressWarnings("unchecked")
List<BizObject> attrs=JBOFactory.createBizObjectQuery(LB_DOCATTRIBUTE.CLASS_NAME,"library_id=:id").setParameter("id",lib.getAttribute("id").getString()).getResultList(false);
List<BizObject> attrs=JBOFactory.createBizObjectQuery(LB_DOCATTRIBUTE.CLASS_NAME,"library_id=:id and DELETEED is null").setParameter("id",lib.getAttribute("id").getString()).getResultList(false);
if(attrs.size()==0){
continue;
}

View File

@ -3,11 +3,14 @@ package com.tenwa.util;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.mozilla.javascript.edu.emory.mathcs.backport.java.util.Collections;
import org.springframework.security.core.authority.mapping.MappableAttributesRetriever;
public class ZipFileUtil {
/**
@ -21,6 +24,7 @@ public class ZipFileUtil {
if(!path.endsWith("/")){
path+="/";
}
HashMap<String,Integer> map = new HashMap<String,Integer>();
byte[] buf = new byte[1024];
try {
if(srcFiles.size()==0){
@ -40,11 +44,25 @@ public class ZipFileUtil {
zipFiles(out,path+srcPath,as,null);
}
else{
FileInputStream in = new FileInputStream(srcFiles.get(i));
String filename= srcFiles.get(i).getName();
if(filenames!=null){
filename=filenames.get(i);
/**
* 文件输出流写入相同的文件名到相同的地址时会出错
* 当遇到相同的文件名时放到map中之后改变文件名
* 第一次放入key,1
* 第二次若相同1++
* 若不同放入key1
*/
String filename= filenames.get(i);
if(map.get(filename)==null){
map.put(filename, 1);
}else{
int num = map.get(filename)+1;
map.put(filename,num);
}
if(1!=map.get(filename)){
String[] arr = filenames.get(i).split("\\.");
filename = arr[0]+"("+map.get(filename)+")."+arr[1];
}
FileInputStream in = new FileInputStream(srcFiles.get(i));
out.putNextEntry(new ZipEntry(path + filename));
int len;
while((len=in.read(buf))>0){