/*******************************************************************************
*	 All Rights reserved,Copyright (c) K-Opticom 
********************************************************************************
*＜プログラム内容＞
*	システム名		：eo顧客基幹システム
*	モジュール名	：JSYejbTU0051KRCK
*	ソースファイル名：JSYejbTU0051KRCK.java
*	作成者			：EK916564
*	日付			：2014年08月18日
*＜機能概要＞
*	関連チェック部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	ｖ1.00.00
*	ｖ72.0.0	2024/04/04	FJ)竹内		【ANK-4494-00-00】【eo定期】 双方向番ポ対応
*
********************************************************************************/

package eo.ejb.cbm.entity;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.text.ParsePosition;
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 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
 *	execIKK0191D003_6
 *	execIKK0191D006_4
 *	execIKK0191D015_3
 *	execIKK1951C001_2
 *	execIKK1951D001_3
 *	execITU0011D004_8
 *	execITU0041C001_3
 *	execITU0041D001_2
 *	execITU0051C003_1
 *	execITU0051C003_2
 *	execITU0051C003_3
 *	execITU0051C004_1
 *	execITU0051C004_2
 *	execITU0051D001_1
 *	execITU0051D001_2
 *	execITU0051E001_1
 *	execITU0131C001_3
 *	execITU0131D001_2
 *	execIZM0121C001_7
 *	execIZM0121C001_8
 *	【ANK-4494-00-00】双方向番ポ対応 ADD STRAT
 *	execIZM0121C001_13
 *	execIZM0121C001_14
 *	execIZM0121C001_15
 *	【ANK-4494-00-00】双方向番ポ対応 ADD STRAT
 *
 */

public class JSYejbTU0051KRCK implements KanrenCheckHandler {

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

	public JSYejbTU0051KRCK() {
	}

	/**
	 * 通信事業者関連チェックを行います。
	 * 
	 * @param inETMsg エンティティ
	 * @param inContext Agentから渡されたAgentDispatchContext
	 */

