|
|
@@ -1,10 +1,6 @@
|
|
|
package com.goafanti.techservice.patent.controller;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.OutputStream;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
@@ -40,7 +36,7 @@ import com.goafanti.common.model.PatentInfo;
|
|
|
import com.goafanti.common.model.PatentLog;
|
|
|
import com.goafanti.common.model.PatentRegistration;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
-import com.goafanti.common.utils.DownloadUtils;
|
|
|
+import com.goafanti.common.utils.FileUtils;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
@@ -522,7 +518,7 @@ public class PatentApiController extends BaseApiController {
|
|
|
if (res.getError().isEmpty()) {
|
|
|
exportComosites(response, composites);
|
|
|
} else {
|
|
|
- DownloadUtils downloadUtils = new DownloadUtils();
|
|
|
+ FileUtils downloadUtils = new FileUtils();
|
|
|
downloadUtils.out(response, res.toString());
|
|
|
}
|
|
|
return res;
|
|
|
@@ -540,7 +536,7 @@ public class PatentApiController extends BaseApiController {
|
|
|
if (res.getError().isEmpty()) {
|
|
|
exportPendings(response, pendings);
|
|
|
} else {
|
|
|
- DownloadUtils downloadUtils = new DownloadUtils();
|
|
|
+ FileUtils downloadUtils = new FileUtils();
|
|
|
downloadUtils.out(response, res.toString());
|
|
|
}
|
|
|
return res;
|
|
|
@@ -562,7 +558,7 @@ public class PatentApiController extends BaseApiController {
|
|
|
if (res.getError().isEmpty()) {
|
|
|
exportFees(response, fees);
|
|
|
} else {
|
|
|
- DownloadUtils downloadUtils = new DownloadUtils();
|
|
|
+ FileUtils downloadUtils = new FileUtils();
|
|
|
downloadUtils.out(response, res.toString());
|
|
|
}
|
|
|
|
|
|
@@ -633,7 +629,7 @@ public class PatentApiController extends BaseApiController {
|
|
|
: calDeadline(obj.getPatentApplicationDateFormattedDate()));
|
|
|
|
|
|
}
|
|
|
- DownloadUtils downloadUtils = new DownloadUtils();
|
|
|
+ FileUtils downloadUtils = new FileUtils();
|
|
|
downloadUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
|
|
|
}
|
|
|
|
|
|
@@ -689,7 +685,7 @@ public class PatentApiController extends BaseApiController {
|
|
|
: calDeadline(obj.getAuthorizedDateFormattedDate()));
|
|
|
|
|
|
}
|
|
|
- DownloadUtils downloadUtils = new DownloadUtils();
|
|
|
+ FileUtils downloadUtils = new FileUtils();
|
|
|
downloadUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
|
|
|
}
|
|
|
|
|
|
@@ -720,7 +716,7 @@ public class PatentApiController extends BaseApiController {
|
|
|
row.createCell(10).setCellValue(obj.getPatentApplicationFormattedDate());
|
|
|
row.createCell(11).setCellValue(obj.getAuthor());
|
|
|
}
|
|
|
- DownloadUtils downloadUtils = new DownloadUtils();
|
|
|
+ FileUtils downloadUtils = new FileUtils();
|
|
|
downloadUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
|
|
|
|
|
|
}
|
|
|
@@ -754,7 +750,7 @@ public class PatentApiController extends BaseApiController {
|
|
|
@RequestMapping(value = "/patentFile", method = RequestMethod.POST)
|
|
|
public Result patentFile(HttpServletRequest req, String sign, String oid) {
|
|
|
Result res = new Result();
|
|
|
- String fileName = "";
|
|
|
+ /*String fileName = "";
|
|
|
if (StringUtils.isBlank(oid)) {
|
|
|
fileName = "/patent/" + TokenManager.getUserId() + "_" + sign + ".doc";
|
|
|
} else {
|
|
|
@@ -763,8 +759,9 @@ public class PatentApiController extends BaseApiController {
|
|
|
} else {
|
|
|
fileName = "/patent/" + oid + "_" + sign + ".jpg";
|
|
|
}
|
|
|
- }
|
|
|
- res.setData(handleFile(res, fileName, req));
|
|
|
+ }*/
|
|
|
+ //res.setData(handleFile(res, fileName, req));
|
|
|
+ res.setData(handleFile(res, "/patent/", true, req, sign, oid));
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@@ -774,11 +771,11 @@ public class PatentApiController extends BaseApiController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
|
|
|
- public Result downloadPatentProryStatement(HttpServletResponse response, HttpServletRequest request) {
|
|
|
+ public Result downloadPatentProryStatement(HttpServletResponse response, String fileName) {
|
|
|
Result res = new Result();
|
|
|
- String filename = "Patent" + Long.toString(System.nanoTime()) + ".doc";
|
|
|
- String fileSaveRootPath = uploadPrivatePath + "/patent/patent_prory_statement.doc";
|
|
|
- return patentDownload(res, response, filename, fileSaveRootPath);
|
|
|
+ FileUtils f = new FileUtils();
|
|
|
+ String path = "/patent/patent_prory_statement.doc";
|
|
|
+ return f.downloadFile(res, fileName, response, path);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -787,25 +784,18 @@ public class PatentApiController extends BaseApiController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
|
|
|
- public Result downloadPatentFile(HttpServletResponse response, String path, String sign,
|
|
|
- HttpServletRequest request) {
|
|
|
+ public Result downloadPatentFile(HttpServletResponse response, String path, String fileName) {
|
|
|
Result res = new Result();
|
|
|
if (StringUtils.isBlank(path)) {
|
|
|
res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "下载文件不存在!"));
|
|
|
return res;
|
|
|
}
|
|
|
- String filename = "";
|
|
|
- if (sign.equals("patent_prory_statement") || sign.equals("patent_writing")) {
|
|
|
- filename = Long.toString(System.nanoTime()) + ".doc";
|
|
|
- } else {
|
|
|
- filename = Long.toString(System.nanoTime()) + ".jpg";
|
|
|
- }
|
|
|
- String fileSaveRootPath = uploadPrivatePath + path;
|
|
|
- return patentDownload(res, response, filename, fileSaveRootPath);
|
|
|
+ FileUtils f = new FileUtils();
|
|
|
+ return f.downloadFile(res, fileName, response, path);
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Result patentDownload(Result res, HttpServletResponse response, String filename, String fileSaveRootPath) {
|
|
|
+ /*private Result patentDownload(Result res, HttpServletResponse response, String filename, String fileSaveRootPath) {
|
|
|
InputStream in = null;
|
|
|
OutputStream out = null;
|
|
|
byte[] buffer = new byte[8 * 1024];
|
|
|
@@ -839,13 +829,14 @@ public class PatentApiController extends BaseApiController {
|
|
|
}
|
|
|
return res;
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- private String handleFile(Result res, String fileName, HttpServletRequest req) {
|
|
|
+ private String handleFile(Result res, String path, boolean isPrivate, HttpServletRequest req, String sign, String oid) {
|
|
|
List<MultipartFile> files = getFiles(req);
|
|
|
+ MultipartFile mf = files.get(0);
|
|
|
+ String fileName = FileUtils.mosaicFileName(mf, isPrivate, sign, path, StringUtils.isBlank(oid) ? TokenManager.getUserId() : oid);
|
|
|
if (!files.isEmpty()) {
|
|
|
try {
|
|
|
- MultipartFile mf = files.get(0);
|
|
|
mf.transferTo(toPrivateFile(fileName));
|
|
|
LoggerUtils.debug(getClass(), fileName + " 文件上传成功");
|
|
|
} catch (IllegalStateException | IOException e) {
|