/*
 * MosP - Mind Open Source Project         http://www.mosp.jp/
 * Copyright (C) 1987-2009 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.common.action;

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

import jp.mosp.common.MosPAction;
import jp.mosp.common.common.BaseVo;
import jp.mosp.common.common.MospConst;
import jp.mosp.common.common.MospException;
import jp.mosp.common.common.MospUtility;
import jp.mosp.payroll.base.PayrollConst;
import jp.mosp.payroll.common.vo.ImportMasterCardVo;
import jp.mosp.payroll.dao.MImportDao;
import jp.mosp.payroll.dao.MImportFieldDao;
import jp.mosp.payroll.dao.PmDetailPaDao;
import jp.mosp.payroll.dao.PmDetailPbDao;
import jp.mosp.payroll.dao.PmDetailPdDao;
import jp.mosp.payroll.dao.PmDetailPsDao;
import jp.mosp.payroll.dao.PmDetailPtDao;
import jp.mosp.payroll.dto.DetailMoneyDto;
import jp.mosp.payroll.dto.DetailPaDto;
import jp.mosp.payroll.dto.DetailPbDto;
import jp.mosp.payroll.dto.DetailPdDto;
import jp.mosp.payroll.dto.DetailTimeDto;
import jp.mosp.payroll.dto.MImportDto;
import jp.mosp.payroll.dto.MImportFieldDto;

public class ImportMasterCardAction extends MosPAction {

	// コマンド
	private static final String CMD_IMPORT_MASTER_CARD_SHOW	= "P9030";	// 表示(追加)
	private static final String CMD_IMPORT_MASTER_CARD_SELECT	= "P9031";	// 表示(選択)
	private static final String CMD_IMPORT_MASTER_CARD_INSERT	= "P9032";	// 登録
	private static final String CMD_IMPORT_MASTER_CARD_UPDATE	= "P9033";	// 更新
	private static final String CMD_IMPORT_MASTER_CARD_DELETE	= "P9034";	// 削除

	public List<DetailPaDto>		detailPaDto_lst;
	public List<DetailPbDto>		detailPbDto_lst;
	public List<DetailPdDto>		detailPdDto_lst;
	public List<DetailMoneyDto>		detailPsDto_lst;
	public List<DetailTimeDto>		detailPtDto_lst;
	
	/**
	 * コンストラクタ
	 */
	public ImportMasterCardAction() {
		super();
	}

	/* (non-Javadoc)
	 * @see jp.mosp.common.common.BaseAction#getSpecificVo()
	 */
	@Override
	protected BaseVo getSpecificVo() {
		return new ImportMasterCardVo();
	}

	/**
	 * アクション
	 */
	public void action() throws Exception {
		// DBコネクション取得
		getConnection();
		// VO取得及び設定
		prepareVo();
		// コマンド毎の処理
		if (cmd.equals(CMD_IMPORT_MASTER_CARD_SHOW)) {
			show();
		} else if (cmd.equals(CMD_IMPORT_MASTER_CARD_SELECT)) {
			select();
		} else if (cmd.equals(CMD_IMPORT_MASTER_CARD_INSERT)) {
			insert();
		} else if (cmd.equals(CMD_IMPORT_MASTER_CARD_UPDATE)) {
			update();
		} else if (cmd.equals(CMD_IMPORT_MASTER_CARD_DELETE)) {
			delete();
		} else {
			throw new MospException(MospConst.EX_CMD_INVALID);
		}
	}

	private void show() throws SQLException, IllegalAccessException, NoSuchFieldException {
		setPulldown(key1);
		// VO取得
		ImportMasterCardVo vo = (ImportMasterCardVo)getVo();
		vo.setAryHidIField(getImportFieldCodeArray	(key1));
		vo.setAryLblIField(getImportFieldNameArray	(key1));
		vo.setAryPltIOrder(getImportFieldOrderArray	(key1));
		vo.setTxtICode("");
		vo.setTxtIName("");
		vo.setHidITable(key1);
		vo.setLblITable(util.getCodeName(key1, vo.aryPltTable));
		vo.setMode(ImportMasterCardVo.MODE_INSERT);
	}

	private void select() throws Exception {
		// DAOの準備
		MImportDao dao = new MImportDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		MImportFieldDao mImportFieldDao = new MImportFieldDao();
		mImportFieldDao.initDao(cfg, cmd, aspUser, user, conn);
		MImportDto dto = dao.findForKey(key1);
		chkExist(dto);
		setPulldown(dto.getITable());
		// VO取得
		ImportMasterCardVo vo = (ImportMasterCardVo)getVo();
		vo.setAryHidIField(getImportFieldCodeArray	(dto.getITable()));
		vo.setAryLblIField(getImportFieldNameArray	(dto.getITable()));
		vo.setAryPltIOrder(getImportFieldOrderArray	(dto.getITable()));
		// VOに情報をセット
		vo.setFields(dto);
		vo.setFields(mImportFieldDao.findForCondition(dto.getICode()));
		vo.setMode(ImportMasterCardVo.MODE_UPDATE);
		//セッションにDTOをセット
		session.setAttribute(MospConst.ATT_DTO, dto);
	}

	private void insert() throws Exception {
		// VO取得
		ImportMasterCardVo vo = (ImportMasterCardVo)getVo();
		vo.setParams(request);
		// パラメーターの妥当性確認
		vo.validate();
		// DAOの準備
		MImportDao dao = new MImportDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		// 存在チェック
		chkDuplicate(dao.findForKey(vo.getTxtICode()), vo);
		// DTOの準備
		MImportDto dto = new MImportDto();
		vo.setDtoFields(dto);
		// データの挿入
		dao.insert(dto);
		// DTOの再取得
		dto = dao.findForKey(dto.getICode());
		chkInsert(dto);
		// インポートフィールドの挿入
		insertImportField();
		// コミット
		commit();
		// モード設定
		vo.setMode(ImportMasterCardVo.MODE_UPDATE);
		// メッセージ設定
		vo.setMessage(MospUtility.getMessage(msg, MospConst.MSG_INSERT, ""));
		// セッションにDTOをセット
		session.setAttribute(MospConst.ATT_DTO, dto);
	}

	private void update() throws Exception {
		// VO取得
		ImportMasterCardVo vo = (ImportMasterCardVo)getVo();
		vo.setParams(request);
		//パラメーターの妥当性確認
		vo.validate();
		// DAOの準備
		MImportDao dao = new MImportDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		// DTOの取得
		MImportDto dto;
		Object obj = session.getAttribute(MospConst.ATT_DTO);
		dto = obj instanceof MImportDto ? (MImportDto)obj : null;
		// 排他確認
		chkExclusive(dto, dao.findForUpdate(vo.getTxtICode()), vo);
		// DTOの準備
		vo.setDtoFields(dto);
		// データの更新
		dao.update(dto);
		// DTOの再取得
		MImportDto retDto = dao.findForKey(dto.getICode());
		chkUpdate(retDto);
		// インポートフィールドの挿入
		insertImportField();
		// コミット
		commit();
		// モード設定
		vo.setMode(ImportMasterCardVo.MODE_UPDATE);
		// メッセージ設定
		vo.setMessage(MospUtility.getMessage(msg, MospConst.MSG_UPDATE, ""));
		// セッションにDTOをセット
		session.setAttribute(MospConst.ATT_DTO, retDto);
	}

	private void delete() throws Exception {
		// DAOの準備
		MImportDao dao = new MImportDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		// DTOの取得
		MImportDto dto;
		Object obj = session.getAttribute(MospConst.ATT_DTO);
		dto = obj instanceof MImportDto ? (MImportDto)obj : null;
		// データの更新
		dao.delete(dto);
		// インポートフィールドの削除
		deleteImportField(dto.getICode());
		// コミット
		commit();
		// VO取得
		ImportMasterCardVo vo = (ImportMasterCardVo)getVo();
		// モード設定
		vo.setMode(ImportMasterCardVo.MODE_INSERT);
		// メッセージ設定
		vo.setMessage(MospUtility.getMessage(msg, MospConst.MSG_DELETE, ""));
		// セッションにDTOをセット
		session.setAttribute(MospConst.ATT_DTO, dto);
	}

	private void insertImportField() throws Exception {
		// VO取得
		ImportMasterCardVo vo = (ImportMasterCardVo)getVo();
		// 削除
		deleteImportField(vo.getTxtICode());
		// DAOの準備
		MImportFieldDao dao = new MImportFieldDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		// DTOの準備
		MImportFieldDto dto = new MImportFieldDto();
		String[] importFieldOrder = vo.getAryPltIOrder();
		for (int i = 0; i < importFieldOrder.length; i++) {
			if (!importFieldOrder[i].equals("")) {
				vo.setDtoFields(dto, i);
				// データの挿入
				dao.insert(dto);
				// DTOの再取得
				dto = dao.findForKey(dto.getICode(), dto.getIField());
				chkInsert(dto);
			}
		}
	}

	private void deleteImportField(String icode) throws Exception {
		// DAOの準備
		MImportFieldDao dao = new MImportFieldDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		// データの更新
		dao.delete(icode, dao.findForCondition(icode).size());
	}

	private void setPulldown(String table) throws SQLException, IllegalAccessException, NoSuchFieldException {
		// VO取得
		ImportMasterCardVo vo = (ImportMasterCardVo)getVo();
		vo.aryPltTable = getImportTableArray();
		vo.aryPltOrder = util.getCountArray(1, getImportFieldCodeArray(table).length, 1);
	}

	/**
	 * インポートフィールドコード取得
	 * @param table インポートテーブル
	 * @return インポートフィールドコード用文字列配列
	 * @throws NoSuchFieldException 
	 * @throws IllegalAccessException 
	 * @throws SQLException 
	 */
	private String[] getImportFieldCodeArray(String table) throws SQLException, IllegalAccessException, NoSuchFieldException {
		String[] aryImportFieldCode = new String[0];
        int tmo_count = 0;
		ArrayList<String> add_list = new ArrayList<String>();
		if (table.equals(PayrollConst.CODE_IMPORT_TABLE_PI_PAYMENT)) {
			
			// DAOの準備
			PmDetailPaDao pmDetailPaDao = new PmDetailPaDao(cfg, cmd, aspUser, user, conn);
			PmDetailPbDao pmDetailPbDao = new PmDetailPbDao(cfg, cmd, aspUser, user, conn);
			PmDetailPdDao pmDetailPdDao = new PmDetailPdDao(cfg, cmd, aspUser, user, conn);
			PmDetailPsDao pmDetailPsDao = new PmDetailPsDao(cfg, cmd, aspUser, user, conn);
			PmDetailPtDao pmDetailPtDao = new PmDetailPtDao(cfg, cmd, aspUser, user, conn);
			detailPaDto_lst = pmDetailPaDao.findNotDelete();
			detailPbDto_lst = pmDetailPbDao.findNotDelete();
			detailPdDto_lst = pmDetailPdDao.findNotDelete();
			detailPsDto_lst = pmDetailPsDao.findNotDelete();
			detailPtDto_lst = pmDetailPtDao.findNotDelete();

			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KCODE );
			add_list.add( PayrollConst.DTL_SNEN );
			add_list.add( PayrollConst.DTL_STUKI );
			add_list.add( PayrollConst.DTL_SHI );
			
			for (Iterator<DetailPaDto> it = detailPaDto_lst.iterator(); it.hasNext();) {
				DetailPaDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailCode());
				}
			}

			for (Iterator<DetailPbDto> it = detailPbDto_lst.iterator(); it.hasNext();) {
				DetailPbDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailCode());
				}
			}

			for (Iterator<DetailPdDto> it = detailPdDto_lst.iterator(); it.hasNext();) {
				DetailPdDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailCode());
				}
			}
			
			for (Iterator<DetailMoneyDto> it = detailPsDto_lst.iterator(); it.hasNext();) {
				DetailMoneyDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailCode());
				}
			}

			for (Iterator<DetailTimeDto> it = detailPtDto_lst.iterator(); it.hasNext();) {
				DetailTimeDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailCode());
					if(dto.getDetailCode().equals( PayrollConst.DTL_WARIMASI1 )){
						tmo_count = 1;
					}
				}
			}

			if(tmo_count == 0){
				add_list.add(PayrollConst.DTL_WARIMASI1);
			}
			aryImportFieldCode = paiLieToArrayList( add_list );
			
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLE_M_SYUKKINBO)) {
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KCODE );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_HIZUKE );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SYJIKOKU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KINMU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SHANKYUKB );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KYUSYUKB );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_TIRIYUU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_TICOMENT );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_TISYOUMEI );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_TIJIKAN );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_TAJIKOKU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KINMUJI );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KYUKEIJI );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_THANKYUKB );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SORIYUU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SOCOMENT );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SOSYOUMEI );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SOJIKAN );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_ZAJIKAN );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KSJIKAN );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SNJIKAN );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SYOKJI );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_CYOKU1 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_CYOKU2 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_CYOKU3 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_HOKA1 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_HOKA2 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_HOKA3 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_HOKA4 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_HOKA5 );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KKRIYUU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_DAIKYUJYU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KKCOMENT );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KKSYOUMEI );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KKJIKAN );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_NIJIKYU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_NZAJIKAN );
			aryImportFieldCode = paiLieToArrayList( add_list );
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLCT_TIMECARD)) {
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KCODE );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_HIZUKE );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SYJIKOKU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_TAJIKOKU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KINMU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KKRIYUU );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_SHANKYUKB );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_THANKYUKB );
			add_list.add( PayrollConst.CODE_IMPORT_FIELD_KYUSYUKB );
