/*
 * MosP - Mind Open Source Project    http://www.mosp.jp/
 * Copyright (C) MIND Co., Ltd.       http://www.e-mind.co.jp/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package jp.mosp.payroll.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import jp.mosp.common.utils.DateUtil;
import jp.mosp.kintai.common.dao.MKihonDao;
import jp.mosp.payroll.base.PayrollConst;
import jp.mosp.payroll.base.PayrollDao;
import jp.mosp.payroll.dto.AdjustmentDto;

/**
 * @author koike 
 *
 */
public class AdjustmentDao extends PayrollDao {
	
	// 列名
	/**
	 * 社員コード
	 */
	public static final String	COL_K_CODE_KIHON			= MKihonDao.TABLE + "." + MKihonDao.COL_KCODE;
	
	/**
	 * 社員コード
	 */
	public static final String	COL_K_CODE_INC_TAX			= CmIncomeTaxDao.TABLE + "." + CmIncomeTaxDao.COL_K_CODE;
	
	/**
	 * 社員コード
	 */
	public static final String	COL_K_CODE_MID_ENT			= CmMidwayEnterDao.TABLE + "."
																	+ CmMidwayEnterDao.COL_K_CODE;
	/**
	 * 社員コード
	 */
	public static final String	COL_K_CODE_ADJUST			= CdAdjustmentDao.TABLE + "." + CdAdjustmentDao.COL_K_CODE;
	
	/**
	 * 社員氏名
	 */
	public static final String	COL_K_NAME					= MKihonDao.TABLE + "." + MKihonDao.COL_SIMEI;
	
	/**
	 * 社員ﾌﾘｶﾞﾅ
	 */
	public static final String	COL_K_KANA					= MKihonDao.TABLE + "." + MKihonDao.COL_FURIGANA;
	
	/**
	 * 所属コード
	 */
	public static final String	COL_STATION_CODE			= MKihonDao.TABLE + "." + MKihonDao.COL_SCODE;
	
	/**
	 * 職位コード
	 */
	public static final String	COL_POSITION_CODE			= MKihonDao.TABLE + "." + MKihonDao.COL_YCODE;
	
	/**
	 * 入社日
	 */
	public static final String	COL_ENTRANCE_DATE			= MKihonDao.TABLE + "." + MKihonDao.COL_NYDATE;
	
	/**
	 * 退社日
	 */
	public static final String	COL_RETIREMENT_DATE			= MKihonDao.TABLE + "." + MKihonDao.COL_TSDATE;
	
