diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java index e3d556ce..b5feedda 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/CoEPALController.java @@ -1171,7 +1171,7 @@ public class CoEPALController { @Mapping("com.actionsoft.apps.coe.pal_outputreport_output_downloadZipfile") public String COEPALOUTPUTREPORTOutputProcessDownloadZipFILE(UserContext me, RequestParams params) throws Exception { UpfileWeb web = new UpfileWeb(me); - String uuid = params.get("uuid"); + String uuid = params.get("splitId"); return web.readZipFileDownLoad(uuid); } diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/web/UpfileWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/web/UpfileWeb.java index 808bbaf4..874a25fa 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/web/UpfileWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/upfile/web/UpfileWeb.java @@ -3,7 +3,7 @@ */ package com.actionsoft.apps.coe.pal.pal.repository.upfile.web; -import java.io.File; +import java.io.*; import java.sql.Timestamp; import java.util.*; import java.util.zip.ZipOutputStream; @@ -23,9 +23,8 @@ import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.Design import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil; import com.actionsoft.apps.coe.pal.util.HighSecurityUtil; -import com.actionsoft.apps.resource.AppContext; -import com.actionsoft.bpms.org.model.UserModel; import com.actionsoft.bpms.server.DispatcherRequest; +import com.actionsoft.bpms.server.conf.server.AWSServerConf; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -49,6 +48,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao; import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.api.AppAPI; +import org.apache.commons.compress.utils.IOUtils; /** * coe-附件处理web页面 @@ -415,54 +415,79 @@ public class UpfileWeb extends ActionWeb { * @return * @author zhaolei */ - public String readZipFileDownLoad(String uuid) throws Exception { + public String readZipFileDownLoad(String downloadZipFile) throws Exception { UserContext me = super.getContext(); ResponseObject ro = ResponseObject.newOkResponse(); UpFileDao upfileDao = new UpFileDao(); - //867f064e-de33-4dc6-bbe3-1180fcd389bd - //77cf13f0-8a71-43bb-bbda-fdaecb9af606 - //a355e064-6d45-44a0-a24a-b90270ca9044 + try { + + long times = System.currentTimeMillis(); + final String zipName = "批量下载"+ times + ".zip"; + String targetDir = AWSServerConf.getProperty("dc.path") + File.separator + "com.actionsoft.apps.coe.pal" + File.separator + "tmp/grouppackage/zip" + times + "/"; + File targetFileDir = new File(targetDir); + if (!targetFileDir.exists()) { + targetFileDir.mkdirs(); + } + + String uuids="287f7d3c-7034-4e88-a92c-8564ed041970,c42b7c14-b614-492c-a37d-e045ce86705a,0bef45da-a6d8-43c2-96e3-6476f62bb143"; + // 查找对应应用下模版 + String[] uuidSpilt=uuids.split(","); + if(uuidSpilt.length>0){ + for(String oneuuid:uuidSpilt){ + UpfileModel upfileModel = upfileDao.get(oneuuid); + DCContext dcContext = getDCContext(upfileModel); + File targetFile = new File(targetDir + dcContext.getFileName()); + if (!targetFile.exists()) { + targetFile.createNewFile(); + } + OutputStream out = new FileOutputStream(targetFile); + InputStream in = DCUtil.decryptFile(dcContext); + if (in == null) { + String msg = "+ dcContext.getFileName() + "; + if (dcContext.getDCMessage() != null) { + msg = dcContext.getDCMessage().getMessage(); + } + return ResponseObject.newErrResponse(msg).toString(); + } + try { + IOUtils.copy(in, out); + in.close(); + out.close(); + } finally { + IOUtils.closeQuietly(in); + IOUtils.closeQuietly(out); + } - String uuids="867f064e-de33-4dc6-bbe3-1180fcd389bd,77cf13f0-8a71-43bb-bbda-fdaecb9af606,a355e064-6d45-44a0-a24a-b90270ca9044"; - // 查找对应应用下模版 - List files = new ArrayList<>(); - String[] uuidSpilt=uuids.split(","); - if(uuidSpilt.length>0){ - for(String oneuuid:uuidSpilt){ - UpfileModel upfileModel = upfileDao.get(oneuuid); - DCContext dcContext = getDCContext(upfileModel); - UtilFile file = new UtilFile(dcContext.getPath()); - if (file.exists()) { - files.add(file); } } - } + UtilFile.zipCompress(targetDir, new File(targetDir + zipName)); - String outputAppId = CoEConstant.APP_ID; - String groupValue = "outputZipFile"; - String dirName = files.get(0).getName(); - dirName = dirName.substring(0, dirName.lastIndexOf(".")); - String fileValue = "download" + System.currentTimeMillis(); - - - DCContext dcContext = DCUtil.createTempFileContext(outputAppId, groupValue, fileValue, null); - try { - for (UtilFile sourceFile : files) { - UtilFile.copyFile(sourceFile, new UtilFile(dcContext.getPath() + File.separator + sourceFile.getName())); + File[] files = targetFileDir.listFiles(new FilenameFilter() + { + @Override + public boolean accept(File dir, String name) { + if (name.equals(zipName)) { + return false; + } + return true; + } + }); + for (File file : files) { + try { + file.delete(); + } catch (Exception exception) {} } - // 创建压缩包 - DCContext dcContext2 = DCUtil.createTempFileContext(outputAppId, groupValue, fileValue + "_zip", "zip"); - dcContext2.setFileName(dirName+ ".zip"); - File ff = new File(dcContext2.getFilePath()); - File f = new File(dcContext.getPath()); - UtilFile.zipCompress(f.getPath(), ff); - dcContext2.setSession(_uc); - ro = ResponseObject.newOkResponse(); - ro.put("url",dcContext2.getDownloadURL()); + + DCContext zipDcContext = new DCContext(getContext(), DCProfileManager.getDCProfile("com.actionsoft.apps.coe.pal", "tmp"), "com.actionsoft.apps.coe.pal", "grouppackage", "zip" + times, zipName); + + String downUrl=SDK.getConfAPI().getPortalUrl() + "/r/" + zipDcContext.getDownloadURL().replace("./", ""); + ro.put("url",downUrl); return ro.toString(); + } catch (Exception e) { e.printStackTrace(); + return ResponseObject.newErrResponse((e.getMessage() == null) ? e.getCause().getMessage() : e.getMessage()).toString(); } @@ -477,12 +502,18 @@ public class UpfileWeb extends ActionWeb { ro.put("url",downUrl); return ro.toString();*/ - return ResponseObject.newErrResponse("下载失败").toString(); + //return ResponseObject.newErrResponse("下载失败").toString(); } + + + + + + /** * 流程报告模版下载 * @param appId diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.js index 146ad9f7..8cd58044 100755 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.js +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.js @@ -1651,17 +1651,15 @@ function downloadProcessFile(taskId) { * 相关文件/制度文件下载 * @param uuid */ -function downloadZipFile(uuid) { - debugger; +function downloadZipFile(splitId) { $.ajax({ type : "POST", url : "./jd?sid=" + sid + "&cmd=com.actionsoft.apps.coe.pal_outputreport_output_downloadZipfile", data : { - uuid : uuid + splitId : splitId }, success : function(msg) { - debugger; if (msg.result == "ok") { window.location.href = msg.data.url; } @@ -1677,6 +1675,7 @@ function initUpfileData(obj) { if (obj == undefined || obj == '0') { /*$('#portalFileDock').empty();*/ var t = ''; + var splitId=''; var processFile = upfileData['file']; if(processFile.length > 0) { t += ''; @@ -1684,15 +1683,15 @@ function initUpfileData(obj) { t += '
文件附件:
'; for(var i = 0; i < processFile.length; i++) { var obj = processFile[i]; - t += '
'+ obj.name +''; - t +=''; + t +='';*/ t +='
'; + splitId+=obj.id+','; + } - - t += '
'; } @@ -1709,15 +1708,27 @@ function initUpfileData(obj) { t += '
' +"节点附件"+"("+ele.text +")"+ ':
'; for(var i = 0; i < processShape.length; i++) { var obj = processShape[i]; - t += '
'+ obj.name +'
'; - t +=''; + t +='';*/ t += ''; + + splitId+=obj.id+','; } - t += ''; + } } + + t += ''; + + if(splitId.length>0){ + splitId=splitId.substring(0,splitId.length-1); + t +=''; + } + $('#processFileDock').append(t); } else { $('#processFileDock table').show();