package jp.mosp.payroll.payment.action;

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

import jp.mosp.common.CommonConst;
import jp.mosp.common.common.BaseVo;
import jp.mosp.common.common.MospConst;
import jp.mosp.common.common.MospException;
import jp.mosp.common.common.PoiUtility;
import jp.mosp.common.utils.StringUtil;
import jp.mosp.payroll.base.PayrollAction;
import jp.mosp.payroll.base.PayrollConst;
import jp.mosp.payroll.dao.CmCompanyDao;
import jp.mosp.payroll.dao.ResidenceTaxDao;
import jp.mosp.payroll.dto.CmCompanyDto;
import jp.mosp.payroll.dto.ResidenceTaxDto;
import jp.mosp.payroll.payment.vo.PaymentReportVo;

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

/**
 * @author koike
 *
 */
public class ResidenceTaxListAction extends PayrollAction {
	
	//コマンド
	private static final String	CMD_RESID_TAX_PERSON	= "P9018";
	private static final String	CMD_RESID_TAX_COMPANY	= "P9019";
	
	private Date				sysDate;
	

	/**
	 * コンストラクタ
	 */
	public ResidenceTaxListAction() {
		super();
		setNeedProcSeq(false);
	}
	
	/* (non-Javadoc)
	 * @see jp.mosp.common.common.BaseAction#getSpecificVo()
	 */
	@Override
	protected BaseVo getSpecificVo() {
		return new PaymentReportVo();
	}
	
	/**
	 * アクション。<br>
	 * 詳細は、クラス説明を参照。<br>
	 */
	public void action() throws Exception {
		//VO取得及び設定
		prepareVo();
		
		//帳票出力日付取得
		sysDate = getSystemDate();
		
		if (cmd.equals(CMD_RESID_TAX_PERSON)) {
			personTax();
		} else if (cmd.equals(CMD_RESID_TAX_COMPANY)) {
			companyTax();
		} else {
			throw new MospException(MospConst.EX_CMD_INVALID);
		}
		
	}
	
	/**
	 * 住民税一覧表作成(住民税人別)
	 * @throws Exception 例外処理が発生した場合
	 */
	private void personTax() throws Exception {
		//DBコネクション取得
		getConnection();
		//PAYROLL権限確認
		confirmPayrollAuth();
		// VO取得
		PaymentReportVo vo = (PaymentReportVo)getVo();
		//パラメータ取得
		vo.setParams(request);
		//対象年月取得
		Date date = vo.getDate(String.valueOf(vo.getPltOutYear()), String.valueOf(vo.getPltOutMonth()), String
			.valueOf(PayrollConst.TIME_DEFAULT_DAY));
		
		//住民税データ取得
		ResidenceTaxDao dao = new ResidenceTaxDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		List<ResidenceTaxDto> list = dao.findForCondition(date);
		//DAO準備
		CmCompanyDao cmCompanyDao = new CmCompanyDao();
		cmCompanyDao.initDao(cfg, cmd, aspUser, user, conn);
		// DTO準備
		CmCompanyDto dto;
		dto = cmCompanyDao.findAll();
		if (StringUtil.isNotNull(cfg.getProperty(CommonConst.PPT_KINTAI_USE_ODF))) {
			//ODS
			makeAttendanceBookOds(list, vo, date, dto);
		} else {
			//XLS
			makeAttendanceBook(list, vo, date, dto);
		}
		
	}
	
