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

import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import com.jeeplus.common.persistence.DataEntity;
import com.jeeplus.common.utils.Collections3;
import com.jeeplus.common.utils.IdGen;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.iim.entity.LayGroup;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.entity.Workattachment;

import java.util.Date;
import java.util.List;

/**
 * 工作报告Entity
 * @author 许凯
 * @version 2017-04-21
 */
public class WorkReport extends DataEntity<WorkReport> {
	
	private static final long serialVersionUID = 1L;
	private String type;		// 类型
    private String companyId;		// 公司主键
    private String officeId;		// 部门主键
	private String thisContent;		// 本次工作内容
	private String thisFiles;		// 本次工作内容附件
	private String nextContent;		// 下次工作计划内容
	private String nextFiles;		// 下次工作附件
	private String status;		// 状态
	private Date startDate;		// 开始时间
	private Date finishDate;		// 结束时间
	private String readFlag;	// 本人阅读状态
	private boolean isSelf;		// 是否只查询自己的报告
	private List<WorkReportRecord> workReportRecordListUser = Lists.newArrayList();		// 子表列表
	private List<WorkReportRecord> workReportRecordListGroup = Lists.newArrayList();		// 子表列表
	private String userName;
	private String photo;
	private String userId;

	public String getUserName() {
		return userName;
	}

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

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	public String getUserId() {
		return userId;
	}

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

	private String create;
	private List<Workattachment> workAttachments;//附件
	
	public WorkReport() {
		super();
	}

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

	@ExcelField(title="类型", dictType="work_report_type", align=2, sort=1)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

    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;
    }

    @ExcelField(title="本次工作内容", align=2, sort=2)
	public String getThisContent() {
		return thisContent;
	}

	public void setThisContent(String thisContent) {
		this.thisContent = thisContent;
	}
	
	@ExcelField(title="本次工作内容附件", align=2, sort=3)
	public String getThisFiles() {
		return thisFiles;
	}

	public void setThisFiles(String thisFiles) {
		this.thisFiles = thisFiles;
	}
	
	@ExcelField(title="下次工作计划内容", align=2, sort=4)
	public String getNextContent() {
		return nextContent;
	}

	public void setNextContent(String nextContent) {
		this.nextContent = nextContent;
	}
	
	@ExcelField(title="下次工作附件", align=2, sort=5)
	public String getNextFiles() {
		return nextFiles;
	}

	public void setNextFiles(String nextFiles) {
		this.nextFiles = nextFiles;
	}
	
	@ExcelField(title="状态", dictType="oa_notify_status", align=2, sort=6)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="开始时间", align=2, sort=7)
	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="结束时间", align=2, sort=8)
	public Date getFinishDate() {
		return finishDate;
	}

	public void setFinishDate(Date finishDate) {
		this.finishDate = finishDate;
	}
	
	public List<WorkReportRecord> getWorkReportRecordListUser() {
		return workReportRecordListUser;
	}

	public void setWorkReportRecordListUser(List<WorkReportRecord> workReportRecordListUser) {
		this.workReportRecordListUser = workReportRecordListUser;
	}

	public List<WorkReportRecord> getWorkReportRecordListGroup() {
		return workReportRecordListGroup;
	}

	public void setWorkReportRecordListGroup(List<WorkReportRecord> workReportRecordListGroup) {
		this.workReportRecordListGroup = workReportRecordListGroup;
	}

	/**
	 * 获取报告发送记录用户ID
	 * @return
	 */
	public String getWorkReportRecordIdsUser() {
		return Collections3.extractToString(workReportRecordListUser, "user.id", ",") ;
	}
	
	/**
	 * 设置报告发送记录用户ID
	 * @return
	 */
	public void setWorkReportRecordIdsUser(String workReportRecordu) {
		this.workReportRecordListUser = Lists.newArrayList();
		for (String id : StringUtils.split(workReportRecordu, ",")){
			WorkReportRecord entity = new WorkReportRecord();
			entity.setId(IdGen.uuid());
			entity.setReport(this);
			entity.setUser(new User(id));
			entity.setReadFlag("0");	
			this.workReportRecordListUser.add(entity);
		//	System.out.println("------ListUser----------"+workReportRecordListUser.toString());
		}
		
	}
	/**
	 * 设置报告发送记录用户ID
	 * @return
	 */
	public void setWorkReportRecordIdsGroup(String groupIds) {
		this.workReportRecordListGroup = Lists.newArrayList();
		for (String id : StringUtils.split(groupIds, ",")){
			WorkReportRecord entity = new WorkReportRecord();
			entity.setId(IdGen.uuid());
			entity.setReport(this);
			entity.setGroup(new LayGroup(id));
			entity.setReadFlag("0");
			this.workReportRecordListGroup.add(entity);
		//	System.out.println("------ListUser----------"+workReportRecordListUser.toString());
		}

	}


	/**
	 * 获取报告发送记录用户Name
	 * @return
	 */
	public String getWorkReportRecordNamesUser() {
		return Collections3.extractToString(workReportRecordListUser, "user.name", ",") ;
	}
	
	/**
	 * 设置报告发送记录用户Name
	 * @return
	 */
	public void setWorkReportRecordNamesUser(String workReportRecord) {
		// 什么也不做
	}

	
	public String getReadFlag() {
		return readFlag;
	}

	public void setReadFlag(String readFlag) {
		this.readFlag = readFlag;
	}

	public boolean isSelf() {
		return isSelf;
	}

	public void setSelf(boolean isSelf) {
		this.isSelf = isSelf;
	}

	@Override
	public String toString() {
		return "WorkReport [type=" + type + ", thisContent=" + thisContent + ", thisFiles=" + thisFiles
				+ ", nextContent=" + nextContent + ", nextFiles=" + nextFiles + ", status=" + status + ", startDate="
				+ startDate + ", finishDate=" + finishDate + ", readFlag=" + readFlag + ", isSelf=" + isSelf
				+ ", workReportRecordListUser=" + workReportRecordListUser + "]";
	}

	public String getCreate() {
		return create;
	}

	public void setCreate(String create) {
		this.create = create;
	}

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

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