package kcc.kccadr.accdnt.ars.web; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.FileUtils; import org.apache.pdfbox.pdmodel.PDDocument; import org.quartz.JobKey; import org.quartz.Scheduler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.quartz.SchedulerFactoryBean; import org.springframework.stereotype.Controller; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.epapyrus.common.util.UriUtils; import com.epapyrus.pdf.pg.client.PdfGatewayAgent; import com.epapyrus.pdf.pg.entity.BookMark; import com.epapyrus.pdf.pg.entity.BookMarkPage; import com.epapyrus.pdf.pg.entity.Merge; import com.epapyrus.pdf.pg.entity.PdfConversion; import com.epapyrus.pdf.pg.entity.TextWatermark; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; import kcc.com.cmm.service.EgovFileMngService; import kcc.com.cmm.service.FileVO; import kcc.com.cmm.util.StreamDocsUtil; import kcc.kccadr.accdnt.ai.service.AdjstIncidentService; import kcc.kccadr.accdnt.ai.service.AdjstIncidentVO; import kcc.kccadr.accdnt.ars.service.AdjstReqStatusService; import kcc.kccadr.adjst.service.AdjstReqService; import kcc.kccadr.adjst.service.AdjstReqVO; import kcc.kccadr.cmm.service.PdfConversionService; import kcc.kccadr.cmm.service.PdfConversionVO; import kcc.let.utl.fcc.service.EgovCryptoUtil; /** * 대국민(사용자) * 조정사건 관한 pdf controller 클래스를 정의한다. * @author 김봉호 * @since 2021.08.23 * @version 1.0 * @see * *
 * << 개정이력(Modification Information) >>
 *
 *   수정일      수정자           수정내용
 *  -------    --------    ---------------------------
 *   2021.08.23  김봉호          최초 생성
 *
 * 
*/ @Controller public class AdjstReqStatusPdfController { private static final Logger LOGGER = LoggerFactory.getLogger(AdjstReqStatusPdfController.class); @Resource(name="adjstReqStatusService") private AdjstReqStatusService adjstReqStatusService; @Resource(name="adjstIncidentService") private AdjstIncidentService adjstIncidentService; //암복호화 유틸 @Resource(name = "egovCryptoUtil") EgovCryptoUtil egovCryptoUtil; //암복호화 유틸 @Resource(name = "EgovFileMngService") EgovFileMngService egovFileMngService; //adr_mgr_master @Resource(name="AdjstReqService") private AdjstReqService adjstReqService; // //pdf 변환 서버 관련 설정 // @Value("#{globalSettings['Globals.pdf.serverUrl']}") // private String pdfServerUrl; //192.168.0.200 // // @Value("#{globalSettings['Globals.pdf.apiUrl']}") // private String pdfApiUrl; //http://192.168.0.34:7080 // // @Value("#{globalSettings['Globals.pdf.filepath.out']}") // private String pdfFilepathOut; //file:/c:/usr/local/tomcat/file/sht/out // // @Value("#{globalSettings['Globals.pdf.makepath']}") // private String pdfMakepath; //c:/usr/local/tomcat/file/sht // // @Value("#{globalSettings['Globals.pdf.makepath.out']}") // private String pdfMakepathOut; //c:/usr/local/tomcat/file/sht/out // // @Value("#{globalSettings['Globals.pdf.webpath']}") // private String pdfWebpath; // /pdf/out/ //pdf 변환 서버 관련 설정 private static String pdfServerUrl; //192.168.0.200 @Value("#{globalSettings['Globals.pdf.serverUrl']}") public void setPdfServerUrl(String path) { pdfServerUrl = path; } private static String pdfApiUrl; //http://192.168.0.34:7080 @Value("#{globalSettings['Globals.pdf.apiUrl']}") public void setPdfApiUrl(String path) { pdfApiUrl = path; } private static String pdfFilepathOut; //file:/c:/usr/local/tomcat/file/sht/out @Value("#{globalSettings['Globals.pdf.filepath.out']}") public void setPdfFilepathOut(String path) { pdfFilepathOut = path; } private static String pdfMakepath; //c:/usr/local/tomcat/file/sht @Value("#{globalSettings['Globals.pdf.makepath']}") public void setPdfMakepath(String path) { pdfMakepath = path; } private static String pdfMakepathOut; //c:/usr/local/tomcat/file/sht/out @Value("#{globalSettings['Globals.pdf.makepath.out']}") public void setPdfMakepathOut(String path) { pdfMakepathOut = path; } private static String pdfWebpath; // /pdf/out/ @Value("#{globalSettings['Globals.pdf.webpath']}") public void setPdfWebpath(String path) { pdfWebpath = path; } //배치 스케쥴러 bean @Autowired SchedulerFactoryBean schedulerBean; //pdf 변환 service @Resource(name="PdfConversionService") private PdfConversionService pdfConversionService; /** * 조정진행 상세 Tab 조정진행 화면 - 선택다운로드 1단계 * 1.대상폴더 생성 * 2.변환 요청 * 조정신청서 요청 * 3.결과 통보 */ @RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusDownloadStep1Ajax.do") public ModelAndView adjstReqStatusTabStatusDownloadStep1Ajax( HttpServletRequest request , AdjstIncidentVO adjstIncidentVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); //System.out.println("adjstReqStatusTabStatusStep1Ajax"); try { //step.1.폴더 생성======================================================================= //String path = "D:\\Eclipse\\Java\\새폴더"; //폴더 경로 String s_time_dir = request.getParameter("time_dir"); //download 폴더 { String path_pdf = pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/download/"+s_time_dir; //pdf 변환기가 생성하는 파일이 들어가는 폴더경로 String path_pdf_4d = pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/download"; //pdf 변환기가 생성하는 파일이 들어가는 폴더경로 File Folder_pdf = new File(path_pdf); File Folder_pdf_4d = new File(path_pdf_4d); // 해당 디렉토리가 없을경우 디렉토리를 생성합니다. if (!Folder_pdf.exists()) { try{ this.deleteFile(path_pdf_4d, s_time_dir); } catch(Exception e){ System.out.println("Exception Occured!!!"); } try{ Folder_pdf_4d.mkdirs(); //폴더 생성합니다. Folder_pdf.mkdirs(); //폴더 생성합니다. System.out.println("D 폴더가 생성되었습니다."); //System.out.println(path_pdf); } catch(Exception e){ System.out.println("Exception Occured!!!"); } }else { System.out.println("D 이미 폴더가 생성되어 있습니다."); this.deleteFile(path_pdf_4d, s_time_dir); //System.out.println(path_pdf); Folder_pdf.mkdirs(); //폴더 생성합니다. } } //=============================================================================== //bookmark file name---------------------------------- AdjstReqVO adjstReqVO = new AdjstReqVO(); adjstReqVO.setAdrSeq(adjstIncidentVO.getAdrSeq()); adjstReqVO = adjstReqService.selectAdjsMgrMaster(adjstReqVO); String s_bookmark_name = adjstReqVO.getAdrNo()+".pdf"; s_bookmark_name = "bookmark.pdf"; String s_bookmark_name_2 = "100.pdf"; //bookmark file name ////2.파일 요청했으면 생성 //2-1파일정보 가져오기 //2-2변환하기 //this.conversionFromWWW(adjstIncidentVO.getAdrSeq()); this.conversionFromWWW( adjstIncidentVO.getAdrSeq() , adjstIncidentVO.getAdrSeq()+"/download/"+s_time_dir+"/" , s_bookmark_name ); this.conversionFromWWW( adjstIncidentVO.getAdrSeq() , adjstIncidentVO.getAdrSeq()+"/download/"+s_time_dir+"/" , s_bookmark_name_2 ); modelAndView.addObject("result", "SUCCESS"); }catch(Exception ex) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1"); System.out.println("Exception Occured!!!"); } return modelAndView; } /** * 조정진행 상세 Tab 조정진행 화면 - 다운로드 1단계 - 체커 * 1.대상생성 확인 * * 2.단권화 진행 * 3.3초 delay 발생 * 4.결과 통보 */ @RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusDownloadStep1CheckerAjax.do") public ModelAndView adjstReqStatusTabStatusDownloadStep1CheckerAjax( HttpServletRequest request , AdjstIncidentVO adjstIncidentVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); try{ //bookmark file name---------------------------------- AdjstReqVO adjstReqVO = new AdjstReqVO(); adjstReqVO.setAdrSeq(adjstIncidentVO.getAdrSeq()); adjstReqVO = adjstReqService.selectAdjsMgrMaster(adjstReqVO); String s_bookmark_name = adjstReqVO.getAdrNo()+".pdf"; s_bookmark_name = "bookmark.pdf"; //bookmark file name String s_time_dir = request.getParameter("time_dir"); //step.1.대상생성 확인======================================================================= //String path = "D:\\Eclipse\\Java\\새폴더"; //폴더 경로 String path = pdfMakepathOut + adjstIncidentVO.getAdrSeq()+"/download/"+s_time_dir+"/"; //pdf변환 폴더 경로 File[] files = new File(path).listFiles(); //System.out.println(path); //System.out.println(s_bookmark_name); int i_pdf_cnt = 0; for (File f : files){ if (f.getName().toUpperCase().indexOf(s_bookmark_name.toUpperCase())>-1) { i_pdf_cnt++; } } if (i_pdf_cnt!=1) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1-check"); return modelAndView; } //=============================================================================== modelAndView.addObject("result", "SUCCESS"); modelAndView.addObject("path", adjstIncidentVO.getAdrSeq()+"/download/"+s_time_dir); modelAndView.addObject("file", s_bookmark_name); }catch(Exception ex) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1"); System.out.println("Exception Occured!!!"); } return modelAndView; } /** * 조정진행 상세 Tab 조정진행 화면 - 문서보기 1단계 * 1.대상폴더 생성 * 2.변환 요청 * 조정신청서 요청 * 첨부파일 변환 요청 * 3.결과 통보 */ @RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusStep1Ajax.do") public ModelAndView adjstReqStatusTabStatusStep1Ajax( HttpServletRequest request , AdjstIncidentVO adjstIncidentVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); //System.out.println("adjstReqStatusTabStatusStep1Ajax"); try { //step.1.폴더 생성======================================================================= //String path = "D:\\Eclipse\\Java\\새폴더"; //폴더 경로 String s_time_dir = request.getParameter("time_dir"); //upload 폴더 { String path_upload = pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/upload"; //사용자가 업로드한 파일이 복사되는 폴더경로 File Folder_upload = new File(path_upload); // 해당 디렉토리가 없을경우 디렉토리를 생성합니다. if (!Folder_upload.exists()) { try{ Boolean result1 = Folder_upload.mkdirs(); //폴더 생성합니다. System.out.println("U 폴더가 생성되었습니다."); //System.out.println(Folder_upload); } catch(Exception e){ System.out.println("Exception Occured!!!"); } }else { System.out.println("U 이미 폴더가 생성되어 있습니다."); //System.out.println(path_upload); File[] files = new File(path_upload).listFiles(); for (File f : files){ //System.out.println(f.getName()); f.delete(); //System.out.println(f.delete()); } } } //pdf 폴더 { String path_pdf = pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/pdf/"+s_time_dir; //pdf 변환기가 생성하는 파일이 들어가는 폴더경로 String path_pdf_4d = pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/pdf"; //pdf 변환기가 생성하는 파일이 들어가는 폴더경로 File Folder_pdf = new File(path_pdf); File Folder_pdf_4d = new File(path_pdf_4d); // 해당 디렉토리가 없을경우 디렉토리를 생성합니다. if (!Folder_pdf.exists()) { try{ this.deleteFile(path_pdf_4d, s_time_dir); } catch(Exception e){ System.out.println("Exception Occured!!!"); } try{ Boolean fileMake1 = Folder_pdf_4d.mkdirs(); //폴더 생성합니다. Boolean fileMake2 = Folder_pdf.mkdirs(); //폴더 생성합니다. System.out.println("P 폴더가 생성되었습니다."); //System.out.println(Folder_pdf); } catch(Exception e){ System.out.println("Exception Occured!!!"); } }else { System.out.println("P 이미 폴더가 생성되어 있습니다."); this.deleteFile(path_pdf_4d, s_time_dir); //System.out.println(Folder_pdf); Folder_pdf.mkdirs(); //폴더 생성합니다. } } //=============================================================================== String[] a_chk = request.getParameterValues("chk"); ////2.파일 요청했으면 생성 //2-1파일정보 가져오기 //2-2변환하기 //this.conversionFromWWW(adjstIncidentVO.getAdrSeq()); int j=0; if(a_chk != null) { for (int i=0;i out/adrseq FileVO fileVO = new FileVO(); fileVO.setAtchFileId(a_vals[0]); fileVO.setFileSn(a_vals[1]); FileVO nfile = egovFileMngService.selectFileInf(fileVO); //step1.copy and rename String s_src_file_name = nfile.streFileNm; String s_target_file_name = nfile.orignlFileNm; String s_save_file_name = s_target_file_name.substring(0, s_target_file_name.lastIndexOf(".")); //System.out.println("s_src_file_name"); //System.out.println(s_src_file_name); //System.out.println(s_target_file_name); //System.out.println(s_target_file_name.lastIndexOf(".")); //System.out.println(s_target_file_name.substring(0, s_target_file_name.lastIndexOf("."))); //System.out.println("s_target_file_name"); File srcFile = new File(pdfMakepath + s_src_file_name); File destFile = new File(pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/upload/" + s_target_file_name); FileUtils.copyFile(srcFile, destFile); j++; this.conversionFromUFile( adjstIncidentVO.getAdrSeq()+"/upload/" //src path , s_target_file_name //src file name , adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/" //target path //, Integer.toString(j)+".pdf" , Integer.toString(j)+"_"+s_save_file_name+".pdf" ); //target file } } } //오즈 리포트 생성 Export 파일 복사 후 이동 시키기 int h=0; { File orgFilePath = new File(pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/ozFile/"); File copyFilePath = new File(pdfMakepathOut + adjstIncidentVO.getAdrSeq() + "/pdf/" + s_time_dir); if(orgFilePath.listFiles() != null) { File[] targetFile = orgFilePath.listFiles(); for (File file : targetFile) { File temp = new File(copyFilePath.getAbsolutePath() + File.separator + file.getName()); String srcFilePath = adjstIncidentVO.getAdrSeq() + "/ozFile/"; String targetFilePath = adjstIncidentVO.getAdrSeq() + "/pdf/" + s_time_dir+"/"; String saveFileNm = file.getName(); if(file.isDirectory()){ temp.mkdirs(); } else { h++; this.conversionFromUFile( srcFilePath //src path , saveFileNm //src file name , targetFilePath //target path , Integer.toString(h)+"_"+saveFileNm.substring(0, saveFileNm.lastIndexOf("."))+".pdf" ); /*FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(file); fos = new FileOutputStream(temp) ; byte[] b = new byte[4096]; int cnt = 0; while((cnt=fis.read(b)) != -1){ fos.write(b, 0, cnt); } } catch (Exception e) { e.printStackTrace(); } finally{ try { fis.close(); fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }*/ } /*h++;*/ } } } modelAndView.addObject("convertCnt", h); modelAndView.addObject("result", "SUCCESS"); }catch(Exception ex) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1"); System.out.println("Exception Occured!!!" + ex); } return modelAndView; } /** * 조정진행 상세 Tab 조정진행 화면 - 문서보기 1단계 - 체커 * 1.대상생성 확인 * * 2.단권화 진행 * 3.3초 delay 발생 * 4.결과 통보 */ @RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusStep1CheckerAjax.do") public ModelAndView adjstReqStatusTabStatusStep1CheckerAjax( HttpServletRequest request , AdjstIncidentVO adjstIncidentVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); System.out.println("adjstReqStatusTabStatusStep1CheckerAjax"); try{ String s_time_dir = request.getParameter("time_dir"); //step.1.대상생성 확인======================================================================= //String path = "D:\\Eclipse\\Java\\새폴더"; //폴더 경로 String path = pdfMakepathOut + adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir + "/"; //pdf변환 폴더 경로 File[] files = new File(path).listFiles(); //System.out.println(path); int i_pdf_cnt = 0; for (File f : files){ if (f.getName().toUpperCase().indexOf(".PDF")>-1 && f.getName().toUpperCase().indexOf("PDF0CHANGE.PDF")<0) { i_pdf_cnt++; } } String[] a_chk = request.getParameterValues("chk"); String convertCnt1 = request.getParameter("convertCnt"); if(a_chk != null) { if (i_pdf_cnt!=a_chk.length) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1-check"); return modelAndView; } }else { if (i_pdf_cnt!=Integer.parseInt(convertCnt1)) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1-check"); return modelAndView; } } //=============================================================================== modelAndView.addObject("result", "SUCCESS"); }catch(Exception ex) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1"); System.out.println("Exception Occured!!!"); } return modelAndView; } /** * 조정진행 상세 Tab 조정진행 화면 - 문서보기 2단계 * 1.대상생성 확인 * * 2.단권화 진행 * 3.3초 delay 발생 * 4.결과 통보 */ @RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusStep2Ajax.do") public ModelAndView adjstReqStatusTabStatusStep2Ajax( HttpServletRequest request , AdjstIncidentVO adjstIncidentVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); System.out.println("adjstReqStatusTabStatusStep2Ajax"); try { List l_file_nm = new ArrayList(); String s_time_dir = request.getParameter("time_dir"); //step.1.대상생성 확인======================================================================= //String path = "D:\\Eclipse\\Java\\새폴더"; //폴더 경로 String path = pdfMakepathOut + adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/"; //pdf 폴더 경로 File[] files = new File(path).listFiles(); int i_pdf_cnt = 0; for (File f : files){ if (f.getName().toUpperCase().indexOf(".PDF")>-1 && f.getName().toUpperCase().indexOf("PDF0CHANGE.PDF")<0) { i_pdf_cnt++; //String s_save_file_name = f.getName().substring(0, f.getName().lastIndexOf(".")); l_file_nm.add(f.getName().substring(0, f.getName().lastIndexOf("."))); System.out.println("단권화 할 파일 목록 입니다. cnt : " + i_pdf_cnt +f.getName()); } } String[] a_chk = request.getParameterValues("chk"); String convertCnt1 = request.getParameter("convertCnt"); if(a_chk != null) { if (i_pdf_cnt!=a_chk.length) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step2"); return modelAndView; } }else { if (i_pdf_cnt!=Integer.parseInt(convertCnt1)) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1-check"); return modelAndView; } } //=============================================================================== //3.단권화 진행 if (i_pdf_cnt>1) { this.mergeFromUFileNew( i_pdf_cnt , l_file_nm , adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/" , "PDF0CHANGE.pdf" ); }else { //1권이면 merge 가 아니고 바로 만들기를 한다. this.conversionFromUFile( adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/" //src path , "1_조정신청서.pdf" //src file name , adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/" //target path , "PDF0CHANGE.pdf"); } modelAndView.addObject("result", "SUCCESS"); }catch(Exception ex) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "단권화요청에 실패했습니다.-step2"); System.out.println("Exception Occured!!!"); } return modelAndView; } /** * 조정진행 상세 Tab 조정진행 화면 - 문서보기 2단계 - 체커 * 1.대상생성 확인 * 2.페이지 측정 * 3.북마크 진행 * 4.3초 delay 발생 * 5.결과 통보 */ @RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusStep2CheckerAjax.do") public ModelAndView adjstReqStatusTabStatusStep2CheckerAjax( HttpServletRequest request , AdjstIncidentVO adjstIncidentVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); System.out.println("adjstReqStatusTabStatusStep2CheckerAjax"); try { String s_time_dir = request.getParameter("time_dir"); //step.1.대상생성 확인======================================================================= //String path = "D:\\Eclipse\\Java\\새폴더"; //폴더 경로 String path = pdfMakepathOut + adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/"; //pdf 폴더 경로 File[] files = new File(path).listFiles(); int i_0_pdf_cnt = 0; for (File f : files){ if (f.getName().toUpperCase().indexOf("PDF0CHANGE.PDF")>-1) { i_0_pdf_cnt++; } } if (i_0_pdf_cnt<=0) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step2-check"); return modelAndView; } //=============================================================================== modelAndView.addObject("result", "SUCCESS"); }catch(Exception ex) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1"); System.out.println("Exception Occured!!!"); } return modelAndView; } /** * 조정진행 상세 Tab 조정진행 화면 - 문서보기 3단계 * 1.대상생성 확인 * 2.페이지 측정 * 3.북마크 진행 * 4.3초 delay 발생 * 5.결과 통보 */ @RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusStep3Ajax.do") public ModelAndView adjstReqStatusTabStatusStep3Ajax( HttpServletRequest request , AdjstIncidentVO adjstIncidentVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); System.out.println("adjstReqStatusTabStatusStep3Ajax"); try{ //bookmark file name---------------------------------- AdjstReqVO adjstReqVO = new AdjstReqVO(); adjstReqVO.setAdrSeq(adjstIncidentVO.getAdrSeq()); adjstReqVO = adjstReqService.selectAdjsMgrMaster(adjstReqVO); String s_bookmark_name = adjstReqVO.getAdrNo()+".pdf"; s_bookmark_name = "bookmark.pdf"; //bookmark file name List l_file_nm = new ArrayList(); String s_time_dir = request.getParameter("time_dir"); //step.1.pdf 북마크 대상 파일 수 확인======================================================================= //String path = "D:\\Eclipse\\Java\\새폴더"; //폴더 경로 String path = pdfMakepathOut + adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/"; //pdf 폴더 경로 File[] files = new File(path).listFiles(); int i_pdf_cnt = 0; //int i_0_pdf_cnt = 0; for (File f : files){ if (f.getName().toUpperCase().indexOf(".PDF")>-1 && f.getName().toUpperCase().indexOf("PDF0CHANGE.PDF")<0) { i_pdf_cnt++; l_file_nm.add(f.getName().substring(0, f.getName().lastIndexOf("."))); //a } } //=============================================================================== //4.북마크 - 페이지 수, 인텍스명 찾기 String[] a_bookPage = new String[i_pdf_cnt];//페이지수 찾기 String[] a_title = new String[i_pdf_cnt];//index 제목 찾기 for (int i=0;i-1) { PDDocument doc = null; try { doc = PDDocument.load(new File(f.getAbsolutePath())); int count = doc.getNumberOfPages(); //String s_number = f.getName().substring(0, f.getName().length()-4); a_bookPage[i] = Integer.toString(count); a_title[i] = l_file_nm.get(i).replaceAll(Integer.toString(i+1)+"_", ""); //System.out.println("a_title[i]"); //System.out.println(a_title[i]); //System.out.println(a_title[i].length()); //PDDocument close() //DEBUG org.apache.pdfbox.io.ScratchFileBuffer - ScratchFileBuffer not closed! 에러로 추가 22.01.16 이준호 //서버 리소스 점유 및 에러로그 확인 필요 doc.close(); }catch(Exception ex) { doc.close(); } } } } /* for (File f : files){ if (f.getName().toUpperCase().indexOf(".PDF")>-1 && f.getName().toUpperCase().indexOf("PDF0CHANGE.PDF")<0) { //ㅁ for (int j=0;j-1) { i_0_pdf_cnt++; } } if (i_0_pdf_cnt<=0) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step3-check"); return modelAndView; } //=============================================================================== modelAndView.addObject("result", "SUCCESS"); modelAndView.addObject("webFile", adjstIncidentVO.getAdrSeq()); }catch(Exception ex) { modelAndView.addObject("result", "FAIL"); modelAndView.addObject("message", "생성요청이 실패했습니다.-step1"); System.out.println("Exception Occured!!!"); } return modelAndView; } /////////////////////////////////////////////////////////////////////////// // // // private function // private void conversionFromWWW( String p_param1 , String p_save_path //pdf save path , String p_save_file_name //pdf save file name ) throws Exception{ //pdf 변환 서버 관련 설정 /* @Value("#{globalSettings['Globals.pdf.serverUrl']}") private String pdfServerUrl; //192.168.0.200 @Value("#{globalSettings['Globals.pdf.apiUrl']}") private String pdfApiUrl; //http://192.168.0.34:7080 @Value("#{globalSettings['Globals.pdf.filepath.out']}") private String pdfFilepathOut; //file:/c:/usr/local/tomcat/file/sht/out */ System.out.println(pdfFilepathOut + p_save_path + p_save_file_name); String s_output = UriUtils.encodeUri(pdfFilepathOut + p_save_path + p_save_file_name); PdfConversion conversion = PdfConversion.create(); conversion.input(UriUtils.encodeUri(pdfApiUrl + "/popup/main/adjstIncidentDetailPdf.do?adrSeq="+p_param1)).htmlUrlResource(true); PdfGatewayAgent.of(pdfServerUrl, 8888) .conversion(conversion) .name("convertions-addr-html") .distribute(s_output) .start(); } //파일 pdf 로 변환 //확장자 적용하여 이름변경 필요함 private void conversionFromUFile( String p_src_path , String p_src_file , String p_target_path , String p_target_file ) throws Exception{ String s_in = UriUtils.encodeUri(pdfFilepathOut + p_src_path + p_src_file); String s_output = UriUtils.encodeUri(pdfFilepathOut + p_target_path + p_target_file); System.out.println(pdfFilepathOut + p_src_path + p_src_file); System.out.println(pdfFilepathOut + p_target_path + p_target_file); //PdfConversion conversion = PdfConversion.create(); //conversion.input(UriUtils.encodeUri(pdfApiUrl + "/popup/main/adjstIncidentDetailPdf.do?adrSeq="+p_param1)).htmlUrlResource(true); // PdfGatewayAgent.of(pdfServerUrl, 8888) //.conversion(conversion) .conversion(s_in) .name("convertions-addr-html") .distribute(s_output) .start(); } private void mergeFromUFileNew( //File[] p_files int p_file_cnt , List p_l_file_nm , String p_path , String p_merge_file_name ) throws Exception{ String s_output = UriUtils.encodeUri(pdfFilepathOut + p_path + p_merge_file_name); Merge merge = Merge.create(); //.input(s_in_1) //.mergeResource(s_in_2, "all") //; for (int i=0;i pages = new ArrayList(); BookMarkPage indexPage = BookMarkPage.create("INDEX", 0); int i_bookmark_count = 0; for (int i=0;i '~') { sb.append(URLEncoder.encode("" + c, "UTF-8")); } else { sb.append(c); } } encodedFilename = sb.toString(); } else { //throw new RuntimeException("Not supported browser"); throw new IOException("Not supported browser"); } // response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename); // 파일명에 콤마 포함시 오류 response.setHeader("Content-Disposition", dispositionPrefix + "\"" + encodedFilename + "\""); if ("Opera".equals(browser)) { response.setContentType("application/octet-stream;charset=UTF-8"); } } /** * 브라우저 구분 얻기. * * @param request * @return */ private String getBrowser(HttpServletRequest request) { String header = request.getHeader("User-Agent"); if (header.indexOf("MSIE") > -1) { return "MSIE"; } else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지 return "Trident"; } else if (header.indexOf("Chrome") > -1) { return "Chrome"; } else if (header.indexOf("Opera") > -1) { return "Opera"; } return "Firefox"; } }