package cn.iocoder.lyzsys.module.tjt.controller.admin.project.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDate;

import static cn.iocoder.lyzsys.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;

@Schema(description = "管理后台 - 项目新增/修改 Request VO")
@Data
public class ProjectSaveReqVO {

    @Schema(description = "项目 ID", example = "1")
    private Long id;

    @Schema(description = "项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "XX 设计项目")
    @NotBlank(message = "项目名称不能为空")
    @Size(max = 200, message = "项目名称长度不能超过 200 个字符")
    private String projectName;

    @Schema(description = "排序", example = "0")
    private Integer sortNo;

    @Schema(description = "是否签订合同", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    @NotNull(message = "是否签订合同不能为空")
    private Boolean contractSignedFlag;

    @Schema(description = "合同总产值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000000")
    @NotNull(message = "合同总产值不能为空")
    private BigDecimal contractAmount;

    @Schema(description = "建筑面积", requiredMode = Schema.RequiredMode.REQUIRED, example = "30000")
    @NotNull(message = "建筑面积不能为空")
    private BigDecimal totalConstructionArea;

    @Schema(description = "建设单位", example = "XX 建设单位")
    @Size(max = 200, message = "建设单位长度不能超过 200 个字符")
    private String constructionUnitName;

    @Schema(description = "建设单位联系人", example = "张三")
    @Size(max = 64, message = "建设单位联系人长度不能超过 64 个字符")
    private String contactName;

    @Schema(description = "建设单位联系电话", example = "13800000000")
    @Size(max = 32, message = "建设单位联系电话长度不能超过 32 个字符")
    private String contactPhone;

    @Schema(description = "合同签订日期", example = "2026-04-14")
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
    private LocalDate contractSigningDate;

    @Schema(description = "工程类型", example = "建筑工程")
    @Size(max = 50, message = "工程类型长度不能超过 50 个字符")
    private String projectType;

    @Schema(description = "设计类型", example = "住宅")
    @Size(max = 50, message = "设计类型长度不能超过 50 个字符")
    private String projectCategory;

    @Schema(description = "项目开始年度", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026")
    @NotNull(message = "项目开始年度不能为空")
    private Integer projectStartYear;

    @Schema(description = "项目状态", example = "进行中")
    @Size(max = 20, message = "项目状态长度不能超过 20 个字符")
    private String projectStatus;

    @Schema(description = "暂停原因")
    @Size(max = 255, message = "暂停原因长度不能超过 255 个字符")
    private String pauseReason;

    @Schema(description = "中止原因")
    @Size(max = 255, message = "中止原因长度不能超过 255 个字符")
    private String terminateReason;

    @Schema(description = "结算合同总产值", example = "1200000")
    private BigDecimal finalSettlementAmount;

    @Schema(description = "科创产值比例", example = "0.0100")
    @DecimalMin(value = "0.0000", message = "科创产值比例不能小于 0%")
    @DecimalMax(value = "1.0000", message = "科创产值比例不能大于 100%")
    private BigDecimal innovationOutputRate;

    @Schema(description = "其他成本", example = "20000.00")
    private BigDecimal otherCost;

    @Schema(description = "项目角色人员列表")
    @Valid
    private java.util.List<ProjectRolePersonSaveReqVO> rolePersons;

}
