From 9179a7e589746de719d88eab8f01d9e7fbe1b5cb Mon Sep 17 00:00:00 2001 From: leebj Date: Thu, 17 Jul 2025 17:01:02 +0900 Subject: [PATCH] no message --- src/main/java/AnprImageJob.java | 2 +- src/main/java/FTPUtil.java | 48 ++++++++++++--------------------- src/main/java/SendThread.java | 46 +++++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 43 deletions(-) diff --git a/src/main/java/AnprImageJob.java b/src/main/java/AnprImageJob.java index 6fabb1e..63391b7 100644 --- a/src/main/java/AnprImageJob.java +++ b/src/main/java/AnprImageJob.java @@ -89,7 +89,7 @@ public class AnprImageJob implements Job { return; } SendThread obj = null; - for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < list.size(); i++) { //차로갯수만큼반복 this.logger.info(String.format("%s차로 시작", new Object[] { list.get(i) })); obj = new SendThread(list.get(i)); //차로2자리 diff --git a/src/main/java/FTPUtil.java b/src/main/java/FTPUtil.java index b9a5f35..2a675bd 100644 --- a/src/main/java/FTPUtil.java +++ b/src/main/java/FTPUtil.java @@ -1,7 +1,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.util.Properties; import org.apache.log4j.Logger; @@ -25,25 +24,6 @@ public class FTPUtil { - public String mkdir(String path) throws SftpException { - String[] pathArray = path.split("/"); - String currentDirectory = String.valueOf(this.channelSftp.pwd()) + "/"; - String totPathArray = ""; - for (int i = 0; i < pathArray.length; i++) { - if (pathArray[i].length() != 0) { - totPathArray = String.valueOf(totPathArray) + pathArray[i] + "/"; - String currentPath = String.valueOf(currentDirectory) + totPathArray; - try { - this.channelSftp.mkdir(currentPath); - this.channelSftp.cd(currentPath); - } catch (Exception e) { - this.channelSftp.cd(currentPath); - } - } - } - return String.valueOf(currentDirectory) + "/" + totPathArray; - } - public String mkdir2(String path) throws SftpException { String[] pathArray = path.split("/"); String currentDirectory = "/"; @@ -88,6 +68,13 @@ public class FTPUtil { return sftpInitSuccess; } + /** + * dir : 원격지 디렉토리 + * file : 업로드할 객체 + * old : 바꿀대상이름 + * neo : 바꿀이름 + * + * */ public void upload(String dir, File file, String old, String neo) throws SftpException, IOException, JSchException { FileInputStream in = null; in = new FileInputStream(file); @@ -99,13 +86,22 @@ public class FTPUtil { this.channelSftp.rename(old, neo); } + /** + * dir : 원격지 디렉토리 + * file : 업로드할 객체 + * old : 바꿀대상이름 + * neo : 바꿀이름 + * + * */ public void upload2(String dir, File file, String old, String neo) throws SftpException, IOException, JSchException { FileInputStream in = null; this.logger.debug(String.format("============= :upload2 1 ", new Object[0])); in = new FileInputStream(file); this.logger.debug(String.format("============= :upload2 2 ", new Object[0])); this.logger.debug(dir); + this.channelSftp.cd(dir); + this.logger.debug(String.format("============= :upload2 3 ", new Object[0])); this.channelSftp.put(in, file.getName()); this.logger.debug(String.format("============= :upload2 4 ", new Object[0])); @@ -115,17 +111,7 @@ public class FTPUtil { this.logger.debug(String.format("============= :upload2 6 ", new Object[0])); } - public InputStream download(String dir, String fileNm) { - InputStream in = null; - String path = "..."; - try { - this.channelSftp.cd(String.valueOf(path) + dir); - in = this.channelSftp.get(fileNm); - } catch (SftpException se) { - this.logger.debug("Exception : " + se); - } - return in; - } + public void disconnect() { this.channelSftp.quit(); diff --git a/src/main/java/SendThread.java b/src/main/java/SendThread.java index d59b94f..7f8408f 100644 --- a/src/main/java/SendThread.java +++ b/src/main/java/SendThread.java @@ -134,8 +134,14 @@ public void run() { mapDic.put("7", "1"); mapDic.put("8", "1"); this.logger.debug("============================= Z : " + mapDic.get(dirc)); - mapDefault.put("image_path_desc", String.format("/data2/DOTR/%s/0%s/IMAGE/", new Object[] { strarr[0], tennel })); - mapDefault.put("image_path_desc_center", String.format(" /images/ANPRImage/cfs/%s/0%s/%s/", new Object[] { strarr[0].substring(0, 4), tennel, strarr[0] })); + + mapDefault.put( + "image_path_desc_center", + String.format( + " /images/ANPRImage/cfs/%s/0%s/%s/", + new Object[] { strarr[0].substring(0, 4), tennel, strarr[0] } + ) + ); mapDefault.put("work_times", strarr[1]); mapDefault.put("seqno", strarr[2]); int n = Integer.parseInt(strarr[2].substring(6, 8)); @@ -171,9 +177,8 @@ public void run() { StringBuilder pathOrg = new StringBuilder(); pathOrg.append(this.g_strFTP[0]); + StringBuilder path = new StringBuilder(); - path.append(this.g_strFTP[5]); - path.append("/"); path.append(strarr[0].substring(0, 4)); path.append("/"); path.append(strarr[0].substring(4, 6)); @@ -205,15 +210,31 @@ public void run() { strbuf.append(strarr[2]); strbuf.append(".jpg"); mapDefault.put("image_file_new2", - String.format("0%s%s%s%sS.JPG", new Object[] { tennel, line, strarr[0], strarr[1].substring(0, 6) })); + String.format( + "0%s%s%s%sS.JPG", + new Object[] { tennel, line, strarr[0], strarr[1].substring(0, 6) } + ) + ); + mapDefault.put("image_path", pathOrg.toString()); mapDefault.put("image_file", strOrgFile); + this.logger.debug("=== pathOrg.toString() : " + pathOrg.toString()); this.logger.debug("=== path.toString() : " + path.toString()); this.logger.debug("=== strbuf.toString() : " + strbuf.toString()); - jsonParam.put("allImagePath", String.format("%s%s", new Object[] { path.toString().replace(String.valueOf(this.g_strFTP[5]) + "/", ""), strbuf.toString() })); + + jsonParam.put("allImagePath", + String.format( + "%s%s", + new Object[] { + path.toString(), strbuf.toString() + } + ) + ); this.logger.debug("=== : " + jsonParam.toJSONString()); - return String.valueOf(pathOrg.toString()) + "#" + path.toString() + "#" + strbuf.toString() + "#" + line; + return String.valueOf(pathOrg.toString()) + + "#" + path.toString() + "#" + strbuf.toString() + + "#" + line; } //연계api호출 @@ -225,7 +246,7 @@ public void run() { BufferedReader br = null; try { URL url = new URL(this.g_strFTP[4]); - this.logger.info("==== 수집서버 주소가 아니고 대외연계서버 주소 : " + this.g_strFTP[4]); + this.logger.info("==== 대외연계서버 주소 + 녹색과태료 API URL : " + this.g_strFTP[4]); connection = (HttpURLConnection)url.openConnection(); connection.setDoInput(true); connection.setDoOutput(true); @@ -323,7 +344,7 @@ public void run() { return; } - for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < list.size(); i++) { //디렉토리 경로상에 현재 존재하는 JPG파일 mapDefaultCar.clear(); this.logger.debug("=== i : " + i + ", : " + list.get(i)); // @@ -378,6 +399,7 @@ public void run() { this.logger.debug("=== 4 : " + strTargPath[1]); isOk = false; try { + //SFTP 1-1 sftp.mkdir2(strTargPath[1].substring(1)); this.logger.debug("폴더가 생성되었습니다."); } catch (Exception e) { @@ -385,7 +407,7 @@ public void run() { } this.logger.debug(String.format("============= : 업로드 전 ", new Object[0])); try { - + //SFTP 1-2 sftp.upload(strTargPath[1], file, list.get(i), strTargPath[2]); this.logger.debug(String.format("============= : 업로드 성공 ", new Object[0])); @@ -414,7 +436,8 @@ public void run() { this.logger.debug(String.format("=== update param : %s, %s, %s", new Object[] { strTargPath[1], file, list.get(i), strTargPath[2] })); this.logger.debug("==== 미납 수행 시작"); try { - // + + //2번째FTP처리 DefaultCarCenter(strTargPath[3], file, mapDefaultCar); } catch (SQLException e) { @@ -462,6 +485,7 @@ public void run() { } catch (Exception e) { e.getStackTrace(); } + this.logger.debug("=== " + map.get("image_path_desc_center")); this.logger.debug("=== image_file_new2 : " + map.get("image_file_new2")); this.logger.info(String.format("============= : DefaultCarCenter 파일전송 전 ", new Object[0]));