feat: NICE CI 소켓 통신 추가

- 전문 응답 parsing
dev
Jonguk. Lim 2 months ago
parent fd9d600f55
commit c0a723538f

@ -23,12 +23,12 @@ import lombok.extern.slf4j.*;
* *
* </pre> * </pre>
*/ */
@Schema(name = "NiceCiCommon", description = "NICE CI 전문 공통 DTO") @Schema(name = "NiceCiApiCommon", description = "NICE CI API 전문 공통 DTO")
@Getter @Getter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Slf4j @Slf4j
public class NiceCiCommon { public class NiceCiApiCommon {
/** /**
* <pre> * <pre>
@ -198,7 +198,7 @@ public class NiceCiCommon {
return sb.toString(); return sb.toString();
} }
public static NiceCiCommon parse(String tgtString) { public static NiceCiApiCommon parse(String tgtString) {
final int[] parseLength = { final int[] parseLength = {
9, // 전문그룹코드 9, // 전문그룹코드
4, // 거래종별코드 4, // 거래종별코드
@ -214,7 +214,7 @@ public class NiceCiCommon {
}; };
if (StringUtils.isNotBlank(tgtString) && tgtString.length() >= 83) { if (StringUtils.isNotBlank(tgtString) && tgtString.length() >= 83) {
NiceCiCommon nc = new NiceCiCommon(); NiceCiApiCommon nc = new NiceCiApiCommon();
int idx = 0; int idx = 0;
nc.setGrpCode(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx]))); nc.setGrpCode(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
tgtString = tgtString.substring(parseLength[idx++]); tgtString = tgtString.substring(parseLength[idx++]);
@ -258,7 +258,7 @@ public class NiceCiCommon {
} }
public static void main(String[] args) { public static void main(String[] args) {
NiceCiHistoryDTO.Request nr = new NiceCiHistoryDTO.Request(); NiceCiHistoryApiDTO.Request nr = new NiceCiHistoryApiDTO.Request();
nr.setTrCode("0000006150"); nr.setTrCode("0000006150");
// // 공통부 // // 공통부
// //
@ -272,7 +272,7 @@ public class NiceCiCommon {
// 공통부 // 공통부
NiceCiCommon nc = new NiceCiCommon(); NiceCiApiCommon nc = new NiceCiApiCommon();
// nc.setGrpCode("grpCode"); // nc.setGrpCode("grpCode");
//nc.setTrType("Type"); //nc.setTrType("Type");
nc.setTrClassification("31895"); // 거래구분 nc.setTrClassification("31895"); // 거래구분
@ -280,7 +280,7 @@ public class NiceCiCommon {
nc.setOrgMngNo("0000000103"); // 기관관리번호 nc.setOrgMngNo("0000000103"); // 기관관리번호
nc.setOrgSndDt("20240919"); nc.setOrgSndDt("20240919");
System.out.println(NiceCiCommon.parse(nc.ofString())); System.out.println(NiceCiApiCommon.parse(nc.ofString()));
//sendNiceSocket(); //sendNiceSocket();
//serverSocket(); //serverSocket();
} }

@ -29,9 +29,9 @@ import lombok.*;
* *
* </pre> * </pre>
*/ */
public class NiceCiDTO { public class NiceCiApiDTO {
@Schema(name = "Request(Nice CI) DTO", description = "NICE CI 요청 전문 DTO") @Schema(name = "Request(Nice CI) API DTO", description = "NICE CI API 요청 전문 DTO")
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ -61,7 +61,7 @@ public class NiceCiDTO {
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
@Valid @Valid
NiceCiCommon niceCommon; NiceCiApiCommon niceCommon;
/** /**
* <pre> * <pre>
@ -351,7 +351,7 @@ public class NiceCiDTO {
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// 공통부 : 100 자리 // 공통부 : 100 자리
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
NiceCiCommon niceCommon; NiceCiApiCommon niceCommon;
/** /**
* <pre> * <pre>
@ -445,7 +445,7 @@ public class NiceCiDTO {
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// 응답반복부 : 110 자리 // 응답반복부 : 110 자리
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
List<NiceCiResult> niceCiResults = new ArrayList<>(); List<NiceCiApiResult> niceCiResults = new ArrayList<>();
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// 응답반복부 : 110 자리 // 응답반복부 : 110 자리
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
@ -488,7 +488,7 @@ public class NiceCiDTO {
response.setTrCode(StringUtils.left(tgtString, parseLength[idx])); response.setTrCode(StringUtils.left(tgtString, parseLength[idx]));
tgtString = tgtString.substring(parseLength[idx++]); tgtString = tgtString.substring(parseLength[idx++]);
response.setNiceCommon(NiceCiCommon.parse(tgtString)); response.setNiceCommon(NiceCiApiCommon.parse(tgtString));
tgtString = tgtString.substring(parseLength[idx++]); tgtString = tgtString.substring(parseLength[idx++]);
response.setCommonEmptyField(StringUtils.left(tgtString, parseLength[idx])); response.setCommonEmptyField(StringUtils.left(tgtString, parseLength[idx]));
@ -515,10 +515,10 @@ public class NiceCiDTO {
if(NiceCiUtils.lengthKr(tgtString) % repeatLength == 0){ if(NiceCiUtils.lengthKr(tgtString) % repeatLength == 0){
int repeat = NiceCiUtils.lengthKr(tgtString) / repeatLength; int repeat = NiceCiUtils.lengthKr(tgtString) / repeatLength;
String finalTgtString = tgtString; String finalTgtString = tgtString;
List<NiceCiResult> resResults = IntStream.range(0, repeat) List<NiceCiApiResult> resResults = IntStream.range(0, repeat)
.mapToObj(i -> { .mapToObj(i -> {
String currentString = NiceCiUtils.substringKr(finalTgtString, i * repeatLength); String currentString = NiceCiUtils.substringKr(finalTgtString, i * repeatLength);
return NiceCiResult.parse(currentString); return NiceCiApiResult.parse(currentString);
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
response.setNiceCiResults(resResults); response.setNiceCiResults(resResults);
@ -651,7 +651,7 @@ public class NiceCiDTO {
} }
public static void main(String[] args) { public static void main(String[] args) {
NiceCiDTO.Request ciRequest = new NiceCiDTO.Request(); NiceCiApiDTO.Request ciRequest = new NiceCiApiDTO.Request();
//ciRequest.setTrCode("0000006150"); //ciRequest.setTrCode("0000006150");
// // 공통부 // // 공통부
// //
@ -684,7 +684,7 @@ public class NiceCiDTO {
// 공통부 // 공통부
NiceCiCommon nc = new NiceCiCommon(); NiceCiApiCommon nc = new NiceCiApiCommon();
// nc.setGrpCode("grpCode"); // nc.setGrpCode("grpCode");
//nc.setTrType("Type"); //nc.setTrType("Type");
nc.setTrClassification("31895"); // 거래구분 nc.setTrClassification("31895"); // 거래구분
@ -716,7 +716,7 @@ public class NiceCiDTO {
// 응답반복부 // 응답반복부
"18401011449211name2 001 "+ "18401011449211name2 001 "+
"19412341234567이름2 1 "; "19412341234567이름2 1 ";
NiceCiDTO.Response niceResponse = NiceCiDTO.Response.parse(resStr); NiceCiApiDTO.Response niceResponse = NiceCiApiDTO.Response.parse(resStr);
System.out.println(niceResponse); System.out.println(niceResponse);
//sendNiceSocket(); //sendNiceSocket();
//serverSocket(); //serverSocket();

@ -20,11 +20,11 @@ import lombok.*;
* *
* </pre> * </pre>
*/ */
@Schema(name = "NiceCiResult", description = "NICE CI 결과 DTO") @Schema(name = "NiceCiApiResult", description = "NICE CI API 결과 DTO")
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class NiceCiResult { public class NiceCiApiResult {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// 연락처 이력 조회시만 // 연락처 이력 조회시만
@ -252,7 +252,7 @@ public class NiceCiResult {
// return sb.toString(); // return sb.toString();
// } // }
public static NiceCiResult parse(String tgtString) { public static NiceCiApiResult parse(String tgtString) {
// 110 자리 // 110 자리
final int[] parseLength = { final int[] parseLength = {
1, // 개인.사업자.법인구분 1, // 개인.사업자.법인구분
@ -269,7 +269,7 @@ public class NiceCiResult {
}; };
if (StringUtils.isNotBlank(tgtString) && NiceCiUtils.lengthKr(tgtString)%110 == 0) { if (StringUtils.isNotBlank(tgtString) && NiceCiUtils.lengthKr(tgtString)%110 == 0) {
NiceCiResult result = new NiceCiResult(); NiceCiApiResult result = new NiceCiApiResult();
int idx = 0; int idx = 0;
result.setIdDiv(StringUtils.left(tgtString, parseLength[idx])); result.setIdDiv(StringUtils.left(tgtString, parseLength[idx]));
@ -308,7 +308,7 @@ public class NiceCiResult {
return null; return null;
} }
public static NiceCiResult parseHistory(String tgtString) { public static NiceCiApiResult parseHistory(String tgtString) {
// 1150 // 1150
final int[] parseLength = { final int[] parseLength = {
20, // 조회일시 - 이력조회시만 사용 20, // 조회일시 - 이력조회시만 사용
@ -332,7 +332,7 @@ public class NiceCiResult {
}; };
if (StringUtils.isNotBlank(tgtString) && NiceCiUtils.lengthKr(tgtString)%1150 == 0) { if (StringUtils.isNotBlank(tgtString) && NiceCiUtils.lengthKr(tgtString)%1150 == 0) {
NiceCiResult result = new NiceCiResult(); NiceCiApiResult result = new NiceCiApiResult();
int idx = 0; int idx = 0;
// 이력조회시만 사용 //////////////////////////////////////////////////////// // 이력조회시만 사용 ////////////////////////////////////////////////////////

@ -30,9 +30,9 @@ import lombok.*;
* *
* </pre> * </pre>
*/ */
public class NiceCiHistoryDTO { public class NiceCiHistoryApiDTO {
@Schema(name = "Request(Nice CI History) DTO", description = "NICE CI 이력 요청 전문 DTO") @Schema(name = "Request(Nice CI History) API DTO", description = "NICE CI API 이력 요청 전문 DTO")
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ -62,7 +62,7 @@ public class NiceCiHistoryDTO {
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
@Valid @Valid
NiceCiCommon niceCommon; NiceCiApiCommon niceCommon;
/** /**
* <pre> * <pre>
@ -243,7 +243,7 @@ public class NiceCiHistoryDTO {
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// 공통부 : 100 자리 // 공통부 : 100 자리
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
NiceCiCommon niceCommon; NiceCiApiCommon niceCommon;
/** /**
* <pre> * <pre>
@ -298,7 +298,7 @@ public class NiceCiHistoryDTO {
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// 응답반복부 : 1150 자리 // 응답반복부 : 1150 자리
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
List<NiceCiResult> niceCiResults = new ArrayList<>(); List<NiceCiApiResult> niceCiResults = new ArrayList<>();
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
// 응답반복부 : 1150 자리 // 응답반복부 : 1150 자리
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
@ -337,7 +337,7 @@ public class NiceCiHistoryDTO {
nr.setTrCode(StringUtils.left(tgtString, parseLength[idx])); nr.setTrCode(StringUtils.left(tgtString, parseLength[idx]));
tgtString = tgtString.substring(parseLength[idx++]); tgtString = tgtString.substring(parseLength[idx++]);
nr.setNiceCommon(NiceCiCommon.parse(tgtString)); nr.setNiceCommon(NiceCiApiCommon.parse(tgtString));
tgtString = tgtString.substring(parseLength[idx++]); tgtString = tgtString.substring(parseLength[idx++]);
nr.setCommonEmptyField(StringUtils.left(tgtString, parseLength[idx])); nr.setCommonEmptyField(StringUtils.left(tgtString, parseLength[idx]));
@ -355,10 +355,10 @@ public class NiceCiHistoryDTO {
if(NiceCiUtils.lengthKr(tgtString) % repeatLength == 0){ if(NiceCiUtils.lengthKr(tgtString) % repeatLength == 0){
int repeat = NiceCiUtils.lengthKr(tgtString) / repeatLength; int repeat = NiceCiUtils.lengthKr(tgtString) / repeatLength;
String finalTgtString = tgtString; String finalTgtString = tgtString;
List<NiceCiResult> resResults = IntStream.range(0, repeat) List<NiceCiApiResult> resResults = IntStream.range(0, repeat)
.mapToObj(i -> { .mapToObj(i -> {
String currentString = NiceCiUtils.substringKr(finalTgtString, i * repeatLength); String currentString = NiceCiUtils.substringKr(finalTgtString, i * repeatLength);
return NiceCiResult.parseHistory(currentString); return NiceCiApiResult.parseHistory(currentString);
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
nr.setNiceCiResults(resResults); nr.setNiceCiResults(resResults);
@ -374,7 +374,7 @@ public class NiceCiHistoryDTO {
} }
public static void main(String[] args) { public static void main(String[] args) {
NiceCiHistoryDTO.Request ciHisRequest = new NiceCiHistoryDTO.Request(); NiceCiHistoryApiDTO.Request ciHisRequest = new NiceCiHistoryApiDTO.Request();
ciHisRequest.setTrCode("0000006150"); ciHisRequest.setTrCode("0000006150");
// // 공통부 // // 공통부
// //
@ -387,7 +387,7 @@ public class NiceCiHistoryDTO {
// 공통부 // 공통부
NiceCiCommon nc = new NiceCiCommon(); NiceCiApiCommon nc = new NiceCiApiCommon();
// nc.setGrpCode("grpCode"); // nc.setGrpCode("grpCode");
//nc.setTrType("Type"); //nc.setTrType("Type");
nc.setTrClassification("31895"); // 거래구분 nc.setTrClassification("31895"); // 거래구분
@ -408,7 +408,7 @@ public class NiceCiHistoryDTO {
// 응답반복부 // 응답반복부
"18401011449211name2 001 "+ "18401011449211name2 001 "+
"19412341234567이름2 1 "; "19412341234567이름2 1 ";
NiceCiHistoryDTO.Response niceResponse = NiceCiHistoryDTO.Response.parse(resStr); NiceCiHistoryApiDTO.Response niceResponse = NiceCiHistoryApiDTO.Response.parse(resStr);
System.out.println(niceResponse); System.out.println(niceResponse);
//sendNiceSocket(); //sendNiceSocket();
//serverSocket(); //serverSocket();

@ -58,8 +58,14 @@ public class NiceCiService {
+ "\n" + "\n"
+ "문의처 : 044-211-3377"; + "문의처 : 044-211-3377";
public EnsResponseVO<?> accept(){
return null;
}
public EnsResponseVO<?> requestSendBulk() { public EnsResponseVO<?> requestSendBulk() {
NiceCiDTO.Request ciRequest = new NiceCiDTO.Request(); NiceCiApiDTO.Request ciRequest = new NiceCiApiDTO.Request();
//ciRequest.setTrCode("0000006150"); //ciRequest.setTrCode("0000006150");
// // 공통부 // // 공통부
// //
@ -75,7 +81,7 @@ public class NiceCiService {
// nr.setContactSearchCode("1"); // nr.setContactSearchCode("1");
// 공통부 // 공통부
NiceCiCommon nc = new NiceCiCommon(); NiceCiApiCommon nc = new NiceCiApiCommon();
// nc.setGrpCode("grpCode"); // nc.setGrpCode("grpCode");
//nc.setTrType("Type"); //nc.setTrType("Type");
nc.setTrClassification("31895"); // 거래구분 nc.setTrClassification("31895"); // 거래구분
@ -83,8 +89,8 @@ public class NiceCiService {
nc.setOrgMngNo("0000000103"); // 기관관리번호 nc.setOrgMngNo("0000000103"); // 기관관리번호
nc.setOrgSndDt("20240919"); nc.setOrgSndDt("20240919");
NiceCiDTO.QueryRequest qr = new NiceCiDTO.QueryRequest(); NiceCiApiDTO.QueryRequest qr = new NiceCiApiDTO.QueryRequest();
NiceCiDTO.ButtonRequest br = new NiceCiDTO.ButtonRequest(); NiceCiApiDTO.ButtonRequest br = new NiceCiApiDTO.ButtonRequest();
ciRequest.setNiceCommon(nc); ciRequest.setNiceCommon(nc);
ciRequest.getQueryRequests().add(qr); ciRequest.getQueryRequests().add(qr);
@ -105,7 +111,7 @@ public class NiceCiService {
} }
public EnsResponseVO<?> findBulkStatus() { public EnsResponseVO<?> findBulkStatus() {
NiceCiHistoryDTO.Request ciRequest = new NiceCiHistoryDTO.Request(); NiceCiHistoryApiDTO.Request ciRequest = new NiceCiHistoryApiDTO.Request();
//ciRequest.setTrCode("0000006150"); //ciRequest.setTrCode("0000006150");
// // 공통부 // // 공통부
// //
@ -120,7 +126,7 @@ public class NiceCiService {
// nr.setContactSearchCode("1"); // nr.setContactSearchCode("1");
// 공통부 // 공통부
NiceCiCommon nc = new NiceCiCommon(); NiceCiApiCommon nc = new NiceCiApiCommon();
// nc.setGrpCode("grpCode"); // nc.setGrpCode("grpCode");
//nc.setTrType("Type"); //nc.setTrType("Type");
nc.setTrClassification("31895"); // 거래구분 nc.setTrClassification("31895"); // 거래구분
@ -128,8 +134,8 @@ public class NiceCiService {
nc.setOrgMngNo("0000000103"); // 기관관리번호 nc.setOrgMngNo("0000000103"); // 기관관리번호
nc.setOrgSndDt("20240919"); nc.setOrgSndDt("20240919");
NiceCiDTO.QueryRequest qr = new NiceCiDTO.QueryRequest(); NiceCiApiDTO.QueryRequest qr = new NiceCiApiDTO.QueryRequest();
NiceCiDTO.ButtonRequest br = new NiceCiDTO.ButtonRequest(); NiceCiApiDTO.ButtonRequest br = new NiceCiApiDTO.ButtonRequest();
ciRequest.setNiceCommon(nc); ciRequest.setNiceCommon(nc);

@ -50,9 +50,9 @@ public class NiceCiApiService {
private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
public EnsResponseVO<?> requestSendBulk(final NiceCiDTO.Request reqDTO) { public EnsResponseVO<?> requestSendBulk(final NiceCiApiDTO.Request reqDTO) {
List<String> errors = new ArrayList<>(); List<String> errors = new ArrayList<>();
final Set<ConstraintViolation<NiceCiDTO.Request>> list = validator.validate(reqDTO); final Set<ConstraintViolation<NiceCiApiDTO.Request>> list = validator.validate(reqDTO);
if (!list.isEmpty()) { if (!list.isEmpty()) {
errors.addAll(list.stream() errors.addAll(list.stream()
.map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate())) .map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate()))
@ -80,15 +80,15 @@ public class NiceCiApiService {
.errMsg(e.getMessage()) .errMsg(e.getMessage())
.build(); .build();
} }
NiceCiDTO.Response resDTO = NiceCiDTO.Response.parse(rtnMsg); NiceCiApiDTO.Response resDTO = NiceCiApiDTO.Response.parse(rtnMsg);
return EnsResponseVO.okBuilder() return EnsResponseVO.okBuilder()
.resultInfo(resDTO) .resultInfo(resDTO)
.build(); .build();
} }
public EnsResponseVO<?> findBulkStatus(final NiceCiHistoryDTO.Request reqDTO) { public EnsResponseVO<?> findBulkStatus(final NiceCiHistoryApiDTO.Request reqDTO) {
List<String> errors = new ArrayList<>(); List<String> errors = new ArrayList<>();
final Set<ConstraintViolation<NiceCiHistoryDTO.Request>> list = validator.validate(reqDTO); final Set<ConstraintViolation<NiceCiHistoryApiDTO.Request>> list = validator.validate(reqDTO);
if (!list.isEmpty()) { if (!list.isEmpty()) {
errors.addAll(list.stream() errors.addAll(list.stream()
.map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate())) .map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate()))
@ -116,7 +116,7 @@ public class NiceCiApiService {
.errMsg(e.getMessage()) .errMsg(e.getMessage())
.build(); .build();
} }
NiceCiHistoryDTO.Response resDTO = NiceCiHistoryDTO.Response.parse(rtnMsg); NiceCiHistoryApiDTO.Response resDTO = NiceCiHistoryApiDTO.Response.parse(rtnMsg);
return EnsResponseVO.okBuilder() return EnsResponseVO.okBuilder()
.resultInfo(resDTO) .resultInfo(resDTO)
.build(); .build();

@ -2,7 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cokr.xit.ens.modules.kkotalk.mapper.IKkoTalkMapper"> <mapper namespace="cokr.xit.ens.modules.kkotalk.mapper.IKkoTalkMapper">
<!-- // FIXME: 카카오톡 신규 추가 -->
<!-- =================================================================================== --> <!-- =================================================================================== -->
<!-- ================================ accept =========================================== --> <!-- ================================ accept =========================================== -->
<!-- =================================================================================== --> <!-- =================================================================================== -->

Loading…
Cancel
Save