/*******************************************************************************
*	 All Rights reserved,Copyright (c) K-Opticom 
********************************************************************************
*＜プログラム内容＞
*	システム名		：eo顧客基幹システム
*	モジュール名	：JSYejbKU0271KRCK
*	ソースファイル名：JSYejbKU0271KRCK.java
*	作成者			：EK945604
*	日付			：2018年01月24日
*＜機能概要＞
*	関連チェック部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	ｖ1.00.00
*
********************************************************************************/

package eo.ejb.cbm.entity;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.fujitsu.futurity.model.ejb.common.JSYejbLog;
import com.fujitsu.futurity.model.ejb.common.JSYejbConnection;
import com.fujitsu.futurity.model.ejb.common.StatusCodes;
import com.fujitsu.futurity.model.ejb.common.fw.AgentDispatchContext;
import eo.ejb.common.EventIDList;
import com.fujitsu.futurity.model.ejb.common.fw.KanrenCheckHandler;
import eo.ejb.common.JPCModelCommon;
import eo.ejb.common.entity.JZMejbZM0171CRCK;

import com.fujitsu.futurity.model.base.CAANConnectionMgr;
import com.fujitsu.futurity.model.base.CAANJDBCUtil;
import com.fujitsu.futurity.model.base.CAANMsg;
import com.fujitsu.futurity.model.base.CAANRuntimeException;

/**
 * 切断ツール送付先関連チェッククラスです。
 * ＜メソッド一覧＞
 * invoke
 *	IKU0271C001
 *	IKU0271D001
 *	IKU0271D002
 *
 */

public class JSYejbKU0271KRCK implements KanrenCheckHandler {

	/**
	 * コンストラクタ
	 */

	public JSYejbKU0271KRCK() {
	}

	/**
	 * 切断ツール送付先関連チェックを行います。
	 * 
	 * @param inETMsg エンティティ
	 * @param inContext Agentから渡されたAgentDispatchContext
	 */

	public void invoke(CAANMsg inETMsg, AgentDispatchContext inContext) {

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "call:JSYejbKU0271KRCK.invoke");

		// inETMsgのチェック
		if(inETMsg == null) {
			throw new CAANRuntimeException("inETMsgがnullです。");
		}

		// 振舞IDの取り出し
		String eventID = inETMsg.getString("eventID");
		if(eventID == null) {
			throw new CAANRuntimeException("振舞IDがnullです。");
		}