//			add_list.add( PayrollConst.CODE_IMPORT_FIELD_NIJIKYU );
//			add_list.add( PayrollConst.CODE_IMPORT_FIELD_NZAJIKAN );
			aryImportFieldCode = paiLieToArrayList( add_list );
		}
		return aryImportFieldCode;
	}

	/**
	 * インポートフィールド名称取得
	 * @param table インポートテーブル
	 * @return インポートフィールド名称用文字列配列
	 * @throws NoSuchFieldException 
	 * @throws IllegalAccessException 
	 * @throws SQLException 
	 */
	private String[] getImportFieldNameArray(String table) throws SQLException, IllegalAccessException, NoSuchFieldException {
		String[] aryImportFieldName	= new String[0];
		ArrayList<String> add_list = new ArrayList<String>();

		if (table.equals(PayrollConst.CODE_IMPORT_TABLE_PI_PAYMENT)) {
			// DAOの準備
			PmDetailPaDao pmDetailPaDao = new PmDetailPaDao(cfg, cmd, aspUser, user, conn);
			PmDetailPbDao pmDetailPbDao = new PmDetailPbDao(cfg, cmd, aspUser, user, conn);
			PmDetailPdDao pmDetailPdDao = new PmDetailPdDao(cfg, cmd, aspUser, user, conn);
			PmDetailPsDao pmDetailPsDao = new PmDetailPsDao(cfg, cmd, aspUser, user, conn);
			PmDetailPtDao pmDetailPtDao = new PmDetailPtDao(cfg, cmd, aspUser, user, conn);
			
			detailPaDto_lst = pmDetailPaDao.findNotDelete();
			detailPbDto_lst = pmDetailPbDao.findNotDelete();
			detailPdDto_lst = pmDetailPdDao.findNotDelete();
			detailPsDto_lst = pmDetailPsDao.findNotDelete();
			detailPtDto_lst = pmDetailPtDao.findNotDelete();

			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KCODE );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_DTL_SNEN );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_DTL_STUKI );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_DTL_DTL_SHI );
			
			for (Iterator<DetailPaDto> it = detailPaDto_lst.iterator(); it.hasNext();) {
				DetailPaDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailName());
				}
			}

			for (Iterator<DetailPbDto> it = detailPbDto_lst.iterator(); it.hasNext();) {
				DetailPbDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailName());
				}
			}

			for (Iterator<DetailPdDto> it = detailPdDto_lst.iterator(); it.hasNext();) {
				DetailPdDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailName());
				}
			}
			
			for (Iterator<DetailMoneyDto> it = detailPsDto_lst.iterator(); it.hasNext();) {
				DetailMoneyDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailName());
				}
			}

			for (Iterator<DetailTimeDto> it = detailPtDto_lst.iterator(); it.hasNext();) {
				DetailTimeDto dto = it.next();
				if( dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD ){
					add_list.add(dto.getDetailName());
				}
			}
			add_list.add(PayrollConst.NAM_IMPORT_FIELD_NZAJIKAN);
			aryImportFieldName = paiLieToArrayList( add_list );
		    
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLE_M_SYUKKINBO)) {
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KCODE );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_HIZUKE );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SYJIKOKU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KINMU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SHANKYUKB );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KYUSYUKB );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_TIRIYUU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_TICOMENT );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_TISYOUMEI );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_TIJIKAN );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_TAJIKOKU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KINMUJI );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KYUKEIJI );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_THANKYUKB );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SORIYUU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SOCOMENT );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SOSYOUMEI );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SOJIKAN );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_ZAJIKAN );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KSJIKAN );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SNJIKAN );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SYOKJI );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_CYOKU1 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_CYOKU2 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_CYOKU3 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_HOKA1 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_HOKA2 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_HOKA3 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_HOKA4 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_HOKA5 );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KKRIYUU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_DAIKYUJYU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KKCOMENT );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KKSYOUMEI );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KKJIKAN );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_NIJIKYU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_NZAJIKAN );

			aryImportFieldName = paiLieToArrayList( add_list );
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLCT_TIMECARD)) {
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KCODE );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_HIZUKE );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SYJIKOKU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_TAJIKOKU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KINMU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KKRIYUU );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_SHANKYUKB );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_THANKYUKB );
			add_list.add( PayrollConst.NAM_IMPORT_FIELD_KYUSYUKB );
