세외수입전송용 압축파일 생성 기능 추가
parent
f65a50c59f
commit
d1b080916d
@ -0,0 +1,221 @@
|
||||
package cokr.xit.fims.crdn.send.nxrp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import cokr.xit.base.code.CommonCode;
|
||||
import cokr.xit.fims.cmmn.CmmnUtil;
|
||||
import cokr.xit.fims.cmmn.Hangul;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
|
||||
public class AttachedTxtMaker extends LinkFileMaker {
|
||||
|
||||
private String innerFilePrefix;
|
||||
private String textFileName;
|
||||
|
||||
private List<CommonCode> fimsVltnCodes;
|
||||
private List<CommonCode> nxrpVltnCodes;
|
||||
|
||||
public void appendVltnCodeInfo(List<CommonCode> fimsVltnCodes, List<CommonCode> nxrpVltnCodes) {
|
||||
this.fimsVltnCodes = fimsVltnCodes;
|
||||
this.nxrpVltnCodes = nxrpVltnCodes;
|
||||
}
|
||||
|
||||
public AttachedTxtMaker(String nxrpLinkSeCd, String instDigit7){
|
||||
|
||||
String ifId = "EBF_Z000001LGE_1741000NIS_";
|
||||
String systemCode = "";
|
||||
if(nxrpLinkSeCd.equals("B01")) {
|
||||
ifId += "0001";
|
||||
systemCode = "PVS";
|
||||
this.maxImageFileCnt = 4;
|
||||
} else if(nxrpLinkSeCd.equals("C01")) {
|
||||
ifId += "0003";
|
||||
systemCode = "BPV";
|
||||
this.maxImageFileCnt = 7;
|
||||
}
|
||||
this.ifId = ifId;
|
||||
|
||||
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
String currentTime = ymdhmsFormat.format(new Date());
|
||||
|
||||
this.zipFileName = ifId + "_" + currentTime + "@" + instDigit7 + systemCode + ".zip";
|
||||
|
||||
|
||||
this.innerFilePrefix = ifId + "_" + currentTime + "_" + instDigit7 + "_";
|
||||
this.textFileName = this.innerFilePrefix + "0.txt";
|
||||
|
||||
}
|
||||
|
||||
public String getTextFileName() {
|
||||
return this.textFileName;
|
||||
}
|
||||
|
||||
public void writeTextFileContents(String workPath, String... contents) {
|
||||
try {
|
||||
|
||||
File txtFile = new File(workPath + "/" + this.textFileName);
|
||||
txtFile.createNewFile();
|
||||
|
||||
FileWriter fileWriter = new FileWriter(workPath + "/" + this.textFileName);
|
||||
|
||||
for(int i=0; i < contents.length; i++) {
|
||||
if(i != 0) {
|
||||
fileWriter.write("|");
|
||||
}
|
||||
fileWriter.write(contents[i]);
|
||||
}
|
||||
fileWriter.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("[F]"+e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] extractForPVS(DataObject crdnInfo) {
|
||||
String[] B01 = new String[14];
|
||||
Hangul hangul = new Hangul(3);
|
||||
|
||||
B01[0] = crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM");
|
||||
B01[1] = crdnInfo.string("VHRNO");
|
||||
String crdnSeCd = crdnInfo.string("CRDN_SE_CD");
|
||||
if(!crdnSeCd.equals("01") && !crdnSeCd.equals("02") && !crdnSeCd.equals("07")) {
|
||||
throw new RuntimeException("[F]잘못된 단속구분입니다.");
|
||||
}
|
||||
B01[2] = crdnSeCd;
|
||||
B01[3] = crdnInfo.string("TEAM_ID");
|
||||
String vltnCd = crdnInfo.string("VLTN_CD");
|
||||
|
||||
boolean vltnCdMatch = false;
|
||||
for(CommonCode nxrpVltnCode : this.nxrpVltnCodes) {
|
||||
if(nxrpVltnCode.getCode().equals(vltnCd)) {
|
||||
vltnCdMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(vltnCdMatch) {
|
||||
B01[4] = vltnCd;
|
||||
B01[5] = "";
|
||||
} else {
|
||||
B01[4] = "99";
|
||||
String vltnNm = "";
|
||||
for(CommonCode fimsVltnCode : this.fimsVltnCodes) {
|
||||
if(fimsVltnCode.getCode().equals(vltnCd)) {
|
||||
vltnNm = fimsVltnCode.getValue();
|
||||
}
|
||||
}
|
||||
B01[5] = vltnNm;
|
||||
}
|
||||
|
||||
String law = CmmnUtil.spacedJoin(crdnInfo.string("VLTN_LAW_NM"), crdnInfo.string("VLTN_LAW1"), crdnInfo.string("VLTN_LAW2"));
|
||||
if(hangul.getByteLength(law) > 60) {
|
||||
throw new RuntimeException("[F]위반법규가 60byte를 초과하여 오류가 발생하였습니다.");
|
||||
}
|
||||
B01[6] = law;
|
||||
String crdnPlc = crdnInfo.string("CRDN_PLC");
|
||||
if(hangul.getByteLength(crdnPlc) > 60) {
|
||||
throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다.");
|
||||
}
|
||||
B01[7] = crdnPlc;
|
||||
String crdnSpareaCd = crdnInfo.string("CRDN_SPAREA_CD");
|
||||
if(crdnSpareaCd.equals("00")) {
|
||||
crdnSpareaCd = "";
|
||||
} else if(crdnSpareaCd.equals("06") || crdnSpareaCd.equals("07")) {
|
||||
crdnSpareaCd = "03";
|
||||
}
|
||||
B01[8] = crdnSpareaCd;
|
||||
String gujesi = "1";
|
||||
//TODO : 구제시
|
||||
B01[9] = gujesi;
|
||||
|
||||
if(crdnInfo.string("STDG_CD").equals("")) {
|
||||
B01[10] = "0000000000";
|
||||
} else {
|
||||
B01[10] = crdnInfo.string("STDG_CD");
|
||||
}
|
||||
|
||||
B01[11] = crdnInfo.string("GPS_X");
|
||||
B01[12] = crdnInfo.string("GPS_Y");
|
||||
int atchFileCnt = crdnInfo.number("ATCH_FILE_CNT").intValue();
|
||||
if(atchFileCnt > this.maxImageFileCnt) {
|
||||
atchFileCnt = this.maxImageFileCnt;
|
||||
}
|
||||
B01[13] = Integer.toString(atchFileCnt);
|
||||
|
||||
return B01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] extractForBPV(DataObject crdnInfo) {
|
||||
String[] C01 = new String[14];
|
||||
Hangul hangul = new Hangul(3);
|
||||
|
||||
C01[0] = crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM");
|
||||
C01[1] = crdnInfo.string("VHRNO");
|
||||
String crdnSeCd = crdnInfo.string("CRDN_SE_CD");
|
||||
if(!crdnSeCd.equals("01") && !crdnSeCd.equals("02") && !crdnSeCd.equals("07")) {
|
||||
throw new RuntimeException("[F]잘못된 단속구분입니다.");
|
||||
}
|
||||
C01[2] = crdnSeCd;
|
||||
C01[3] = crdnInfo.string("TEAM_ID");
|
||||
String vltnCd = crdnInfo.string("VLTN_CD");
|
||||
C01[4] = vltnCd;
|
||||
|
||||
String law = CmmnUtil.spacedJoin(crdnInfo.string("VLTN_LAW_NM"), crdnInfo.string("VLTN_LAW1"), crdnInfo.string("VLTN_LAW2"));
|
||||
if(hangul.getByteLength(law) > 60) {
|
||||
throw new RuntimeException("[F]위반법규가 60byte를 초과하여 오류가 발생하였습니다.");
|
||||
}
|
||||
|
||||
C01[5] = law;
|
||||
String crdnPlc = crdnInfo.string("CRDN_PLC");
|
||||
if(hangul.getByteLength(crdnPlc) > 60) {
|
||||
throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다.");
|
||||
}
|
||||
C01[6] = crdnPlc;
|
||||
|
||||
String gujesi = "1";
|
||||
//TODO : 구제시
|
||||
C01[7] = gujesi;
|
||||
|
||||
if(crdnInfo.string("STDG_CD").equals("")) {
|
||||
C01[8] = "0000000000";
|
||||
} else {
|
||||
C01[8] = crdnInfo.string("STDG_CD");
|
||||
}
|
||||
|
||||
C01[9] = crdnInfo.string("GPS_X");
|
||||
C01[10] = crdnInfo.string("GPS_Y");
|
||||
C01[11] = crdnInfo.string("MOSC_X");
|
||||
C01[12] = crdnInfo.string("MOSC_Y");
|
||||
|
||||
int atchFileCnt = crdnInfo.number("ATCH_FILE_CNT").intValue();
|
||||
if(atchFileCnt > this.maxImageFileCnt) {
|
||||
atchFileCnt = this.maxImageFileCnt;
|
||||
}
|
||||
C01[13] = Integer.toString(atchFileCnt);
|
||||
|
||||
return C01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFile(String workPath, String filePath, int fileIndex, String... items) {
|
||||
|
||||
String fileExtension = FilenameUtils.getExtension(filePath);
|
||||
|
||||
String newFileName = this.innerFilePrefix + (fileIndex+1) + "." + fileExtension;
|
||||
String newPath = workPath + "/" + newFileName;
|
||||
try {
|
||||
Files.copy(new File(filePath).toPath(), new File(newPath).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("[F]"+e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cokr.xit.fims.crdn.send.nxrp;
|
||||
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
|
||||
public abstract class LinkFileMaker {
|
||||
|
||||
protected String ifId;
|
||||
protected String zipFileName;
|
||||
protected int maxImageFileCnt;
|
||||
|
||||
public int getMaxImageFileCnt() {
|
||||
return this.maxImageFileCnt;
|
||||
}
|
||||
|
||||
public String getIfId() {
|
||||
return this.ifId;
|
||||
}
|
||||
public String getZipFileName() {
|
||||
return this.zipFileName;
|
||||
}
|
||||
|
||||
abstract public String[] extractForPVS(DataObject crdnInfo);
|
||||
abstract public String[] extractForBPV(DataObject crdnInfo);
|
||||
abstract public void copyFile(String workPath, String filePath, int fileIndex, String... items);
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
package cokr.xit.fims.crdn.send.nxrp;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import cokr.xit.fims.cmmn.Hangul;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
|
||||
public class OnlyImageMaker extends LinkFileMaker {
|
||||
|
||||
public OnlyImageMaker(String nxrpLinkSeCd, String instDigit7){
|
||||
|
||||
String ifId = "EBF_Z000001LGE_1741000NIS_";
|
||||
String systemCode = "";
|
||||
if(nxrpLinkSeCd.equals("B01")) {
|
||||
ifId += "0002";
|
||||
systemCode = "PVS";
|
||||
this.maxImageFileCnt = 4;
|
||||
} else if(nxrpLinkSeCd.equals("C01")) {
|
||||
ifId += "0004";
|
||||
systemCode = "BPV";
|
||||
this.maxImageFileCnt = 7;
|
||||
}
|
||||
this.ifId = ifId;
|
||||
|
||||
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
String currentTime = ymdhmsFormat.format(new Date());
|
||||
|
||||
this.zipFileName = ifId + "_" + currentTime + "@" + instDigit7 + systemCode + ".zip";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] extractForPVS(DataObject crdnInfo) {
|
||||
String[] B01 = new String[11];
|
||||
Hangul hangul = new Hangul(3);
|
||||
|
||||
B01[0] = crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM");
|
||||
B01[1] = crdnInfo.string("VHRNO");
|
||||
String crdnSeCd = crdnInfo.string("CRDN_SE_CD");
|
||||
if(!crdnSeCd.equals("01") && !crdnSeCd.equals("02") && !crdnSeCd.equals("07")) {
|
||||
throw new RuntimeException("[F]잘못된 단속구분입니다.");
|
||||
}
|
||||
B01[2] = crdnSeCd;
|
||||
B01[3] = crdnInfo.string("TEAM_ID");
|
||||
String vltnCd = crdnInfo.string("VLTN_CD");
|
||||
B01[4] = vltnCd;
|
||||
|
||||
String crdnPlc = crdnInfo.string("CRDN_PLC");
|
||||
if(hangul.getByteLength(crdnPlc) > 60) {
|
||||
throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다.");
|
||||
}
|
||||
B01[5] = crdnPlc;
|
||||
String crdnSpareaCd = crdnInfo.string("CRDN_SPAREA_CD");
|
||||
if(crdnSpareaCd.equals("00")) {
|
||||
crdnSpareaCd = "";
|
||||
} else if(crdnSpareaCd.equals("06") || crdnSpareaCd.equals("07")) {
|
||||
crdnSpareaCd = "03";
|
||||
}
|
||||
B01[6] = crdnSpareaCd;
|
||||
String gujesi = "1";
|
||||
//TODO : 구제시
|
||||
B01[7] = gujesi;
|
||||
|
||||
if(crdnInfo.string("STDG_CD").equals("")) {
|
||||
B01[8] = "0000000000";
|
||||
} else {
|
||||
B01[8] = crdnInfo.string("STDG_CD");
|
||||
}
|
||||
|
||||
String gpsX = crdnInfo.string("GPS_X");
|
||||
if(gpsX.equals("")) {
|
||||
gpsX = "000";
|
||||
}
|
||||
String gpsY = crdnInfo.string("GPS_Y");
|
||||
if(gpsY.equals("")) {
|
||||
gpsY = "000";
|
||||
}
|
||||
B01[9] = gpsX;
|
||||
B01[10] = gpsY;
|
||||
|
||||
return B01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] extractForBPV(DataObject crdnInfo) {
|
||||
String[] C01 = new String[10];
|
||||
Hangul hangul = new Hangul(3);
|
||||
|
||||
C01[0] = crdnInfo.string("CRDN_YMD")+crdnInfo.string("CRDN_TM");
|
||||
C01[1] = crdnInfo.string("VHRNO");
|
||||
String crdnSeCd = crdnInfo.string("CRDN_SE_CD");
|
||||
if(!crdnSeCd.equals("01") && !crdnSeCd.equals("02") && !crdnSeCd.equals("07")) {
|
||||
throw new RuntimeException("[F]잘못된 단속구분입니다.");
|
||||
}
|
||||
C01[2] = crdnSeCd;
|
||||
C01[3] = crdnInfo.string("TEAM_ID");
|
||||
String vltnCd = crdnInfo.string("VLTN_CD");
|
||||
C01[4] = vltnCd;
|
||||
|
||||
String crdnPlc = crdnInfo.string("CRDN_PLC");
|
||||
if(hangul.getByteLength(crdnPlc) > 60) {
|
||||
throw new RuntimeException("[F]단속장소가 60byte를 초과하여 오류가 발생하였습니다.");
|
||||
}
|
||||
C01[5] = crdnPlc;
|
||||
|
||||
String gujesi = "1";
|
||||
//TODO : 구제시
|
||||
C01[6] = crdnInfo.string(gujesi);
|
||||
|
||||
if(crdnInfo.string("STDG_CD").equals("")) {
|
||||
C01[7] = "0000000000";
|
||||
} else {
|
||||
C01[7] = crdnInfo.string("STDG_CD");
|
||||
}
|
||||
|
||||
String gpsX = crdnInfo.string("GPS_X");
|
||||
if(gpsX.equals("")) {
|
||||
gpsX = "000";
|
||||
}
|
||||
String gpsY = crdnInfo.string("GPS_Y");
|
||||
if(gpsY.equals("")) {
|
||||
gpsY = "000";
|
||||
}
|
||||
C01[8] = gpsX;
|
||||
C01[9] = gpsY;
|
||||
|
||||
return C01;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFile(String workPath, String filePath, int fileIndex, String... items) {
|
||||
|
||||
String fileExtension = FilenameUtils.getExtension(filePath);
|
||||
|
||||
String delim = "_";
|
||||
String newFileName = String.join(delim, items) + delim + fileIndex + "." + fileExtension;
|
||||
|
||||
String newPath = workPath + "/" + newFileName;
|
||||
|
||||
try {
|
||||
Files.copy(new File(filePath).toPath(), new File(newPath).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("[F]"+e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue