152 lines
5.8 KiB
Java
152 lines
5.8 KiB
Java
package com.kbstar.eai.inbound.action;
|
||
|
||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||
import com.eactive.eai.adapter.AdapterManager;
|
||
import com.eactive.eai.agent.firstaccount.ShareMemory;
|
||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||
import com.eactive.eai.common.util.Logger;
|
||
import com.eactive.eai.common.util.MessageKeyExtractor;
|
||
import com.eactive.eai.inbound.action.ActionException;
|
||
import com.eactive.eai.inbound.action.RequestActionSupport;
|
||
|
||
/**
|
||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 KESA를 생성하기 위한 키값을 추출
|
||
* 2. 처리 개요 :
|
||
* - 어뎁터의 업무그룹코드를 키값앞에 추가한다.
|
||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||
* 3. 주의사항
|
||
*
|
||
* @author :
|
||
* @version : v 1.0.0
|
||
* @see :
|
||
* @since :
|
||
*/
|
||
public class CDSFirstAccountRequestAction extends RequestActionSupport
|
||
{
|
||
/**
|
||
* 1. 기능 : Inbound Adapter를 통해 전달받은 비표준메시지에서 KESA를 생성하기 위한 키값을 추출
|
||
* 2. 처리 개요 :
|
||
* - MessageKeyExtractor를 통해 Adapter별 추출 Rule에 따라 메시지를 구분할 수 있는 키값을 추출한다.
|
||
* 3. 주의사항
|
||
*
|
||
* @param message Object 타입의 요청메시지
|
||
* @return String 비표준메시지의 메시지키값
|
||
* @exception
|
||
**/
|
||
public String[] perform(Object message) throws ActionException
|
||
{
|
||
byte[] tmp = null;
|
||
String[] key = null;
|
||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||
String eaiBizCode = null;
|
||
if(adptGrpVO != null) {
|
||
eaiBizCode = adptGrpVO.getEaiBizCode();
|
||
}
|
||
else {
|
||
eaiBizCode = getEaiBizCodeFromAdapterName(adapterGroupName);
|
||
}
|
||
|
||
if(message instanceof byte[]) {
|
||
try {
|
||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||
} catch(Exception e) {
|
||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||
}
|
||
tmp = (byte[])message;
|
||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ new String(tmp));
|
||
} else {
|
||
try {
|
||
key = MessageKeyExtractor.getMessageKeyValue(this.adapterGroupName, message);
|
||
} catch(Exception e) {
|
||
throw new ActionException(ExceptionUtil.getErrorCode(e, "RECEAIIRA001"));
|
||
}
|
||
if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ message);
|
||
}
|
||
|
||
//집중계좌번호 호출 로직
|
||
ShareMemory sm = ShareMemory.getInstance();
|
||
String accNum = sm.getAccoutName();
|
||
|
||
for(int i=0; i<key.length; i++) {
|
||
|
||
//집중계좌 관련 추가 로직
|
||
//기본값 0000 이거나 null이면 아래로직 Pass
|
||
if(!"0000".equals(accNum) && accNum != null){
|
||
String[] parseAccount = accNum.split(";");
|
||
if( "0200310126".equals(key[i]) ) {
|
||
byte[] resCode = new byte[14];
|
||
System.arraycopy(message, 193, resCode, 0, 14);
|
||
for (int k = 0; k < parseAccount.length; k++) {
|
||
if(parseAccount[k].equals(new String(resCode).trim())){
|
||
key[i] = key[i] + "F";
|
||
}
|
||
}
|
||
}else if( "0200400120".equals(key[i]) ) {
|
||
byte[] resCode = new byte[14];
|
||
System.arraycopy(message, 193, resCode, 0, 14);
|
||
for (int k = 0; k < parseAccount.length; k++) {
|
||
if(parseAccount[k].equals(new String(resCode).trim())){
|
||
key[i] = key[i] + "F";
|
||
}
|
||
}
|
||
}else if( "0201400120".equals(key[i]) ) {
|
||
byte[] resCode = new byte[14];
|
||
System.arraycopy(message, 193, resCode, 0, 14);
|
||
for (int k = 0; k < parseAccount.length; k++) {
|
||
if(parseAccount[k].equals(new String(resCode).trim())){
|
||
key[i] = key[i] + "F";
|
||
}
|
||
}
|
||
}else if( "0200400100".equals(key[i]) ) {
|
||
byte[] resCode = new byte[14];
|
||
System.arraycopy(message, 193, resCode, 0, 14);
|
||
for (int k = 0; k < parseAccount.length; k++) {
|
||
if(parseAccount[k].equals(new String(resCode).trim())){
|
||
key[i] = key[i] + "F";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//----------------------------------------
|
||
key[i] = eaiBizCode.trim() + key[i];
|
||
}
|
||
|
||
return key;
|
||
}
|
||
|
||
public String getDescription() {
|
||
return "키추출방식 : 어댑터업무코드[3]+추출키값+집중계좌로직[F 추가?]";
|
||
}
|
||
|
||
// public static void main(String args[]) throws Exception {
|
||
// test(String args[]);
|
||
//}
|
||
|
||
//private static void test(String args[]) throws Exception {
|
||
// //byte[] message = "0248HDRELB02104000004000430201002111245423000007420100211004CN300000740040049277060060000060704095823902 0000000000001000공무원연금급여 0701 36013704003051 ".getBytes();
|
||
// byte[] message = "0473HDRISO0140000500200B238020148809000000000000380708C310126000000300000091516110627872216110609150010708170992359081=07099101916960700081070953343608170990053003436410 2059004=94450200175424020최성숙 007450991701174740000000020최성숙 70991019169607 1002810186967434000000000000000000000000000000000000000000000000000000000000000000****************************************************************************************************".getBytes();
|
||
// byte[] resCode = new byte[14];
|
||
// System.arraycopy(message, 193, resCode, 0, 14);
|
||
// /*
|
||
// String key = "";
|
||
// if("430".equals(new String(resCode))) {
|
||
// key = key + "430";
|
||
// }
|
||
// System.out.println(key);
|
||
// */
|
||
// System.out.println("["+new String(resCode).trim()+"]");
|
||
// String dd = "00001";
|
||
// if(!"0000".equals(dd) && dd != null){
|
||
// String[] parseAccount = dd.split(",");
|
||
// System.out.println(parseAccount.length );
|
||
// System.out.println(parseAccount[0]);
|
||
//
|
||
// }else{
|
||
// System.out.println("null");
|
||
// }
|
||
// }
|
||
|
||
}
|