	/**
	 * 所得税適用年
	 */
	public static final String	COL_INC_EXPECTED_DATE		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_INC_EXPECTED_DATE;
	/**
	 * 課税区分
	 */
	public static final String	COL_INCOME_TAX_TYPE			= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_INCOME_TAX_TYPE;
	/**
	 * 年末調整区分
	 */
	public static final String	COL_ADJUSTMENT_TYPE			= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_ADJUSTMENT_TYPE;
	/**
	 * 本人寡婦区分
	 */
	public static final String	COL_SELF_WIDOW_TYPE			= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_SELF_WIDOW_TYPE;
	/**
	 * 本人障害区分
	 */
	public static final String	COL_SELF_HANDICAP_TYPE		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_SELF_HANDICAP_TYPE;
	/**
	 * 本人学生区分
	 */
	public static final String	COL_SELF_STUDENT_TYPE		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_SELF_STUDENT_TYPE;
	/**
	 * 配偶者区分
	 */
	public static final String	COL_SPOUSE_INTEND_TYPE		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_SPOUSE_INTEND_TYPE;
	/**
	 * 一般扶養親族
	 */
	public static final String	COL_GENERAL_DEPENDENT		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_GENERAL_DEPENDENT;
	/**
	 * 特定扶養親族
	 */
	public static final String	COL_SPECIFIC_DEPENDENT		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_SPECIFIC_DEPENDENT;
	/**
	 * 老人扶養親族
	 */
	public static final String	COL_ELDERLY_DEPENDENT		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_ELDERLY_DEPENDENT;
	/**
	 * 同居老親等
	 */
	public static final String	COL_LIVE_WITH_ELD_REL		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_LIVE_WITH_ELD_REL;
	/**
	 * 同居特障一般
	 */
	public static final String	COL_LIVE_WITH_HANDI_GE		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_LIVE_WITH_HANDI_GE;
	/**
	 * 同居特障特定
	 */
	public static final String	COL_LIVE_WITH_HANDI_SP		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_LIVE_WITH_HANDI_SP;
	/**
	 * 同居特障老人
	 */
	public static final String	COL_LIVE_WITH_HANDI_EL		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_LIVE_WITH_HANDI_EL;
	/**
	 * 同居特障老親
	 */
	public static final String	COL_LIVE_WITH_HANDI_ER		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_LIVE_WITH_HANDI_ER;
	/**
	 * 一般障害者
	 */
	public static final String	COL_GENERAL_HANDICAP		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_GENERAL_HANDICAP;
	/**
	 * 特別障害者
	 */
	public static final String	COL_SPECIFIC_HANDICAP		= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_SPECIFIC_HANDICAP;
	/**
	 * 扶養等の数
	 */
	public static final String	COL_DEPENDENT_COUNT			= CmIncomeTaxDao.TABLE + "."
																	+ CmIncomeTaxDao.COL_DEPENDENT_COUNT;
	/**
	 * 中途入社区分
	 */
	public static final String	COL_MIDWAY_TYPE				= CmMidwayEnterDao.TABLE + "."
																	+ CmMidwayEnterDao.COL_MIDWAY_TYPE;
	/**
	 * 前勤務先収入金額
	 */
	public static final String	COL_FORMER_INCOME			= CmMidwayEnterDao.TABLE + "."
																	+ CmMidwayEnterDao.COL_FORMER_INCOME;
	/**
	 * 前勤務先社会保険額
	 */
	public static final String	COL_FORMER_INSURANCE		= CmMidwayEnterDao.TABLE + "."
																	+ CmMidwayEnterDao.COL_FORMER_INSURANCE;
	/**
	 * 前勤務先所得税額
	 */
	public static final String	COL_FORMER_TAX				= CmMidwayEnterDao.TABLE + "."
																	+ CmMidwayEnterDao.COL_FORMER_TAX;
	/**
	 * 調整年
	 */
	public static final String	COL_ADJUST_YEAR				= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_ADJUST_YEAR;
	/**
	 * 年末調整計算状態
	 */
	public static final String	COL_ADJUST_STATUS			= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_ADJUST_STATUS;
	/**
	 * 一般の生命保険料
	 */
	public static final String	COL_GENERAL_LIFE_INS		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_GENERAL_LIFE_INS;
	/**
	 * 個人年金保険料
	 */
	public static final String	COL_PRIVATE_PENSION			= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_PRIVATE_PENSION;
	/**
	 * 生命保険料控除額
	 */
	public static final String	COL_LIFE_INS_DEDUCTION		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_LIFE_INS_DEDUCTION;
	/**
	 * 地震保険料
	 */
	public static final String	COL_EARTHQUAKE_INS			= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_EARTHQUAKE_INS;
	/**
	 * 旧長期損害保険料
	 */
	public static final String	COL_LONG_TERM_DAMAGE_INS	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_LONG_TERM_DAMAGE_INS;
	/**
	 * 損害保険料控除額
	 */
	public static final String	COL_DAMAGE_INS_DEDUCTION	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_DAMAGE_INS_DEDUCTION;
	/**
	 * 社会保険料控除額
	 */
	public static final String	COL_SOCIAL_INS_DEDUCTION	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_SOCIAL_INS_DEDUCTION;
	/**
	 * 小規模企業共済等掛金控除額
	 */
	public static final String	COL_MUTUAL_AID_DEDUCTION	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_MUTUAL_AID_DEDUCTION;
	/**
	 * 配偶者の本年中の合計所得金額の見積額
	 */
	public static final String	COL_SPOUSE_SUM_INCOME		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_SPOUSE_SUM_INCOME;
	/**
	 * 配偶者特別控除額
	 */
	public static final String	COL_SPOUSE_SP_DEDUCTION		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_SPOUSE_SP_DEDUCTION;
	/**
	 * 住宅借入金等特別控除額
	 */
	public static final String	COL_HOUSE_LOAN_DEDUCTION	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_HOUSE_LOAN_DEDUCTION;
	/**
	 * 支給調整額
	 */
	public static final String	COL_ALLOWANCE_ADJUSTMENT	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_ALLOWANCE_ADJUSTMENT;
	/**
	 * 非課税調整額
	 */
	public static final String	COL_TAX_FREE_ADJUSTMENT		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_TAX_FREE_ADJUSTMENT;
	/**
	 * 社会保険調整額
	 */
	public static final String	COL_SOC_INS_ADJUSTMENT		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_SOC_INS_ADJUSTMENT;
	/**
	 * 所得税調整額
	 */
	public static final String	COL_TAX_INC_ADJUSTMENT		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_TAX_INC_ADJUSTMENT;
	/**
	 * 源泉徴収票摘要欄
	 */
	public static final String	COL_WITHHOLD_SLIP_NOTES		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_WITHHOLD_SLIP_NOTES;
	/**
	 * 給与、手当等金額
	 */
	public static final String	COL_PAYMENT_ALLOWANCE		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_PAYMENT_ALLOWANCE;
	/**
	 * 給与、手当等税額
	 */
	public static final String	COL_PAYMENT_INCOME_TAX		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_PAYMENT_INCOME_TAX;
	/**
	 * 賞与等金額
	 */
	public static final String	COL_BONUS_ALLOWANCE			= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_BONUS_ALLOWANCE;
	/**
	 * 賞与等税額
	 */
	public static final String	COL_BONUS_INCOME_TAX		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_BONUS_INCOME_TAX;
	/**
	 * 中途、調整収入金額
	 */
	public static final String	COL_MIDWAY_ADJUST_INCOME	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_MIDWAY_ADJUST_INCOME;
	/**
	 * 中途、調整収入税額
	 */
	public static final String	COL_MIDWAY_ADJUST_TAX		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_MIDWAY_ADJUST_TAX;
	/**
	 * 給与所得控除後の給与等の金額
	 */
	public static final String	COL_AFTER_DEDUCT_INCOME		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_AFTER_DEDUCT_INCOME;
	
