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

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

import jp.mosp.common.CommonConst;
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.utils.DateUtil;
import jp.mosp.common.utils.StringUtil;
import jp.mosp.common.utils.TimeUtil;
import jp.mosp.kintai.common.action.AttendanceTotalAction;
import jp.mosp.kintai.common.part.KintaiCommonPart;
import jp.mosp.kintai.kintai.dto.MSyukkinboDto;
import jp.mosp.kintai.kintai.vo.AttendanceListVo;

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

/**
 * @author yoshida
 *
 */
public class AttendanceTableAction extends AttendanceTotalAction {
	
	// 印刷プログラム制御変数
	/**
	 * Row(行) 0〜
	 */
	private int					r					= 0;
	/**
	 * ページ数
	 */
	private int					pageno				= 0;
	/**
	 * 1ページの最終行数
	 */
	private static final int	END_PAGE_L			= 72;
	/**
	 * 明細の改行数
	 */
	private int					gyol				= 2;
	/**
	 * 1ページのタイトル印刷位置
	 */
	private int					titlel				= 3;
	/**
	 * 1ページの明細開始位置
	 */
	private int					firstl				= 7;
	/**
	 * 1ページの合計印刷行
	 */
	private static final int	TOTAL_L				= 69;
	private int					printcnt			= 0;
	
	// エクセル・セル番号
	private static final int[]	CC					= { 1, 4, 6, 8, 13, 18, 23, 28, 33, 39, 43, 47, 51, 55, 59, 63, 69 };
	
	private int					workDays			= 0;
	private int					totalWork			= 0;
	private int					totalOver			= 0;
	private int					totalLateNight		= 0;
	private int					totalLate			= 0;
	private int					totalLeaveEarly		= 0;
	private int					totalHolidayWork	= 0;
	private int					totalBreak			= 0;
	private int					totalVacation		= 0;
	private int					totalSyokuji		= 0;
	private int					totalCyoku1			= 0;
	private int					totalCyoku2			= 0;
	private int					totalCyoku3			= 0;
	private int					totalHoka1			= 0;
	private int					totalHoka2			= 0;
	private int					totalHoka3			= 0;
	private int					totalHoka4			= 0;
	private int					totalHoka5			= 0;
	private int					totalHourVacation	= 0;
	// 午前半休数（合計）
	private int					totalSHankyu		= 0;
	// 午後半休数（合計）
	private int					totalTHankyu		= 0;
	
	// OpenDocument用
	/**
	 * 1ページの明細開始位置
	 */
	private static final int	DETAIL_ROW			= 6;
	/**
	 * 1ページの合計印刷行
	 */
	private static final int	TOTAL_ROW			= 68;
	/**
	 * 年
	 */
	private static final String	CELL_YEAR			= "H3";
	/**
	 * 月
	 */
	private static final String	CELL_MONTH			= "M3";
	/**
	 * 社員名
	 */
	private static final String	CELL_K_NAME			= "Y3";
	/**
	 * 所属名
	 */
	private static final String	CELL_SECTION		= "AZ3";
	/**
	 * 対象年月
	 */
	private Date				targetMonth;
	/**
	 * 対象社員コード
	 */
	private String				kCode;
	/**
	 * POI
	 */
	private PoiUtility			poi;
	/**
	 * シート
	 */
	private Sheet				sheet;
	

	/**
	 * コンストラクタ
	 */
	public AttendanceTableAction() {
		super();
		setNeedProcSeq(false);
	}
	
