package com.ruoyi.info.collection.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 招投标信息编辑DTO
 *
 * @author ruoyi
 * @date 2026-02-06
 */
@Data
@Schema(description = "招投标信息编辑")
public class CcdiPurchaseTransactionEditDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /** 采购事项ID */
    @NotBlank(message = "采购事项ID不能为空")
    @Size(max = 32, message = "采购事项ID长度不能超过32个字符")
    @Schema(description = "采购事项ID")
    private String purchaseId;

    /** 采购类别 */
    @NotBlank(message = "采购类别不能为空")
    @Size(max = 50, message = "采购类别长度不能超过50个字符")
    @Schema(description = "采购类别")
    private String purchaseCategory;

    /** 项目名称 */
    @Size(max = 200, message = "项目名称长度不能超过200个字符")
    @Schema(description = "项目名称")
    private String projectName;

    /** 标的物名称 */
    @NotBlank(message = "标的物名称不能为空")
    @Size(max = 200, message = "标的物名称长度不能超过200个字符")
    @Schema(description = "标的物名称")
    private String subjectName;

    /** 标的物描述 */
    @Schema(description = "标的物描述")
    private String subjectDesc;

    /** 采购数量 */
    @NotNull(message = "采购数量不能为空")
    @DecimalMin(value = "0.0001", message = "采购数量必须大于0")
    @Schema(description = "采购数量")
    private BigDecimal purchaseQty;

    /** 预算金额 */
    @NotNull(message = "预算金额不能为空")
    @DecimalMin(value = "0.01", message = "预算金额必须大于0")
    @Schema(description = "预算金额")
    private BigDecimal budgetAmount;

    /** 中标金额 */
    @DecimalMin(value = "0.01", message = "中标金额必须大于0")
    @Schema(description = "中标金额")
    private BigDecimal bidAmount;

    /** 实际采购金额 */
    @DecimalMin(value = "0.01", message = "实际采购金额必须大于0")
    @Schema(description = "实际采购金额")
    private BigDecimal actualAmount;

    /** 合同金额 */
    @DecimalMin(value = "0.01", message = "合同金额必须大于0")
    @Schema(description = "合同金额")
    private BigDecimal contractAmount;

    /** 结算金额 */
    @DecimalMin(value = "0.01", message = "结算金额必须大于0")
    @Schema(description = "结算金额")
    private BigDecimal settlementAmount;

    /** 采购方式 */
    @NotBlank(message = "采购方式不能为空")
    @Size(max = 50, message = "采购方式长度不能超过50个字符")
    @Schema(description = "采购方式")
    private String purchaseMethod;

    /** 供应商明细 */
    @Valid
    @Schema(description = "供应商明细列表")
    private List<CcdiPurchaseTransactionSupplierDTO> supplierList;

    /** 采购申请日期（或立项日期） */
    @NotNull(message = "采购申请日期不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "采购申请日期")
    private Date applyDate;

    /** 采购计划批准日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "采购计划批准日期")
    private Date planApproveDate;

    /** 采购公告发布日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "采购公告发布日期")
    private Date announceDate;

    /** 开标日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "开标日期")
    private Date bidOpenDate;

    /** 合同签订日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "合同签订日期")
    private Date contractSignDate;

    /** 预计交货日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "预计交货日期")
    private Date expectedDeliveryDate;

    /** 实际交货日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "实际交货日期")
    private Date actualDeliveryDate;

    /** 验收日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "验收日期")
    private Date acceptanceDate;

    /** 结算日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Schema(description = "结算日期")
    private Date settlementDate;

    /** 申请人工号 */
    @NotBlank(message = "申请人工号不能为空")
    @Pattern(regexp = "^\\d{7}$", message = "申请人工号必须为7位数字")
    @Schema(description = "申请人工号")
    private String applicantId;

    /** 申请人姓名 */
    @NotBlank(message = "申请人姓名不能为空")
    @Size(max = 50, message = "申请人姓名长度不能超过50个字符")
    @Schema(description = "申请人姓名")
    private String applicantName;

    /** 申请部门 */
    @NotBlank(message = "申请部门不能为空")
    @Size(max = 100, message = "申请部门长度不能超过100个字符")
    @Schema(description = "申请部门")
    private String applyDepartment;

    /** 采购负责人工号 */
    @Pattern(regexp = "^\\d{7}$", message = "采购负责人工号必须为7位数字")
    @Schema(description = "采购负责人工号")
    private String purchaseLeaderId;

    /** 采购负责人姓名 */
    @Size(max = 50, message = "采购负责人姓名长度不能超过50个字符")
    @Schema(description = "采购负责人姓名")
    private String purchaseLeaderName;

    /** 采购部门 */
    @Size(max = 100, message = "采购部门长度不能超过100个字符")
    @Schema(description = "采购部门")
    private String purchaseDepartment;
}
