광주은행 표준전문 관련 작업

This commit is contained in:
yunjy-hp
2025-12-09 13:46:56 +09:00
parent c5ad5f7b7d
commit 24958ac00e
6 changed files with 76 additions and 17 deletions
@@ -5,6 +5,7 @@ import com.eactive.eai.adapter.http.client.HttpClient5AdapterServiceSupport;
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
import com.eactive.eai.adapter.http.client.HttpClientAdapterVO;
import com.eactive.eai.common.TransactionContextKeys;
import com.eactive.eai.common.message.MessageType;
import com.eactive.eai.common.util.CommonLib;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.lang3.StringUtils;
@@ -57,14 +58,16 @@ public class HttpClient5AdapterServiceBody extends HttpClient5AdapterServiceSupp
} else if (data instanceof byte[]) {
sendData = new String((byte[]) data, vo.getEncode());
}
ObjectMapper mapper = new ObjectMapper();
ObjectNode jsonNode = (ObjectNode) mapper.readTree(sendData);
ObjectNode headerPart = (ObjectNode) jsonNode.get("header_part");
if( headerPart.get("mciIntfId") != null && headerPart.get("mciIntfId").asText().trim().length() > 0 ) {
headerPart.put("eaiIntfId", "");
sendData = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode);
if(MessageType.JSON.equals(prop.getProperty("messageType"))) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode jsonNode = (ObjectNode) mapper.readTree(sendData);
ObjectNode headerPart = (ObjectNode) jsonNode.get("header_part");
if( headerPart.get("mciIntfId") != null && headerPart.get("mciIntfId").asText().trim().length() > 0 ) {
headerPart.put("eaiIntfId", "");
sendData = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonNode);
}
}
if ("Y".equals(vo.getUrlEncodeYn())) {
@@ -33,7 +33,9 @@ public abstract class Process {
String outboundAdapterGroupName = eaiMessage.getCurrentSvcMsg().getPsvSysItfTp();
AdapterGroupVO outboundAdapterGvo = AdapterManager.getInstance().getAdapterGroupVO(outboundAdapterGroupName);
standardMessage.setBizData(bizObject, outboundAdapterGvo.getMessageEncode());
StandardMessageManager.getInstance().getMessageCoordinator().coordinateBeforeStandardMessageSend(standardMessage, msgType, charset);
if(MessageType.JSON.equals(msgType)) {
return standardMessage.toJson();
}
@@ -1222,6 +1222,9 @@ public class RequestProcessor extends RequestProcessorSupport {
logger.error("convertToSub failed.", e);
}
}
//응답 전 표준 전문의 로직 처리 필요 한 경우를 위해 호출
standardManager.getMessageCoordinator().coordinateBeforeResponse(standardMessage, vo, prop, inboundCharset);
// 10. 응답 거래로그 Logging
if(EAIMessageKeys.SYNC_SVC.equals(svcTsmtUsgTp) &&
@@ -107,16 +107,22 @@ public class FlatReader implements StandardReader {
case StandardType.GROUP:
logger.debug("@GROUP name={}, getLength={}, getRefPath={}, getRefValue=[{}]"
, currentItem.getName(), currentItem.getLength(), currentItem.getRefPath(), currentItem.getRefValue());
if( currentItem.getSize() == 0
&& StringUtils.isNotBlank(currentItem.getRefPath())
if( currentItem.getSize() == 0
&& StringUtils.isNotBlank(currentItem.getRefPath())
&& StringUtils.isNotBlank(currentItem.getRefValue()) ) {
String refItemValue = itemMap.get(currentItem.getRefPath());
//2024.08.07 아래추가로직은 Group 하위의 field 값에 따라서
//파싱을 해야 될경우 추가
String refItemValue ="";
if (currentItem.getRefPath().startsWith(fieldName)){
refItemValue = getRefItemValue(currentItem.getRefPath(), fieldName, srcbytes, currentItem, start);
}else{
refItemValue = itemMap.get(currentItem.getRefPath());
}
logger.debug("@GROUP name={}, getRefPath={}, refItemValue=[{}], getRefValue=[{}]"
, currentItem.getName(), currentItem.getRefPath(), refItemValue, currentItem.getRefValue());
if(refItemValue != null) refItemValue = refItemValue.trim();
/*
* 값의 경우의수 NR,ER,""(blank)
* ER이 아닐경우 표현하고 싶어서 ! 를 추가했음
@@ -284,6 +290,26 @@ public class FlatReader implements StandardReader {
}
return result;
}
private String getRefItemValue(String orgRef, String fieldName, byte[] srcbytes , StandardItem currentItem ,int start ){
String currentFieldName = orgRef.replace(fieldName+".","");
ArrayList<StandardItem> childList = currentItem.getChildsList();
String refItemValue ="";
for(StandardItem item : childList) {
if (currentFieldName.indexOf(".") < 0) {
byte[] tempValue = null;
if (orgRef.equals(fieldName + "." + item.getName())) {
tempValue = cut(fieldName, srcbytes, start, item.getLength());
return new String(tempValue);
}else{
start = start + item.getLength();
}
} else {
return getRefItemValue(orgRef, fieldName+"."+item.getName(), srcbytes, item, start);
}
}
return refItemValue;
}
// public static void main(String[] args) {
// }
}
@@ -25,6 +25,11 @@ public class DefaultStandardMessageCoordinator implements StandardMessageCoordin
mapper.setGuid(standardMessage, UUIDGenerator.getGUID(eaiServerManager.getSystemType()));
}
@Override
public void coordinateBeforeStandardMessageSend(StandardMessage standardMessage, String msgType, String charset) {
}
@Override
public void coordinateInReturnObject(StandardMessage standardMessage) {
}
@@ -72,5 +77,7 @@ public class DefaultStandardMessageCoordinator implements StandardMessageCoordin
}
@Override
public void coordinateBeforeResponse(StandardMessage standardMessage, ProcessVO processVO, Properties prop, String charset) {
}
}
@@ -26,7 +26,14 @@ public interface StandardMessageCoordinator {
* @param prop
*/
public void coordinateAfterCreateMessageByRule(StandardMessage standardMessage, Object paramObject, Properties prop);
/**
* 표준전문 송신 전 메시지 조립 전 처리
*
* @param standardMessage
*/
public void coordinateBeforeStandardMessageSend(StandardMessage standardMessage, String msgType, String charset);
/**
* 표준 메시지일경우 ReturnObject 에서 처리
*
@@ -97,4 +104,15 @@ public interface StandardMessageCoordinator {
* @param responseMessage
*/
public void coordinateAfterRecvNonStdSyncResponse(StandardMessage responseMessage);
/**
* RequestProcess 400 응답 로그 전 표준 메시지 조작 처리
*
* @param standardMessage
* @param processVO
* @param prop
* @param charset
*/
public void coordinateBeforeResponse(StandardMessage standardMessage, ProcessVO processVO, Properties prop, String charset);
}