	/**
	 * アクション
	 */
	public void action() throws Exception {
		// VOの取得
		prepareVo();
		// 初期処理
		init();
		// 帳票設定
		StringBuffer fileName = new StringBuffer();
		fileName.append(DateUtil.convDateToStringYearMonth(targetMonth));
		fileName.append(CommonConst.FILE_NAME_SEPARATOR);
		fileName.append(kCode);
		fileName.append(CommonConst.FILE_NAME_SEPARATOR);
		// 帳票作成
		if (StringUtil.isNotNull(cfg.getProperty(CommonConst.PPT_KINTAI_USE_ODF))) {
			// ファイル名
			fileName.append(CommonConst.FILE_ATTENDANCE_TABLE_ODS);
			// ODS
			ods();
		} else {
			// ファイル名
			fileName.append(CommonConst.FILE_ATTENDANCE_TABLE);
			// XLS
			xls();
		}
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName.toString());
	}
	
	@Override
	protected BaseVo getSpecificVo() {
		return new AttendanceListVo();
	}
	
	@Override
	protected void init() throws Exception {
		AttendanceListVo vo = (AttendanceListVo)getVo();
		// パラメータ取得
		vo.setParams(request);
		// 表示月
		targetMonth = DateUtil.getYearMonth(vo.getPltYear(), vo.getPltMonth());
		// データ取得
		kCode = request.getParameter(AttendanceListVo.PRM_HID_K_CODE);
	}
	
	/**
	 * 勤務表(ODS)作成
	 * @throws Exception	例外処理が発生した場合
	 */
	private void ods() throws Exception {
		// テンプレートファイル
		StringBuffer sb = new StringBuffer();
		sb.append(cfg.getProperty(MospConst.PPT_APP_DOCBASE));
		sb.append(CommonConst.TEMPLATE_M_KINMUHYO_ODS);
		// 帳票作成
		SpreadSheet ss = SpreadSheet.createFromFile(new File(sb.toString()));
		// シート
		sheet = ss.getSheet(0);
		// 年
		sheet.getCellAt(CELL_YEAR).setValue(MospUtility.getYear(targetMonth));
		// 月
		sheet.getCellAt(CELL_MONTH).setValue(MospUtility.getMonth(targetMonth));
		// 社員名
		sheet.getCellAt(CELL_K_NAME).setValue(getKName(kCode));
		// 所属名
		sheet.getCellAt(CELL_SECTION).setValue(part().section().getBelongSectionName(kCode));
		// 日集計データ配列作成
		makeAttendance();
		// 明細印刷
		printDetail();
		// 総合計印刷
		printTotal();
		// ODS
		request.setAttribute(MospConst.ATT_FILE_OBJECT, ss);
	}
	
	/**
	 * 勤務表(XLS)作成
	 * @throws Exception	例外処理が発生した場合
	 */
	private void xls() throws Exception {
		// 帳票作成準備
		poi = new PoiUtility();
		poi.crtNewDocR(0, cfg.getProperty(MospConst.PPT_APP_DOCBASE) + CommonConst.TEMPLATE_M_KINMUHYO);
		// ヘッダー情報設定
		prtTitle();
		// 日集計データ配列作成
		makeAttendance();
		// データ情報設定
		prtDetail();
		if (printcnt > 0) {
			// 総合計印刷
			prtTotal();
		}
		// XLS
		request.setAttribute(MospConst.ATT_FILE_OBJECT, poi.getWorkbook());
	}
	
	/**
	 * タイトル印刷メソッド
	 * @throws Exception   	例外処理が発生した場合
	 */
	private void prtTitle() throws Exception {
		// 改ページ
		pageno += 1;
		// タイトル印刷位置算出
		r = (pageno - 1) * END_PAGE_L + (titlel - 1);
		// 年月
		poi.prtItem(r, 7, MospUtility.getYear(targetMonth));
		poi.prtItem(r, 12, MospUtility.getMonth(targetMonth));
		// 氏名
		poi.prtItem(r, 24, getKName(kCode));
		// 所属
		final int ccNum = 51;
		poi.prtItem(r, ccNum, part().section().getBelongSectionName(kCode));
	}
	
	/**
	 * 明細印刷メソッド
	 * @throws Exception   	例外処理が発生した場合
	 */
	private void prtDetail() throws Exception {
		// 明細印刷位置算出
		r = (pageno - 1) * END_PAGE_L + (firstl - 1 - gyol);
		// 改行
		r += gyol;
		// 行タイトルの設定
		poi.prtItem(r - 2, CC[9], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "09", 2));
		poi.prtItem(r - 2, CC[10], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "11", 2));
		poi.prtItem(r - 2, CC[11], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "13", 3));
		poi.prtItem(r - 2, CC[12], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "15", 3));
		poi.prtItem(r - 2, CC[13], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "17", 3));
		poi.prtItem(r - 1, CC[9], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "10", 2));
		poi.prtItem(r - 1, CC[10], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "12", 2));
		poi.prtItem(r - 1, CC[11], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "14", 3));
		poi.prtItem(r - 1, CC[12], getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "16", 3));
		// 上段項目設定
		for (String[] element : aryAttendance) {
			// 上段
			poi.prtItem(r, CC[0], element[1]);
			poi.prtItem(r, CC[1], element[2]);
			poi.prtItem(r, CC[2], element[3]);
			poi.prtItem(r, CC[3], element[4]);
			poi.prtItem(r, CC[4], element[5]);
			poi.prtItem(r, CC[5], element[6]);
			poi.prtItem(r, CC[6], element[7]);
			poi.prtItem(r, CC[7], element[8]);
			poi.prtItem(r, CC[8], element[9]);
			poi.prtItem(r, CC[9], element[10]);
			poi.prtItem(r, CC[10], element[11]);
			poi.prtItem(r, CC[11], element[12]);
			poi.prtItem(r, CC[12], element[13]);
			poi.prtItem(r, CC[13], element[14]);
			poi.prtItem(r, CC[14], element[15]);
			poi.prtItem(r, CC[15], element[16]);
			poi.prtItem(r, CC[16], element[17]);
			// 下段
			poi.prtItem(r + 1, CC[3], element[18]);
			poi.prtItem(r + 1, CC[4], element[19]);
			poi.prtItem(r + 1, CC[5], element[20]);
			poi.prtItem(r + 1, CC[7], element[21]);
			poi.prtItem(r + 1, CC[8], element[22]);
			poi.prtItem(r + 1, CC[9], element[23]);
			poi.prtItem(r + 1, CC[10], element[24]);
			poi.prtItem(r + 1, CC[11], element[25]);
			poi.prtItem(r + 1, CC[12], element[26]);
			poi.prtItem(r + 1, CC[13], element[27]);
			poi.prtItem(r + 1, CC[14], element[28]);
			poi.prtItem(r + 1, CC[15], element[29]);
			r += 2;
			// 明細印刷件数
			printcnt++;
		}
	}
	
	/**
	 * 総合計印刷メソッド
	 * @throws Exception   	例外処理が発生した場合
	 */
	private void prtTotal() throws Exception {
		// 合計印刷位置算出
		r = (pageno - 1) * END_PAGE_L + (TOTAL_L - 1);
		// 上段項目
		poi.prtItem(r, CC[2], workDays);
		poi.prtItem(r, CC[4], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalWork)));
		poi.prtItem(r, CC[5], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalOver)));
		poi.prtItem(r, CC[6], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalLateNight)));
		poi.prtItem(r, CC[7], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalLate)));
		poi.prtItem(r, CC[9], totalSyokuji);
		poi.prtItem(r, CC[10], totalCyoku2);
		poi.prtItem(r, CC[11], totalHoka1);
		poi.prtItem(r, CC[12], totalHoka3);
		poi.prtItem(r, CC[13], totalHoka5);
		poi.prtItem(r, CC[14], totalSHankyu);
		poi.prtItem(r, CC[15], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalVacation)));
		// 下段項目
		poi.prtItem(r + 1, CC[4], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalBreak)));
		poi.prtItem(r + 1, CC[5], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalHolidayWork)));
		poi.prtItem(r + 1, CC[7], getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalLeaveEarly)));
		poi.prtItem(r + 1, CC[9], totalCyoku1);
		poi.prtItem(r + 1, CC[10], totalCyoku3);
		poi.prtItem(r + 1, CC[11], totalHoka2);
		poi.prtItem(r + 1, CC[12], totalHoka4);
		poi.prtItem(r + 1, CC[13], totalHourVacation);
		poi.prtItem(r + 1, CC[14], totalTHankyu);
		// 明細印刷件数
		printcnt++;
	}
	
	/**
	 * 明細印刷メソッド
	 * @throws Exception   	例外処理が発生した場合
	 */
	private void printDetail() throws Exception {
		// 項目設定
		int row = DETAIL_ROW;
		// 行タイトルの設定
		sheet.getCellAt(CC[9], row - 2).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "09", 2));
		sheet.getCellAt(CC[9], row - 2).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "09", 2));
		sheet.getCellAt(CC[10], row - 2).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "11", 2));
		sheet.getCellAt(CC[11], row - 2).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "13", 3));
		sheet.getCellAt(CC[12], row - 2).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "15", 3));
		sheet.getCellAt(CC[13], row - 2).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "17", 3));
		sheet.getCellAt(CC[9], row - 1).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "10", 2));
		sheet.getCellAt(CC[10], row - 1).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "12", 2));
		sheet.getCellAt(CC[11], row - 1).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "14", 3));
		sheet.getCellAt(CC[12], row - 1).setValue(getTChangeOrTName(CommonConst.TID_ALLOWANCE_NAME, "16", 3));
		
		for (String[] element : aryAttendance) {
			// 上段
			sheet.getCellAt(CC[0], row).setValue(element[1]);
			sheet.getCellAt(CC[1], row).setValue(element[2]);
			sheet.getCellAt(CC[2], row).setValue(element[3]);
			sheet.getCellAt(CC[3], row).setValue(element[4]);
			sheet.getCellAt(CC[4], row).setValue(element[5]);
			sheet.getCellAt(CC[5], row).setValue(element[6]);
			sheet.getCellAt(CC[6], row).setValue(element[7]);
			sheet.getCellAt(CC[7], row).setValue(element[8]);
			sheet.getCellAt(CC[8], row).setValue(element[9]);
			sheet.getCellAt(CC[9], row).setValue(element[10]);
			sheet.getCellAt(CC[10], row).setValue(element[11]);
			sheet.getCellAt(CC[11], row).setValue(element[12]);
			sheet.getCellAt(CC[12], row).setValue(element[13]);
			sheet.getCellAt(CC[13], row).setValue(element[14]);
			sheet.getCellAt(CC[14], row).setValue(element[15]);
			sheet.getCellAt(CC[15], row).setValue(element[16]);
			sheet.getCellAt(CC[16], row).setValue(element[17]);
			// 下段
			int lower = row + 1;
			sheet.getCellAt(CC[3], lower).setValue(element[18]);
			sheet.getCellAt(CC[4], lower).setValue(element[19]);
			sheet.getCellAt(CC[5], lower).setValue(element[20]);
			sheet.getCellAt(CC[7], lower).setValue(element[21]);
			sheet.getCellAt(CC[8], lower).setValue(element[22]);
			sheet.getCellAt(CC[9], lower).setValue(element[23]);
			sheet.getCellAt(CC[10], lower).setValue(element[24]);
			sheet.getCellAt(CC[11], lower).setValue(element[25]);
			sheet.getCellAt(CC[12], lower).setValue(element[26]);
			sheet.getCellAt(CC[13], lower).setValue(element[27]);
			sheet.getCellAt(CC[14], lower).setValue(element[28]);
			sheet.getCellAt(CC[15], lower).setValue(element[29]);
			row += 2;
		}
	}
	
	/**
	 * 総合計印刷メソッド
	 * @throws Exception   	例外処理が発生した場合
	 */
	private void printTotal() throws Exception {
		// 上段項目
		int upper = TOTAL_ROW;
		sheet.getCellAt(CC[2], upper).setValue(workDays);
		sheet.getCellAt(CC[4], upper).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalWork)));
		sheet.getCellAt(CC[5], upper).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalOver)));
		sheet.getCellAt(CC[6], upper).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalLateNight)));
		sheet.getCellAt(CC[7], upper).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalLate)));
		sheet.getCellAt(CC[9], upper).setValue(totalSyokuji);
		sheet.getCellAt(CC[10], upper).setValue(totalCyoku2);
		sheet.getCellAt(CC[11], upper).setValue(totalHoka1);
		sheet.getCellAt(CC[12], upper).setValue(totalHoka3);
		sheet.getCellAt(CC[13], upper).setValue(totalHoka5);
		sheet.getCellAt(CC[14], upper).setValue(totalSHankyu);
		sheet.getCellAt(CC[15], upper).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalVacation)));
		// 下段項目
		int lower = upper + 1;
		sheet.getCellAt(CC[4], lower).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalBreak)));
		sheet.getCellAt(CC[5], lower).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalHolidayWork)));
		sheet.getCellAt(CC[7], lower).setValue(getHourString(TimeUtil.convIntegerTimeToDoubleTime(totalLeaveEarly)));
		sheet.getCellAt(CC[9], lower).setValue(totalCyoku1);
		sheet.getCellAt(CC[10], lower).setValue(totalCyoku3);
		sheet.getCellAt(CC[11], lower).setValue(totalHoka2);
		sheet.getCellAt(CC[12], lower).setValue(totalHoka4);
		sheet.getCellAt(CC[13], lower).setValue(totalHourVacation);
		sheet.getCellAt(CC[14], lower).setValue(totalTHankyu);
	}
	
	/**
	 * 日集計データ配列作成
	 * @throws Exception   	例外処理が発生した場合
	 */
	private void makeAttendance() throws Exception {
		int localTotalVacation;
		// 勤怠月一覧データ取得 
		getAttendanceList(kCode, targetMonth);
		// データ数取得
		Calendar cal = Calendar.getInstance();
		cal.setTime(MospUtility.getDate(startDate));
		int count = 0;
		while (MospUtility.getDate(endDate).compareTo(cal.getTime()) >= 0) {
			cal.add(Calendar.DAY_OF_MONTH, 1);
			count++;
		}
		// 配列初期化
		final int childSize = 40;
		aryAttendance = StringUtil.getBlankArray(count, childSize);
		// 日付設定
		cal.setTime(MospUtility.getDate(startDate));
		for (int i = 0; i < aryAttendance.length; i++) {
			// 日付（検索用）
			aryAttendance[i][0] = MospUtility.getDateString(cal.getTime(), CommonConst.FORMAT_DATE);
			// 日付
			aryAttendance[i][1] = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
			// 曜日
			aryAttendance[i][2] = getDayOfWeek(cal.get(Calendar.DAY_OF_WEEK));
			cal.add(Calendar.DAY_OF_MONTH, 1);
		}
		// データの設定
		Iterator<MSyukkinboDto> it = attendanceList.iterator();
		while (it.hasNext()) {
			cal.setTime(MospUtility.getDate(startDate));
			MSyukkinboDto dto = it.next();
			Date attendanceDate = MospUtility.getDate(dto.getHizuke());
			for (int i = 0; i < aryAttendance.length; i++) {
				if (attendanceDate.compareTo(cal.getTime()) == 0) {
					// 勤務形態
					if (KintaiCommonPart.isAvailableWorkType(dto)) {
						aryAttendance[i][4] = dto.getSyJikoku();
						aryAttendance[i][5] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(dto.getKinmuJi()));
						aryAttendance[i][6] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(dto.getZaJikan()));
						aryAttendance[i][7] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(dto.getSnJikan()));
						aryAttendance[i][8] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(dto.getTiJikan()));
						aryAttendance[i][9] = part().mospcode().getTName(CommonConst.TID_LATE_REASON, dto.getTiRiyuu());
						aryAttendance[i][10] = String.valueOf(dto.getSyokuji());
						aryAttendance[i][11] = String.valueOf(dto.getCyoku2());
						aryAttendance[i][12] = String.valueOf(dto.getHoka1());
						aryAttendance[i][13] = String.valueOf(dto.getHoka3());
						aryAttendance[i][14] = String.valueOf(dto.getHoka5());
						if (KintaiCommonPart.isStartHalfHoliday(dto) || KintaiCommonPart.isOverTimeSubHolidayStart(dto)) {
							aryAttendance[i][15] = "1";
							totalSHankyu++;
						}
						aryAttendance[i][18] = dto.getTaJikoku();
						aryAttendance[i][19] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(dto.getKyukeiJi()));
						aryAttendance[i][20] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(dto.getKsJikan()));
						aryAttendance[i][21] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(dto.getSoJikan()));
						aryAttendance[i][22] = part().mospcode().getTName(CommonConst.TID_LEAVE_EARLY_REASON,
								dto.getSoRiyuu());
						aryAttendance[i][23] = String.valueOf(dto.getCyoku1());
						aryAttendance[i][24] = String.valueOf(dto.getCyoku3());
						aryAttendance[i][25] = String.valueOf(dto.getHoka2());
						aryAttendance[i][26] = String.valueOf(dto.getHoka4());
						aryAttendance[i][27] = String.valueOf(dto.getNijiKyu()
								* part().mospcode().getHourPaidHolidayUnit());
						if (KintaiCommonPart.isQuitHalfHoliday(dto) || KintaiCommonPart.isOverTimeSubHolidayQuit(dto)) {
							aryAttendance[i][28] = "1";
							totalTHankyu++;
						}
						totalWork += dto.getKinmuJi();
						totalOver += dto.getZaJikan();
						totalLateNight += dto.getSnJikan();
						totalLate += dto.getTiJikan();
						totalBreak += dto.getKyukeiJi();
						totalHolidayWork += dto.getKsJikan();
						totalLeaveEarly += dto.getSoJikan();
						totalSyokuji += dto.getSyokuji();
						totalCyoku1 += dto.getCyoku1();
						totalCyoku2 += dto.getCyoku2();
						totalCyoku3 += dto.getCyoku3();
						totalHoka1 += dto.getHoka1();
						totalHoka2 += dto.getHoka2();
						totalHoka3 += dto.getHoka3();
						totalHoka4 += dto.getHoka4();
						totalHoka5 += dto.getHoka5();
						totalHourVacation += dto.getNijiKyu() * part().mospcode().getHourPaidHolidayUnit();
						workDays++;
					}
					// 休暇時間
					localTotalVacation = 0;
					totalVacation += dto.getKKJikan();
					localTotalVacation += dto.getKKJikan();
					/* 半休を取得していた場合もtotalVacationへ加算する */
					if (KintaiCommonPart.isStartHalfHoliday(dto) || KintaiCommonPart.isOverTimeSubHolidayStart(dto)) {
						totalVacation += kintai().getHalfHolidayTimes();
						localTotalVacation += kintai().getHalfHolidayTimes();
					}
					if (KintaiCommonPart.isQuitHalfHoliday(dto) || KintaiCommonPart.isOverTimeSubHolidayQuit(dto)) {
						totalVacation += kintai().getHalfHolidayTimes();
						localTotalVacation += kintai().getHalfHolidayTimes();
					}
					aryAttendance[i][16] = getHourString(TimeUtil.convIntegerTimeToDoubleTime(localTotalVacation));
					// 勤務形態名称
					String workTypeName = "";
					if (KintaiCommonPart.isOfficialHoliday(dto)) {
						// 法定休日→法休
						workTypeName = CommonConst.NAM_OFFICIAL_HOLIDAY_SHORT;
					} else if (KintaiCommonPart.isWeekHoliday(dto)) {
						// 所定休日→所休
						workTypeName = CommonConst.NAM_STANDARD_WEEK_HOLIDAY_SHORT;
					} else {
						workTypeName = part().worktype().getWorkTypeName(dto.getKinmu());
					}
					aryAttendance[i][3] = workTypeName;
					// 休暇理由
					aryAttendance[i][17] = part().mospcode().getHolidayName(dto.getKKRiyuu());
					// 代休充当日
					aryAttendance[i][29] = dto.getDaiKyuJyu();
					break;
				}
				cal.add(Calendar.DAY_OF_MONTH, 1);
			}
		}
	}
	
}
