/*******************************************************************************
*	 All Rights reserved,Copyright (c) K-Opticom 
********************************************************************************
*＜プログラム内容＞
*	システム名		：eo顧客基幹システム
*	モジュール名	：JSYejbDK0171KRCK
*	ソースファイル名：JSYejbDK0171KRCK.java
*	作成者			：EK912100
*	日付			：2014年03月13日
*＜機能概要＞
*	関連チェック部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	ｖ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 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 eo.ejb.common.entity.JDKejbDK0171KRCK;
import eo.ejb.common.JPCModelCommon;

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
 *	execIDK0171C003_1
 *	execIDK0171C003_2
 *	execIDK0171C004_1
 *	execIDK0171C004_2
 *	execIDK0171C005_1
 *	execIDK0171C005_2
 *	execIDK0171C006_1
 *	execIDK0171C006_2
 *	execIDK0171C007_1
 *	execIDK0171C007_2
 *	execIDK0171C007_3
 *	execIDK0171C008_1
 *	execIDK0171C008_2
 *	execIDK0171C009_1
 *	execIDK0171C009_2
 *	execIDK0301D001_3
 *	execIDK0351D001_1
 *	execIKK0961D001_7
 *
 */

public class JSYejbDK0171KRCK implements KanrenCheckHandler {

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

	public JSYejbDK0171KRCK() {
	}

	/**
	 * 物流保全関連チェックを行います。
	 * 
	 * @param inETMsg エンティティ
	 * @param inContext Agentから渡されたAgentDispatchContext
	 */