	/**
	 * 住民税一覧表作成(住民税市町村別)
	 * @throws Exception 例外処理が発生した場合
	 */
	private void companyTax() throws Exception {
		//DBコネクション取得
		getConnection();
		//PAYROLL権限確認
		confirmPayrollAuth();
		// VO取得
		PaymentReportVo vo = (PaymentReportVo)getVo();
		//パラメータ取得
		vo.setParams(request);
		//対象年月取得
		Date date = vo.getDate(String.valueOf(vo.getPltOutYear()), String.valueOf(vo.getPltOutMonth()), String
			.valueOf(PayrollConst.TIME_DEFAULT_DAY));
		//住民税データ取得
		ResidenceTaxDao dao = new ResidenceTaxDao();
		dao.initDao(cfg, cmd, aspUser, user, conn);
		List<ResidenceTaxDto> list = dao.findForCondition(date);
		//DAO準備
		CmCompanyDao cmCompanyDao = new CmCompanyDao();
		cmCompanyDao.initDao(cfg, cmd, aspUser, user, conn);
		// DTO準備
		CmCompanyDto dto;
		dto = cmCompanyDao.findAll();
		if (StringUtil.isNotNull(cfg.getProperty(CommonConst.PPT_KINTAI_USE_ODF))) {
			//ODS
			makeAttendanceBook2Ods(list, vo, date, dto);
		} else {
			//XLS
			makeAttendanceBook2(list, vo, date, dto);
		}
	}
	
	/**
	 * 住民税一覧表作成(住民税人別)XLS
	 * @param dtolist 
	 * @param vo 対象VO
	 * @param date 
	 * @param companyDto 
	 * @throws Exception 例外処理が発生した場合
	 */
	private void makeAttendanceBook(List<ResidenceTaxDto> dtolist, PaymentReportVo vo, Date date,
			CmCompanyDto companyDto) throws Exception {
		String cityCodeOld = "";
		String cityCodeNew = "";
		int subCnt = 0;
		int subTotalAmo = 0;
		int totalAmo = 0;
		int totalCnt = 0;
		int printDataRow = 7;
		//帳票作成準備
		PoiUtility poi = new PoiUtility();
		poi.crtNewDocR(0, cfg.getProperty(MospConst.PPT_APP_DOCBASE) + PayrollConst.TEMPLATE_RES_TAX_PARSON_LIST);
		//フォント設定の為の初期化処理
		poi.createCellStyleAndFont();
		setStyle(poi, true, false);
		//ヘッダー情報設定
		poi.prtItem(1, 0, jpnYM(date, vo) + PayrollConst.NAM_PAYMENT_TARGET);
		poi.prtItem(3, 1, companyDto.getCompanyName());
		poi.prtItem(3, 5, jpnYMD(sysDate, vo));
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					printDataRow++;
					poi.prtItem(printDataRow, 3, PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  "
							+ subCnt + PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
					setStyle(poi, false, true);
					printDataRow++;
					totalCnt = totalCnt + subCnt;
					subCnt = 0;
				}
				printDataRow++;
				poi.prtItem(printDataRow, 1, PayrollConst.BRACKET_LEFT2 + dto.getPaymentCityCode()
						+ PayrollConst.BRACKET_RIGHT2);
				setStyle(poi, false, true);
				poi.prtItem(printDataRow, 3, dto.getCityName());
				setStyle(poi, false, true);
				printDataRow++;
			}
			
