pdf관련 패키지 정리

main
이범준 10 months ago
parent 0beaddf614
commit 19553ee51b

@ -1,5 +0,0 @@
package cokr.xit.fims.cmmn.pdf;
public abstract class PDFExtractFormat {
}

@ -1,72 +1,8 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageTree;
public class PDFUtil { public class PDFUtil {
public static List<Extraction> extract(String pdfPath, String taskSeCd, String templateId) {
List<Extraction> extractList = new ArrayList<Extraction>();
File file = null;
try {
file = new File(pdfPath);
} catch (Exception e2) {
e2.printStackTrace();
}
PDDocument pdDocument = null;
try {
pdDocument = Loader.loadPDF(file);
} catch (IOException e) {
e.printStackTrace();
}
PDPageTree pages = pdDocument.getPages();
int pageCount = pages.getCount();
int pageIndex = 0;
Extraction extraction = new Extraction();
for(;pageIndex < pageCount; pageIndex++) {
extraction = new Extraction();
extraction.setPage(pageIndex+1);
//설정 = mapper.get설정(query.setSggCd().setTaskSeCd(taskSeCd).setTemplateId(templateId));
String epayNo = ExtractText.getExtractByStng(pdDocument, pageIndex+1, 0, 0, 100, 100);
extraction.setEpayNo(epayNo);
PDPage page = pages.get(pageIndex);
List<String> b64imageList = new ArrayList<>();
try {
ExtractImageEngine printer = new ExtractImageEngine();
printer.processPage(page);
b64imageList = printer.getBase64List();
printer.clearBase64List();
} catch (IOException e1) {
e1.printStackTrace();
}
extraction.setBase64List(b64imageList);
extractList.add(extraction);
}
return extractList;
}
} }

@ -1,4 +1,4 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf.extration;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;

@ -1,4 +1,4 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf.extration;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.io.IOException; import java.io.IOException;

@ -1,4 +1,4 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf.extration;
import java.util.List; import java.util.List;

@ -0,0 +1,69 @@
package cokr.xit.fims.cmmn.pdf.extration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageTree;
public class PDFExtractionUtil {
public static List<Extraction> extract(String pdfPath, String taskSeCd, String templateId) {
List<Extraction> extractList = new ArrayList<Extraction>();
File file = null;
try {
file = new File(pdfPath);
} catch (Exception e2) {
e2.printStackTrace();
}
PDDocument pdDocument = null;
try {
pdDocument = Loader.loadPDF(file);
} catch (IOException e) {
e.printStackTrace();
}
PDPageTree pages = pdDocument.getPages();
int pageCount = pages.getCount();
int pageIndex = 0;
Extraction extraction = new Extraction();
for(;pageIndex < pageCount; pageIndex++) {
extraction = new Extraction();
extraction.setPage(pageIndex+1);
//설정 = mapper.get설정(query.setSggCd().setTaskSeCd(taskSeCd).setTemplateId(templateId));
String epayNo = ExtractText.getExtractByStng(pdDocument, pageIndex+1, 0, 0, 100, 100);
extraction.setEpayNo(epayNo);
PDPage page = pages.get(pageIndex);
List<String> b64imageList = new ArrayList<>();
try {
ExtractImageEngine printer = new ExtractImageEngine();
printer.processPage(page);
b64imageList = printer.getBase64List();
printer.clearBase64List();
} catch (IOException e1) {
e1.printStackTrace();
}
extraction.setBase64List(b64imageList);
extractList.add(extraction);
}
return extractList;
}
}

@ -0,0 +1,8 @@
package cokr.xit.fims.cmmn.pdf.extration.format;
/**
*
*/
public class ElectronicNotice extends PDFExtractFormat {
}

@ -0,0 +1,5 @@
package cokr.xit.fims.cmmn.pdf.extration.format;
public abstract class PDFExtractFormat {
}

@ -1,10 +0,0 @@
package cokr.xit.fims.cmmn.pdf.extrationFormat;
import cokr.xit.fims.cmmn.pdf.PDFExtractFormat;
/**
*
*/
public class ElectronicNotice extends PDFExtractFormat {
}

@ -1,5 +1,6 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf.print;
import cokr.xit.fims.cmmn.pdf.Pstn;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

@ -1,4 +1,4 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf.print;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -18,6 +18,11 @@ import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import cokr.xit.fims.cmmn.PrintUtil; import cokr.xit.fims.cmmn.PrintUtil;
import cokr.xit.fims.cmmn.pdf.PDFColors;
import cokr.xit.fims.cmmn.pdf.PDFCoordinate;
import cokr.xit.fims.cmmn.pdf.Pstn;
import cokr.xit.fims.cmmn.pdf.PstnAndSize;
import cokr.xit.fims.cmmn.pdf.Size;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
public class PDFPrintUtil extends PrintUtil { public class PDFPrintUtil extends PrintUtil {

@ -1,12 +1,11 @@
package cokr.xit.fims.cmmn.pdf.printFormat; package cokr.xit.fims.cmmn.pdf.print.format;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.pdf.PDFPrintFormat; import cokr.xit.fims.cmmn.pdf.print.PDFPrintUtil;
import cokr.xit.fims.cmmn.pdf.PDFPrintUtil;
import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.fims.mngt.FactionUtil;
import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.data.DataFormat; import cokr.xit.foundation.data.DataFormat;

@ -1,12 +1,11 @@
package cokr.xit.fims.cmmn.pdf.printFormat; package cokr.xit.fims.cmmn.pdf.print.format;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.CmmnUtil;
import cokr.xit.fims.cmmn.pdf.PDFPrintFormat; import cokr.xit.fims.cmmn.pdf.print.PDFPrintUtil;
import cokr.xit.fims.cmmn.pdf.PDFPrintUtil;
import cokr.xit.fims.mngt.FactionUtil; import cokr.xit.fims.mngt.FactionUtil;
import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.data.DataFormat; import cokr.xit.foundation.data.DataFormat;

@ -1,8 +1,10 @@
package cokr.xit.fims.cmmn.pdf; package cokr.xit.fims.cmmn.pdf.print.format;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import cokr.xit.fims.cmmn.pdf.print.DefaultOtptArtclStng;
import cokr.xit.fims.cmmn.pdf.print.PDFPrintUtil;
import cokr.xit.fims.sprt.PrintOption; import cokr.xit.fims.sprt.PrintOption;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;

@ -1,10 +1,18 @@
package cokr.xit.fims.cmmn.web; package cokr.xit.fims.cmmn.web;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import cokr.xit.fims.cmmn.pdf.PDFUtil; import cokr.xit.fims.cmmn.pdf.extration.Extraction;
import cokr.xit.fims.cmmn.pdf.extration.PDFExtractionUtil;
import cokr.xit.fims.cmmn.service.bean.LinkBean;
import cokr.xit.fims.mngt.service.bean.FactionBean;
import cokr.xit.foundation.UserInfo;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
import cokr.xit.foundation.web.AbstractController; import cokr.xit.foundation.web.AbstractController;
@ -12,14 +20,21 @@ import cokr.xit.foundation.web.AbstractController;
@RequestMapping(name = "연계 처리", value = "/link") @RequestMapping(name = "연계 처리", value = "/link")
public class LinkController extends AbstractController { public class LinkController extends AbstractController {
@Resource(name = "linkBean")
private LinkBean linkBean;
@Resource(name = "factionBean")
private FactionBean factionBean;
@RequestMapping(name = "파일 처리", value = "/fileProcess.do") @RequestMapping(name = "파일 처리", value = "/fileProcess.do")
public ModelAndView fileProcess(String filePath, String job, String param) { public ModelAndView fileProcess(String filePath, String job, String param) {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");
boolean saved = false; boolean saved = false;
UserInfo userInfo = currentUser();
factionBean.initUserInfo(userInfo);
String sggCd = (String) userInfo.getInfo().get("sggCd");
System.out.println("파일경로 : " +filePath);
System.out.println("업무 : " + job);
System.out.println("파라미터 : "+ param); System.out.println("파라미터 : "+ param);
DataObject dataObject = fromJson(param, DataObject.class); DataObject dataObject = fromJson(param, DataObject.class);
@ -28,7 +43,32 @@ public class LinkController extends AbstractController {
if(job.equals("01")) { if(job.equals("01")) {
String tmplatId = dataObject.string("tmplatId"); String tmplatId = dataObject.string("tmplatId");
String taskSeCd = dataObject.string("taskSeCd"); String taskSeCd = dataObject.string("taskSeCd");
PDFUtil.extract(filePath, taskSeCd, tmplatId);
List<Extraction> extractionInfos = PDFExtractionUtil.extract(filePath, taskSeCd, tmplatId);
for(int i=0; i < extractionInfos.size(); i++) {
DataObject masterInfo = new DataObject();
masterInfo.set("signguCode", sggCd);
masterInfo.set("ffnlgCode", taskSeCd);
masterInfo.set("tmplatId", tmplatId);
masterInfo.set("sndngCo", extractionInfos.size());
//발송일시!
//마감일시!
DataObject detailInfo = new DataObject();
detailInfo.set("signguCode", sggCd);
masterInfo.set("ffnlgCode", taskSeCd);
//차량번호,주민등록번호,핸드폰번호,성명,주소,상세주소,우편번호
//mmdd
//모바일페이지
//masterInfo.set("mainCode", ); //통합플랫폼 단속id? 전자납부번호?
//masterInfo.set("useInsttIdntfcId", ); //통합플랫폼 발송id?
linkBean.insertElectronicNoticeSndng(masterInfo, List.of(detailInfo));
}
} }
mav.addObject("saved", saved); mav.addObject("saved", saved);

@ -40,12 +40,12 @@ import cokr.xit.fims.cmmn.hwp.format.CrdnList;
import cokr.xit.fims.cmmn.hwp.format.RcvmtConfirm; import cokr.xit.fims.cmmn.hwp.format.RcvmtConfirm;
import cokr.xit.fims.cmmn.hwp.format.ReportOnClaims; import cokr.xit.fims.cmmn.hwp.format.ReportOnClaims;
import cokr.xit.fims.cmmn.hwp.format.RequestForDelivery; import cokr.xit.fims.cmmn.hwp.format.RequestForDelivery;
import cokr.xit.fims.cmmn.pdf.DefaultOtptArtclStng;
import cokr.xit.fims.cmmn.pdf.PDFPrintFormat;
import cokr.xit.fims.cmmn.pdf.PDFPrintUtil;
import cokr.xit.fims.cmmn.pdf.PstnAndSize; import cokr.xit.fims.cmmn.pdf.PstnAndSize;
import cokr.xit.fims.cmmn.pdf.printFormat.Advntce; import cokr.xit.fims.cmmn.pdf.print.DefaultOtptArtclStng;
import cokr.xit.fims.cmmn.pdf.printFormat.Nht; import cokr.xit.fims.cmmn.pdf.print.PDFPrintUtil;
import cokr.xit.fims.cmmn.pdf.print.format.Advntce;
import cokr.xit.fims.cmmn.pdf.print.format.Nht;
import cokr.xit.fims.cmmn.pdf.print.format.PDFPrintFormat;
import cokr.xit.fims.cmmn.service.bean.StngBean; import cokr.xit.fims.cmmn.service.bean.StngBean;
import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.Crdn;
import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.CrdnQuery;

@ -9,10 +9,10 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import cokr.xit.fims.cmmn.pdf.DefaultOtptArtclStng; import cokr.xit.fims.cmmn.pdf.print.DefaultOtptArtclStng;
import cokr.xit.fims.cmmn.pdf.PDFPrintFormat; import cokr.xit.fims.cmmn.pdf.print.format.Advntce;
import cokr.xit.fims.cmmn.pdf.printFormat.Advntce; import cokr.xit.fims.cmmn.pdf.print.format.Nht;
import cokr.xit.fims.cmmn.pdf.printFormat.Nht; import cokr.xit.fims.cmmn.pdf.print.format.PDFPrintFormat;
import cokr.xit.fims.sprt.OtptArtclStng; import cokr.xit.fims.sprt.OtptArtclStng;
import cokr.xit.fims.sprt.OtptForm; import cokr.xit.fims.sprt.OtptForm;
import cokr.xit.fims.sprt.OtptStngQuery; import cokr.xit.fims.sprt.OtptStngQuery;

Loading…
Cancel
Save