package com.palmnest.model.repair;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

import com.palmnest.model.User;

/**
 * 维修单
 *
 * @author wangxz
 * <p>
 * 2018年5月2日
 */
@Entity
@Table(name = "tb_repair_bills")
public class RepairBill implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 2145255166612536066L;

	private Long       id;
	private String     code;
	private Integer    status;//维修单状态(1,待审核;2,可抢单;3,进行中;4,挂单中;5,转单中;8,已完成;10,审核未通过) 22-待派单 add status dz 1029
	private Integer    confirmStatus; //确认状态 1-待确认 2-已确认

	private String     completeDesc; //完成描述
	private String     completePhotoUrl;//完成照片

	private String     repairUser;//'报修人',
	private String     contactWay;//'联系方式',
	private String     address;//'地址',
	private String     description;//'报修描述',
	private Long       repairWay;//'报修方式',
	private Long       repairArea;// '报修区域',
	private Long       repairType;//'维修类型',
	private Long       repairTypeDetail;// '维修类型小类',
	private String     picUrl;//'上传图片地址多个以;分割',
	private Integer    billFrom;//下单源(1，PC；2，微信；3，Android；4，iOS)
	private String     serviceUser;// '维修人',//change type dz 1029
	private Long       billUserId;// '下单人',
	private BigDecimal repairCost;//维修费用
	private Integer    hasComment;//是否有评论
	private Integer    hasReturnVisit;//是否有回访记录
	private Integer    hasPaid;//是否支付
	private String     creator;            //创建者
	private Date       createTime;        //创建日期
	private String     modifier;        //修改者
	private Date       modifyTime;        //修改日期
	private Date       endTime;        //完成日期
	private Integer    version;//版本号
	private Set<User>  supportUsers;
	private Date       meetingTime;        //预约时间
	private Date       singleTime;  //抢单时间 用于支撑报表 减少查询耗时
	private Integer    orgId;
	private Integer    userId;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID", unique = true, nullable = false)
	public Long getId() {
		return id;
	}

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

	@Column(name = "code")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}

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

	@Column(name = "repair_user")
	public String getRepairUser() {
		return repairUser;
	}

	public void setRepairUser(String repairUser) {
		this.repairUser = repairUser;
	}

	@Column(name = "contact_way")
	public String getContactWay() {
		return contactWay;
	}

	public void setContactWay(String contactWay) {
		this.contactWay = contactWay;
	}

	@Column(name = "address")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "repair_way")
	public Long getRepairWay() {
		return repairWay;
	}

	public void setRepairWay(Long repairWay) {
		this.repairWay = repairWay;
	}

	@Column(name = "repair_area")
	public Long getRepairArea() {
		return repairArea;
	}

	public void setRepairArea(Long repairArea) {
		this.repairArea = repairArea;
	}

	@Column(name = "repair_type")
	public Long getRepairType() {
		return repairType;
	}

	public void setRepairType(Long repairType) {
		this.repairType = repairType;
	}

	@Column(name = "repair_type_detail")
	public Long getRepairTypeDetail() {
		return repairTypeDetail;
	}

	public void setRepairTypeDetail(Long repairTypeDetail) {
		this.repairTypeDetail = repairTypeDetail;
	}

	@Column(name = "pic_url")
	public String getPicUrl() {
		return picUrl;
	}

	public void setPicUrl(String picUrl) {
		this.picUrl = picUrl;
	}

	@Column(name = "bill_from")
	public Integer getBillFrom() {
		return billFrom;
	}

	public void setBillFrom(Integer billFrom) {
		this.billFrom = billFrom;
	}

	@Column(name = "service_user")
	public String getServiceUser() {
		return serviceUser;
	}

	public void setServiceUser(String serviceUser) {
		this.serviceUser = serviceUser;
	}

	@Column(name = "repair_cost")
	public BigDecimal getRepairCost() {
		return repairCost;
	}

	public void setRepairCost(BigDecimal repairCost) {
		this.repairCost = repairCost;
	}

	@Column(name = "has_comment")
	public Integer getHasComment() {
		return hasComment;
	}

	public void setHasComment(Integer hasComment) {
		this.hasComment = hasComment;
	}

	@Column(name = "has_return_visit")
	public Integer getHasReturnVisit() {
		return hasReturnVisit;
	}

	public void setHasReturnVisit(Integer hasReturnVisit) {
		this.hasReturnVisit = hasReturnVisit;
	}

	@Column(name = "has_paid")
	public Integer getHasPaid() {
		return hasPaid;
	}

	public void setHasPaid(Integer hasPaid) {
		this.hasPaid = hasPaid;
	}

	@Column(name = "creator")
	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

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

	@Column(name = "modifier")
	public String getModifier() {
		return modifier;
	}

	public void setModifier(String modifier) {
		this.modifier = modifier;
	}

	@Column(name = "modify_time")
	public Date getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	@Column(name = "bill_user_id")
	public Long getBillUserId() {
		return billUserId;
	}

	public void setBillUserId(Long billUserId) {
		this.billUserId = billUserId;
	}

	@JsonIgnore
	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "tb_repair_bill_support_users", joinColumns = {@JoinColumn(name = "bill_id")}, inverseJoinColumns = @JoinColumn(name = "support_user_id"))
	public Set<User> getSupportUsers() {
		return supportUsers;
	}

	public void setSupportUsers(Set<User> supportUsers) {
		this.supportUsers = supportUsers;
	}

	@Column(name = "end_time")
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Column(name = "version")
	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@Column(name = "meetingTime")
	public Date getMeetingTime() {
		return meetingTime;
	}

	public void setMeetingTime(Date meetingTime) {
		this.meetingTime = meetingTime;
	}

	@Column(name = "orgId")
	public Integer getOrgId() {
		return orgId;
	}

	public void setOrgId(Integer orgId) {
		this.orgId = orgId;
	}
	@Column(name = "userId")
	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@Column(name = "confirm_status")
	public Integer getConfirmStatus() {
		return confirmStatus;
	}

	public void setConfirmStatus(Integer confirmStatus) {
		this.confirmStatus = confirmStatus;
	}

	@Column(name = "complete_desc")
	public String getCompleteDesc() {
		return completeDesc;
	}

	public void setCompleteDesc(String completeDesc) {
		this.completeDesc = completeDesc;
	}

	@Column(name = "complete_photo_url")
	public String getCompletePhotoUrl() {
		return completePhotoUrl;
	}

	public void setCompletePhotoUrl(String completePhotoUrl) {
		this.completePhotoUrl = completePhotoUrl;
	}

	@Column(name = "single_time")
	public Date getSingleTime() {
		return singleTime;
	}

	public void setSingleTime(Date singleTime) {
		this.singleTime = singleTime;
	}


}
