package com.yunyan.business.document.y23.finalData;

import cn.hutool.core.date.DateUtil;
import com.yunyan.business.constant.TemplateEpType;
import com.yunyan.business.document.WordGeneratorUtils;
import com.yunyan.business.document.common.constant.TemplateFilePathConstants;
import com.yunyan.business.document.y22.pojo.finalExcelY22.FinalExcelDataVo;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

@Slf4j
public class FinalUtils {

    private static final String BASE_FILE_URL = "F:\\out\\决算\\";
    private static final String TARGET_BASE = "f:\\out\\word\\决算\\output";


    @SneakyThrows
    private static void final2023Gp() {
        String deptName = "桂平市财政局";
        String templateExportType = TemplateEpType.Y2023FT5GP.getCode();
        String templatePath = TemplateFilePathConstants.TEMPLATE_WORD_Y2023FT5GP;
        String fileName1 = BASE_FILE_URL + "23桂平\\"+ deptName + ".23.xlsx";
        String fileName2 = BASE_FILE_URL + "23桂平\\"+ deptName + ".22.xlsx";

        testBaseFinal(deptName, templateExportType, templatePath, fileName1, fileName2, "2023");
    }

    /**
     * 生成的 结算文档的 基础
     * @param deptName
     * @param templateExportType
     * @param templatePath
     * @param fileName1
     * @param fileName2
     */
    @SneakyThrows
    private static void testBaseFinal(String deptName, String templateExportType, String templatePath, String fileName1, String fileName2, String year) {
        FinalExcelDataVo dataVo = ReadFinalExcelY23Utils.getFinalExcelDataVo(year, deptName, templateExportType);
        ReadFinalExcelY23Utils.getSheetInfos(null, fileName1, dataVo, 0,  templateExportType);
        FinalExcelDataVo excelDataLastYearVo = ReadFinalExcelY23Utils.getFinalExcelDataVo(year, deptName, templateExportType);
        ReadFinalExcelY23Utils.getSheetInfos(null, fileName2, excelDataLastYearVo, 1,  templateExportType);
        FinalY23CompareLastUtils.compareData(dataVo, excelDataLastYearVo);

        //使用模板和上下文生成Word文档
        String dstr = DateUtil.formatDateTime(new Date()).replace(" ", "").replace(":", "") + "." + deptName;
        String targetWordFileName = TARGET_BASE + dstr + ".docx";
        WordGeneratorUtils.generatorWord(dataVo, targetWordFileName, templatePath);
    }

}
