package com.yh.saas.plugin.base.entity;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotations.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yh.saas.common.support.entity.BaseModel;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * <p>
 * 记录单据操作历史
 * </p>
 *
 * @author SongJin
 * @since 2020-01-03
 */
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CommonBillOperateHis extends BaseModel<CommonBillOperateHis> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    private String id;
    /**
     * 单据ID
     */
    private String billId;

    /**
     * 单据枚举类型（两个单据ID相同的时候用类型区分）
     */
    private String billType;
    /**
     * 单据名称
     */
    private String billName;
    /**
     * 操作人
     */
    private String operateUser;
    /**
     * 操作时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date operateDate;
    /**
     * 处理信息
     */
    private String dealMsg;
    /**
     * 处理信息英文
     */
    private String dealMsgEn;
    /**
     * 审核意见
     */
    private String verifyRemark;
    /**
     * 审核人职务
     */
    private String verifyUserDuty;
    /**
     * 签名路径
     */
    private String signPath;
    /**
     * 审批结果
     */
    @TableField(exist = false)
    private String approveResult;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    /**
     * 查询类
     */
    public static class QueryFields {

        private QueryFields() {

        }

        public static final String BILL_ID = "bill_id";
        public static final String OPERATE_DATE = "operate_date";
        public static final String BILL_NAME = "bill_name";
        public static final String CREATE_USER_ID = "create_user_id";
        public static final String BILL_TYPE = "bill_type";


    }

    public static CommonBillOperateHis getInstance(String operateUser, Date operateDate, String approveResult,
                                                   String dealMsg, String dealMsgEn, String duty, String verifyRemark) {
        CommonBillOperateHis history = new CommonBillOperateHis();
        history.setOperateUser(duty + " " + operateUser);
        history.setOperateDate(operateDate);
        history.setDealMsg(dealMsg);
        history.setDealMsgEn(dealMsgEn);
        history.setApproveResult(approveResult);
        history.setVerifyRemark(verifyRemark);
        return history;
    }

}
