/*********************************************************************
* All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*   システム名      ：eo顧客基幹システム
*   モジュール名    ：JKKTelSelectOpPackIkoMapperCC
*   ソースファイル名：JKKTelSelectOpPackIkoMapperCC.java
*   作成者          ：FJ
*   日付            ：2014年05月14日
*＜機能概要＞
*   電話セレクトオプションパック移行CCMapper
*＜修正履歴＞
*   バージョン  修正日      修正者      修正内容
*	v9.00.00    2014/05/14  FJ)三宅     新規作成(ANK-2056-00-00)
*
**********************************************************************/
package com.fujitsu.futurity.bp.custom.common;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import com.fujitsu.futurity.bp.x21.bpm.ServiceComponentRequestInvoker;
import com.fujitsu.futurity.bp.x21.bpm.db.SessionHandle;
import com.fujitsu.futurity.bp.x21.bpm.parameter.IRequestParameterReadWrite;
import com.fujitsu.futurity.bp.x21.cc.exception.SCCallException;
import com.fujitsu.futurity.common.JCMConstants;
import com.fujitsu.futurity.common.x01.sc.SCControlMapKeys;
import com.fujitsu.futurity.mapping.bp.common.TemplateErrorUtil;
import com.fujitsu.futurity.model.base.CAANMsg;
import com.fujitsu.futurity.model.common.JCMAPLConstMgr;
import com.fujitsu.futurity.model.ejb.common.JSYejbLog;

import eo.common.constant.JKKStrConst;
import eo.common.util.JPCDateUtil;
import eo.ejb.cbs.cbsmsg.EKK0011D020CBSMsg;
import eo.ejb.cbs.cbsmsg.EKK0011D020CBSMsg1List;
import eo.ejb.cbs.cbsmsg.EKK0021C060CBSMsg;
import eo.ejb.cbs.cbsmsg.EKK0081A010CBSMsg;
import eo.ejb.cbs.cbsmsg.EKK0321B002CBSMsg;
import eo.ejb.cbs.cbsmsg.EKK0321B003CBSMsg;
import eo.ejb.cbs.cbsmsg.EKK0451B005CBSMsg;
import eo.ejb.cbs.cbsmsg.EKK1091D010CBSMsg;
import eo.ejb.cbs.cbsmsg.EKK1091D010CBSMsg1List;

/**
 * 電話セレクトオプションパック操作部品CC CC-SCマッピングクラス
 * 
 * @author 富士通
 */
public class JKKTelSelectOpPackIkoMapperCC
{
	/** SC呼び出し部品 */
	private ServiceComponentRequestInvoker scCall = null;
	/** セッションハンドル */
	private SessionHandle handle = null;
	/** 業務データ取得用I/F */
	private IRequestParameterReadWrite param = null;
	/** オンライン運用日付 */
	private String opeDate = null;
	
	/** サービス契約一意照会 */
	private final String EKK0081A010 = "EKK0081A010";
	/** 申込内容承認登録 */
	private final String EKK0011D020 = "EKK0011D020";
	/** 申込明細照査・後続業務依頼 */
	private final String EKK0021C060 = "EKK0021C060";
	/** 進捗登録 */
	private final String EKK1091D010 = "EKK1091D010";
	/** 課金先一覧照会（請求契約番号／サービス契約番号） */
	private final String EKK0321B002 = "EKK0321B002";
	/** 課金先一覧照会（サービス契約番号関連） */
	private final String EKK0321B003 = "EKK0321B003";
	
	/** 申込種別コード（オプション申込） */
	private final String MSKM_SBT_CD_OP_MSKM = "00026";
	
	/** 申込年月日（20140630） */
	private final String MSKM_YMD_20140630   = "20140630";
	
	/** パック指定（eo光電話パック3） */
	private final String PACK_STI_PACK3 = "W00000007";
	/** パック指定（eo光電話パック7） */
	private final String PACK_STI_PACK7 = "W00000008";
	
