한번 실행시 종료되지 않도록 수정

main
이범준 2 months ago
parent bd7408c473
commit 86c96cc4c0

@ -20,41 +20,59 @@ public class MainClass {
}
public static void main(String[] args) throws IOException {
public static void main(String[] args) throws IOException, InterruptedException {
String curJarPath = ClassLoader.getSystemClassLoader().getResource(".").getPath();
if(curJarPath.startsWith("/C:/") || curJarPath.startsWith("/D:/") || curJarPath.startsWith("/E:/")) {
curJarPath = curJarPath.substring(1);
}
String receiveFilesPath = curJarPath + "files/RCV/1741000NIS";
while(true) {
SimpleDateFormat sdf_mm = new SimpleDateFormat("mm");
String curMinute = sdf_mm.format(new Date());
String sendFilesPath = curJarPath + "files/SND/1741000NIS";
if(!curMinute.endsWith("7")) {
Thread.sleep(1000 * 60);
continue;
}
List<Contract> contractDatas = new ArrayList<>();
String curJarPath = ClassLoader.getSystemClassLoader().getResource(".").getPath();
if(curJarPath.startsWith("/C:/") || curJarPath.startsWith("/D:/") || curJarPath.startsWith("/E:/")) {
curJarPath = curJarPath.substring(1);
}
getContractInfoFromWorkingUnit(WORKING_UNIT.DOWNLOAD_DIR, sendFilesPath, contractDatas);
String receiveFilesPath = curJarPath + "files/RCV/1741000NIS";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String curYmdhms = sdf.format(new Date());
String receiveFileName = "EBF_1741000NIS_Z000001LGE_2001_"+curYmdhms+"000"+"@6510000ECA";
String txtFilePath = receiveFilesPath + "/" + receiveFileName + ".txt";
String zipFilePath = receiveFilesPath + "/" + receiveFileName + ".zip";
File txtFile = new File(txtFilePath);
txtFile.createNewFile();
FileWriter fileWriter = new FileWriter(txtFile);
String sendFilesPath = curJarPath + "files/SND/1741000NIS";
List<String> respLines = makeResp(contractDatas);
List<Contract> contractDatas = new ArrayList<>();
getContractInfoFromWorkingUnit(WORKING_UNIT.DOWNLOAD_DIR, sendFilesPath, contractDatas);
if(contractDatas.isEmpty()) {
continue;
}
Thread.sleep(1000 * 60);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String curYmdhms = sdf.format(new Date());
String receiveFileName = "EBF_1741000NIS_Z000001LGE_2001_"+curYmdhms+"000"+"@6510000ECA";
String txtFilePath = receiveFilesPath + "/" + receiveFileName + ".txt";
String zipFilePath = receiveFilesPath + "/" + receiveFileName + ".zip";
File txtFile = new File(txtFilePath);
txtFile.createNewFile();
FileWriter fileWriter = new FileWriter(txtFile);
List<String> respLines = makeResp(contractDatas);
for(String respLine : respLines) {
fileWriter.write(respLine);
fileWriter.write("\r\n");
}
fileWriter.close();
new ZIP().compress(zipFilePath, txtFilePath);
txtFile.delete();
for(String respLine : respLines) {
fileWriter.write(respLine);
fileWriter.write("\r\n");
}
fileWriter.close();
new ZIP().compress(zipFilePath, txtFilePath);
txtFile.delete();
System.out.println("종료");
}

Loading…
Cancel
Save