	public void invoke(CAANMsg inETMsg, AgentDispatchContext inContext) {

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "call:JSYejbTU0051KRCK.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.IKK0191D003)){
			/** サービス契約内訳<eo光電話>登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0191D003_6(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0191D006)){
			/** サービス契約内訳<eo光電話>情報変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0191D006_4(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0191D015)){
			/** サービス契約内訳<eo光電話>情報変更(住変)振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0191D015_3(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK1951C001)){
			/** 住所変更申込電話番号一時保存更新振舞内部 */
			int Rtn = 0;
			Rtn = execIKK1951C001_2(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK1951D001)){
			/** 住所変更申込電話番号一時保存登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK1951D001_3(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.ITU0011D004)){
			/** 番ポ工事登録振舞内部 */
			int Rtn = 0;
			Rtn = execITU0011D004_8(inETMsg, inContext, "EH");

		}else if(eventID.equals(EventIDList.ITU0041C001)){
			/** 申込事業所内容変更振舞内部 */
			int Rtn = 0;
			Rtn = execITU0041C001_3(inETMsg, inContext, "EC");

		}else if(eventID.equals(EventIDList.ITU0041D001)){
			/** 申込事業所登録振舞内部 */
			int Rtn = 0;
			Rtn = execITU0041D001_2(inETMsg, inContext, "EB");

		}else if(eventID.equals(EventIDList.ITU0051C003)){
			/** 通信事業者変更振舞内部 */
			int Rtn = 0;
			Rtn = execITU0051C003_1(inETMsg, inContext, "EA");

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

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

		}else if(eventID.equals(EventIDList.ITU0051C004)){
			/** 通信事業者削除振舞内部 */
			int Rtn = 0;
			Rtn = execITU0051C004_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.ITU0051D001)){
			/** 通信事業者登録振舞内部 */
			int Rtn = 0;
			Rtn = execITU0051D001_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.ITU0051E001)){
			/** 通信事業者削除振舞内部 */
			int Rtn = 0;
			Rtn = execITU0051E001_1(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.ITU0131C001)){
			/** 通信事業者拠点内容変更振舞内部 */
			int Rtn = 0;
			Rtn = execITU0131C001_3(inETMsg, inContext, "EC");

		}else if(eventID.equals(EventIDList.ITU0131D001)){
			/** 通信事業者拠点登録振舞内部 */
			int Rtn = 0;
			Rtn = execITU0131D001_2(inETMsg, inContext, "EB");

		}else if(eventID.equals(EventIDList.IZM0121C001)){
			/** 電話番号変更振舞内部 */
			int Rtn = 0;
			//【ANK-4494-00-00】双方向番ポ対応 DEL STRAT
//			Rtn = execIZM0121C001_7(inETMsg, inContext, "EG");
//
//			if(Rtn <= StatusCodes.WARNING){
//				Rtn = execIZM0121C001_8(inETMsg, inContext, "EH");
//			}
			//【ANK-4494-00-00】双方向番ポ対応 DEL END

			//【ANK-4494-00-00】双方向番ポ対応 ADD STRAT
			Rtn = execIZM0121C001_13(inETMsg, inContext, "EM");

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

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIZM0121C001_15(inETMsg, inContext, "EO");
			}
			//【ANK-4494-00-00】双方向番ポ対応 ADD END

		}

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

	}

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

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

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

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

		try{

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

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0191ETMsg.TSJGS_CD)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(KK0191ETMsg.TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0191ETMsg.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(KK0191ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0191ETMsg.STATUS)) {
			inETMsg.set(KK0191ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

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

			// チェック条件
			if (!inETMsg.isNull(KK0191ETMsg.TSJGS_CD)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(KK0191ETMsg.TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0191ETMsg.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(KK0191ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0191ETMsg.STATUS)) {
			inETMsg.set(KK0191ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

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

			// チェック条件
			if (!inETMsg.isNull(KK0191ETMsg.TSJGS_CD)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(KK0191ETMsg.TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0191ETMsg.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(KK0191ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0191ETMsg.STATUS)) {
			inETMsg.set(KK0191ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK1951ETMsg.BMP_MSKM_JI_TSJGS_CD)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(KK1951ETMsg.BMP_MSKM_JI_TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK1951ETMsg.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(KK1951ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK1951ETMsg.STATUS)) {
			inETMsg.set(KK1951ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK1951ETMsg.BMP_MSKM_JI_TSJGS_CD)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(KK1951ETMsg.BMP_MSKM_JI_TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK1951ETMsg.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(KK1951ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK1951ETMsg.STATUS)) {
			inETMsg.set(KK1951ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(TU0011ETMsg.ITNM_TSJGS_CD)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0011ETMsg.ITNM_TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(TU0011ETMsg.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(TU0011ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0011ETMsg.STATUS)) {
			inETMsg.set(TU0011ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0041ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0041ETMsg.TSJGS_CD).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0041ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0041ETMsg.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(TU0041ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0041ETMsg.STATUS)) {
			inETMsg.set(TU0041ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0041ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0041ETMsg.TSJGS_CD).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0041ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0041ETMsg.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(TU0041ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0041ETMsg.STATUS)) {
			inETMsg.set(TU0041ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0051ETMsg.TSJGS_CD).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0051ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0051ETMsg.TSJGS_CD).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.UPD_DTM)){
				joken2_2 = new String(inETMsg.getObject(TU0051ETMsg.UPD_DTM).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.UPD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0051ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// チェック条件定数
			String joken2_1 = new String();
			if(!inETMsg.isNull(TU0051ETMsg.JISHA_TASHA_FLG)){
				joken2_1 = inETMsg.getObject(TU0051ETMsg.JISHA_TASHA_FLG).toString();
			}

			String joken2_2 = "1";

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0051ETMsg.TSJGS_CD).toString());
			}

			String joken3_2 = "1";
			String joken4_2 = "0";
			// 条件文定義
			String joken_1 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.TSJGS_CD);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " <> ? ";
			}

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

			String joken_4 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken4_2 == null){
				joken_4 += " IS NULL ";
			}else{
				joken_4 += " = ? ";
			}

			// チェック条件
			if (joken2_1.compareTo(joken2_2) == 0) { 

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

				// ＳＱＬ文の解析
				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);
				}
				if(joken4_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken4_2);
				}

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

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

			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0051ETMsg.TSJGS_CD).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0051ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0051ETMsg.TSJGS_CD).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.UPD_DTM)){
				joken2_2 = new String(inETMsg.getObject(TU0051ETMsg.UPD_DTM).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.UPD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0051ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0051ETMsg.TSJGS_CD).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0051ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// チェック条件定数
			String joken2_1 = new String();
			if(!inETMsg.isNull(TU0051ETMsg.JISHA_TASHA_FLG)){
				joken2_1 = inETMsg.getObject(TU0051ETMsg.JISHA_TASHA_FLG).toString();
			}

			String joken2_2 = "1";

			// ＳＱＬ引数定義
			String joken1_2 = "1";
			String joken3_2 = "0";
			// 条件文定義
			String joken_1 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.JISHA_TASHA_FLG);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

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

			// チェック条件
			if (joken2_1.compareTo(joken2_2) == 0) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0051ETMsg.JISHA_TASHA_FLG_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0051ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0051ETMsg.TSJGS_CD).toString());
			}

			String joken2_2 = "1";
			// 条件文定義
			String joken_1 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.TSJGS_CD);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0051ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0051ETMsg.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(TU0051ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0051ETMsg.STATUS)) {
			inETMsg.set(TU0051ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0131ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0131ETMsg.TSJGS_CD).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0131ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0131ETMsg.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(TU0131ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0131ETMsg.STATUS)) {
			inETMsg.set(TU0131ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(TU0131ETMsg.TSJGS_CD)){
				joken1_2 = new String(inETMsg.getObject(TU0131ETMsg.TSJGS_CD).toString());
			}

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

			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(TU0131ETMsg.TSJGS_CD_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(TU0131ETMsg.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(TU0131ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(TU0131ETMsg.STATUS)) {
			inETMsg.set(TU0131ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	//【ANK-4494-00-00】双方向番ポ対応 DEL STRAT
//	/**
//	 * IZM0121C001_制約ＮＯ7チェック
//	 *
//	 * @param inETMsg チェック対象のETMsg(ZM0121ETMsg)
//	 * @param inContext Agentから渡されたAgentDispatchContext
//	 * @param errFlag ERRフラグ
//	 * @return int チェック結果
//	 */
//	private int execIZM0121C001_7(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){
//
//		// ステータス
//		int rtn = 0;
//
//		Connection con = JSYejbConnection.getConnection(TU0051ETMsg.getTableName());
//
//		PreparedStatement pstmtQuery = null;
//		ResultSet rsltQuery = null;
//		StringBuffer sqlQuery = new StringBuffer();
//
//		try{
//
//			// ＳＱＬ引数定義
//			String joken1_2 = null;
//			if(!inETMsg.isNull(ZM0121ETMsg.WARIATE_TSJGS_CD)){
//				joken1_2 = new String(inETMsg.getObject(ZM0121ETMsg.WARIATE_TSJGS_CD).toString());
//			}
//
//			String joken2_2 = "0";
//			// 条件文定義
//			String joken_1 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.TSJGS_CD);
//			if(joken1_2 == null){
//				joken_1 += " IS NULL ";
//			}else{
//				joken_1 += " = ? ";
//			}
//
//			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
//			if(joken2_2 == null){
//				joken_2 += " IS NULL ";
//			}else{
//				joken_2 += " = ? ";
//			}
//
//
//			// ＳＱＬ文の組み立て
//			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(ZM0121ETMsg.WARIATE_TSJGS_CD_ERR, errFlag);
//					if("W".equals(errFlag.substring(0,1))){
//						rtn = StatusCodes.WARNING;
//					} else {
//						rtn = StatusCodes.RELATION_ERR;
//					}
//				}
//			}
//
//		} catch(SQLException e) {
//			inETMsg.set(ZM0121ETMsg.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(ZM0121ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//				throw new CAANRuntimeException(e);
//			}
//		}
//		
//		// ステータスのセット
//		if (rtn > inETMsg.getInt(ZM0121ETMsg.STATUS)) {
//			inETMsg.set(ZM0121ETMsg.STATUS, rtn);
//		}
//
//		return rtn;
//
//	}
	//【ANK-4494-00-00】双方向番ポ対応 DEL END

	//【ANK-4494-00-00】双方向番ポ対応 DEL STRAT
//	/**
//	 * IZM0121C001_制約ＮＯ8チェック
//	 *
//	 * @param inETMsg チェック対象のETMsg(ZM0121ETMsg)
//	 * @param inContext Agentから渡されたAgentDispatchContext
//	 * @param errFlag ERRフラグ
//	 * @return int チェック結果
//	 */
//	private int execIZM0121C001_8(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){
//
//		// ステータス
//		int rtn = 0;
//
//		Connection con = JSYejbConnection.getConnection(TU0051ETMsg.getTableName());
//
//		PreparedStatement pstmtQuery = null;
//		ResultSet rsltQuery = null;
//		StringBuffer sqlQuery = new StringBuffer();
//
//		try{
//
//			// ＳＱＬ引数定義
//			String joken1_2 = null;
//			if(!inETMsg.isNull(ZM0121ETMsg.USE_TSJGS_CD)){
//				joken1_2 = new String(inETMsg.getObject(ZM0121ETMsg.USE_TSJGS_CD).toString());
//			}
//
//			String joken2_2 = "0";
//			// 条件文定義
//			String joken_1 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.TSJGS_CD);
//			if(joken1_2 == null){
//				joken_1 += " IS NULL ";
//			}else{
//				joken_1 += " = ? ";
//			}
//
//			String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
//			if(joken2_2 == null){
//				joken_2 += " IS NULL ";
//			}else{
//				joken_2 += " = ? ";
//			}
//
//
//			// ＳＱＬ文の組み立て
//			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(ZM0121ETMsg.USE_TSJGS_CD_ERR, errFlag);
//					if("W".equals(errFlag.substring(0,1))){
//						rtn = StatusCodes.WARNING;
//					} else {
//						rtn = StatusCodes.RELATION_ERR;
//					}
//				}
//			}
//
//		} catch(SQLException e) {
//			inETMsg.set(ZM0121ETMsg.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(ZM0121ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
//				throw new CAANRuntimeException(e);
//			}
//		}
//		
//		// ステータスのセット
//		if (rtn > inETMsg.getInt(ZM0121ETMsg.STATUS)) {
//			inETMsg.set(ZM0121ETMsg.STATUS, rtn);
//		}
//
//		return rtn;
//
//	}
	//【ANK-4494-00-00】双方向番ポ対応 DEL END

	//【ANK-4494-00-00】双方向番ポ対応 ADD STRAT
	/**
	 * IZM0121C001_制約ＮＯ13チェック
	 *
	 * @param inETMsg チェック対象のETMsg(ZM0121ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIZM0121C001_13(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

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

		if(!inETMsg.isNull(ZM0121ETMsg.TLN_STKU_TSJGS_CD))
		{
			Connection con = JSYejbConnection.getConnection(TU0051ETMsg.getTableName());

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

			try{

				// ＳＱＬ引数定義
				String joken1_2 = null;
				if(!inETMsg.isNull(ZM0121ETMsg.TLN_STKU_TSJGS_CD)){
					joken1_2 = new String(inETMsg.getObject(ZM0121ETMsg.TLN_STKU_TSJGS_CD).toString());
				}

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

				String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
				if(joken2_2 == null){
					joken_2 += " IS NULL ";
				}else{
					joken_2 += " = ? ";
				}


				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(ZM0121ETMsg.TLN_STKU_TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			} catch(SQLException e) {
				inETMsg.set(ZM0121ETMsg.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(ZM0121ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
					throw new CAANRuntimeException(e);
				}
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(ZM0121ETMsg.STATUS)) {
			inETMsg.set(ZM0121ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

		if(!inETMsg.isNull(ZM0121ETMsg.ITNM_TSJGS_CD))
		{
			Connection con = JSYejbConnection.getConnection(TU0051ETMsg.getTableName());

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

			try{

				// ＳＱＬ引数定義
				String joken1_2 = null;
				if(!inETMsg.isNull(ZM0121ETMsg.ITNM_TSJGS_CD)){
					joken1_2 = new String(inETMsg.getObject(ZM0121ETMsg.ITNM_TSJGS_CD).toString());
				}

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

				String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
				if(joken2_2 == null){
					joken_2 += " IS NULL ";
				}else{
					joken_2 += " = ? ";
				}


				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(ZM0121ETMsg.ITNM_TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			} catch(SQLException e) {
				inETMsg.set(ZM0121ETMsg.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(ZM0121ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
					throw new CAANRuntimeException(e);
				}
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(ZM0121ETMsg.STATUS)) {
			inETMsg.set(ZM0121ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

		if(!inETMsg.isNull(ZM0121ETMsg.ITNS_TSJGS_CD))
		{
			Connection con = JSYejbConnection.getConnection(TU0051ETMsg.getTableName());

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

			try{

				// ＳＱＬ引数定義
				String joken1_2 = null;
				if(!inETMsg.isNull(ZM0121ETMsg.ITNS_TSJGS_CD)){
					joken1_2 = new String(inETMsg.getObject(ZM0121ETMsg.ITNS_TSJGS_CD).toString());
				}

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

				String joken_2 = TU0051ETMsg.getDBColumnName(TU0051ETMsg.MK_FLG);
				if(joken2_2 == null){
					joken_2 += " IS NULL ";
				}else{
					joken_2 += " = ? ";
				}


				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(TU0051ETMsg.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(ZM0121ETMsg.ITNS_TSJGS_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			} catch(SQLException e) {
				inETMsg.set(ZM0121ETMsg.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(ZM0121ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
					throw new CAANRuntimeException(e);
				}
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(ZM0121ETMsg.STATUS)) {
			inETMsg.set(ZM0121ETMsg.STATUS, rtn);
		}

		return rtn;

	}
	//【ANK-4494-00-00】双方向番ポ対応 ADD END
}

