package cn.palmte.work.model;

import cn.palmte.work.bean.ApproveStatusEnum;
import org.hibernate.annotations.GenericGenerator;
import top.jfunc.common.datetime.DatetimeUtils;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 项目实体
 * @author xiongshiyan at 2021/10/29 , contact me with email yanshixiong@126.com or phone 15208384257
 */
@Entity
@Table(name = "project")
public class Project {
    public static final int STATUS_ESTIMATE = 1;
    public static final int STATUS_BUDGET = 5;
    public static final int STATUS_SETTLE = 10;
    public static final int STATUS_FINAL = 15;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @GenericGenerator(name = "persistenceGenerator", strategy = "increment")
    private int id;
    /**
     * 序号
     */
    @Transient
    private int tempId;
    /**
     * 项目编号
     */
    private String projectNo;
    /**
     * 项目名称
     */
    private String name;
    /**
     * 项目类型：1工程集成类、2设备集成类、3战略合作类
     */
    private int type;
    @Column(name = "type_desc")
    private String typeDesc;
    /**
     * 项目状态：1项目创建(概算)，5预算，10结算，15决算
     */
    private int status;
    @Column(name = "status_desc")
    private String statusDesc;
    /**
     * 概算、预算、结算、决算：审核状态：0草稿，1待审核，2审核通过，3审核不通过
     */
    @Column(name = "approve_status_estimate")
    private int approveStatusEstimate = -1;
    @Column(name = "approve_status_budget")
    private int approveStatusBudget = -1;
    @Column(name = "approve_status_settle")
    private int approveStatusSettle = -1;
    @Column(name = "approve_status_final")
    private int approveStatusFinal = -1;

