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

import com.google.common.collect.Lists;
import com.jeeplus.common.persistence.ActEntity;
import com.jeeplus.common.utils.Collections3;
import com.jeeplus.common.utils.IdGen;
import com.jeeplus.modules.sys.entity.Area;
import com.jeeplus.modules.sys.entity.Office;
import javax.validation.constraints.NotNull;

import com.jeeplus.common.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
import com.jeeplus.modules.worksalaryitem.entity.WorkSalaryItem;
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 java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 单项工资Entity
 * @author 杨帆
 * @version 2018-09-26
 */
public class WorkSingleWage extends ActEntity<WorkSingleWage> {
	
	private static final long serialVersionUID = 1L;
	private String companyId;		// company_id
	private String status;		// 状态
	private Office office;		// 部门id
	private String name;		// 发放名称
	private String month;		// 发放月份
	private String wageId;		// 工资项
	private Double money;		// 发放金额（元）
	private String minmoney;		// 发放金额（元）
	private String maxmoney;		// 发放金额（元）
	private Integer branchCount;		// 分公司人数
	private Integer grantCount;		// 发放人数
	private String nowMonth;     //当月 上月
	private Date startDate;
	private Date endDate;
	private WorkSalaryItem workSalaryItem;
	private List<User> userList;
	private List<Office> officeList;
	private List<WorkSingleWageRecord> workSingleWageRecordList = Lists.newArrayList();
	private List<WorkSingleWageRecord> workSingleWageRecordOfficeList = Lists.newArrayList();
	private String view;
	private String branchOffice;
	private String processInstanceId;
	private String home;

	public WorkSingleWage() {
		super();
	}

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

	private List<WorkClientAttachment> workAttachments = Lists.newArrayList();

	public List<WorkClientAttachment> getWorkAttachments() {
		return workAttachments;
	}

	public void setWorkAttachments(List<WorkClientAttachment> workAttachments) {
		this.workAttachments = workAttachments;
	}

	@ExcelField(title="company_id", align=2, sort=1)
	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}
	
	@ExcelField(title="状态", align=2, sort=2)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@ExcelField(title="部门id", fieldType=Office.class, value="office.name", align=2, sort=9)
	public Office getOffice() {
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}
	
	@ExcelField(title="发放名称", align=2, sort=10)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@ExcelField(title="发放月份", align=2, sort=11)
	public String getMonth() {
		return month;
	}

	public void setMonth(String month) {
		this.month = month;
	}
	
	@ExcelField(title="工资项", align=2, sort=12)
	public String getWageId() {
		return wageId;
	}

	public void setWageId(String wageId) {
		this.wageId = wageId;
	}
	
	@ExcelField(title="发放金额（元）", align=2, sort=13)
	public Double getMoney() {
		return money;
	}

	public void setMoney(Double money) {
		this.money = money;
	}
	
	@NotNull(message="分公司人数不能为空")
	@ExcelField(title="分公司人数", align=2, sort=14)
	public Integer getBranchCount() {
		return branchCount;
	}

	public void setBranchCount(Integer branchCount) {
		this.branchCount = branchCount;
	}
	
	@NotNull(message="发放人数不能为空")
	@ExcelField(title="发放人数", align=2, sort=15)
	public Integer getGrantCount() {
		return grantCount;
	}

	public void setGrantCount(Integer grantCount) {
		this.grantCount = grantCount;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public WorkSalaryItem getWorkSalaryItem() {
		return workSalaryItem;
	}

	public void setWorkSalaryItem(WorkSalaryItem workSalaryItem) {
		this.workSalaryItem = workSalaryItem;
	}

	/**
	 * 获取通知发送记录用户ID
	 * @return
	 */
	public String getWorkSingleWageRecordIds() {
		return Collections3.extractToString(workSingleWageRecordList, "user.id", ",") ;
	}

	/**
	 * 设置通知发送记录用户ID
	 * @return
	 */
	public void setWorkSingleWageRecordIds(List<User> users) {
		this.workSingleWageRecordList = Lists.newArrayList();
		if (users!=null && users.size()!=0) {
			for (User user : users) {
				if (user.getDelFlag().equals("0")) {
					WorkSingleWageRecord entity = new WorkSingleWageRecord();
					entity.setId(IdGen.uuid());
					entity.setWorkSingleWage(this);
					entity.setUser(user);
					this.workSingleWageRecordList.add(entity);
				}
			}
		}
	}
	/**
	 * 设置通知发送记录用户ID
	 * @return
	 */
	public void setWorkSingleWageRecordOffices(List<Office> offices) {
		this.workSingleWageRecordOfficeList = Lists.newArrayList();
		if (offices!=null && offices.size()!=0) {
			for (Office office : offices) {
				if (office.getDelFlag().equals("0")) {
					WorkSingleWageRecord entity = new WorkSingleWageRecord();
					entity.setId(IdGen.uuid());
					entity.setWorkSingleWage(this);
					entity.setOfficeId(office.getId());
					this.workSingleWageRecordOfficeList.add(entity);
				}
			}
		}
	}

	/**
	 * 获取通知发送记录用户Name
	 * @return
	 */
	public String getWorkSingleWageRecordNames() {
		return Collections3.extractToString(workSingleWageRecordList, "user.name", ",") ;
	}

	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

	public List<Office> getOfficeList() {
		return officeList;
	}

	public void setOfficeList(List<Office> officeList) {
		this.officeList = officeList;
	}

	public List<WorkSingleWageRecord> getWorkSingleWageRecordList() {
		return workSingleWageRecordList;
	}

	public void setWorkSingleWageRecordList(List<WorkSingleWageRecord> workSingleWageRecordList) {
		this.workSingleWageRecordList = workSingleWageRecordList;
	}

	public List<WorkSingleWageRecord> getWorkSingleWageRecordOfficeList() {
		return workSingleWageRecordOfficeList;
	}

	public void setWorkSingleWageRecordOfficeList(List<WorkSingleWageRecord> workSingleWageRecordOfficeList) {
		this.workSingleWageRecordOfficeList = workSingleWageRecordOfficeList;
	}

	public String getView() {
		return view;
	}

	public void setView(String view) {
		this.view = view;
	}

	public String getNowMonth() {
		return nowMonth;
	}

	public void setNowMonth(String nowMonth) {
		this.nowMonth = nowMonth;
	}

	public String getBranchOffice() {
		return branchOffice;
	}

	public void setBranchOffice(String branchOffice) {
		this.branchOffice = branchOffice;
	}

	public String getProcessInstanceId() {
		return processInstanceId;
	}

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

	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 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 String getHome() {
		return home;
	}

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

	public String getMinmoney() {
		return minmoney;
	}

	public void setMinmoney(String minmoney) {
		this.minmoney = minmoney;
	}

	public String getMaxmoney() {
		return maxmoney;
	}

	public void setMaxmoney(String maxmoney) {
		this.maxmoney = maxmoney;
	}
}