package com.ssj.bean.sys.fx.domain;

import com.alibaba.fastjson.JSON;
import com.ssj.bean.common.framework.core.domain.PersistentEntity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Table(name="fx_materiel_off")
public class MaterielOff extends PersistentEntity {
    private static final long serialVersionUID = 1534056643006312407L;

    /*
     * 主键
     */
    private String id;

    @Id
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    private Integer offFlow; //核销流水号
    private String templateId; //核销所属模板id
    private String templateJson; //核销模板具体内容 防止模板改变
    private BigDecimal price; //物品平均单价
    private Integer offNum; //核销数量
    private Integer lossNum; //损耗数量
    private Date offTime; //核销时间
    private List<TemplateInfo> tempInfoList;

    public Integer getOffFlow() {
        return offFlow;
    }

    public void setOffFlow(Integer offFlow) {
        this.offFlow = offFlow;
    }

    public String getTemplateId() {
        return templateId;
    }

    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }

    public String getTemplateJson() {
        return templateJson;
    }

    public void setTemplateJson(String templateJson) {
        this.templateJson = templateJson;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getOffNum() {
        return offNum;
    }

    public void setOffNum(Integer offNum) {
        this.offNum = offNum;
    }

    public Date getOffTime() {
        return offTime;
    }

    public void setOffTime(Date offTime) {
        this.offTime = offTime;
    }

    @Transient
    public List<TemplateInfo> getTempInfoList() {
        if(!"".equals(templateJson)){
            return JSON.parseArray(templateJson,TemplateInfo.class);
        }else{
            return new ArrayList<TemplateInfo>();
        }
    }

    public void setTempInfoList(List<TemplateInfo> tempInfoList) {
        this.tempInfoList = tempInfoList;
    }

    public Integer getLossNum() {
        return lossNum;
    }

    public void setLossNum(Integer lossNum) {
        this.lossNum = lossNum;
    }
}
