package com.hz.pm.api.scheduler.task;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.file.service.FileService;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.gov.manage.GovProjectCollectionManage;
import com.hz.pm.api.gov.model.entity.*;
import com.hz.pm.api.gov.model.vo.GovBizProjectDetailVO;
import com.hz.pm.api.gov.model.vo.GovBizProjectListVO;
import com.hz.pm.api.gov.model.vo.GovOperationProjectBaseinfoVO;
import com.hz.pm.api.gov.model.vo.GovOperationProjectDetailVO;
import com.hz.pm.api.gov.service.*;
import com.hz.pm.api.gov.utils.ProjectConvertUtil;
import com.hz.pm.api.projectlib.manage.ProjectLibManage;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.vo.ProjectDetailVO;
import com.hz.pm.api.projectlib.service.IProjectService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

/**
 * @author ZPF
 * @since 2023/08/31 18:16
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class SynProjectCollectionTask {

    @Value("${hostname}")
    public String HOST;

    @Value("${spring.profiles.active}")
    public String active;



    private final GovProjectCollectionManage collectionManage;
    private final IGovBizProjectBaseinfoService baseinfoService;
    private final IGovBizProjectApplyService applyService;
    private final IGovBizProjectApproveService approveService;
    private final IGovBizProjectCimplementService cimplementService;
    private final IGovBizProjectMimplementService mimplementService;
    private final IGovBizProjectProcureService procureService;
    private final IProjectService projectService;
    private final ProjectLibManage projectLibManage;
    private final FileService fileService;

    private static final Integer PAGE_NUMBER = 1;


    /**
     * 前置机每天晚上10点自动清空，第二天早上6点获取数据
     * 定时同步前置机数据 每天1点开始执行一次
     *
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void doTask() throws UnknownHostException {
        if (!HOST.equals(InetAddress.getLocalHost().getHostName())) {
            log.info("定时器没开启或者host不对! {}:{}",
                    HOST,InetAddress.getLocalHost().getHostName());
            return;
        }
        if(BizConst.PRE.equals(active)){
            log.info("预发环境不用同步!");
            return;
        }

        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        log.info("数据同步任务开始之前 先删除前置机上的所有数据");
        collectionManage.deleteAll();

        //全量项目归集
        ProjectListReq req = new ProjectListReq();
        Long count = collectionManage.count(req) + collectionManage.operationCount(req);
        if(count == 0L){
            log.info("本次同步无数据");
            return;
        }
        req.setPageNumber(PAGE_NUMBER);
        req.setPageSize(count.intValue());
        PageVo<GovBizProjectListVO> projectCollectionPage = collectionManage.list(req);

        log.info("projectCollections size :{}",projectCollectionPage.getTotal());

        for(GovBizProjectListVO vo : projectCollectionPage.getRecords()){
            GovBizProjectDetailVO projectDetail = collectionManage.detail(vo.getBaseProjId());
            collectionManage.pushProjectVo(projectDetail);
        }

        //2.运维备案项目
        PageVo<GovBizProjectListVO> operationList = collectionManage.operationList(req);
        log.info("operation list size :{}",operationList.getTotal());
        for(GovBizProjectListVO vo : operationList.getRecords()){
            GovOperationProjectDetailVO operationDetail = collectionManage.operationDetail(vo.getBaseProjId());
            GovOperationProjectBaseinfoVO baseinfo = operationDetail.getBaseinfo();
            if(Objects.isNull(baseinfo) || Objects.isNull(baseinfo.getPush()) ||
                    Boolean.FALSE.equals(baseinfo.getPush())){
                log.info("此运维项目不用推送:" + vo.getBaseProjId());
            }
            collectionManage.pushProjectVo(operationDetail);
        }

        //3.申报项目 需要推送的项目
        List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
                .eq(Project::getNewest,Boolean.TRUE)
                .eq(Project::getPush,Boolean.TRUE));
        log.info("projects need push size :{}",projects.size());
        for(Project project : projects){
            ProjectDetailVO projectDetailVO = projectLibManage.detailProjectCode(project.getProjectCode());
            GovBizProjectDetailVO vo = ProjectConvertUtil.declaredToCollection(projectDetailVO,fileService);
            if(Objects.nonNull(vo)){
                collectionManage.pushProjectVo(vo);
            }
        }

        stopWatch.stop();
        log.info("数据同步任务结束====={}s",stopWatch.getTotalTimeSeconds());
    }

    /**
     * 把库存的项目归集里 没有转换PDF文件的 都转换一遍 存入数据库
     */
    public void stagingConvertPdf(String projId) {
        log.info("项目归集库存转换PDF任务开始=====");
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        GovBizProjectBaseinfo base = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class)
                .eq(GovBizProjectBaseinfo::getBaseProjId, projId));
        if(Objects.nonNull(base)){
            //开始转换PDF
            convertPdfVo(projId);
        }

        stopWatch.stop();
        log.info("项目归集库存转换PDF任务结束====={}s",stopWatch.getTotalTimeSeconds());
    }

    public void stagingConvertPdf2(String projId) {
        log.info("项目归集库存转换PDF任务2开始=====");
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        ProjectListReq req = new ProjectListReq();
        req.setPageNumber(1);
        req.setPageSize(BizConst.MAX_EXPORT_COUNT);
        List<GovBizProjectApprove> projects = approveService.list(Wrappers.lambdaQuery(GovBizProjectApprove.class)
                .eq(GovBizProjectApprove::getDeleted,Boolean.FALSE)
                .eq(StringUtils.isNotBlank(projId),GovBizProjectApprove::getBaseProjId,projId)
                .isNotNull(GovBizProjectApprove::getApprovalFile)
                .isNull(GovBizProjectApprove::getApprovalFilePdf));

        if(CollUtil.isEmpty(projects)){
            log.info("没有项目归集 任务终止");
            return;
        }

        for(GovBizProjectApprove project : projects){
            String baseProjId = project.getBaseProjId();
            //开始转换PDF
            GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaQuery(GovBizProjectApprove.class)
                    .eq(GovBizProjectApprove::getBaseProjId,baseProjId)
                    .last(BizConst.LIMIT_1));
            if(Objects.isNull(approve)){
                return;
            }
            if(StringUtils.isBlank(approve.getApprovalFilePdf()) && StringUtils.isNotBlank(approve.getApprovalFile())){
                StringJoiner sj = collectionManage.convertAndUpload(approve.getApprovalFile());
                approve.setApprovalFilePdf(sj.toString());
            }
        }

        stopWatch.stop();
        log.info("项目归集库存转换PDF任务2结束====={}s",stopWatch.getTotalTimeSeconds());
    }

    public void stagingConvertPdf3(String projId) {
        log.info("项目归集库存转换PDF任务3开始=====");

        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        ProjectListReq req = new ProjectListReq();
        req.setPageNumber(1);
        req.setPageSize(BizConst.MAX_EXPORT_COUNT);
        List<GovBizProjectApprove> approves = approveService.list(Wrappers.lambdaQuery(GovBizProjectApprove.class)
                .eq(GovBizProjectApprove::getDeleted,Boolean.FALSE)
                .eq(StringUtils.isNotBlank(projId),GovBizProjectApprove::getBaseProjId,projId)
                .isNotNull(GovBizProjectApprove::getApprovalFile)
                .isNull(GovBizProjectApprove::getApprovalFilePdf));

        if(CollUtil.isEmpty(approves)){
            log.info("没有项目归集 审批信息 立项文件 任务终止");
            return;
        }

        for(GovBizProjectApprove approve : approves){
            //开始转换PDF
            convertPdfVo(approve.getBaseProjId());
        }

        stopWatch.stop();
        log.info("项目归集库存转换PDF任务3结束====={}s",stopWatch.getTotalTimeSeconds());
    }

    //开始转换PDF
    private void convertPdfVo(String baseProjId) {
        convertPdfApply(baseProjId);
        convertPdfApprove(baseProjId);
        convertPdfCimplement(baseProjId);
        convertPdfMimplement(baseProjId);
        convertPdfAProcure(baseProjId);
    }

    private void convertPdfApply(String baseProjId) {
        GovBizProjectApply apply = applyService.getOne(Wrappers.lambdaQuery(GovBizProjectApply.class)
                .eq(GovBizProjectApply::getBaseProjId,baseProjId)
                .last(BizConst.LIMIT_1));
        if(Objects.isNull(apply)){
            return;
        }
        if(StringUtils.isBlank(apply.getBaseProjApplyFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjApplyFile())){
            StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjApplyFile());
            apply.setBaseProjApplyFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(apply.getBaseProjBasisFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjBasisFile())){
            StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjBasisFile());
            apply.setBaseProjBasisFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(apply.getBaseProjOtherFilePdf()) && StringUtils.isNotBlank(apply.getBaseProjOtherFile())){
            StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseProjOtherFile());
            apply.setBaseProjOtherFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(apply.getBaseResearchReportFilePdf()) && StringUtils.isNotBlank(apply.getBaseResearchReportFile())){
            StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseResearchReportFile());
            apply.setBaseResearchReportFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(apply.getBaseOperatMaintenFilePdf()) && StringUtils.isNotBlank(apply.getBaseOperatMaintenFile())){
            StringJoiner sj = collectionManage.convertAndUpload(apply.getBaseOperatMaintenFile());
            apply.setBaseOperatMaintenFilePdf(sj.toString());
        }
        applyService.updateById(apply);
    }

    private void convertPdfApprove(String baseProjId) {
        GovBizProjectApprove approve = approveService.getOne(Wrappers.lambdaQuery(GovBizProjectApprove.class)
                .eq(GovBizProjectApprove::getBaseProjId,baseProjId)
                .last(BizConst.LIMIT_1));
        if(Objects.isNull(approve)){
            return;
        }
        if(StringUtils.isBlank(approve.getApprovalFilePdf()) && StringUtils.isNotBlank(approve.getApprovalFile())){
            StringJoiner sj = collectionManage.convertAndUpload(approve.getApprovalFile());
            approve.setApprovalFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(approve.getPreliminaryDesignFilePdf()) && StringUtils.isNotBlank(approve.getPreliminaryDesignFile())){
            StringJoiner sj = collectionManage.convertAndUpload(approve.getPreliminaryDesignFile());
            approve.setPreliminaryDesignFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(approve.getBaseReviewCommentsFilePdf()) && StringUtils.isNotBlank(approve.getBaseReviewCommentsFile())){
            StringJoiner sj = collectionManage.convertAndUpload(approve.getBaseReviewCommentsFile());
            approve.setBaseReviewCommentsFilePdf(sj.toString());
        }
        approveService.updateById(approve);
    }

    private void convertPdfCimplement(String baseProjId) {
        GovBizProjectCimplement cimplement = cimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectCimplement.class)
                .eq(GovBizProjectCimplement::getBaseProjId,baseProjId)
                .last(BizConst.LIMIT_1));
        if(Objects.isNull(cimplement)){
            return;
        }
        if(StringUtils.isBlank(cimplement.getBaseCheckFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseCheckFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseCheckFile());
            cimplement.setBaseCheckFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseChanFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseChanFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseChanFile());
            cimplement.setBaseChanFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseChangeFormFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseChangeFormFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseChangeFormFile());
            cimplement.setBaseChangeFormFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseUserConsFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseUserConsFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseUserConsFile());
            cimplement.setBaseUserConsFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseEstaSummFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseEstaSummFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseEstaSummFile());
            cimplement.setBaseEstaSummFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseEngineerPostpoFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseEngineerPostpoFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseEngineerPostpoFile());
            cimplement.setBaseEngineerPostpoFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBasePasswAssessFilePdf()) && StringUtils.isNotBlank(cimplement.getBasePasswAssessFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBasePasswAssessFile());
            cimplement.setBasePasswAssessFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseThirdAcceptFile());
            cimplement.setBaseThirdAcceptFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseFinanlAuditFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseFinanlAuditFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseFinanlAuditFile());
            cimplement.setBaseFinanlAuditFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseInitialOpinionFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseInitialOpinionFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseInitialOpinionFile());
            cimplement.setBaseInitialOpinionFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseThirdAcceptFile());
            cimplement.setBaseThirdAcceptFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseSummReportFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseSummReportFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseSummReportFile());
            cimplement.setBaseSummReportFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseFinalExpertOpinionFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseFinalExpertOpinionFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseFinalExpertOpinionFile());
            cimplement.setBaseFinalExpertOpinionFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseIrsTestRunFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseIrsTestRunFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseIrsTestRunFile());
            cimplement.setBaseIrsTestRunFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(cimplement.getBaseInforLevelFilePdf()) && StringUtils.isNotBlank(cimplement.getBaseInforLevelFile())){
            StringJoiner sj = collectionManage.convertAndUpload(cimplement.getBaseInforLevelFile());
            cimplement.setBaseInforLevelFilePdf(sj.toString());
        }
        cimplementService.updateById(cimplement);
    }

    private void convertPdfMimplement(String baseProjId) {
        GovBizProjectMimplement mimplement = mimplementService.getOne(Wrappers.lambdaQuery(GovBizProjectMimplement.class)
                .eq(GovBizProjectMimplement::getBaseProjId,baseProjId)
                .last(BizConst.LIMIT_1));
        if(Objects.isNull(mimplement)){
            return;
        }
        if(StringUtils.isBlank(mimplement.getBaseChanFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseChanFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseChanFile());
            mimplement.setBaseChanFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseUserConsFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseUserConsFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseUserConsFile());
            mimplement.setBaseUserConsFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseEstaSummFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEstaSummFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEstaSummFile());
            mimplement.setBaseEstaSummFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseEngineerPostpoFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEngineerPostpoFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEngineerPostpoFile());
            mimplement.setBaseEngineerPostpoFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBasePasswAssessFilePdf()) && StringUtils.isNotBlank(mimplement.getBasePasswAssessFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBasePasswAssessFile());
            mimplement.setBasePasswAssessFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseThirdAcceptFile());
            mimplement.setBaseThirdAcceptFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseThirdAcceptFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseThirdAcceptFile());
            mimplement.setBaseThirdAcceptFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseFinalExpertOpinionFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseFinalExpertOpinionFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseFinalExpertOpinionFile());
            mimplement.setBaseFinalExpertOpinionFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseEngineerAlterFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseEngineerAlterFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseEngineerAlterFile());
            mimplement.setBaseEngineerAlterFilePdf(sj.toString());
        }
        if(StringUtils.isBlank(mimplement.getBaseOperatMaintenSummFilePdf()) && StringUtils.isNotBlank(mimplement.getBaseOperatMaintenSummFile())){
            StringJoiner sj = collectionManage.convertAndUpload(mimplement.getBaseOperatMaintenSummFile());
            mimplement.setBaseOperatMaintenSummFilePdf(sj.toString());
        }
        mimplementService.updateById(mimplement);
    }

    private void convertPdfAProcure(String baseProjId) {
        List<GovBizProjectProcure> procures = procureService.list(Wrappers.lambdaQuery(GovBizProjectProcure.class)
                .eq(GovBizProjectProcure::getBaseProjId, baseProjId));
        for(GovBizProjectProcure procure : procures){
            if(StringUtils.isBlank(procure.getPurchaseContractPdf()) && StringUtils.isNotBlank(procure.getPurchaseContract())){
                StringJoiner sj = collectionManage.convertAndUpload(procure.getPurchaseContract());
                procure.setPurchaseContractPdf(sj.toString());
            }
            if(StringUtils.isBlank(procure.getPurchaseFilePdf()) && StringUtils.isNotBlank(procure.getPurchaseFile())){
                StringJoiner sj = collectionManage.convertAndUpload(procure.getPurchaseFile());
                procure.setPurchaseFilePdf(sj.toString());
            }
            if(StringUtils.isBlank(procure.getBiddingFilePdf()) && StringUtils.isNotBlank(procure.getBiddingFile())){
                StringJoiner sj = collectionManage.convertAndUpload(procure.getBiddingFile());
                procure.setBiddingFilePdf(sj.toString());
            }
            procureService.updateById(procure);
        }
    }

    public void doTaskSingle(List<String> projectCodes) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        log.info("数据同步任务 指定项目编号 :{}",projectCodes);

        if(CollUtil.isEmpty(projectCodes)){
            throw new BizException("不能为空!");
        }

        //全量项目归集
        ProjectListReq req = new ProjectListReq();
        req.setPageNumber(PAGE_NUMBER);
        req.setPageSize(1000);
        PageVo<GovBizProjectListVO> projectCollectionPage = collectionManage.list(req);

        log.info("projectCollections size :{}",projectCollectionPage.getTotal());

        for(GovBizProjectListVO vo : projectCollectionPage.getRecords()){
            GovBizProjectDetailVO projectDetail = collectionManage.detail(vo.getBaseProjId());
            collectionManage.pushProjectVo(projectDetail);
        }

        //2.运维备案项目
        PageVo<GovBizProjectListVO> operationList = collectionManage.operationList(req);
        log.info("operation list size :{}",operationList.getTotal());
        for(GovBizProjectListVO vo : operationList.getRecords()){
            GovOperationProjectDetailVO operationDetail = collectionManage.operationDetail(vo.getBaseProjId());
            GovOperationProjectBaseinfoVO baseinfo = operationDetail.getBaseinfo();
            if(Objects.isNull(baseinfo) || Objects.isNull(baseinfo.getPush()) ||
                    Boolean.FALSE.equals(baseinfo.getPush())){
                log.info("此运维项目不用推送:" + vo.getBaseProjId());
            }
            collectionManage.pushProjectVo(operationDetail);
        }

        //3.申报项目 需要推送的项目
        List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
                .eq(Project::getNewest,Boolean.TRUE)
                .eq(Project::getPush,Boolean.TRUE)
                .in(Project::getProjectCode,projectCodes));
        log.info("projects need push size :{}",projects.size());
        for(Project project : projects){
            ProjectDetailVO projectDetailVO = projectLibManage.detailProjectCode(project.getProjectCode());
            GovBizProjectDetailVO vo = ProjectConvertUtil.declaredToCollection(projectDetailVO,fileService);
            if(Objects.nonNull(vo)){
                collectionManage.pushProjectVo(vo);
            }
        }

        stopWatch.stop();
        log.info("数据同步任务 指定项目编号 结束====={}s",stopWatch.getTotalTimeSeconds());
    }
}
