광주은행 표준전문 대응 v0.1
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package com.eactive.eai.custom.message;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.eactive.eai.common.server.Keys;
|
||||
import com.eactive.eai.common.util.StringUtil;
|
||||
import com.eactive.eai.common.util.UUID;
|
||||
|
||||
/**
|
||||
* 1. 기능 : UUID Generation Class 2. 처리 개요 : * - 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see : 관련 기능을 참조
|
||||
* @since : :
|
||||
*/
|
||||
public final class GUIDGeneratorKJB {
|
||||
|
||||
private static final DateTimeFormatter SDF_YYYYMMDDHHMMSS = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
|
||||
/*
|
||||
* 그룹사코드(3) + 호스트명(8) + 서버구분번호(2) + 일자(8) + 전문생성시간(6) + 일련번호(6) + 시스템경로번호(3, '001')
|
||||
*/
|
||||
|
||||
public static final int GUID_LENGTH = 33; // 시스템경로번호 제외부분
|
||||
|
||||
/**
|
||||
* 1. 기능 : Private 생성자 2. 처리 개요 : - 3. 주의사항 - Instance 생성하지 못함
|
||||
**/
|
||||
private GUIDGeneratorKJB() {
|
||||
}
|
||||
|
||||
public synchronized static String getGUID(String groupCmpCd) {
|
||||
if (StringUtils.isEmpty(groupCmpCd)) groupCmpCd = "034"; //광주은행 그룹회사코드 "034"
|
||||
|
||||
String nowDateTime = SDF_YYYYMMDDHHMMSS.format(ZonedDateTime.now());
|
||||
String strSeq = StringUtils.leftPad(String.valueOf(seq), 6, '0') ;
|
||||
String guid = groupCmpCd + UNIQUE_NUM + nowDateTime + strSeq + "001";
|
||||
|
||||
seq++;
|
||||
if (seq > 999999) {
|
||||
seq = 1;
|
||||
}
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
private static String UNIQUE_NUM;
|
||||
private static int seq = 1;
|
||||
static {
|
||||
String hostname = "";
|
||||
try {
|
||||
hostname = java.net.InetAddress.getLocalHost().getHostName();
|
||||
}
|
||||
catch(Exception e) {
|
||||
hostname = "________";
|
||||
}
|
||||
|
||||
if(hostname.getBytes().length != 8) {
|
||||
if(hostname.getBytes().length < 8) {
|
||||
hostname = StringUtils.leftPad(hostname, 8, '_');
|
||||
} else if(hostname.getBytes().length > 8) {
|
||||
hostname = StringUtils.substring(hostname, 0, 8);
|
||||
}
|
||||
}
|
||||
|
||||
String serverName = System.getProperty(Keys.SERVER_KEY);
|
||||
String instid = "00";
|
||||
if(serverName != null && serverName.length() > 2) {
|
||||
instid = serverName.substring(serverName.length()-2, serverName.length());
|
||||
}
|
||||
|
||||
UNIQUE_NUM = hostname.toUpperCase() + instid;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String guid = getGUID("051");
|
||||
System.out.println("[" + guid.length() + "]" + guid);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class InterfaceMapperKBANK extends DefaultInterfaceMapper {
|
||||
|
||||
@Override
|
||||
public String getInExDivision(StandardMessage standardMessage) {
|
||||
return "1";
|
||||
return "2";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
package com.eactive.eai.custom.message;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.common.util.StringUtil;
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.service.DefaultInterfaceMapper;
|
||||
import com.ext.eai.common.stdmessage.STDMessageKeys;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class InterfaceMapperKJB extends DefaultInterfaceMapper {
|
||||
private static String SESSION_ID = "INTERFACE_COMMON.MCI_SESN_ID";
|
||||
private static String INSTANCE_ID = "INTERFACE_COMMON.MCI_INSTNC_ID";
|
||||
|
||||
@Override
|
||||
public String getEaiSvcCode(StandardMessage standardMessage) {
|
||||
String eaiSvcCode = null;
|
||||
String interfaceId = getInterfaceId(standardMessage);
|
||||
String returnType = getSendRecvDivision(standardMessage); // S | R
|
||||
String inExDivision = getInExDivision(standardMessage); // 1 | 2
|
||||
if (interfaceId == null)
|
||||
interfaceId = "";
|
||||
interfaceId = interfaceId.trim();
|
||||
|
||||
// TODO : site에 맞게 조합해야 함.
|
||||
eaiSvcCode = interfaceId + returnType + StringUtils.defaultString(inExDivision);
|
||||
return eaiSvcCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuid(StandardMessage standardMessage, String guid) {
|
||||
if (guid == null)
|
||||
throw new RuntimeException("guid is null");
|
||||
if (guid.length() != 36)
|
||||
throw new RuntimeException("The length of guid is not 36");
|
||||
setItemValue(standardMessage, getPath(GUID), guid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuid(StandardMessage standardMessage) {
|
||||
String guid = getItemValue(standardMessage, getPath(GUID));
|
||||
if (guid.length() == 36) {
|
||||
guid = guid.substring(0, 33);
|
||||
}
|
||||
return guid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuidSeq(StandardMessage standardMessage) {
|
||||
String guidseq = null;
|
||||
String guid = getItemValue(standardMessage, getPath(GUID));
|
||||
if (guid.length() == 36) {
|
||||
guidseq = guid.substring(33);
|
||||
} else {
|
||||
guidseq = "000";
|
||||
}
|
||||
return guidseq;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuidSeq(StandardMessage standardMessage, String guidSeq) {
|
||||
setItemValue(standardMessage, getPath(GUID), getGuid(standardMessage) + guidSeq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOrgGuid(StandardMessage standardMessage) {
|
||||
String orgGuid = getItemValue(standardMessage, getPath(GUID_ORG));
|
||||
if (orgGuid.length() == 36) {
|
||||
orgGuid = orgGuid.substring(0, 33);
|
||||
}
|
||||
return orgGuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrgGuid(StandardMessage standardMessage, String orgGuid) {
|
||||
if (orgGuid.length() == 36) {
|
||||
orgGuid = orgGuid.substring(0, 33);
|
||||
}
|
||||
setItemValue(standardMessage, getPath(GUID_ORG), orgGuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nextGuidSeq(StandardMessage standardMessage) {
|
||||
String guidSeq = getGuidSeq(standardMessage);
|
||||
if (guidSeq == null)
|
||||
return "";
|
||||
int seq = 0;
|
||||
try {
|
||||
seq = Integer.parseInt(guidSeq) + 1;
|
||||
} catch (NumberFormatException e) {
|
||||
seq = 1;
|
||||
}
|
||||
guidSeq = StringUtil.stringFormat(Integer.toString(seq), true, '0', 3);
|
||||
setGuidSeq(standardMessage, guidSeq);
|
||||
return guidSeq;
|
||||
}
|
||||
|
||||
/**
|
||||
* 표준전문의 복원은 COMMON.ORTR_RESTR_YN 의 value는 (Y/N) 엔진에서 복원여부 의 value는 (1/0)
|
||||
*/
|
||||
@Override
|
||||
public String getRecoverYn(StandardMessage standardMessage) {
|
||||
String data = getItemValue(standardMessage, getPath(RECOVER_YN));
|
||||
if ("Y".equals(data)) {
|
||||
return "1";
|
||||
} else {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecoverYn(StandardMessage standardMessage, String recoverYn) {
|
||||
if ("1".equals(recoverYn)) {
|
||||
setItemValue(standardMessage, getPath(RECOVER_YN), "Y");
|
||||
} else {
|
||||
setItemValue(standardMessage, getPath(RECOVER_YN), "N");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstCode(StandardMessage standardMessage) {
|
||||
EAIServerManager server = EAIServerManager.getInstance();
|
||||
if (server != null && server.isMCI()) {
|
||||
return getItemValue(standardMessage, INSTANCE_ID);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstCode(StandardMessage standardMessage, String instCode) {
|
||||
EAIServerManager server = EAIServerManager.getInstance();
|
||||
if (server != null && server.isMCI()) {
|
||||
setItemValue(standardMessage, INSTANCE_ID, instCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionId(StandardMessage standardMessage) {
|
||||
EAIServerManager server = EAIServerManager.getInstance();
|
||||
if (server != null && server.isMCI()) {
|
||||
return getItemValue(standardMessage, SESSION_ID);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionId(StandardMessage standardMessage, String sessionId) {
|
||||
EAIServerManager server = EAIServerManager.getInstance();
|
||||
if (server != null && server.isMCI()) {
|
||||
setItemValue(standardMessage, SESSION_ID, sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 엔진 에서는 public static final String RESPONSE_TYPE_CODE_N = "0";//정상(normal)
|
||||
* public static final String RESPONSE_TYPE_CODE_E = "1";//오류(error)
|
||||
*/
|
||||
@Override
|
||||
public void setResponseType(StandardMessage standardMessage, String responseType) {
|
||||
if (responseType != null && (STDMessageKeys.RESPONSE_TYPE_CODE_N.equals(responseType)
|
||||
|| STDMessageKeys.RESPONSE_TYPE_CODE_E.equals(responseType))) {
|
||||
if (STDMessageKeys.RESPONSE_TYPE_CODE_N.equals(responseType)) {
|
||||
setItemValue(standardMessage, getPath(RESPONSE_TYPE), "NR");
|
||||
} else {
|
||||
setItemValue(standardMessage, getPath(RESPONSE_TYPE), "ER");
|
||||
}
|
||||
} else {
|
||||
setItemValue(standardMessage, getPath(RESPONSE_TYPE), responseType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInterfaceId(StandardMessage standardMessage) {
|
||||
String interfaceId = getItemValue(standardMessage, getPath(INTERFACE_ID));
|
||||
if (interfaceId == null)
|
||||
return "";
|
||||
interfaceId = interfaceId.trim();
|
||||
return interfaceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReqSysCode(StandardMessage standardMessage) {
|
||||
// apiPath의 값에서 추출할 예정 : serviceId = api_path
|
||||
String apiPath = getItemValue(standardMessage, getPath(SERVICE_ID));
|
||||
if (apiPath != null) {
|
||||
String[] split = apiPath.split("/");
|
||||
if (split.length > 2) {
|
||||
String route = split[1].toUpperCase();
|
||||
if (route.length() > 3) {
|
||||
route = route.substring(0, 3);
|
||||
}
|
||||
return route;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user