32dfc37a1c513a1b41a820f20d9f46d32beb6dc8.svn-base 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
  2. <%@ page
  3. import = "com.sysmodel.datamodel.xmlmodel.ModelFactory"
  4. import = "com.sysmodel.datamodel.xmlmodel.able.SysModel"
  5. import = "com.persistence.service.SysPersistence"
  6. import = "com.persistence.service.PersistenceFactory"
  7. import = "javax.servlet.ServletOutputStream"
  8. import = "java.io.PrintWriter"
  9. import = "java.util.ArrayList"
  10. import = "com.sinosoft.common.upLoad.util.*"
  11. import = "com.sinosoft.common.upLoad.service.UploadManageable"
  12. import = "com.sinosoft.common.upLoad.service.UploadManageImpl"
  13. import = "java.net.URLDecoder"
  14. import = "com.sinosoft.am.zip.ZipFileUtil"
  15. import = "com.system.configer.vo.WSClientConfigure"
  16. import = "org.springframework.context.support.ClassPathXmlApplicationContext"
  17. import = "java.io.File"
  18. import = "java.lang.String"
  19. import = "java.util.Map"
  20. import = "java.util.HashMap"
  21. %>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  23. <%@page import="java.io.OutputStream"%>
  24. <%@page import="java.net.URLDecoder"%><html>
  25. <head>
  26. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  27. <meta http-equiv="Content-Language" content="UTF-8" />
  28. </head>
  29. <body>
  30. <%
  31. response.setCharacterEncoding("UTF-8");
  32. String objectID = request.getParameter("objectID") == null ? "" : request.getParameter("objectID");
  33. //String classId = request.getParameter("classid") == null ? "" : request.getParameter("classid");
  34. //存储的文件名 Sys_Comm_FileImg NAME + "." + FILEEXT;如果有多个,就用";"隔开。
  35. String filenames = request.getParameter("filenames") == null ? "" : request.getParameter("filenames");
  36. //保存的文件名。Sys_Comm_FileImg SAVENAME+ "." + FILEEXT;如果有多个,就用";"隔开。
  37. String downfilename = request.getParameter("downfilename") == null ? "" : request.getParameter("downfilename");
  38. //autopath=false 自己传入完整路径文件
  39. String autopath = request.getParameter("autopath") == null ? "" : request.getParameter("autopath");
  40. //optmethod 文件处理方式
  41. //open 打开文件
  42. String optmethod = request.getParameter("optmethod") == null ? "" : request.getParameter("optmethod");
  43. filenames = URLDecoder.decode(filenames, "UTF-8");
  44. downfilename = URLDecoder.decode(downfilename, "UTF-8");
  45. String uploadType = request.getParameter("uploadType") == null ? "path" : "blob";
  46. //filenames = new String(filenames.getBytes("iso-8859-1"),"utf-8");
  47. response.reset();
  48. //获取文件存储的位置upload文件夹的位置
  49. WSClientConfigure configure = (WSClientConfigure) new ClassPathXmlApplicationContext(
  50. "applicationContext.xml").getBean("WSClientConfigure");
  51. String downloadPath = request.getSession().getServletContext()
  52. .getRealPath(configure.getUploadPath());
  53. try {
  54. String zipfileName = ZipFileUtil.getZipFileName()+".zip";
  55. //String zipFilePath = "e:\\ziptest\\rawfiles";
  56. Map<String,String> fileNames = new HashMap<String,String>();
  57. String[] filenames_map = filenames.split(";");
  58. String[] downfilename_map = downfilename.split(";");
  59. for(int i =0;i<downfilename_map.length;i++){
  60. System.out.println(downfilename_map[i]+"====="+filenames_map[i]);
  61. fileNames.put(downfilename_map[i],filenames_map[i]);
  62. }
  63. /* fileNames.put("58c36694-07ab-4309-9b01-56ad6c7a659a.docx","1.docx");
  64. fileNames.put("bdd11e1b-cb66-4984-a1c0-7a954407cd80.xlsx","2.xlsx");
  65. fileNames.put("f9960587-14e8-4142-8020-19c052dec28e.xlsx","3.xlsx"); */
  66. boolean flag = false;
  67. if(filenames!=""&&downfilename!=""){
  68. //压缩文件
  69. flag = ZipFileUtil.zip(downloadPath, downloadPath, zipfileName, fileNames);
  70. }
  71. OutputStream sout = response.getOutputStream();
  72. //判断下载方式
  73. System.out.println(autopath);
  74. if (uploadType.equalsIgnoreCase("path")&&flag ==true) {
  75. UploadManageable upload = new UploadManageImpl();
  76. if("false".equalsIgnoreCase(autopath.trim())){
  77. upload.downloadFile(request, response, zipfileName, false, zipfileName);
  78. }else{
  79. upload.downloadFile(request, response, zipfileName, true, zipfileName);
  80. }
  81. }else if (uploadType.equalsIgnoreCase("blob")&&flag ==true){
  82. SysModel sysmodel = ModelFactory.getSysmodel();
  83. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  84. persistence.readBlobToOutputStream(110,objectID,"FileContents",sout);
  85. }
  86. out.clear();
  87. out = pageContext.pushBody();
  88. }catch (Exception e) {
  89. e.printStackTrace();
  90. }
  91. %>
  92. </body>
  93. </html>