package com.hz.pm.api.gov.convert;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.hz.pm.api.gov.contants.BizProjectContant;
import com.hz.pm.api.gov.model.dto.*;
import com.hz.pm.api.gov.model.req.*;
import com.hz.pm.api.gov.model.vo.*;
import com.hz.pm.api.gov.utils.ProjectCollectionUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @Classname ProjectConvert
 * @Description
 * @Date 2023/8/25 11:53
 * @Author PoffyZhang
 */
public class ProjectConvert {

    private ProjectConvert() {
    }

    /**
     * 6个 转换方法
     *
     * @param saveDTO
     * @return
     */
    public static ProjectPushReq convert(GovBizProjectSaveDTO saveDTO) {
        ProjectPushReq req = new ProjectPushReq();
        req.setBaseinfo(convertBase(saveDTO.getBaseinfo(), BizProjectContant.EFFECTIVE_CODE));
        req.setApply(convertApply(saveDTO.getApply()));
        req.setApprove(convertApprove(saveDTO.getApprove()));
        req.setCimplement(convertCimplement(saveDTO.getCimplement()));
        req.setMimplement(convertMimplement(saveDTO.getMimplement()));
        req.setProcures(convertProcures(saveDTO.getProcures()));
        return req;
    }

    public static ProjectPushReq convert(GovBizProjectDetailVO vo) {
        ProjectPushReq req = new ProjectPushReq();
        req.setBaseinfo(convertBaseVo(vo.getBaseinfo(), BizProjectContant.EFFECTIVE_CODE));
        req.setApply(convertApplyVo(vo.getApply()));
        req.setApprove(convertApproveVo(vo.getApprove()));
        req.setCimplement(convertCimplementVo(vo.getCimplement()));
        req.setMimplement(convertMimplementVo(vo.getMimplement()));
        req.setProcures(convertProcuresVo(vo.getProcures()));
        return req;
    }

    public static ProjectPushReq convertWithConvertPdf(GovBizProjectDetailVO vo) {
        ProjectPushReq req = new ProjectPushReq();
        req.setBaseinfo(convertBaseVo(vo.getBaseinfo(), BizProjectContant.EFFECTIVE_CODE));
        req.setApply(convertApplyVoWithConvertPdf(vo.getApply()));
        req.setApprove(convertApproveVoWithConvertPdf(vo.getApprove()));
        req.setCimplement(convertCimplementVoWithConvertPdf(vo.getCimplement()));
        req.setMimplement(convertMimplementVoWithConvertPdf(vo.getMimplement()));
        req.setProcures(convertProcuresVoWithConvertPdf(vo.getProcures()));
        return req;
    }

    public static ProjectPushReq convertWithConvertPdf(GovOperationProjectDetailVO vo) {
        ProjectPushReq req = new ProjectPushReq();
        req.setBaseinfo(convertBaseVo(vo.getBaseinfo(), BizProjectContant.EFFECTIVE_CODE));
        req.setApply(convertApplyVoWithConvertPdf(vo.getApply()));
        req.setApprove(convertApproveVoWithConvertPdf(vo.getApprove()));
        req.setCimplement(convertCimplementVoWithConvertPdf(vo.getCimplement()));
        req.setMimplement(convertMimplementVoWithConvertPdf(vo.getMimplement()));
        req.setProcures(convertProcuresVoWithConvertPdf(vo.getProcures()));
        return req;
    }

    private static List<ProjectProcureReq> convertProcures(List<GovBizProjectProcureDTO> procures) {
        if (CollUtil.isEmpty(procures)) {
            return Collections.emptyList();
        }

        List<ProjectProcureReq> req = procures.stream()
                .map(p -> {
                    ProjectProcureReq r = BeanUtil.copyProperties(p, ProjectProcureReq.class);
                    if (Objects.nonNull(p.getId())) {
                        r.setTongID(p.getId().intValue());
                    }
                    r.setBaseWinningBidTime(ProjectCollectionUtil.convertLocalDateTime(p.getBaseWinningBidTime()));
                    r.setBasePaymentTime(ProjectCollectionUtil.convertLocalDateTime(p.getBasePaymentTime()));
                    return r;
                })
                .collect(Collectors.toList());
        return req;
    }

