111 lines
4.4 KiB
Java
111 lines
4.4 KiB
Java
package com.kbstar.eai.common.header;
|
|
|
|
import com.eactive.eai.common.header.HeaderActionSupport;
|
|
import com.eactive.eai.common.util.DatetimeUtil;
|
|
import com.eactive.eai.common.util.StringUtil;
|
|
|
|
|
|
/**
|
|
* 1. 기능 : 연계기관 의 Header를 EAI에서 생성하거나 삭제해야하는 경우를 위한 Class
|
|
* 2. 처리 개요 :
|
|
* - 메시지종류에 따라 헤더를 생성하거나 삭제하는 API를 제공
|
|
* 3. 주의사항
|
|
* - AD 의 경우는 S는 ADD, R 는 DELETE
|
|
* - DA 의 경우는 S는 DELETE, R 는 ADD
|
|
* @author :
|
|
* @version : v 1.0.0
|
|
* @see :
|
|
* @since :
|
|
*/
|
|
public class CYUHeaderAction extends HeaderActionSupport
|
|
{
|
|
private static final int HEADER_LENGTH = 30; // 연계 - 기관간의 헤더Length
|
|
// private static int mCount = 0;
|
|
|
|
public CYUHeaderAction(){
|
|
super.setHeaderLength(HEADER_LENGTH);
|
|
|
|
}
|
|
|
|
public byte[] addHeaderDA(byte[] orgData , byte[] message ) {
|
|
return addHeader(orgData,message);
|
|
}
|
|
public byte[] addHeaderAD(byte[] orgData , byte[] message ) {
|
|
return addHeader(orgData,message);
|
|
}
|
|
|
|
public byte[] addHeader(byte[] orgData , byte[] message ) {
|
|
String tranOccurPath = "E"; // 거래발생 경로(1)
|
|
String serverName = "EAISVR1"; // 서버이름(7)
|
|
String sysMinHMSUnit = ""; // 거래시간(12)
|
|
String tranSysDstcd = "1"; // 거래처리시스템 구분(1)
|
|
String tranLogRecrdEonot = "2"; // 거래log Dump 기록유무(1)
|
|
String Blnk0 = " "; // Filler (8)
|
|
|
|
int msgLength = message.length + HEADER_LENGTH;
|
|
|
|
sysMinHMSUnit = StringUtil.stringFormat(DatetimeUtil.getFormattedDate("HHmmssSSS"), false, ' ', 12);
|
|
|
|
StringBuffer sb = new StringBuffer(30);
|
|
sb.append(tranOccurPath);
|
|
sb.append(serverName);
|
|
sb.append(sysMinHMSUnit);
|
|
sb.append(tranSysDstcd);
|
|
sb.append(tranLogRecrdEonot);
|
|
sb.append(Blnk0);
|
|
|
|
byte[] retHeader = new byte[msgLength];
|
|
|
|
System.arraycopy(sb.toString().getBytes(), 0, retHeader, 0, HEADER_LENGTH);
|
|
System.arraycopy(message, 0, retHeader, HEADER_LENGTH, retHeader.length-HEADER_LENGTH);
|
|
return retHeader;
|
|
}
|
|
// public static void main(String args[]) throws Exception {
|
|
// test();
|
|
//}
|
|
|
|
// private static void test() throws Exception {
|
|
// String actionName = "com.kbstar.eai.common.header.CYUHeaderAction";
|
|
//
|
|
//
|
|
// /////전송 AD
|
|
//// HeaderAction action = HeaderActionFactory.createAction(actionName);
|
|
////
|
|
//// Object[] bizObjs =new Object[1];
|
|
//// bizObjs[0] = "1234567890".getBytes();
|
|
//// Object bizObj = null;
|
|
//// if(bizObjs != null && bizObjs.length > 0) {
|
|
//// bizObj = bizObjs[0];
|
|
//// }
|
|
//// byte[] orgData = null;
|
|
//// System.out.println("orgData=>"+new String(orgData==null?"".getBytes():orgData));
|
|
//// System.out.println("message=>"+new String(bizObj==null?"".getBytes():(byte[])bizObj));
|
|
//// System.out.println("sendRecv=>"+HeaderActionKeys.MESSAGE_SEND);
|
|
//// System.out.println("commandType=>"+HeaderActionKeys.ADD_DELETE_HEADER);
|
|
//// byte[] header = action.excute(orgData ,(byte[])bizObj, HeaderActionKeys.MESSAGE_SEND, HeaderActionKeys.ADD_DELETE_HEADER);
|
|
//// System.out.println("header=>"+new String(header));
|
|
// /////////////
|
|
//
|
|
// /////수신 AD
|
|
// HeaderAction action = HeaderActionFactory.createAction(actionName);
|
|
//
|
|
// Object[] bizObjs =new Object[1];
|
|
// bizObjs[0] = "EEAISVR1135201896 12 1234567890".getBytes();
|
|
// Object bizObj = null;
|
|
// if(bizObjs != null && bizObjs.length > 0) {
|
|
// bizObj = bizObjs[0];
|
|
// }
|
|
// byte[] orgData = null;
|
|
// //orgData = new byte[((byte[])bizObj).length ];
|
|
// //System.arraycopy(((byte[])bizObj), 0, orgData, 0,orgData.length);
|
|
// System.out.println("orgData=>"+new String(orgData==null?"".getBytes():orgData));
|
|
// System.out.println("message=>"+new String(bizObj==null?"".getBytes():(byte[])bizObj));
|
|
// System.out.println("sendRecv=>"+HeaderActionKeys.MESSAGE_RECV);
|
|
// System.out.println("commandType=>"+HeaderActionKeys.ADD_DELETE_HEADER);
|
|
//
|
|
// byte[] header = action.excute(orgData ,(byte[])bizObj, HeaderActionKeys.MESSAGE_RECV, HeaderActionKeys.ADD_DELETE_HEADER);
|
|
// System.out.println("header=>"+new String(header));
|
|
// }
|
|
}
|
|
|