	/**
	 * 社会保険料等給与等からの控除分
	 */
	public static final String	COL_PAY_INS_DEDUCTION		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_PAY_INS_DEDUCTION;
	/**
	 * 配偶者控除額、扶養控除額、基礎控除額及び障害者等の控除額の合計額
	 */
	public static final String	COL_DEPENDENTS_DEDUCTION	= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_DEPENDENTS_DEDUCTION;
	/**
	 * 差引課税給与所得金額
	 */
	public static final String	COL_CALC_TAXED_INCOME		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_CALC_TAXED_INCOME;
	/**
	 * 算出年税額
	 */
	public static final String	COL_CALC_INCOME_TAX			= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_CALC_INCOME_TAX;
	/**
	 * 年調年税額
	 */
	public static final String	COL_ADJUSTED_INCOME_TAX		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_ADJUSTED_INCOME_TAX;
	/**
	 * 年調定率控除額税額
	 */
	public static final String	COL_DEDUCTED_INCOME_TAX		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_DEDUCTED_INCOME_TAX;
	/**
	 * 年税額
	 */
	public static final String	COL_FINAL_INCOME_TAX		= CdAdjustmentDao.TABLE + "."
																	+ CdAdjustmentDao.COL_FINAL_INCOME_TAX;
	/**
	 * 社員コード
	 */
	public static final int		NUM_K_CODE_KIHON			= 1;
	
	/**
	 * 社員コード
	 */
	public static final int		NUM_K_CODE_INC_TAX			= 2;
	
	/**
	 * 社員コード
	 */
	public static final int		NUM_K_CODE_MID_ENT			= 3;
	/**
	 * 社員コード
	 */
	public static final int		NUM_K_CODE_ADJUST			= 4;
	
	/**
	 * 社員氏名
	 */
	public static final int		NUM_K_NAME					= 5;
	
	/**
	 * 社員ﾌﾘｶﾞﾅ
	 */
	public static final int		NUM_K_KANA					= 6;
	
	/**
	 * 所属コード
	 */
	public static final int		NUM_STATION_CODE			= 7;
	
	/**
	 * 職位コード
	 */
	public static final int		NUM_POSITION_CODE			= 8;
	
	/**
	 * 入社日
	 */
	public static final int		NUM_ENTRANCE_DATE			= 9;
	
	/**
	 * 退社日
	 */
	public static final int		NUM_RETIREMENT_DATE			= 10;
	