    private static List<ProjectProcureReq> convertProcuresVo(List<GovBizProjectProcureVO> procures) {
        if (CollUtil.isEmpty(procures)) {
            return Collections.emptyList();
        }

        List<ProjectProcureReq> req = procures.stream()
                .map(p -> {
                    ProjectProcureReq r = BeanUtil.copyProperties(p, ProjectProcureReq.class);
                    if (Objects.nonNull(p.getId())) {
                        r.setTongID(p.getId().intValue());
                    }
                    r.setBaseWinningBidTime(ProjectCollectionUtil.convertLocalDateTime(p.getBaseWinningBidTime()));
                    r.setBasePaymentTime(ProjectCollectionUtil.convertLocalDateTime(p.getBasePaymentTime()));
                    return r;
                })
                .collect(Collectors.toList());
        return req;
    }

    private static List<ProjectProcureReq> convertProcuresVoWithConvertPdf(List<GovBizProjectProcureVO> procures) {
        if (CollUtil.isEmpty(procures)) {
            return Collections.emptyList();
        }

        List<ProjectProcureReq> req = procures.stream()
                .map(p -> {
                    ProjectProcureReq r = BeanUtil.copyProperties(p, ProjectProcureReq.class);
                    r.setBiddingFile(StringUtils.isNotBlank(p.getBiddingFilePdf()) ? p.getBiddingFilePdf() :
                            null);
                    r.setPurchaseFile(StringUtils.isNotBlank(p.getPurchaseFilePdf()) ? p.getPurchaseFilePdf() :
                            null);
                    r.setPurchaseContract(StringUtils.isNotBlank(p.getPurchaseContractPdf()) ? p.getPurchaseContractPdf() :
                            null);
                    r.setBaseWinningBidTime(ProjectCollectionUtil.convertLocalDateTime(p.getBaseWinningBidTime()));
                    r.setBasePaymentTime(ProjectCollectionUtil.convertLocalDateTime(p.getBasePaymentTime()));
                    return r;
                })
                .collect(Collectors.toList());
        return req;
    }

    private static ProjectMimplementReq convertMimplement(GovBizProjectMimplementDTO mimplement) {
        ProjectMimplementReq req = BeanUtil.copyProperties(mimplement, ProjectMimplementReq.class);
        return req;
    }

    private static ProjectMimplementReq convertMimplementVo(GovBizProjectMimplementVO mimplement) {
        ProjectMimplementReq req = BeanUtil.copyProperties(mimplement, ProjectMimplementReq.class);
        return req;
    }

    private static ProjectMimplementReq convertMimplementVoWithConvertPdf(GovBizProjectMimplementVO mimplement) {
        ProjectMimplementReq req = BeanUtil.copyProperties(mimplement, ProjectMimplementReq.class);
        if (Objects.isNull(req)) {
            return req;
        }
        req.setBaseUserConsFile(StringUtils.isNotBlank(mimplement.getBaseUserConsFilePdf()) ? mimplement.getBaseUserConsFilePdf() :
                mimplement.getBaseUserConsFile());
        req.setBaseChanFile(StringUtils.isNotBlank(mimplement.getBaseChanFilePdf()) ? mimplement.getBaseChanFilePdf() :
                mimplement.getBaseChanFile());
        req.setBasePasswAssessFile(StringUtils.isNotBlank(mimplement.getBasePasswAssessFilePdf()) ? mimplement.getBasePasswAssessFilePdf() :
                mimplement.getBasePasswAssessFile());
        req.setBaseInforLevelFile(StringUtils.isNotBlank(mimplement.getBaseInforLevelFilePdf()) ? mimplement.getBaseInforLevelFilePdf() :
                mimplement.getBaseInforLevelFile());
        req.setBaseEngineerPostpoFile(StringUtils.isNotBlank(mimplement.getBaseEngineerPostpoFilePdf()) ? mimplement.getBaseEngineerPostpoFilePdf() :
                mimplement.getBaseEngineerPostpoFile());
        req.setBaseEstaSummFile(StringUtils.isNotBlank(mimplement.getBaseEstaSummFilePdf()) ? mimplement.getBaseEstaSummFilePdf() :
                mimplement.getBaseEstaSummFile());
        req.setBaseFinalExpertOpinionFile(StringUtils.isNotBlank(mimplement.getBaseFinalExpertOpinionFilePdf()) ? mimplement.getBaseFinalExpertOpinionFilePdf() :
                mimplement.getBaseFinalExpertOpinionFile());
        req.setBaseThirdAcceptFile(StringUtils.isNotBlank(mimplement.getBaseThirdAcceptFilePdf()) ? mimplement.getBaseThirdAcceptFilePdf() :
                mimplement.getBaseThirdAcceptFile());
        req.setBaseOperatMaintenSummFile(StringUtils.isNotBlank(mimplement.getBaseOperatMaintenSummFilePdf()) ? mimplement.getBaseOperatMaintenSummFilePdf() :
                mimplement.getBaseOperatMaintenSummFile());
        req.setBaseEngineerAlterFile(StringUtils.isNotBlank(mimplement.getBaseEngineerAlterFilePdf()) ? mimplement.getBaseEngineerAlterFilePdf() :
                mimplement.getBaseEngineerAlterFile());
        return req;
    }

    public static ProjectCimplementReq convertCimplement(GovBizProjectCimplementDTO cimplement) {
        ProjectCimplementReq req = BeanUtil.copyProperties(cimplement, ProjectCimplementReq.class);
        return req;
    }

    public static ProjectCimplementReq convertCimplementVo(GovBizProjectCimplementVO cimplement) {
        return BeanUtil.copyProperties(cimplement, ProjectCimplementReq.class);
    }

    public static ProjectCimplementReq convertCimplementVoWithConvertPdf(GovBizProjectCimplementVO cimplement) {
        ProjectCimplementReq req = BeanUtil.copyProperties(cimplement, ProjectCimplementReq.class);
        if (Objects.isNull(req)) {
            return req;
        }
        req.setBaseChangeFormFile(StringUtils.isNotBlank(cimplement.getBaseChangeFormFilePdf()) ? cimplement.getBaseChangeFormFilePdf() :
                cimplement.getBaseChangeFormFile());
        req.setBaseUserConsFile(StringUtils.isNotBlank(cimplement.getBaseUserConsFilePdf()) ? cimplement.getBaseUserConsFilePdf() :
                cimplement.getBaseUserConsFile());
        req.setBaseCheckFile(StringUtils.isNotBlank(cimplement.getBaseCheckFilePdf()) ? cimplement.getBaseCheckFilePdf() :
                cimplement.getBaseCheckFile());
        req.setBaseChanFile(StringUtils.isNotBlank(cimplement.getBaseChanFilePdf()) ? cimplement.getBaseChanFilePdf() :
                cimplement.getBaseChanFile());
        req.setBaseSummReportFile(StringUtils.isNotBlank(cimplement.getBaseSummReportFilePdf()) ? cimplement.getBaseSummReportFilePdf() :
                cimplement.getBaseSummReportFile());
        req.setBasePasswAssessFile(StringUtils.isNotBlank(cimplement.getBasePasswAssessFilePdf()) ? cimplement.getBasePasswAssessFilePdf() :
                cimplement.getBasePasswAssessFile());
        req.setBaseInforLevelFile(StringUtils.isNotBlank(cimplement.getBaseInforLevelFilePdf()) ? cimplement.getBaseInforLevelFilePdf() :
                cimplement.getBaseInforLevelFile());
        req.setBaseEngineerPostpoFile(StringUtils.isNotBlank(cimplement.getBaseEngineerPostpoFilePdf()) ? cimplement.getBaseEngineerPostpoFilePdf() :
                cimplement.getBaseEngineerPostpoFile());
        req.setBaseEstaSummFile(StringUtils.isNotBlank(cimplement.getBaseEstaSummFilePdf()) ? cimplement.getBaseEstaSummFilePdf() :
                cimplement.getBaseEstaSummFile());
        req.setBaseFinanlAuditFile(StringUtils.isNotBlank(cimplement.getBaseFinanlAuditFilePdf()) ? cimplement.getBaseFinanlAuditFilePdf() :
                cimplement.getBaseFinanlAuditFile());
        req.setBaseFinalExpertOpinionFile(StringUtils.isNotBlank(cimplement.getBaseFinalExpertOpinionFilePdf()) ? cimplement.getBaseFinalExpertOpinionFilePdf() :
                cimplement.getBaseFinalExpertOpinionFile());
        req.setBaseThirdAcceptFile(StringUtils.isNotBlank(cimplement.getBaseThirdAcceptFilePdf()) ? cimplement.getBaseThirdAcceptFilePdf() :
                cimplement.getBaseThirdAcceptFile());
        req.setBaseInitialOpinionFile(StringUtils.isNotBlank(cimplement.getBaseInitialOpinionFilePdf()) ? cimplement.getBaseInitialOpinionFilePdf() :
                cimplement.getBaseInitialOpinionFile());
        req.setBaseIrsTestRunFile(StringUtils.isNotBlank(cimplement.getBaseIrsTestRunFilePdf()) ? cimplement.getBaseIrsTestRunFilePdf() :
                cimplement.getBaseIrsTestRunFile());
        return req;
    }

    public static ProjectApproveReq convertApprove(GovBizProjectApproveDTO approve) {
        ProjectApproveReq req = new ProjectApproveReq();
        if (Objects.isNull(approve)) {
            return req;
        }
        req.setBaseProjId(approve.getBaseProjId());
        req.setBaseProjName(approve.getBaseProjName());
        req.setOp(approve.getOp());
        req.setApprovalFile(approve.getApprovalFile());
        req.setBaseReviewCommentsFile(approve.getBaseReviewCommentsFile());
        req.setPreliminaryDesignFile(approve.getPreliminaryDesignFile());
        req.setAreaCode(approve.getAreaCode());
        req.setBaseDevelopCode(approve.getBaseDevelopCode());
        req.setBaseExpertTotalMoney(Objects.nonNull(approve.getBaseExpertTotalMoney()) ? String.valueOf(approve.getBaseExpertTotalMoney()) : null);
        req.setBaseExpertYearMoney(Objects.nonNull(approve.getBaseExpertYearMoney()) ? String.valueOf(approve.getBaseExpertYearMoney()) : null);
        req.setReleaseYearMoney(Objects.nonNull(approve.getReleaseYearMoney()) ? String.valueOf(approve.getReleaseYearMoney()) : null);
        req.setBaseInitialReviewTotalMoney(Objects.nonNull(approve.getBaseInitialReviewTotalMoney()) ? String.valueOf(approve.getBaseInitialReviewTotalMoney()) : null);
        req.setBaseReviewOpinion(approve.getBaseReviewOpinion());
        req.setBaseReviewResults(approve.getBaseReviewResults());
        req.setEqualProtectionLevel(approve.getEqualProtectionLevel());
        req.setPreliminaryDesignScheme(approve.getPreliminaryDesignScheme());
        req.setSetProjCodeFinan(approve.getSetProjCodeFinan());
        return req;
    }

    public static ProjectApproveReq convertApproveVo(GovBizProjectApproveVO approve) {
        ProjectApproveReq req = new ProjectApproveReq();
        if (Objects.isNull(approve)) {
            return req;
        }
        req.setBaseProjId(approve.getBaseProjId());
        req.setBaseProjName(approve.getBaseProjName());
        req.setOp(approve.getOp());
        req.setApprovalFile(approve.getApprovalFile());
        req.setBaseReviewCommentsFile(approve.getBaseReviewCommentsFile());
        req.setPreliminaryDesignFile(approve.getPreliminaryDesignFile());
        req.setAreaCode(approve.getAreaCode());
        req.setBaseDevelopCode(approve.getBaseDevelopCode());
        req.setBaseExpertTotalMoney(Objects.nonNull(approve.getBaseExpertTotalMoney()) ? String.valueOf(approve.getBaseExpertTotalMoney()) : null);
        req.setBaseExpertYearMoney(Objects.nonNull(approve.getBaseExpertYearMoney()) ? String.valueOf(approve.getBaseExpertYearMoney()) : null);
        req.setReleaseYearMoney(Objects.nonNull(approve.getReleaseYearMoney()) ? String.valueOf(approve.getReleaseYearMoney()) : null);
        req.setBaseInitialReviewTotalMoney(Objects.nonNull(approve.getBaseInitialReviewTotalMoney()) ? String.valueOf(approve.getBaseInitialReviewTotalMoney()) : null);
        req.setBaseReviewOpinion(approve.getBaseReviewOpinion());
        req.setBaseReviewResults(approve.getBaseReviewResults());
        req.setEqualProtectionLevel(approve.getEqualProtectionLevel());
        req.setPreliminaryDesignScheme(approve.getPreliminaryDesignScheme());
        req.setSetProjCodeFinan(approve.getSetProjCodeFinan());
        return req;
    }

