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

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

import jp.mosp.common.CommonConst;
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.utils.DateUtil;
import jp.mosp.common.utils.StringUtil;
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;

/**
 * @author 
 *
 */
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 intCalcDates = 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;
			intCalcDates = (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;
				intCalcDates = (nowYear * 100) + PayrollConst.MONTH_TEKIYOU_DEFAULT;
			} else {
				intCalcDate = (nowYear * 10000) + ((Integer.valueOf(confVo.prmSyoukyuTuki) + 3) * 100)
						+ PayrollConst.TIME_DEFAULT_DAY;
				intCalcDates = (nowYear * 100) + (Integer.valueOf(confVo.prmSyoukyuTuki) + 3);
			}
		}
		dateTekiyouDate = DateUtil.convIntegerDateToDate(intCalcDate);
		strTekiyouDate = String.valueOf(intCalcDates);
		
		// 会社情報取得
		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 (StringUtil.isNotNull(cfg.getProperty(CommonConst.PPT_KINTAI_USE_ODF))) {
				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>
	 * @param vo 
	 * @param list 
	 * @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 sumSheet;
		int sumCnt;
		int tmpDate;
		
		int lkName = 14; // 行：社員氏名
		int ckName = 7; // 欄：社員氏名
		int lHhealthNo = 14; // 行：健康保険番号
		int cHhealthNo = 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 lHealthBefPremium = 14; // 行：健保従前保険料
		int cHealthBefPremium = 25; // 欄：健保従前保険料
		int lPensionBefPremium = 14; // 行：厚年従前保険料
		int cPensionBefPremium = 32; // 欄：厚年従前保険料
		
		int lPayBasicMonth1 = 20; // 行：支払基礎日数1(月)
		int cPayBasicMonth1 = 1; // 欄：支払基礎日数1(月)
		int lPayBasicMonth2 = 18; // 行：支払基礎日数2(月)
		int cPayBasicMonth2 = 1; // 欄：支払基礎日数2(月)
		int lPayBasicMonth3 = 16; // 行：支払基礎日数3(月)
		int cPayBasicMonth3 = 1; // 欄：支払基礎日数3(月)
		
		int lPayBasicDay1 = 20; // 行：支払基礎日数1(日)
		int cPayBasicDay1 = 3; // 欄：支払基礎日数1(日)
		int lPayBasicDay2 = 18; // 行：支払基礎日数2(日)
		int cPayBasicDay2 = 3; // 欄：支払基礎日数2(日)
		int lPayBasicDay3 = 16; // 行：支払基礎日数3(日)
		int cPayBasicDay3 = 3; // 欄：支払基礎日数3(日)
		
		int lPayAmount1 = 20; // 行：金銭の額1
		int cPayAmount1 = 6; // 欄：金銭の額1
		int lPayAmount2 = 18; // 行：金銭の額2
		int cPayAmount2 = 6; // 欄：金銭の額2
		int lPayAmount3 = 16; // 行：金銭の額3
		int cPayAmount3 = 6; // 欄：金銭の額3
		
		int lGoodsAmount1 = 20; // 行：現物の額1
		int cGoodsAmount1 = 12; // 欄：現物の額1
		int lGoodsAmount2 = 18; // 行：現物の額2
		int cGoodsAmount2 = 12; // 欄：現物の額2
		int lGoodsAmount3 = 16; // 行：現物の額3
		int cGoodsAmount3 = 12; // 欄：現物の額3
		
		int lRewardTotal1 = 20; // 行：報酬合計1
		int cRewardTotal1 = 19; // 欄：報酬合計1
		int lRewardTotal2 = 18; // 行：報酬合計2
		int cRewardTotal2 = 19; // 欄：報酬合計2
		int lRewardTotal3 = 16; // 行：報酬合計3
		int cRewardTotal3 = 19; // 欄：報酬合計3
		
		int lRewardTotalSum = 16; // 行：報酬総額
		int cRewardTotalSum = 25; // 欄：報酬総額
		int lAverageThreeMonths = 18; // 行：３ヶ月平均
		int cAverageThreeMonths = 25; // 欄：３ヶ月平均
		int lHealthDecPremium = 20; // 行：健保決定保険料
		int cHealthDecPremium = 25; // 欄：健保決定保険料
		int lExpectedDateY = 16; // 行：適用年月:年
		int cExpectedDateY = 32; // 欄：適用年月:年
		int lExpectedDateM = 16; // 行：適用年月:月
		int cExpectedDateM = 34; // 欄：適用年月:月
		int lEditAverage = 18; // 行：修正平均
		int cEditAverage = 32; // 欄：修正平均
		int lPensionDecPremium = 20; // 行：厚年決定保険料
		int cPensionDecPremium = 32; // 欄：厚年決定保険料
		int lRetroactivePayment = 16; // 行：遡及支払額
		int cRetroactivePayment = 39; // 欄：遡及支払額
		int lRaiseDownSalaryBasis = 17; // 行：昇降給差の月額
		int cRaiseDownSalaryBasis = 39; // 欄：昇降給差の月額
		int lRaiseDownSalaryDate = 18; // 行：昇降給年月
		int cRaiseDownSalaryDate = 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); //和暦本日日付（副）
		
		sumCnt = 99;
		sumSheet = 0;
		
		for (int i = 0; i < list.size(); i++) {
			if (sumCnt >= 4) {
				sumSheet++;
//				poi.clnSheet(0, Sum_sheet, String.valueOf(Sum_sheet));  //シートの複製
//				poi.crtSheet(Sum_sheet, String.valueOf(Sum_sheet));     //空ソート作成
				sumCnt = 0;
			}
			
			cdSocInsuranceDto = list.get(i);
			kCode = cdSocInsuranceDto.getKCode();
			mKojinDto = mKojinDao.findForKey(kCode); //人事マスタ個人情報インスタンス取得
			cmSocInsuranceDto = cmSocInsuranceDao.findForEmployee(kCode); //人事マスタ社会保険部インスタンス取得		
			if ((null != mKojinDto) && (null != cmSocInsuranceDto)) {
				
				/**** ↓↓　各社員毎の項目設定  ↓↓****/
				
				// 健康保険番号(正)
				poi.prtItem(lHhealthNo + (sumCnt * 8), cHhealthNo, cmSocInsuranceDto.getHealthNo() + "\n" + "("
						+ cmSocInsuranceDto.getPensionNo() + ")");
				// 健康保険番号(副)
				poi.prtItem(lHhealthNo + (sumCnt * 8) + 56, cHhealthNo, cmSocInsuranceDto.getHealthNo() + "\n" + "("
						+ cmSocInsuranceDto.getPensionNo() + ")");
				
				poi.prtItem(lkName + (sumCnt * 8), ckName, cdSocInsuranceDto.getKName()); // 社員氏名(正)
				poi.prtItem(lkName + (sumCnt * 8) + 56, ckName, cdSocInsuranceDto.getKName()); // 社員氏名(副)
				
				poi.prtItem(lBerthdayJpCd + (sumCnt * 8), cBerthdayJpCd, String.valueOf(getGengouCD(mKojinDto
					.getSeinenbi()))); // 元号コード(正)
				poi.prtItem(lBerthdayJpCd + (sumCnt * 8) + 56, cBerthdayJpCd, String.valueOf(getGengouCD(mKojinDto
					.getSeinenbi()))); // 元号コード(副)
				
				tmpDate = mKojinDto.getSeinenbi();
				String tmpM = String.valueOf(MospUtility.getMonth(DateUtil.convIntegerDateToDate(tmpDate)));
				String tmpD = String.valueOf(MospUtility.getDay(DateUtil.convIntegerDateToDate(tmpDate)));
				poi.prtItem(lBerthdayY + (sumCnt * 8), cBerthdayY, getWaNen(tmpDate)); // 誕生年(正)
				poi.prtItem(lBerthdayY + (sumCnt * 8) + 56, cBerthdayY, getWaNen(tmpDate)); // 誕生年(副)
				poi.prtItem(lBerthdayM + (sumCnt * 8), cBerthdaym, tmpM); // 誕生月(正)
				poi.prtItem(lBerthdayM + (sumCnt * 8) + 56, cBerthdaym, tmpM); // 誕生月(副)
				poi.prtItem(lBerthdayD + (sumCnt * 8), cBerthdayD, tmpD); // 誕生日(正)
				poi.prtItem(lBerthdayD + (sumCnt * 8) + 56, cBerthdayD, tmpD); // 誕生日(副)
				poi.prtItem(lGender + (sumCnt * 8), cGender, mKojinDto.getSeibetu()); // 性別コード(正)
				poi.prtItem(lGender + (sumCnt * 8) + 56, cGender, mKojinDto.getSeibetu()); // 性別コード(副)
				poi.prtItem(lHealthBefPremium + (sumCnt * 8), cHealthBefPremium, omission1000(cdSocInsuranceDto
					.getHealthBefPremium())); // 健保従前保険料(正)
				poi.prtItem(lHealthBefPremium + (sumCnt * 8) + 56, cHealthBefPremium, omission1000(cdSocInsuranceDto
					.getHealthBefPremium())); // 健保従前保険料(副)
				poi.prtItem(lPensionBefPremium + (sumCnt * 8), cPensionBefPremium, omission1000(cdSocInsuranceDto
					.getPensionBefPremium())); // 厚年従前保険料(正)
				poi.prtItem(lPensionBefPremium + (sumCnt * 8) + 56, cPensionBefPremium, omission1000(cdSocInsuranceDto
					.getPensionBefPremium())); // 厚年従前保険料(副)
				poi.prtItem(lPayBasicMonth1 + (sumCnt * 8), cPayBasicMonth1, cdSocInsuranceDto.getPayBasicMonth1()); // 支払基礎日数1:月(正)
				poi
					.prtItem(lPayBasicMonth1 + (sumCnt * 8) + 56, cPayBasicMonth1, cdSocInsuranceDto
						.getPayBasicMonth1()); // 支払基礎日数1:月(副)
				poi.prtItem(lPayBasicMonth2 + (sumCnt * 8), cPayBasicMonth2, cdSocInsuranceDto.getPayBasicMonth2()); // 支払基礎日数2:月(正)
				poi
					.prtItem(lPayBasicMonth2 + (sumCnt * 8) + 56, cPayBasicMonth2, cdSocInsuranceDto
						.getPayBasicMonth2()); // 支払基礎日数2:月(副)
				poi.prtItem(lPayBasicMonth3 + (sumCnt * 8), cPayBasicMonth3, cdSocInsuranceDto.getPayBasicMonth3()); // 支払基礎日数3:月(正)
				poi
					.prtItem(lPayBasicMonth3 + (sumCnt * 8) + 56, cPayBasicMonth3, cdSocInsuranceDto
						.getPayBasicMonth3()); // 支払基礎日数3:月(副)
				poi.prtItem(lPayBasicDay1 + (sumCnt * 8), cPayBasicDay1, cdSocInsuranceDto.getPayBasicDay1()); // 支払基礎日数1:日(正)
				poi.prtItem(lPayBasicDay1 + (sumCnt * 8) + 56, cPayBasicDay1, cdSocInsuranceDto.getPayBasicDay1()); // 支払基礎日数1:日(副)
				poi.prtItem(lPayBasicDay2 + (sumCnt * 8), cPayBasicDay2, cdSocInsuranceDto.getPayBasicDay2()); // 支払基礎日数2:日(正)
				poi.prtItem(lPayBasicDay2 + (sumCnt * 8) + 56, cPayBasicDay2, cdSocInsuranceDto.getPayBasicDay2()); // 支払基礎日数2:日(副)
				poi.prtItem(lPayBasicDay3 + (sumCnt * 8), cPayBasicDay3, cdSocInsuranceDto.getPayBasicDay3()); // 支払基礎日数3:日(正)
				poi.prtItem(lPayBasicDay3 + (sumCnt * 8) + 56, cPayBasicDay3, cdSocInsuranceDto.getPayBasicDay3()); // 支払基礎日数3:日(副)
				poi.prtItem(lPayAmount1 + (sumCnt * 8), cPayAmount1, cdSocInsuranceDto.getPayAmount1()); // 金銭の額1(正)
				poi.prtItem(lPayAmount1 + (sumCnt * 8) + 56, cPayAmount1, cdSocInsuranceDto.getPayAmount1()); // 金銭の額1(副)
				poi.prtItem(lPayAmount2 + (sumCnt * 8), cPayAmount2, cdSocInsuranceDto.getPayAmount2()); // 金銭の額2(正)
				poi.prtItem(lPayAmount2 + (sumCnt * 8) + 56, cPayAmount2, cdSocInsuranceDto.getPayAmount2()); // 金銭の額2(副)
				poi.prtItem(lPayAmount3 + (sumCnt * 8), cPayAmount3, cdSocInsuranceDto.getPayAmount3()); // 金銭の額3(正)
				poi.prtItem(lPayAmount3 + (sumCnt * 8) + 56, cPayAmount3, cdSocInsuranceDto.getPayAmount3()); // 金銭の額3(副)
				poi.prtItem(lGoodsAmount1 + (sumCnt * 8), cGoodsAmount1, cdSocInsuranceDto.getGoodsAmount1()); // 現物の額1(正)
				poi.prtItem(lGoodsAmount1 + (sumCnt * 8) + 56, cGoodsAmount1, cdSocInsuranceDto.getGoodsAmount1()); // 現物の額1(副)
				poi.prtItem(lGoodsAmount2 + (sumCnt * 8), cGoodsAmount2, cdSocInsuranceDto.getGoodsAmount2()); // 現物の額2(正)
				poi.prtItem(lGoodsAmount2 + (sumCnt * 8) + 56, cGoodsAmount2, cdSocInsuranceDto.getGoodsAmount2()); // 現物の額2(副)
				poi.prtItem(lGoodsAmount3 + (sumCnt * 8), cGoodsAmount3, cdSocInsuranceDto.getGoodsAmount3()); // 現物の額3(正)
				poi.prtItem(lGoodsAmount3 + (sumCnt * 8) + 56, cGoodsAmount3, cdSocInsuranceDto.getGoodsAmount3()); // 現物の額3(副)
				poi.prtItem(lRewardTotal1 + (sumCnt * 8), cRewardTotal1, cdSocInsuranceDto.getRewardTotal1()); // 報酬合計1(正)
				poi.prtItem(lRewardTotal1 + (sumCnt * 8) + 56, cRewardTotal1, cdSocInsuranceDto.getRewardTotal1()); // 報酬合計1(副)
				poi.prtItem(lRewardTotal2 + (sumCnt * 8), cRewardTotal2, cdSocInsuranceDto.getRewardTotal2()); // 報酬合計2(正)
				poi.prtItem(lRewardTotal2 + (sumCnt * 8) + 56, cRewardTotal2, cdSocInsuranceDto.getRewardTotal2()); // 報酬合計2(副)
				poi.prtItem(lRewardTotal3 + (sumCnt * 8), cRewardTotal3, cdSocInsuranceDto.getRewardTotal3()); // 報酬合計3(正)
				poi.prtItem(lRewardTotal3 + (sumCnt * 8) + 56, cRewardTotal3, cdSocInsuranceDto.getRewardTotal3()); // 報酬合計3(副)
				poi.prtItem(lRewardTotalSum + (sumCnt * 8), cRewardTotalSum, cdSocInsuranceDto.getRewardTotalSum()); // 報酬総額(正)
				poi
					.prtItem(lRewardTotalSum + (sumCnt * 8) + 56, cRewardTotalSum, cdSocInsuranceDto
						.getRewardTotalSum()); // 報酬総額(副)
				poi.prtItem(lAverageThreeMonths + (sumCnt * 8), cAverageThreeMonths, cdSocInsuranceDto
					.getAverageThreeMonths()); // ３ヶ月平均(正)
				poi.prtItem(lAverageThreeMonths + (sumCnt * 8) + 56, cAverageThreeMonths, cdSocInsuranceDto
					.getAverageThreeMonths()); // ３ヶ月平均(副)
				poi.prtItem(lHealthDecPremium + (sumCnt * 8), cHealthDecPremium, omission1000(cdSocInsuranceDto
					.getHealthDecPremium())); // 健保決定保険料(正)
				poi.prtItem(lHealthDecPremium + (sumCnt * 8) + 56, cHealthDecPremium, omission1000(cdSocInsuranceDto
					.getHealthDecPremium())); // 健保決定保険料(副)
				
				tmpDate = DateUtil.convDateToInteger(cdSocInsuranceDto.getExpectedDate());
				poi.prtItem(lExpectedDateY + (sumCnt * 8), cExpectedDateY, getWaNen(tmpDate)); // 適用年月:年(正)
				poi.prtItem(lExpectedDateY + (sumCnt * 8) + 56, cExpectedDateY, getWaNen(tmpDate)); // 適用年月:年(副)
				poi.prtItem(lExpectedDateM + (sumCnt * 8), cExpectedDateM, MospUtility.getMonth(cdSocInsuranceDto
					.getExpectedDate())); // 適用年月:月(正)
				poi.prtItem(lExpectedDateM + (sumCnt * 8) + 56, cExpectedDateM, MospUtility.getMonth(cdSocInsuranceDto
					.getExpectedDate())); // 適用年月:月(副)
				poi.prtItem(lEditAverage + (sumCnt * 8), cEditAverage, cdSocInsuranceDto.getEditAverage()); // 修正平均(正)
				poi.prtItem(lEditAverage + (sumCnt * 8) + 56, cEditAverage, cdSocInsuranceDto.getEditAverage()); // 修正平均(副)
				poi.prtItem(lPensionDecPremium + (sumCnt * 8), cPensionDecPremium, omission1000(cdSocInsuranceDto
					.getPensionDecPremium())); // 厚年決定保険料(正)
				poi.prtItem(lPensionDecPremium + (sumCnt * 8) + 56, cPensionDecPremium, omission1000(cdSocInsuranceDto
					.getPensionDecPremium())); // 厚年決定保険料(副)
				poi.prtItem(lRetroactivePayment + (sumCnt * 8), cRetroactivePayment, cdSocInsuranceDto
					.getRetroactivePayment()); // 遡及支払額(正)
				poi.prtItem(lRetroactivePayment + (sumCnt * 8) + 56, cRetroactivePayment, cdSocInsuranceDto
					.getRetroactivePayment()); // 遡及支払額(副)
				poi.prtItem(lRaiseDownSalaryBasis + (sumCnt * 8), cRaiseDownSalaryBasis, cdSocInsuranceDto
					.getRaiseDownSalaryBasis()); // 昇降給差の月額(正)
				poi.prtItem(lRaiseDownSalaryBasis + (sumCnt * 8) + 56, cRaiseDownSalaryBasis, cdSocInsuranceDto
					.getRaiseDownSalaryBasis()); // 昇降給差の月額(副)
				
				tmpDate = DateUtil.convDateToInteger(cdSocInsuranceDto.getRaiseDownSalaryDate());
				tmpWork = getWaNen(tmpDate) + "年" + MospUtility.getMonth(cdSocInsuranceDto.getRaiseDownSalaryDate())
						+ "日";
				poi.prtItem(lRaiseDownSalaryDate + (sumCnt * 8), cRaiseDownSalaryDate, tmpWork); // 昇降給年月(正)
				poi.prtItem(lRaiseDownSalaryDate + (sumCnt * 8) + 56, cRaiseDownSalaryDate, tmpWork); // 昇降給年月(副)
				
				/**** ↑↑　各社員毎の項目設定  ↑↑****/
				
				sumCnt++;
			}
		}
		
		//テンプレートシート０の削除