	/**
	 * 所得税適用年
	 */
	public static final int		NUM_INC_EXPECTED_DATE		= 11;
	/**
	 * 課税区分
	 */
	public static final int		NUM_INCOME_TAX_TYPE			= 12;
	/**
	 * 年末調整区分
	 */
	public static final int		NUM_ADJUSTMENT_TYPE			= 13;
	/**
	 * 本人寡婦区分
	 */
	public static final int		NUM_SELF_WIDOW_TYPE			= 14;
	/**
	 * 本人障害区分
	 */
	public static final int		NUM_SELF_HANDICAP_TYPE		= 15;
	/**
	 * 本人学生区分
	 */
	public static final int		NUM_SELF_STUDENT_TYPE		= 16;
	/**
	 * 配偶者区分
	 */
	public static final int		NUM_SPOUSE_INTEND_TYPE		= 17;
	/**
	 * 一般扶養親族
	 */
	public static final int		NUM_GENERAL_DEPENDENT		= 18;
	/**
	 * 特定扶養親族
	 */
	public static final int		NUM_SPECIFIC_DEPENDENT		= 19;
	/**
	 * 老人扶養親族
	 */
	public static final int		NUM_ELDERLY_DEPENDENT		= 20;
	/**
	 * 同居老親等
	 */
	public static final int		NUM_LIVE_WITH_ELD_REL		= 21;
	/**
	 * 同居特障一般
	 */
	public static final int		NUM_LIVE_WITH_HANDI_GE		= 22;
	/**
	 * 同居特障特定
	 */
	public static final int		NUM_LIVE_WITH_HANDI_SP		= 23;
	/**
	 * 同居特障老人
	 */
	public static final int		NUM_LIVE_WITH_HANDI_EL		= 24;
	/**
	 * 同居特障老親
	 */
	public static final int		NUM_LIVE_WITH_HANDI_ER		= 25;
	/**
	 * 一般障害者
	 */
	public static final int		NUM_GENERAL_HANDICAP		= 26;
	/**
	 * 特別障害者
	 */
	public static final int		NUM_SPECIFIC_HANDICAP		= 27;
	/**
	 * 扶養等の数
	 */
	public static final int		NUM_DEPENDENT_COUNT			= 28;
	/**
	 * 中途入社区分
	 */
	public static final int		NUM_MIDWAY_TYPE				= 29;
	/**
	 * 前勤務先収入金額
	 */
	public static final int		NUM_FORMER_INCOME			= 30;
	/**
	 * 前勤務先社会保険額
	 */
	public static final int		NUM_FORMER_INSURANCE		= 31;
	/**
	 * 前勤務先所得税額
	 */
	public static final int		NUM_FORMER_TAX				= 32;
	/**
	 * 調整年
	 */
	public static final int		NUM_ADJUST_YEAR				= 33;
	/**
	 * 年末調整計算状態
	 */
	public static final int		NUM_ADJUST_STATUS			= 34;
	/**
	 * 一般の生命保険料
	 */
	public static final int		NUM_GENERAL_LIFE_INS		= 35;
	/**
	 * 個人年金保険料
	 */
	public static final int		NUM_PRIVATE_PENSION			= 36;
	/**
	 * 生命保険料控除額
	 */
	public static final int		NUM_LIFE_INS_DEDUCTION		= 37;
	/**
	 * 地震保険料
	 */
	public static final int		NUM_EARTHQUAKE_INS			= 38;
	/**
	 * 旧長期損害保険料
	 */
	public static final int		NUM_LONG_TERM_DAMAGE_INS	= 39;
	/**
	 * 損害保険料控除額
	 */
	public static final int		NUM_DAMAGE_INS_DEDUCTION	= 40;
	/**
	 * 社会保険料控除額
	 */
	public static final int		NUM_SOCIAL_INS_DEDUCTION	= 41;
	/**
	 * 小規模企業共済等掛金控除額
	 */
	public static final int		NUM_MUTUAL_AID_DEDUCTION	= 42;
	/**
	 * 配偶者の本年中の合計所得金額の見積額
	 */
	public static final int		NUM_SPOUSE_SUM_INCOME		= 43;
	/**
	 * 配偶者特別控除額
	 */
	public static final int		NUM_SPOUSE_SP_DEDUCTION		= 44;
	/**
	 * 住宅借入金等特別控除額
	 */
	public static final int		NUM_HOUSE_LOAN_DEDUCTION	= 45;
	/**
	 * 支給調整額
	 */
	public static final int		NUM_ALLOWANCE_ADJUSTMENT	= 46;
	/**
	 * 非課税調整額
	 */
	public static final int		NUM_TAX_FREE_ADJUSTMENT		= 47;
	/**
	 * 社会保険調整額
	 */
	public static final int		NUM_SOC_INS_ADJUSTMENT		= 48;
	/**
	 * 所得税調整額
	 */
	public static final int		NUM_TAX_INC_ADJUSTMENT		= 49;
	/**
	 * 源泉徴収票摘要欄
	 */
	public static final int		NUM_WITHHOLD_SLIP_NOTES		= 50;
	/**
	 * 給与、手当等金額
	 */
	public static final int		NUM_PAYMENT_ALLOWANCE		= 51;
	/**
	 * 給与、手当等税額
	 */
	public static final int		NUM_PAYMENT_INCOME_TAX		= 52;
	/**
	 * 賞与等金額
	 */
	public static final int		NUM_BONUS_ALLOWANCE			= 53;
	/**
	 * 賞与等税額
	 */
	public static final int		NUM_BONUS_INCOME_TAX		= 54;
	/**
	 * 中途、調整収入金額
	 */
	public static final int		NUM_MIDWAY_ADJUST_INCOME	= 55;
	/**
	 * 中途、調整収入税額
	 */
	public static final int		NUM_MIDWAY_ADJUST_TAX		= 56;
	/**
	 * 給与所得控除後の給与等の金額
	 */
	public static final int		NUM_AFTER_DEDUCT_INCOME		= 57;
	/**
	 * 社会保険料等給与等からの控除分
	 */
	public static final int		NUM_PAY_INS_DEDUCTION		= 58;
	/**
	 * 配偶者控除額、扶養控除額、基礎控除額及び障害者等の控除額の合計額
	 */
	public static final int		NUM_DEPENDENTS_DEDUCTION	= 59;
	/**
	 * 差引課税給与所得金額
	 */
	public static final int		NUM_CALC_TAXED_INCOME		= 60;
	/**
	 * 算出年税額
	 */
	public static final int		NUM_CALC_INCOME_TAX			= 61;
	/**
	 * 年調年税額
	 */
	public static final int		NUM_ADJUSTED_INCOME_TAX		= 62;
	/**
	 * 年調定率控除額税額
	 */
	public static final int		NUM_DEDUCTED_INCOME_TAX		= 63;
	/**
	 * 年税額
	 */
	public static final int		NUM_FINAL_INCOME_TAX		= 64;
	

