package com.tykj.dev.device.repair.subject.domin;

import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * entity class for repair_send_bill
 * 装备维修账单
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update repair_send_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("装备送修账单")
public class RepairSendBill {

    /**
     * 主键id
     */
    @Id
    @GeneratedValue
    @ApiModelProperty(name = "主键id")
    @Column(columnDefinition = "integer NOT NULL AUTO_INCREMENT")
    private Integer id;
    /**
     * 维修标题
     */
    @ApiModelProperty(value = "维修标题")
    private String title;
    /**
     * 申请文号
     */
    @ApiModelProperty(value = "申请文号")
    private String applyNumber;
    /**
     * 批复文号
     */
    @ApiModelProperty(value = "批复文号")
    private String replayNumber;

    /**
     * 发件单位
     */
    @ApiModelProperty(value = "发件单位")
    private String sendUnit;
    /**
     * 收件单位
     */
    @ApiModelProperty(value = "收件单位")
    private String receiveUnit;
    /**
     * 配发时间
     */
    @ApiModelProperty(value = "配发时间")
    private java.util.Date sendTime;
    /**
     * 接收时间
     */
    @ApiModelProperty(value = "接收时间")
    private java.util.Date receiveTime;
    /**
     * 维修单id
     */
    @ApiModelProperty(value = "维修单id")
    private Integer deviceRepairBillId;
    /**
     * 发起维修经办人id(市A岗)
     */
    @ApiModelProperty(value = "发起维修经办人id(市A岗)")
    private Integer startUseraId;
    /**
     * 发起维修审核人id(市B岗)
     */
    @ApiModelProperty(value = "发起维修审核人id(市B岗)")
    private Integer startUserbId;
    /**
     * 维修接收单位经办人id(省A岗)
     */
    @ApiModelProperty(value = "维修接收单位经办人id(省A岗)")
    private Integer repairUseraId;
    /**
     * 维修接收单位审核人id(省B岗)
     */
    @ApiModelProperty(value = "维修接收单位审核人id(省B岗)")
    private Integer repairUserbId;
    /**
     * 维修状态(0:草稿,1:维修任务审核失败,2:维修装备送到上级中,3:上级接收维修装备待审核,4:上级接收维修装备审核失败,5:维修中,6:维修完成退回中,7:维修完成)
     */
    @ApiModelProperty(value = "维修状态(0:草稿,1:维修任务审核失败,2:维修装备送到上级中,3:上级接收维修装备待审核,4:上级接收维修装备审核失败,5:维修中,6:维修完成退回中,7:维修完成)")
    private Integer repairStatus;

    @Column(name = "repair_device_detail",columnDefinition = "TEXT")
    @ApiModelProperty(value = "Ǵ作为分隔符,维修装备的主键id加备注,例如x1Ǵ备注1Ǵx2Ǵ备注2Ǵx,意为id为1的装备在维修，备注为备注1,id为2的装备在维修，备注为备注2")
    private String repairDeviceDetail;
    /**
     * 送修装备出库详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配
     */
    @Column(name = "repair_device_check_detail",columnDefinition = "TEXT")
    @ApiModelProperty(value = "送修装备出库详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配")
    private String repairDeviceCheckDetail;
    /**
     * 送修装备出库检查结果
     */
    @ApiModelProperty(value = "送修装备出库检查结果")
    private String repairDeviceCheckResult;
    /**
     * 送修装备接收入库详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配
     */
    @Column(name = "repair_recive_check_detail",columnDefinition = "TEXT")
    @ApiModelProperty(value = "送修装备接收入库详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配")
    private String repairReciveCheckDetail;
    /**
     * 送修装备接收入库检查结果
     */
    @ApiModelProperty(value = "送修装备接收入库检查结果")
    private String repairReciveCheckResult;
    /**
     * 出库附件文件名
     */
    @ApiModelProperty(value = "出库附件文件名")
    private String fileName;
    /**
     * 出库附件文件地址URL
     */
    @Column(name = "file_url",columnDefinition = "TEXT")
    @ApiModelProperty(value = "出库附件文件地址URL")
    private String fileUrl;
    /**
     * 入库附件文件名
     */
    @ApiModelProperty(value = "入库附件文件名")
    private String receiveFileName;
    /**
     * 入库附件文件地址URL
     */
    @Column(name = "receive_file_url",columnDefinition = "TEXT")
    @ApiModelProperty(value = "入库附件文件地址URL")
    private String receiveFileUrl;
    /**
     * 账单文件名
     */
    @ApiModelProperty(value = "账单文件名")
    private String billFileName;
    /**
     * 账单文件地址URL
     */
    @Column(name = "bill_file_url",columnDefinition = "TEXT")
    @ApiModelProperty(value = "账单文件地址URL")
    private String billFileUrl;
    /**
     * 应出库装备数量
     */
    @ApiModelProperty(value = "应出库装备数量")
    private Integer sendingCount;
    /**
     * 已出库装备数量
     */
    @ApiModelProperty(value = "已出库装备数量")
    private Integer sendedCount;
    /**
     * 已接收装备数量
     */
    @ApiModelProperty(value = "已接收装备数量")
    private Integer receiveCount;
    /**
     * 创建用户id
     */
    @CreatedBy
    @ApiModelProperty(value = "创建用户id")
    private Integer createUserId;
    /**
     * 创建时间
     */
    @CreatedDate
    @ApiModelProperty(value = "创建时间")
    private java.util.Date createTime;
    /**
     * 更新用户id
     */
    @LastModifiedBy
    @ApiModelProperty(value = "更新用户id")
    private Integer updateUserId;
    /**
     * 更新时间
     */
    @LastModifiedDate
    @ApiModelProperty(value = "更新时间")
    private java.util.Date updateTime;
    /**
     * 删除标记(0:未删除，1:已删除)
     */
    @ApiModelProperty(value = "删除标记(0:未删除，1:已删除)")
    private Integer deleteTag = 0;
    /**
     * 签发人
     */
    @ApiModelProperty(value = "签发人")
    private String agent;

    @ApiModelProperty(value = "申请人")
    @Transient
    private String startUserA;

    @ApiModelProperty(value = "申请确认人")
    @Transient
    private String startUserB;

    @ApiModelProperty(value = "维修经手人")
    private String repairUserA;

    @ApiModelProperty(value = "维修核验人")
    @Transient
    private String repairUserB;

    @ApiModelProperty(value = "区块链记录id")
    private String recordId;

    @ApiModelProperty(value = "发件方上传单据")
    @Column(name = "send_files",columnDefinition = "TEXT")
    private String sendFiles;

    @ApiModelProperty(value = "收件方上传单据")
    @Column(name = "receive_files",columnDefinition = "TEXT")
    private String receiveFiles;

    @ApiModelProperty(value = "单据json")
    @Column(name = "script_json",columnDefinition = "TEXT")
    private String scriptJson;

    @Transient
    private List<ScriptSaveVo> scripts = new ArrayList<>();

    @Transient
    private List<FileRet> sendFileList = new ArrayList<>();

    @Transient
    private List<FileRet> receiveFileList = new ArrayList<>();
}