			poi.prtItem(printDataRow, 1, dto.getKCode());
			setStyle(poi, false, true);
			poi.prtItem(printDataRow, 3, dto.getKName());
			setStyle(poi, false, true);
			printDataRow++;
			subCnt++;
			cityCodeOld = cityCodeNew;
		}
		if (dtolist.size() != 0) {
			printDataRow++;
			totalCnt = totalCnt + subCnt;
			poi.prtItem(printDataRow, 3, PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  " + subCnt
					+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
			setStyle(poi, false, true);
			printDataRow++;
			printDataRow++;
			poi.prtItem(printDataRow, 3, PayrollConst.BRACKET_LEFT + PayrollConst.NAM_COMMON_SUM + "  " + totalCnt
					+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
			setStyle(poi, false, true);
			
		}
		
		//金額の設定
		setStyle(poi, true, false);
		printDataRow = 9;
		
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					printDataRow++;
					poi.prtBorderTop(printDataRow, 5);
					poi.prtItem(printDataRow, 5, insertComma(String.valueOf(subTotalAmo)));
					setStyle(poi, false, false);
					setStyle(poi, true, false);
					printDataRow = printDataRow + 3;
					totalAmo = totalAmo + subTotalAmo;
					subTotalAmo = 0;
				}
			}
			poi.prtItem(printDataRow, 5, insertComma(String.valueOf(dto.getResidenceTax())));
			setStyle(poi, false, false);
			subTotalAmo = subTotalAmo + dto.getResidenceTax();
			printDataRow++;
			cityCodeOld = cityCodeNew;
		}
		
		if (dtolist.size() != 0) {
			printDataRow++;
			totalAmo = totalAmo + subTotalAmo;
			poi.prtBorderTop(printDataRow, 5);
			poi.prtItem(printDataRow, 5, insertComma(String.valueOf(subTotalAmo)));
			setStyle(poi, false, false);
			printDataRow = printDataRow + 2;
			poi.prtBorderTop(printDataRow, 5);
			poi.prtItem(printDataRow, 5, insertComma(String.valueOf(totalAmo)));
			setStyle(poi, false, false);
		}
		String fileName = vo.getPltYear() + PayrollConst.FILE_NAME_SEPARATOR + vo.getPltMonth()
				+ PayrollConst.FILE_NAME_SEPARATOR + PayrollConst.FILE_RES_TAX_PARSON_LIST;
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName);
		request.setAttribute(MospConst.ATT_FILE_OBJECT, poi.getWorkbook());
	}
	
	/**
	 * 住民税一覧表作成(住民税人別)ODS
	 * @param dtolist 
	 * @param vo 対象VO
	 * @param date 
	 * @param companyDto 
	 * @throws Exception 例外処理が発生した場合
	 */
	private void makeAttendanceBookOds(List<ResidenceTaxDto> dtolist, PaymentReportVo vo, Date date,
			CmCompanyDto companyDto) throws Exception {
		String cityCodeOld = "";
		String cityCodeNew = "";
		int subCnt = 0;
		int subTotalAmo = 0;
		int totalAmo = 0;
		int totalCnt = 0;
		int printDataRow = 7;
		//テンプレートファイル
		StringBuffer sb = new StringBuffer();
		sb.append(cfg.getProperty(MospConst.PPT_APP_DOCBASE));
		sb.append(PayrollConst.TEMPLATE_RES_TAX_PARSON_LIST_ODS);
		//帳票作成
		SpreadSheet ss = SpreadSheet.createFromFile(new File(sb.toString()));
		//シート
		Sheet sheet = ss.getSheet(0);
		//ヘッダー情報設定
		sheet.getCellAt(0, 1).setValue(jpnYM(date, vo) + PayrollConst.NAM_PAYMENT_TARGET);
		sheet.getCellAt(1, 3).setValue(companyDto.getCompanyName());
		sheet.getCellAt(5, 3).setValue(jpnYMD(sysDate, vo));
		//罫線スタイルコードの取得
		String styleCodeBorderBotom = sheet.getCellAt(3, 3).getStyleName();
		//明細データの設定
		sheet.insertDuplicatedRows(sheet.getRowCount() - 1, 6000);
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					printDataRow = printDataRow + 2;
					sheet.getCellAt(3, printDataRow).setValue(
							PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  " + subCnt
									+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
					printDataRow++;
					totalCnt = totalCnt + subCnt;
					subCnt = 0;
				}
				printDataRow++;
				sheet.getCellAt(1, printDataRow).setValue(
						PayrollConst.BRACKET_LEFT2 + dto.getPaymentCityCode() + PayrollConst.BRACKET_RIGHT2);
				sheet.getCellAt(3, printDataRow).setValue(dto.getCityName());
				printDataRow++;
			}
			sheet.getCellAt(1, printDataRow).setValue(dto.getKCode());
			sheet.getCellAt(3, printDataRow).setValue(dto.getKName());
			printDataRow++;
			subCnt++;
			cityCodeOld = cityCodeNew;
		}
		if (dtolist.size() != 0) {
			printDataRow = printDataRow + 2;
			totalCnt = totalCnt + subCnt;
			sheet.getCellAt(3, printDataRow).setValue(
					PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  " + subCnt
							+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
			printDataRow = printDataRow + 2;
			sheet.getCellAt(3, printDataRow).setValue(
					PayrollConst.BRACKET_LEFT + PayrollConst.NAM_COMMON_SUM + "  " + totalCnt
							+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
			
		}
		//金額の設定
		printDataRow = 9;
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					printDataRow++;
					sheet.getCellAt(5, printDataRow).setStyleName(styleCodeBorderBotom);
					printDataRow++;
					sheet.getCellAt(5, printDataRow).setValue(insertComma(String.valueOf(subTotalAmo)));
					printDataRow = printDataRow + 3;
					totalAmo = totalAmo + subTotalAmo;
					subTotalAmo = 0;
				}
			}
			sheet.getCellAt(5, printDataRow).setValue(insertComma(String.valueOf(dto.getResidenceTax())));
			subTotalAmo = subTotalAmo + dto.getResidenceTax();
			printDataRow++;
			cityCodeOld = cityCodeNew;
		}
		
		if (dtolist.size() != 0) {
			totalAmo = totalAmo + subTotalAmo;
			printDataRow++;
			sheet.getCellAt(5, printDataRow).setStyleName(styleCodeBorderBotom);
			printDataRow++;
			sheet.getCellAt(5, printDataRow).setValue(insertComma(String.valueOf(subTotalAmo)));
			printDataRow++;
			sheet.getCellAt(5, printDataRow).setStyleName(styleCodeBorderBotom);
			printDataRow++;
			sheet.getCellAt(5, printDataRow).setValue(insertComma(String.valueOf(totalAmo)));
		}
		String fileName = vo.getPltYear() + PayrollConst.FILE_NAME_SEPARATOR + vo.getPltMonth()
				+ PayrollConst.FILE_NAME_SEPARATOR + PayrollConst.FILE_RES_TAX_PARSON_LIST_ODS;
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName);
		request.setAttribute(MospConst.ATT_FILE_OBJECT, ss);
	}
	
	/**
	 * 住民税一覧表作成(住民税市区町村別)
	 * @param dtolist 
	 * @param vo 対象VO
	 * @param date 
	 * @param companyDto 
	 * @throws Exception 例外処理が発生した場合
	 */
	private void makeAttendanceBook2(List<ResidenceTaxDto> dtolist, PaymentReportVo vo, Date date,
			CmCompanyDto companyDto) throws Exception {
		String cityCodeOld = "";
		String cityCodeNew = "";
		int subCnt = 0;
		int subTotalAmo = 0;
		int totalAmo = 0;
		int totalCnt = 0;
		int printDataRow = 7;
		//帳票作成準備
		PoiUtility poi = new PoiUtility();
		poi.crtNewDocR(0, cfg.getProperty(MospConst.PPT_APP_DOCBASE) + PayrollConst.TEMPLATE_RES_TAX_LIST);
		//フォント設定の為の初期化処理
		poi.createCellStyleAndFont();
		setStyle(poi, true, false);
		//ヘッダー情報設定
		poi.prtItem(1, 0, jpnYM(date, vo) + PayrollConst.NAM_PAYMENT_TARGET);
		poi.prtItem(3, 1, companyDto.getCompanyName());
		poi.prtItem(3, 5, jpnYMD(sysDate, vo));
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					printDataRow++;
					poi.prtItem(printDataRow, 3, PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  "
							+ subCnt + PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
					setStyle(poi, false, true);
					printDataRow++;
					totalCnt = totalCnt + subCnt;
					subCnt = 0;
				}
				printDataRow++;
				poi.prtItem(printDataRow, 1, PayrollConst.BRACKET_LEFT2 + dto.getPaymentCityCode()
						+ PayrollConst.BRACKET_RIGHT2);
				setStyle(poi, false, true);
				poi.prtItem(printDataRow, 3, dto.getCityName());
				setStyle(poi, false, true);
				printDataRow++;
			}
			//件数加算
			subCnt++;
			cityCodeOld = cityCodeNew;
		}
		if (dtolist.size() != 0) {
			printDataRow++;
			totalCnt = totalCnt + subCnt;
			poi.prtItem(printDataRow, 3, PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  " + subCnt
					+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
			setStyle(poi, false, true);
			printDataRow++;
			printDataRow++;
			poi.prtItem(printDataRow, 3, PayrollConst.BRACKET_LEFT + PayrollConst.NAM_COMMON_SUM + "  " + totalCnt
					+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
			setStyle(poi, false, true);
			
		}
		
		//金額の設定
		setStyle(poi, true, false);
		printDataRow = 10;
		
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					poi.prtItem(printDataRow, 5, insertComma(String.valueOf(subTotalAmo)));
					setStyle(poi, false, false);
					printDataRow = printDataRow + 4;
					setStyle(poi, true, false);
					totalAmo = totalAmo + subTotalAmo;
					subTotalAmo = 0;
				}
			}
			subTotalAmo = subTotalAmo + dto.getResidenceTax();
			cityCodeOld = cityCodeNew;
		}
		
		if (dtolist.size() != 0) {
			totalAmo = totalAmo + subTotalAmo;
			poi.prtItem(printDataRow, 5, insertComma(String.valueOf(subTotalAmo)));
			setStyle(poi, false, false);
			printDataRow = printDataRow + 2;
			poi.prtBorderTop(printDataRow, 5);
			poi.prtItem(printDataRow, 5, insertComma(String.valueOf(totalAmo)));
			setStyle(poi, false, false);
		}
		String fileName = vo.getPltYear() + PayrollConst.FILE_NAME_SEPARATOR + vo.getPltMonth()
				+ PayrollConst.FILE_NAME_SEPARATOR + PayrollConst.FILE_RES_TAX_LIST;
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName);
		request.setAttribute(MospConst.ATT_FILE_OBJECT, poi.getWorkbook());
	}
	
	/**
	 * 住民税一覧表作成(住民税市区町村別)
	 * @param dtolist 
	 * @param vo 対象VO
	 * @param date 
	 * @param companyDto 
	 * @throws Exception 例外処理が発生した場合
	 */
	private void makeAttendanceBook2Ods(List<ResidenceTaxDto> dtolist, PaymentReportVo vo, Date date,
			CmCompanyDto companyDto) throws Exception {
		String cityCodeOld = "";
		String cityCodeNew = "";
		int subCnt = 0;
		int subTotalAmo = 0;
		int totalAmo = 0;
		int totalCnt = 0;
		int printDataRow = 7;
		//テンプレートファイル
		StringBuffer sb = new StringBuffer();
		sb.append(cfg.getProperty(MospConst.PPT_APP_DOCBASE));
		sb.append(PayrollConst.TEMPLATE_RES_TAX_LIST_ODS);
		//帳票作成
		SpreadSheet ss = SpreadSheet.createFromFile(new File(sb.toString()));
		//シート
		Sheet sheet = ss.getSheet(0);
		//ヘッダー情報設定
		sheet.getCellAt(0, 1).setValue(jpnYM(date, vo) + PayrollConst.NAM_PAYMENT_TARGET);
		sheet.getCellAt(1, 3).setValue(companyDto.getCompanyName());
		sheet.getCellAt(5, 3).setValue(jpnYMD(sysDate, vo));
		//罫線スタイルコードの取得
		String styleCodeBorderBotom = sheet.getCellAt(3, 3).getStyleName();
		//明細データの設定
		sheet.insertDuplicatedRows(sheet.getRowCount() - 1, 6000);
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					printDataRow++;
					sheet.getCellAt(3, printDataRow).setValue(
							PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  " + subCnt
									+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
					printDataRow++;
					totalCnt = totalCnt + subCnt;
					subCnt = 0;
				}
				printDataRow++;
				sheet.getCellAt(1, printDataRow).setValue(
						PayrollConst.BRACKET_LEFT2 + dto.getPaymentCityCode() + PayrollConst.BRACKET_RIGHT2);
				sheet.getCellAt(3, printDataRow).setValue(dto.getCityName());
				printDataRow++;
			}
			//件数加算
			subCnt++;
			cityCodeOld = cityCodeNew;
		}
		if (dtolist.size() != 0) {
			printDataRow++;
			totalCnt = totalCnt + subCnt;
			sheet.getCellAt(3, printDataRow).setValue(
					PayrollConst.BRACKET_LEFT + PayrollConst.NAM_CITY_PARSON_TOTAL + "  " + subCnt
							+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
			printDataRow++;
			printDataRow++;
			sheet.getCellAt(3, printDataRow).setValue(
					PayrollConst.BRACKET_LEFT + PayrollConst.NAM_COMMON_SUM + "  " + totalCnt
							+ PayrollConst.NAM_COMMON_NAME + PayrollConst.BRACKET_RIGHT);
		}
		
		//金額の設定
		printDataRow = 10;
		
		for (int i = 0; i < dtolist.size(); i++) {
			ResidenceTaxDto dto = dtolist.get(i);
			cityCodeNew = dto.getPaymentCityCode();
			if (!cityCodeNew.equals(cityCodeOld)) {
				if (i != 0) {
					sheet.getCellAt(5, printDataRow).setValue(insertComma(String.valueOf(subTotalAmo)));
					printDataRow = printDataRow + 3;
					totalAmo = totalAmo + subTotalAmo;
					subTotalAmo = 0;
				}
			}
			subTotalAmo = subTotalAmo + dto.getResidenceTax();
			cityCodeOld = cityCodeNew;
		}
		
		if (dtolist.size() != 0) {
			totalAmo = totalAmo + subTotalAmo;
			sheet.getCellAt(5, printDataRow).setValue(insertComma(String.valueOf(subTotalAmo)));
			printDataRow = printDataRow + 2;
			sheet.getCellAt(5, printDataRow).setStyleName(styleCodeBorderBotom);
			printDataRow++;
			sheet.getCellAt(5, printDataRow).setValue(insertComma(String.valueOf(totalAmo)));
		}
		String fileName = vo.getPltYear() + PayrollConst.FILE_NAME_SEPARATOR + vo.getPltMonth()
				+ PayrollConst.FILE_NAME_SEPARATOR + PayrollConst.FILE_RES_TAX_LIST_ODS;
		request.setAttribute(MospConst.ATT_FILE_NAME, fileName);
		request.setAttribute(MospConst.ATT_FILE_OBJECT, ss);
	}
	
	/**
	 * セルフォント・スタイル設定 
	 * @param poi PoiUtility
	 * @param styleFlg スタイル初期化フラグ
	 * @param halignFlg 左右揃え判定フラグ
	 */
	private void setStyle(PoiUtility poi, boolean styleFlg, boolean halignFlg) {
		int fontSize = 13;
		//フォント設定の為の初期化処理
		if (styleFlg == true) {
			poi.createCellStyle();
		} else {
			poi.setFontType(PoiUtility.MS_MINTYO);
			poi.setFontSize(fontSize);
			if (halignFlg == true) {
				poi.setFontHAlignLeft();
			} else {
				poi.setFontHAlignRight();
			}
			poi.reflectCellStyle();
		}
		
	}
	
}
