/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.workpettycash.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import com.jeeplus.common.persistence.ActEntity;
import com.jeeplus.common.utils.Number2CN;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.sys.entity.Office;
import com.jeeplus.modules.sys.entity.User;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 备用金申请Entity
 * @author fgy
 * @version 2018-01-15
 */
public class WorkPettyCash extends ActEntity<WorkPettyCash> {
	
	private static final long serialVersionUID = 1L;
	private Office company;		// 公司
	private String companyId;
	private String companyName;
	private Office office;		// 创建部门
	private String officeId;
	private String officeName;
	private User user;//创建人
	private String userName;//创建人
	private String applicantName;  //申请人
	private Office applicantOffice;  //申请部门
	private String applicantOfficeId;
	private String applicantOfficeName;
	private String reason;		// 事由
	private String amount;		// 金额
	private String amountCN;    //金额大写
	private Date useDate;		// 使用日期
	private String useDateStr;
	private Date returnDate;		// 归还日期
	private String returnDateStr;
	private User casher;		// 出纳
	private String casherName;  //出纳
	private String status;		// 审核状态
	private String processInstanceId;		// 流程id
	private String ids;		//审批人
	private String CCid;   //抄送人
	private String name;
	private List<String> adds = Lists.newArrayList();
	private String comment; //审核意见 目前只保存手机端审核
	private String home;


	// 流程任务
	private Task task;
	private Map<String, Object> variables;
	// 运行中的流程实例
	private ProcessInstance processInstance;
	// 历史的流程实例
	private HistoricProcessInstance historicProcessInstance;
	// 流程定义
	private ProcessDefinition processDefinition;


	public WorkPettyCash() {
		super();
	}

	public WorkPettyCash(String id){
		super(id);
	}

	@ExcelField(title="申请公司", align=2, sort=7)
	public Office getCompany() {
		return company;
	}

	public void setCompany(Office company) {
		this.company = company;
	}
	
	@ExcelField(title="申请部门", fieldType=Office.class, value="", align=2, sort=8)
	public Office getOffice() {
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}

	@ExcelField(title="事由", align=2, sort=10)
	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}
	
	@ExcelField(title="金额", align=2, sort=11)
	public String getAmount() {
		return amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="使用日期不能为空")
	@ExcelField(title="使用日期", align=2, sort=12)
	public Date getUseDate() {
		return useDate;
	}

	public void setUseDate(Date useDate) {
		this.useDate = useDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@NotNull(message="归还日期不能为空")
	@ExcelField(title="归还日期", align=2, sort=13)
	public Date getReturnDate() {
		return returnDate;
	}

	public void setReturnDate(Date returnDate) {
		this.returnDate = returnDate;
	}
	
	@ExcelField(title="出纳", fieldType=User.class, value="", align=2, sort=14)
	public User getCasher() {
		return casher;
	}

	public void setCasher(User casher) {
		this.casher = casher;
	}
	
	@ExcelField(title="申请状态", dictType="act_status", align=2, sort=15)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@ExcelField(title="流程id", align=2, sort=16)
	public String getProcessInstanceId() {
		return processInstanceId;
	}

	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}

	public String getCasherName() {
		return casherName;
	}

	public void setCasherName(String casherName) {
		this.casherName = casherName;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}

	public String getOfficeId() {
		return officeId;
	}

	public void setOfficeId(String officeId) {
		this.officeId = officeId;
	}

	public String getOfficeName() {
		return officeName;
	}

	public void setOfficeName(String officeName) {
		this.officeName = officeName;
	}

	public String getIds() {
		List<String> idList = Lists.newArrayList();
		if (StringUtils.isNotBlank(ids)) {
			String ss = ids.trim().replace("　", ",").replace(" ", ",").replace("，", ",").replace("'", "");
			for (String s : ss.split(",")) {
				// if(s.matches("\\d*")) {
				idList.add("'" + s + "'");
				// }
			}
		}
		return StringUtils.join(idList, ",");
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	public String getCCid() {
		return CCid;
	}

	public void setCCid(String CCid) {
		this.CCid = CCid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<String> getAdds() {
		return adds;
	}

	public void setAdds(List<String> adds) {
		this.adds = adds;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public Task getTask() {
		return task;
	}

	public void setTask(Task task) {
		this.task = task;
	}

	public Map<String, Object> getVariables() {
		return variables;
	}

	public void setVariables(Map<String, Object> variables) {
		this.variables = variables;
	}

	public ProcessInstance getProcessInstance() {
		return processInstance;
	}

	public void setProcessInstance(ProcessInstance processInstance) {
		this.processInstance = processInstance;
	}

	public HistoricProcessInstance getHistoricProcessInstance() {
		return historicProcessInstance;
	}

	public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
		this.historicProcessInstance = historicProcessInstance;
	}

	public ProcessDefinition getProcessDefinition() {
		return processDefinition;
	}

	public void setProcessDefinition(ProcessDefinition processDefinition) {
		this.processDefinition = processDefinition;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getUseDateStr() {
		return useDateStr;
	}

	public void setUseDateStr(String useDateStr) {
		this.useDateStr = useDateStr;
	}

	public String getReturnDateStr() {
		return returnDateStr;
	}

	public void setReturnDateStr(String returnDateStr) {
		this.returnDateStr = returnDateStr;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getAmountCN() {
		String amountCN = "";
		if(org.apache.commons.lang3.StringUtils.isNotBlank(amount)){
			BigDecimal bd = new BigDecimal(amount);
			amountCN = Number2CN.number2CNMontrayUnit(bd);
		}
		return amountCN;
	}

	public void setAmountCN(String amountCN) {
		this.amountCN = amountCN;
	}

	public String getApplicantName() {
		return applicantName;
	}

	public void setApplicantName(String applicantName) {
		this.applicantName = applicantName;
	}

	public Office getApplicantOffice() {
		return applicantOffice;
	}

	public void setApplicantOffice(Office applicantOffice) {
		this.applicantOffice = applicantOffice;
	}

	public String getApplicantOfficeName() {
		return applicantOfficeName;
	}

	public void setApplicantOfficeName(String applicantOfficeName) {
		this.applicantOfficeName = applicantOfficeName;
	}

	public String getApplicantOfficeId() {
		return applicantOfficeId;
	}

	public void setApplicantOfficeId(String applicantOfficeId) {
		this.applicantOfficeId = applicantOfficeId;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getHome() {
		return home;
	}

	public void setHome(String home) {
		this.home = home;
	}
}