package com.ruoyi.project.business.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.project.business.domain.vo.lead.LeadRes;
import com.ruoyi.project.business.domain.vo.project.ProjectEquipmentRes;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.springframework.data.annotation.Transient;

/**
 * 项目管理对象 tc_project
 *
 * @author ruoyi
 * @date 2024-04-10
 */
@EqualsAndHashCode(callSuper = false)
@Data
@TableName("tc_project")
public class TcProject extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 项目ID
     */
    @TableId(type = IdType.AUTO)
    private Long projectId;


    /**
     * 项目编号(自动采番）
     */
    @Excel(name = "项目编号", i18nCode = "project.no", headNeedMerge = true, sort = 10)
    private String projectNo;

    /**
     * 区域
     */
    @Transient
    @Excel(name = "区域", i18nCode = "lead.area", headNeedMerge = true, sort = 20)
    private String areaName;

    /**
     * 国家
     */
    @Excel(name = "国家", i18nCode = "project.countryName", headNeedMerge = true, sort = 30)
    private String countryName;

    /**
     * 城市
     */
    @Excel(name = "城市", i18nCode = "project.city", headNeedMerge = true, sort = 40)
    private String city;

    /**
     * 计划成交月份 新增
     */
    @Excel(name = "计划成交月份", i18nCode = "project.planDealMonth", headNeedMerge = true, dateFormat = "yyyy-MM-dd", sort = 50)
    private Date planDealMonth;


    @Excel(name = "项目状态", i18nCode = "project.status", headNeedMerge = true, sort = 60)
    private String progressName;

    @Excel(name = "审批状态", i18nCode = "project.audit.status", headNeedMerge = true, sort = 61)
    private String statusName;

    /**
     * 负责人名称
     */
    @Transient
    @Excel(name = "负责人", i18nCode = "business.owner", headNeedMerge = true, sort = 70)
    private String ownerName;

    /**
     * 代理商名称
     */
    @Transient
    @Excel(name = "所属代理商", i18nCode = "business.ownerAgent", headNeedMerge = true, sort = 80)
    private String ownerAgentName;

    /**
     * 项目名称
     */
    @Excel(name = "项目名称", i18nCode = "project.name", headNeedMerge = true, sort = 90)
    private String projectName;

    private Integer elevatorNumber;
    private String elevatorType;
    private BigDecimal elevatorAmount;

    @Transient
    @Excel(name = "设备总数", i18nCode = "project.deviceTotal", headNeedMerge = true, sort = 91)
    private Integer deviceTotal;

    @Transient
    private BigDecimal priceTotal;

    @Transient
    @Excel(name = "总价", i18nCode = "project.priceTotal", headNeedMerge = true, sort = 92, align = HorizontalAlignment.RIGHT)
    private String priceTotalStr;

    @Transient
    @Excel(name = "项目类型", i18nCode = "project.type", headNeedMerge = true, sort = 100)
    private String typeName;

    @Transient
    @Excel(name = "标杆项目", i18nCode = "project.flag", headNeedMerge = true, sort = 110)
    private String modelFlagName;

    @Excel(name = "产品系列", i18nCode = "project.productSeries", headNeedMerge = true, sort = 120)
    private String segmentedMarketName;

    /**
     * 项目交期 新增
     */
    // @Excel(name = "项目交期", i18nCode = "project.completionYear", headNeedMerge = true, dateFormat = "yyyy-MM-dd", sort = 130)
    private Date completionYear;

    @Transient
    @Excel(name = "关联客户", i18nCode = "project.relatedCustomer", headNeedMerge = true, sort = 140)
    private String accountName;

    /**
     * 最新跟进结果
     */
    @Transient
    @Excel(name = "最新跟进结果", i18nCode = "account.followDesc", headNeedMerge = true, sort = 150)
    private String followDesc;

    /**
     * 最新跟进时间
     */
    @Transient
    @Excel(name = "最新跟进时间", i18nCode = "account.followTime", headNeedMerge = true, dateFormat = "yyyy-MM-dd", sort = 160)
    private Date followTime;

    /**
     * 跟进人
     */
    @Transient
    @Excel(name = "跟进人", i18nCode = "account.followPerson", headNeedMerge = true, sort = 170)
    private String followPerson;

    /**
     * 币种ID
     */
    @Excel(name = "币种", i18nCode = "project.currency", headNeedMerge = true, sort = 180, dictType = "currency_type")
    // private Long currencyId;
    private String currencyId;

    /**
     * 项目地址
     */
    @Excel(name = "项目地址", i18nCode = "project.address", headNeedMerge = true, sort = 200)
    private String address;

    /**
     * 关键决策人
     */
    @Excel(name = "关键决策人", i18nCode = "project.keyContactPerson", headNeedMerge = true, sort = 210)
    private String keyContactPerson;

    /**
     * 关键决策人职位
     */
    @Excel(name = "关键决策人职位", i18nCode = "project.keyJobTitle", headNeedMerge = true, sort = 220)
    private String keyJobTitle;

    /**
     * 关键决策人电话
     */
    @Excel(name = "关键决策人电话", i18nCode = "project.keyContact", headNeedMerge = true, sort = 230)
    private String keyContact;

    /**
     * 关键决策人邮箱
     */
    @Excel(name = "关键决策人邮箱", i18nCode = "project.keyEmail", headNeedMerge = true, sort = 240)
    private String keyEmail;

    /**
     * 联系人
     */
    @Excel(name = "联系人", i18nCode = "project.contactPerson", headNeedMerge = true, sort = 250)
    private String contactPerson;

    /**
     * 职位
     */
    @Excel(name = "职位", i18nCode = "project.jobTitle", headNeedMerge = true, sort = 260)
    private String jobTitle;

    /**
     * 联系方式
     */
    @Excel(name = "联系方式", i18nCode = "project.contact", headNeedMerge = true, sort = 270)
    private String contact;

    /**
     * 邮箱
     */
    @Excel(name = "邮箱", i18nCode = "project.email", headNeedMerge = true, sort = 280)
    private String email;

    /**
     * 解决方案 新增
     */
    @Excel(name = "解决方案", i18nCode = "project.solution", headNeedMerge = true, sort = 290)
    private String solution;


    /**
     * 特殊需求
     */
    @Excel(name = "特殊需求", i18nCode = "project.specialRemark", headNeedMerge = true, sort = 300)
    private String specialRemark;

    @Excel(name ="预期安装开始日期", i18nCode = "project.expectedInstallStartDate", dateFormat = "yyyy-MM-dd", sort = 310)
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date expectedInstallStartDate;

    /**
     * 设备规格信息 子列表：ruoyi 默认的值列表只支持一个，且是必须是最后一个。TODO 尝试优化 因为 TcProjectEquipment中也有remark，会导致列合并失败=
     */
    @Excel(name = "设备信息", i18nCode = "project.equipmentSpecifications", sort = Integer.MAX_VALUE)
    List<ProjectEquipmentRes> subList;

    /**
     * 客户ID
     */
    private Long accountId;


    /**
     * 标杆项目 0:否  1:是
     */
    private String modelFlag;

    /**
     * 项目类型（关联字典表）
     */
    private String type;


    /**
     * 项目细分市场（关联字典表）
     */
    private String segmentedMarket;

    /**
     * 区域ID
     */
    private Long areaId;

    /**
     * 国家ID
     */
    private Long countryId;

    private String progress;

    /**
     * 开发商
     */
    private String developer;

    /**
     * 开始时间
     */
    private Date startTime;

    /**
     * 结束时间
     */
    private Date overTime;

    /**
     * 项目状态  01待审批、02审批不通过、03审批通过、04已报价、05议价中、06已接受价格、07已成单、08已出图、98延期、99丢单、
     */
    private String status;


    /**
     * 产品型号 新增
     */
    private String productSeries;

    /**
     * 所有人
     */
    private Long owner;

    /**
     * 代理商
     */
    private Long ownerAgent;

    /**
     * 驳回原因
     */
    private String refuseReason;

    /**
     * 审批人
     */
    private Long auditPerson;

    /**
     * 延期备注
     */
    private String delayRemark;

    /**
     * 丢单备注
     */
    private String loseRemark;

    /**
     * 数据权限字符
     */
    private String permissionChar;

    /**
     * 删除标记（0：启用  1：停用）
     */
    @TableLogic
    private String delFlag;

    @Transient
    private String createByName;

    /**
     * 最后跟进日期
     */
    @Transient
    private Date lastFollowTime;

    // 所属代理商的上级销售
    @Transient
    private Long parentSaleId;

    @Transient
    private String accountNo;

    @Transient
    private Long leadId;

    /**
     * 远程检索key
     */
    @Transient
    private String query;

    @Transient
    private Long loginId;

    @Transient
    private String language;

    //新增线索list
    List<Long> leadIds;

    List<LeadRes> leadList;

    /**
     * 项目关联的设备数量
     */
    // @Excel(name = "设备数量", i18nCode = "project.equipmentQuantity", sort = 11)
    private Integer equipmentQuantity;

    /**
     * 项目关联的设备类型
     */
    // @Excel(name = "设备类型", i18nCode = "project.equipmentType", sort = 12, dictType = "intentional_product")
    private String equipmentType;

    /**
     * 项目关联的设备金额
     */
    // @Excel(name = "设备金额", i18nCode = "project.amount", sort = 13)
    private BigDecimal amount;

    /**
     * 创建人的 所属 id
     */
    private Long deptId;

    /**
     * 列表 row-key
     */
    private String rowKey;

    /**
     * table 树
     */
    List<TcProject> children;

    List<TcProjectEquipment> machineList;

    @TableField(exist = false)
    private Boolean discountFlag;

    @TableField(exist = false)
    private BigDecimal agentDiscountRate;

    @TableField(exist = false)
    private BigDecimal countryDiscountRate;


    // 设备单价
    private BigDecimal deviceAmount;


    // 竞争对手 50
    private String competitor;

    // 丢单原因分类
    private String reasonType;
    private String reasonTypeName;
    @TableField(exist = false)
    private String modifyRemark;

    // 关联线索
    private String leads;
    private String countryAbbr;
}