	/** 割引サービス名（ｅｏ光電話パック３） */
	private final String WRIB_SVC_NM_PACK3 = "eo光電話パック３";
	/** 割引サービス名（ｅｏ光電話パック７） */
	private final String WRIB_SVC_NM_PACK7 = "eo光電話パック７";
	
	
	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>コンストラクタ<br>
	 * <dt>処理補足：
	 * <dd>フィールド変数の値を設定する<br>
	 * </dl>
	 * 
	 * @param iCmnHandle セッションハンドル
	 * @param iCmnParam 業務データ取得用I/F
	 * @param iOpeDate オンライン運用日付
	 */
	public JKKTelSelectOpPackIkoMapperCC(SessionHandle iCmnHandle,
										IRequestParameterReadWrite iCmnParam,
										String iOpeDate) {
		this.handle = iCmnHandle;
		this.param = iCmnParam;
		this.opeDate = iOpeDate;
		this.scCall = new ServiceComponentRequestInvoker();
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>デバッグログを出力する<br>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param dumpObj 出力するオブジェクト
	 */
	@SuppressWarnings("static-access")
	private void printlnEjbLog(Object dumpObj) {
		JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), dumpObj, null, null, null);
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>持ちうるフィールドにNullマッピングで埋める<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param msg 対象クラス
	 * @param contents 対応クラスのフィールド列挙
	 */
	private void fillCAANMSGNullMapping(CAANMsg msg, Object[][] contents) {
		
		// 要素ごとのループ
		for (int i = 0; i < contents.length; i++) {
			
			Object element = null;
			
			// キーに該当する箇所の取得
			element = contents[i][0];
			// Nullでマッピング
			msg.setNull((String) element);
		}
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>S/IF呼出時の共通情報を設定する<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param template 条件の設定先
	 * @throws Throwable
	 */
	private void templateCommonInfo(CAANMsg template) throws Throwable {
		
		// オペレータID
		Object operatorId = this.param.getControlMapData(SCControlMapKeys.OPERATOR_ID);
		template.set(JCMConstants.OPERATOR_ID_KEY, operatorId);
		
		// 運用日付
		Object operateDate = this.param.getControlMapData(SCControlMapKeys.OPE_DATE);
		template.set(JCMConstants.OPERATE_DATE_KEY, operateDate);
		
		// 運用日時
		Object operateDateTime = this.param.getControlMapData(SCControlMapKeys.OPE_TIME);
		template.set(JCMConstants.OPERATE_DATETIME_KEY, operateDateTime);
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>SCインプット共通データ設定処理です。<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param inMap
	 * @return パラメータマップ
	 * @throws Throwable
	 */
	private HashMap<String, Object> setSCInputCommonData(HashMap<String, Object> inMap) throws Throwable {
		
		/* SCインプット共通データ */
		// **********************************************
		// 【取得元：電文ヘッダ(ヘッダ)】
		// **********************************************
		// 電文ID
		inMap.put(JCMConstants.TRANZACTION_ID_KEY, this.param.getTelegramID());
		// ユースケースID
		inMap.put(JCMConstants.USECASE_ID_KEY, this.param.getUsecaseID());
		// オペレーションID
		inMap.put(JCMConstants.OPERATION_ID_KEY, this.param.getOperationID());
		// サービス呼び出し区分
		inMap.put(JCMConstants.CALL_TYPE_KEY, this.param.getCallType());
		
		// **********************************************
		// 【取得元：ユーザエリア(コントロールマップ)】
		// **********************************************
		// 依頼先ホスト名
		inMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, this.param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME));
		// 依頼元IPアドレス
		inMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, this.param.getControlMapData(SCControlMapKeys.REQ_HOSTIP));
		// 依頼元画面ID
		inMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, this.param.getControlMapData(SCControlMapKeys.REQ_VIEWID));
		// オペレータID
		inMap.put(JCMConstants.OPERATOR_ID_KEY, this.param.getControlMapData(SCControlMapKeys.OPERATOR_ID));
		
		return inMap;
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>呼び出したサービスIFの処理結果を判定する.<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param result
	 * @throws Throwable
	 */
	@SuppressWarnings("boxing")
	private void checkExecutionResult(Map<?, ?> result) throws Throwable {
		
		// 取得したリターンコード、ステータスの内容を見て異常かどうかの判断をする。
		String rtnCode = result.get(JCMConstants.RET_CD_INT_KEY).toString();
		CAANMsg[] templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY);
		Integer status = templates[0].getInt(JCMConstants.STATUS_INT_KEY);
		
		// 異常の場合、SCCallExceptionを生成してスローする
		if (!("0".equals(rtnCode) && 0 == status.intValue()))
		{
			SCCallException scCallEx = new SCCallException("戻り値不正", rtnCode, status);
			throw scCallEx;
		}
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>サービスIFの結果を取得する<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param rsltMap サービスIFリスト
	 * @return templateList 結果が格納されたリスト
	 * @throws Throwable 
	 */
	private ArrayList<CAANMsg> getRsltList(Map<?, ?> rsltMap) {
		
		// SCからの戻り値からCAANMsgを取得する。
		CAANMsg[] templates = (CAANMsg[])rsltMap.get(JCMConstants.TEMPLATE_LIST_KEY);
		ArrayList<CAANMsg> resultList = new ArrayList<CAANMsg>(Arrays.asList(templates));
		return resultList;
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>サービスコンポーネント実行後に、IRequestParameterReadWriteに必要なデータをマッピングする<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param param 
	 * @param mapName 
	 * @return templateList 結果が格納されたリスト
	 * @throws Throwable 
	 */
	@SuppressWarnings({ "unchecked", "cast", "boxing" })
	public IRequestParameterReadWrite editResultRP(Map<?, ?> msgList,
													@SuppressWarnings("hiding") IRequestParameterReadWrite param,
													String mapName) throws Throwable {
		
		// SCからの戻り値からCAANMsgを取得する。
		CAANMsg[] templates = (CAANMsg[]) msgList.get(JCMConstants.TEMPLATE_LIST_KEY);
		
		// リターンコード取得
		Object return_code = msgList.get(JCMConstants.RET_CD_INT_KEY);
		
		// 作業領域の取得
		Map workMap = (Map)param.getMappingWorkArea();
		if (workMap == null) {
			workMap = new HashMap();
			param.setMappingWorkArea(workMap);
		}
		
		// 結果を詰めるマップを取得。
		HashMap dataMap = null;
		
		/* 業務データ設定 */
		dataMap = (HashMap)param.getData(mapName);
		if (dataMap == null) {
			dataMap = new HashMap();
			param.setData(mapName, dataMap);
		}
		
		// エラー情報の設定
		param = editErrorInfo(param, templates, (Integer)return_code, mapName);
		
		//エラー情報のマップを取得
		ArrayList<Object> errList = (ArrayList<Object>)param.getControlMapData(SCControlMapKeys.ERROR_INFO);
		if (errList == null)
		{
			errList = new ArrayList<Object>();
		}
		// コントロールマップに設定
		param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList));
		
		return param;
	}


	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>サービス契約一意照会サービスIFを呼び出す<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param  funcCd
	 * @param  wribSvcKeiNo
	 * @return CAANMsg[]
	 * @throws Throwable
	 */
	public CAANMsg[] callEKK0081A010(String funcCd, String svcKeiNo) throws Throwable {
		
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0081A010 start");
		/* --------------------------------------------------
		 * CC項目 -> SC項目 上りマッピング
		 * -------------------------------------------------- */
		HashMap<String, Object> inMap = new HashMap<String, Object>();
		
		// 割引サービス契約一意照会サービスインターフェイスを作成
		CAANMsg template = new CAANMsg(EKK0081A010CBSMsg.class.getName());
		
		// nullを設定
		fillCAANMSGNullMapping(template, new EKK0081A010CBSMsg().getContents());
		
		// テンプレートID
		template.set(EKK0081A010CBSMsg.TEMPLATEID, this.EKK0081A010);
		// 機能コード
		template.set(EKK0081A010CBSMsg.FUNC_CODE, funcCd);
		// サービス契約番号
		template.set(EKK0081A010CBSMsg.KEY_SVC_KEI_NO, svcKeiNo);
		// 予約適用年月日
		template.set(EKK0081A010CBSMsg.KEY_RSV_APLY_YMD, this.opeDate);
		
		// 共通情報設定処理
		templateCommonInfo(template);
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		inMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		// SCインプット共通データ設定処理
		setSCInputCommonData(inMap);
		
		printlnEjbLog("inMap="  + inMap.toString());
		printlnEjbLog("handle=" + this.handle.toString());
		
		/* --------------------------------------------------
		 * サービスIF実行
		 * -------------------------------------------------- */
		Map<?, ?> result = this.scCall.run(inMap, this.handle);
		
		// エラー情報の設定
		this.param = editResultRP(result, this.param, this.EKK0081A010);
		
		checkExecutionResult(result);
		
		/* --------------------------------------------------
		 * CC項目 <- SC項目 下りマッピング
		 * -------------------------------------------------- */
		// 結果をリストで取得
		ArrayList<CAANMsg> kk0081List = getRsltList(result);
		
		CAANMsg kk0081 = kk0081List.get(0);
		CAANMsg[] ret = kk0081.getCAANMsgList(EKK0081A010CBSMsg.EKK0081A010CBSMSG1LIST);
		
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0081A010 end");
		return ret;
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>申込内容承認登録サービスIFを呼び出す<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param  funcCd 
	 * @param  wribSvcKeiInf
	 * @return wrisvcTgKeiList
	 * @throws Throwable
	 */
	public CAANMsg callEKK0011D020(String funcCd, String sysid) throws Throwable {
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0011D020 start");
		
		// バッチ運用日時
		String batUnyoDtm = this.opeDate + JCCBPCommon.getSysDateTimeStamp().substring(8, 17);
		
		/* --------------------------------------------------
		 * CC項目 -> SC項目 上りマッピング
		 * -------------------------------------------------- */
		HashMap<String, Object> inMap = new HashMap<String, Object>();
		
		// 申込内容承認登録サービスインターフェイスを作成
		CAANMsg template = new CAANMsg(EKK0011D020CBSMsg.class.getName());
		
		// nullを設定
		fillCAANMSGNullMapping(template, new EKK0011D020CBSMsg().getContents());
		
		// テンプレートID
		template.set(EKK0011D020CBSMsg.TEMPLATEID, this.EKK0011D020);
		// 機能コード
		template.set(EKK0011D020CBSMsg.FUNC_CODE, funcCd);
		
		
		//---------------------------------------------
		// 申込の設定値
		//---------------------------------------------
		// ＳＹＳＩＤ
		template.set(EKK0011D020CBSMsg.SYSID,       sysid);
		// 申込種別コード
		template.set(EKK0011D020CBSMsg.MSKM_SBT_CD, MSKM_SBT_CD_OP_MSKM);
		// 申込受付年月日時分秒	
		template.set(EKK0011D020CBSMsg.MSKM_UK_DTM, batUnyoDtm);
		// 申込年月日
		template.set(EKK0011D020CBSMsg.MSKM_YMD,    MSKM_YMD_20140630);
		// コンシューマ営業用申込状態識別コード
		template.set(EKK0011D020CBSMsg.CONSMBSN_MSKM_STAT_SKBT_CD, JKKStrConst.CD00760_04);
		
		CAANMsg[] childTemplate = template.getCAANMsgList(EKK0011D020CBSMsg.EKK0011D020CBSMSG1LIST);
		if (childTemplate == null) {
			childTemplate = new CAANMsg[1];
		}
		//---------------------------------------------
		// 申込明細の設定値
		//---------------------------------------------
		childTemplate[0] = new CAANMsg(EKK0011D020CBSMsg1List.class.getName());
		
		template.set(EKK0011D020CBSMsg.EKK0011D020CBSMSG1LIST, childTemplate);
		
		// 共通情報設定処理
		templateCommonInfo(template);
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		inMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		// SCインプット共通データ設定処理
		setSCInputCommonData(inMap);
		
		printlnEjbLog("inMap="  + inMap.toString());
		printlnEjbLog("handle=" + this.handle.toString());
		
		/* --------------------------------------------------
		 * サービスIF実行
		 * -------------------------------------------------- */
		Map<?, ?> result = this.scCall.run(inMap, this.handle);
		
		// エラー情報の設定
		this.param = editResultRP(result, this.param, this.EKK0011D020);
		
		checkExecutionResult(result);
		
		/* --------------------------------------------------
		 * CC項目 <- SC項目 下りマッピング
		 * -------------------------------------------------- */
		// 結果をリストで取得
		ArrayList<CAANMsg> kk0011List = getRsltList(result);
		
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0011D020 end");
		
		return kk0011List.get(0);
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>申込明細照査・後続業務依頼サービスIFを呼び出す<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param  funcCd 
	 * @param  wribSvcKeiInf
	 * @return wrisvcTgKeiList
	 * @throws Throwable
	 */
	public CAANMsg callEKK0021C060(String funcCd, CAANMsg mskmMsg) throws Throwable {
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0021C060 start");
		
		// 申込明細の情報取得
		CAANMsg[] mskmDtl = mskmMsg.getCAANMsgList(EKK0011D020CBSMsg.EKK0011D020CBSMSG1LIST);
		
		/* --------------------------------------------------
		 * CC項目 -> SC項目 上りマッピング
		 * -------------------------------------------------- */
		HashMap<String, Object> inMap = new HashMap<String, Object>();
		
		// 申込内容承認登録サービスインターフェイスを作成
		CAANMsg template = new CAANMsg(EKK0021C060CBSMsg.class.getName());
		
		// nullを設定
		fillCAANMSGNullMapping(template, new EKK0021C060CBSMsg().getContents());
		
		// テンプレートID
		template.set(EKK0021C060CBSMsg.TEMPLATEID, this.EKK0021C060);
		// 機能コード
		template.set(EKK0021C060CBSMsg.FUNC_CODE, funcCd);
		
		
		// 申込明細番号
		template.set(EKK0021C060CBSMsg.MSKM_DTL_NO,   mskmDtl[0].getString(EKK0011D020CBSMsg1List.MSKM_DTL_NO));
		// 連絡事項登録年月日時分秒
		template.setNull(EKK0021C060CBSMsg.RRK_JIKO_ADD_DTM);
		// 後続業務依頼年月日
		template.set(EKK0021C060CBSMsg.KZKWRK_REQYMD, this.opeDate);
		// 連絡事項
		template.setNull(EKK0021C060CBSMsg.RRK_JIKO);
		// 更新年月日時分秒(更新前)
		template.set(EKK0021C060CBSMsg.UPD_DTM_BF,    mskmMsg.getString(EKK0011D020CBSMsg.UPD_DTM));
		
		
		// 共通情報設定処理
		templateCommonInfo(template);
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		inMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		// SCインプット共通データ設定処理
		setSCInputCommonData(inMap);
		
		printlnEjbLog("inMap="  + inMap.toString());
		printlnEjbLog("handle=" + this.handle.toString());
		
		/* --------------------------------------------------
		 * サービスIF実行
		 * -------------------------------------------------- */
		Map<?, ?> result = this.scCall.run(inMap, this.handle);
		
		// エラー情報の設定
		this.param = editResultRP(result, this.param, this.EKK0021C060);
		
		checkExecutionResult(result);
		
		/* --------------------------------------------------
		 * CC項目 <- SC項目 下りマッピング
		 * -------------------------------------------------- */
		// 結果をリストで取得
		ArrayList<CAANMsg> kk0011List = getRsltList(result);
		
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0021C060 end");
		
		return kk0011List.get(0);
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>進捗登録サービスIFを呼び出す<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param  funcCd 
	 * @param  wribSvcKeiInf
	 * @return wrisvcTgKeiList
	 * @throws Throwable
	 */
	public CAANMsg callEKK1091D010(String funcCd, String mskmDtlNo, String svcKeiNo, String telno, String packSti) throws Throwable {
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK1091D010 start");
		
		/* --------------------------------------------------
		 * CC項目 -> SC項目 上りマッピング
		 * -------------------------------------------------- */
		HashMap<String, Object> inMap = new HashMap<String, Object>();
		
		// 申込内容承認登録サービスインターフェイスを作成
		CAANMsg template = new CAANMsg(EKK1091D010CBSMsg.class.getName());
		
		// nullを設定
		fillCAANMSGNullMapping(template, new EKK1091D010CBSMsg().getContents());
		
		// テンプレートID
		template.set(EKK1091D010CBSMsg.TEMPLATEID, this.EKK1091D010);
		// 機能コード
		template.set(EKK1091D010CBSMsg.FUNC_CODE, funcCd);
		
		// 進捗年月日時分秒を算出（運用日翌日＋時分秒）
		String batUnyoNextDtm = JPCDateUtil.addDay(this.opeDate, 1) + JCCBPCommon.getSysDateTimeStamp().substring(8, 17);
		
		//---------------------------------------------
		// 申込の設定値
		//---------------------------------------------
		// 申込明細番号
		template.set(EKK1091D010CBSMsg.MSKM_DTL_NO, mskmDtlNo);
		// サービス契約番号
		template.set(EKK1091D010CBSMsg.SVC_KEI_NO,  svcKeiNo);
		// 異動区分
		template.set(EKK1091D010CBSMsg.IDO_DIV,     JKKStrConst.CD00576_00031);
		// 異動年月日時分秒
		template.set(EKK1091D010CBSMsg.IDO_DTM,     JCCBPCommon.getSysDateTimeStamp());
		// 進捗ステータス
		template.set(EKK1091D010CBSMsg.PRG_STAT,    JKKStrConst.CD00647_EOHTL_PACK_SETTE_FIN);
		// 進捗メモ
		template.setNull(EKK1091D010CBSMsg.PRG_MEMO);
		// 進捗特記事項１
		String prgTkjk1 = null;
		if(PACK_STI_PACK3.equals(packSti))
		{
			prgTkjk1 = "電話番号：" + telno + " " + WRIB_SVC_NM_PACK3 + "移行　利用開始日：" + "2014/07/01";
		}
		else
		{
			prgTkjk1 = "電話番号：" + telno + " " + WRIB_SVC_NM_PACK7 + "移行　利用開始日：" + "2014/07/01";
		}
		template.set(EKK1091D010CBSMsg.PRG_TKJK_1,  prgTkjk1);
		// 進捗特記事項２
		template.setNull(EKK1091D010CBSMsg.PRG_TKJK_2);
		// 進捗年月日時分秒
		template.set(EKK1091D010CBSMsg.PRG_DTM_I, batUnyoNextDtm);
		
		CAANMsg[] childTemplate = template.getCAANMsgList(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST);
		if (childTemplate == null) {
			childTemplate = new CAANMsg[1];
		}
		//---------------------------------------------
		// 異動理由の設定値
		//---------------------------------------------
		childTemplate[0] = new CAANMsg(EKK1091D010CBSMsg1List.class.getName());
		// 異動理由コード
		childTemplate[0].set(EKK1091D010CBSMsg1List.IDO_RSN_CD,   JKKStrConst.CD00846_OTHER);
		// 異動理由メモ
		childTemplate[0].setNull(EKK1091D010CBSMsg1List.IDO_RSN_MEMO);
		
		template.set(EKK1091D010CBSMsg.EKK1091D010CBSMSG1LIST, childTemplate);
		
		// 共通情報設定処理
		templateCommonInfo(template);
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		inMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		// SCインプット共通データ設定処理
		setSCInputCommonData(inMap);
		
		printlnEjbLog("inMap="  + inMap.toString());
		printlnEjbLog("handle=" + this.handle.toString());
		
		/* --------------------------------------------------
		 * サービスIF実行
		 * -------------------------------------------------- */
		Map<?, ?> result = this.scCall.run(inMap, this.handle);
		
		// エラー情報の設定
		this.param = editResultRP(result, this.param, this.EKK1091D010);
		
		checkExecutionResult(result);
		
		/* --------------------------------------------------
		 * CC項目 <- SC項目 下りマッピング
		 * -------------------------------------------------- */
		// 結果をリストで取得
		ArrayList<CAANMsg> kk0011List = getRsltList(result);
		
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK1091D010 end");
		
		return kk0011List.get(0);
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>課金先一覧照会（請求契約番号／サービス契約番号）サービスIFを呼び出す<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param  funcCd 
	 * @param  svcKeiNo
	 * @return CAANMsg[]
	 * @throws Throwable
	 */
	public CAANMsg[] callEKK0321B002(String funcCd, String svcKeiNo) throws Throwable {
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0321B002 start");
		
		/* --------------------------------------------------
		 * CC項目 -> SC項目 上りマッピング
		 * -------------------------------------------------- */
		HashMap<String, Object> inMap = new HashMap<String, Object>();
		
		// 課金先一覧照会（サービス契約番号）照会サービスインターフェイスを作成
		CAANMsg template = new CAANMsg(EKK0321B002CBSMsg.class.getName());
		
		// nullを設定
		fillCAANMSGNullMapping(template, new EKK0321B002CBSMsg().getContents());
		
		// テンプレートID
		template.set(EKK0321B002CBSMsg.TEMPLATEID, this.EKK0321B002);
		// 機能コード
		template.set(EKK0321B002CBSMsg.FUNC_CODE, funcCd);
		
		// サービス契約番号
		template.set(EKK0321B002CBSMsg.KEY_SVC_KEI_NO, svcKeiNo);
		
		// 共通情報設定処理
		templateCommonInfo(template);
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		inMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		// SCインプット共通データ設定処理
		setSCInputCommonData(inMap);
		
		printlnEjbLog("inMap="  + inMap.toString());
		printlnEjbLog("handle=" + this.handle.toString());
		
		/* --------------------------------------------------
		 * サービスIF実行
		 * -------------------------------------------------- */
		Map<?, ?> result = this.scCall.run(inMap, this.handle);
		
        // エラー情報の設定
		this.param = editResultRP(result, this.param, this.EKK0321B002);
		
		checkExecutionResult(result);
		
		/* --------------------------------------------------
		 * CC項目 <- SC項目 下りマッピング
		 * -------------------------------------------------- */
		// 結果をリストで取得
		ArrayList<CAANMsg> kk0321List = getRsltList(result);
		
		CAANMsg kk0321 = kk0321List.get(0);
		CAANMsg[] ret  = kk0321.getCAANMsgList(EKK0321B002CBSMsg.EKK0321B002CBSMSG1LIST);
		
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0321B002 end");
		return ret;
	}

	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>課金先一覧照会（請求契約番号／サービス契約番号）サービスIFを呼び出す<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param  funcCd 
	 * @param  svcKeiNo
	 * @return CAANMsg[]
	 * @throws Throwable
	 */
	public CAANMsg[] callEKK0321B003(String funcCd, String seikyKeiNo, String svcKeiNo) throws Throwable {
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0321B003 start");
		
		/* --------------------------------------------------
		 * CC項目 -> SC項目 上りマッピング
		 * -------------------------------------------------- */
		HashMap<String, Object> inMap = new HashMap<String, Object>();
		
		// 課金先一覧照会（サービス契約番号）照会サービスインターフェイスを作成
		CAANMsg template = new CAANMsg(EKK0321B003CBSMsg.class.getName());
		
		// nullを設定
		fillCAANMSGNullMapping(template, new EKK0321B003CBSMsg().getContents());
		
		// テンプレートID
		template.set(EKK0321B003CBSMsg.TEMPLATEID, this.EKK0321B003);
		// 機能コード
		template.set(EKK0321B003CBSMsg.FUNC_CODE, funcCd);
		
		// 請求契約番号
		template.set(EKK0321B003CBSMsg.KEY_SEIKY_KEI_NO, seikyKeiNo);
		// サービス契約番号
		template.set(EKK0321B003CBSMsg.KEY_SVC_KEI_NO,   svcKeiNo);
		// 基準年月日
		template.set(EKK0321B003CBSMsg.KEY_BASE_YMD,     this.opeDate);
		
		// 共通情報設定処理
		templateCommonInfo(template);
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		inMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		// SCインプット共通データ設定処理
		setSCInputCommonData(inMap);
		
		printlnEjbLog("inMap="  + inMap.toString());
		printlnEjbLog("handle=" + this.handle.toString());
		
		/* --------------------------------------------------
		 * サービスIF実行
		 * -------------------------------------------------- */
		Map<?, ?> result = this.scCall.run(inMap, this.handle);
		
        // エラー情報の設定
		this.param = editResultRP(result, this.param, this.EKK0321B003);
		
		checkExecutionResult(result);
		
		/* --------------------------------------------------
		 * CC項目 <- SC項目 下りマッピング
		 * -------------------------------------------------- */
		// 結果をリストで取得
		ArrayList<CAANMsg> kk0321List = getRsltList(result);
		
		CAANMsg kk0321 = kk0321List.get(0);
		CAANMsg[] ret  = kk0321.getCAANMsgList(EKK0321B003CBSMsg.EKK0321B003CBSMSG1LIST);
		
		printlnEjbLog("JKKTelSelectOpPackOperateMapperCC.callEKK0321B003 end");
		return ret;
	}


	/**
	 * 
	 * <dl>
	 * <dt>処理概要：
	 * <dd>サービスコンポーネント実行後に、IRequestParameterReadWriteにエラー情報をマッピングする<BR>
	 * <dt>処理補足：
	 * <dd>
	 * </dl>
	 * 
	 * @param param      業務データ取得・書込用I/F
	 * @param templates  CAANMsgクラス配列
	 * @param returnCode リターンコード
	 * @param mapName    SCマップ名
	 * 
	 * @return 業務データ取得・書込用I/F
	 */
	@SuppressWarnings({ "unchecked", "cast", "null", "boxing" })
	public IRequestParameterReadWrite editErrorInfo(@SuppressWarnings("hiding") IRequestParameterReadWrite param,
													 CAANMsg[] templates,
													 int returnCode,
													 String mapName) throws Throwable {
		CAANMsg template = templates[0];
		CAANMsg[] templateArray = null;
		int templateStatus = template.getInt(EKK0451B005CBSMsg.STATUS);
		if (returnCode != 0) {
			templateStatus = 9000;
		}
		if (JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null) {
			templateStatus = 0;
		}
		
		int bpStatus = 0;
		Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE);
		if (obj == null) {
			bpStatus = -1;
		} else {
			bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE));
		}

		if (templateStatus > bpStatus) {
			
			// BPにサービスコンポーネントのステータスを設定する。
			String formatStatus = String.format("%1$04d", templateStatus);
			String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus);
			param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus);
			param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message);
		}
		
		HashMap inMap = null;
		ArrayList inList = null;
		
		// 作業項目領域
		Map workMap = (Map)param.getMappingWorkArea();
		if (workMap == null) {
			workMap = new HashMap();
			param.setMappingWorkArea(workMap);
		}
		
		/* ユーザデータ情報 */
		inMap = (HashMap)param.getData(mapName);
		if (inMap == null) {
			inMap = new HashMap();
			param.setData(mapName, inMap);
		}

		String svcIf = null;
		if (svcIf == null) {
			return param;
			
		} else {
			
			// 処理なし
		}
		return param;
	}
}
