/*
 * 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.common.action;

import java.sql.SQLException;
import java.util.ArrayList;
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.common.utils.StringUtil;
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);
		}
	}
	
	@Override
	public 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(StringUtil.getCodeName(key1, vo.aryPltTable));
		vo.setMode(ImportMasterCardVo.MODE_INSERT);
	}
	
	@Override
	public 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);
	}
	
	@Override
	public 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);
	}
	
	@Override
	public 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 = StringUtil.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 tmoCount = 0;
		ArrayList<String> addList = 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();
			
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KCODE);
			addList.add(PayrollConst.DTL_SNEN);
			addList.add(PayrollConst.DTL_STUKI);
			addList.add(PayrollConst.DTL_SHI);
			
			for (DetailPaDto dto : detailPaDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailCode());
				}
			}
			
			for (DetailPbDto dto : detailPbDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailCode());
				}
			}
			
			for (DetailPdDto dto : detailPdDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailCode());
				}
			}
			
			for (DetailMoneyDto dto : detailPsDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailCode());
				}
			}
			
			for (DetailTimeDto dto : detailPtDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailCode());
					if (dto.getDetailCode().equals(PayrollConst.DTL_WARIMASI1)) {
						tmoCount = 1;
					}
				}
			}
			
			if (tmoCount == 0) {
				addList.add(PayrollConst.DTL_WARIMASI1);
			}
			aryImportFieldCode = paiLieToArrayList(addList);
			
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLE_M_SYUKKINBO)) {
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KCODE);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_HIZUKE);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SYJIKOKU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KINMU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SHANKYUKB);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KYUSYUKB);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_TIRIYUU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_TICOMENT);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_TISYOUMEI);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_TIJIKAN);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_TAJIKOKU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KINMUJI);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KYUKEIJI);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_THANKYUKB);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SORIYUU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SOCOMENT);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SOSYOUMEI);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SOJIKAN);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_ZAJIKAN);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KSJIKAN);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SNJIKAN);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SYOKJI);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_CYOKU1);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_CYOKU2);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_CYOKU3);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_HOKA1);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_HOKA2);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_HOKA3);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_HOKA4);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_HOKA5);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KKRIYUU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_DAIKYUJYU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KKCOMENT);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KKSYOUMEI);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KKJIKAN);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_NIJIKYU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_NZAJIKAN);
			aryImportFieldCode = paiLieToArrayList(addList);
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLCT_TIMECARD)) {
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KCODE);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_HIZUKE);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SYJIKOKU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_TAJIKOKU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KINMU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KKRIYUU);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_SHANKYUKB);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_THANKYUKB);
			addList.add(PayrollConst.CODE_IMPORT_FIELD_KYUSYUKB);
//			add_list.add( PayrollConst.CODE_IMPORT_FIELD_NIJIKYU );
//			add_list.add( PayrollConst.CODE_IMPORT_FIELD_NZAJIKAN );
			aryImportFieldCode = paiLieToArrayList(addList);
		}
		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> addList = 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();
			
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KCODE);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_DTL_SNEN);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_DTL_STUKI);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_DTL_DTL_SHI);
			
			for (DetailPaDto dto : detailPaDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailName());
				}
			}
			
			for (DetailPbDto dto : detailPbDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailName());
				}
			}
			
			for (DetailPdDto dto : detailPdDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailName());
				}
			}
			
			for (DetailMoneyDto dto : detailPsDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailName());
				}
			}
			
			for (DetailTimeDto dto : detailPtDto_lst) {
				if (dto.getInputType() == PayrollConst.DETAIL_IN_UPLOAD) {
					addList.add(dto.getDetailName());
				}
			}
			addList.add(PayrollConst.NAM_IMPORT_FIELD_NZAJIKAN);
			aryImportFieldName = paiLieToArrayList(addList);
			
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLE_M_SYUKKINBO)) {
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KCODE);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_HIZUKE);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SYJIKOKU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KINMU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SHANKYUKB);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KYUSYUKB);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_TIRIYUU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_TICOMENT);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_TISYOUMEI);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_TIJIKAN);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_TAJIKOKU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KINMUJI);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KYUKEIJI);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_THANKYUKB);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SORIYUU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SOCOMENT);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SOSYOUMEI);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SOJIKAN);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_ZAJIKAN);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KSJIKAN);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SNJIKAN);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SYOKJI);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_CYOKU1);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_CYOKU2);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_CYOKU3);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_HOKA1);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_HOKA2);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_HOKA3);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_HOKA4);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_HOKA5);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KKRIYUU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_DAIKYUJYU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KKCOMENT);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KKSYOUMEI);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KKJIKAN);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_NIJIKYU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_NZAJIKAN);
			
			aryImportFieldName = paiLieToArrayList(addList);
		} else if (table.equals(PayrollConst.CODE_IMPORT_TABLCT_TIMECARD)) {
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KCODE);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_HIZUKE);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SYJIKOKU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_TAJIKOKU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KINMU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KKRIYUU);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_SHANKYUKB);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_THANKYUKB);
			addList.add(PayrollConst.NAM_IMPORT_FIELD_KYUSYUKB);
//			add_list.add( PayrollConst.NAM_IMPORT_FIELD_NIJIKYU );
//			add_list.add( PayrollConst.NAM_IMPORT_FIELD_NZAJIKAN );
			aryImportFieldName = paiLieToArrayList(addList);
		}
		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 = list.toArray(new String[]{});
		return strs;
	}
	
}