	public void invoke(CAANMsg inETMsg, AgentDispatchContext inContext) {

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "call:JSYejbDK0171KRCK.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.IDK0171C003)){
			/** メーカー修理依頼振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0171C003_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.IDK0171C004)){
			/** 物流保全キャンセル振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0171C004_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.IDK0171C005)){
			/** 修理対象機器返品完了振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0171C005_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.IDK0171C006)){
			/** 機器メーカー修理完了更新振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0171C006_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.IDK0171C007)){
			/** 物流保全完了振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0171C007_1(inETMsg, inContext, "EA");

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

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

		}else if(eventID.equals(EventIDList.IDK0171C008)){
			/** 修理機器送付振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0171C008_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.IDK0171C009)){
			/** 交換機器送付振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0171C009_1(inETMsg, inContext, "EA");

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

		}else if(eventID.equals(EventIDList.IDK0301D001)){
			/** 返品機器受付振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0301D001_3(inETMsg, inContext, "EC");

		}else if(eventID.equals(EventIDList.IDK0351D001)){
			/** 物流保全対応記録登録振舞内部 */
			int Rtn = 0;
			Rtn = execIDK0351D001_1(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0961D001)){
			/** 利用停止期間登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0961D001_7(inETMsg, inContext, "EA");

		}

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

	}

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

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

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

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

		try{

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

			String joken2_2 = "\"\"";

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

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

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

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

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

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

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

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

			}

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

		return rtn;

	}

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

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

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

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

		try{

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

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

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

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


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

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

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

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

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

		return rtn;

	}

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

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

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

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

		try{

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

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

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

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


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

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

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

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

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

		return rtn;

	}

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

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

			// 制約部品引数定義
			Object joken_1_prm_1 = "DK0171";

			// 判定条件
			if(!(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == true)){
				inETMsg.set(DK0171ETMsg.UPD_DTM_ERR, errFlag);
				if("W".equals(errFlag.substring(0,1))){
					rtn = StatusCodes.WARNING;
				} else {
					rtn = StatusCodes.RELATION_ERR;
				}
			}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(DK0171ETMsg.STATUS)) {
			inETMsg.set(DK0171ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

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

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


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

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

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

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

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

		return rtn;

	}

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

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

			// 制約部品引数定義
			Object joken_1_prm_1 = "DK0171";

			// 判定条件
			if(!(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == true)){
				inETMsg.set(DK0171ETMsg.UPD_DTM_ERR, errFlag);
				if("W".equals(errFlag.substring(0,1))){
					rtn = StatusCodes.WARNING;
				} else {
					rtn = StatusCodes.RELATION_ERR;
				}
			}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(DK0171ETMsg.STATUS)) {
			inETMsg.set(DK0171ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

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


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

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

		return rtn;

	}

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

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

			// 制約部品引数定義
			Object joken_1_prm_1 = "DK0171";

			// 判定条件
			if(!(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == true)){
				inETMsg.set(DK0171ETMsg.UPD_DTM_ERR, errFlag);
				if("W".equals(errFlag.substring(0,1))){
					rtn = StatusCodes.WARNING;
				} else {
					rtn = StatusCodes.RELATION_ERR;
				}
			}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(DK0171ETMsg.STATUS)) {
			inETMsg.set(DK0171ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

			// 制約部品引数定義
			// 判定条件
			if(!(JDKejbDK0171KRCK.checkBtryhoznStat(inETMsg, inContext ) == true)){
				inETMsg.set(DK0171ETMsg.BTRYHOZN_NO_ERR, errFlag);
				if("W".equals(errFlag.substring(0,1))){
					rtn = StatusCodes.WARNING;
				} else {
					rtn = StatusCodes.RELATION_ERR;
				}
			}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(DK0171ETMsg.STATUS)) {
			inETMsg.set(DK0171ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

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


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

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

		return rtn;

	}

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

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

			// 制約部品引数定義
			Object joken_1_prm_1 = "DK0171";

			// 判定条件
			if(!(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == true)){
				inETMsg.set(DK0171ETMsg.UPD_DTM_ERR, errFlag);
				if("W".equals(errFlag.substring(0,1))){
					rtn = StatusCodes.WARNING;
				} else {
					rtn = StatusCodes.RELATION_ERR;
				}
			}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(DK0171ETMsg.STATUS)) {
			inETMsg.set(DK0171ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

			String joken2_2 = "003";
			String joken3_2 = "0";
			String joken4_2 = "2";
			String joken5_2 = "001";
			// 条件文定義
			String joken_1 = DK0171ETMsg.getDBColumnName(DK0171ETMsg.BTRYHOZN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

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

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

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

			String joken_5 = DK0171ETMsg.getDBColumnName(DK0171ETMsg.BTRYHOZN_STAT);
			if(joken5_2 == null){
				joken_5 += " IS NULL ";
			}else{
				joken_5 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(DK0171ETMsg.getTableName()).append(" WHERE ")
				.append("(" + "(" + joken_1 + " AND " + joken_3 + " ) " + " AND " + "(" + joken_2 + " OR " + "(" + joken_5 + " 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(joken2_2 != null){
				CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
			}
			if(joken5_2 != null){
				CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken5_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(DK0171ETMsg.BTRYHOZN_NO_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

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

		return rtn;

	}

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

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

			// 制約部品引数定義
			Object joken_1_prm_1 = "DK0171";

			// 判定条件
			if(!(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == true)){
				inETMsg.set(DK0171ETMsg.UPD_DTM_ERR, errFlag);
				if("W".equals(errFlag.substring(0,1))){
					rtn = StatusCodes.WARNING;
				} else {
					rtn = StatusCodes.RELATION_ERR;
				}
			}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(DK0171ETMsg.STATUS)) {
			inETMsg.set(DK0171ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

			String joken2_2 = "001";
			String joken3_2 = "0";
			String joken4_2 = "002";
			String joken5_2 = "1";
			// 条件文定義
			String joken_1 = DK0171ETMsg.getDBColumnName(DK0171ETMsg.BTRYHOZN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

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

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

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

			String joken_5 = DK0171ETMsg.getDBColumnName(DK0171ETMsg.DAITAI_KIKI_CD);
			if(joken5_2 == null){
				joken_5 += " IS NULL ";
			}else{
				joken_5 += " = ? ";
			}


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

			// ＳＱＬ文の解析
			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);
			}
			if(joken5_2 != null){
				CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken5_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(DK0171ETMsg.BTRYHOZN_NO_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

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

		return rtn;

	}

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

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

			// 制約部品引数定義
			Object joken_1_prm_1 = "DK0171";

			// 判定条件
			if(!(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == true)){
				inETMsg.set(DK0171ETMsg.UPD_DTM_ERR, errFlag);
				if("W".equals(errFlag.substring(0,1))){
					rtn = StatusCodes.WARNING;
				} else {
					rtn = StatusCodes.RELATION_ERR;
				}
			}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(DK0171ETMsg.STATUS)) {
			inETMsg.set(DK0171ETMsg.STATUS, rtn);
		}

		return rtn;

	}

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

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

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

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

		try{

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

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

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

			// チェック条件
			if (!inETMsg.isNull(DK0301ETMsg.BTRYHOZN_NO)) { 

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

			}

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

		return rtn;

	}

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

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

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

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

		try{

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

			String joken4_2 = "04";

			// ＳＱＬ引数定義
			String joken1_2 = "001";
			String joken5_2 = "004";
			String joken6_2 = null;
			if(!inETMsg.isNull(DK0351ETMsg.BTRYHOZN_NO)){
				joken6_2 = new String(inETMsg.getObject(DK0351ETMsg.BTRYHOZN_NO).toString());
			}

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

			String joken_5 = DK0171ETMsg.getDBColumnName(DK0171ETMsg.BTRYHOZN_STAT);
			if(joken5_2 == null){
				joken_5 += " IS NULL ";
			}else{
				joken_5 += " = ? ";
			}

			String joken_6 = DK0171ETMsg.getDBColumnName(DK0171ETMsg.BTRYHOZN_NO);
			if(joken6_2 == null){
				joken_6 += " IS NULL ";
			}else{
				joken_6 += " = ? ";
			}

			String joken_7 = DK0171ETMsg.getDBColumnName(DK0171ETMsg.MK_FLG);
			if(joken7_2 == null){
				joken_7 += " IS NULL ";
			}else{
				joken_7 += " = ? ";
			}

			// チェック条件
			if (joken4_1.compareTo(joken4_2) == 0) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(DK0171ETMsg.getTableName()).append(" WHERE ")
					.append("(" + "(" + "(" + joken_1 + " OR " + joken_5 + " ) " + " AND " + joken_6 + " ) " + " AND " + joken_7 + " ) ");

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

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

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

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

			}

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

		return rtn;

	}

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

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

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

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

		try{

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

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

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

			// チェック条件
			if (!inETMsg.isNull(KK0961ETMsg.BTRYHOZN_NO)) { 

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

			}

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

		return rtn;

	}

}

