package com.yunyan.business.service.impl;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunyan.business.document.utils.FileDataUtil;
import com.yunyan.business.document.y22.ReadFinalExcelY22Utils;
import com.yunyan.business.document.y22.pojo.finalExcelY22.FinalExcelDataVo;
import com.yunyan.business.document.y22.pojo.finalExcelY22.FinalP1Vo;
import com.yunyan.business.document.y23.budget.ReadBudgetExcelY23Utils;
import com.yunyan.business.document.y23.budget.UpdateReportBudgetData;
import com.yunyan.business.document.y23.budget.pojo.budgetY23.BudgetDataVo;
import com.yunyan.business.document.y23.budget.pojo.budgetY23.purchase.BudgetP3p10p2ItemVo;
import com.yunyan.business.document.y23.budget.pojo.budgetY23.update.UpdateBudgetP3Vo;
import com.yunyan.business.domain.FinalData;
import com.yunyan.business.domain.ReportDept;
import com.yunyan.business.domain.ReportExplain;
import com.yunyan.business.domain.ReportFill;
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.domain.entity.SysDept;
import com.yunyan.common.core.redis.RedisCache;
import com.yunyan.common.utils.StringUtils;
import com.yunyan.common.utils.spring.SpringUtils;
import com.yunyan.system.service.ISysDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;

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

    @Autowired
    private RedisCache redisCache;

    @Autowired
    private IReportDeptService reportDeptService;

    @Autowired
    private IReportExplainService reportExplainService;

    @Autowired
    private ISyncService syncService;

    @Autowired
    private FinalDataMapper finalDataMapper;

    @Autowired
    private IReportFillService reportFillService;

    @Autowired
    private ISysDeptService sysDeptService;

    @Autowired
    private IPurchaseDataService purchaseDataService;

    @Override
    public void budgetDataReportInfoUpdate1(String area, Integer type, String year) {
        List<FinalData> list = lambdaQuery().select(FinalData::getId)//.eq(FinalData::getId, 15037)
                .eq(FinalData::getType, type)
                .eq(FinalData::getYear, year)
                .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, 3);

        //多线程 处理
        //每个线程至少同步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::getExcelUrl, FinalData::getExcelUrlLast, FinalData::getDeptId, FinalData::getYear, FinalData::getType).eq(FinalData::getId, finalData.getId()).one();

                        Long reportId = finalData.getId();

                        //查询 报告的数据
                        ReportExplain reportExplain = reportExplainService.getReportExplainByReportId(finalData.getId());
                        if(null == reportExplain || StringUtils.isBlank(reportExplain.getJsonContent())) {
                            log.error("数据还未读取, 请联系管理员~");
                            continue;
                        }

                        //查询 填报的数据
                        LambdaQueryWrapper<ReportFill> queryWrapper = new LambdaQueryWrapper<>();
                        queryWrapper.eq(ReportFill::getReportId, reportId);
                        queryWrapper.orderByDesc(ReportFill::getCreateTime);
                        queryWrapper.select(ReportFill::getReportId, ReportFill::getId);
                        List<ReportFill> reportFillList = reportFillService.list(queryWrapper);
                        if(reportFillList.isEmpty()) {
                            log.debug("未查询到填报的数据");
                            continue;
                        }

                        ReportFill reportFill = reportFillList.get(0);
                        //已填报的数据
                        UpdateBudgetP3Vo updateVo = JSONUtil.toBean(reportFill.getJsonContent(), UpdateBudgetP3Vo.class);;

                        //取旧数据 与新修改的数据
                        BudgetDataVo dataVo = JSONUtil.toBean(reportExplain.getJsonContent(), BudgetDataVo.class);
                        //UpdateBudgetP3Vo updateVo = dto.getDv();

                        /**
                         * 重新读取  excel文件里 的数据
                         */
                        String fileName = finalData.getExcelUrl();
                        String absolutePathName = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
                        //读取本年的 excel
                        BudgetDataVo excelDataVo = ReadBudgetExcelY23Utils.getSheetInfos(null, absolutePathName, 0, year, "");
                        //初始化 去年 数据
                        UpdateReportBudgetData.initValue(excelDataVo.getExplainVo());
                        UpdateReportBudgetData.setLastValue(excelDataVo.getExplainVo(), null);

                        //设置新读取的本年值设置到数据中 TODO
                        //dataVo

                        //读取去年的
                        String fileNameLast = finalData.getExcelUrlLast();
                        String absolutePathNameLast = localPath + StringUtils.substringAfter(fileNameLast, Constants.RESOURCE_PREFIX);
                        BudgetDataVo lastDataVo = ReadBudgetExcelY23Utils.getSheetInfos(null, absolutePathNameLast, 1, year, "");
                        //设置 去年数据 对比
                        UpdateReportBudgetData.initValue(lastDataVo.getExplainVo());
                        UpdateReportBudgetData.setLastValue(dataVo.getExplainVo(), lastDataVo.getExplainVo());


                        //不 更新 填报的信息
                        //UpdateReportBudgetData.updateFillData(dataVo.getExplainVo(), updateVo);

                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());

                        //保存情况说明
                        String jsonTableContent = JSONUtil.toJsonStr(dataVo);
                        ReportExplain reportExplainUpdate = new ReportExplain();
                        reportExplainUpdate.setId(reportExplain.getId());
                        reportExplainUpdate.setJsonContent(jsonTableContent);
                        boolean updateRes = finalDataService.saveFinalDataAndReportExplain(updateEntity, jsonTableContent, reportExplain.getId());

                        //判断是否是有更新，旧文件去掉，并删除
                        /*String localPath2 = YunYanConfig.getOfficePath();
                        FileDataUtil.deleteUrlFile(localPath2, finalData.getJsonFileContent(), finalData.getPdfUrl());*/


                        //生成 文档, 不生成, 会冲突, 一个个的生成可以
                        //syncService.generateDocument(dto.getId());
                    } catch (Exception e) {
                        log.debug("异常信息 [{}], [{}]", e.getMessage(), e);
                    }


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

    }

    @Override
    public AjaxResultVo budgetP10P1DeptAttrupdate(String area, Integer type, String year) {
        List<FinalData> list = lambdaQuery().select(FinalData::getId).eq(FinalData::getId, 21574)
                .eq(FinalData::getType, type)
                .eq(FinalData::getYear, year)
                .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, 4);

        List<SysDept> deptList = sysDeptService.lambdaQuery().eq(SysDept::getArea, area)
                .select(SysDept::getDeptId, SysDept::getArea, SysDept::getDeptName, SysDept::getDeptCode, SysDept::getDeptAttr, SysDept::getDeptLevel)
                .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::getId, FinalData::getExcelUrl, FinalData::getExcelUrlLast, FinalData::getDeptId, FinalData::getYear, FinalData::getType).eq(FinalData::getId, finalData.getId()).one();

                        Long reportId = finalData.getId();
                        Long deptId = finalData.getDeptId();

                        //查询 报告的数据
                        ReportExplain reportExplain = reportExplainService.getReportExplainByReportId(finalData.getId());
                        if(null == reportExplain || StringUtils.isBlank(reportExplain.getJsonContent())) {
                            log.error("数据还未读取, 请联系管理员~");
                            continue;
                        }

                        //查询 填报的数据
                        /*LambdaQueryWrapper<ReportFill> queryWrapper = new LambdaQueryWrapper<>();
                        queryWrapper.eq(ReportFill::getReportId, reportId);
                        queryWrapper.orderByDesc(ReportFill::getCreateTime);
                        queryWrapper.select(ReportFill::getReportId, ReportFill::getId);
                        List<ReportFill> reportFillList = reportFillService.list(queryWrapper);
                        if(reportFillList.isEmpty()) {
                            log.debug("未查询到填报的数据");
                            continue;
                        }

                        ReportFill reportFill = reportFillList.get(0);
                        //已填报的数据
                        UpdateBudgetP3Vo updateVo = JSONUtil.toBean(reportFill.getJsonContent(), UpdateBudgetP3Vo.class);;
                        */

                        //取旧数据 与新修改的数据
                        BudgetDataVo dataVo = JSONUtil.toBean(reportExplain.getJsonContent(), BudgetDataVo.class);
                        //UpdateBudgetP3Vo updateVo = dto.getDv();

                        //查询 部门的信息
                        SysDept sysDept = deptList.stream().filter(i-> i.getDeptId().equals(deptId)).findFirst().orElse(null);
                        if(null != sysDept) {
                            //设置 单位属性
                            dataVo.getExplainVo().getP3p10Vo().getP1Vo().setDeptAttr(sysDept.getDeptAttr());

                            //博白 预算模板2 查询下级是否有行政和事业单位, 模板一也要
                            List<SysDept> tb5ChildDeptList = sysDeptService.checkChildDeptAttrAndSumTotal(UpdateReportBudgetData.subDeptCodeListTb5(dataVo.getExplainVo().getP3p5Vo().getSubDeptList()), area);
                            UpdateReportBudgetData.setBudgetP3p10p1VoByDeptAttr(dataVo.getExplainVo().getP3p5Vo().getSubDeptList(), dataVo.getExplainVo().getP3p10Vo().getP1Vo(), tb5ChildDeptList);
                        }

                        /**
                         * 重新读取  excel文件里 的数据
                         */
                        /*String fileName = finalData.getExcelUrl();
                        String absolutePathName = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
                        //读取本年的 excel
                        BudgetDataVo excelDataVo = ReadBudgetExcelY23Utils.getSheetInfos(null, absolutePathName, 0, year);
                        //初始化 去年 数据
                        UpdateReportBudgetData.initValue(excelDataVo.getExplainVo());
                        UpdateReportBudgetData.setLastValue(excelDataVo.getExplainVo(), null);*/

                        //设置新读取的本年值设置到数据中 TODO
                        //dataVo

                        //读取去年的
                        /*String fileNameLast = finalData.getExcelUrlLast();
                        String absolutePathNameLast = localPath + StringUtils.substringAfter(fileNameLast, Constants.RESOURCE_PREFIX);
                        BudgetDataVo lastDataVo = ReadBudgetExcelY23Utils.getSheetInfos(null, absolutePathNameLast, 1, year);
                        //设置 去年数据 对比
                        UpdateReportBudgetData.initValue(lastDataVo.getExplainVo());
                        UpdateReportBudgetData.setLastValue(dataVo.getExplainVo(), lastDataVo.getExplainVo());*/


                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());

                        //保存情况说明
                        String jsonTableContent = JSONUtil.toJsonStr(dataVo);
                        ReportExplain reportExplainUpdate = new ReportExplain();
                        reportExplainUpdate.setId(reportExplain.getId());
                        reportExplainUpdate.setJsonContent(jsonTableContent);
                        boolean updateRes = finalDataService.saveFinalDataAndReportExplain(updateEntity, jsonTableContent, reportExplain.getId());

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


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("更新的线程 结束");
                    return AjaxResultVo.error("更新执行成功");
                    //break;
                }
            }
        }

        return AjaxResultVo.error("执行成功");
    }

    @Override
    public AjaxResultVo budgetP10P1DeptAttrupdateLast(String area, Integer type, String year, String id) {
        LambdaQueryWrapper<FinalData> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(FinalData::getId)
                .eq(FinalData::getType, type)
                .eq(FinalData::getYear, year)
                .exists(String.format("select 1 from sys_dept where dept_id = tb_final_data.dept_id and area = '%s' ", area));
        if(StringUtils.isNotBlank(id)) {
            queryWrapper.eq(FinalData::getId, id);
        }
        List<FinalData> list = this.list(queryWrapper);
        //list = list.subList(0, 4);

        List<SysDept> deptList = sysDeptService.lambdaQuery().eq(SysDept::getArea, area)
                .select(SysDept::getDeptId, SysDept::getArea, SysDept::getDeptName, SysDept::getDeptCode, SysDept::getDeptAttr, SysDept::getDeptLevel)
                .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::getId, FinalData::getExcelUrl, FinalData::getExcelUrlLast, FinalData::getDeptId, FinalData::getYear, FinalData::getType).eq(FinalData::getId, finalData.getId()).one();

                        Long reportId = finalData.getId();
                        Long deptId = finalData.getDeptId();

                        //查询 报告的数据
                        ReportExplain reportExplain = reportExplainService.getReportExplainByReportId(finalData.getId());
                        if(null == reportExplain || StringUtils.isBlank(reportExplain.getJsonContent())) {
                            log.error("数据还未读取, 请联系管理员~");
                            continue;
                        }

                        //读取去年的
                        String fileNameLast = finalData.getExcelUrlLast();
                        String absolutePathNameLast = localPath + StringUtils.substringAfter(fileNameLast, Constants.RESOURCE_PREFIX);
                        BudgetDataVo lastDataVo = ReadBudgetExcelY23Utils.getSheetInfos(null, absolutePathNameLast, 1, year, "");
                        //设置 去年数据 对比
                        UpdateReportBudgetData.initValue(lastDataVo.getExplainVo());
                        UpdateReportBudgetData.setLastValue(lastDataVo.getExplainVo(), lastDataVo.getExplainVo());



                        //取旧数据 与新修改的数据
                        BudgetDataVo dataVo = JSONUtil.toBean(reportExplain.getJsonContent(), BudgetDataVo.class);
                        //UpdateBudgetP3Vo updateVo = dto.getDv();

                        //查询 部门的信息
                        SysDept sysDept = deptList.stream().filter(i-> i.getDeptId().equals(deptId)).findFirst().orElse(null);
                        if(null != sysDept) {
                            //设置 单位属性
                            dataVo.getExplainVo().getP3p10Vo().getP1Vo().setDeptAttr(sysDept.getDeptAttr());

                            //博白 预算模板2 查询下级是否有行政和事业单位, 模板一也要
                            List<SysDept> tb5ChildDeptList = sysDeptService.checkChildDeptAttrAndSumTotal(UpdateReportBudgetData.subDeptCodeListTb5(lastDataVo.getExplainVo().getP3p5Vo().getSubDeptList()), area);
                            UpdateReportBudgetData.setBudgetP3p10p1VoByDeptAttr(lastDataVo.getExplainVo().getP3p5Vo().getSubDeptList(), lastDataVo.getExplainVo().getP3p10Vo().getP1Vo(), tb5ChildDeptList);
                            //比对 p3p10去年的数据
                            UpdateReportBudgetData.setP3p10p1LastSubItem(dataVo.getExplainVo().getP3p10Vo().getP1Vo().getOperationItemVo(), lastDataVo.getExplainVo().getP3p10Vo().getP1Vo().getOperationItemVo().getTotal());
                            UpdateReportBudgetData.setP3p10p1LastSubItem(dataVo.getExplainVo().getP3p10Vo().getP1Vo().getOperationItemVo2(), lastDataVo.getExplainVo().getP3p10Vo().getP1Vo().getOperationItemVo2().getTotal());
                        }

                        /**
                         * 重新读取  excel文件里 的数据
                         */
                        /*String fileName = finalData.getExcelUrl();
                        String absolutePathName = localPath + StringUtils.substringAfter(fileName, Constants.RESOURCE_PREFIX);
                        //读取本年的 excel
                        BudgetDataVo excelDataVo = ReadBudgetExcelY23Utils.getSheetInfos(null, absolutePathName, 0, year);
                        //初始化 去年 数据
                        UpdateReportBudgetData.initValue(excelDataVo.getExplainVo());
                        UpdateReportBudgetData.setLastValue(excelDataVo.getExplainVo(), null);*/

                        //设置新读取的本年值设置到数据中 TODO
                        //dataVo


                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());

                        //保存情况说明
                        String jsonTableContent = JSONUtil.toJsonStr(dataVo);
                        ReportExplain reportExplainUpdate = new ReportExplain();
                        reportExplainUpdate.setId(reportExplain.getId());
                        reportExplainUpdate.setJsonContent(jsonTableContent);
                        boolean updateRes = finalDataService.saveFinalDataAndReportExplain(updateEntity, jsonTableContent, reportExplain.getId());

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


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("更新的线程 结束");
                    return AjaxResultVo.error("更新执行成功");
                    //break;
                }
            }
        }

        return AjaxResultVo.error("执行成功");
    }

    @Override
    public AjaxResultVo budgetP3p7ItemupdateLast(String area, Integer type, String year, String id) {
        return null;
    }

    @Override
    public AjaxResultVo budgetP10P2TotalFundUpdateLast(String area, Integer type, String year, String id) {
        LambdaQueryWrapper<FinalData> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(FinalData::getId)
                .eq(FinalData::getType, type)
                .eq(FinalData::getYear, year)
                .exists(String.format("select 1 from sys_dept where dept_id = tb_final_data.dept_id and area = '%s' ", area));
        if(StringUtils.isNotBlank(id)) {
            queryWrapper.eq(FinalData::getId, id);
        }
        List<FinalData> list = this.list(queryWrapper);
        //list = list.subList(0, 4);

        List<SysDept> deptList = sysDeptService.lambdaQuery().eq(SysDept::getArea, area)
                .select(SysDept::getDeptId, SysDept::getArea, SysDept::getDeptName, SysDept::getDeptCode, SysDept::getDeptAttr, SysDept::getDeptLevel)
                .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::getId, FinalData::getExcelUrl, FinalData::getExcelUrlLast, FinalData::getDeptId, FinalData::getYear, FinalData::getType).eq(FinalData::getId, finalData.getId()).one();

                        Long reportId = finalData.getId();
                        Long deptId = finalData.getDeptId();

                        //查询 报告的数据
                        ReportExplain reportExplain = reportExplainService.getReportExplainByReportId(finalData.getId());
                        if(null == reportExplain || StringUtils.isBlank(reportExplain.getJsonContent())) {
                            log.error("数据还未读取, 请联系管理员~");
                            continue;
                        }


                        //取旧数据 与新修改的数据
                        BudgetDataVo dataVo = JSONUtil.toBean(reportExplain.getJsonContent(), BudgetDataVo.class);
                        //UpdateBudgetP3Vo updateVo = dto.getDv();


                        //查询 部门的信息
                        SysDept sysDept = deptList.stream().filter(i-> i.getDeptId().equals(deptId)).findFirst().orElse(null);
                        if(null != sysDept) {

                            //设置p3p10p2采购的信息
                            List<BudgetP3p10p2ItemVo> purchaseDataList = purchaseDataService.getPurchaseDataList(area, year);
                            UpdateReportBudgetData.setPurchaseValueTotalFundAndPerson(dataVo.getExplainVo(), purchaseDataList, sysDept.getDeptCode());

                        }

                        FinalData updateEntity = new FinalData();
                        updateEntity.setId(finalData.getId());

                        //保存情况说明
                        String jsonTableContent = JSONUtil.toJsonStr(dataVo);
                        ReportExplain reportExplainUpdate = new ReportExplain();
                        reportExplainUpdate.setId(reportExplain.getId());
                        reportExplainUpdate.setJsonContent(jsonTableContent);
                        boolean updateRes = finalDataService.saveFinalDataAndReportExplain(updateEntity, jsonTableContent, reportExplain.getId());

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


                }
            }));
        }
        for (Future f : taskList) {
            while (true) {
                if (f.isDone() && !f.isCancelled()) {
                    log.debug("更新的线程 结束");
                    return AjaxResultVo.error("更新执行成功");
                    //break;
                }
            }
        }

        return AjaxResultVo.error("执行成功");
    }
}
