package com.yunyan.business.service.impl;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunyan.business.constant.BusinessCacheConstants;
import com.yunyan.business.constant.FinalDataStatus;
import com.yunyan.business.document.templateEpStrategy.AnnotationTplStrategyFactory;
import com.yunyan.business.document.templateEpStrategy.TplStrategy;
import com.yunyan.business.document.y22.FinalY22CompareLastUtils;
import com.yunyan.business.document.y22.FinalY22Utils;
import com.yunyan.business.document.y22.ReadFinalExcelY22Utils;
import com.yunyan.business.document.y22.pojo.finalExcelY22.*;
import com.yunyan.business.domain.FinalData;
import com.yunyan.business.domain.ReportDept;
import com.yunyan.business.domain.ReportExplain;
import com.yunyan.business.mapper.FinalDataMapper;
import com.yunyan.business.service.*;
import com.yunyan.common.config.YunYanConfig;
import com.yunyan.common.constant.Constants;
import com.yunyan.common.core.domain.AjaxResultVo;
import com.yunyan.common.core.redis.RedisCache;
import com.yunyan.common.exception.ServiceException;
import com.yunyan.common.utils.StringUtils;
import com.yunyan.common.utils.spring.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * 报告数据Service业务层处理
 *
 * @author yunyan
 * @date 2023-07-27
 */
@Slf4j
@Service
public class FinalDataUpdateDataServiceImpl extends ServiceImpl<FinalDataMapper, FinalData> implements IFinalDataUpdateDataService
{
    @Autowired
    private IFinalDataService finalDataService;

    @Autowired
    private RedisCache redisCache;

    @Autowired
    private IReportDeptService reportDeptService;

    @Autowired
    private IReportExplainService reportExplainService;

    @Autowired
    private ISyncService syncService;

    @Autowired
    private FinalDataMapper finalDataMapper;


    //@Transactional(rollbackFor = Exception.class)
    @Override
    public void finalDataUpdateData() {

        List<FinalData> list = lambdaQuery().select(FinalData::getId).eq(FinalData::getId, 11239).list();

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    //finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getJsonLastYearContent).eq(FinalData::getId, finalData.getId()).one();

                    //json数据
                    //FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);
                    /*FinalExcelDataVo finalExcelDataVo = new FinalExcelDataVo();

                    FinalY22CompareLastUtils.compareDataP3T3Budget(finalExcelDataVo, "桂平");


                    //FinalExcelDataVo excelLastYearData = JSONUtil.toBean(finalData.getJsonLastYearContent(), FinalExcelDataVo.class);
                    FinalExcelDataVo excelLastYearData = new FinalExcelDataVo();

                    FinalY22CompareLastUtils.compareP3T1Set(finalExcelDataVo, excelLastYearData);

                    String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


                    //更新 保存 去年的 excel数据
                    FinalData updateEntity = new FinalData();
                    updateEntity.setId(finalData.getId());
                    //保存去年的对比数据
                    //updateEntity.setJsonTableContent(jsonTableContent);

                    //updateList.add(updateEntity);
                    //保存去年的 excel数据

                    this.updateById(updateEntity);*/

                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }



        /*for (FinalData finalData : list) {

            //json数据
            FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);

            FinalY22CompareLastUtils.compareDataP3T3Budget(finalExcelDataVo, "桂平");

            String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


            //更新 保存 去年的 excel数据
            FinalData updateEntity = new FinalData();
            updateEntity.setId(finalData.getId());
            //保存去年的对比数据
            //updateEntity.setJsonTableContent(jsonTableContent);

            //updateList.add(updateEntity);
            //保存去年的 excel数据

            this.updateById(updateEntity);

        }*/

/*        if(!updateList.isEmpty()) {
            boolean res = this.updateBatchById(updateList);
            log.debug("res [{}]", res);
        }*/

    }

    @Override
    public void finalDataUpdateDataFromExcel() {
        List<FinalData> list = lambdaQuery().select(FinalData::getId).eq(FinalData::getId, 11239).list();

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {
                        /*finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl).eq(FinalData::getId, finalData.getId()).one();

                        String fileName = finalData.getExcelUrl();
                        String absolutePathName = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
                        FinalExcelDataVo finalExcelForCompareDataVo = ReadFinalExcelY22Utils.getSheetInfos(null, absolutePathName, 1);

                        //json数据
                        //FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);
                        FinalExcelDataVo finalExcelDataVo = new FinalExcelDataVo();

                        //设置 p2p2 head
                        FinalY22CompareLastUtils.setP2p2HeadData(finalExcelDataVo, finalExcelForCompareDataVo);


                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


                        //更新 保存 去年的 excel数据
                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据
                        //updateEntity.setJsonTableContent(jsonTableContent);

                        //updateList.add(updateEntity);
                        //保存去年的 excel数据

                        this.updateById(updateEntity);*/
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }
    }

    @Override
    public void finalDataUpdateDataTerm() {
        List<FinalData> list = lambdaQuery().select(FinalData::getId).list(); //.eq(FinalData::getId, 11786)

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {
                        /*finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl).eq(FinalData::getId, finalData.getId()).one();

                        *//*String fileName = finalData.getExcelUrl();
                        String absolutePathName = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
                        FinalExcelDataVo finalExcelForCompareDataVo = ReadFinalExcelY22Utils.getSheetInfos(null, absolutePathName, 1);*//*

                        //json数据
                        //FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);
                        FinalExcelDataVo finalExcelDataVo = new FinalExcelDataVo();

                        if(null == finalExcelDataVo.getTermList() || finalExcelDataVo.getTermList().isEmpty()) {
                            continue;
                        }

                        //设置 p2p2 head
                        //FinalY22CompareLastUtils.setP2p2HeadData(finalExcelDataVo, finalExcelForCompareDataVo);

                        //更新 名词解释的 句号问题 , 去掉 最后一个的句号
                        for(FinalP4T1TermVo p4T1TermVo : finalExcelDataVo.getTermList() ) {
                            String info = p4T1TermVo.getInfo();
                            if(info.charAt(info.length()-1) == '。') { //s.length()-1获取字符串最后一位字符的索引，传入charAt方法获取索引对应的字符，判断是否为句号
                                info = info.substring(0, info.length()-1); //若为句号，则通过substring截取需要的值
                                p4T1TermVo.setInfo(info);
                            }
                        }


                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


                        //更新 保存 去年的 excel数据
                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据
                        //updateEntity.setJsonTableContent(jsonTableContent);
                        //TODO 更新 PDF 以及 删除
                        updateEntity.setPdfUrl("");
                        updateEntity.setJsonFileContent("");

                        //updateList.add(updateEntity);
                        //保存去年的 excel数据

                        this.updateById(updateEntity);*/
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }
    }

    @Override
    public void finalDataUpdateDataDeptInfo() {
        List<FinalData> list = lambdaQuery().select(FinalData::getId).list(); //.eq(FinalData::getId, 11790)

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {
                        /*finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl).eq(FinalData::getId, finalData.getId()).one();

                        //json数据
                        //FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);
                        FinalExcelDataVo finalExcelDataVo = new FinalExcelDataVo();

                        if(null == finalExcelDataVo.getP1Vo() || StringUtils.isBlank(finalExcelDataVo.getP1Vo().getSettings())) {
                            continue;
                        }

                        boolean changeFlag =  false;
                        String settings = finalExcelDataVo.getP1Vo().getSettings();
                        //内设机构无个：。
                        if( StringUtils.isNotBlank(settings) && settings.contains("内设机构无个：。")) {
                            settings = settings.replace("内设机构无个：。", "内设机构0个。");
                            changeFlag = true;
                        }
                        if( StringUtils.isNotBlank(settings) && settings.contains("内设机构0个：。")) {
                            settings = settings.replace("内设机构0个：。", "内设机构0个。");
                            changeFlag = true;
                        }
                        if( StringUtils.isNotBlank(settings) && settings.contains("内设机构0个：无。")) {
                            settings = settings.replace("内设机构0个：无。", "内设机构0个。");
                            changeFlag = true;
                        }

                        if(!changeFlag) {
                            continue;
                        }

                        finalExcelDataVo.getP1Vo().setSettings(settings);

                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


                        //更新 保存 去年的 excel数据
                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据
                        //updateEntity.setJsonTableContent(jsonTableContent);
                        //TODO 更新 PDF 以及 删除
                        updateEntity.setPdfUrl("");
                        updateEntity.setJsonFileContent("");

                        //updateList.add(updateEntity);
                        //保存去年的 excel数据

                        this.updateById(updateEntity);*/
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }
    }

    @Override
    public void finalDataUpdateDataDefaultF03() {
        List<FinalData> list = lambdaQuery().select(FinalData::getId)//.eq(FinalData::getId, 14619)
                .list(); //.eq(FinalData::getId, 14673)

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        final String[] deptNameStr = {""};

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {
                        //finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl, FinalData::getExcelDeptName).eq(FinalData::getId, finalData.getId()).one();

                        //json数据
                        //FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);
                        FinalExcelDataVo finalExcelDataVo = new FinalExcelDataVo();

                        /*FinalP3T6Vo p3T6Vo = finalExcelDataVo.getP3T6Vo();
                        if(StringUtils.isBlank(p3T6Vo.getExpenditureTotal())) {
                            p3T6Vo.setExpenditureTotal("0.00");
                            deptNameStr[0] += finalData.getId() + " : " + finalData.getExcelDeptName() + "\n";
                        }
                        if(StringUtils.isBlank(p3T6Vo.getExpenditureBegin())) {
                            p3T6Vo.setExpenditureBegin("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getExpenditureTotalLastYear())) {
                            p3T6Vo.setExpenditureTotalLastYear("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getAbroad())) {
                            p3T6Vo.setAbroad("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarSubtotal())) {
                            p3T6Vo.setCarSubtotal("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getReception())) {
                            p3T6Vo.setReception("0.00");
                        }


                        if(StringUtils.isBlank(p3T6Vo.getAbroadVo().getExpenditure())) {
                            p3T6Vo.getAbroadVo().setExpenditure("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getAbroadVo().getBeginValue())) {
                            p3T6Vo.getAbroadVo().setBeginValue("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getAbroadVo().getExpenditureLastYear())) {
                            p3T6Vo.getAbroadVo().setExpenditureLastYear("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getAbroadVo().getDeptGroupNum())) {
                            p3T6Vo.getAbroadVo().setDeptGroupNum("0");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getAbroadVo().getPersonNum())) {
                            p3T6Vo.getAbroadVo().setPersonNum("0");
                        }

                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarSubtotal())) {
                            p3T6Vo.getCarVo().setCarSubtotal("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarBuyExpenditure())) {
                            p3T6Vo.getCarVo().setCarBuyExpenditure("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarBuyBeginValue())) {
                            p3T6Vo.getCarVo().setCarBuyBeginValue("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarBuyExpenditureLastYear())) {
                            p3T6Vo.getCarVo().setCarBuyExpenditureLastYear("0.00");
                        }

                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarOperateExpenditure())) {
                            p3T6Vo.getCarVo().setCarOperateExpenditure("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarOperateBeginValue())) {
                            p3T6Vo.getCarVo().setCarOperateBeginValue("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarOperateExpenditureLastYear())) {
                            p3T6Vo.getCarVo().setCarOperateExpenditureLastYear("0.00");
                        }

                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarNum())) {
                            p3T6Vo.getCarVo().setCarNum("0");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarOperateYear())) {
                            p3T6Vo.getCarVo().setCarOperateYear("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getCarVo().getCarOperateEach())) {
                            p3T6Vo.getCarVo().setCarOperateEach("0.00");
                        }


                        if(StringUtils.isBlank(p3T6Vo.getReceptiondVo().getExpenditure())) {
                            p3T6Vo.getReceptiondVo().setExpenditure("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getReceptiondVo().getBeginValue())) {
                            p3T6Vo.getReceptiondVo().setBeginValue("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getReceptiondVo().getExpenditureLastYear())) {
                            p3T6Vo.getReceptiondVo().setExpenditureLastYear("0.00");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getReceptiondVo().getInBatch())) {
                            p3T6Vo.getReceptiondVo().setInBatch("0");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getReceptiondVo().getInPersonNum())) {
                            p3T6Vo.getReceptiondVo().setInPersonNum("0");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getReceptiondVo().getOutBatch())) {
                            p3T6Vo.getReceptiondVo().setOutBatch("0");
                        }
                        if(StringUtils.isBlank(p3T6Vo.getReceptiondVo().getOutPersonNum())) {
                            p3T6Vo.getReceptiondVo().setOutPersonNum("0");
                        }*/

                        FinalP3T7Vo p3T7Vo = finalExcelDataVo.getP3T7Vo();
                        FinalP3T7ItemGovBuyVo p3T7ItemGovBuyVo = p3T7Vo.getGovBuyVo();
                        if(StringUtils.isBlank(p3T7ItemGovBuyVo.getTotal())) {
                            p3T7ItemGovBuyVo.setTotal("0.00");
                            //deptNameStr[0] += finalData.getId() + " : " + finalData.getExcelDeptName() + "\n";
                        }
                        if(StringUtils.isBlank(p3T7ItemGovBuyVo.getProduct())) {
                            p3T7ItemGovBuyVo.setProduct("0.00");
                        }
                        if(StringUtils.isBlank(p3T7ItemGovBuyVo.getProject())) {
                            p3T7ItemGovBuyVo.setProject("0.00");
                        }
                        if(StringUtils.isBlank(p3T7ItemGovBuyVo.getService())) {
                            p3T7ItemGovBuyVo.setService("0.00");
                        }
                        if(StringUtils.isBlank(p3T7ItemGovBuyVo.getMedium())) {
                            p3T7ItemGovBuyVo.setMedium("0.00");
                        }
                        if(StringUtils.isBlank(p3T7ItemGovBuyVo.getSmall())) {
                            p3T7ItemGovBuyVo.setSmall("0.00");
                        }
                        //国有资产占用情况说明
                        FinalP3T7ItemAssetVo p3T7VoAssetVo = p3T7Vo.getAssetVo();
                        if(StringUtils.isBlank(p3T7VoAssetVo.getTotal())) {
                            p3T7VoAssetVo.setTotal("0");
                        }
                        //单价100万元（含）以上设备（不含车辆） 0台（套）
                        if("单价100万元（含）以上设备（不含车辆） 台（套）".equals(p3T7VoAssetVo.getDeviceStr())) {
                            p3T7VoAssetVo.setDeviceStr("单价100万元（含）以上设备（不含车辆） 0台（套）");
                            deptNameStr[0] += finalData.getId() + " : " + finalData.getExcelDeptName() + "\n";
                        }
                        //副部（省）级及以上领导用车辆、主要领导干部用车辆、机要通信用车辆、应急保障用车辆、执法执勤用车辆、特种专业技术用车辆、离退休干部用车辆、其他用车辆
                        //副部（省）级及以上领导用车0辆、主要领导干部用车0辆、机要通信用车0辆、应急保障用车0辆、执法执勤用车0辆、特种专业技术用车0辆、离退休干部用车0辆、其他用车0辆
                        if("副部（省）级及以上领导用车辆、主要领导干部用车辆、机要通信用车辆、应急保障用车辆、执法执勤用车辆、特种专业技术用车辆、离退休干部用车辆、其他用车辆".equals(p3T7VoAssetVo.getCarStr())) {
                            p3T7VoAssetVo.setCarStr("副部（省）级及以上领导用车0辆、主要领导干部用车0辆、机要通信用车0辆、应急保障用车0辆、执法执勤用车0辆、特种专业技术用车0辆、离退休干部用车0辆、其他用车0辆");
                            // deptNameStr[0] += finalData.getId() + " : " + finalData.getExcelDeptName() + "\n";
                        }

                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


                        //更新 保存 去年的 excel数据
                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据
                        //updateEntity.setJsonTableContent(jsonTableContent);
                        //TODO 更新 PDF 以及 删除
                        updateEntity.setPdfUrl("");
                        updateEntity.setJsonFileContent("");

                        //updateList.add(updateEntity);
                        //保存去年的 excel数据

                        //this.updateById(updateEntity);
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }

        try {
            File file = ResourceUtils.getFile("F:\\out\\updateP6Default.txt");
            FileUtil.writeString(deptNameStr[0], file, CharsetUtil.UTF_8);
        } catch (FileNotFoundException e) {
            log.debug("文件异常 [{}]", e);
        }
    }

    @Override
    public void generateAllFile() {
        List<FinalData> list = lambdaQuery().select(FinalData::getId)
                //.eq(FinalData::getId, 11851)
                .list(); //.eq(FinalData::getId, 11790)

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {

                        //判断 redis 是否存在
                        String generateDocumentKey = BusinessCacheConstants.GENERATE_DOCUMENT_FINAL_FLAG + finalData.getId();
                        if (redisCache.hasKey(generateDocumentKey)) {
                            log.error("文档在生成中, 请稍后再试~");
                            //return new AsyncResult<>("文档在生成中, 请稍后再试~");
                        }

                        redisCache.setCacheObject(generateDocumentKey, 1, 40, TimeUnit.SECONDS);

                        try {
                            TplStrategy tplStrategy = AnnotationTplStrategyFactory.getTemplateStrategy(finalData.getTemplateExportType());
                            tplStrategy.exportSave(finalDataService, finalData.getId());
                        } catch (Exception e) {
                            log.error("生成文档异常");
                            //return new AsyncResult<>("生成文档异常， 请稍后再试, 或者联系管理员~");
                        } finally {
                            if (redisCache.hasKey(generateDocumentKey)) {
                                redisCache.deleteObject(generateDocumentKey);
                            }
                        }

                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }

                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }

    }

    /**
     * 修改 第8部分的自评的
     */
    @Override
    public void finalDataUpdateDataT8() {
        List<FinalData> list = lambdaQuery().select(FinalData::getId).eq(FinalData::getId, 16276)
                .list(); //.eq(FinalData::getId, 14673)

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        final String[] deptNameStr = {""};

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {
                        /*finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl, FinalData::getExcelDeptName).eq(FinalData::getId, finalData.getId()).one();

                        //json数据
                        //FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);
                        FinalExcelDataVo finalExcelDataVo = new FinalExcelDataVo();



                        FinalP3T8Vo p3T8Vo = finalExcelDataVo.getP3T8Vo();
                        Integer fillFlag = p3T8Vo.getNoFillFlag();
                        p3T8Vo.setNoFillFlag(1);



                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


                        //更新 保存 去年的 excel数据
                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据
                        //updateEntity.setJsonTableContent(jsonTableContent);

                        this.updateById(updateEntity);*/
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }

        try {
            File file = ResourceUtils.getFile("F:\\out\\updateP6Default.txt");
            FileUtil.writeString(deptNameStr[0], file, CharsetUtil.UTF_8);
        } catch (FileNotFoundException e) {
            log.debug("文件异常 [{}]", e);
        }
    }

    @Override
    public void finalDataUpdateDataP6FromExcel(String area) {
        List<FinalData> list = lambdaQuery().select(FinalData::getId)//.eq(FinalData::getId, 12393)
                .ge(FinalData::getStatus, 4).exists(String.format("select 1 from sys_dept where dept_id = tb_final_data.dept_id and area = '%s' ", area)).list();

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {
                        /*finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl).eq(FinalData::getId, finalData.getId()).one();

                        String fileName = finalData.getExcelUrl();
                        String absolutePathName = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
                        //新数据的
                        FinalExcelDataVo finalExcelForCompareDataVo = ReadFinalExcelY22Utils.getSheetInfos(null, absolutePathName, 0);

                        //json数据
                        //FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);
                        FinalExcelDataVo finalExcelDataVo = new FinalExcelDataVo();

                        //设置 p6 head
                        FinalP3T6ItemCarVo itemCarVo = finalExcelDataVo.getP3T6Vo().getCarVo();

                        //新数据的
                        FinalP3T6ItemCarVo itemCarVoNew = finalExcelForCompareDataVo.getP3T6Vo().getCarVo();

                        itemCarVo.setCarNum(itemCarVoNew.getCarNum());
                        itemCarVo.setCarOperateYear(itemCarVoNew.getCarOperateYear());
                        *//*itemCarVo.setCarNum("0");
                        itemCarVo.setCarOperateYear("0");*//*
                        //公务车运行费用/保有量 = 每辆运行费用
                        itemCarVo.setCarOperateEach(FinalY22Utils.getDivisionNum(itemCarVo.getCarOperateYear(), itemCarVo.getCarNum()));


                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);


                        //更新 保存 去年的 excel数据
                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据
                        //updateEntity.setJsonTableContent(jsonTableContent);

                        //保存去年的 excel数据

                        this.updateById(updateEntity);*/
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }
    }

    @Async
    @Override
    public void finalDataGenerate(String area, String s, String year, Integer type) {
        /*if(true) {
            return;
        }*/
        //判断 redis 是否存在 正在生成中
        String generateDocumentKey = BusinessCacheConstants.GENERATE_DOCUMENT_FINAL_FLAG + ":AREA:" + area;
        redisCache.setCacheObject(generateDocumentKey, 1, 6, TimeUnit.MINUTES);

        List<FinalData> list = lambdaQuery().select(FinalData::getId, FinalData::getTemplateExportType).eq(FinalData::getType, type).eq(FinalData::getYear, year)//.eq(FinalData::getId, 14690)
                //.ge(FinalData::getStatus, 4)
                .exists(String.format("select 1 from sys_dept where dept_id = tb_final_data.dept_id and area = '%s' ", area)).list();

        int num = 0;


        for (FinalData finalData : list) {


            try {
                ThreadUtil.sleep(RandomUtil.randomInt(1000, 3500));

                //finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl, FinalData::getTemplateExportType).eq(FinalData::getId, finalData.getId()).one();

                try {
                    TplStrategy tplStrategy = AnnotationTplStrategyFactory.getTemplateStrategy(finalData.getTemplateExportType());
                    tplStrategy.exportSave(finalDataService, finalData.getId());
                    num++;
                } catch (Exception e) {
                    log.error("生成文档异常: [{}], [{}]", e.getMessage(), e);
                }

            } catch (Exception e) {
                log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
            }

        }

        log.info("生成成功的数量: [{}]", num);

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        /*List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {
                        try {
                            TplStrategy tplStrategy = AnnotationTplStrategyFactory.getTemplateStrategy(finalData.getTemplateExportType());
                            tplStrategy.exportSave(finalDataService, finalData.getId());
                        } catch (Exception e) {
                            log.error("生成文档异常: [{}], [{}]", e.getMessage(), e);
                        }

                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }*/
        redisCache.deleteObject(generateDocumentKey);
    }

    @Deprecated
    @Override
    public void finalDataMoveReportDeptInfo(String area) {
        List<FinalData> list = lambdaQuery().select(FinalData::getId)//.eq(FinalData::getId, 15037)
                .exists(String.format("select 1 from sys_dept where dept_id = tb_final_data.dept_id and area = '%s' ", area)).list();

        if(true) {
            return;
        }
        //list = list.subList(0, 3);

        /*LambdaQueryWrapper<ReportDept> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ReportDept::getDeptId, deptId);
        queryWrapper.eq(ReportDept::getYear, "2022");
        queryWrapper.eq(ReportDept::getType, 1);
        queryWrapper.orderByDesc(ReportDept::getCreateTime);
        queryWrapper.exists(String.format("select 1 from sys_dept where dept_id = tb_report_dept.dept_id and area = '%s' ", area));
        List<ReportDept> reportDeptList = reportDeptService.list(queryWrapper);*/

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {

                        finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl, FinalData::getDeptId, FinalData::getYear, FinalData::getType).eq(FinalData::getId, finalData.getId()).one();

                        //json数据
                        FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(finalData.getJsonTableContent(), FinalExcelDataVo.class);

                        //保存 报告 部门
                        FinalP1Vo finalP1Vo1 = finalExcelDataVo.getP1Vo();
                        String jsonContent = JSONUtil.toJsonStr(finalP1Vo1);
                        ReportDept reportDept = new ReportDept();
                        reportDept.setType(finalData.getType());
                        reportDept.setYear(finalData.getYear());
                        reportDept.setDeptId(finalData.getDeptId());
                        reportDept.setJsonContent(jsonContent);

                        //保存 报告的 部门概况信息
                        LambdaQueryWrapper<ReportDept> queryWrapper = new LambdaQueryWrapper<>();
                        queryWrapper.eq(ReportDept::getDeptId, finalData.getDeptId());
                        queryWrapper.eq(ReportDept::getYear, finalData.getYear());
                        queryWrapper.eq(ReportDept::getType, finalData.getType());
                        queryWrapper.orderByDesc(ReportDept::getCreateTime);
                        List<ReportDept> reportDeptList = reportDeptService.list(queryWrapper);
                        if(reportDeptList.size() > 0) {
                            ReportDept reportDeptold = reportDeptList.get(0);
                            reportDept.setId(reportDeptold.getId());
                        }



                        //更新 保存 excel数据
                        //finalExcelDataVo.setP1Vo(new FinalP1Vo());
                        //finalExcelDataVo.setTermList(new ArrayList<>());
                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);

                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据
                        updateEntity.setJsonTableContent(jsonTableContent);

                        if(StringUtils.isNotBlank(finalP1Vo1.getDuty())) {
                            reportDeptService.saveOrUpdate(reportDept);

                            //保存去年的 excel数据 暂不更新
                            //this.updateById(updateEntity);
                        }
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }

    }

    @Override
    public void finalDataMoveReportExplain(String area, String year, Integer type) {
        List<FinalData> list = lambdaQuery().select(FinalData::getId).eq(FinalData::getYear, year).eq(FinalData::getType, type)//.eq(FinalData::getId, 15063)
                .exists(String.format("select 1 from sys_dept where dept_id = tb_final_data.dept_id and area = '%s' ", area)).list();

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {

                        finalData = lambdaQuery().select(FinalData::getJsonTableContent, FinalData::getId, FinalData::getExcelUrl, FinalData::getDeptId, FinalData::getYear, FinalData::getType).eq(FinalData::getId, finalData.getId()).one();

                        String jsonContent = finalData.getJsonTableContent();
                        if(StringUtils.isBlank(jsonContent)) {
                            continue;
                        }

                        //json数据
                        FinalExcelDataVo finalExcelDataVo = JSONUtil.toBean(jsonContent, FinalExcelDataVo.class);


                        //更新 保存 excel数据
                        String jsonTableContent = JSONUtil.toJsonStr(finalExcelDataVo);

                        //查询 报告的数据
                        Long reportExplainId = null;
                        ReportExplain reportExplain = reportExplainService.getReportExplainByReportId(finalData.getId());
                        if(null != reportExplain) {
                            reportExplainId = reportExplain.getId();
                        }

                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());
                        //保存去年的对比数据 先不去除 TODO
                        //updateEntity.setJsonTableContent("");
                        //保存 报告的 excel数据
                        //this.updateById(updateEntity);
                        boolean saveRes = finalDataService.saveFinalDataAndReportExplain(updateEntity, jsonTableContent, reportExplainId);



                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }

    }

    @Override
    public void websiteFillUpdate(String area) {
        List<FinalData> list = lambdaQuery().select(FinalData::getId).eq(FinalData::getId, 15155)
                .isNotNull(FinalData::getPublicSite)
                .exists(String.format("select 1 from sys_dept where dept_id = tb_final_data.dept_id and area = '%s' ", area)).list();

        //list = list.subList(0, 1);

        //多线程 处理
        //每个线程至少同步30条记录，计算线程数，不超过10个线程
        int threadSize = Math.min((int) Math.ceil(list.size() / 30D), 10);
//            threadSize = 2;
        //计算平均每个任务数
        int taskNum = (int) Math.ceil(list.size() / (float) threadSize);

        final Integer[] successNum = new Integer[]{0};

        // 本机地址的文件路径
        String localPath = YunYanConfig.getProfile();

        List<Future> taskList = new ArrayList<>();
        ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService");
        for (int j = 0, size = threadSize - 1; j <= size; j++) {
            List<FinalData> dataList = list.subList(j * taskNum, j < size ? (j + 1) * taskNum : list.size());
            taskList.add(executor.submit(() -> {
                //保存 excel的 决算的本年数据

                for (FinalData finalData : dataList) {

                    try {

                        finalData = lambdaQuery().select( FinalData::getId, FinalData::getPublicDownloadUrl, FinalData::getPdfUrl, FinalData::getPublicSite, FinalData::getExcelUrl, FinalData::getDeptId, FinalData::getYear, FinalData::getType).eq(FinalData::getId, finalData.getId()).one();
                        if(StringUtils.isBlank(finalData.getPublicSite())) {
                            continue;
                        }

                        // 若通过二审核则进行网站填报
                        LambdaUpdateWrapper<FinalData> lambdaUpdateWrapper =new LambdaUpdateWrapper<>();
                        lambdaUpdateWrapper//.set(FinalData::getPublicSite, websiteFillDto.getPublicSite())
                                //.set(FinalData::getPublicDownloadUrl, websiteFillDto.getPublicDownloadUrl())
                                //通过判断 标题中是否包含来使用
                                .set(FinalData::getPublicStatus, 0)
                                .set(FinalData::getStatus, FinalDataStatus.FILL_WEBSITE.getCode())
                                .set(FinalData::getUpdateBy, "自动")
                                .set(FinalData::getUpdateTime,new Date())
                                .eq(FinalData::getId, finalData.getId());

                        //没有选公开时间时，取当前时间
                        lambdaUpdateWrapper.set(FinalData::getPublicTime,new Date());
                        /*if(null == websiteFillDto.getPublicTime()) {
                            lambdaUpdateWrapper.set(FinalData::getPublicTime,new Date());
                        }*/

                        // 更新决算数据信息
                        int line = finalDataMapper.update(null, lambdaUpdateWrapper);

                        //调用 文件的比较 异步
                        syncService.PDFComparator(finalData.getId(), finalData.getPublicDownloadUrl(), finalData.getPdfUrl(), finalData.getPublicSite());

                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("导入的文件线程 结束");
                    break;
                }
            }
        }
    }
}
