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

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hz.pm.api.common.compare.Compare;
import com.hz.pm.api.portrait.model.vo.TagVO;
import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
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.List;
import java.util.Objects;
import java.util.Optional;

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

    @Tolerate
    public ProjectLibListItemVO() {
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    private String projectTypeName;

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

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

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

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

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

    @ApiModelProperty("建设周期 月")
    private Integer buildCycle;

    @ApiModelProperty("计划验收时间")
    @JSONField(format = "yyyy-MM-dd")
    private LocalDateTime planAcceptanceTime;

    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 canPreDeclared = Boolean.FALSE;

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

    @ApiModelProperty("是否可以申请延期")
    private Boolean canDelayApply = Boolean.TRUE;

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

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

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

    //预审申报时候 需不需要上传上级条线意见文件
    private Boolean needUploadSuperLineFile;

    @ApiModelProperty("当前审批人")
    private List<UserFullInfoDTO> approveUsers;

    @ApiModelProperty("年度投资金额总额")
    private BigDecimal annualAccumulateAmount;
    private List<AnnualAmountVO> annualAccumulateAmountList;

}
