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

import java.io.File;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.jopendocument.dom.spreadsheet.Sheet;
import org.jopendocument.dom.spreadsheet.SpreadSheet;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPAction;
import jp.mosp.common.common.BaseVo;
import jp.mosp.common.common.MospConst;
import jp.mosp.common.common.MospUtility;
import jp.mosp.common.common.PoiUtility;
import jp.mosp.common.part.DatePart;
import jp.mosp.common.part.StringPart;

import jp.mosp.payroll.vo.AttendanceExportCardVo;

import jp.mosp.report.dao.AttendanceManagementDao;
import jp.mosp.report.dto.AttendanceManagementDto;

public class AttendanceManagementAction extends MosPAction {

	private int		row			= 0;	//Row(行) 0〜
	private int		pageno		= 0;	//ページ数
	private int		endpagel	= 50;	//1ページの最終行数
	private int		gyol		= 2;	//明細の改行数
	private int		titlel		= 3;	//1ページのタイトル印刷位置
	private int		firstl		= 8;	//1ページの明細開始位置
	private int		endl		= 50;	//最終位置getLastRow()で取得
	private int		lastl		= 46;	//1ページの明細最終行(合計行は含まない)
	private int		totall		= 48;	//1ページの合計印刷行	
	private String		file1		= "";
	private int		printcnt	= 0;

	// エクセル・セル番号
	private int		cc[]		= {12,19,26,33,40,47,54,61,68,75,82,89,96,103,110};

	private String		simei			= "";

	private double		snissu			= 0;
	private int    	kinmuji			= 0;
	private int      	kyukeiji		= 0;
	private double   	yukyu			= 0;
	private double  	tokukyu			= 0;
	private double  	kekkin			= 0;
	private double    	skekkin			= 0;
	private int        tisokai			= 0;
	private int       	tijikan			= 0;
	private int    	zajikan    		= 0;
	private int   		ksjikan    		= 0;
	private int     	snjikan    		= 0;
	private int      	kaikin     		= 0;
	private int      	syokujikaisu 	= 0;
	private int       	cyokukaisu1 	= 0;
	private int     	cyokukaisu2 	= 0;
	private int      	cyokukaisu3 	= 0;
	private int      	hokakaisu1   	= 0;
	private int      	hokakaisu2   	= 0;
	private int       	hokakaisu3		= 0;
	private int     	hokakaisu4		= 0;
	private int       	hokakaisu5		= 0;

	private double 	totalSNissu 		= 0;
	private int 		totalKinmuJi 		= 0;
	private int 		totalKyukeiJi 		= 0;
	private double 	totalYukyu 			= 0;
	private double 	totalTokukyu 		= 0;
	private double 	totalKekkin 		= 0;
	private double 	totalSKekkin 		= 0;
	private int 		totalTisoKai 		= 0;
	private int 		totalTiJikan 		= 0;
	private int 		totalZaJikan 		= 0;
	private int 		totalKsJikan 		= 0;
	private int 		totalSnJikan 		= 0;
	private int 		totalKaikin 		= 0;
	private int 		totalSyokujiKaisu  	= 0;
	private int 		totalCyokuKaisu1 	= 0;
	private int 		totalCyokuKaisu2 	= 0;
	private int 		totalCyokuKaisu3 	= 0;
	private int 		totalHokaKaisu1 	= 0;
	private int 		totalHokaKaisu2 	= 0;
	private int 		totalHokaKaisu3 	= 0;
	private int 		totalHokaKaisu4 	= 0;
	private int 		totalHokaKaisu5 	= 0;

	private String sectionName = "";
	private String targetYear = "";
	private String targetMonth = "";

	private List<AttendanceManagementDto> managementList;

	private static final int CELL_K_NAME 		= 1;
	private static final int CELL_YEAR 		= 6;
	private static final int CELL_MONTH 		= 12;
	private static final int CELL_SECTION 	= 93;

	// OpenDocument用
	private static final int PAGE_END_ROW 	= 50;	// 1ページの終了位置
	private static final int TITLE_ROW 		= 3;	// タイトル開始位置
	private static final int DETAIL_ROW 		= 7;	// 1ページの明細開始位置
	private static final int TOTAL_ROW 		= 47;	// 1ページの合計開始位置
	private static final int LEN_EMPLOYEE 	= 20;	// 1ページの最大人数

