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

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 * <p>
 * ProjectLibListItemVO
 * </p>
 *
 * @author WendyYang
 * @since 15:13 2023/2/1
 */
@Data
@ApiModel("项目库列表视图")
public class ProjectLibListItemVO {

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

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

    @ApiModelProperty("申报金额")
    private BigDecimal declaredAmount;

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

    @ApiModelProperty("项目类型")
    private Integer projectType;

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

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

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

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

    @ApiModelProperty("业务领域")
    private String bizDomain;

    @ApiModelProperty("流程状态")
    private Integer processStatus;

    @ApiModelProperty("实例code")
    private String instCode;

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

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

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

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

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

}