	/**
	 * コンストラクタ
	 */
	public AdjustmentDao() {
		super();
		INSERT_DATE = "";
		INSERT_USER = "";
		UPDATE_DATE = "";
		UPDATE_USER = "";
	}
	
	/**
	 * 検索結果取得(DTOのList)
	 * @return List 検索リスト
	 * @throws SQLException SQL例外が発生した場合
	 */
	private List<AdjustmentDto> mappingAll() throws SQLException {
		List<AdjustmentDto> all = new ArrayList<AdjustmentDto>();
		while (rs.next()) {
			all.add(mapping());
		}
		return all;
	}
	
	/**
	 * 検索結果取得(DTO)
	 * @return AdjustmentListDto 年末調整レコード
	 * @throws SQLException SQL例外が発生した場合
	 */
	private AdjustmentDto mapping() throws SQLException {
		AdjustmentDto dto = new AdjustmentDto();
		dto.setKCode(rs.getString(NUM_K_CODE_KIHON)); // 社員コード
		
		dto.setKName(rs.getString(NUM_K_NAME)); // 社員氏名
		dto.setKKana(rs.getString(NUM_K_KANA)); // 社員ﾌﾘｶﾞﾅ
		dto.setStationCode(rs.getString(NUM_STATION_CODE)); // 所属コード
		dto.setPositionCode(rs.getString(NUM_POSITION_CODE)); // 職位コード
		dto.setEntranceDate(rs.getInt(NUM_ENTRANCE_DATE)); // 入社日
		dto.setRetirementDate(rs.getInt(NUM_RETIREMENT_DATE)); // 退社日
		
		dto.setIncExpectedDate(rs.getDate(NUM_INC_EXPECTED_DATE)); // 所得税適用年
		dto.setIncomeTaxType(rs.getString(NUM_INCOME_TAX_TYPE)); // 課税区分
		dto.setAdjustmentType(rs.getString(NUM_ADJUSTMENT_TYPE)); // 年末調整区分
		dto.setSelfWidowType(rs.getString(NUM_SELF_WIDOW_TYPE)); // 本人寡婦区分
		dto.setSelfHandicapType(rs.getString(NUM_SELF_HANDICAP_TYPE)); // 本人障害区分
		dto.setSelfStudentType(rs.getString(NUM_SELF_STUDENT_TYPE)); // 本人学生区分
		dto.setSpouseIntendType(rs.getString(NUM_SPOUSE_INTEND_TYPE)); // 配偶者区分
		dto.setGeneralDependent(rs.getInt(NUM_GENERAL_DEPENDENT)); // 一般扶養親族
		dto.setSpecificDependent(rs.getInt(NUM_SPECIFIC_DEPENDENT)); // 特定扶養親族
		dto.setElderlyDependent(rs.getInt(NUM_ELDERLY_DEPENDENT)); // 老人扶養親族
		dto.setLiveWithEldRel(rs.getInt(NUM_LIVE_WITH_ELD_REL)); // 同居老親等
		dto.setLiveWithHandiGe(rs.getInt(NUM_LIVE_WITH_HANDI_GE)); // 同居特障一般
		dto.setLiveWithHandiSp(rs.getInt(NUM_LIVE_WITH_HANDI_SP)); // 同居特障特定
		dto.setLiveWithHandiEl(rs.getInt(NUM_LIVE_WITH_HANDI_EL)); // 同居特障老人
		dto.setLiveWithHandiEr(rs.getInt(NUM_LIVE_WITH_HANDI_ER)); // 同居特障老親
		dto.setGeneralHandicap(rs.getInt(NUM_GENERAL_HANDICAP)); // 一般障害者
		dto.setSpecificHandicap(rs.getInt(NUM_SPECIFIC_HANDICAP)); // 特別障害者
		dto.setDependentCount(rs.getInt(NUM_DEPENDENT_COUNT)); // 扶養等の数
		
		dto.setMidwayType(rs.getString(NUM_MIDWAY_TYPE)); // 中途入社区分
		dto.setFormerIncome(rs.getInt(NUM_FORMER_INCOME)); // 前勤務先収入金額
		dto.setFormerInsurance(rs.getInt(NUM_FORMER_INSURANCE)); // 前勤務先社会保険額
		dto.setFormerTax(rs.getInt(NUM_FORMER_TAX)); // 前勤務先所得税額
		
		dto.setAdjustYear(rs.getInt(NUM_ADJUST_YEAR)); // 調整年
		dto.setAdjustStatus(rs.getString(NUM_ADJUST_STATUS)); // 年末調整計算状態
		dto.setGeneralLifeIns(rs.getInt(NUM_GENERAL_LIFE_INS)); // 一般の生命保険料
		dto.setPrivatePension(rs.getInt(NUM_PRIVATE_PENSION)); // 個人年金保険料
		dto.setLifeInsDeduction(rs.getInt(NUM_LIFE_INS_DEDUCTION)); // 生命保険料控除額
		dto.setEarthquakeIns(rs.getInt(NUM_EARTHQUAKE_INS)); // 地震保険料
		dto.setLongTermDamageIns(rs.getInt(NUM_LONG_TERM_DAMAGE_INS)); // 旧長期損害保険料
		dto.setDamageInsDeduction(rs.getInt(NUM_DAMAGE_INS_DEDUCTION)); // 損害保険料控除額
		dto.setSocialInsDeduction(rs.getInt(NUM_SOCIAL_INS_DEDUCTION)); // 社会保険料控除額
		dto.setMutualAidDeduction(rs.getInt(NUM_MUTUAL_AID_DEDUCTION)); // 小規模企業共済等掛金控除額
		dto.setSpouseSumIncome(rs.getInt(NUM_SPOUSE_SUM_INCOME)); // 配偶者の本年中の合計所得金額の見積額
		dto.setSpouseSpDeduction(rs.getInt(NUM_SPOUSE_SP_DEDUCTION)); // 配偶者特別控除額
		dto.setHouseLoanDeduction(rs.getInt(NUM_HOUSE_LOAN_DEDUCTION)); // 住宅借入金等特別控除額
		dto.setAllowanceAdjustment(rs.getInt(NUM_ALLOWANCE_ADJUSTMENT)); // 支給調整額
		dto.setTaxFreeAdjustment(rs.getInt(NUM_TAX_FREE_ADJUSTMENT)); // 非課税調整額
		dto.setSocInsAdjustment(rs.getInt(NUM_SOC_INS_ADJUSTMENT)); // 社会保険調整額
		dto.setTaxIncAdjustment(rs.getInt(NUM_TAX_INC_ADJUSTMENT)); // 所得税調整額
		dto.setWithholdSlipNotes(rs.getString(NUM_WITHHOLD_SLIP_NOTES)); // 源泉徴収票摘要欄
		dto.setPaymentAllowance(rs.getInt(NUM_PAYMENT_ALLOWANCE)); // 給与、手当等金額
		dto.setPaymentIncomeTax(rs.getInt(NUM_PAYMENT_INCOME_TAX)); // 給与、手当等税額
		dto.setBonusAllowance(rs.getInt(NUM_BONUS_ALLOWANCE)); // 賞与等金額
		dto.setBonusIncomeTax(rs.getInt(NUM_BONUS_INCOME_TAX)); // 賞与等税額
		dto.setMidwayAdjustIncome(rs.getInt(NUM_MIDWAY_ADJUST_INCOME)); // 中途、調整収入金額
		dto.setMidwayAdjustTax(rs.getInt(NUM_MIDWAY_ADJUST_TAX)); // 中途、調整収入税額
		dto.setAfterDeductIncome(rs.getInt(NUM_AFTER_DEDUCT_INCOME)); // 給与所得控除後の給与等の金額
		dto.setPayInsDeduction(rs.getInt(NUM_PAY_INS_DEDUCTION)); // 社会保険料等給与等からの控除分
		dto.setDependentsDeduction(rs.getInt(NUM_DEPENDENTS_DEDUCTION)); // 配偶者控除額、扶養控除額、基礎控除額及び障害者等の控除額の合計額
		dto.setCalcTaxedIncome(rs.getInt(NUM_CALC_TAXED_INCOME)); // 差引課税給与所得金額
		dto.setCalcIncomeTax(rs.getInt(NUM_CALC_INCOME_TAX)); // 算出年税額
		dto.setAdjustedIncomeTax(rs.getInt(NUM_ADJUSTED_INCOME_TAX)); // 年調年税額
		dto.setDeductedIncomeTax(rs.getInt(NUM_DEDUCTED_INCOME_TAX)); // 年調定率控除額税額
		dto.setFinalIncomeTax(rs.getInt(NUM_FINAL_INCOME_TAX)); // 年税額
		
		return dto;
	}
	
