diff --git a/src/main/java/cokr/xit/ens/core/utils/DateUtil.java b/src/main/java/cokr/xit/ens/core/utils/DateUtil.java index 8e9636d..17f20be 100644 --- a/src/main/java/cokr/xit/ens/core/utils/DateUtil.java +++ b/src/main/java/cokr/xit/ens/core/utils/DateUtil.java @@ -520,6 +520,20 @@ public class DateUtil { return LocalDateTime.parse(target); } + /** + *
+ * 현재시간을 microsecond 까지 포함한 형태로 반환 + * yyyyMMddHHmmssSSSSSSS + *+ * @return String yyyyMMddHHmmssSSSSSSS 포맷으로 + */ + public static String getNowTimeMicrosecond() { + ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Asia/Seoul")); + // 6자리 나노초까지 포함된 포맷 지정 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSSSSSS"); + return now.format(formatter); + } + /** ** 년 월 일 계산 @@ -590,5 +604,6 @@ public class DateUtil { System.out.println(getAddDayT("2024-10-30T23:59:59", 1)); System.out.println(isAfterLocalDateTimeT("2024-10-30T23:59:59", "2024-10-30T23:59:58")); System.out.println(isAfterLocalDateTimeT("2024-10-31T23:59:59", "2024-10-30T23:59:58")); + System.out.println(getNowTimeMicrosecond()); } } diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/Client.java b/src/main/java/cokr/xit/ens/modules/nice/model/Client.java new file mode 100644 index 0000000..bbfd9a9 --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/nice/model/Client.java @@ -0,0 +1,87 @@ +package cokr.xit.ens.modules.nice.model; + +import java.io.*; +import java.net.*; +import java.nio.charset.*; + +public class Client { + public static void main(String[] args) { + + final String msg = "0000006438NICEIF 020031895B503 Z755400 000000010320240919 4 誘쇱����濡� 愿�由ъ����쇳�곗���� 源��댁갔��猿� 諛��≫�� 誘몃�⑺�듯��猷� 怨�吏���媛� ��李⑺���듬����.\n" + + "\n" + + "誘쇱����濡� 誘몃�⑺�듯��猷� 怨�吏���\n" + + "\n" + + "�� 李⑤��踰��� : 19��0914\n" + + "�� 誘몃�⑸��� �몄�� : ����-臾몄��\n" + + "�� 誘몃�⑸��� 湲곌� : 2021�� 04�� 12��~2023�� 08�� 30��\n" + + "�� �⑸�湲��� : 819,500��(42嫄�)\n" + + "�� �⑸�湲고�� : 2024��10��01��\n" + + "�� �⑸�諛⑸� : \n" + + "�� ���⑥�� (�⑸���湲�) �대┃\n" + + "�� 媛���怨�醫� �⑸�\n" + + "-(媛���怨�醫�) : �������� 792000-36-986609\n" + + "援�誘쇱���� 731190-72-253083\n" + + "�곕━���� 283752-73-918780\n" + + "�������� 562146-27-470101\n" + + "\n" + + "�� ��由쇳�� ���� �� 醫��닿�吏����� 諛��〓��吏� ���듬����.\n" + + "\n" + + "臾몄��泥� : 044-211-3377 31 1 WL "; + + final String msg2 = "0000006150NICEIF 020031895B503 Z755400 000000010320240919 4 민자도로 관리지원센터에서 김해찬님께 발송한 미납통행료 고지서가 도착했습니다.\n" + + "\n" + + "민자도로 미납통행료 고지서\n" + + "\n" + + "□ 차량번호 : 19너0914\n" + + "□ 미납발생 노선 : 서울-문산\n" + + "□ 미납발생 기간 : 2021년 04월 12일~2023년 08월 30일\n" + + "□ 납부금액 : 819,500원(42건)\n" + + "□ 납부기한 : 2024년10월01일\n" + + "□ 납부방법 : \n" + + "① 하단의 (납부하기) 클릭\n" + + "② 가상계좌 납부\n" + + "-(가상계좌) : 농협은행 792000-36-986609\n" + + "국민은행 731190-72-253083\n" + + "우리은행 283752-73-918780\n" + + "신한은행 562146-27-470101\n" + + "\n" + + "※ 알림톡 수신 시 종이고지서는 발송되지 않습니다.\n" + + "\n" + + "문의처 : 044-211-3377 31 1 WL " + + "\n "; + + try (Socket socket = new Socket("localhost", 12345); // 서버에 연결 + BufferedWriter out = new BufferedWriter( + new OutputStreamWriter(socket.getOutputStream(), Charset.forName("EUC-KR"))); + //new OutputStreamWriter(socket.getOutputStream())); + BufferedReader in = new BufferedReader( + new InputStreamReader(socket.getInputStream(), Charset.forName("EUC-KR")))) { + + // 서버로 메시지 전송 + // String message = "클라이언트에서 보내는 메시지"; + // out.write(message); + // out.newLine(); + // out.write("-------------------------------------------------------------------"); + // out.newLine(); + // // + out.write(msg2); + out.newLine(); + out.flush(); + + // 서버로부터 응답 받기 (EUC-KR -> UTF-8 변환) + String rtnMsg; + // while((rtnMsg = in.readLine()) != null){ + // System.out.println("서버 응답 (EUC-KR로 읽어온 값): " + rtnMsg); + // }; + //String responseUTF8 = new String(response.getBytes(Charset.forName("EUC-KR")), StandardCharsets.UTF_8); + //String responseUTF8 = new String(response.getBytes()); + + rtnMsg = in.readLine(); + System.out.println("=============>>>서버 응답 (EUC-KR로 읽어온 값)<<<===================================="); + System.out.println(rtnMsg); + System.out.println("=============>>>서버 응답 (EUC-KR로 읽어온 값)<<<===================================="); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/Server.java b/src/main/java/cokr/xit/ens/modules/nice/model/Server.java new file mode 100644 index 0000000..026a454 --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/nice/model/Server.java @@ -0,0 +1,65 @@ +package cokr.xit.ens.modules.nice.model; + +import java.io.*; +import java.net.*; +import java.nio.charset.*; + +import org.apache.commons.lang.*; + +public class Server { + + public static void main(String[] args) { + + try (ServerSocket serverSocket = new ServerSocket(12345)) { // 포트 12345에서 서버 소켓 열기 + System.out.println("서버가 시작되었습니다."); + + while (true) { + Socket clientSocket = serverSocket.accept(); // 클라이언트 연결 수락 + new Thread(() -> handleClient(clientSocket)).start(); // 새로운 스레드에서 클라이언트 처리 + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void handleClient(Socket clientSocket) { + final String res = "trCode " + + // NiceCommon + "NICEIF 020031895B503rsltorgId orgMngNo orgSndDt niceMngNo niceSndDt" + + " "+ + // 개별응답부 + "241~~~~~~~~~~~~~~~~~~~~~~~ 010 1 "+ + // 응답반복부 + "18401011449211name2 001 "+ + "19412341234567이름2 1 "; + + try (BufferedReader in = new BufferedReader( + new InputStreamReader(clientSocket.getInputStream(), Charset.forName("EUC-KR"))); + BufferedWriter out = new BufferedWriter( + new OutputStreamWriter(clientSocket.getOutputStream(), Charset.forName("EUC-KR")))) { + + // 클라이언트로부터 메시지 읽기 + String message; + StringBuffer sb = new StringBuffer(); + while((message = in.readLine()) != null && !(message.length() >= 10 && StringUtils.isEmpty(message.trim()))) { // 빈 줄이 들어올 때까지 읽기 + sb.append(message); + }; + System.out.println("=============>>>클라이언트로부터 받은 메시지<<<===================================="); + System.out.println(sb.toString()); + System.out.println("=============>>>클라이언트로부터 받은 메시지<<<===================================="); + + // 응답 메시지 작성 및 전송 + out.write(res); + out.newLine(); + out.flush(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + clientSocket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/resources/config/conf-contract.yml b/src/main/resources/config/conf-contract.yml index 14d0a34..896d9f4 100644 --- a/src/main/resources/config/conf-contract.yml +++ b/src/main/resources/config/conf-contract.yml @@ -133,3 +133,12 @@ contract: bulksend: /api/msg/send bulksend-batch-unit: 100 read: /api/msg/read + + niceCi: + ip: 10.1.1.55 + port: 10002 + orgId: Z755400 + # 개발 + clientId: 0027370001 + # 운영 + #clientId: 0027370002