package com.eactive.eai.custom.message;

import org.apache.commons.lang3.StringUtils;

import com.eactive.eai.message.StandardMessage;
import com.eactive.eai.message.service.DefaultInterfaceMapper;
import com.ext.eai.common.stdmessage.STDMessageKeys;

public class InterfaceMapperKBANK extends DefaultInterfaceMapper {

	private static final long serialVersionUID = 1L;
	
	//전문작성일시
	String ITEM_TLGR_WRTN_DT = "header_part.tlgrWrtnDt";
	//전문생성시스템
	String ITEM_TLGR_CRTN_SYS_NM = "header_part.tlgrCrtnSysNm";
	//전문일련번호
	String ITEM_TLGR_SRL_NO = "header_part.tlgrSrlNo";
	
	@Override
	public String getInExDivision(StandardMessage standardMessage) {
		return "2";
	}
	
	@Override
	public void setGuid(StandardMessage standardMessage, String guid) {
		String tlgrWrtnDt = StringUtils.substring(guid, 0, 14);
		String tlgrCrtnSysNm = StringUtils.substring(guid, 14, 22);
		String tlgrSrlNo = StringUtils.substring(guid, 22, 30);
		setItemValue(standardMessage, ITEM_TLGR_WRTN_DT, tlgrWrtnDt);
		setItemValue(standardMessage, ITEM_TLGR_CRTN_SYS_NM, tlgrCrtnSysNm);
		setItemValue(standardMessage, ITEM_TLGR_SRL_NO, tlgrSrlNo);
	}
	
	@Override
	public void setGuidSeq(StandardMessage standardMessage, String guidSeq) {
		if(guidSeq.length() == 1) {
			guidSeq = "0"+guidSeq;
		}
		super.setGuidSeq(standardMessage, guidSeq);
	}
	
	@Override
	public String getGuid(StandardMessage standardMessage) {
		String tlgrWrtnDt = getItemValue(standardMessage, ITEM_TLGR_WRTN_DT);
		String tlgrCrtnSysNm = getItemValue(standardMessage, ITEM_TLGR_CRTN_SYS_NM);
		String tlgrSrlNo = getItemValue(standardMessage, ITEM_TLGR_SRL_NO);
		return tlgrWrtnDt+tlgrCrtnSysNm+tlgrSrlNo;
	}
}