		// 処理の振り分け
		// イベントの振り分け
		if(eventID.equals(EventIDList.IKU0271C001)){
			/** 切断ツール送付先論理削除振舞内部 */
			int Rtn = 0;
			Rtn = execIKU0271C001_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKU0271C001_2(inETMsg, inContext, "EA");
			}

		}else if(eventID.equals(EventIDList.IKU0271D002)){
			/** 切断ツール送付先登録振舞内部 */
//			int Rtn = 0;
//			Rtn = execIKU0271D003_1(inETMsg, inContext, "EA");
//
//			if(Rtn <= StatusCodes.WARNING){
//				Rtn = execIKU0271D002_3(inETMsg, inContext, "EA");
//			}
//
//			if(Rtn <= StatusCodes.WARNING){
//				Rtn = execIKU0271D003_2(inETMsg, inContext, "EA");
//			}
		}else if(eventID.equals(EventIDList.IKU0271D001)){
			/** 切断ツール送付先更新振舞内部 */
			int Rtn = 0;
//			Rtn = execIKU0271D002_1(inETMsg, inContext, "EA");
//
//			if(Rtn <= StatusCodes.WARNING){
//				Rtn = execIKU0271D002_2(inETMsg, inContext, "EB");
//			}
//
//			if(Rtn <= StatusCodes.WARNING){
//				Rtn = execIKU0271D002_3(inETMsg, inContext, "EA");
//			}
			
			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKU0271D002_4(inETMsg, inContext, "EA");
			}
		}

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "end:JSYejbKU0271KRCK.invoke");

	}

	/**
	 * IKU0271C001_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKU0271C001_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KU0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KU0271ETMsg.KOJIAK_NO)){
				joken1_2 = new String(inETMsg.getObject(KU0271ETMsg.KOJIAK_NO).toString());
			}

			String joken3_2 = "0";
			// 条件文定義
			String joken_1 = KU0271ETMsg.getDBColumnName(KU0271ETMsg.KOJIAK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_3 = KU0271ETMsg.getDBColumnName(KU0271ETMsg.MK_FLG);
			if(joken3_2 == null){
				joken_3 += " IS NULL ";
			}else{
				joken_3 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KU0271ETMsg.KOJIAK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KU0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_3 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken3_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken3_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KU0271ETMsg.KOJIAK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
			inETMsg.set(KU0271ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKU0271C001_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKU0271C001_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

			// チェック条件定数
			// 制約部品引数定義
			Object joken_1_prm_1 = "KU0271";

			// チェック条件
			if (!inETMsg.isNull(KU0271ETMsg.KOJIAK_NO) && !inETMsg.isNull(KU0271ETMsg.UPD_DTM)) { 
			// 判定条件
			if(JPCModelCommon.succeededExclusiveLockForGene(inETMsg, inContext, joken_1_prm_1 ) == false){
					inETMsg.set(KU0271ETMsg.UPD_DTM_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
			inETMsg.set(KU0271ETMsg.STATUS, rtn);
		}

		return rtn;

	}

//	/**
//	 * IKU0271D004_制約ＮＯ1チェック
//	 *
//	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
//	 * @param inContext Agentから渡されたAgentDispatchContext
//	 * @param errFlag ERRフラグ
//	 * @return int チェック結果
//	 */
//	private int execIKU0271D002_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){
//
//		// ステータス
//		int rtn = 0;
//
//		Connection con = JSYejbConnection.getConnection(KU0271ETMsg.getTableName());
//
//		PreparedStatement pstmtQuery = null;
//		ResultSet rsltQuery = null;
//		StringBuffer sqlQuery = new StringBuffer();
//
//		try{
//
//			// チェック条件定数
//			// ＳＱＬ引数定義
//			String joken1_2 = null;
//			if(!inETMsg.isNull(KU0271ETMsg.KOJIAK_NO)){
//				joken1_2 = new String(inETMsg.getObject(KU0271ETMsg.KOJIAK_NO).toString());
//			}
//
//			String joken3_2 = "0";
//			// 条件文定義
//			String joken_1 = KU0271ETMsg.getDBColumnName(KU0271ETMsg.KOJIAK_NO);
//			if(joken1_2 == null){
//				joken_1 += " IS NULL ";
//			}else{
//				joken_1 += " = ? ";
//			}
//
//			String joken_3 = KU0271ETMsg.getDBColumnName(KU0271ETMsg.MK_FLG);
//			if(joken3_2 == null){
//				joken_3 += " IS NULL ";
//			}else{
//				joken_3 += " = ? ";
//			}
//
//			// チェック条件
//			if (!inETMsg.isNull(KU0271ETMsg.KOJIAK_NO)) { 
//
//				// ＳＱＬ文の組み立て
//				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KU0271ETMsg.getTableName()).append(" WHERE ")
//					.append("(" + joken_1 + " AND " + joken_3 + " ) ");
//
//				// ＳＱＬ文の解析
//				pstmtQuery = con.prepareStatement(sqlQuery.toString());
//
//				// パラメータの設定
//				int para_idx = 1;
//				if(joken1_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
//				}
//				if(joken3_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken3_2);
//				}
//
//				// ＳＱＬ文の実行
//				rsltQuery = pstmtQuery.executeQuery();
//
//				if(rsltQuery.next()){
//				// 判定条件
//					if(!(rsltQuery.getLong("CNT")>0)){
//						inETMsg.set(KU0271ETMsg.KOJIAK_NO_ERR, errFlag);
//						if("W".equals(errFlag.substring(0,1))){
//							rtn = StatusCodes.WARNING;
//						} else {
//							rtn = StatusCodes.RELATION_ERR;
//						}
//					}
//				}
//
//			}
//
//		} catch(SQLException e) {
//			inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//			throw new CAANRuntimeException(e);
//		} finally {
//			// このメソッドで確保した資源の解放
//			try {
//				if(rsltQuery != null) {
//					rsltQuery.close();
//				}
//				if(pstmtQuery != null) {
//					pstmtQuery.close();
//				}
//				if(con != null) {
//					CAANConnectionMgr.getInstance().close(con);
//				}
//			} catch(SQLException e) {
//				inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//				throw new CAANRuntimeException(e);
//			}
//		}
//		
//		// ステータスのセット
//		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
//			inETMsg.set(KU0271ETMsg.STATUS, rtn);
//		}
//
//		return rtn;
//
//	}