//			add_list.add( PayrollConst.NAM_IMPORT_FIELD_NIJIKYU );
//			add_list.add( PayrollConst.NAM_IMPORT_FIELD_NZAJIKAN );
			aryImportFieldName = paiLieToArrayList( add_list );
		}
		return aryImportFieldName;
	}

	private String[] getImportFieldOrderArray(String table) throws SQLException, IllegalAccessException, NoSuchFieldException {
		return new String[getImportFieldCodeArray(table).length];
	}

	/**
	 * インポートテーブルプルダウン取得
	 * @return インポートテーブルプルダウン用文字列配列
	 */
	protected String[][] getImportTableArray() {
		String[][] aryImportTable = new String[3][2];
		aryImportTable[0][0] = PayrollConst.CODE_IMPORT_TABLE_PI_PAYMENT;
		aryImportTable[0][1] = PayrollConst.NAM_IMPORT_TABLE_PI_PAYMENT;
		aryImportTable[1][0] = PayrollConst.CODE_IMPORT_TABLE_M_SYUKKINBO;
		aryImportTable[1][1] = PayrollConst.NAM_IMPORT_TABLE_M_SYUKKINBO;
		aryImportTable[2][0] = PayrollConst.CODE_IMPORT_TABLCT_TIMECARD;
		aryImportTable[2][1] = PayrollConst.NAM_IMPORT_TABLCT_TIMECARD;
		return aryImportTable;
	}
	
	  /**
	  * StringのListをString配列に変換
	  * @param List リスト
	  * @return Stringの配列
	  */
	  public static String[] paiLieToArrayList(List<String> list){
	    String[] strs = (String[])list.toArray(new String[]{});
	    return strs;
	  }


}
