package com.ym.mec.biz.dal.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.enums.*;
import com.ym.mec.common.enums.BaseEnum;

import io.swagger.annotations.ApiModelProperty;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 对应数据库表(course_schedule):
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CourseSchedule {

	private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
	private SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");

	public enum CourseScheduleType implements BaseEnum<String, CourseScheduleType> {

		SINGLE("SINGLE", "声部课"), MIX("MIX", "合奏课"), HIGH("HIGH", "小班课"), VIP("VIP", "vip课"), DEMO("DEMO", "试听课"), COMPREHENSIVE("COMPREHENSIVE", "综合课"), PRACTICE(
				"PRACTICE", "网管课"), ENLIGHTENMENT("ENLIGHTENMENT", "启蒙课"), TRAINING_SINGLE("TRAINING_SINGLE", "集训声部课"), TRAINING_MIX("TRAINING_MIX", "集训合奏课"), CLASSROOM(
				"CLASSROOM", "课堂课"),COMM("COMM","对外课程"),HIGH_ONLINE("HIGH_ONLINE","网络基础训练课"),MUSIC_NETWORK("MUSIC_NETWORK","乐团网管课");

		private String code;

		private String msg;

		CourseScheduleType(String code, String msg) {
			this.code = code;
			this.msg = msg;
		}

		@Override
		public String getCode() {
			return code;
		}

		public String getMsg() {
			return msg;
		}
	}

	/**  */
	private Long id;

	private Long newCourseId;

	private GroupType groupType;

	/**  */
	@ApiModelProperty(value = "乐团编号",required = false)
	private String musicGroupId;

	/** 班级编号 */
	@ApiModelProperty(value = "班级编号", required = false)
	private Integer classGroupId;

	/** 课程状态 */
	@ApiModelProperty(value = "课程状态", required = false)
	private CourseStatusEnum status;

	/** 补贴 */
	@ApiModelProperty(value = "补贴", required = false)
	private BigDecimal subsidy;

	/** 上课日期 */
	@ApiModelProperty(value = "上课日期", required = false)
	private java.util.Date classDate;

	/** 上课时间 */
	@ApiModelProperty(value = "上课时间", required = false)
	private java.util.Date startClassTime;

	@ApiModelProperty(value = "上课时间字符")
	private String startClassTimeStr;

	/** 结束时间 */
	@ApiModelProperty(value = "结束时间", required = false)
	private java.util.Date endClassTime;

	@ApiModelProperty(value = "结束时间字符")
	private String endClassTimeStr;

	/** 上课教师 */
	@ApiModelProperty(value = "上课教师", required = false)
	private Integer teacherId;

	@ApiModelProperty(value = "主教老师", required = false)
	private String teacherName;

	/** 实际上课教师 */
	@ApiModelProperty(value = "实际上课教师", required = false)
	private Integer actualTeacherId;

	/** 实际上课教师 */
	@ApiModelProperty(value = "实际上课教师名称", required = false)
	private String actualTeacherName;

	@ApiModelProperty(value = "助教编号列表")
	private List<Integer> teachingTeacherIdList = new ArrayList<Integer>();

	@ApiModelProperty(value = "助教编号列表(用于记录调整日志)")
	private String teachingTeacherIds;

	/**  */
	private java.util.Date createTime;

	/**  */
	private java.util.Date updateTime;

	private TeachModeEnum teachMode;

	private CourseScheduleType type;

	private String name;

	@ApiModelProperty(value = "实际上课人数")
	private Integer studentNum;

	@ApiModelProperty(value = "请假人数")
	private Integer leaveStudentNum;

	private Integer schoolId;

	private String schoolName;

	/** 主教是否不需要重新生成课酬 */
	private boolean bishopTeacherSalaryNotCreate;

	private String classGroupName;

	private Integer isSettlement = 0;

	private String classGroupType;

	private java.util.Date coursesExpireDate;

	private Integer isLock;

	private Integer organId;
	
	private Organization organization = new Organization();

	private YesOrNoEnum isCallNames;

	private String teachingContent;

	private String note;

	private SignInStatusEnum signInStatusEnum;

	private SignOutStatusEnum signOutStatusEnum;

	private Date signInTime;

	private Date signOutTime;

	private int isSignIn = 3;

	private int isSignOut = 3;

	public String getTeachingTeacherIds() {
		return teachingTeacherIds;
	}

	public void setTeachingTeacherIds(String teachingTeacherIds) {
		this.teachingTeacherIds = teachingTeacherIds;
	}

	public String getActualTeacherName() {
		return actualTeacherName;
	}

	public void setActualTeacherName(String actualTeacherName) {
		this.actualTeacherName = actualTeacherName;
	}

	public Integer getOrganId() {
		return organId;
	}

	public void setOrganId(Integer organId) {
		this.organId = organId;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public int getIsSignIn() {
		return isSignIn;
	}

	public void setIsSignIn(int isSignIn) {
		this.isSignIn = isSignIn;
	}

	public int getIsSignOut() {
		return isSignOut;
	}

	public void setIsSignOut(int isSignOut) {
		this.isSignOut = isSignOut;
	}

	public SignInStatusEnum getSignInStatusEnum() {
		return signInStatusEnum;
	}

	public void setSignInStatusEnum(SignInStatusEnum signInStatusEnum) {
		this.signInStatusEnum = signInStatusEnum;
	}

	public SignOutStatusEnum getSignOutStatusEnum() {
		return signOutStatusEnum;
	}

	public void setSignOutStatusEnum(SignOutStatusEnum signOutStatusEnum) {
		this.signOutStatusEnum = signOutStatusEnum;
	}

	public Date getSignInTime() {
		return signInTime;
	}

	public void setSignInTime(Date signInTime) {
		this.signInTime = signInTime;
	}

	public Date getSignOutTime() {
		return signOutTime;
	}

	public void setSignOutTime(Date signOutTime) {
		this.signOutTime = signOutTime;
	}

	public String getTeachingContent() {
		return teachingContent;
	}

	public void setTeachingContent(String teachingContent) {
		this.teachingContent = teachingContent;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public YesOrNoEnum getIsCallNames() {
		return isCallNames;
	}

	public void setIsCallNames(YesOrNoEnum isCallNames) {
		this.isCallNames = isCallNames;
	}

	public Integer getIsLock() {
		return isLock;
	}

	public void setIsLock(Integer isLock) {
		this.isLock = isLock;
	}

	public Date getCoursesExpireDate() {
		return coursesExpireDate;
	}

	public void setCoursesExpireDate(Date coursesExpireDate) {
		this.coursesExpireDate = coursesExpireDate;
	}

	public String getTeacherName() {
		return teacherName;
	}

	public void setTeacherName(String teacherName) {
		this.teacherName = teacherName;
	}

	public String getClassGroupType() {
		return classGroupType;
	}

	public void setClassGroupType(String classGroupType) {
		this.classGroupType = classGroupType;
	}

	public Integer getIsSettlement() {
		return isSettlement;
	}

	public void setIsSettlement(Integer isSettlement) {
		this.isSettlement = isSettlement;
	}

	public String getSchoolName() {
		return schoolName;
	}

	public void setSchoolName(String schoolName) {
		this.schoolName = schoolName;
	}

	public String getClassGroupName() {
		return classGroupName;
	}

	public void setClassGroupName(String classGroupName) {
		this.classGroupName = classGroupName;
	}

	private SysUser teacher = new SysUser();

	public boolean isBishopTeacherSalaryNotCreate() {
		return bishopTeacherSalaryNotCreate;
	}

	public void setBishopTeacherSalaryNotCreate(boolean bishopTeacherSalaryNotCreate) {
		this.bishopTeacherSalaryNotCreate = bishopTeacherSalaryNotCreate;
	}

	public List<Integer> getTeachingTeacherIdList() {
		return teachingTeacherIdList;
	}

	public void setTeachingTeacherIdList(List<Integer> teachingTeacherIdList) {
		this.teachingTeacherIdList = teachingTeacherIdList;
	}

	public String getStartClassTimeStr() {
		return startClassTimeStr;
	}

	public void setStartClassTimeStr(String startClassTimeStr) throws ParseException {
		if (Objects.nonNull(this.classDate) && !StringUtils.isBlank(startClassTimeStr)) {
			String startTime = simpleDateFormat.format(this.classDate);
			startTime = startTime + " " + startClassTimeStr;
			this.startClassTime = simpleDateFormat1.parse(startTime);
		}
		this.startClassTimeStr = startClassTimeStr;
	}

	public String getEndClassTimeStr() {
		return endClassTimeStr;
	}

	public void setEndClassTimeStr(String endClassTimeStr) throws ParseException {
		if (Objects.nonNull(this.classDate) && !StringUtils.isBlank(endClassTimeStr)) {
			String endTime = simpleDateFormat.format(this.classDate);
			endTime = endTime + " " + endClassTimeStr;
			this.endClassTime = simpleDateFormat1.parse(endTime);
		}
		this.endClassTimeStr = endClassTimeStr;
	}

	public Integer getStudentNum() {
		return studentNum;
	}

	public void setStudentNum(Integer studentNum) {
		this.studentNum = studentNum;
	}

	public Integer getLeaveStudentNum() {
		return leaveStudentNum;
	}

	public void setLeaveStudentNum(Integer leaveStudentNum) {
		this.leaveStudentNum = leaveStudentNum;
	}

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

	public Long getId() {
		return this.id;
	}

	public Long getNewCourseId() {
		return newCourseId;
	}

	public void setNewCourseId(Long newCourseId) {
		this.newCourseId = newCourseId;
	}

	public GroupType getGroupType() {
		return groupType;
	}

	public void setGroupType(GroupType groupType) {
		this.groupType = groupType;
	}

	public String getMusicGroupId() {
		return musicGroupId;
	}

	public void setMusicGroupId(String musicGroupId) {
		this.musicGroupId = musicGroupId;
	}

	public void setClassGroupId(Integer classGroupId) {
		this.classGroupId = classGroupId;
	}

	public Integer getClassGroupId() {
		return this.classGroupId;
	}

	public CourseStatusEnum getStatus() {
		return status;
	}

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

	public void setSubsidy(BigDecimal subsidy) {
		this.subsidy = subsidy;
	}

	public BigDecimal getSubsidy() {
		return this.subsidy;
	}

	public void setClassDate(java.util.Date classDate) {
		if (StringUtils.isNotEmpty(startClassTimeStr)) {
			String startTime = simpleDateFormat.format(classDate);
			startTime = startTime + " " + startClassTimeStr;
			try {
				this.startClassTime = simpleDateFormat1.parse(startTime);
			} catch (ParseException e) {
				this.startClassTime = null;
			}
		}
		if (StringUtils.isNotEmpty(endClassTimeStr)) {
			String endTime = simpleDateFormat.format(classDate);
			endTime = endTime + " " + endClassTimeStr;
			try {
				this.endClassTime = simpleDateFormat1.parse(endTime);
			} catch (ParseException e) {
				this.endClassTime = null;
			}
		}
		this.classDate = classDate;
	}

	public java.util.Date getClassDate() {
		return this.classDate;
	}

	public void setStartClassTime(java.util.Date startClassTime) {
		this.startClassTime = startClassTime;
	}

	public java.util.Date getStartClassTime() {
		return this.startClassTime;
	}

	public void setEndClassTime(java.util.Date endClassTime) {
		this.endClassTime = endClassTime;
	}

	public java.util.Date getEndClassTime() {
		return this.endClassTime;
	}

	public Integer getTeacherId() {
		return teacherId;
	}

	public void setTeacherId(Integer teacherId) {
		this.teacherId = teacherId;
	}

	public Integer getActualTeacherId() {
		return actualTeacherId;
	}

	public void setActualTeacherId(Integer actualTeacherId) {
		this.actualTeacherId = actualTeacherId;
	}

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

	public java.util.Date getCreateTime() {
		return this.createTime;
	}

	public void setUpdateTime(java.util.Date updateTime) {
		this.updateTime = updateTime;
	}

	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}

	public TeachModeEnum getTeachMode() {
		return teachMode;
	}

	public void setTeachMode(TeachModeEnum teachMode) {
		this.teachMode = teachMode;
	}

	public CourseScheduleType getType() {
		return type;
	}

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

	public String getName() {
		return name;
	}

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

	public Integer getSchoolId() {
		return schoolId;
	}

	public void setSchoolId(Integer schoolId) {
		this.schoolId = schoolId;
	}

	public SysUser getTeacher() {
		return teacher;
	}

	public void setTeacher(SysUser teacher) {
		this.teacher = teacher;
	}


	public static CourseScheduleType getCourseScheduleTypeByCode(String code) {
		CourseScheduleType type = null;
		for (CourseScheduleType courseScheduleType : CourseScheduleType.values()) {
			if(courseScheduleType.getCode().equals(code)){
				type = courseScheduleType;
				break;
			}
		}
		return type;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