//	/**
//	 * IKU0271D002_制約ＮＯ2チェック
//	 *
//	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
//	 * @param inContext Agentから渡されたAgentDispatchContext
//	 * @param errFlag ERRフラグ
//	 * @return int チェック結果
//	 */
//	private int execIKU0271D002_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){
//
//		// ステータス
//		int rtn = 0;
//
//		Connection con = JSYejbConnection.getConnection(KU0271ETMsg.getTableName());
//
//		PreparedStatement pstmtQuery = null;
//		ResultSet rsltQuery = null;
//		StringBuffer sqlQuery = new StringBuffer();
//
//		try{
//
//			// チェック条件定数
//			// ＳＱＬ引数定義
//			String joken1_2 = null;
//			if(!inETMsg.isNull(KU0271ETMsg.CASHPOST_KEI_NO)){
//				joken1_2 = new String(inETMsg.getObject(KU0271ETMsg.CASHPOST_KEI_NO).toString());
//			}
//
//			String joken2_2 = null;
//			if(!inETMsg.isNull(KU0271ETMsg.GENE_ADD_DTM)){
//				joken2_2 = new String(inETMsg.getObject(KU0271ETMsg.GENE_ADD_DTM).toString());
//			}
//
//			// 条件文定義
//			String joken_1 = KU0271ETMsg.getDBColumnName(KU0271ETMsg.CASHPOST_KEI_NO);
//			if(joken1_2 == null){
//				joken_1 += " IS NULL ";
//			}else{
//				joken_1 += " = ? ";
//			}
//
//			String joken_2 = KU0271ETMsg.getDBColumnName(KU0271ETMsg.CASHPOST_KEI_NO);
//			if(joken2_2 == null){
//				joken_2 += " IS NULL ";
//			}else{
//				joken_2 += " = ? ";
//			}
//
//			// チェック条件
//			if (!inETMsg.isNull(KU0271ETMsg.CASHPOST_KEI_NO) && !inETMsg.isNull(KU0271ETMsg.GENE_ADD_DTM)) { 
//
//				// ＳＱＬ文の組み立て
//				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KU0271ETMsg.getTableName()).append(" WHERE ")
//					.append("(" + joken_1 + " AND " + joken_2 + " ) ");
//
//				// ＳＱＬ文の解析
//				pstmtQuery = con.prepareStatement(sqlQuery.toString());
//
//				// パラメータの設定
//				int para_idx = 1;
//				if(joken1_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
//				}
//				if(joken2_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
//				}
//
//				// ＳＱＬ文の実行
//				rsltQuery = pstmtQuery.executeQuery();
//
//				if(rsltQuery.next()){
//				// 判定条件
//					if(rsltQuery.getLong("CNT")>0){
//						inETMsg.set(KU0271ETMsg.CASHPOST_KEI_NO_ERR, errFlag);
//						if("W".equals(errFlag.substring(0,1))){
//							rtn = StatusCodes.WARNING;
//						} else {
//							rtn = StatusCodes.RELATION_ERR;
//						}
//					}
//				}
//
//			}
//
//		} catch(SQLException e) {
//			inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//			throw new CAANRuntimeException(e);
//		} finally {
//			// このメソッドで確保した資源の解放
//			try {
//				if(rsltQuery != null) {
//					rsltQuery.close();
//				}
//				if(pstmtQuery != null) {
//					pstmtQuery.close();
//				}
//				if(con != null) {
//					CAANConnectionMgr.getInstance().close(con);
//				}
//			} catch(SQLException e) {
//				inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//				throw new CAANRuntimeException(e);
//			}
//		}
//		
//		// ステータスのセット
//		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
//			inETMsg.set(KU0271ETMsg.STATUS, rtn);
//		}
//
//		return rtn;
//
//	}

	/**
	 * IKU0271D002_制約ＮＯ4チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKU0271D002_4(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

			// チェック条件定数
			// 制約部品引数定義
			Object joken_1_prm_1 = "KU0271";

			// チェック条件
			if (!inETMsg.isNull(KU0271ETMsg.KOJIAK_NO) && !inETMsg.isNull(KU0271ETMsg.UPD_DTM)) { 
			// 判定条件
			if(JPCModelCommon.succeededExclusiveLockForGene(inETMsg, inContext, joken_1_prm_1 ) == false){
					inETMsg.set(KU0271ETMsg.UPD_DTM_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
			inETMsg.set(KU0271ETMsg.STATUS, rtn);
		}

		return rtn;


	}

//	/**
//	 *IKU0271D002_制約ＮＯ3チェック
//	 *
//	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
//	 * @param inContext Agentから渡されたAgentDispatchContext
//	 * @param errFlag ERRフラグ
//	 * @return int チェック結果
//	 */
//	private int execIKU0271D002_3(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){
//
//		// ステータス
//		int rtn = 0;
//
//			// チェック条件定数
//			// 制約部品引数定義
//			Object joken_1_prm_1 = "CD01740";
//
//			Object joken_1_prm_2 = null;
//			if(!inETMsg.isNull(KU0271ETMsg.CASHPOST_KEI_STAT)){
//				joken_1_prm_2 = inETMsg.getObject(KU0271ETMsg.CASHPOST_KEI_STAT);
//			}
//
//			// チェック条件
//			if (!inETMsg.isNull(KU0271ETMsg.CASHPOST_KEI_STAT)) { 
//			// 判定条件
//			if(JZMejbZM0171CRCK.isExistsPrimaryKey001(inETMsg, inContext, joken_1_prm_1, joken_1_prm_2 ) == false){
//					inETMsg.set(KU0271ETMsg.CASHPOST_KEI_STAT_ERR, errFlag);
//					if("W".equals(errFlag.substring(0,1))){
//						rtn = StatusCodes.WARNING;
//					} else {
//						rtn = StatusCodes.RELATION_ERR;
//					}
//				}
//			}
//
//		
//		// ステータスのセット
//		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
//			inETMsg.set(KU0271ETMsg.STATUS, rtn);
//		}
//
//		return rtn;
//
//	}
//	
//	/**
//	 * IKU0271D003_制約ＮＯ3チェック
//	 *
//	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
//	 * @param inContext Agentから渡されたAgentDispatchContext
//	 * @param errFlag ERRフラグ
//	 * @return int チェック結果
//	 */
//	private int execIKU0271D003_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){
//
//		// ステータス
//		int rtn = 0;
//
//		Connection con = JSYejbConnection.getConnection(KK0081ETMsg.getTableName());
//
//		PreparedStatement pstmtQuery = null;
//		ResultSet rsltQuery = null;
//		StringBuffer sqlQuery = new StringBuffer();
//
//		try{
//
//			// チェック条件定数
//			// ＳＱＬ引数定義
//			String joken1_2 = null;
//			if(!inETMsg.isNull(KU0271ETMsg.SVC_KEI_NO)){
//				joken1_2 = new String(inETMsg.getObject(KU0271ETMsg.SVC_KEI_NO).toString());
//			}
//
//			String joken2_2 = "0";
//			// 条件文定義
//			String joken_1 = KK0081ETMsg.getDBColumnName(KK0081ETMsg.SVC_KEI_NO);
//			if(joken1_2 == null){
//				joken_1 += " IS NULL ";
//			}else{
//				joken_1 += " = ? ";
//			}
//
//			String joken_2 = KK0081ETMsg.getDBColumnName(KK0081ETMsg.MK_FLG);
//			if(joken2_2 == null){
//				joken_2 += " IS NULL ";
//			}else{
//				joken_2 += " = ? ";
//			}
//
//			// チェック条件
//			if (!inETMsg.isNull(KU0271ETMsg.SVC_KEI_NO)) { 
//
//				// ＳＱＬ文の組み立て
//				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0081ETMsg.getTableName()).append(" WHERE ")
//					.append("(" + joken_1 + " AND " + joken_2 + " ) ");
//
//				// ＳＱＬ文の解析
//				pstmtQuery = con.prepareStatement(sqlQuery.toString());
//
//				// パラメータの設定
//				int para_idx = 1;
//				if(joken1_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
//				}
//				if(joken2_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
//				}
//
//				// ＳＱＬ文の実行
//				rsltQuery = pstmtQuery.executeQuery();
//
//				if(rsltQuery.next()){
//				// 判定条件
//					if(!(rsltQuery.getLong("CNT")>0)){
//						inETMsg.set(KU0271ETMsg.SVC_KEI_NO_ERR, errFlag);
//						if("W".equals(errFlag.substring(0,1))){
//							rtn = StatusCodes.WARNING;
//						} else {
//							rtn = StatusCodes.RELATION_ERR;
//						}
//					}
//				}
//
//			}
//
//		} catch(SQLException e) {
//			inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//			throw new CAANRuntimeException(e);
//		} finally {
//			// このメソッドで確保した資源の解放
//			try {
//				if(rsltQuery != null) {
//					rsltQuery.close();
//				}
//				if(pstmtQuery != null) {
//					pstmtQuery.close();
//				}
//				if(con != null) {
//					CAANConnectionMgr.getInstance().close(con);
//				}
//			} catch(SQLException e) {
//				inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//				throw new CAANRuntimeException(e);
//			}
//		}
//		
//		// ステータスのセット
//		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
//			inETMsg.set(KU0271ETMsg.STATUS, rtn);
//		}
//
//		return rtn;
//
//	}
//	
//	/**
//	 * IKU0271D002_制約ＮＯ7チェック
//	 *
//	 * @param inETMsg チェック対象のETMsg(KU0271ETMsg)
//	 * @param inContext Agentから渡されたAgentDispatchContext
//	 * @param errFlag ERRフラグ
//	 * @return int チェック結果
//	 */
//	private int execIKU0271D003_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){
//
//		// ステータス
//		int rtn = 0;
//
//		Connection con = JSYejbConnection.getConnection(KK3191ETMsg.getTableName());
//
//		PreparedStatement pstmtQuery = null;
//		ResultSet rsltQuery = null;
//		StringBuffer sqlQuery = new StringBuffer();
//
//		try{
//
//			// チェック条件定数
//			// ＳＱＬ引数定義
//			String joken1_2 = null;
//			if(!inETMsg.isNull(KU0271ETMsg.CASHPOST_CD)){
//				joken1_2 = new String(inETMsg.getObject(KU0271ETMsg.CASHPOST_CD).toString());
//			}
//
//			String joken2_2 = "0";
//			// 条件文定義
//			String joken_1 = KK3191ETMsg.getDBColumnName(KK3191ETMsg.CASHPOST_CD);
//			if(joken1_2 == null){
//				joken_1 += " IS NULL ";
//			}else{
//				joken_1 += " = ? ";
//			}
//
//			String joken_2 = KK3191ETMsg.getDBColumnName(KK3191ETMsg.MK_FLG);
//			if(joken2_2 == null){
//				joken_2 += " IS NULL ";
//			}else{
//				joken_2 += " = ? ";
//			}
//
//			// チェック条件
//			if (!inETMsg.isNull(KU0271ETMsg.CASHPOST_CD)) { 
//
//				// ＳＱＬ文の組み立て
//				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK3191ETMsg.getTableName()).append(" WHERE ")
//					.append("(" + joken_1 + " AND " + joken_2 + " ) ");
//
//				// ＳＱＬ文の解析
//				pstmtQuery = con.prepareStatement(sqlQuery.toString());
//
//				// パラメータの設定
//				int para_idx = 1;
//				if(joken1_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
//				}
//				if(joken2_2 != null){
//					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
//				}
//
//				// ＳＱＬ文の実行
//				rsltQuery = pstmtQuery.executeQuery();
//
//				if(rsltQuery.next()){
//				// 判定条件
//					if(!(rsltQuery.getLong("CNT")>0)){
//						inETMsg.set(KU0271ETMsg.CASHPOST_CD_ERR, errFlag);
//						if("W".equals(errFlag.substring(0,1))){
//							rtn = StatusCodes.WARNING;
//						} else {
//							rtn = StatusCodes.RELATION_ERR;
//						}
//					}
//				}
//
//			}
//
//		} catch(SQLException e) {
//			inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//			throw new CAANRuntimeException(e);
//		} finally {
//			// このメソッドで確保した資源の解放
//			try {
//				if(rsltQuery != null) {
//					rsltQuery.close();
//				}
//				if(pstmtQuery != null) {
//					pstmtQuery.close();
//				}
//				if(con != null) {
//					CAANConnectionMgr.getInstance().close(con);
//				}
//			} catch(SQLException e) {
//				inETMsg.set(KU0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//				throw new CAANRuntimeException(e);
//			}
//		}
//		
//		// ステータスのセット
//		if (rtn > inETMsg.getInt(KU0271ETMsg.STATUS)) {
//			inETMsg.set(KU0271ETMsg.STATUS, rtn);
//		}
//
//		return rtn;
//
//	}

}

