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

import java.util.Date;
import java.util.List;

import jp.mosp.common.bean.OdsBean;
import jp.mosp.common.common.MospConst;
import jp.mosp.common.common.MospException;
import jp.mosp.common.common.MospUtility;
import jp.mosp.common.common.PoiUtility;
import jp.mosp.common.dto.MosPConfDto;
import jp.mosp.common.part.DatePart;
import jp.mosp.payroll.base.AdjustmentAction;
import jp.mosp.payroll.base.PayrollConst;
import jp.mosp.payroll.common.vo.InsuranceConfSetVo;
import jp.mosp.payroll.dao.CdSocInsuranceDao;
import jp.mosp.payroll.dao.CmCompanyDao;
import jp.mosp.payroll.dto.CdSocInsuranceDto;
import jp.mosp.payroll.dto.CmCompanyDto;
public class InsuranceRepAction extends AdjustmentAction{
	
	
	// コマンド
	private static final String CMD_INSURANCEREP_LIST_ALL = "P4010";
	private static final String CMD_INSURANCEREP_LIST_ONE = "P4011";
	private static final String CMD_INSURANCEREP_LIST_ALL2= "P4012";
	
	private	int		nowYear = 0;			// 今年度計算用
	private	String	strTekiyouDate	=	"";	// 適用日付（年・月）
	private	Date    nowDateTmp;				//本日日付(Date型)
	private	String  nowDateJp;				//本日日付(和暦)

	private CmCompanyDao cmCompanyDao;
	private CmCompanyDto cmCompanyDto;
	
	public String[][] aryGender  ;
	// 設定テーブル
	public List<MosPConfDto> listConf;
	public String[][] aryEra;
	public String[][] aryStation ;
	
	
	/**
	 * コンストラクタ
	 */
	public InsuranceRepAction() {
		super();
		setNeedProcSeq(false);
	}
	
	/**
	 * アクション
	 */
	public void action() throws Exception {
		InsuranceConfSetVo	confVo;
		Date	dateTekiyouDate	=	null;								// 適用日付（年・月・日）
		int intCalcDate   = 0;
		int intCalcDate_s = 0;

		// DBコネクション取得
		getConnection();
		// DAO準備
		prepareDao();
		// 配列取得
		aryStation  = getStationArrayAll() ;
		aryPosition = getPositionArrayAll();
		aryEra      = getCodeArray(PayrollConst.TID_JAPANESE);

		//条件設定voの取得
		confVo	=	(InsuranceConfSetVo)getStoredVo(PayrollConst.VO_INSURANCECONF_SET); // 算定・月変条件設定VOの取得
		
		// 和暦設定取得
		listConf = getConfList(PayrollConst.CONF_ID_JP_IMP_CAL);

		nowDateTmp = getSystemDate();					//本日日付を取得
		nowYear	=	MospUtility.getYear(nowDateTmp);	//今年を取得

		//和暦本日日付を取得
		nowDateJp = getJapaneseDate( nowDateTmp);

		//適用月（年月）を取得設定
		if(confVo.idButtonSyori.equals(InsuranceConfSetVo.PRM_CKR_SANTEI_KISO)){	//算定基礎指定の場合
			intCalcDate = (nowYear * 10000) + (PayrollConst.MONTH_TEKIYOU_DEFAULT * 100) + PayrollConst.TIME_DEFAULT_DAY;
			intCalcDate_s = (nowYear * 100) + PayrollConst.MONTH_TEKIYOU_DEFAULT ;
		}else{
			if((confVo.prmSyoukyuTuki == null) || (confVo.prmSyoukyuTuki.equals("0"))){
				intCalcDate   = (nowYear * 10000) + (PayrollConst.MONTH_TEKIYOU_DEFAULT * 100) + PayrollConst.TIME_DEFAULT_DAY;
				intCalcDate_s = (nowYear * 100)   +  PayrollConst.MONTH_TEKIYOU_DEFAULT;
			}else{
				intCalcDate   = (nowYear * 10000) + ((Integer.valueOf(confVo.prmSyoukyuTuki) + 3 ) * 100 ) + PayrollConst.TIME_DEFAULT_DAY;
				intCalcDate_s = (nowYear * 100)   +  (Integer.valueOf(confVo.prmSyoukyuTuki) + 3 );
			}
		}
		dateTekiyouDate = DatePart.convIntegerDateToDate(intCalcDate);
		strTekiyouDate = String.valueOf(intCalcDate_s);			

		// 会社情報取得
		cmCompanyDao = new CmCompanyDao();
		cmCompanyDao.initDao(cfg, cmd, aspUser, user, conn);
		cmCompanyDto = cmCompanyDao.findAll();
		
		if (cmd.equals(CMD_INSURANCEREP_LIST_ALL)) {
			startAdjDate = getStartDateOfYear(adjustYear);
			lastDate     = getLastDateOfYear(adjustYear);
			CdSocInsuranceDao cdSocInsuranceDao = new CdSocInsuranceDao();
			cdSocInsuranceDao.initDao(cfg, cmd, aspUser, user, conn);
				
			// 給与明細データ作成
			List<CdSocInsuranceDto> list = cdSocInsuranceDao.findForCondition( dateTekiyouDate );
			// 帳票作成準備
			if (cfg.getProperty(PayrollConst.PPT_PAY_USEXLS) == null) {
				report(confVo, list);
			} else {
				reportXls(confVo, list);
			}
			
		} else if (cmd.equals(CMD_INSURANCEREP_LIST_ONE)) {
			// VOの取得
		} else if (cmd.equals(CMD_INSURANCEREP_LIST_ALL2)) {
			// VOの取得
		} else {
			throw new MospException(MospConst.EX_CMD_INVALID);	
		}
	}