//		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>
	 * @param vo 
	 * @param list 
	 * @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 sumSheet;
		int sumCnt;
		int tmpDate;
		
		int lkName = 14; // 行：社員氏名
		int ckName = 7; // 欄：社員氏名
		int lHhealthNo = 14; // 行：健康保険番号
		int cHhealthNo = 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 lHealthBefPremium = 14; // 行：健保従前保険料
		int cHealthBefPremium = 25; // 欄：健保従前保険料
		int lPensionBefPremium = 14; // 行：厚年従前保険料
		int cPensionBefPremium = 32; // 欄：厚年従前保険料
		
		int lPayBasicMonth1 = 20; // 行：支払基礎日数1(月)
		int cPayBasicMonth1 = 1; // 欄：支払基礎日数1(月)
		int lPayBasicMonth2 = 18; // 行：支払基礎日数2(月)
		int cPayBasicMonth2 = 1; // 欄：支払基礎日数2(月)
		int lPayBasicMonth3 = 16; // 行：支払基礎日数3(月)
		int cPayBasicMonth3 = 1; // 欄：支払基礎日数3(月)
		
		int lPayBasicDay1 = 20; // 行：支払基礎日数1(日)
		int cPayBasicDay1 = 3; // 欄：支払基礎日数1(日)
		int lPayBasicDay2 = 18; // 行：支払基礎日数2(日)
		int cPayBsicday2 = 3; // 欄：支払基礎日数2(日)
		int lPayBasicDay3 = 16; // 行：支払基礎日数3(日)
		int cPayBasicDay3 = 3; // 欄：支払基礎日数3(日)
		
		int lPayAmount1 = 20; // 行：金銭の額1
		int cPayAmount1 = 6; // 欄：金銭の額1
		int lPayAmount2 = 18; // 行：金銭の額2
		int cPayAmount2 = 6; // 欄：金銭の額2
		int lPayAmount3 = 16; // 行：金銭の額3
		int cPayAmount3 = 6; // 欄：金銭の額3
		
		int lGoodsAmount1 = 20; // 行：現物の額1
		int cGoodsAmount1 = 12; // 欄：現物の額1
		int lGoodsAmount2 = 18; // 行：現物の額2
		int cGoodsAmount2 = 12; // 欄：現物の額2
		int lGoodsAmount3 = 16; // 行：現物の額3
		int cGoodsAmount3 = 12; // 欄：現物の額3
		
		int lRewardTotal1 = 20; // 行：報酬合計1
		int cRewardTotal1 = 19; // 欄：報酬合計1
		int lRewardTotal2 = 18; // 行：報酬合計2
		int cRewardTotal2 = 19; // 欄：報酬合計2
		int lRewardTotal3 = 16; // 行：報酬合計3
		int cRewardTotal3 = 19; // 欄：報酬合計3
		
		int lRewardTotalSum = 16; // 行：報酬総額
		int cRewardTotalSum = 25; // 欄：報酬総額
		int lAverageThreeMonths = 18; // 行：３ヶ月平均
		int cAverageThreeMonths = 25; // 欄：３ヶ月平均
		int lHealthDecPremium = 20; // 行：健保決定保険料
		int cHealthDecPremium = 25; // 欄：健保決定保険料
		int lExpectedDateY = 16; // 行：適用年月:年
		int cExpectedDateY = 32; // 欄：適用年月:年
		int lExpectedDateM = 16; // 行：適用年月:月
		int cExpectedDateM = 34; // 欄：適用年月:月
		int lEditAverage = 18; // 行：修正平均
		int cEditAverage = 32; // 欄：修正平均
		int lPensionDecPremium = 20; // 行：厚年決定保険料
		int cPensionDecPremium = 32; // 欄：厚年決定保険料
		int lRetroactivePayment = 16; // 行：遡及支払額
		int cRetroactivePayment = 39; // 欄：遡及支払額
		int lRaiseDownSalaryBasis = 17; // 行：昇降給差の月額
		int cRaiseDownsalaryBasis = 39; // 欄：昇降給差の月額
		int lRaisedownSalaryDate = 18; // 行：昇降給年月
		int cRaiseDownSalaryDate = 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); //和暦本日日付（副）
		
		sumCnt = 99;
		sumSheet = 0;
		
		for (int i = 0; i < list.size(); i++) {
			if (sumCnt >= 4) {
				sumSheet++;
//				poi.clnSheet(0, Sum_sheet, String.valueOf(Sum_sheet));  //シートの複製
//				poi.crtSheet(Sum_sheet, String.valueOf(Sum_sheet));     //空ソート作成
				sumCnt = 0;
			}
			
			cdSocInsuranceDto = list.get(i);
			kCode = cdSocInsuranceDto.getKCode();
			mKojinDto = mKojinDao.findForKey(kCode); //人事マスタ個人情報インスタンス取得
			cmSocInsuranceDto = cmSocInsuranceDao.findForEmployee(kCode); //人事マスタ社会保険部インスタンス取得		
			if ((null != mKojinDto) && (null != cmSocInsuranceDto)) {
				
				/**** ↓↓　各社員毎の項目設定  ↓↓****/
				
				odsBean.setValue(cHhealthNo, lHhealthNo + (sumCnt * 8), cmSocInsuranceDto.getHealthNo() + "\n" + "("
						+ cmSocInsuranceDto.getPensionNo() + ")"); // 健康保険番号(正)
				odsBean.setValue(cHhealthNo, lHhealthNo + (sumCnt * 8) + 56, cmSocInsuranceDto.getHealthNo() + "\n"
						+ "(" + cmSocInsuranceDto.getPensionNo() + ")"); // 健康保険番号(副)
				odsBean.setValue(ckName, lkName + (sumCnt * 8), cdSocInsuranceDto.getKName()); // 社員氏名(正)
				odsBean.setValue(ckName, lkName + (sumCnt * 8) + 56, cdSocInsuranceDto.getKName()); // 社員氏名(副)
				odsBean.setValue(cBerthdayJpCd, lBerthdayJpCd + (sumCnt * 8), String.valueOf(getGengouCD(mKojinDto
					.getSeinenbi()))); // 元号コード(正)
				odsBean.setValue(cBerthdayJpCd, lBerthdayJpCd + (sumCnt * 8) + 56, String.valueOf(getGengouCD(mKojinDto
					.getSeinenbi()))); // 元号コード(副)
				
				tmpDate = mKojinDto.getSeinenbi();
				String tmpM = String.valueOf(MospUtility.getMonth(DateUtil.convIntegerDateToDate(tmpDate)));
				String tmpD = String.valueOf(MospUtility.getDay(DateUtil.convIntegerDateToDate(tmpDate)));
				
				odsBean.setValue(cBerthdayY, lBerthdayY + (sumCnt * 8), getWaNen(tmpDate)); // 誕生年(正)
				odsBean.setValue(cBerthdayY, lBerthdayY + (sumCnt * 8) + 56, getWaNen(tmpDate)); // 誕生年(副)
				odsBean.setValue(cBerthdaym, lBerthdayM + (sumCnt * 8), tmpM); // 誕生月(正)
				odsBean.setValue(cBerthdaym, lBerthdayM + (sumCnt * 8) + 56, tmpM); // 誕生月(副)
				odsBean.setValue(cBerthdayD, lBerthdayD + (sumCnt * 8), tmpD); // 誕生日(正)
				odsBean.setValue(cBerthdayD, lBerthdayD + (sumCnt * 8) + 56, tmpD); // 誕生日(副)
				odsBean.setValue(cGender, lGender + (sumCnt * 8), mKojinDto.getSeibetu()); // 性別コード(正)
				odsBean.setValue(cGender, lGender + (sumCnt * 8) + 56, mKojinDto.getSeibetu()); // 性別コード(副)
				odsBean.setValue(cHealthBefPremium, lHealthBefPremium + (sumCnt * 8), omission1000(cdSocInsuranceDto
					.getHealthBefPremium())); // 健保従前保険料(正)
				odsBean.setValue(cHealthBefPremium, lHealthBefPremium + (sumCnt * 8) + 56,
						omission1000(cdSocInsuranceDto.getHealthBefPremium())); // 健保従前保険料(副)
				odsBean.setValue(cPensionBefPremium, lPensionBefPremium + (sumCnt * 8), omission1000(cdSocInsuranceDto
					.getPensionBefPremium())); // 厚年従前保険料(正)
				odsBean.setValue(cPensionBefPremium, lPensionBefPremium + (sumCnt * 8) + 56,
						omission1000(cdSocInsuranceDto.getPensionBefPremium())); // 厚年従前保険料(副)
				odsBean
					.setValue(cPayBasicMonth1, lPayBasicMonth1 + (sumCnt * 8), cdSocInsuranceDto.getPayBasicMonth1()); // 支払基礎日数1:月(正)
				odsBean.setValue(cPayBasicMonth1, lPayBasicMonth1 + (sumCnt * 8) + 56, cdSocInsuranceDto
					.getPayBasicMonth1()); // 支払基礎日数1:月(副)
				odsBean
					.setValue(cPayBasicMonth2, lPayBasicMonth2 + (sumCnt * 8), cdSocInsuranceDto.getPayBasicMonth2()); // 支払基礎日数2:月(正)
				odsBean.setValue(cPayBasicMonth2, lPayBasicMonth2 + (sumCnt * 8) + 56, cdSocInsuranceDto
					.getPayBasicMonth2()); // 支払基礎日数2:月(副)
				odsBean
					.setValue(cPayBasicMonth3, lPayBasicMonth3 + (sumCnt * 8), cdSocInsuranceDto.getPayBasicMonth3()); // 支払基礎日数3:月(正)
				odsBean.setValue(cPayBasicMonth3, lPayBasicMonth3 + (sumCnt * 8) + 56, cdSocInsuranceDto
					.getPayBasicMonth3()); // 支払基礎日数3:月(副)
				odsBean.setValue(cPayBasicDay1, lPayBasicDay1 + (sumCnt * 8), cdSocInsuranceDto.getPayBasicDay1()); // 支払基礎日数1:日(正)
				odsBean.setValue(cPayBasicDay1, lPayBasicDay1 + (sumCnt * 8) + 56, cdSocInsuranceDto.getPayBasicDay1()); // 支払基礎日数1:日(副)
				odsBean.setValue(cPayBsicday2, lPayBasicDay2 + (sumCnt * 8), cdSocInsuranceDto.getPayBasicDay2()); // 支払基礎日数2:日(正)
				odsBean.setValue(cPayBsicday2, lPayBasicDay2 + (sumCnt * 8) + 56, cdSocInsuranceDto.getPayBasicDay2()); // 支払基礎日数2:日(副)
				odsBean.setValue(cPayBasicDay3, lPayBasicDay3 + (sumCnt * 8), cdSocInsuranceDto.getPayBasicDay3()); // 支払基礎日数3:日(正)
				odsBean.setValue(cPayBasicDay3, lPayBasicDay3 + (sumCnt * 8) + 56, cdSocInsuranceDto.getPayBasicDay3()); // 支払基礎日数3:日(副)
				odsBean.setValue(cPayAmount1, lPayAmount1 + (sumCnt * 8), cdSocInsuranceDto.getPayAmount1()); // 金銭の額1(正)
				odsBean.setValue(cPayAmount1, lPayAmount1 + (sumCnt * 8) + 56, cdSocInsuranceDto.getPayAmount1()); // 金銭の額1(副)
				odsBean.setValue(cPayAmount2, lPayAmount2 + (sumCnt * 8), cdSocInsuranceDto.getPayAmount2()); // 金銭の額2(正)
				odsBean.setValue(cPayAmount2, lPayAmount2 + (sumCnt * 8) + 56, cdSocInsuranceDto.getPayAmount2()); // 金銭の額2(副)
				odsBean.setValue(cPayAmount3, lPayAmount3 + (sumCnt * 8), cdSocInsuranceDto.getPayAmount3()); // 金銭の額3(正)
				odsBean.setValue(cPayAmount3, lPayAmount3 + (sumCnt * 8) + 56, cdSocInsuranceDto.getPayAmount3()); // 金銭の額3(副)
				odsBean.setValue(cGoodsAmount1, lGoodsAmount1 + (sumCnt * 8), cdSocInsuranceDto.getGoodsAmount1()); // 現物の額1(正)
				odsBean.setValue(cGoodsAmount1, lGoodsAmount1 + (sumCnt * 8) + 56, cdSocInsuranceDto.getGoodsAmount1()); // 現物の額1(副)
				odsBean.setValue(cGoodsAmount2, lGoodsAmount2 + (sumCnt * 8), cdSocInsuranceDto.getGoodsAmount2()); // 現物の額2(正)
				odsBean.setValue(cGoodsAmount2, lGoodsAmount2 + (sumCnt * 8) + 56, cdSocInsuranceDto.getGoodsAmount2()); // 現物の額2(副)
				odsBean.setValue(cGoodsAmount3, lGoodsAmount3 + (sumCnt * 8), cdSocInsuranceDto.getGoodsAmount3()); // 現物の額3(正)
				odsBean.setValue(cGoodsAmount3, lGoodsAmount3 + (sumCnt * 8) + 56, cdSocInsuranceDto.getGoodsAmount3()); // 現物の額3(副)
				odsBean.setValue(cRewardTotal1, lRewardTotal1 + (sumCnt * 8), cdSocInsuranceDto.getRewardTotal1()); // 報酬合計1(正)
				odsBean.setValue(cRewardTotal1, lRewardTotal1 + (sumCnt * 8) + 56, cdSocInsuranceDto.getRewardTotal1()); // 報酬合計1(副)
				odsBean.setValue(cRewardTotal2, lRewardTotal2 + (sumCnt * 8), cdSocInsuranceDto.getRewardTotal2()); // 報酬合計2(正)
				odsBean.setValue(cRewardTotal2, lRewardTotal2 + (sumCnt * 8) + 56, cdSocInsuranceDto.getRewardTotal2()); // 報酬合計2(副)
				odsBean.setValue(cRewardTotal3, lRewardTotal3 + (sumCnt * 8), cdSocInsuranceDto.getRewardTotal3()); // 報酬合計3(正)
				odsBean.setValue(cRewardTotal3, lRewardTotal3 + (sumCnt * 8) + 56, cdSocInsuranceDto.getRewardTotal3()); // 報酬合計3(副)
				odsBean
					.setValue(cRewardTotalSum, lRewardTotalSum + (sumCnt * 8), cdSocInsuranceDto.getRewardTotalSum()); // 報酬総額(正)
				odsBean.setValue(cRewardTotalSum, lRewardTotalSum + (sumCnt * 8) + 56, cdSocInsuranceDto
					.getRewardTotalSum()); // 報酬総額(副)
				odsBean.setValue(cAverageThreeMonths, lAverageThreeMonths + (sumCnt * 8), cdSocInsuranceDto
					.getAverageThreeMonths()); // ３ヶ月平均(正)
				odsBean.setValue(cAverageThreeMonths, lAverageThreeMonths + (sumCnt * 8) + 56, cdSocInsuranceDto
					.getAverageThreeMonths()); // ３ヶ月平均(副)
				odsBean.setValue(cHealthDecPremium, lHealthDecPremium + (sumCnt * 8), omission1000(cdSocInsuranceDto
					.getHealthDecPremium())); // 健保決定保険料(正)
				odsBean.setValue(cHealthDecPremium, lHealthDecPremium + (sumCnt * 8) + 56,
						omission1000(cdSocInsuranceDto.getHealthDecPremium())); // 健保決定保険料(副)
				
				tmpDate = DateUtil.convDateToInteger(cdSocInsuranceDto.getExpectedDate());
				odsBean.setValue(cExpectedDateY, lExpectedDateY + (sumCnt * 8), getWaNen(tmpDate)); // 適用年月:年(正)
				odsBean.setValue(cExpectedDateY, lExpectedDateY + (sumCnt * 8) + 56, getWaNen(tmpDate)); // 適用年月:年(副)
				odsBean.setValue(cExpectedDateM, lExpectedDateM + (sumCnt * 8), MospUtility.getMonth(cdSocInsuranceDto
					.getExpectedDate())); // 適用年月:月(正)
				odsBean.setValue(cExpectedDateM, lExpectedDateM + (sumCnt * 8) + 56, MospUtility
					.getMonth(cdSocInsuranceDto.getExpectedDate())); // 適用年月:月(副)
				odsBean.setValue(cEditAverage, lEditAverage + (sumCnt * 8), cdSocInsuranceDto.getEditAverage()); // 修正平均(正)
				odsBean.setValue(cEditAverage, lEditAverage + (sumCnt * 8) + 56, cdSocInsuranceDto.getEditAverage()); // 修正平均(副)
				odsBean.setValue(cPensionDecPremium, lPensionDecPremium + (sumCnt * 8), omission1000(cdSocInsuranceDto
					.getPensionDecPremium())); // 厚年決定保険料(正)
				odsBean.setValue(cPensionDecPremium, lPensionDecPremium + (sumCnt * 8) + 56,
						omission1000(cdSocInsuranceDto.getPensionDecPremium())); // 厚年決定保険料(副)
				odsBean.setValue(cRetroactivePayment, lRetroactivePayment + (sumCnt * 8), cdSocInsuranceDto
					.getRetroactivePayment()); // 遡及支払額(正)
				odsBean.setValue(cRetroactivePayment, lRetroactivePayment + (sumCnt * 8) + 56, cdSocInsuranceDto
					.getRetroactivePayment()); // 遡及支払額(副)
				odsBean.setValue(cRaiseDownsalaryBasis, lRaiseDownSalaryBasis + (sumCnt * 8), cdSocInsuranceDto
					.getRaiseDownSalaryBasis()); // 昇降給差の月額(正)
				odsBean.setValue(cRaiseDownsalaryBasis, lRaiseDownSalaryBasis + (sumCnt * 8) + 56, cdSocInsuranceDto
					.getRaiseDownSalaryBasis()); // 昇降給差の月額(副)
				
				tmpDate = DateUtil.convDateToInteger(cdSocInsuranceDto.getRaiseDownSalaryDate());
				tmpWork = getWaNen(tmpDate) + "年" + MospUtility.getMonth(cdSocInsuranceDto.getRaiseDownSalaryDate())
						+ "日";
				odsBean.setValue(cRaiseDownSalaryDate, lRaisedownSalaryDate + (sumCnt * 8), tmpWork); // 昇降給年月(正)
				odsBean.setValue(cRaiseDownSalaryDate, lRaisedownSalaryDate + (sumCnt * 8) + 56, tmpWork); // 昇降給年月(副)
				
				/**** ↑↑　各社員毎の項目設定  ↑↑****/
				
				sumCnt++;
			}
		}
		
		// 出力内容設定
		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;
	}
	
}
