차세대세외수입 API수정(압축파일내부에 텍스트파일1개)

main
이범준 3 months ago
parent 1abb1324c4
commit 5378ecebb3

@ -76,7 +76,6 @@ public class NisIndivBean extends AbstractBean {
String sggCd = req.getSggCd();
String taskSeCd = req.getTaskSeCd();
String instDigit7 = "6510000";
String deptCd = "";
@ -84,6 +83,8 @@ public class NisIndivBean extends AbstractBean {
deptCd = "6510245";
} else if(sggCd.equals("50130") && taskSeCd.equals("ECA")) {
deptCd = "6520178";
} else {
return "";
}
String lsctLinkTblNm = "TB_LSCT_APRV_"+sggCd+"_"+taskSeCd;
@ -95,7 +96,7 @@ public class NisIndivBean extends AbstractBean {
List<DataObject> targets = null;
if(randomData) {
targets = this.makeRandomJeju01Targets();
targets = this.makeRandomJeju01Targets(10);
} else {
targets = nisIndivMapper.selectLcnsNoLinkTarget(req);
}
@ -116,7 +117,7 @@ public class NisIndivBean extends AbstractBean {
}
OnlyTxtMaker linkFileMaker = new OnlyTxtMaker(instDigit7);
OnlyTxtMaker linkFileMaker = new OnlyTxtMaker("ECA");
if (!isEmpty(gujesi)) {
linkFileMaker.setGujesiStng(gujesi);
@ -144,12 +145,19 @@ public class NisIndivBean extends AbstractBean {
}
workFolder.mkdirs();
linkFileMaker.startTxt(workPath);
int lineCnt = 0;
for(DataObject one : targets) {
if(lineCnt != 0) {
linkFileMaker.newLine();
}
String[] items = linkFileMaker.extract(one,sggCd,taskSeCd).get();
linkFileMaker.writeTextFileContents(workPath, items);
linkFileMaker.increaseInnerFileIndex();
linkFileMaker.writeLine(workPath, items);
lineCnt++;
}
linkFileMaker.endTxt();
File[] fileList = workFolder.listFiles(new FilenameFilter() {
@Override
@ -330,29 +338,32 @@ public class NisIndivBean extends AbstractBean {
}
}
public List<DataObject> makeRandomJeju01Targets(){
public List<DataObject> makeRandomJeju01Targets(int dataCnt){
List<DataObject> result = new ArrayList<>();
DataObject tagets = new DataObject();
for(int i=0;i<dataCnt;i++) {
DataObject tagets = new DataObject();
//APRV_ID
LocalDateTime now = LocalDateTime.now();
String hms = now.format(DateTimeFormatter.ofPattern("HHmmss"));
tagets.put("APRV_ID", "9999"+hms);
//랜덤
tagets.put("VHRNO", shuffleAndGet(Arrays.asList("11가1111", "22가2222", "33가3333")));
tagets.put("HIRER_NM", shuffleAndGet(Arrays.asList("최렌트", "김렌트", "박렌트")));
tagets.put("OM_JNO", shuffleAndGet(Arrays.asList("123456123456", "654321654321", "123456654321")));
tagets.put("RENT_ENT_NM", shuffleAndGet(Arrays.asList("롯데렌트카", "제주렌트카", "기타렌트카")));
tagets.put("RENT_ENT_REG_NO", shuffleAndGet(Arrays.asList("1111112222222", "1111113333333", "1111114444444")));
//CTRT_BGNG_YMD,CTRT_END_YMD는 9월1일~9월16일
tagets.put("CTRT_BGNG_YMD", "20250901");
tagets.put("CTRT_END_YMD", "20250916");
//CTRT_NO는 빈값
tagets.put("CTRT_NO", "");
result.add(tagets);
}
//APRV_ID
LocalDateTime now = LocalDateTime.now();
String hms = now.format(DateTimeFormatter.ofPattern("HHmmss"));
tagets.put("APRV_ID", "9999"+hms);
//랜덤
tagets.put("VHRNO", shuffleAndGet(Arrays.asList("11가1111", "22가2222", "33가3333")));
tagets.put("HIRER_NM", shuffleAndGet(Arrays.asList("최렌트", "김렌트", "박렌트")));
tagets.put("OM_JNO", shuffleAndGet(Arrays.asList("123456123456", "654321654321", "123456654321")));
tagets.put("RENT_ENT_NM", shuffleAndGet(Arrays.asList("롯데렌트카", "제주렌트카", "기타렌트카")));
tagets.put("RENT_ENT_REG_NO", shuffleAndGet(Arrays.asList("1111112222222", "1111113333333", "1111114444444")));
//CTRT_BGNG_YMD,CTRT_END_YMD는 9월1일~9월16일
tagets.put("CTRT_BGNG_YMD", "20250901");
tagets.put("CTRT_END_YMD", "20250916");
//CTRT_NO는 빈값
tagets.put("CTRT_NO", "");
result.add(tagets);
return result;
}

@ -2,6 +2,7 @@ package cokr.xit.fims.nxrp.support;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -10,34 +11,29 @@ import cokr.xit.foundation.data.DataObject;
public class OnlyTxtMaker extends LinkFileMaker {
private String innerFilePrefix;
private String txtFileName;
private int innerFileIndex = 0;
private FileWriter fileWriter;
public OnlyTxtMaker(String instDigit7){
public OnlyTxtMaker(String systemCode){
String ifId = "EBF_Z000001LGE_1741000NIS_2001";
String systemCode = "ECA";
this.ifId = ifId;
SimpleDateFormat ymdhmsFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String currentTime = ymdhmsFormat.format(new Date());
zipFileName = ifId + "_" + currentTime + "@" + instDigit7 + systemCode + ".zip";
zipFileName = ifId + "_" + currentTime + "@6510000" + systemCode + ".zip";
txtFileName = ifId + "_" + currentTime + "@6510000" + systemCode + ".txt";
innerFilePrefix = ifId + "_" + currentTime + "_" + instDigit7 + "_";
}
public String getTextFileName() {
return innerFilePrefix + innerFileIndex + ".txt";
return txtFileName;
}
public void increaseInnerFileIndex() {
innerFileIndex++;
};
@Override
public UnnamedItems extract(DataObject rentInfo, String sggCd, String taskSeCd) {
UnnamedItems u = new UnnamedItems();
@ -55,26 +51,45 @@ public class OnlyTxtMaker extends LinkFileMaker {
return u;
}
public void writeTextFileContents(String workPath, String... contents) {
public void startTxt(String workPath) {
try {
File txtFile = new File(workPath + "/" + getTextFileName());
if(!txtFile.createNewFile()) {
throw new RuntimeException("[F]파일 생성 오류");
}
fileWriter = new FileWriter(txtFile);
} catch (IOException e) {
e.printStackTrace();
}
}
public void endTxt() {
try {
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
FileWriter fileWriter = new FileWriter(txtFile);
public void newLine() {
try {
fileWriter.write("\r\n");
} catch (IOException e) {
e.printStackTrace();
}
}
public void writeLine(String workPath, String... contents) {
try {
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);
}
}
}

@ -1,5 +1,6 @@
package cokr.xit.fims.nxrp.web;
import java.io.File;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -60,8 +61,13 @@ public class NxrpController extends AbstractController {
LocalDateTime now = LocalDateTime.now();
String ymd = now.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String sggCd = "50110";
File folder = new File("/files/temp/sendLcns/"+sggCd+"/"+ymd);
File[] files = folder.listFiles();
for(File file : files) {
nisIndivBean.send_DO_to_SI(file.getPath());
}
nisIndivBean.send_DO_to_SI("/files/temp/sendLcns/50110/"+ymd);
return new ModelAndView("jsonView");
}

Loading…
Cancel
Save