	/**
	 * 条件文による年末調整データ取得
	 * @param adjustYear 調整年
	 * @param lastDate 調整年最終日
	 * @param kCode 社員コード
	 * @param kName 社員名
	 * @param kKana 社員ﾌﾘｶﾞﾅ
	 * @param retirementFlag 
	 * @param positionCode 
	 * @param adjustmentType 
	 * @param midwayType 
	 * @param adjustStatus 
	 * @return List 検索結果(DTOのList)
	 * @throws IllegalAccessException メソッドにアクセスできない場合
	 * @throws SQLException SQL例外が発生した場合
	 */
	public List<AdjustmentDto> findForCondition(int adjustYear, Date lastDate, String kCode, String kName,
			String kKana, String retirementFlag, String positionCode, String adjustmentType, String midwayType,
			String adjustStatus) throws IllegalAccessException, SQLException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		sb.append(COL_K_CODE_KIHON + " LIKE ? ");
		sb.append("AND ");
		sb.append(COL_K_NAME + " LIKE ? ");
		sb.append("AND ");
		sb.append(COL_K_KANA + " LIKE ? ");
		if (retirementFlag != null && retirementFlag.equals(String.valueOf(PayrollConst.RETIREMENT_FLAG_ON))) {
			sb.append("AND ");
			sb.append(COL_RETIREMENT_DATE + " <= ? ");
		} else if (retirementFlag != null && retirementFlag.equals(String.valueOf(PayrollConst.RETIREMENT_FLAG_OFF))) {
			sb.append("AND ");
			sb.append("( ");
			sb.append(COL_RETIREMENT_DATE + " = 0 ");
			sb.append("OR ");
			sb.append(COL_RETIREMENT_DATE + " > ? ");
			sb.append(") ");
		}
		if (positionCode != null && !positionCode.equals("")) {
			sb.append("AND ");
			sb.append(COL_POSITION_CODE + " = ? ");
		}
		if (adjustmentType != null && !adjustmentType.equals("")) {
			sb.append("AND ");
			sb.append(COL_ADJUSTMENT_TYPE + " = ? ");
		}
		if (midwayType != null && !midwayType.equals("")) {
			sb.append("AND ");
			sb.append(COL_MIDWAY_TYPE + " = ? ");
		}
		if (adjustStatus != null && adjustStatus.equals(PayrollConst.ADJU_STATUS_NON)) {
			sb.append("AND ");
			sb.append(COL_ADJUST_STATUS + " IS NULL ");
		} else if (adjustStatus != null && !adjustStatus.equals("")) {
			sb.append("AND ");
			sb.append(COL_ADJUST_STATUS + " = ? ");
		}
		try {
			prepareStatement(getSelectStatement(getClass()) + getAdjustmentTable() + sb.toString());
			setParam(index++, DateUtil.convDateToInteger(lastDate));
			setParam(index++, lastDate);
			setParam(index++, adjustYear);
			setParam(index++, "%" + kCode + "%");
			setParam(index++, "%" + kName + "%");
			setParam(index++, "%" + kKana + "%");
			if (retirementFlag != null && !retirementFlag.equals("")) {
				setParam(index++, DateUtil.convDateToInteger(lastDate));
			}
			if (positionCode != null && !positionCode.equals("")) {
				setParam(index++, positionCode);
			}
			if (adjustmentType != null && !adjustmentType.equals("")) {
				setParam(index++, adjustmentType);
			}
			if (midwayType != null && !midwayType.equals("")) {
				setParam(index++, midwayType);
			}
			if (adjustStatus != null && !adjustStatus.equals("") && !adjustStatus.equals(PayrollConst.ADJU_STATUS_NON)) {
				setParam(index++, adjustStatus);
			}
			executeQuery();
			return mappingAll();
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 条件文による年末調整データ取得
	 * @param adjustDate 調整年
	 * @param endDate    調整年最終日
	 * @param kCode      社員コード
	 * @return List 検索結果(DTOのList)
	 * @throws IllegalAccessException  メソッドにアクセスできない場合
	 * @throws SQLException SQL例外が発生した場合
	 */
	public AdjustmentDto findForEmployee(Date adjustDate, Date endDate, String kCode) throws IllegalAccessException,
			SQLException {
		index = 1;
		StringBuffer sb = new StringBuffer();
		sb.append("WHERE ");
		sb.append(COL_K_CODE_KIHON + " = ? ");
		try {
			prepareStatement(getSelectStatement(getClass()) + getAdjustmentTable() + sb.toString());
			setParam(index++, endDate);
			setParam(index++, adjustDate);
			setParam(index++, adjustDate);
			setParam(index++, kCode);
			executeQuery();
			AdjustmentDto dto = null;
			if (rs.next()) {
				dto = mapping();
			}
			return dto;
		} catch (SQLException e) {
			throw e;
		} finally {
			releaseResultSet();
			releasePreparedStatement();
		}
	}
	
	/**
	 * 年末調整データビューSQL取得
	 * @return 年末調整データビュー取得SQL文字列
	 * @throws IllegalAccessException メソッドにアクセスできない場合
	 */
	public String getAdjustmentTable() throws IllegalAccessException {
		MKihonPayrollDao kihonPayrollDao = new MKihonPayrollDao();
		CmIncomeTaxDao cmIncomeTaxDao = new CmIncomeTaxDao();
		CdAdjustmentDao cdAdjustmentDao = new CdAdjustmentDao();
		StringBuffer sb = new StringBuffer();
		sb.append(" ");
		sb.append("FROM ");
		sb.append("(");
		sb.append("(");
		sb.append("(");
		sb.append(kihonPayrollDao.getHistoryTable() + " ");
		sb.append("LEFT JOIN ");
		sb.append(cmIncomeTaxDao.getHistoryTableForDate() + " ");
		sb.append("ON " + COL_K_CODE_KIHON + " = " + COL_K_CODE_INC_TAX);
		sb.append(") ");
		sb.append("LEFT JOIN ");
		sb.append(CmMidwayEnterDao.TABLE + " ");
		sb.append("ON " + COL_K_CODE_KIHON + " = " + COL_K_CODE_MID_ENT);
		sb.append(") ");
		sb.append("LEFT JOIN ");
		sb.append(cdAdjustmentDao.getTableForDate() + " ");
		sb.append("ON " + COL_K_CODE_KIHON + " = " + COL_K_CODE_ADJUST);
		sb.append(") ");
		return sb.toString();
	}
	
}