	/**
	 * 帳票出力処理を行う。(Excel)<br><br>
	 * @throws Exception 
	 */
	private void reportXls(InsuranceConfSetVo vo , List<CdSocInsuranceDto> list ) throws Exception {

		CdSocInsuranceDto	cdSocInsuranceDto;
		
		String tmpTitleSei   = "";	
		String tmpTitleFuk   = "";	
		String tmpRepCode    = "";	
		String tmpWork       = "";	
		int Line;
		int Column;
		int Sum_sheet;
		int Sum_cnt;
		int tmpDate;

		int lK_name						= 14;	// 行：社員氏名
		int cK_name						=  7;	// 欄：社員氏名
		int lHhealth_no					= 14;	// 行：健康保険番号
		int cHhealth_no					=  2;	// 欄：健康保険番号
		int lBerthdayJpCd				= 14;	// 行：元号コード
		int cBerthdayJpCd				= 15;	// 欄：元号コード
		int lBerthdayY					= 14;	// 行：誕生年
		int cBerthdayY					= 17;	// 欄：誕生年
		int lBerthdayM					= 14;	// 行：誕生月
		int cBerthdaym					= 19;	// 欄：誕生月
		int lBerthdayD					= 14;	// 行：誕生日
		int cBerthdayD					= 21;	// 欄：誕生日
		int lGender						= 14;	// 行：性別コード
		int cGender						= 23;	// 欄：性別コード
		int lHealth_bef_premium			= 14;	// 行：健保従前保険料
		int cHealth_bef_premium			= 25;	// 欄：健保従前保険料
		int lPension_bef_premium		= 14;	// 行：厚年従前保険料
		int cPension_bef_premium		= 32;	// 欄：厚年従前保険料

		int lPay_basic_month1			= 20;	// 行：支払基礎日数1(月)
		int cPay_basic_month1			=  1;	// 欄：支払基礎日数1(月)
		int lPay_basic_month2			= 18;	// 行：支払基礎日数2(月)
		int cPay_basic_month2			=  1;	// 欄：支払基礎日数2(月)
		int lPay_basic_month3			= 16;	// 行：支払基礎日数3(月)
		int cPay_basic_month3			=  1;	// 欄：支払基礎日数3(月)

		int lPay_basic_day1				= 20;	// 行：支払基礎日数1(日)
		int cPay_basic_day1				=  3;	// 欄：支払基礎日数1(日)
		int lPay_basic_day2				= 18;	// 行：支払基礎日数2(日)
		int cPay_basic_day2				=  3;	// 欄：支払基礎日数2(日)
		int lPay_basic_day3				= 16;	// 行：支払基礎日数3(日)
		int cPay_basic_day3				=  3;	// 欄：支払基礎日数3(日)

		int lPay_amount1				= 20;	// 行：金銭の額1
		int cPay_amount1				=  6;	// 欄：金銭の額1
		int lPay_amount2				= 18;	// 行：金銭の額2
		int cPay_amount2				=  6;	// 欄：金銭の額2
		int lPay_amount3				= 16;	// 行：金銭の額3
		int cPay_amount3				=  6;	// 欄：金銭の額3

		int lGoods_amount1				= 20;	// 行：現物の額1
		int cGoods_amount1				= 12;	// 欄：現物の額1
		int lGoods_amount2				= 18;	// 行：現物の額2
		int cGoods_amount2				= 12;	// 欄：現物の額2
		int lGoods_amount3				= 16;	// 行：現物の額3
		int cGoods_amount3				= 12;	// 欄：現物の額3

		int lReward_total1				= 20;	// 行：報酬合計1
		int cReward_total1				= 19;	// 欄：報酬合計1
		int lReward_total2				= 18;	// 行：報酬合計2
		int cReward_total2				= 19;	// 欄：報酬合計2
		int lReward_total3				= 16;	// 行：報酬合計3
		int cReward_total3				= 19;	// 欄：報酬合計3
		
		int lReward_total_sum			= 16;	// 行：報酬総額
		int cReward_total_sum			= 25;	// 欄：報酬総額
		int lAverage_three_months		= 18;	// 行：３ヶ月平均
		int cAverage_three_months		= 25;	// 欄：３ヶ月平均
		int lHealth_dec_premium			= 20;	// 行：健保決定保険料
		int cHealth_dec_premium			= 25;	// 欄：健保決定保険料
		int lExpected_dateY				= 16;	// 行：適用年月:年
		int cExpected_dateY				= 32;	// 欄：適用年月:年
		int lExpected_dateM				= 16;	// 行：適用年月:月
		int cExpected_dateM				= 34;	// 欄：適用年月:月
		int lEdit_average				= 18;	// 行：修正平均
		int cEdit_average				= 32;	// 欄：修正平均
		int lPension_dec_premium		= 20;	// 行：厚年決定保険料
		int cPension_dec_premium		= 32;	// 欄：厚年決定保険料
		int lRetroactive_payment		= 16;	// 行：遡及支払額
		int cRetroactive_payment		= 39;	// 欄：遡及支払額
		int lRaise_down_salary_basis	= 17;	// 行：昇降給差の月額
		int cRaise_down_salary_basis	= 39;	// 欄：昇降給差の月額
		int lRaise_down_salary_date		= 18;	// 行：昇降給年月
		int cRaise_down_salary_date		= 39;	// 欄：昇降給年月
		
		
		
		// コネクション取得
		getConnection();

		if(null == cmCompanyDto){ // 会社情報未取得
			throw new MospException(MospConst.EX_CM_USER_ILLEGAL);	
		}

		// ヘッダータイトル＆届出コードの取得
		if(vo.idButtonSyori.equals(InsuranceConfSetVo.PRM_CKR_SANTEI_KISO)){ //「算定基礎」指定の場合
			tmpTitleSei   = PayrollConst.TTL_REP_SANTEI_SEI;	
			tmpTitleFuk   = PayrollConst.TTL_REP_SANTEI_FUKU;	
			tmpRepCode    = PayrollConst.TTL_REP_CODE_SANTEI;	
		}else{
			tmpTitleSei   = PayrollConst.TTL_REP_GEPPEN_SEI;	
			tmpTitleFuk   = PayrollConst.TTL_REP_GEPPEN_FUKU;	
			tmpRepCode    = PayrollConst.TTL_REP_CODE_GEPPEN;	
		}

		PoiUtility poi = new PoiUtility();
		poi.crtNewDocR(0, cfg.getProperty(MospConst.PPT_APP_DOCBASE) + PayrollConst.TEMPLATE_GEPPEN_XLS);

		// ヘッダー
		Line   =   2;
		Column =  12;
		poi.prtItem( Line      , Column     , tmpTitleSei);		// 書類タイトル（正）
		poi.prtItem( Line +  54, Column +  2, tmpTitleFuk);		// 書類タイトル（副）

		Line   =   4;
		Column =   0;
		poi.prtItem( Line      , Column     , tmpRepCode);		// 届出コード

		Line   =   5;
		Column =   6;
		poi.prtItem( Line      , Column     , cmCompanyDto.getDisposeNo());		// 事業所整理番号（正）
		poi.prtItem( Line +  56, Column     , cmCompanyDto.getDisposeNo());		// 事業所整理番号（副）
		
		Line   =  48;
		Column =   6;
		poi.prtItem( Line      , Column     , PayrollConst.NAM_COMMON_POSTAL + cmCompanyDto.getCompanyPostal()); // 事業所郵便番号（正）
		poi.prtItem( Line +  56, Column     , PayrollConst.NAM_COMMON_POSTAL + cmCompanyDto.getCompanyPostal()); // 事業所郵便番号（副）

		Line   =  49;
		Column =   6;
		poi.prtItem( Line      , Column     , cmCompanyDto.getCompanyAddress()); //事業所所在地（正）
		poi.prtItem( Line +  56, Column     , cmCompanyDto.getCompanyAddress()); //事業所所在地（副）
		

		Line   =  50;
		Column =   6;
		poi.prtItem( Line      , Column     , cmCompanyDto.getCompanyName());	 //事業所名称（正）
		poi.prtItem( Line +  56, Column     , cmCompanyDto.getCompanyName());	 //事業所名称（副）

		Line   =  51;
		Column =   6;
		poi.prtItem( Line      , Column     , cmCompanyDto.getEnterpreneur());	//事業主氏名（正）
		poi.prtItem( Line +  56, Column     , cmCompanyDto.getEnterpreneur());	//事業主氏名（副）

		Line   =  52;
		Column =   6;
		poi.prtItem( Line      , Column     , cmCompanyDto.getCompanyPhone());	//電話（正）
		poi.prtItem( Line +  56, Column     , cmCompanyDto.getCompanyPhone());	//電話（副）


		Line   =  46;
		Column =   8;
		poi.prtItem( Line      , Column     , nowDateJp);	//和暦本日日付（正）	
		poi.prtItem( Line +  59, Column + 21, nowDateJp);	//和暦本日日付（副）

		Sum_cnt   = 99;
		Sum_sheet = 0;
		
		for(int i = 0 ; i < list.size(); i++){
			if(Sum_cnt >= 4){
				Sum_sheet++;
//				poi.clnSheet(0, Sum_sheet, String.valueOf(Sum_sheet));  //シートの複製
//				poi.crtSheet(Sum_sheet, String.valueOf(Sum_sheet));     //空ソート作成
				Sum_cnt = 0;
			}

			cdSocInsuranceDto = list.get(i);
			kCode = cdSocInsuranceDto.getKCode();
			mKojinDto = mKojinDao.findForKey(kCode);	//人事マスタ個人情報インスタンス取得
			cmSocInsuranceDto = cmSocInsuranceDao.findForEmployee(kCode);	//人事マスタ社会保険部インスタンス取得		
			if((null != mKojinDto) && (null != cmSocInsuranceDto)){

				/**** ↓↓　各社員毎の項目設定  ↓↓****/
			
				// 健康保険番号(正)
				poi.prtItem( lHhealth_no   + (Sum_cnt * 8)     , cHhealth_no  ,	cmSocInsuranceDto.getHealthNo()+  "\n" + "(" +	cmSocInsuranceDto.getPensionNo() + ")");
				// 健康保険番号(副)
				poi.prtItem( lHhealth_no   + (Sum_cnt * 8) + 56, cHhealth_no  ,	cmSocInsuranceDto.getHealthNo() + "\n" + "(" +	cmSocInsuranceDto.getPensionNo() + ")");

				poi.prtItem( lK_name       + (Sum_cnt * 8)     , cK_name      , cdSocInsuranceDto.getKName());	// 社員氏名(正)
				poi.prtItem( lK_name       + (Sum_cnt * 8) + 56, cK_name      , cdSocInsuranceDto.getKName());	// 社員氏名(副)

				poi.prtItem( lBerthdayJpCd + (Sum_cnt * 8)     , cBerthdayJpCd, String.valueOf(getGengouCD(mKojinDto.getSeinenbi())));	// 元号コード(正)
				poi.prtItem( lBerthdayJpCd + (Sum_cnt * 8) + 56, cBerthdayJpCd, String.valueOf(getGengouCD(mKojinDto.getSeinenbi())));	// 元号コード(副)

				tmpDate = mKojinDto.getSeinenbi();
				String tmpM =  String.valueOf(MospUtility.getMonth(DatePart.convIntegerDateToDate(tmpDate)));
				String tmpD =  String.valueOf(MospUtility.getDay(DatePart.convIntegerDateToDate(tmpDate)));
				poi.prtItem( lBerthdayY    + (Sum_cnt * 8)     , cBerthdayY   , getWaNen(tmpDate));				// 誕生年(正)
				poi.prtItem( lBerthdayY    + (Sum_cnt * 8) + 56, cBerthdayY   , getWaNen(tmpDate));				// 誕生年(副)
				poi.prtItem( lBerthdayM    + (Sum_cnt * 8)     , cBerthdaym   , tmpM);							// 誕生月(正)
				poi.prtItem( lBerthdayM    + (Sum_cnt * 8) + 56, cBerthdaym   , tmpM);							// 誕生月(副)
				poi.prtItem( lBerthdayD    + (Sum_cnt * 8)     , cBerthdayD   , tmpD);							// 誕生日(正)
				poi.prtItem( lBerthdayD    + (Sum_cnt * 8) + 56, cBerthdayD   , tmpD);							// 誕生日(副)
				poi.prtItem( lGender       + (Sum_cnt * 8)     , cGender      , mKojinDto.getSeibetu());		// 性別コード(正)
				poi.prtItem( lGender       + (Sum_cnt * 8) + 56, cGender      , mKojinDto.getSeibetu());		// 性別コード(副)
				poi.prtItem( lHealth_bef_premium   + (Sum_cnt * 8)     , cHealth_bef_premium   , omission1000(cdSocInsuranceDto.getHealthBefPremium()));	// 健保従前保険料(正)
				poi.prtItem( lHealth_bef_premium   + (Sum_cnt * 8) + 56, cHealth_bef_premium   , omission1000(cdSocInsuranceDto.getHealthBefPremium()));	// 健保従前保険料(副)
				poi.prtItem( lPension_bef_premium  + (Sum_cnt * 8)     , cPension_bef_premium  , omission1000(cdSocInsuranceDto.getPensionBefPremium()));	// 厚年従前保険料(正)
				poi.prtItem( lPension_bef_premium  + (Sum_cnt * 8) + 56, cPension_bef_premium  , omission1000(cdSocInsuranceDto.getPensionBefPremium()));	// 厚年従前保険料(副)
				poi.prtItem( lPay_basic_month1     + (Sum_cnt * 8)     , cPay_basic_month1     , cdSocInsuranceDto.getPayBasicMonth1());	// 支払基礎日数1:月(正)
				poi.prtItem( lPay_basic_month1     + (Sum_cnt * 8) + 56, cPay_basic_month1     , cdSocInsuranceDto.getPayBasicMonth1());	// 支払基礎日数1:月(副)
				poi.prtItem( lPay_basic_month2     + (Sum_cnt * 8)     , cPay_basic_month2     , cdSocInsuranceDto.getPayBasicMonth2());	// 支払基礎日数2:月(正)
				poi.prtItem( lPay_basic_month2     + (Sum_cnt * 8) + 56, cPay_basic_month2     , cdSocInsuranceDto.getPayBasicMonth2());	// 支払基礎日数2:月(副)
				poi.prtItem( lPay_basic_month3     + (Sum_cnt * 8)     , cPay_basic_month3     , cdSocInsuranceDto.getPayBasicMonth3());	// 支払基礎日数3:月(正)
				poi.prtItem( lPay_basic_month3     + (Sum_cnt * 8) + 56, cPay_basic_month3     , cdSocInsuranceDto.getPayBasicMonth3());	// 支払基礎日数3:月(副)
				poi.prtItem( lPay_basic_day1       + (Sum_cnt * 8)     , cPay_basic_day1       , cdSocInsuranceDto.getPayBasicDay1());		// 支払基礎日数1:日(正)
				poi.prtItem( lPay_basic_day1       + (Sum_cnt * 8) + 56, cPay_basic_day1       , cdSocInsuranceDto.getPayBasicDay1());		// 支払基礎日数1:日(副)
				poi.prtItem( lPay_basic_day2       + (Sum_cnt * 8)     , cPay_basic_day2       , cdSocInsuranceDto.getPayBasicDay2());		// 支払基礎日数2:日(正)
				poi.prtItem( lPay_basic_day2       + (Sum_cnt * 8) + 56, cPay_basic_day2       , cdSocInsuranceDto.getPayBasicDay2());		// 支払基礎日数2:日(副)
				poi.prtItem( lPay_basic_day3       + (Sum_cnt * 8)     , cPay_basic_day3       , cdSocInsuranceDto.getPayBasicDay3());		// 支払基礎日数3:日(正)
				poi.prtItem( lPay_basic_day3       + (Sum_cnt * 8) + 56, cPay_basic_day3       , cdSocInsuranceDto.getPayBasicDay3());		// 支払基礎日数3:日(副)
				poi.prtItem( lPay_amount1          + (Sum_cnt * 8)     , cPay_amount1          , cdSocInsuranceDto.getPayAmount1());		// 金銭の額1(正)
				poi.prtItem( lPay_amount1          + (Sum_cnt * 8) + 56, cPay_amount1          , cdSocInsuranceDto.getPayAmount1());		// 金銭の額1(副)
				poi.prtItem( lPay_amount2          + (Sum_cnt * 8)     , cPay_amount2          , cdSocInsuranceDto.getPayAmount2());		// 金銭の額2(正)
				poi.prtItem( lPay_amount2          + (Sum_cnt * 8) + 56, cPay_amount2          , cdSocInsuranceDto.getPayAmount2());		// 金銭の額2(副)
				poi.prtItem( lPay_amount3          + (Sum_cnt * 8)     , cPay_amount3          ,  cdSocInsuranceDto.getPayAmount3());		// 金銭の額3(正)
				poi.prtItem( lPay_amount3          + (Sum_cnt * 8) + 56, cPay_amount3          , cdSocInsuranceDto.getPayAmount3());		// 金銭の額3(副)
				poi.prtItem( lGoods_amount1        + (Sum_cnt * 8)     , cGoods_amount1        , cdSocInsuranceDto.getGoodsAmount1());		// 現物の額1(正)
				poi.prtItem( lGoods_amount1        + (Sum_cnt * 8) + 56, cGoods_amount1        , cdSocInsuranceDto.getGoodsAmount1());		// 現物の額1(副)
				poi.prtItem( lGoods_amount2        + (Sum_cnt * 8)     , cGoods_amount2        , cdSocInsuranceDto.getGoodsAmount2());		// 現物の額2(正)
				poi.prtItem( lGoods_amount2        + (Sum_cnt * 8) + 56, cGoods_amount2        , cdSocInsuranceDto.getGoodsAmount2());		// 現物の額2(副)
				poi.prtItem( lGoods_amount3        + (Sum_cnt * 8)     , cGoods_amount3        , cdSocInsuranceDto.getGoodsAmount3());		// 現物の額3(正)
				poi.prtItem( lGoods_amount3        + (Sum_cnt * 8) + 56, cGoods_amount3        , cdSocInsuranceDto.getGoodsAmount3());		// 現物の額3(副)
				poi.prtItem( lReward_total1        + (Sum_cnt * 8)     , cReward_total1        , cdSocInsuranceDto.getRewardTotal1());		// 報酬合計1(正)
				poi.prtItem( lReward_total1        + (Sum_cnt * 8) + 56, cReward_total1        , cdSocInsuranceDto.getRewardTotal1());		// 報酬合計1(副)
				poi.prtItem( lReward_total2        + (Sum_cnt * 8)     , cReward_total2        , cdSocInsuranceDto.getRewardTotal2());		// 報酬合計2(正)
				poi.prtItem( lReward_total2        + (Sum_cnt * 8) + 56, cReward_total2        , cdSocInsuranceDto.getRewardTotal2());		// 報酬合計2(副)
				poi.prtItem( lReward_total3        + (Sum_cnt * 8)     , cReward_total3        , cdSocInsuranceDto.getRewardTotal3());		// 報酬合計3(正)
				poi.prtItem( lReward_total3        + (Sum_cnt * 8) + 56, cReward_total3        , cdSocInsuranceDto.getRewardTotal3());		// 報酬合計3(副)
				poi.prtItem( lReward_total_sum     + (Sum_cnt * 8)     , cReward_total_sum     , cdSocInsuranceDto.getRewardTotalSum());	// 報酬総額(正)
				poi.prtItem( lReward_total_sum     + (Sum_cnt * 8) + 56, cReward_total_sum     , cdSocInsuranceDto.getRewardTotalSum());	// 報酬総額(副)
				poi.prtItem( lAverage_three_months + (Sum_cnt * 8)     , cAverage_three_months , cdSocInsuranceDto.getAverageThreeMonths()); // ３ヶ月平均(正)
				poi.prtItem( lAverage_three_months + (Sum_cnt * 8) + 56, cAverage_three_months , cdSocInsuranceDto.getAverageThreeMonths()); // ３ヶ月平均(副)
				poi.prtItem( lHealth_dec_premium   + (Sum_cnt * 8)     , cHealth_dec_premium   , omission1000(cdSocInsuranceDto.getHealthDecPremium()));	// 健保決定保険料(正)
				poi.prtItem( lHealth_dec_premium   + (Sum_cnt * 8) + 56, cHealth_dec_premium   , omission1000(cdSocInsuranceDto.getHealthDecPremium()));	// 健保決定保険料(副)

				tmpDate = DatePart.convDateToInteger(cdSocInsuranceDto.getExpectedDate());
				poi.prtItem( lExpected_dateY       + (Sum_cnt * 8)     , cExpected_dateY       , getWaNen(tmpDate));	// 適用年月:年(正)
				poi.prtItem( lExpected_dateY       + (Sum_cnt * 8) + 56, cExpected_dateY       , getWaNen(tmpDate));	// 適用年月:年(副)
				poi.prtItem( lExpected_dateM       + (Sum_cnt * 8)     , cExpected_dateM       , MospUtility.getMonth(cdSocInsuranceDto.getExpectedDate()));	// 適用年月:月(正)
				poi.prtItem( lExpected_dateM       + (Sum_cnt * 8) + 56, cExpected_dateM       , MospUtility.getMonth(cdSocInsuranceDto.getExpectedDate()));	// 適用年月:月(副)
				poi.prtItem( lEdit_average         + (Sum_cnt * 8)     , cEdit_average         , cdSocInsuranceDto.getEditAverage());	// 修正平均(正)
				poi.prtItem( lEdit_average         + (Sum_cnt * 8) + 56, cEdit_average         , cdSocInsuranceDto.getEditAverage());	// 修正平均(副)
				poi.prtItem( lPension_dec_premium  + (Sum_cnt * 8)     , cPension_dec_premium  , omission1000(cdSocInsuranceDto.getPensionDecPremium()));			// 厚年決定保険料(正)
				poi.prtItem( lPension_dec_premium  + (Sum_cnt * 8) + 56, cPension_dec_premium  , omission1000(cdSocInsuranceDto.getPensionDecPremium()));			// 厚年決定保険料(副)
				poi.prtItem( lRetroactive_payment  + (Sum_cnt * 8)     , cRetroactive_payment  , cdSocInsuranceDto.getRetroactivePayment  ());		// 遡及支払額(正)
				poi.prtItem( lRetroactive_payment  + (Sum_cnt * 8) + 56, cRetroactive_payment  , cdSocInsuranceDto.getRetroactivePayment  ());		// 遡及支払額(副)
				poi.prtItem( lRaise_down_salary_basis + (Sum_cnt * 8)     , cRaise_down_salary_basis, cdSocInsuranceDto.getRaiseDownSalaryBasis());	// 昇降給差の月額(正)
				poi.prtItem( lRaise_down_salary_basis + (Sum_cnt * 8) + 56, cRaise_down_salary_basis, cdSocInsuranceDto.getRaiseDownSalaryBasis());	// 昇降給差の月額(副)

				tmpDate = DatePart.convDateToInteger(cdSocInsuranceDto.getRaiseDownSalaryDate());
				tmpWork = getWaNen(tmpDate) + "年" + MospUtility.getMonth(cdSocInsuranceDto.getRaiseDownSalaryDate()) + "日";				
				poi.prtItem( lRaise_down_salary_date  + (Sum_cnt * 8)     , cRaise_down_salary_date , tmpWork);										// 昇降給年月(正)
				poi.prtItem( lRaise_down_salary_date  + (Sum_cnt * 8) + 56, cRaise_down_salary_date , tmpWork);										// 昇降給年月(副)
				
				/**** ↑↑　各社員毎の項目設定  ↑↑****/

				Sum_cnt++;			
			}
		}

		//テンプレートシート０の削除
//		if(Sum_sheet > 0){
//			poi.rmvSheet(0);
//		}
		// 出力内容設定
		String fileName = strTekiyouDate + 
							PayrollConst.FILE_NAME_SEPARATOR +
							PayrollConst.FILE_INSURANCE_XLS;
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName);
		request.setAttribute(MospConst.ATT_FILE_OBJECT, poi.getWorkbook());
	}


	/**
	 * 帳票出力処理を行う。(OpenOffice Calc)<br><br>
	 * @throws Exception 
	 */
	private void report(InsuranceConfSetVo vo , List<CdSocInsuranceDto> list ) throws Exception {
		CdSocInsuranceDto	cdSocInsuranceDto;

		String tmpTitleSei   = "";	
		String tmpTitleFuk   = "";	
		String tmpRepCode    = "";	
		String tmpWork       = "";	

		int Line;
		int Column;
		int Sum_sheet;
		int Sum_cnt;
		int tmpDate;

		int lK_name						= 14;	// 行：社員氏名
		int cK_name						=  7;	// 欄：社員氏名
		int lHhealth_no					= 14;	// 行：健康保険番号
		int cHhealth_no					=  2;	// 欄：健康保険番号
		int lBerthdayJpCd				= 14;	// 行：元号コード
		int cBerthdayJpCd				= 15;	// 欄：元号コード
		int lBerthdayY					= 14;	// 行：誕生年
		int cBerthdayY					= 17;	// 欄：誕生年
		int lBerthdayM					= 14;	// 行：誕生月
		int cBerthdaym					= 19;	// 欄：誕生月
		int lBerthdayD					= 14;	// 行：誕生日
		int cBerthdayD					= 21;	// 欄：誕生日
		int lGender						= 14;	// 行：性別コード
		int cGender						= 23;	// 欄：性別コード
		int lHealth_bef_premium			= 14;	// 行：健保従前保険料
		int cHealth_bef_premium			= 25;	// 欄：健保従前保険料
		int lPension_bef_premium		= 14;	// 行：厚年従前保険料
		int cPension_bef_premium		= 32;	// 欄：厚年従前保険料

		int lPay_basic_month1			= 20;	// 行：支払基礎日数1(月)
		int cPay_basic_month1			=  1;	// 欄：支払基礎日数1(月)
		int lPay_basic_month2			= 18;	// 行：支払基礎日数2(月)
		int cPay_basic_month2			=  1;	// 欄：支払基礎日数2(月)
		int lPay_basic_month3			= 16;	// 行：支払基礎日数3(月)
		int cPay_basic_month3			=  1;	// 欄：支払基礎日数3(月)

		int lPay_basic_day1				= 20;	// 行：支払基礎日数1(日)
		int cPay_basic_day1				=  3;	// 欄：支払基礎日数1(日)
		int lPay_basic_day2				= 18;	// 行：支払基礎日数2(日)
		int cPay_basic_day2				=  3;	// 欄：支払基礎日数2(日)
		int lPay_basic_day3				= 16;	// 行：支払基礎日数3(日)
		int cPay_basic_day3				=  3;	// 欄：支払基礎日数3(日)

		int lPay_amount1				= 20;	// 行：金銭の額1
		int cPay_amount1				=  6;	// 欄：金銭の額1
		int lPay_amount2				= 18;	// 行：金銭の額2
		int cPay_amount2				=  6;	// 欄：金銭の額2
		int lPay_amount3				= 16;	// 行：金銭の額3
		int cPay_amount3				=  6;	// 欄：金銭の額3

		int lGoods_amount1				= 20;	// 行：現物の額1
		int cGoods_amount1				= 12;	// 欄：現物の額1
		int lGoods_amount2				= 18;	// 行：現物の額2
		int cGoods_amount2				= 12;	// 欄：現物の額2
		int lGoods_amount3				= 16;	// 行：現物の額3
		int cGoods_amount3				= 12;	// 欄：現物の額3

		int lReward_total1				= 20;	// 行：報酬合計1
		int cReward_total1				= 19;	// 欄：報酬合計1
		int lReward_total2				= 18;	// 行：報酬合計2
		int cReward_total2				= 19;	// 欄：報酬合計2
		int lReward_total3				= 16;	// 行：報酬合計3
		int cReward_total3				= 19;	// 欄：報酬合計3
		
		int lReward_total_sum			= 16;	// 行：報酬総額
		int cReward_total_sum			= 25;	// 欄：報酬総額
		int lAverage_three_months		= 18;	// 行：３ヶ月平均
		int cAverage_three_months		= 25;	// 欄：３ヶ月平均
		int lHealth_dec_premium			= 20;	// 行：健保決定保険料
		int cHealth_dec_premium			= 25;	// 欄：健保決定保険料
		int lExpected_dateY				= 16;	// 行：適用年月:年
		int cExpected_dateY				= 32;	// 欄：適用年月:年
		int lExpected_dateM				= 16;	// 行：適用年月:月
		int cExpected_dateM				= 34;	// 欄：適用年月:月
		int lEdit_average				= 18;	// 行：修正平均
		int cEdit_average				= 32;	// 欄：修正平均
		int lPension_dec_premium		= 20;	// 行：厚年決定保険料
		int cPension_dec_premium		= 32;	// 欄：厚年決定保険料
		int lRetroactive_payment		= 16;	// 行：遡及支払額
		int cRetroactive_payment		= 39;	// 欄：遡及支払額
		int lRaise_down_salary_basis	= 17;	// 行：昇降給差の月額
		int cRaise_down_salary_basis	= 39;	// 欄：昇降給差の月額
		int lRaise_down_salary_date		= 18;	// 行：昇降給年月
		int cRaise_down_salary_date		= 39;	// 欄：昇降給年月


		// コネクション取得
		getConnection();

		// 帳票作成
		OdsBean odsBean = new OdsBean(cfg.getProperty(MospConst.PPT_APP_DOCBASE) + PayrollConst.TEMPLATE_GEPPEN_ODS);

		if(null == cmCompanyDto){ // 会社情報未取得
			throw new MospException(MospConst.EX_CM_USER_ILLEGAL);	
		}

		// ヘッダータイトル＆届出コードの取得
		if(vo.idButtonSyori.equals(InsuranceConfSetVo.PRM_CKR_SANTEI_KISO)){ //「算定基礎」指定の場合
			tmpTitleSei   = PayrollConst.TTL_REP_SANTEI_SEI;	
			tmpTitleFuk   = PayrollConst.TTL_REP_SANTEI_FUKU;	
			tmpRepCode    = PayrollConst.TTL_REP_CODE_SANTEI;	
		}else{
			tmpTitleSei   = PayrollConst.TTL_REP_GEPPEN_SEI;	
			tmpTitleFuk   = PayrollConst.TTL_REP_GEPPEN_FUKU;	
			tmpRepCode    = PayrollConst.TTL_REP_CODE_GEPPEN;	
		}

		// ヘッダー
		Line   =   2;
		Column =  12;
		odsBean.setValue( Column     , Line      , tmpTitleSei);		// 書類タイトル（正）
		odsBean.setValue( Column +  2, Line +  54, tmpTitleFuk);		// 書類タイトル（副）

		Line   =   4;
		Column =   0;
		odsBean.setValue( Column     , Line      , tmpRepCode);		// 届出コード

		Line   =   5;
		Column =   6;
		odsBean.setValue( Column     , Line      , cmCompanyDto.getDisposeNo());		// 事業所整理番号（正）
		odsBean.setValue( Column     , Line +  56, cmCompanyDto.getDisposeNo());		// 事業所整理番号（副）
		
		Line   =  48;
		Column =   6;
		odsBean.setValue( Column     , Line      , PayrollConst.NAM_COMMON_POSTAL + cmCompanyDto.getCompanyPostal()); // 事業所郵便番号（正）
		odsBean.setValue( Column     , Line +  56, PayrollConst.NAM_COMMON_POSTAL + cmCompanyDto.getCompanyPostal()); // 事業所郵便番号（副）

		Line   =  49;
		Column =   6;
		odsBean.setValue( Column     , Line      , cmCompanyDto.getCompanyAddress()); //事業所所在地（正）
		odsBean.setValue( Column     , Line +  56, cmCompanyDto.getCompanyAddress()); //事業所所在地（副）
		

		Line   =  50;
		Column =   6;
		odsBean.setValue( Column     , Line      , cmCompanyDto.getCompanyName());	 //事業所名称（正）
		odsBean.setValue( Column     , Line +  56, cmCompanyDto.getCompanyName());	 //事業所名称（副）

		Line   =  51;
		Column =   6;
		odsBean.setValue( Column     , Line      , cmCompanyDto.getEnterpreneur());	//事業主氏名（正）
		odsBean.setValue( Column     , Line +  56, cmCompanyDto.getEnterpreneur());	//事業主氏名（副）

		Line   =  52;
		Column =   6;
		odsBean.setValue( Column     , Line      , cmCompanyDto.getCompanyPhone());	//電話（正）
		odsBean.setValue( Column     , Line +  56, cmCompanyDto.getCompanyPhone());	//電話（副）


		Line   =  46;
		Column =   8;
		odsBean.setValue( Column     , Line      , nowDateJp);	//和暦本日日付（正）	
		odsBean.setValue( Column + 21, Line +  59, nowDateJp);	//和暦本日日付（副）

		Sum_cnt   = 99;
		Sum_sheet = 0;
		
		for(int i = 0 ; i < list.size(); i++){
			if(Sum_cnt >= 4){
				Sum_sheet++;
//				poi.clnSheet(0, Sum_sheet, String.valueOf(Sum_sheet));  //シートの複製
//				poi.crtSheet(Sum_sheet, String.valueOf(Sum_sheet));     //空ソート作成
				Sum_cnt = 0;
			}

			cdSocInsuranceDto = list.get(i);
			kCode = cdSocInsuranceDto.getKCode();
			mKojinDto = mKojinDao.findForKey(kCode);	//人事マスタ個人情報インスタンス取得
			cmSocInsuranceDto = cmSocInsuranceDao.findForEmployee(kCode);	//人事マスタ社会保険部インスタンス取得		
			if((null != mKojinDto) && (null != cmSocInsuranceDto)){

				/**** ↓↓　各社員毎の項目設定  ↓↓****/
			
				odsBean.setValue( cHhealth_no  , lHhealth_no   + (Sum_cnt * 8)     , cmSocInsuranceDto.getHealthNo()+  "\n" + "(" +	cmSocInsuranceDto.getPensionNo() + ")"); // 健康保険番号(正)
				odsBean.setValue( cHhealth_no  , lHhealth_no   + (Sum_cnt * 8) + 56, cmSocInsuranceDto.getHealthNo() + "\n" + "(" +	cmSocInsuranceDto.getPensionNo() + ")"); // 健康保険番号(副)
				odsBean.setValue( cK_name      , lK_name       + (Sum_cnt * 8)     , cdSocInsuranceDto.getKName());	// 社員氏名(正)
				odsBean.setValue( cK_name      , lK_name       + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getKName());	// 社員氏名(副)
				odsBean.setValue( cBerthdayJpCd, lBerthdayJpCd + (Sum_cnt * 8)     , String.valueOf(getGengouCD(mKojinDto.getSeinenbi())));	// 元号コード(正)
				odsBean.setValue( cBerthdayJpCd, lBerthdayJpCd + (Sum_cnt * 8) + 56, String.valueOf(getGengouCD(mKojinDto.getSeinenbi())));	// 元号コード(副)
				
				tmpDate = mKojinDto.getSeinenbi();
				String tmpM =  String.valueOf(MospUtility.getMonth(DatePart.convIntegerDateToDate(tmpDate)));
				String tmpD =  String.valueOf(MospUtility.getDay(DatePart.convIntegerDateToDate(tmpDate)));

				odsBean.setValue( cBerthdayY            , lBerthdayY            + (Sum_cnt * 8)     , getWaNen(tmpDate));				// 誕生年(正)
				odsBean.setValue( cBerthdayY            , lBerthdayY            + (Sum_cnt * 8) + 56, getWaNen(tmpDate));				// 誕生年(副)
				odsBean.setValue( cBerthdaym            , lBerthdayM            + (Sum_cnt * 8)     , tmpM);							// 誕生月(正)
				odsBean.setValue( cBerthdaym            , lBerthdayM            + (Sum_cnt * 8) + 56, tmpM);							// 誕生月(副)
				odsBean.setValue( cBerthdayD            , lBerthdayD            + (Sum_cnt * 8)     , tmpD);							// 誕生日(正)
				odsBean.setValue( cBerthdayD            , lBerthdayD            + (Sum_cnt * 8) + 56, tmpD);							// 誕生日(副)
				odsBean.setValue( cGender               , lGender               + (Sum_cnt * 8)     , mKojinDto.getSeibetu());			// 性別コード(正)
				odsBean.setValue( cGender               , lGender               + (Sum_cnt * 8) + 56, mKojinDto.getSeibetu());			// 性別コード(副)
				odsBean.setValue( cHealth_bef_premium   , lHealth_bef_premium   + (Sum_cnt * 8)     , omission1000(cdSocInsuranceDto.getHealthBefPremium()));	// 健保従前保険料(正)
				odsBean.setValue( cHealth_bef_premium   , lHealth_bef_premium   + (Sum_cnt * 8) + 56, omission1000(cdSocInsuranceDto.getHealthBefPremium()));	// 健保従前保険料(副)
				odsBean.setValue( cPension_bef_premium  , lPension_bef_premium  + (Sum_cnt * 8)     , omission1000(cdSocInsuranceDto.getPensionBefPremium()));	// 厚年従前保険料(正)
				odsBean.setValue( cPension_bef_premium  , lPension_bef_premium  + (Sum_cnt * 8) + 56, omission1000(cdSocInsuranceDto.getPensionBefPremium()));	// 厚年従前保険料(副)
				odsBean.setValue( cPay_basic_month1     , lPay_basic_month1     + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayBasicMonth1());	// 支払基礎日数1:月(正)
				odsBean.setValue( cPay_basic_month1     , lPay_basic_month1     + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayBasicMonth1());	// 支払基礎日数1:月(副)
				odsBean.setValue( cPay_basic_month2     , lPay_basic_month2     + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayBasicMonth2());	// 支払基礎日数2:月(正)
				odsBean.setValue( cPay_basic_month2     , lPay_basic_month2     + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayBasicMonth2());	// 支払基礎日数2:月(副)
				odsBean.setValue( cPay_basic_month3     , lPay_basic_month3     + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayBasicMonth3());	// 支払基礎日数3:月(正)
				odsBean.setValue( cPay_basic_month3     , lPay_basic_month3     + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayBasicMonth3());	// 支払基礎日数3:月(副)
				odsBean.setValue( cPay_basic_day1       , lPay_basic_day1       + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayBasicDay1());		// 支払基礎日数1:日(正)
				odsBean.setValue( cPay_basic_day1       , lPay_basic_day1       + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayBasicDay1());		// 支払基礎日数1:日(副)
				odsBean.setValue( cPay_basic_day2       , lPay_basic_day2       + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayBasicDay2());		// 支払基礎日数2:日(正)
				odsBean.setValue( cPay_basic_day2       , lPay_basic_day2       + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayBasicDay2());		// 支払基礎日数2:日(副)
				odsBean.setValue( cPay_basic_day3       , lPay_basic_day3       + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayBasicDay3());		// 支払基礎日数3:日(正)
				odsBean.setValue( cPay_basic_day3       , lPay_basic_day3       + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayBasicDay3());		// 支払基礎日数3:日(副)
				odsBean.setValue( cPay_amount1          , lPay_amount1          + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayAmount1());		// 金銭の額1(正)
				odsBean.setValue( cPay_amount1          , lPay_amount1          + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayAmount1());		// 金銭の額1(副)
				odsBean.setValue( cPay_amount2          , lPay_amount2          + (Sum_cnt * 8)     , cdSocInsuranceDto.getPayAmount2());		// 金銭の額2(正)
				odsBean.setValue( cPay_amount2          , lPay_amount2          + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayAmount2());		// 金銭の額2(副)
				odsBean.setValue( cPay_amount3          , lPay_amount3          + (Sum_cnt * 8)     ,  cdSocInsuranceDto.getPayAmount3());		// 金銭の額3(正)
				odsBean.setValue( cPay_amount3          , lPay_amount3          + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getPayAmount3());		// 金銭の額3(副)
				odsBean.setValue( cGoods_amount1        , lGoods_amount1        + (Sum_cnt * 8)     , cdSocInsuranceDto.getGoodsAmount1());		// 現物の額1(正)
				odsBean.setValue( cGoods_amount1        , lGoods_amount1        + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getGoodsAmount1());		// 現物の額1(副)
				odsBean.setValue( cGoods_amount2        , lGoods_amount2        + (Sum_cnt * 8)     , cdSocInsuranceDto.getGoodsAmount2());		// 現物の額2(正)
				odsBean.setValue( cGoods_amount2        , lGoods_amount2        + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getGoodsAmount2());		// 現物の額2(副)
				odsBean.setValue( cGoods_amount3        , lGoods_amount3        + (Sum_cnt * 8)     , cdSocInsuranceDto.getGoodsAmount3());		// 現物の額3(正)
				odsBean.setValue( cGoods_amount3        , lGoods_amount3        + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getGoodsAmount3());		// 現物の額3(副)
				odsBean.setValue( cReward_total1        , lReward_total1        + (Sum_cnt * 8)     , cdSocInsuranceDto.getRewardTotal1());		// 報酬合計1(正)
				odsBean.setValue( cReward_total1        , lReward_total1        + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getRewardTotal1());		// 報酬合計1(副)
				odsBean.setValue( cReward_total2        , lReward_total2        + (Sum_cnt * 8)     , cdSocInsuranceDto.getRewardTotal2());		// 報酬合計2(正)
				odsBean.setValue( cReward_total2        , lReward_total2        + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getRewardTotal2());		// 報酬合計2(副)
				odsBean.setValue( cReward_total3        , lReward_total3        + (Sum_cnt * 8)     , cdSocInsuranceDto.getRewardTotal3());		// 報酬合計3(正)
				odsBean.setValue( cReward_total3        , lReward_total3        + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getRewardTotal3());		// 報酬合計3(副)
				odsBean.setValue( cReward_total_sum     , lReward_total_sum     + (Sum_cnt * 8)     , cdSocInsuranceDto.getRewardTotalSum());	// 報酬総額(正)
				odsBean.setValue( cReward_total_sum     , lReward_total_sum     + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getRewardTotalSum());	// 報酬総額(副)
				odsBean.setValue( cAverage_three_months , lAverage_three_months + (Sum_cnt * 8)     , cdSocInsuranceDto.getAverageThreeMonths()); // ３ヶ月平均(正)
				odsBean.setValue( cAverage_three_months , lAverage_three_months + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getAverageThreeMonths()); // ３ヶ月平均(副)
				odsBean.setValue( cHealth_dec_premium   , lHealth_dec_premium   + (Sum_cnt * 8)     , omission1000(cdSocInsuranceDto.getHealthDecPremium()));	// 健保決定保険料(正)
				odsBean.setValue( cHealth_dec_premium   , lHealth_dec_premium   + (Sum_cnt * 8) + 56, omission1000(cdSocInsuranceDto.getHealthDecPremium()));	// 健保決定保険料(副)

				tmpDate = DatePart.convDateToInteger(cdSocInsuranceDto.getExpectedDate());
				odsBean.setValue( cExpected_dateY         , lExpected_dateY          + (Sum_cnt * 8)     , getWaNen(tmpDate));	// 適用年月:年(正)
				odsBean.setValue( cExpected_dateY         , lExpected_dateY          + (Sum_cnt * 8) + 56, getWaNen(tmpDate));	// 適用年月:年(副)
				odsBean.setValue( cExpected_dateM         , lExpected_dateM          + (Sum_cnt * 8)     , MospUtility.getMonth(cdSocInsuranceDto.getExpectedDate()));	// 適用年月:月(正)
				odsBean.setValue( cExpected_dateM         , lExpected_dateM          + (Sum_cnt * 8) + 56, MospUtility.getMonth(cdSocInsuranceDto.getExpectedDate()));	// 適用年月:月(副)
				odsBean.setValue( cEdit_average           , lEdit_average            + (Sum_cnt * 8)     , cdSocInsuranceDto.getEditAverage());	// 修正平均(正)
				odsBean.setValue( cEdit_average           , lEdit_average            + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getEditAverage());	// 修正平均(副)
				odsBean.setValue( cPension_dec_premium    , lPension_dec_premium     + (Sum_cnt * 8)     , omission1000(cdSocInsuranceDto.getPensionDecPremium()));	// 厚年決定保険料(正)
				odsBean.setValue( cPension_dec_premium    , lPension_dec_premium     + (Sum_cnt * 8) + 56, omission1000(cdSocInsuranceDto.getPensionDecPremium()));	// 厚年決定保険料(副)
				odsBean.setValue( cRetroactive_payment    , lRetroactive_payment     + (Sum_cnt * 8)     , cdSocInsuranceDto.getRetroactivePayment  ());	// 遡及支払額(正)
				odsBean.setValue( cRetroactive_payment    , lRetroactive_payment     + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getRetroactivePayment  ());	// 遡及支払額(副)
				odsBean.setValue( cRaise_down_salary_basis, lRaise_down_salary_basis + (Sum_cnt * 8)     , cdSocInsuranceDto.getRaiseDownSalaryBasis());	// 昇降給差の月額(正)
				odsBean.setValue( cRaise_down_salary_basis, lRaise_down_salary_basis + (Sum_cnt * 8) + 56, cdSocInsuranceDto.getRaiseDownSalaryBasis());	// 昇降給差の月額(副)

				tmpDate = DatePart.convDateToInteger(cdSocInsuranceDto.getRaiseDownSalaryDate());
				tmpWork = getWaNen(tmpDate) + "年" + MospUtility.getMonth(cdSocInsuranceDto.getRaiseDownSalaryDate()) + "日";				
				odsBean.setValue( cRaise_down_salary_date , lRaise_down_salary_date  + (Sum_cnt * 8)     , tmpWork);										// 昇降給年月(正)
				odsBean.setValue( cRaise_down_salary_date , lRaise_down_salary_date  + (Sum_cnt * 8) + 56, tmpWork);										// 昇降給年月(副)
				
				/**** ↑↑　各社員毎の項目設定  ↑↑****/

				Sum_cnt++;			
			}
		}
		
		// 出力内容設定
		String fileName = strTekiyouDate + 
							PayrollConst.FILE_NAME_SEPARATOR +
							PayrollConst.FILE_INSURANCE_ODS;
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName);
		request.setAttribute(MospConst.ATT_FILE_OBJECT, odsBean.getSpreadSheet());
	}


	/**
	 * 元号コードを取得する。<br><br>
	 * @param intDate 取得対象のINT西暦日
	 * @return 元号コード
	 */
	private int getGengouCD( int intDate ){
		int outCode = 0;
		//西暦から元号コード取得する
		if (intDate >= 19890108)  {
			outCode = 7;
		} else if ((intDate < 19890108) & (intDate >= 19261225))  {
			   outCode = 5;
		} else if ((intDate < 19261225) & (intDate >= 19121110))  {
			   outCode = 3;
		} else if ((intDate < 19121110) & (intDate >= 18680908))  {
			   outCode = 1;
		}
	   return outCode;
	}

	/**
	 * 和暦年を取得する。<br><br>
	 * @param intDate 取得対象のINT西暦年月日
	 * @return 差引超過額又は不足額
	 */
	private String getWaNen( int intDate ){
		String tmpCode = "";
		int    tmpInt = 0;
		//西暦から元号コード取得する
		if (intDate >= 19890108)  {
			tmpCode = String.valueOf(intDate - 19880000);
		} else if ((intDate < 19890108) & (intDate >= 19261225))  {
			tmpCode = String.valueOf(intDate - 19250000);
		} else if ((intDate < 19261225) & (intDate >= 19121110))  {
			tmpCode = String.valueOf(intDate - 19110000);
		} else if ((intDate < 19121110) & (intDate >= 18680908))  {
			tmpCode = String.valueOf(intDate - 18670000);
		}
		tmpInt = tmpCode.length();
		if(tmpInt > 4){
			return tmpCode.substring(0, tmpInt - 4);
		}
		return "0";
	}

	/**
	 * 金額を千円単位にする。(千円以下切捨て)<br><br>
	 * @param intPay 取得対象のINT金額
	 * @return 千円単位の金額
	 */
	private int omission1000( int intPay ){
		int SumTmp = 0;
		if(1000 <= intPay){
			SumTmp = intPay / 1000;
		}
		return SumTmp;
	}

}
