/*********************************************************************
* All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*   システム名      ：eo顧客基幹システム
*   モジュール名    ：物流管理システム
*   ソースファイル名：JDKCommon59CC.java
*   作成者          ：富士通
*   日付            ：2013年01月31日
*＜機能概要＞
*   棚移動指示在庫一意照会CCクラスです。
*＜修正履歴＞
*   バージョン  修正日       修正者      修正内容
*   v1.00.00    2013/01/31   FJ          新規作成
*
**********************************************************************/
package com.fujitsu.futurity.bp.custom.common;

import java.util.HashMap;
import java.util.Map;

import com.fujitsu.futurity.bp.custom.mapping.DKSV0001_DKSV0001OP_EKKA0020005BSMapper;
import com.fujitsu.futurity.bp.custom.mapping.DKSV0001_DKSV0001OP_EDKA0010009BSMapper;
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.AbstractCommonComponent;
import com.fujitsu.futurity.bp.x21.cc.exception.SCCallException;
import com.fujitsu.futurity.model.ejb.common.JSYejbLog;


/**
 * 棚移動指示在庫一意照会CCクラスです。
 * @author 富士通
 */
public class JDKCommon59CC extends AbstractCommonComponent
{

	/** 宅内機器物流在庫一意照会マッパー */
	private static final DKSV0001_DKSV0001OP_EKKA0020005BSMapper MAPPER_EKKA0020005 = new DKSV0001_DKSV0001OP_EKKA0020005BSMapper();
	/** 棚移動指示一意照会マッパー */
	private static final DKSV0001_DKSV0001OP_EDKA0010009BSMapper MAPPER_EDKA0010009 = new DKSV0001_DKSV0001OP_EDKA0010009BSMapper();
	
	/**
	 * 棚移動指示一覧照会処理を行います。
	 * @param handle セッションハンドル
	 * @param param パラメータ
	 * @param fixedText 定型文字
	 * @return パラメータ
	 * @throws Throwable 
	 */
	@SuppressWarnings("unchecked")
	public IRequestParameterReadWrite getTkData(SessionHandle handle, IRequestParameterReadWrite param, String fixedText) throws Throwable
	{
		ServiceComponentRequestInvoker scCall = new ServiceComponentRequestInvoker();
		
		// 宅内機器物流在庫一意照会
		HashMap<String, Object> ekka0020005ParamMap = new HashMap<String, Object>();
		ekka0020005ParamMap = MAPPER_EKKA0020005.editInMsg(param);
		JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "宅内機器物流在庫一意照会処理の実行");
		Map ekka0020005Result = scCall.run(ekka0020005ParamMap, handle);
		MAPPER_EKKA0020005.editResultRP(ekka0020005Result, param);
		
		if (JDKBPCommon.hasError(param))
		{
			throw new SCCallException("宅内機器物流在庫一意照会処理失敗", "0", 
					Integer.parseInt(param.getControlMapData("returnCode").toString()));
		}
		
		JDKBPCommon.throwScExceptionIfHasError("宅内機器物流在庫一意照会処理リターンコード不正", param);
		
		HashMap inMap = (HashMap)param.getData("DKSV000102SC");
		if(inMap == null){
			// 数量指定の場合は検索処理を行わない(DKW00508SFLogicでセットしていないのでnullが取れる)
			JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "棚移動指示一意照会処理の未実行(検索対象なし)");
			return param;
		}
		
		// 棚移動指示一意照会
		HashMap<String, Object> edka0010009ParamMap = new HashMap<String, Object>();
		edka0010009ParamMap = MAPPER_EDKA0010009.editInMsg(param);
		JSYejbLog.println(JSYejbLog.DEBUG, this.getClass(), "棚移動指示一意照会処理の実行");
		Map edka0010009Result = scCall.run(edka0010009ParamMap, handle);
		MAPPER_EDKA0010009.editResultRP(edka0010009Result, param);
		
		if (JDKBPCommon.hasError(param))
		{
			throw new SCCallException("棚移動指示一覧照会処理失敗", "0", 
					Integer.parseInt(param.getControlMapData("returnCode").toString()));
		}
		
		JDKBPCommon.throwScExceptionIfHasError("棚移動指示一覧照会処理リターンコード不正", param);
		
		return param;
	}

}