	/**
	 * コンストラクタ
	 */
	public AttendanceManagementAction() {
		super();
		setNeedProcSeq(false);
	}

	/**
	 * アクション
	 */
	public void action() throws Exception {		
		// DBコネクション取得
		getConnection();
		// VOの取得
		AttendanceExportCardVo vo = (AttendanceExportCardVo) prepareVo();
		// VO及びフォワード先URLの設定
		setVo(vo);
		setUrl(vo.getRetUrl());
		// パラメータ取得
		vo.setParams(request);
		Date targetYearMonth = util.getYearMonth(vo.getPltYear(), vo.getPltMonth());			
		// 所属名設定
		if (vo.getPltSection().equals(CommonConst.NAM_COMMON_STRING_INITIAL_VALUE)) {
			sectionName = CommonConst.NAM_ALL_SECTION;
		} else {
			sectionName = getSectionName(vo.getPltSection());
		}
		// 年月
		targetYear = String.valueOf(MospUtility.getYear(targetYearMonth));
		targetMonth = String.valueOf(MospUtility.getMonth(targetYearMonth));
		// 検索
		AttendanceManagementDao dao = new AttendanceManagementDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		managementList = dao.findForCondition(
				DatePart.convDateToStringYearMonthShort(targetYearMonth),
				vo.getPltSection()
		);
		// 帳票設定
		StringBuffer fileName = new StringBuffer();
		fileName.append(util.convDateToStringYearMonth(targetYearMonth));
		fileName.append(CommonConst.FILE_NAME_SEPARATOR);
		fileName.append(vo.getPltSection());
		fileName.append(CommonConst.FILE_NAME_SEPARATOR);
		// 帳票作成
		if (StringPart.isNotNull(cfg.getProperty(CommonConst.PPT_KINTAI_USE_ODF))) {
			// ODS
			request.setAttribute(MospConst.ATT_FILE_OBJECT, makeSpreadSheet());
			// ファイル名
			fileName.append(CommonConst.FILE_SAMP_M_KINTAIKANRI_ODS);
		} else {
			// XLS
			request.setAttribute(MospConst.ATT_FILE_OBJECT, makeWorkbook().getWorkbook());
			// ファイル名
			fileName.append(CommonConst.FILE_SAMP_M_KINTAIKANRI);
		}
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName.toString());
	}

	protected BaseVo getSpecificVo() {
		return new AttendanceExportCardVo();
	}

	/**
	 * 勤怠管理情報一覧作成
	 * @return PoiUtilityインスタンス
	 * @throws Exception 
	 */
	private PoiUtility makeWorkbook() throws Exception {
		// 帳票作成準備
		PoiUtility poi = new PoiUtility();
		StringBuffer sb = new StringBuffer();
		sb.append(cfg.getProperty(MospConst.PPT_APP_DOCBASE));
		sb.append(CommonConst.TEMPLATE_M_KINTAIKANRI);
		poi.crtNewDocR(0, sb.toString());
		// ヘッダー情報設定
		printTitle(poi);
		// データ表示
		Iterator<AttendanceManagementDto> it = managementList.iterator();
		while(it.hasNext()){
			AttendanceManagementDto dto = it.next();
			simei 			= dto.getSimei();
			snissu 			= Double.valueOf(dto.getSNissu());
			kinmuji 		= Integer.valueOf(dto.getKinmuJil());
			kyukeiji 		= Integer.valueOf(dto.getKyukeiJi());
			yukyu 			= Double.valueOf(dto.getYukyu());
			tokukyu 		= Double.valueOf(dto.getTokuKyu());
			kekkin 			= Double.valueOf(dto.getKekkin());
			skekkin 		= Double.valueOf(dto.getSKekkin());
			tisokai 		= Integer.valueOf(dto.getTiSoKai());
			tijikan 		= Integer.valueOf(dto.getTiJikan());
			zajikan 		= Integer.valueOf(dto.getZaJikan());
			ksjikan 		= Integer.valueOf(dto.getKsJikan());
			snjikan 		= Integer.valueOf(dto.getSnJikan());
			kaikin 			= Integer.valueOf(dto.getKaikin());
			syokujikaisu 	= Integer.valueOf(dto.getSyokujiKaisu());
			cyokukaisu1 	= Integer.valueOf(dto.getCyokuKaisu1());
			cyokukaisu2 	= Integer.valueOf(dto.getCyokuKaisu2());
			cyokukaisu3 	= Integer.valueOf(dto.getCyokuKaisu3());
			hokakaisu1 		= Integer.valueOf(dto.getHokaKaisu1());
			hokakaisu2 		= Integer.valueOf(dto.getHokaKaisu2());
			hokakaisu3 		= Integer.valueOf(dto.getHokaKaisu3());
			hokakaisu4 		= Integer.valueOf(dto.getHokaKaisu4());
			hokakaisu5 		= Integer.parseInt(dto.getHokaKaisu5());
			// 明細印刷
			printDetail(poi);
			// 合計
			addTotal();
		}
		if (printcnt > 0) {
			// 総合計印刷
			printTotal(poi);
			printEnding(poi);
		} else {
			// データ無し印刷
			printNothing(poi);
		}
		return poi;
	}

	/**
	 * タイトル印刷メソッド
	 * @param poi
	 * @throws Exception
	 */
	private void printTitle(PoiUtility poi) throws Exception {
		// 改ページ
		pageno++;
		//タイトル印刷位置算出
		row = (pageno - 1) * endpagel + (titlel - 1);
		//タイトル,日付
		row++;
		// 年月日
		poi.prtItem(row, CELL_YEAR, targetYear);
		poi.prtItem(row, CELL_MONTH, targetMonth);
		// 所属
		poi.prtItem(row, CELL_SECTION, sectionName);
		// 明細印刷位置算出
		row = (pageno - 1) * endpagel + (firstl - 1 - gyol);
	}

	/**
	 * 明細印刷
	 * @param poi
	 * @throws Exception
	 */
	private void printDetail(PoiUtility poi) throws Exception{
		// 改頁確認
		chkNewPage(poi);
		// 氏名
		poi.prtItem(row, CELL_K_NAME, simei);
		// 上段項目
		poi.prtItem(row, cc[ 0], snissu);
		poi.prtItem(row, cc[ 1], getHourString(util.convIntegerTimeToDoubleTime(kinmuji)));
		poi.prtItem(row, cc[ 2], getHourString(util.convIntegerTimeToDoubleTime(zajikan)));
		poi.prtItem(row, cc[ 3], getHourString(util.convIntegerTimeToDoubleTime(snjikan)));
		poi.prtItem(row, cc[ 4], getHourString(util.convIntegerTimeToDoubleTime(tijikan)));
		poi.prtItem(row, cc[ 5], tisokai);
		poi.prtItem(row, cc[ 7], syokujikaisu);
		poi.prtItem(row, cc[ 8], cyokukaisu2);
		poi.prtItem(row, cc[ 9], hokakaisu1);
		poi.prtItem(row, cc[10], hokakaisu3);
		poi.prtItem(row, cc[11], hokakaisu5);
		poi.prtItem(row, cc[12], yukyu);
		poi.prtItem(row, cc[13], tokukyu);
		// 下段項目
		poi.prtItem(row+1, cc[ 0], "");
		poi.prtItem(row+1, cc[ 1], getHourString(util.convIntegerTimeToDoubleTime(kyukeiji)));
		poi.prtItem(row+1, cc[ 2], getHourString(util.convIntegerTimeToDoubleTime(ksjikan)));
		poi.prtItem(row+1, cc[ 7], cyokukaisu1);
		poi.prtItem(row+1, cc[ 8], cyokukaisu3);
		poi.prtItem(row+1, cc[ 9], hokakaisu2);
		poi.prtItem(row+1, cc[10], hokakaisu4);
		poi.prtItem(row+1, cc[11], kaikin);
		poi.prtItem(row+1, cc[12], kekkin);
		poi.prtItem(row+1, cc[13], skekkin);
		// 明細印刷件数
		printcnt++;
	}

	/**
	 * 合計印刷位置算出
	 * @param poi
	 * @throws Exception
	 */
	private void printTotal(PoiUtility poi) throws Exception{		
		row = (pageno - 1) * endpagel + (totall - 1);
		// 支給項目
		poi.prtItem(row, cc[ 0], totalSNissu);
		poi.prtItem(row, cc[ 1], getHourString(util.convIntegerTimeToDoubleTime(totalKinmuJi)));
		poi.prtItem(row, cc[ 2], getHourString(util.convIntegerTimeToDoubleTime(totalZaJikan)));
		poi.prtItem(row, cc[ 3], getHourString(util.convIntegerTimeToDoubleTime(totalSnJikan)));
		poi.prtItem(row, cc[ 4], getHourString(util.convIntegerTimeToDoubleTime(totalTiJikan)));
		poi.prtItem(row, cc[ 5], totalTisoKai);
		poi.prtItem(row, cc[ 7], totalSyokujiKaisu);
		poi.prtItem(row, cc[ 8], totalCyokuKaisu2);
		poi.prtItem(row, cc[ 9], totalHokaKaisu1);
		poi.prtItem(row, cc[10], totalHokaKaisu3);
		poi.prtItem(row, cc[11], totalHokaKaisu5);
		poi.prtItem(row, cc[12], totalYukyu);
		poi.prtItem(row, cc[13], totalTokukyu);
		// 控除項目
		poi.prtItem(row+1, cc[ 1], getHourString(util.convIntegerTimeToDoubleTime(totalKyukeiJi)));
		poi.prtItem(row+1, cc[ 2], getHourString(util.convIntegerTimeToDoubleTime(totalKsJikan)));
		poi.prtItem(row+1, cc[ 7], totalCyokuKaisu1);
		poi.prtItem(row+1, cc[ 8], totalCyokuKaisu3);
		poi.prtItem(row+1, cc[ 9], totalHokaKaisu2);
		poi.prtItem(row+1, cc[10], totalHokaKaisu4);
		poi.prtItem(row+1, cc[11], totalKaikin);
		poi.prtItem(row+1, cc[12], totalKekkin);
		poi.prtItem(row+1, cc[13], totalSKekkin);
		// 明細印刷件数
		printcnt++;
	}

	/**
	 * 新しい頁作成メソッド
	 * @param poi
	 * @throws Exception
	 */
	private void chkNewPage(PoiUtility poi) throws Exception{
		// オープン
		if (pageno == 0) {
			// Pageを再生成
			crtNewDoc(poi);
			// タイトル印刷
			printTitle(poi);
		}
		if (row >= ((pageno - 1) * endpagel + (lastl - gyol))) {
			// オーバーフロー又は最初の印刷の時、タイトル印刷
			printTitle(poi);
		}
		// 改行
		row += gyol;
	}

	/**
	 * 新しい頁作成メソッド
	 * @param poi
	 * @throws Exception
	 */
	private void crtNewDoc(PoiUtility poi) throws Exception{
		poi.crtNewDocR(0, file1);
		// 最終行取得
		endl = poi.getLastRow();
	}

	/**
	 * データ無し印刷メソッド
	 * @param poi
	 * @throws Exception
	 */
	private void printNothing(PoiUtility poi) throws Exception{
		// 改頁確認
		chkNewPage(poi);
		poi.prtItem( 7, 1, CommonConst.MSG_ATTENDANCE_REPORT_NO_DATA);
	}

	/**
	 * 帳票終了
	 * @param poi
	 * @throws Exception
	 */
	private void printEnding(PoiUtility poi) throws Exception{
		// 印刷ｙ座標
		// 終了後の最初の行
		row = pageno * endpagel;
		boolean syori =  true;
		// 残り行を削除する
		for (; row <= endl; row++) {
			if (syori) {
				poi.dltRow(row);
			}
		}
	}

	/**
	 * 勤怠管理情報一覧作成
	 * @return SpreadSheetインスタンス
	 * @throws Exception 
	 */
	private SpreadSheet makeSpreadSheet() throws Exception {
		// テンプレートファイル
		StringBuffer sb = new StringBuffer();
		sb.append(cfg.getProperty(MospConst.PPT_APP_DOCBASE));
		sb.append(CommonConst.TEMPLATE_M_KINTAIKANRI_ODS);
		// 帳票作成
		SpreadSheet ss = SpreadSheet.createFromFile(new File(sb.toString()));
		// シート
		Sheet sheet = ss.getSheet(0);
		// 初期値
		pageno = 0;
		// タイトル
		printTitle(sheet);
		// データ表示
		Iterator<AttendanceManagementDto> it = managementList.iterator();
		int count = 0;
		while (it.hasNext()) {
			AttendanceManagementDto dto = it.next();
			// 氏名
			sheet.getCellAt(CELL_K_NAME, row).setValue(dto.getSimei());
			snissu 			= Double.valueOf(dto.getSNissu());
			kinmuji 		= Integer.valueOf(dto.getKinmuJil());
			kyukeiji 		= Integer.valueOf(dto.getKyukeiJi());
			yukyu 			= Double.valueOf(dto.getYukyu());
			tokukyu 		= Double.valueOf(dto.getTokuKyu());
			kekkin 			= Double.valueOf(dto.getKekkin());
			skekkin 		= Double.valueOf(dto.getSKekkin());
			tisokai 		= Integer.valueOf(dto.getTiSoKai());
			tijikan 		= Integer.valueOf(dto.getTiJikan());
			zajikan 		= Integer.valueOf(dto.getZaJikan());
			ksjikan 		= Integer.valueOf(dto.getKsJikan());
			snjikan 		= Integer.valueOf(dto.getSnJikan());
			kaikin 			= Integer.valueOf(dto.getKaikin());
			syokujikaisu 	= Integer.valueOf(dto.getSyokujiKaisu());
			cyokukaisu1 	= Integer.valueOf(dto.getCyokuKaisu1());
			cyokukaisu2 	= Integer.valueOf(dto.getCyokuKaisu2());
			cyokukaisu3 	= Integer.valueOf(dto.getCyokuKaisu3());
			hokakaisu1 		= Integer.valueOf(dto.getHokaKaisu1());
			hokakaisu2 		= Integer.valueOf(dto.getHokaKaisu2());
			hokakaisu3 		= Integer.valueOf(dto.getHokaKaisu3());
			hokakaisu4 		= Integer.valueOf(dto.getHokaKaisu4());
			hokakaisu5 		= Integer.parseInt(dto.getHokaKaisu5());
			// 詳細印刷
			printDetail(sheet);
			// 合計
			addTotal();
			// 次の人へ
			row += 2;
			count++;
			// 最後の一人
			if (!it.hasNext()) {
				// 合計行へ移動
				row = pageno * PAGE_END_ROW + TOTAL_ROW;
				// 合計印刷
				printTotal(sheet);
			}
			if (count == LEN_EMPLOYEE) {
				// 初期化
				count = 0;
				// 次ページへ遷移
				addPageNo(sheet);
			}
		}
		return ss;
	}

	/**
	 * タイトル印刷メソッド
	 * @param sheet
	 * @throws Exception
	 */
	private void printTitle(Sheet sheet) {
		row = pageno * PAGE_END_ROW + TITLE_ROW;
		// 年月
		sheet.getCellAt(CELL_YEAR, row).setValue(targetYear);
		sheet.getCellAt(CELL_MONTH, row).setValue(targetMonth);
		// 所属
		sheet.getCellAt(CELL_SECTION, row).setValue(sectionName);
		// 明細行へ移動
		row = pageno * PAGE_END_ROW + DETAIL_ROW;
	}

	/**
	 * 次ページへ移動
	 * @param sheet
	 */
	private void addPageNo(Sheet sheet) {
		// ページ加算
		pageno++;
		// ページの先頭行へ移動
		row = pageno * PAGE_END_ROW;
		// タイトル設定
		printTitle(sheet);
	}

	/**
	 * 詳細印刷
	 * @param sheet
	 */
	private void printDetail(Sheet sheet) {
		// 上段項目
		int upper = row;
		sheet.getCellAt(cc[ 0], upper).setValue(snissu);
		sheet.getCellAt(cc[ 1], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(kinmuji)));
		sheet.getCellAt(cc[ 2], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(zajikan)));
		sheet.getCellAt(cc[ 3], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(snjikan)));
		sheet.getCellAt(cc[ 4], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(tijikan)));
		sheet.getCellAt(cc[ 5], upper).setValue(tisokai);
		sheet.getCellAt(cc[ 7], upper).setValue(syokujikaisu);
		sheet.getCellAt(cc[ 8], upper).setValue(cyokukaisu2);
		sheet.getCellAt(cc[ 9], upper).setValue(hokakaisu1);
		sheet.getCellAt(cc[10], upper).setValue(hokakaisu3);
		sheet.getCellAt(cc[11], upper).setValue(hokakaisu5);
		sheet.getCellAt(cc[12], upper).setValue(yukyu);
		sheet.getCellAt(cc[13], upper).setValue(tokukyu);
		// 下段項目
		int lower = row +1;
		sheet.getCellAt(cc[ 0], lower).setValue("");
		sheet.getCellAt(cc[ 1], lower).setValue(getHourString(util.convIntegerTimeToDoubleTime(kyukeiji)));
		sheet.getCellAt(cc[ 2], lower).setValue(getHourString(util.convIntegerTimeToDoubleTime(ksjikan)));
		sheet.getCellAt(cc[ 7], lower).setValue(cyokukaisu1);
		sheet.getCellAt(cc[ 8], lower).setValue(cyokukaisu3);
		sheet.getCellAt(cc[ 9], lower).setValue(hokakaisu2);
		sheet.getCellAt(cc[10], lower).setValue(hokakaisu4);
		sheet.getCellAt(cc[11], lower).setValue(kaikin);
		sheet.getCellAt(cc[12], lower).setValue(kekkin);
		sheet.getCellAt(cc[13], lower).setValue(skekkin);
	}

	/**
	 * 合計印刷
	 * @param sheet
	 */
	private void printTotal(Sheet sheet) {
		// 上段項目
		int upper = row;
		sheet.getCellAt(cc[ 0], upper).setValue(totalSNissu);
		sheet.getCellAt(cc[ 1], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(totalKinmuJi)));
		sheet.getCellAt(cc[ 2], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(totalZaJikan)));
		sheet.getCellAt(cc[ 3], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(totalSnJikan)));
		sheet.getCellAt(cc[ 4], upper).setValue(getHourString(util.convIntegerTimeToDoubleTime(totalTiJikan)));
		sheet.getCellAt(cc[ 5], upper).setValue(totalTisoKai);
		sheet.getCellAt(cc[ 7], upper).setValue(totalSyokujiKaisu);
		sheet.getCellAt(cc[ 8], upper).setValue(totalCyokuKaisu2);
		sheet.getCellAt(cc[ 9], upper).setValue(totalHokaKaisu1);
		sheet.getCellAt(cc[10], upper).setValue(totalHokaKaisu3);
		sheet.getCellAt(cc[11], upper).setValue(totalHokaKaisu5);
		sheet.getCellAt(cc[12], upper).setValue(totalYukyu);
		sheet.getCellAt(cc[13], upper).setValue(totalTokukyu);
		// 下段項目
		int lower = row +1;
		sheet.getCellAt(cc[ 0], lower).setValue("");
		sheet.getCellAt(cc[ 1], lower).setValue(getHourString(util.convIntegerTimeToDoubleTime(totalKyukeiJi)));
		sheet.getCellAt(cc[ 2], lower).setValue(getHourString(util.convIntegerTimeToDoubleTime(totalKsJikan)));
		sheet.getCellAt(cc[ 7], lower).setValue(totalCyokuKaisu1);
		sheet.getCellAt(cc[ 8], lower).setValue(totalCyokuKaisu3);
		sheet.getCellAt(cc[ 9], lower).setValue(totalHokaKaisu2);
		sheet.getCellAt(cc[10], lower).setValue(totalHokaKaisu4);
		sheet.getCellAt(cc[11], lower).setValue(totalKaikin);
		sheet.getCellAt(cc[12], lower).setValue(totalKekkin);
		sheet.getCellAt(cc[13], lower).setValue(totalSKekkin);
	}

	/**
	 * 合計
	 */
	private void addTotal() {
		totalSNissu 		+= snissu;
		totalKinmuJi 		+= kinmuji;
		totalKyukeiJi 		+= kyukeiji;
		totalYukyu 			+= yukyu;
		totalTokukyu 		+= tokukyu;
		totalKekkin 		+= kekkin;
		totalSKekkin 		+= skekkin;
		totalTisoKai 		+= tisokai;
		totalTiJikan 		+= tijikan;
		totalZaJikan 		+= zajikan;
		totalKsJikan 		+= ksjikan;
		totalSnJikan 		+= snjikan;
		totalKaikin 		+= kaikin;
		totalSyokujiKaisu 	+= syokujikaisu;
		totalCyokuKaisu1 	+= cyokukaisu1;
		totalCyokuKaisu2 	+= cyokukaisu2;
		totalCyokuKaisu3 	+= cyokukaisu3;
		totalHokaKaisu1 	+= hokakaisu1;
		totalHokaKaisu2 	+= hokakaisu2;
		totalHokaKaisu3 	+= hokakaisu3;
		totalHokaKaisu4 	+= hokakaisu4;
		totalHokaKaisu5 	+= hokakaisu5;
	}

}
