Commit 0e17af31 authored by 王琮's avatar 王琮

打包

parent 1aede14e
...@@ -147,9 +147,9 @@ public class FileCtrl { ...@@ -147,9 +147,9 @@ public class FileCtrl {
fileName = file.getFileName(); fileName = file.getFileName();
String originPath = ""; String originPath = "";
if (fileNum.startsWith("http")) { if (fileNum.startsWith("http")) {
originPath = fileNum; originPath = fileName;
} else { } else {
originPath = this.getfileUrl() + fileNum; originPath = this.getfileUrl() + fileName;
} }
String targetPath = myPath + fileName; String targetPath = myPath + fileName;
...@@ -197,7 +197,7 @@ public class FileCtrl { ...@@ -197,7 +197,7 @@ public class FileCtrl {
outputStream.write(data); outputStream.write(data);
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
zipFileDownLoad.delete(); //zipFileDownLoad.delete();
} else { } else {
System.out.println("下载的文件不存在"); System.out.println("下载的文件不存在");
} }
...@@ -220,7 +220,7 @@ public class FileCtrl { ...@@ -220,7 +220,7 @@ public class FileCtrl {
map.put("fileName", myfile.getOriginalFilename()); map.put("fileName", myfile.getOriginalFilename());
map.put("fileID", uuid); map.put("fileID", uuid);
byte[] buffer = myfile.getBytes(); byte[] buffer = myfile.getBytes();
FileOutputStream fos = new FileOutputStream(this.getfileUrl() + fileNum); FileOutputStream fos = new FileOutputStream(this.getfileUrl() + myfile.getOriginalFilename());
fos.write(buffer); fos.write(buffer);
fos.close(); fos.close();
File file = new File(); File file = new File();
......
...@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -204,11 +205,11 @@ public class QuestionnaireCtrl { ...@@ -204,11 +205,11 @@ public class QuestionnaireCtrl {
} }
@RequestMapping({"downZipByFileId"}) @RequestMapping({"downZipByFileId"})
public String downZipByFileId(Long id, HttpServletRequest request, HttpServletResponse response) throws IOException { public String downZipByFileId(@RequestParam Long optionId, HttpServletResponse response) throws IOException {
String forwardName = "/user/file"; String forwardName = "/user/file";
//1.根据选项查询文件列表 //1.根据选项查询文件列表
String forderName = UUIDUtils.getUUID(); String forderName = UUIDUtils.getUUID();
String tempPath = this.getfileUrl(); String tempPath = this.getFileUrl();
String zipName="上传文件"; String zipName="上传文件";
String fileName; String fileName;
String myPath = tempPath + forderName + "/" + zipName + "/"; String myPath = tempPath + forderName + "/" + zipName + "/";
...@@ -216,7 +217,7 @@ public class QuestionnaireCtrl { ...@@ -216,7 +217,7 @@ public class QuestionnaireCtrl {
if (!fileForExists.exists()) { if (!fileForExists.exists()) {
FileUtil.mkdirFolders(myPath); FileUtil.mkdirFolders(myPath);
} }
List<String> fileID = this.fileServer.selectFileId(id); List<String> fileID = this.fileServer.selectFileId(optionId);
for(int i=0;i<fileID.size();++i) { for(int i=0;i<fileID.size();++i) {
File file = this.fileServer.selectFileByFileID(fileID.get(i)); File file = this.fileServer.selectFileByFileID(fileID.get(i));
try { try {
...@@ -225,9 +226,9 @@ public class QuestionnaireCtrl { ...@@ -225,9 +226,9 @@ public class QuestionnaireCtrl {
fileName = file.getFileName(); fileName = file.getFileName();
String originPath = ""; String originPath = "";
if (fileNum.startsWith("http")) { if (fileNum.startsWith("http")) {
originPath = fileNum; originPath = fileName;
} else { } else {
originPath = this.getfileUrl() + fileNum; originPath = this.getFileUrl() + fileName;
} }
String targetPath = myPath + fileName; String targetPath = myPath + fileName;
StringBuffer fileNameForRepeat = new StringBuffer(); StringBuffer fileNameForRepeat = new StringBuffer();
...@@ -270,7 +271,7 @@ public class QuestionnaireCtrl { ...@@ -270,7 +271,7 @@ public class QuestionnaireCtrl {
outputStream.write(data); outputStream.write(data);
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
zipFileDownLoad.delete(); //zipFileDownLoad.delete();
} else { } else {
System.out.println("下载的文件不存在"); System.out.println("下载的文件不存在");
} }
...@@ -280,7 +281,7 @@ public class QuestionnaireCtrl { ...@@ -280,7 +281,7 @@ public class QuestionnaireCtrl {
return null; return null;
} }
private String getfileUrl() throws IOException { private String getFileUrl() throws IOException {
if ("".equals(fileUrl)) { if ("".equals(fileUrl)) {
Properties props = new Properties(); Properties props = new Properties();
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("file.properties"); InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("file.properties");
......
...@@ -156,7 +156,6 @@ public class FileUtil { ...@@ -156,7 +156,6 @@ public class FileUtil {
public static File copyFileByPath(String originPath, String targetPath, String targetPathForRepeat) throws IOException { public static File copyFileByPath(String originPath, String targetPath, String targetPathForRepeat) throws IOException {
File targetFile = new File(targetPath); File targetFile = new File(targetPath);
try { try {
BufferedInputStream input = null; BufferedInputStream input = null;
if (originPath.startsWith("http")) { if (originPath.startsWith("http")) {
...@@ -173,20 +172,16 @@ public class FileUtil { ...@@ -173,20 +172,16 @@ public class FileUtil {
byte[] buffer = new byte[1048576]; byte[] buffer = new byte[1048576];
int bytesum = 0; int bytesum = 0;
boolean var8 = false;
int byteread; int byteread;
while((byteread = input.read(buffer)) != -1) { while((byteread = input.read(buffer)) != -1) {
bytesum += byteread; bytesum += byteread;
fps.write(buffer, 0, byteread); fps.write(buffer, 0, byteread);
fps.flush(); fps.flush();
} }
fps.close(); fps.close();
input.close(); input.close();
} catch (Exception var9) { } catch (Exception var9) {
} }
return targetFile; return targetFile;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment