package com.ningdatech.pmapi.projectlib.model.vo;

import com.alibaba.fastjson.JSON;
import com.ningdatech.pmapi.common.util.BizUtils;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum;
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("应用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("是否临时增补 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 buildOrgCode;

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

    @ApiModelProperty("项目类型 1:建设 2:运维")
    private Integer projectType;

    @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 String bizDomain;

    @ApiModelProperty("建设层级 1:国家级 2:省级 3:省本级 4:市级 5:市本级 6:区县 7乡镇")
    private Integer buildLevel;

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

    @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;

    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 approvedFile;

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

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

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

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

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

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

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

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

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

    @ApiModelProperty("项目发起人id")
    private Long sponsor;

    private String projectTypeName;

    public String getProjectTypeName() {
        if (Objects.nonNull(this.projectType)) {
            Optional.ofNullable(ProjectTypeEnum.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);
        }
    }
}
