package com.hz.pm.api.projectlib.model.vo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.ningdatech.basic.util.NdDateUtils;
import com.hz.pm.api.common.compare.Compare;
import com.hz.pm.api.common.util.BizUtils;
import com.hz.pm.api.dashboard.model.vo.ProtraitProjectOutputVO;
import com.hz.pm.api.portrait.model.vo.TagVO;
import com.hz.pm.api.projectdeclared.model.vo.ContractVO;
import com.hz.pm.api.projectdeclared.model.vo.OperationVO;
import com.hz.pm.api.projectdeclared.model.vo.PreInsAcceptancePersonVO;
import com.hz.pm.api.projectdeclared.model.vo.PurchaseVO;
import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum;
import com.hz.pm.api.safety.model.vo.SafetyMonitorVO;
import com.hz.pm.api.todocenter.model.vo.ProcessProgressDetailVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

/**
 * <p>
 * ProjectLibListItemVO
 * </p>
 *
 * @author WendyYang
 * @since 15:13 2023/2/1
 */
@Data
@ApiModel("项目详情")
public class ProjectDetailVO {

    @ApiModelProperty("来源 1申报项目 2项目归集")
    private String fromType;

    @ApiModelProperty("应用ID")
    private Long id;

    @ApiModelProperty("所属地区编号")
    private String areaCode;

    @ApiModelProperty("所属地区名称")
    private String area;

    @ApiModelProperty("项目阶段")
    private Integer stage;

    @ApiModelProperty("项目状态")
    private Integer status;

    @ApiModelProperty("项目名称")
    private String projectName;

    @ApiModelProperty("历年项目名称")
    private String baseHistorProjName;

    @ApiModelProperty("'历年项目编码'")
    private String baseHistorProjId;

    @ApiModelProperty("预算来源说明")
    private String baseBasisAmountOri;

    @ApiModelProperty("历年项目年度")
    private String baseHistorProjYear;

    @ApiModelProperty("是否临时增补 0:否 1:是")
    private Integer isTemporaryAugment;

    @ApiModelProperty("项目负责人")
    private String responsibleMan;

    @ApiModelProperty("负责人手机号码")
    private String responsibleManMobile;

    @ApiModelProperty("项目联系人")
    private String contactName;

    @ApiModelProperty("项目联系人手机号码")
    private String contactPhone;

    @ApiModelProperty("建设单位名称")
    private String buildOrgName;

    @ApiModelProperty("建设单位统一社会信用代码")
    private String orgCreditCode;

    @ApiModelProperty("公司编码code")
    private String buildOrgCode;

    @ApiModelProperty("建设单位浙政钉ID")
    private String buildOrgZheJiangGovDingId;

    @ApiModelProperty("项目类型 01:首次建设 02:迭代升级 03:结转建设 04新运维 05续运维")
    @Compare("项目类型")
    private String projectType;

    @ApiModelProperty("是否省级 1省级 2非省级")
    private Integer baseProvManDeprtType;

    @ApiModelProperty("是否首次新建 0:否 1:是")
    private Integer isFirst;

    @ApiModelProperty("项目预算年度")
    private Integer projectYear;

    @ApiModelProperty("项目建设起始时间")
    private String beginTime;

    @ApiModelProperty("项目建设终止时间")
    private String endTime;

    @ApiModelProperty("四大体系 1:业务应用 2:应用支撑 3:数据资源 4:基础设施")
    private Integer fourSystems;

    @ApiModelProperty("是否数字化改革项目 0:否 1:是")
    private Integer isDigitalReform;

    @ApiModelProperty("综合业务领域")
    private Integer bizDomain;

    @ApiModelProperty("建设层级 P省级 M市级 C县级 T乡镇级 V村级")
    @Compare("建设层级")
    private String buildLevel;

    @ApiModelProperty("贯通层级 P省级 M市级 C县级 T乡镇级 V村级")
    @Compare("贯通层级")
    private String lowestLevel;

    @ApiModelProperty("立项依据")
    private String buildBasis;

    @ApiModelProperty("立项依据说明")
    private String baseBasisEstablish;

    @ApiModelProperty("发改编码")
    private String developCode;

    @ApiModelProperty("财政编码")
    private String financialCode;

    @ApiModelProperty("是否上云 0:否 1:是")
    private Integer isCloud;

    private String cloudType;

    @ApiModelProperty("等保级别 1:一级 2:二级 3:三级 4:四级 5:五级")
    private Integer protectionLevel;

    @ApiModelProperty("是否密评 0:否 1:是")
    private Integer isSecretComments;

    @ApiModelProperty("项目简介")
    private String projectIntroduction;

    @ApiModelProperty("资金申报情况-申报金额(万元)")
    private BigDecimal declareAmount;

    @ApiModelProperty("资金申报情况-自有金额(万元)")
    private BigDecimal declareHaveAmount;

    @ApiModelProperty("资金申报情况-政府投资-本级财政资金(万元)")
    private BigDecimal declareGovOwnFinanceAmount;

    @ApiModelProperty("资金申报情况-政府投资-上级补助资金(万元)")
    private BigDecimal declareGovSuperiorFinanceAmount;

    @ApiModelProperty("银行贷款(万元)")
    private BigDecimal declareBankLendingAmount;

    @ApiModelProperty("其它资金(万元)")
    private BigDecimal declareOtherAmount;

    @ApiModelProperty("资金分配情况-软件开发(万元)")
    private BigDecimal softwareDevelopmentAmount;

    @ApiModelProperty("资金分配情况-云资源、硬件购置(万元)")
    private BigDecimal cloudHardwarePurchaseAmount;

    @ApiModelProperty("资金分配情况-第三方服务(万元)")
    private BigDecimal thirdPartyAmount;

    @ApiModelProperty("年度支付计划-年度支付计划(万元)")
    private BigDecimal annualPlanAmount;

    @ApiModelProperty("年度支付计划-自有金额(万元)")
    private BigDecimal annualPlanHaveAmount;

    @ApiModelProperty("年度支付计划-政府投资-本级财政资金(万元)")
    private BigDecimal annualPlanGovOwnFinanceAmount;

    @ApiModelProperty("年度支付计划-政府投资-上级补助资金(万元)")
    private BigDecimal annualPlanGovSuperiorFinanceAmount;

    @ApiModelProperty("年度支付计划-银行贷款(万元)")
    private BigDecimal annualPlanBankLendingAmount;

    @ApiModelProperty("年度支付计划-其它资金(万元)")
    private BigDecimal annualPlanOtherAmount;

    @ApiModelProperty("立项批复资金(万元)")
    private BigDecimal approvalAmount;

    @ApiModelProperty("立项批复总预算(万元)")
    @Compare("立项批复总预算")
    private BigDecimal approvalBudget;

    private LocalDateTime annualPlanAddTime;

    @ApiModelProperty("核心业务-核心业务模块")
    private String coreBusiness;

    @ApiModelProperty("安全投入-投入项")
    private String safetyInputTitle;

    @ApiModelProperty("安全投入-内容描述")
    private String safetyInputDescribe;

    @ApiModelProperty("安全投入-金额(万元)")
    private BigDecimal safetyInputAmount;

    @ApiModelProperty("附件-初步方案")
    private String preliminaryPlanFile;

    @ApiModelProperty("附件-延期佐证材料")
    private String supportingMaterialsFile;

    @ApiModelProperty("附件-项目总投资测算明细")
    private String calculationTotalInvestmentFile;

    @ApiModelProperty("附件-申报单位主要职责（单位三定方案）")
    private String mainResponsibilitiesApplicantFile;

    @ApiModelProperty("备注")
    private String projectRemarks;

    @ApiModelProperty("是否包含应用 0:否 1:是")
    private Integer includeApplication;

    @ApiModelProperty("工程形象进度-第一季度")
    private String engineeringSpeedOne;

    @ApiModelProperty("工程形象进度-第二季度")
    private String engineeringSpeedTwo;

    @ApiModelProperty("工程形象进度-第三季度")
    private String engineeringSpeedThree;

    @ApiModelProperty("工程形象进度-第四季度")
    private String engineeringSpeedFour;

    @ApiModelProperty("核心业务-是否开启核心业务模块 false:关闭 true:开启")
    private Boolean isOpenCoreBusiness;

    @ApiModelProperty("安全投入-是否开启安全投入模块 false:关闭 true:开启")
    private Boolean isOpenSafetyInput;

    @ApiModelProperty("工程形象进度-是否开启 false:关闭 true:开启")
    private Boolean isEngineeringSpeed;

    @ApiModelProperty("附件-是否开启 false:关闭 true:开启")
    private Boolean isAccessories;

    @ApiModelProperty("备注-是否开启 false:关闭 true:开启")
    private Boolean isRemarks;

    @ApiModelProperty("年度支付计划-是否开启 false:关闭 true:开启")
    private Boolean isAnnualPlanAmount;

    @ApiModelProperty("一地创新全省共享项目-是否开启 false:关闭 true:开启")
    private Boolean isInnovateWholeProvinceShare;

    @ApiModelProperty("安全投入-模块信息")
    private String safetyInputModular;

    @ApiModelProperty("项目申报pdf")
    private String projectPdf;

    @ApiModelProperty("立项申报pdf")
    private String declarationPdf;

    @ApiModelProperty("建设周期（月）")
    private String buildCycle;

    @ApiModelProperty("建设方案文件")
    private String constructionPlanFile;

    @ApiModelProperty("立项批复建设方案文件")
    private String approvedConstructionPlanFile;

    @ApiModelProperty("立项批复建设方案文件名")
    private String approvedConstructionPlanFileName;

    @ApiModelProperty("立项批复文件")
    private String approvedFile;

    @ApiModelProperty("立项批复文件名")
    private String approvedFileName;

    @ApiModelProperty("批复金额")
    private BigDecimal approvedTotalInvestmentIncrease;

    @ApiModelProperty("立项批复时间")
    @JSONField(format = "yyyy-MM-dd")
    private LocalDateTime approvalDate;

    @ApiModelProperty("是否有上级条线主管部门 0没有 1有")
    private Integer isHigherSuperOrg;

    @ApiModelProperty("上级主管部门")
    private String higherSuperOrg;

    @ApiModelProperty("上级主管部门Code")
    private String higherSuperOrgCode;

    @ApiModelProperty("是否有主管部门 0没有 1有")
    private Integer isSuperOrg;

    @ApiModelProperty("主管部门名称")
    private String superOrg;

    @ApiModelProperty("主管部门Code")
    private String superOrgCode;

    @ApiModelProperty("前端所需验证字段")
    private String allApplicationsDone;

    @ApiModelProperty("项目应用")
    private List<ProjectApplicationVO> projectApplications;

    @ApiModelProperty("动态form")
    private Map<String, Object> dynamicForm;

    @ApiModelProperty("年度投资金额详情")
    private List<AnnualAmountVO> annualAccumulateAmountList;

    @ApiModelProperty("项目发起人 员工code")
    private String sponsor;

    @ApiModelProperty("上级条线单位审核意见")
    private String higherLineSuperOrgReviewComments;
    private String projectTypeName;

    @ApiModelProperty("项目预审申请单文件ID")
    private Long pretrialFileId;

    @ApiModelProperty("项目预审申请单文件名")
    private String pretrialFileName;

    @ApiModelProperty("项目建设方案申请单文件ID")
    private Long constructFileId;

    @ApiModelProperty("项目建设方案申请单文件名")
    private String constructFileName;

    @ApiModelProperty("21位项目编号")
    private String projectCode;

    @ApiModelProperty("项目申报书")
    private String projectApplicationForm;

    @ApiModelProperty("省级联审 审批结果")
    private String sjlsResult;

    @ApiModelProperty("版本号")
    private Integer version;

    @ApiModelProperty("是否是最新版本")
    private Boolean newest;

    private LocalDateTime createOn;
    private LocalDateTime updateOn;

    @ApiModelProperty("成交金额")
    private BigDecimal transactionAmount;

    @ApiModelProperty("成交时间")
    @JSONField(format = "yyyy-MM-dd")
    private LocalDateTime transactionTime;

    @ApiModelProperty("交货时间")
    @JSONField(format = "yyyy-MM-dd")
    private LocalDateTime deliveryTime;

    @ApiModelProperty("初验材料")
    private String preliminaryInspectionMaterials;

    @ApiModelProperty("终验材料")
    private String finalAcceptanceMaterials;

    @ApiModelProperty("合同总金额")
    private BigDecimal contractAmount;

    @ApiModelProperty("合同信息")
    private ContractVO contract;

    @ApiModelProperty("采购信息")
    private List<PurchaseVO> purchases;

    @ApiModelProperty("初审人员")
    private List<PreInsAcceptancePersonVO> acceptancePersons;

    @ApiModelProperty("实施信息")
    private OperationVO operation;

    @ApiModelProperty("版本号str")
    private String versionStr;

    @ApiModelProperty("初步方案项目ID")
    private Long prePlanProjectId;

    @ApiModelProperty("是否为建设方案申报")
    private Boolean isConstruct;