    public static ProjectApproveReq convertApproveVoWithConvertPdf(GovBizProjectApproveVO approve) {
        ProjectApproveReq req = new ProjectApproveReq();
        if (Objects.isNull(approve)) {
            return req;
        }
        req.setBaseProjId(approve.getBaseProjId());
        req.setBaseProjName(approve.getBaseProjName());
        req.setOp(approve.getOp());
        req.setApprovalFile(StringUtils.isNotBlank(approve.getApprovalFilePdf()) ? approve.getApprovalFilePdf() :
                null);
        req.setBaseReviewCommentsFile(StringUtils.isNotBlank(approve.getBaseReviewCommentsFilePdf()) ? approve.getBaseReviewCommentsFilePdf() :
                null);
        req.setPreliminaryDesignFile(StringUtils.isNotBlank(approve.getPreliminaryDesignFilePdf()) ? approve.getPreliminaryDesignFilePdf() :
                null);
        req.setAreaCode(approve.getAreaCode());
        req.setBaseDevelopCode(approve.getBaseDevelopCode());
        req.setBaseProjReplyAmount(Objects.nonNull(approve.getBaseProjReplyAmount()) ? String.valueOf(approve.getBaseProjReplyAmount()) : null);
        req.setBaseExpertTotalMoney(Objects.nonNull(approve.getBaseExpertTotalMoney()) ? String.valueOf(approve.getBaseExpertTotalMoney()) : null);
        req.setBaseExpertYearMoney(Objects.nonNull(approve.getBaseExpertYearMoney()) ? String.valueOf(approve.getBaseExpertYearMoney()) : null);
        req.setReleaseYearMoney(Objects.nonNull(approve.getReleaseYearMoney()) ? String.valueOf(approve.getReleaseYearMoney()) : null);
        req.setBaseInitialReviewTotalMoney(Objects.nonNull(approve.getBaseInitialReviewTotalMoney()) ? String.valueOf(approve.getBaseInitialReviewTotalMoney()) : null);
        req.setBaseReviewOpinion(approve.getBaseReviewOpinion());
        req.setBaseReviewResults(approve.getBaseReviewResults());
        req.setEqualProtectionLevel(approve.getEqualProtectionLevel());
        req.setPreliminaryDesignScheme(approve.getPreliminaryDesignScheme());
        req.setSetProjCodeFinan(approve.getSetProjCodeFinan());
        return req;
    }

    public static ProjectApplyReq convertApply(GovBizProjectApplyDTO apply) {
        ProjectApplyReq req = new ProjectApplyReq();
        if (Objects.isNull(apply)) {
            return req;
        }
        req.setOp(apply.getOp());
        req.setBaseProjId(apply.getBaseProjId());
        req.setBaseProjName(apply.getBaseProjName());
        req.setAreaCode(apply.getAreaCode());
        req.setBaseAccountAppName(apply.getBaseAccountAppName());
        req.setBaseBasisEstablish(apply.getBaseBasisEstablish());
        req.setBaseCoreBusiness(apply.getBaseCoreBusiness());
        req.setBaseCoreBusinessCode(apply.getBaseCoreBusinessCode());
        req.setBaseBrainName(apply.getBaseBrainName());
        req.setBaseDevelopCode(apply.getBaseDevelopCode());
        req.setBaseLowestLevel(apply.getBaseLowestLevel());
        req.setBaseHistorProjId(apply.getBaseHistorProjId());
        req.setBaseHistorProjName(apply.getBaseHistorProjName());
        req.setBaseOperatMaintenFile(apply.getBaseOperatMaintenFile());
        req.setBaseProjApplyFile(apply.getBaseProjApplyFile());
        req.setBaseProjBasisFile(apply.getBaseProjBasisFile());
        req.setBaseProjOtherFile(apply.getBaseProjOtherFile());
        req.setBaseResearchReportFile(apply.getBaseResearchReportFile());
        req.setBaseProjConsClass(apply.getBaseProjConsClass());
        req.setBaseProjDuration(String.valueOf(apply.getBaseProjDuration()));
        req.setBaseProjIntro(apply.getBaseProjIntro());
        req.setBaseProjStartTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjStartTime()));
        req.setBaseProjEndTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjEndTime()));
        req.setBaseProjSetYear(apply.getBaseProjSetYear());
        req.setBaseProjSys(apply.getBaseProjSys());
        req.setBaseProjSysCode(apply.getBaseProjSysCode());
        req.setBaseProjDeclAmount(String.valueOf(apply.getBaseProjDeclAmount()));
        req.setBaseProjTotalAmount(String.valueOf(apply.getBaseProjTotalAmount()));
        req.setBaseBasisAmountOri(apply.getBaseBasisAmountOri());
        req.setBaseProjAmountOri(apply.getBaseProjAmountOri());
        req.setBaseProjRemark(apply.getBaseProjRemark());
        req.setBeseExpectedResults(apply.getBeseExpectedResults());
        req.setBaseProjBasis(apply.getBaseProjBasis());
        return req;
    }

    public static ProjectApplyReq convertApplyVo(GovBizProjectApplyVO apply) {
        ProjectApplyReq req = new ProjectApplyReq();
        if (Objects.isNull(apply)) {
            return req;
        }
        req.setOp(apply.getOp());
        req.setBaseProjId(apply.getBaseProjId());
        req.setBaseProjName(apply.getBaseProjName());
        req.setAreaCode(apply.getAreaCode());
        req.setBaseAccountAppName(apply.getBaseAccountAppName());
        req.setBaseBasisEstablish(apply.getBaseBasisEstablish());
        req.setBaseCoreBusiness(apply.getBaseCoreBusiness());
        req.setBaseCoreBusinessCode(apply.getBaseCoreBusinessCode());
        req.setBaseBrainName(apply.getBaseBrainName());
        req.setBaseDevelopCode(apply.getBaseDevelopCode());
        req.setBaseLowestLevel(apply.getBaseLowestLevel());
        req.setBaseHistorProjId(apply.getBaseHistorProjId());
        req.setBaseHistorProjName(apply.getBaseHistorProjName());
        req.setBaseOperatMaintenFile(apply.getBaseOperatMaintenFile());
        req.setBaseProjApplyFile(apply.getBaseProjApplyFile());
        req.setBaseProjBasisFile(apply.getBaseProjBasisFile());
        req.setBaseProjOtherFile(apply.getBaseProjOtherFile());
        req.setBaseResearchReportFile(apply.getBaseResearchReportFile());
        req.setBaseProjConsClass(apply.getBaseProjConsClass());
        req.setBaseProjDuration(String.valueOf(apply.getBaseProjDuration()));
        req.setBaseProjIntro(apply.getBaseProjIntro());
        req.setBaseProjStartTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjStartTime()));
        req.setBaseProjEndTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjEndTime()));
        req.setBaseProjSetYear(apply.getBaseProjSetYear());
        req.setBaseProjSys(apply.getBaseProjSys());
        req.setBaseProjSysCode(apply.getBaseProjSysCode());
        req.setBaseProjDeclAmount(String.valueOf(apply.getBaseProjDeclAmount()));
        req.setBaseProjTotalAmount(String.valueOf(apply.getBaseProjTotalAmount()));
        req.setBaseBasisAmountOri(apply.getBaseBasisAmountOri());
        req.setBaseProjAmountOri(apply.getBaseProjAmountOri());
        req.setBaseProjRemark(apply.getBaseProjRemark());
        req.setBeseExpectedResults(apply.getBeseExpectedResults());
        req.setBaseProjBasis(apply.getBaseProjBasis());
        return req;
    }

    public static ProjectApplyReq convertApplyVoWithConvertPdf(GovBizProjectApplyVO apply) {
        ProjectApplyReq req = new ProjectApplyReq();
        if (Objects.isNull(apply)) {
            return req;
        }
        req.setOp(apply.getOp());
        req.setBaseProjId(apply.getBaseProjId());
        req.setBaseProjName(apply.getBaseProjName());
        req.setAreaCode(apply.getAreaCode());
        req.setBaseAccountAppName(apply.getBaseAccountAppName());
        req.setBaseBasisEstablish(apply.getBaseBasisEstablish());
        req.setBaseCoreBusiness(apply.getBaseCoreBusiness());
//        req.setBaseCoreBusinessCode(apply.getBaseCoreBusinessCode());
        req.setBaseBrainName(apply.getBaseBrainName());
        req.setBaseDevelopCode(apply.getBaseDevelopCode());
        req.setBaseLowestLevel(apply.getBaseLowestLevel());
        if (Objects.nonNull(apply.getMissing()) && apply.getMissing()) {
            req.setBaseHistorProjId(BizProjectContant.ProjectCollection.MISSING_HIS_PROJ_ID);
            req.setBaseHistorProjName(BizProjectContant.ProjectCollection.MISSING_HIS_PROJ_NAME);
        } else {
            req.setBaseHistorProjId(apply.getBaseHistorProjId());
            req.setBaseHistorProjName(apply.getBaseHistorProjName());
        }
        req.setBaseOperatMaintenFile(StringUtils.isNotBlank(apply.getBaseOperatMaintenFilePdf()) ? apply.getBaseOperatMaintenFilePdf() :
                apply.getBaseOperatMaintenFile());
        req.setBaseProjApplyFile(StringUtils.isNotBlank(apply.getBaseProjApplyFilePdf()) ? apply.getBaseProjApplyFilePdf() :
                apply.getBaseProjApplyFile());
        req.setBaseProjBasisFile(StringUtils.isNotBlank(apply.getBaseProjBasisFilePdf()) ? apply.getBaseProjBasisFilePdf() :
                apply.getBaseProjBasisFile());
        req.setBaseProjOtherFile(StringUtils.isNotBlank(apply.getBaseProjOtherFilePdf()) ? apply.getBaseProjOtherFilePdf() :
                apply.getBaseProjOtherFile());
        req.setBaseResearchReportFile(StringUtils.isNotBlank(apply.getBaseResearchReportFilePdf()) ? apply.getBaseResearchReportFilePdf() :
                apply.getBaseResearchReportFile());
        req.setBaseProjConsClass(apply.getBaseProjConsClass());
        req.setBaseProjDuration((StringUtils.isNotBlank(apply.getBaseProjDuration()) ? apply.getBaseProjDuration() : "0")
                + BizProjectContant.ProjectCollection.MONTH);
        req.setBaseProjIntro(apply.getBaseProjIntro());
        req.setBaseProjStartTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjStartTime()));
        req.setBaseProjEndTime(ProjectCollectionUtil.convertLocalDateTime(apply.getBaseProjEndTime()));
        req.setBaseProjSetYear(apply.getBaseProjSetYear());
        req.setBaseProjSys(apply.getBaseProjSys());
        req.setBaseProjSysCode(apply.getBaseProjSysCode());
        req.setBaseProjDeclAmount(Objects.nonNull(apply.getBaseProjDeclAmount()) ? String.valueOf(apply.getBaseProjDeclAmount()) : null);
        req.setBaseProjTotalAmount(Objects.nonNull(apply.getBaseProjTotalAmount()) ? String.valueOf(apply.getBaseProjTotalAmount()) : null);
        req.setBaseBasisAmountOri(apply.getBaseBasisAmountOri());
        req.setBaseProjAmountOri(apply.getBaseProjAmountOri());
        req.setBaseProjRemark(apply.getBaseProjRemark());
        req.setBeseExpectedResults(apply.getBeseExpectedResults());
        req.setBaseProjBasis(apply.getBaseProjBasis());
        return req;
    }

    public static ProjectBaseInfoReq convertBase(GovBizProjectBaseinfoDTO baseinfo, String isEffective) {
        ProjectBaseInfoReq req = BeanUtil.copyProperties(baseinfo, ProjectBaseInfoReq.class);
        req.setIsEffective(isEffective);
        return req;
    }

    public static ProjectBaseInfoReq convertBaseVo(GovBizProjectBaseinfoVO baseinfo, String isEffective) {
        ProjectBaseInfoReq req = BeanUtil.copyProperties(baseinfo, ProjectBaseInfoReq.class);
        req.setIsEffective(isEffective);
        return req;
    }

    public static ProjectBaseInfoReq convertBaseVo(GovOperationProjectBaseinfoVO baseinfo, String isEffective) {
        ProjectBaseInfoReq req = BeanUtil.copyProperties(baseinfo, ProjectBaseInfoReq.class);
        req.setIsEffective(isEffective);
        return req;
    }
}
