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

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hz.pm.api.common.compare.Compare;
import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Tolerate;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;

/**
 * <p>
 * ProjectContractListVO
 * </p>
 *
 * @author ZPF
 * @since 15:13 2023/11/15
 */
@Data
@Builder
@ApiModel("合同项目库列表视图")
public class ProjectContractListVO {

    @Tolerate
    public ProjectContractListVO() {
    }

    @ApiModelProperty("项目ID")
    private Long id;

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

    @ApiModelProperty("区域")
    private String area;

    @ApiModelProperty("区域Code")
    private String areaCode;

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

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

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

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

    @ApiModelProperty("申报年度")
    private Integer projectYear;

    @ApiModelProperty("申报单位")
    private String buildOrg;

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

    private String projectTypeName;

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

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

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

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    private LocalDateTime createOn;

    @ApiModelProperty("修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    private LocalDateTime updateOn;

    @ApiModelProperty("能否能补充")
    private Boolean supplemented = Boolean.FALSE;


}
