견문보고서 첨부파일 일괄 다운로드 작업완료
parent
64261dd8ba
commit
eecc5c7e04
|
|
@ -31,6 +31,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -126,7 +127,7 @@ public class FileController extends BaseService{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/downloadAffairFiles")
|
@GetMapping("/downloadAffairFiles")
|
||||||
public void downloadAffairFiles(HttpServletRequest request,
|
public void downloadAffairFiles(HttpServletRequest request,
|
||||||
HttpServletResponse response,
|
HttpServletResponse response,
|
||||||
@RequestParam(value="affairKeyList") List<Integer> affairKeyList){
|
@RequestParam(value="affairKeyList") List<Integer> affairKeyList){
|
||||||
|
|
@ -147,10 +148,9 @@ public class FileController extends BaseService{
|
||||||
if (!saveFolder.exists() || saveFolder.isFile()) {
|
if (!saveFolder.exists() || saveFolder.isFile()) {
|
||||||
saveFolder.mkdirs();
|
saveFolder.mkdirs();
|
||||||
}
|
}
|
||||||
String downloadFileName = "견문보고서 첨부파일_"+ LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+".zip";
|
String downloadFileName = "견문보고서 첨부파일_"+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+".zip";
|
||||||
zipFile += File.separator+downloadFileName;
|
zipFile += File.separator+downloadFileName;
|
||||||
try{
|
try{
|
||||||
setDisposition(zipFile, request, response);
|
|
||||||
// ZipOutputStream을 FileOutputStream 으로 감쌈
|
// ZipOutputStream을 FileOutputStream 으로 감쌈
|
||||||
FileOutputStream fout = new FileOutputStream(zipFile);
|
FileOutputStream fout = new FileOutputStream(zipFile);
|
||||||
ZipOutputStream zout = new ZipOutputStream(fout);
|
ZipOutputStream zout = new ZipOutputStream(fout);
|
||||||
|
|
@ -177,6 +177,7 @@ public class FileController extends BaseService{
|
||||||
zout.close();
|
zout.close();
|
||||||
|
|
||||||
|
|
||||||
|
setDisposition(downloadFileName, request, response);
|
||||||
in=new BufferedInputStream(new FileInputStream(zipFile));
|
in=new BufferedInputStream(new FileInputStream(zipFile));
|
||||||
out=new BufferedOutputStream(response.getOutputStream());
|
out=new BufferedOutputStream(response.getOutputStream());
|
||||||
FileCopyUtils.copy(in, out);
|
FileCopyUtils.copy(in, out);
|
||||||
|
|
|
||||||
|
|
@ -154,27 +154,11 @@ $(document).on('click', '#fileDownBtn', function (){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(confirm("선택된 견문의 파일을 다운로드 하시겠습니까?")){
|
if(confirm("선택된 견문의 파일을 다운로드 하시겠습니까?")){
|
||||||
const formData = new FormData();
|
let url = "/file/downloadAffairFiles?affairKeyList="
|
||||||
$.each(selectedList, function(idx, chkBox){
|
$.each(selectedList, function(idx, chkBox){
|
||||||
formData.append("affairKeyList", $(chkBox).parents("tr").find(".affairKey").val());
|
url += $(chkBox).parents("tr").find(".affairKey").val()+",";
|
||||||
})
|
|
||||||
contentFade("in");
|
|
||||||
$.ajax({
|
|
||||||
type : 'POST',
|
|
||||||
data : formData,
|
|
||||||
url : "/file/downloadAffairFiles",
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
beforeSend: function (xhr){
|
|
||||||
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
|
||||||
},
|
|
||||||
success : function(result) {
|
|
||||||
contentFade("out");
|
|
||||||
},
|
|
||||||
error : function(xhr, status) {
|
|
||||||
contentFade("out");
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
window.open(encodeURI(url));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue