no message
parent
d4b948d3e2
commit
cfbdb874f0
@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cokr.xit.app</groupId>
|
||||
<artifactId>app-support</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>app-support</name>
|
||||
<description>app-support</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-public</id>
|
||||
<url>https://nas.xit.co.kr:8888/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-public</id>
|
||||
<url>https://nas.xit.co.kr:8888/repository/maven-public/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cokr.xit.base</groupId>
|
||||
<artifactId>xit-base</artifactId>
|
||||
<version>23.04.01-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<directory>${basedir}/target</directory>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
|
||||
<resources>
|
||||
<resource><directory>${basedir}/src/main/resources</directory></resource>
|
||||
</resources>
|
||||
|
||||
<testResources>
|
||||
<testResource><directory>${basedir}/src/test/resources</directory></testResource>
|
||||
<testResource><directory>${basedir}/src/main/resources</directory></testResource>
|
||||
</testResources>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- EMMA -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>emma-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-3</version>
|
||||
</plugin>
|
||||
<!-- PMD manven plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*.class</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- EMMA -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
<reportFormat>xml</reportFormat>
|
||||
<excludes>
|
||||
<exclude>**/Abstract*.java</exclude>
|
||||
<exclude>**/*Suite.java</exclude>
|
||||
</excludes>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>emma-maven-plugin</artifactId>
|
||||
<inherited>true</inherited>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Javadoc -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- Nexus deploy -->
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>maven-snapshot</id>
|
||||
<url>https://nas.xit.co.kr:8888/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
|
||||
<repository>
|
||||
<id>maven-release</id>
|
||||
<url>https://nas.xit.co.kr:8888/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<!-- Nexus deploy -->
|
||||
|
||||
</project>
|
@ -0,0 +1,131 @@
|
||||
package cokr.xit.applib;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cokr.xit.foundation.UserInfo;
|
||||
|
||||
public class Print {
|
||||
|
||||
public Print(){
|
||||
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
this.printRequestDt = ymdhmsFormat.format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* 출력 요청 일시
|
||||
*/
|
||||
protected String printRequestDt;
|
||||
|
||||
/**
|
||||
* 출력 요청 유저
|
||||
*/
|
||||
protected UserInfo printRequestUserInfo;
|
||||
|
||||
/**
|
||||
* 다중 파일 생성시 파일명 인덱스
|
||||
*/
|
||||
protected int fileNameIndex = 0;
|
||||
|
||||
/**
|
||||
* 확장자
|
||||
*/
|
||||
protected String extension;
|
||||
|
||||
/**
|
||||
* 서식명
|
||||
*/
|
||||
protected String formatName;
|
||||
|
||||
/**
|
||||
* 서식한글명
|
||||
*/
|
||||
protected String formatKorName;
|
||||
|
||||
public String setExtension(String extension) {
|
||||
return this.extension = extension;
|
||||
}
|
||||
|
||||
public String getFormatName() {
|
||||
return this.formatName;
|
||||
}
|
||||
|
||||
public void setFormatName(String formatName) {
|
||||
this.formatName = formatName;
|
||||
}
|
||||
|
||||
public String getFormatKorName() {
|
||||
return this.formatKorName;
|
||||
}
|
||||
|
||||
public void setFormatKorName(String formatKorName) {
|
||||
this.formatKorName = formatKorName;
|
||||
}
|
||||
|
||||
public UserInfo getPrintRequestUserInfo() {
|
||||
return this.printRequestUserInfo;
|
||||
}
|
||||
|
||||
public void setPrintRequestUserInfo(UserInfo printRequestUserInfo) {
|
||||
this.printRequestUserInfo = printRequestUserInfo;
|
||||
}
|
||||
|
||||
public String getPrintRequestDt() {
|
||||
return this.printRequestDt;
|
||||
}
|
||||
|
||||
public void setPrintRequestDt(String printRequestDt) {
|
||||
this.printRequestDt = printRequestDt;
|
||||
}
|
||||
|
||||
|
||||
public int getFileNameIndex() {
|
||||
return this.fileNameIndex;
|
||||
}
|
||||
public int setFileNameIndex(int fileNameIndex) {
|
||||
return this.fileNameIndex = fileNameIndex;
|
||||
}
|
||||
|
||||
|
||||
public boolean getPrivateInfoYn(PrintOption printOption) {
|
||||
|
||||
boolean privateInfoYn = true;
|
||||
if(printOption != null && printOption.getPrivateInfoYn() != null && printOption.getPrivateInfoYn().equals("N")) {
|
||||
privateInfoYn = false;
|
||||
}
|
||||
return privateInfoYn;
|
||||
}
|
||||
|
||||
public Map<String,String> getGlobalVariable(PrintOption printOption) {
|
||||
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
if(printOption != null && printOption.getGlobalVariable() != null && !printOption.getGlobalVariable().isEmpty()) {
|
||||
map = printOption.getGlobalVariable();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public String pathForNewFile(){
|
||||
|
||||
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String currentTime = ymdhmsFormat.format(new Date());
|
||||
String year = currentTime.substring(0, 4);
|
||||
String month = currentTime.substring(4, 6);
|
||||
String day = currentTime.substring(6, 8);
|
||||
String formatFileResultRootPath = "files" + File.separator + "temp" + File.separator + "print";
|
||||
String formatFileResultFolderPath = formatFileResultRootPath
|
||||
+ File.separator + year + File.separator + month + File.separator + day;
|
||||
File formatFileResultFolder = new File(formatFileResultFolderPath);
|
||||
if(!formatFileResultFolder.exists()) {
|
||||
formatFileResultFolder.mkdirs();
|
||||
}
|
||||
String resultPath = formatFileResultFolderPath + File.separator + currentTime +"_"+ this.getFileNameIndex() + "."+this.extension;
|
||||
|
||||
this.setFileNameIndex(this.getFileNameIndex()+1);
|
||||
|
||||
return resultPath;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cokr.xit.applib;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PrintOption {
|
||||
|
||||
/**
|
||||
* 개인정보 표시 여부
|
||||
*/
|
||||
protected String privateInfoYn;
|
||||
|
||||
/**
|
||||
* 용지구분
|
||||
*/
|
||||
protected String paperSeCd;
|
||||
|
||||
/**
|
||||
* 전역 변수
|
||||
*/
|
||||
protected Map<String,String> globalVariable;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cokr.xit.applib.hwp;
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface;
|
||||
import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph;
|
||||
import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphAdder;
|
||||
|
||||
public class HwpMerge {
|
||||
|
||||
/**한글파일을 병합한다.
|
||||
* @param attachHWPFile 기준파일 마지막 페이지에 붙일 파일, baseHWPFile 기준 파일
|
||||
* @return
|
||||
*/
|
||||
public static void appendToLast(HWPFile attachHWPFile, HWPFile baseHWPFile) throws Exception {
|
||||
|
||||
if (attachHWPFile != null && baseHWPFile != null) {
|
||||
|
||||
Paragraph[] ps = attachHWPFile.getBodyText().getSectionList().get(0).getParagraphs();
|
||||
|
||||
ParagraphListInterface baseSection = baseHWPFile.getBodyText().getLastSection();
|
||||
|
||||
ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, baseSection);
|
||||
|
||||
for(int i=0; i<ps.length; i++) {
|
||||
Paragraph p = ps[i];
|
||||
paraAdder.add(attachHWPFile, p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cokr.xit.applib.hwp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cokr.xit.base.docs.hwp.HWPWriter;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.Control;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ControlTable;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ControlType;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.table.Cell;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.table.Row;
|
||||
import kr.dogfoot.hwplib.tool.objectfinder.ControlFinder;
|
||||
|
||||
public class OffcsCellFinder {
|
||||
|
||||
|
||||
public static Cell find(HWPWriter writer) {
|
||||
ArrayList<Control> find = ControlFinder.find(writer.getFile(), (control, paragrpah, section) -> {
|
||||
if(control.getType().equals(ControlType.Table)) {
|
||||
ArrayList<Row> rl = ((ControlTable)control).getRowList();
|
||||
if(rl.size() == 1) {
|
||||
ArrayList<Cell> cl = rl.get(0).getCellList();
|
||||
if(cl.size() == 1) {
|
||||
String fn = cl.get(0).getListHeader().getFieldName();
|
||||
if(fn != null && !fn.equals("")) {
|
||||
if(fn.equals("직인")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if(find != null && !find.isEmpty()) {
|
||||
ControlTable tableForOffcs = (ControlTable) find.get(0);
|
||||
Cell cell = tableForOffcs.getRowList().get(0).getCellList().get(0);
|
||||
return cell;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package cokr.xit.applib.hwp.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cokr.xit.applib.Print;
|
||||
import cokr.xit.applib.PrintOption;
|
||||
import cokr.xit.applib.hwp.HwpMerge;
|
||||
import cokr.xit.base.docs.hwp.HWPWriter;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.reader.HWPReader;
|
||||
|
||||
|
||||
public abstract class HWPFormat {
|
||||
protected HWPWriter writer;
|
||||
|
||||
protected Print print;
|
||||
protected PrintOption printOption;
|
||||
protected List<DataObject> data;
|
||||
|
||||
protected String formatFilePath;
|
||||
|
||||
protected int currentRunCount;
|
||||
protected int maxRunCount;
|
||||
protected List<String> resultFilesPath;
|
||||
|
||||
public HWPFormat(Print print, PrintOption printOption, List<DataObject> dataObjectList) {
|
||||
this.resultFilesPath = new ArrayList<String>();
|
||||
this.currentRunCount = 0;
|
||||
this.data = dataObjectList;
|
||||
this.printOption = printOption;
|
||||
this.print = print;
|
||||
this.print.setExtension("hwp");
|
||||
}
|
||||
|
||||
public HWPFormat makeFile(){
|
||||
|
||||
while(currentRunCount != maxRunCount) {
|
||||
HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath);
|
||||
this.writer = new HWPWriter(hwpFile);
|
||||
runAsWriter();
|
||||
String tempPath = this.print.pathForNewFile();
|
||||
writer.write(tempPath);
|
||||
resultFilesPath.add(tempPath);
|
||||
|
||||
writer = null;
|
||||
currentRunCount++;
|
||||
}
|
||||
|
||||
this.merge();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
protected abstract void runAsWriter();
|
||||
|
||||
|
||||
protected void merge(){
|
||||
if(resultFilesPath.size() >= 2) {
|
||||
|
||||
try {
|
||||
String basePath = resultFilesPath.get(0);
|
||||
HWPFile baseFile = HWPReader.fromFile(basePath);
|
||||
|
||||
|
||||
for(int i=2; i <= resultFilesPath.size();i++) {
|
||||
String attachPath = resultFilesPath.get(i-1);
|
||||
HWPFile attachFile = HWPReader.fromFile(attachPath);
|
||||
HwpMerge.appendToLast(attachFile, baseFile);
|
||||
}
|
||||
|
||||
kr.dogfoot.hwplib.writer.HWPWriter.toFile(baseFile, basePath);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
|
||||
}
|
||||
|
||||
for(int i=2; i <= resultFilesPath.size();i++) {
|
||||
if(!(new File(resultFilesPath.get(i-1))).delete()) {
|
||||
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public HashMap<String, Object> andDownload(){
|
||||
String resultFilePath = resultFilesPath.get(0);
|
||||
HWPFile resultFile = HWPWriter.filepath(resultFilePath);
|
||||
writer = new HWPWriter(resultFile);
|
||||
|
||||
HashMap<String,Object> result = new HashMap<String,Object>();
|
||||
String downlaodFileName = this.print.getFormatKorName()+"_"+this.print.getPrintRequestDt()+".hwp";
|
||||
result.put("download", writer.getDownloadable().setFilename(downlaodFileName));
|
||||
result.put("downloadData", data);
|
||||
result.put("dataNames", getDownloadDataNames());
|
||||
|
||||
new File(resultFilePath).delete();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
public abstract List<String> getDownloadDataNames();
|
||||
|
||||
public String andGetPath(){
|
||||
return resultFilesPath.get(0);
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue