1379 lines
44 KiB
Java
1379 lines
44 KiB
Java
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
|
|
*
|
|
* <pre>
|
|
* << 개정이력(Modification Information) >>
|
|
*
|
|
* 수정일 수정자 수정내용
|
|
* ------- -------- ---------------------------
|
|
* 2021.08.23 김봉호 최초 생성
|
|
*
|
|
* </pre>
|
|
*/
|
|
|
|
@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<a_chk.length;i++) {
|
|
String[] a_vals = a_chk[i].split("-");
|
|
|
|
|
|
if (a_vals.length==3) { //1.조정신청서 요청하면 생성 to pdf 폴더
|
|
j++;
|
|
|
|
this.conversionFromWWW( //웹화면 내용을 pdf로 생성해주는 기능임
|
|
adjstIncidentVO.getAdrSeq()
|
|
, adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/"
|
|
//, Integer.toString(j)+".pdf"
|
|
, "1_조정신청서.pdf"
|
|
);
|
|
|
|
}else if (a_vals.length==2) { //2.업로드 파일 복사 생성 to upload 폴더
|
|
//step1.파일위치 변경
|
|
//sht => 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<String> l_file_nm = new ArrayList<String>();
|
|
|
|
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<String> l_file_nm = new ArrayList<String>();
|
|
|
|
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<i_pdf_cnt;i++) {
|
|
for (File f : files){
|
|
if (f.getName().indexOf(l_file_nm.get(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<l_file_nm.size();j++) {
|
|
if (l_file_nm.get(j).indexOf(Integer.toString((i+1))+"_")==0) {
|
|
//String s_in_1 = UriUtils.encodeUri(pdfFilepathOut + p_path + Integer.toString((i+1))+".pdf");
|
|
String s_in_1 = UriUtils.encodeUri(pdfFilepathOut + p_path + p_l_file_nm.get(j)+".pdf");
|
|
|
|
if (i==0) merge.input(s_in_1);
|
|
else merge.mergeResource(s_in_1, "all");
|
|
}
|
|
}
|
|
|
|
PDDocument doc = PDDocument.load(new File(f.getAbsolutePath()));
|
|
int count = doc.getNumberOfPages();
|
|
String s_number = f.getName().substring(0, f.getName().length()-4);
|
|
a_bookPage[Integer.parseInt(s_number)-1] = Integer.toString(count);
|
|
}
|
|
}
|
|
*/
|
|
|
|
//make book mark
|
|
this.bookmarkFromUFileNew(
|
|
adjstIncidentVO.getAdrSeq()+"/pdf/"+s_time_dir+"/"
|
|
, a_bookPage
|
|
, a_title
|
|
, "PDF0CHANGE.pdf"
|
|
, s_bookmark_name
|
|
);
|
|
|
|
|
|
modelAndView.addObject("result", "SUCCESS");
|
|
|
|
}catch(Exception ex) {
|
|
modelAndView.addObject("result", "FAIL");
|
|
modelAndView.addObject("message", "생성요청이 실패했습니다.-step3");
|
|
System.out.println("Exception Occured!!!");
|
|
}
|
|
|
|
return modelAndView;
|
|
}
|
|
|
|
/**
|
|
* 조정진행 상세 Tab 조정진행 화면 - 문서보기 3단계 - 체커
|
|
* 1.대상생성 확인
|
|
* 2.페이지 측정
|
|
* 3.북마크 진행
|
|
* 4.3초 delay 발생
|
|
* 5.결과 통보
|
|
*/
|
|
@RequestMapping(value="/web/kccadr/accdnt/ars/tab/adjstReqStatusTabStatusStep3CheckerAjax.do")
|
|
public ModelAndView adjstReqStatusTabStatusStep3CheckerAjax(
|
|
HttpServletRequest request
|
|
, AdjstIncidentVO adjstIncidentVO
|
|
) throws Exception {
|
|
ModelAndView modelAndView = new ModelAndView();
|
|
modelAndView.setViewName("jsonView");
|
|
|
|
System.out.println("adjstReqStatusTabStatusStep3CheckerAjax");
|
|
|
|
|
|
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()+"/pdf/"+s_time_dir+"/"; //pdf 폴더 경로
|
|
File[] files = new File(path).listFiles();
|
|
|
|
int i_pdf_cnt = 0;
|
|
int i_0_pdf_cnt = 0;
|
|
|
|
//System.out.println(path);
|
|
//System.out.println(s_bookmark_name);
|
|
|
|
for (File f : files){
|
|
//System.out.println(s_bookmark_name);
|
|
//System.out.println(f.getName());
|
|
//System.out.println(f.getName().toUpperCase());
|
|
//System.out.println(f.getName().toUpperCase().indexOf(s_bookmark_name));
|
|
|
|
if (f.getName().toUpperCase().indexOf(s_bookmark_name.toUpperCase())>-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<String> 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<p_file_cnt;i++) {
|
|
|
|
//System.out.println("p_l_file_nm.get(j)");
|
|
|
|
for (int j=0;j<p_l_file_nm.size();j++) {
|
|
if (p_l_file_nm.get(j).indexOf(Integer.toString((i+1))+"_")==0) {
|
|
//String s_in_1 = UriUtils.encodeUri(pdfFilepathOut + p_path + Integer.toString((i+1))+".pdf");
|
|
String s_in_1 = UriUtils.encodeUri(pdfFilepathOut + p_path + p_l_file_nm.get(j)+".pdf");
|
|
|
|
if (i==0) merge.input(s_in_1);
|
|
else merge.mergeResource(s_in_1, "all");
|
|
}
|
|
}
|
|
/*
|
|
//String s_in_1 = UriUtils.encodeUri(pdfFilepathOut + p_path + Integer.toString((i+1))+".pdf");
|
|
String s_in_1 = UriUtils.encodeUri(pdfFilepathOut + p_path + p_l_file_nm.get(i)+".pdf");
|
|
|
|
if (i==0) merge.input(s_in_1);
|
|
else merge.mergeResource(s_in_1, "all");
|
|
*/
|
|
}
|
|
|
|
|
|
PdfGatewayAgent.of(pdfServerUrl, 8888)
|
|
.name("convertions-addr-merge")
|
|
.merge(merge)
|
|
.distribute(s_output)
|
|
.textWatermark(TextWatermark.create()
|
|
.text("저작권 전자조정시스템")
|
|
.color("#666666")
|
|
.fontName("Gulim")
|
|
.size(8).x(100).y(100)
|
|
.rotate(45)
|
|
.align(7)
|
|
.opacity(1.0)
|
|
.bold(true)
|
|
.allowView(true)
|
|
.allowPrint(true)
|
|
.range("all")
|
|
)
|
|
.start();
|
|
|
|
}
|
|
|
|
//book mark make process
|
|
private void bookmarkFromUFileNew(
|
|
String p_path
|
|
, String[] p_page
|
|
, String[] p_title
|
|
, String p_merge_file_name
|
|
, String p_bookmark_file_name
|
|
|
|
) throws Exception{
|
|
|
|
String s_in = UriUtils.encodeUri(pdfFilepathOut + p_path + p_merge_file_name);
|
|
String s_output = UriUtils.encodeUri(pdfFilepathOut + p_path + p_bookmark_file_name);
|
|
|
|
List<BookMarkPage> pages = new ArrayList<BookMarkPage>();
|
|
BookMarkPage indexPage = BookMarkPage.create("INDEX", 0);
|
|
|
|
int i_bookmark_count = 0;
|
|
|
|
for (int i=0;i<p_page.length;i++) {
|
|
//BookMarkPage page1 = BookMarkPage.create("page "+Integer.toString(i_bookmark_count+1), i_bookmark_count);
|
|
BookMarkPage page1 = BookMarkPage.create("page " + Integer.toString(i_bookmark_count+1) +" - "+ p_title[i] , i_bookmark_count);
|
|
indexPage.subPage(page1);
|
|
|
|
i_bookmark_count = i_bookmark_count + Integer.parseInt(p_page[i]);
|
|
}
|
|
|
|
pages.add(indexPage);
|
|
BookMark bookmark = BookMark.create().bookMarkPages(pages);
|
|
|
|
|
|
PdfGatewayAgent.of(pdfServerUrl, 8888)
|
|
//.conversion(conversion)
|
|
.conversion(s_in)
|
|
.name("convertions-addr-bookmark")
|
|
//.merge(merge)
|
|
.bookMark(bookmark)
|
|
.distribute(s_output)
|
|
|
|
.start();
|
|
|
|
}
|
|
|
|
//하위 폴더 및 파일 모두 지우기
|
|
//현재 폴더가 아닌것만 삭제한다.
|
|
public void deleteFile(String path, String p_target) throws Exception{
|
|
try {
|
|
|
|
if (path.indexOf(p_target)<0){
|
|
File deleteFolder = new File(path);
|
|
|
|
if(deleteFolder.exists()){
|
|
File[] deleteFolderList = deleteFolder.listFiles();
|
|
|
|
for (int i = 0; i < deleteFolderList.length; i++) {
|
|
if(deleteFolderList[i].isFile()) {
|
|
deleteFolderList[i].delete();
|
|
}else {
|
|
deleteFile(deleteFolderList[i].getPath(), p_target);
|
|
}
|
|
deleteFolderList[i].delete();
|
|
}
|
|
//deleteFolder.delete();
|
|
}
|
|
}
|
|
|
|
}catch(Exception ex) {
|
|
System.out.println("Exception Occured!!!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 배치 작업 수동 실행
|
|
*/
|
|
@RequestMapping(value = "/kccadr/adjPgrMgr/apm/schedulerCallAjax.do")
|
|
public ModelAndView schedulerCall(HttpServletRequest request) throws Exception {
|
|
|
|
ModelAndView modelAndView = new ModelAndView();
|
|
modelAndView.setViewName("jsonView");
|
|
|
|
try {
|
|
|
|
//'PdfConversioning'배치 스케쥴러 수동 실행
|
|
JobKey jobKey = new JobKey("PdfConversioning");
|
|
Scheduler scheduler = schedulerBean.getScheduler();
|
|
scheduler.triggerJob(jobKey);
|
|
|
|
modelAndView.addObject("result", "success");
|
|
|
|
}catch (Exception e) {
|
|
System.out.println(e.getMessage());
|
|
}
|
|
|
|
return modelAndView;
|
|
}
|
|
|
|
|
|
/**
|
|
* 종결사건 단권화 파일 다운르도
|
|
*/
|
|
@RequestMapping(value = "/kccadr/adjPgrMgr/apm/adrConversionChkAjax.do")
|
|
public ModelAndView adrEndPdfConversionDownloadAjax(HttpServletRequest request, HttpServletResponse response, PdfConversionVO pdfConversionVO) throws Exception {
|
|
|
|
ModelAndView modelAndView = new ModelAndView();
|
|
modelAndView.setViewName("jsonView");
|
|
|
|
//alert 메세지
|
|
String msg = "";
|
|
//결과 flag
|
|
String result = "";
|
|
|
|
try {
|
|
PdfConversionVO tmpPdfConversionVO = pdfConversionService.selectConversionPdf(pdfConversionVO);
|
|
|
|
if(tmpPdfConversionVO != null) {
|
|
//pdf 변환이 끝난 상태
|
|
if("Y".equals(tmpPdfConversionVO.getIsPdfTran())) {
|
|
|
|
//파일다운로드
|
|
// fileDownloadPdf(request, response, pdfConversionVO);
|
|
result = "success";
|
|
}
|
|
//변환이 끝나지 않은 상태
|
|
else {
|
|
msg = "현재 종결 사건 단권화 작업이 끝나지 않았습니다. 단권화는 시스템 과부하 방지를 위해 매일 새벽시간에 진행됩니다.";
|
|
result = "fail";
|
|
}
|
|
} else {
|
|
msg = "종결되지 않은 사건 또는 단권화 요청 중입니다. 단권화 요청 및 처리는 시스템 과부하 방지를 위해 매일 새벽시간에 진행됩니다.";
|
|
result = "fail";
|
|
}
|
|
|
|
modelAndView.addObject("result", result);
|
|
modelAndView.addObject("message", msg);
|
|
|
|
}catch (Exception e) {
|
|
System.out.println(e.getMessage());
|
|
modelAndView.addObject("result", "fail");
|
|
modelAndView.addObject("message", "요청에 실패하였습니다.");
|
|
}
|
|
|
|
return modelAndView;
|
|
}
|
|
|
|
/**
|
|
* Disposition 지정하기.
|
|
*
|
|
* @param filename
|
|
* @param request
|
|
* @param response
|
|
* @throws Exception
|
|
*/
|
|
@RequestMapping(value = "/kccadr/adjPgrMgr/apm/adrEndPdfConversionDownload.do")
|
|
private void fileDownloadPdf(HttpServletRequest request, HttpServletResponse response, PdfConversionVO pdfConversionVO) throws Exception{
|
|
|
|
|
|
// PdfConversionVO tmpPdfConversionVO = pdfConversionService.selectConversionPdf(pdfConversionVO);
|
|
//종결 사건 파일 경로
|
|
/*File uFile = new File(tmpPdfConversionVO.getAtchFilePath());*/
|
|
File uFile = new File(pdfMakepathOut + pdfConversionVO.getAdrSeq() +"/result/", "bookmark.pdf");
|
|
|
|
//File uFile = new File("d:/testdir/out/" + pdfConversionVO.getAdrSeq() +"/result/", "bookmark.pdf");
|
|
|
|
String mimetype = "application/x-msdownload";
|
|
|
|
response.setContentType(mimetype);
|
|
setDisposition("bookmark.pdf", request, response);
|
|
//response.setContentLength(fSize);
|
|
|
|
BufferedInputStream in = null;
|
|
BufferedOutputStream out = null;
|
|
|
|
try {
|
|
in = new BufferedInputStream(new FileInputStream(uFile));
|
|
out = new BufferedOutputStream(response.getOutputStream());
|
|
|
|
FileCopyUtils.copy(in, out);
|
|
out.flush();
|
|
} catch (Exception ex) {
|
|
LOGGER.debug("IGNORED: {}", ex.getMessage());
|
|
} finally {
|
|
if (in != null) {
|
|
try {
|
|
in.close();
|
|
} catch (Exception ignore) {
|
|
LOGGER.debug("IGNORED: {}", ignore.getMessage());
|
|
}
|
|
}
|
|
if (out != null) {
|
|
try {
|
|
out.close();
|
|
} catch (Exception ignore) {
|
|
LOGGER.debug("IGNORED: {}", ignore.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Disposition 지정하기.
|
|
*
|
|
* @param filename
|
|
* @param request
|
|
* @param response
|
|
* @throws Exception
|
|
*/
|
|
private void setDisposition(String filename, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
String browser = getBrowser(request);
|
|
|
|
String dispositionPrefix = "attachment; filename=";
|
|
String encodedFilename = null;
|
|
|
|
if (browser.equals("MSIE")) {
|
|
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
|
} else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지
|
|
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
|
} else if (browser.equals("Firefox")) {
|
|
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
|
|
} else if (browser.equals("Opera")) {
|
|
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
|
|
} else if (browser.equals("Chrome")) {
|
|
StringBuffer sb = new StringBuffer();
|
|
for (int i = 0; i < filename.length(); i++) {
|
|
char c = filename.charAt(i);
|
|
if (c > '~') {
|
|
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";
|
|
}
|
|
|
|
}
|
|
|