package com.ruoyi.credit.domain;

import java.util.Date;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.constraints.Min;
import javax.validation.constraints.Max;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 贷款一致性验证记录对象 dc_loan_consistency_validation
 * 
 * @author ruoyi
 * @date 2025-12-30
 */
public class LoanConsistencyValidation extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 验证记录ID */
    private Long validationId;

    /** 贷款ID */
    @Excel(name = "贷款ID")
    @NotNull(message = "贷款ID不能为空")
    private Long loanId;

    /** 债权凭证ID */
    @Excel(name = "债权凭证ID")
    private Long creditId;

    /** 服务周期ID */
    @Excel(name = "服务周期ID")
    private Long servicePeriodId;

    /** 合同ID */
    @Excel(name = "合同ID")
    private Long contractId;

    /** 验证状态 */
    @Excel(name = "验证状态")
    @NotNull(message = "验证状态不能为空")
    @Size(max = 20, message = "验证状态长度不能超过20个字符")
    private String validationStatus;

    /** 验证结果详情 */
    @Excel(name = "验证结果详情")
    @Size(max = 2000, message = "验证结果详情长度不能超过2000个字符")
    private String validationResult;

    /** 失败原因 */
    @Excel(name = "失败原因")
    @Size(max = 1000, message = "失败原因长度不能超过1000个字符")
    private String failureReason;

    /** 验证时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "验证时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "验证时间不能为空")
    private Date validationTime;

    /** 验证执行者 */
    @Excel(name = "验证执行者")
    @Size(max = 100, message = "验证执行者长度不能超过100个字符")
    private String validatedBy;

    /** 验证得分(0-100) */
    @Excel(name = "验证得分")
    @Min(value = 0, message = "验证得分不能小于0")
    @Max(value = 100, message = "验证得分不能大于100")
    private Integer validationScore;

    /** 使用的规则版本 */
    @Excel(name = "规则版本")
    @Size(max = 50, message = "规则版本长度不能超过50个字符")
    private String ruleVersion;

    // 验证状态常量
    public static final String STATUS_PASS = "PASS";           // 验证通过
    public static final String STATUS_FAIL = "FAIL";           // 验证失败
    public static final String STATUS_PENDING = "PENDING";     // 验证中
    public static final String STATUS_ERROR = "ERROR";         // 验证错误
    public static final String STATUS_TIMEOUT = "TIMEOUT";     // 验证超时

    public void setValidationId(Long validationId) 
    {
        this.validationId = validationId;
    }

    public Long getValidationId() 
    {
        return validationId;
    }

    public void setLoanId(Long loanId) 
    {
        this.loanId = loanId;
    }

    public Long getLoanId() 
    {
        return loanId;
    }

    public void setCreditId(Long creditId) 
    {
        this.creditId = creditId;
    }

    public Long getCreditId() 
    {
        return creditId;
    }

    public void setServicePeriodId(Long servicePeriodId) 
    {
        this.servicePeriodId = servicePeriodId;
    }

    public Long getServicePeriodId() 
    {
        return servicePeriodId;
    }

    public void setContractId(Long contractId) 
    {
        this.contractId = contractId;
    }

    public Long getContractId() 
    {
        return contractId;
    }

    public void setValidationStatus(String validationStatus) 
    {
        this.validationStatus = validationStatus;
    }

    public String getValidationStatus() 
    {
        return validationStatus;
    }

    public void setValidationResult(String validationResult) 
    {
        this.validationResult = validationResult;
    }

    public String getValidationResult() 
    {
        return validationResult;
    }

    public void setFailureReason(String failureReason) 
    {
        this.failureReason = failureReason;
    }

    public String getFailureReason() 
    {
        return failureReason;
    }

    public void setValidationTime(Date validationTime) 
    {
        this.validationTime = validationTime;
    }

    public Date getValidationTime() 
    {
        return validationTime;
    }

    public void setValidatedBy(String validatedBy) 
    {
        this.validatedBy = validatedBy;
    }

    public String getValidatedBy() 
    {
        return validatedBy;
    }

    public void setValidationScore(Integer validationScore) 
    {
        this.validationScore = validationScore;
    }

    public Integer getValidationScore() 
    {
        return validationScore;
    }

    public void setRuleVersion(String ruleVersion) 
    {
        this.ruleVersion = ruleVersion;
    }

    public String getRuleVersion() 
    {
        return ruleVersion;
    }

    /**
     * 检查验证是否通过
     */
    public boolean isPassed() {
        return STATUS_PASS.equals(this.validationStatus);
    }

    /**
     * 检查验证是否失败
     */
    public boolean isFailed() {
        return STATUS_FAIL.equals(this.validationStatus);
    }

    /**
     * 检查验证是否正在进行中
     */
    public boolean isPending() {
        return STATUS_PENDING.equals(this.validationStatus);
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
            .append("validationId", getValidationId())
            .append("loanId", getLoanId())
            .append("contractId", getContractId())
            .append("creditId", getCreditId())
            .append("servicePeriodId", getServicePeriodId())
            .append("validationStatus", getValidationStatus())
            .append("validationResult", getValidationResult())
            .append("failureReason", getFailureReason())
            .append("validationTime", getValidationTime())
            .append("validatedBy", getValidatedBy())
            .append("validationScore", getValidationScore())
            .append("ruleVersion", getRuleVersion())
            .append("createTime", getCreateTime())
            .append("updateTime", getUpdateTime())
            .toString();
    }
}