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