    /**
     * 审核人id
     */
    @Column(name = "approve_id")
    private int approveId = 0;
    @Column(name = "approve_name")
    private String approveName;
    /**
     * 项目创建者id
     */
    @Column(name = "creator_id")
    private int creatorId;
    @Column(name = "creator_name")
    private String creatorName;
    /**
     * 项目部门id
     */
    @Column(name = "dept_id")
    private int deptId;
    @Column(name = "dept_name")
    private String deptName;
    /**
     * 项目开始时间，精确到月
     */
    @Column(name = "start_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startDate;
    /**
     * 项目结束时间，精确到月
     */
    @Column(name = "end_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endDate;
    /**
     * 垫资模式：1A类-不垫资（战略合作），2B类-不垫资（背靠背），3C类-垫资（账期覆盖），4D类-垫资（账期不覆盖）
     */
    @Column(name = "underwritten_mode")
    private int underwrittenMode;
    /**
     * 合作对象
     */
    @Column(name = "collaborator")
    private String collaborator;
    /**
     * 合作对象url
     */
    @Column(name = "collaborator_url")
    private String collaboratorUrl;
    /**
     * 客户名称
     */
    @Column(name = "customer")
    private String customer;
    /**
     * 终端客户名称
     */
    @Column(name = "terminal_customer")
    private String terminalCustomer;
//    /**
//     * 垫资利息（元为单位）
//     */
//    @Column(name = "advance_interest_amount")
//    private BigDecimal advanceInterestAmount;
//    /**
//     * 垫资峰值
//     */
//    @Column(name = "advance_peak_amount")
//    private BigDecimal advancePeakAmount;
    /**
     * 合同金额
     */
    @Column(name = "contract_amount")
    private BigDecimal contractAmount;
    /**
     * 行业场景应用
     */
    @Column(name = "industry_scenario")
    private String industryScenario;
    /**
     *华智产品金额
     */
    @Column(name = "huazhi_product_amount")
    private BigDecimal huazhiProductAmount;
    /**
     *其他产品金额
     */
    @Column(name = "ziguang_other_amount")
    private BigDecimal ziguangOtherAmount;
    /**
     * 主合同收款条款
     */
    @Column(name = "main_contract_collection_terms")
    private String mainContractCollectionTerms;
    /**
     * 价值及风险
     */
    @Column(name = "value_risk")
    private String valueRisk;
    /**
     * 其他中的小类名称
     */
    @Column(name = "other_name")
    private String otherName;
    /**
     * 项目创建时的配置的阀值
     */
    @Column(name = "project_contribution_profit_rate_threshold")
    private BigDecimal projectContributionProfitRateThreshold;
    /**
     * 项目创建配置的年利率
     */
    @Column(name = "underwritten_tax_rate")
    private BigDecimal underwrittenTaxRate;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    /**
     * 最后更新时间
     */
    @Column(name = "last_update_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdateTime;

    @Column(name = "plan_start_str")
    private String planStartStr;

    @Column(name = "plan_end_str")
    private String planEndStr;

    @Transient
    private String underwrittenModeDesc;

    @Column(name = "certainty")
    private String certainty;

    @Transient
    private String certaintyStr;

    @Column(name = "gross_profit")
    private BigDecimal grossProfit;

    @Column(name = "gross_profit_margin")
    private BigDecimal grossProfitMargin;

    @Column(name = "huizhi_product_amount")
    private BigDecimal huizhiProductAmount;

    @Column(name = "huasan_product_amount")
    private BigDecimal huasanProductAmount;

    @Column(name = "principal")
    private String principal;

    @Column(name = "contract_time")
    private Date contractTime;

    @Column(name = "bids_time")
    private Date bidsTime;

    @Column(name = "is_second")
    private int isSecond;

    @Transient
    private String isSecondStr;

    @Column(name = "sign_type")
    private int signType;

    @Transient
    private String signTypeStr;

    @Column(name = "resolve_plan")
    private int resolvePlan;

    @Transient
    private String resolvePlanStr;

    @Column(name = "main_contract_resolve_plan")
    private String mainContractResolvePlan;

    @Column(name = "calculation_collection")
    private String calculationCollection;

    @Transient
    private String contractRound;

    @Transient
    private String huazhiRound;

    @Transient
    private String ziguangRound;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getTempId() {
        return tempId;
    }

    public void setTempId(int tempId) {
        this.tempId = tempId;
    }

    public String getProjectNo() {
        return projectNo;
    }

    public void setProjectNo(String projectNo) {
        this.projectNo = projectNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTypeDesc() {
        return typeDesc;
    }

    public void setTypeDesc(String typeDesc) {
        this.typeDesc = typeDesc;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getStatusDesc() {
        return statusDesc;
    }

    public void setStatusDesc(String statusDesc) {
        this.statusDesc = statusDesc;
    }


    public int getApproveStatus() {
        if(status == STATUS_ESTIMATE){
            return approveStatusEstimate;
        }
        if(status == STATUS_BUDGET){
            return approveStatusBudget;
        }
        if(status == STATUS_SETTLE){
            return approveStatusSettle;
        }
        if(status == STATUS_FINAL){
            return approveStatusFinal;
        }
        return -1;
    }

    public String getApproveStatusDesc() {
        int approveStatus = getApproveStatus();
        if(-1 == approveStatus){
            return "未知";
        }
        return ApproveStatusEnum.parseApproveStatus(approveStatus).getApproveStatusDesc();
    }

    public String getApproveName() {
        return approveName;
    }

    public void setApproveName(String approveName) {
        this.approveName = approveName;
    }

    public int getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(int creatorId) {
        this.creatorId = creatorId;
    }

    public String getCreatorName() {
        return creatorName;
    }

    public void setCreatorName(String creatorName) {
        this.creatorName = creatorName;
    }

    public int getDeptId() {
        return deptId;
    }

    public void setDeptId(int deptId) {
        this.deptId = deptId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public int getUnderwrittenMode() {
        return underwrittenMode;
    }

    public void setUnderwrittenMode(int underwrittenMode) {
        this.underwrittenMode = underwrittenMode;
    }

    public String getCollaborator() {
        return collaborator;
    }

    public void setCollaborator(String collaborator) {
        this.collaborator = collaborator;
    }

    public String getCollaboratorUrl() {
        return collaboratorUrl;
    }

    public void setCollaboratorUrl(String collaboratorUrl) {
        this.collaboratorUrl = collaboratorUrl;
    }

    public String getCustomer() {
        return customer;
    }

    public void setCustomer(String customer) {
        this.customer = customer;
    }

    public String getTerminalCustomer() {
        return terminalCustomer;
    }

    public void setTerminalCustomer(String terminalCustomer) {
        this.terminalCustomer = terminalCustomer;
    }

    public BigDecimal getContractAmount() {
        return contractAmount;
    }

    public void setContractAmount(BigDecimal contractAmount) {
        this.contractAmount = contractAmount;
    }

    public String getIndustryScenario() {
        return industryScenario;
    }

    public void setIndustryScenario(String industryScenario) {
        this.industryScenario = industryScenario;
    }

    public BigDecimal getHuazhiProductAmount() {
        return huazhiProductAmount;
    }

    public void setHuazhiProductAmount(BigDecimal huazhiProductAmount) {
        this.huazhiProductAmount = huazhiProductAmount;
    }

    public BigDecimal getZiguangOtherAmount() {
        return ziguangOtherAmount;
    }

    public void setZiguangOtherAmount(BigDecimal ziguangOtherAmount) {
        this.ziguangOtherAmount = ziguangOtherAmount;
    }

    public String getMainContractCollectionTerms() {
        return mainContractCollectionTerms;
    }

    public void setMainContractCollectionTerms(String mainContractCollectionTerms) {
        this.mainContractCollectionTerms = mainContractCollectionTerms;
    }

    public String getValueRisk() {
        return valueRisk;
    }

    public void setValueRisk(String valueRisk) {
        this.valueRisk = valueRisk;
    }

    public String getOtherName() {
        return otherName;
    }

    public void setOtherName(String otherName) {
        this.otherName = otherName;
    }

    public BigDecimal getProjectContributionProfitRateThreshold() {
        return projectContributionProfitRateThreshold;
    }

    public void setProjectContributionProfitRateThreshold(BigDecimal projectContributionProfitRateThreshold) {
        this.projectContributionProfitRateThreshold = projectContributionProfitRateThreshold;
    }

    public BigDecimal getUnderwrittenTaxRate() {
        return underwrittenTaxRate;
    }

    public void setUnderwrittenTaxRate(BigDecimal underwrittenTaxRate) {
        this.underwrittenTaxRate = underwrittenTaxRate;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    public int getApproveStatusEstimate() {
        return approveStatusEstimate;
    }

    public void setApproveStatusEstimate(int approveStatusEstimate) {
        this.approveStatusEstimate = approveStatusEstimate;
    }

    public int getApproveStatusBudget() {
        return approveStatusBudget;
    }

    public void setApproveStatusBudget(int approveStatusBudget) {
        this.approveStatusBudget = approveStatusBudget;
    }

    public int getApproveStatusSettle() {
        return approveStatusSettle;
    }

    public void setApproveStatusSettle(int approveStatusSettle) {
        this.approveStatusSettle = approveStatusSettle;
    }

    public int getApproveStatusFinal() {
        return approveStatusFinal;
    }

    public void setApproveStatusFinal(int approveStatusFinal) {
        this.approveStatusFinal = approveStatusFinal;
    }

    public int getApproveId() {
        return approveId;
    }

    public void setApproveId(int approveId) {
        this.approveId = approveId;
    }

    public String getStartDateYM(){
        return DatetimeUtils.toStr(this.startDate,"yyyy-MM");
    }
    public String getEndDateYM(){
        return DatetimeUtils.toStr(this.endDate,"yyyy-MM");
    }

    public String getPlanStartStr() {
        return planStartStr;
    }

    public void setPlanStartStr(String planStartStr) {
        this.planStartStr = planStartStr;
    }

    public String getPlanEndStr() {
        return planEndStr;
    }

    public void setPlanEndStr(String planEndStr) {
        this.planEndStr = planEndStr;
    }

    public String getUnderwrittenModeDesc() {
        return underwrittenModeDesc;
    }

    public void setUnderwrittenModeDesc(String underwrittenModeDesc) {
        this.underwrittenModeDesc = underwrittenModeDesc;
    }

    public String getCertainty() {
        return certainty;
    }

    public void setCertainty(String certainty) {
        this.certainty = certainty;
    }

    public String getCertaintyStr() {
        return certaintyStr;
    }

    public void setCertaintyStr(String certaintyStr) {
        this.certaintyStr = certaintyStr;
    }

    public BigDecimal getGrossProfit() {
        return grossProfit;
    }

    public void setGrossProfit(BigDecimal grossProfit) {
        this.grossProfit = grossProfit;
    }

    public BigDecimal getGrossProfitMargin() {
        return grossProfitMargin;
    }

    public void setGrossProfitMargin(BigDecimal grossProfitMargin) {
        this.grossProfitMargin = grossProfitMargin;
    }

    public BigDecimal getHuizhiProductAmount() {
        return huizhiProductAmount;
    }

    public void setHuizhiProductAmount(BigDecimal huizhiProductAmount) {
        this.huizhiProductAmount = huizhiProductAmount;
    }

    public BigDecimal getHuasanProductAmount() {
        return huasanProductAmount;
    }

    public void setHuasanProductAmount(BigDecimal huasanProductAmount) {
        this.huasanProductAmount = huasanProductAmount;
    }

    public String getPrincipal() {
        return principal;
    }

    public void setPrincipal(String principal) {
        this.principal = principal;
    }

    public Date getContractTime() {
        return contractTime;
    }

    public void setContractTime(Date contractTime) {
        this.contractTime = contractTime;
    }

    public Date getBidsTime() {
        return bidsTime;
    }

    public void setBidsTime(Date bidsTime) {
        this.bidsTime = bidsTime;
    }

    public String getIsSecondStr() {
        return isSecondStr;
    }

    public void setIsSecondStr(String isSecondStr) {
        this.isSecondStr = isSecondStr;
    }

    public String getSignTypeStr() {
        return signTypeStr;
    }

    public void setSignTypeStr(String signTypeStr) {
        this.signTypeStr = signTypeStr;
    }

    public String getResolvePlanStr() {
        return resolvePlanStr;
    }

    public void setResolvePlanStr(String resolvePlanStr) {
        this.resolvePlanStr = resolvePlanStr;
    }

    public String getMainContractResolvePlan() {
        return mainContractResolvePlan;
    }

    public void setMainContractResolvePlan(String mainContractResolvePlan) {
        this.mainContractResolvePlan = mainContractResolvePlan;
    }

    public String getCalculationCollection() {
        return calculationCollection;
    }

    public void setCalculationCollection(String calculationCollection) {
        this.calculationCollection = calculationCollection;
    }

    public String getContractRound() {
        return contractRound;
    }

    public void setContractRound(String contractRound) {
        this.contractRound = contractRound;
    }

    public String getHuazhiRound() {
        return huazhiRound;
    }

    public void setHuazhiRound(String huazhiRound) {
        this.huazhiRound = huazhiRound;
    }

    public String getZiguangRound() {
        return ziguangRound;
    }

    public void setZiguangRound(String ziguangRound) {
        this.ziguangRound = ziguangRound;
    }

    public int getIsSecond() {
        return isSecond;
    }

    public void setIsSecond(int isSecond) {
        this.isSecond = isSecond;
    }

    public int getSignType() {
        return signType;
    }

    public void setSignType(int signType) {
        this.signType = signType;
    }

    public int getResolvePlan() {
        return resolvePlan;
    }

    public void setResolvePlan(int resolvePlan) {
        this.resolvePlan = resolvePlan;
    }
}
