package com.eactive.eai.batch.job.jobItem.ksnet;

import java.io.ByteArrayOutputStream;

import com.eactive.eai.common.exception.ExceptionUtil;

import com.eactive.eai.batch.job.jobItem.DefaultTelegram;
import com.eactive.eai.batch.job.jobItem.TelegramService;

public class RECV_KSN25_0690 extends DefaultTelegram implements TelegramService
{
    /**
     * 생성자
     */
    public RECV_KSN25_0690() {
    }

    public boolean doPostExecute() {
        if (!super.doPostExecute()) return false;
        try {
            //DB로그에 남길 전문 헤더 설정
            ByteArrayOutputStream baout = new ByteArrayOutputStream();
            for (int i=0; i<this.al_Field.size(); i++) {
                baout.write((byte[])this.al_Field.get(i));
            }
            batchDoc.getBatchMsg().setTelegramHeader(new String(baout.toByteArray()));

            batchDoc.getBatchMsg().setTelegramBody("");

            return true;

        } catch(Exception ex) {
            String[] msgArgs = new String[1];
            msgArgs[0] = this.batchDoc.getBatchMsg().getHeader().getProcessCode();
            String errCode = "BECEAIFJI002";
            String errMsg = ExceptionUtil.getErrorCode (ex, errCode, msgArgs);
            this.batchDoc.getBatchMsg().getBody().setErrorMsg(errMsg);
            logger.error( ex.getMessage(), ex);
            return false;
        }
    }
    //응답코드 필드값 리턴
    public String getResCode()
    {
        return super.getFieldValueString(9);
    }
}

