1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
- <%@ page
- import = "com.sysmodel.datamodel.xmlmodel.ModelFactory"
- import = "com.sysmodel.datamodel.xmlmodel.able.SysModel"
- import = "com.persistence.service.SysPersistence"
- import = "com.persistence.service.PersistenceFactory"
- import = "javax.servlet.ServletOutputStream"
- import = "java.io.PrintWriter"
- import = "java.util.ArrayList"
- import = "com.sinosoft.common.upLoad.util.*"
- import = "com.sinosoft.common.upLoad.service.UploadManageable"
- import = "com.sinosoft.common.upLoad.service.UploadManageImpl"
- import = "java.net.URLDecoder"
- import = "com.sinosoft.am.zip.ZipFileUtil"
- import = "com.system.configer.vo.WSClientConfigure"
- import = "org.springframework.context.support.ClassPathXmlApplicationContext"
- import = "java.io.File"
- import = "java.lang.String"
- import = "java.util.Map"
- import = "java.util.HashMap"
- %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <%@page import="java.io.OutputStream"%>
- <%@page import="java.net.URLDecoder"%><html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta http-equiv="Content-Language" content="UTF-8" />
- </head>
- <body>
- <%
- response.setCharacterEncoding("UTF-8");
- String objectID = request.getParameter("objectID") == null ? "" : request.getParameter("objectID");
- //String classId = request.getParameter("classid") == null ? "" : request.getParameter("classid");
- //存储的文件名 Sys_Comm_FileImg NAME + "." + FILEEXT;如果有多个,就用";"隔开。
- String filenames = request.getParameter("filenames") == null ? "" : request.getParameter("filenames");
- //保存的文件名。Sys_Comm_FileImg SAVENAME+ "." + FILEEXT;如果有多个,就用";"隔开。
- String downfilename = request.getParameter("downfilename") == null ? "" : request.getParameter("downfilename");
- //autopath=false 自己传入完整路径文件
- String autopath = request.getParameter("autopath") == null ? "" : request.getParameter("autopath");
- //optmethod 文件处理方式
- //open 打开文件
- String optmethod = request.getParameter("optmethod") == null ? "" : request.getParameter("optmethod");
- filenames = URLDecoder.decode(filenames, "UTF-8");
- downfilename = URLDecoder.decode(downfilename, "UTF-8");
- String uploadType = request.getParameter("uploadType") == null ? "path" : "blob";
- //filenames = new String(filenames.getBytes("iso-8859-1"),"utf-8");
- response.reset();
- //获取文件存储的位置upload文件夹的位置
- WSClientConfigure configure = (WSClientConfigure) new ClassPathXmlApplicationContext(
- "applicationContext.xml").getBean("WSClientConfigure");
- String downloadPath = request.getSession().getServletContext()
- .getRealPath(configure.getUploadPath());
- try {
- String zipfileName = ZipFileUtil.getZipFileName()+".zip";
- //String zipFilePath = "e:\\ziptest\\rawfiles";
- Map<String,String> fileNames = new HashMap<String,String>();
- String[] filenames_map = filenames.split(";");
- String[] downfilename_map = downfilename.split(";");
-
- for(int i =0;i<downfilename_map.length;i++){
- System.out.println(downfilename_map[i]+"====="+filenames_map[i]);
- fileNames.put(downfilename_map[i],filenames_map[i]);
- }
- /* fileNames.put("58c36694-07ab-4309-9b01-56ad6c7a659a.docx","1.docx");
- fileNames.put("bdd11e1b-cb66-4984-a1c0-7a954407cd80.xlsx","2.xlsx");
- fileNames.put("f9960587-14e8-4142-8020-19c052dec28e.xlsx","3.xlsx"); */
- boolean flag = false;
- if(filenames!=""&&downfilename!=""){
- //压缩文件
- flag = ZipFileUtil.zip(downloadPath, downloadPath, zipfileName, fileNames);
- }
-
- OutputStream sout = response.getOutputStream();
-
- //判断下载方式
- System.out.println(autopath);
- if (uploadType.equalsIgnoreCase("path")&&flag ==true) {
- UploadManageable upload = new UploadManageImpl();
-
- if("false".equalsIgnoreCase(autopath.trim())){
- upload.downloadFile(request, response, zipfileName, false, zipfileName);
- }else{
- upload.downloadFile(request, response, zipfileName, true, zipfileName);
- }
- }else if (uploadType.equalsIgnoreCase("blob")&&flag ==true){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- persistence.readBlobToOutputStream(110,objectID,"FileContents",sout);
- }
- out.clear();
- out = pageContext.pushBody();
- }catch (Exception e) {
- e.printStackTrace();
- }
- %>
- </body>
- </html>
|