    @ApiModelProperty("区县预审上级条线主管单位盖章审核意见")
    private String countrySealAuditOpinion;

    @ApiModelProperty("区县预审上级条线主管单位盖章审核日期")
    private String countrySealAuditDate;

    @ApiModelProperty("区县预审盖章上级条线主管单位印章编号")
    private String countrySealNo;

    @ApiModelProperty("审批详情")
    private ProcessProgressDetailVO process;

    @ApiModelProperty("标签")
    private List<TagVO> tags;

    @ApiModelProperty("是否退回|驳回的项目版本")
    private Boolean isBackReject;

    @ApiModelProperty("原本计划验收时间")
    @Compare("原本计划验收时间")
    private LocalDateTime originPlanAcceptanceTime;

    @ApiModelProperty("延期月份数")
    private Integer applyDelayMonths;

    @ApiModelProperty("原始建设周期（月）")
    @Compare("建设周期（月）")
    private Integer originBuildCycle;

    @ApiModelProperty("计划验收时间(有可能是延期后的)")
    @Compare("计划验收时间")
    private LocalDateTime planAcceptanceTime;

    public String getVersionStr() {
        if (Objects.nonNull(this.newest) && this.newest) {
            this.versionStr = "当前版本";
            return this.versionStr;
        }
        this.versionStr = "v" + NdDateUtils.format(this.createOn, "yyyyMMddHHmmss");
        return this.versionStr;
    }


    public String getProjectTypeName() {
        if (Objects.nonNull(this.projectType)) {
            Optional.ofNullable(ProjectTypeNewEnum.getDesc(this.projectType))
                    .ifPresent(desc -> this.projectTypeName = desc);
        }
        return this.projectTypeName;
    }

    public void buildDynamicForm(String dynamicFormStr) {
        if (StringUtils.isNotBlank(dynamicFormStr) && BizUtils.getJSONType(dynamicFormStr)) {
            this.dynamicForm = JSON.parseObject(dynamicFormStr, Map.class);
        }
    }

    @ApiModelProperty("项目阶段中文")
    private String stageName;

    public String getStageName() {
        if (Objects.nonNull(this.stage)) {
            return ProjectStatusEnum.getDesc(this.stage);
        }
        return StringUtils.EMPTY;
    }

    @ApiModelProperty("项目状态中文")
    private String statusName;

    public String getStatusName() {
        if (Objects.nonNull(this.status)) {
            return ProjectStatusEnum.getDesc(this.status);
        }
        return StringUtils.EMPTY;
    }

    @ApiModelProperty("安全风险监测信息")
    private SafetyMonitorVO safetyInfo;

    @ApiModelProperty("项目内容与预期成效")
    private String beseExpectedResults;

    @ApiModelProperty("内容类别")
    private String baseConstructionType;

    @ApiModelProperty("可研报告")
    private String baseResearchReportFile;

    @ApiModelProperty("其他附件")
    private String baseProjOtherFile;

    @ApiModelProperty("是否完成日志数据归集")
    private Boolean isCompletedLogCollection;

    @ApiModelProperty("实际成效指标")
    private String actualPerformanceIndicators;

    @ApiModelProperty("主管单位统一社会信用代码")
    @Compare("主管单位统一社会信用代码")
    private String superOrgCreditCode;

    @ApiModelProperty("终验信息 IRS档案")
    private List<ProtraitProjectOutputVO> finalIrsApps;

    @ApiModelProperty("建议项目总投资")
    private BigDecimal proposeTotalInvest;

    @ApiModelProperty("建议年度预算")
    private BigDecimal proposeAnnualBudget;

    @ApiModelProperty("建议评审意见附件")
    private String proposeAttachFiles;

    @ApiModelProperty("专家评审意见")
    private String proposeAttach;

    @ApiModelProperty("专家评审结果")
    private Integer baseReviewResults;

    @ApiModelProperty("咨询公司")
    private String consultancy;

    @ApiModelProperty("是否开启评审清单")
    private Boolean isReviewChecklist;

    @ApiModelProperty("评审清单")
    private String reviewChecklist;

    @ApiModelProperty("是否开启评审清单")
    private Boolean reviewCheckFinish;

    @ApiModelProperty("是否推送省里")
    private Boolean push;

    @ApiModelProperty("系统定位")
    private String systemPosition;

    @ApiModelProperty("立项依据")
    private String baseProjBasis;

    @ApiModelProperty("立项依据证明材料")
    private String baseProjBasisFile;
}
