package org.linlinjava.jz.db.util.hm;

import org.linlinjava.jz.db.domain.HmEmployRelation;
import org.linlinjava.jz.db.domain.HmEmployTask;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public enum HmNoticeEnum {
	 
	/*
	1保姆请假申请通知雇主，
2雇主审批请假成功通知保姆，
3雇主审批请假失败通知保姆，
4保姆正常打卡通知雇主，
5保姆打卡有无法完成任务，通知雇主管家，有工单
6保姆缺勤打卡，通知管家雇主保姆，有工单
7雇主质疑打卡，通知管家，有工单
8保姆服务记录差评，通知管家 有工单
9管家完成任务（拜访类）通知雇主评价
10管家完成任务 （跟进类）通知雇主评价
11雇主差评管家的任务，通知管家，拜访类
12雇主反馈其他问题，有工单
13保姆反馈其他问题，有工单
14雇主差评管家的任务，通知管家，跟进类
	 * 关联业务关系id
	 * hm_task_question_log 质疑打卡记录
	 * hm_employ_clock 请假 打卡 缺勤 任务 无法完成
	 *  hm_butler_task_parent  管家拜访类任务完成
	 *  jz_built_list  跟进类任务完成
	 *  hm_comment 保姆服务记录差评 雇主拜访完成差评
	 *
	 */
	NOTICE_NUM_1(1,"1", "",			"保姆请假申请，通知雇主 hm_employ_clock"),
	NOTICE_NUM_2(2,"2", "",			"雇主审批请假成功通知，保姆 hm_employ_clock"),
	NOTICE_NUM_3(3,"2", "",			"雇主审批请假失败，通知保姆 hm_employ_clock"),
	NOTICE_NUM_4(4,"1", "",			"保姆正常打卡，通知雇主 hm_employ_clock"),
	NOTICE_NUM_5(5,"1,3", "保姆任务未完成","保姆打卡有无法完成任务，通知雇主管家，有工单 hm_employ_clock"),
	NOTICE_NUM_6(6,"1,2,3","保姆考勤问题", "保姆缺勤打卡，通知管家雇主保姆，有工单 hm_employ_clock"),
	NOTICE_NUM_7(7,"1,3", "保姆服务质量质疑",	"雇主质疑打卡，通知管家，有工单，关联 hm_task_question_log"),//要传hm_employ_clock id
	NOTICE_NUM_8(8,"1,3", "保姆服务记录差评",	"保姆服务记录差评，通知管家 ，有工单jz_built_list"),
	NOTICE_NUM_9(9,"1", "",			"管家完成任务（拜访类）,通知雇主评价 hm_butler_task_parent"),
	NOTICE_NUM_10(10,"1", "",		"管家完成任务 （跟进类）,通知雇主评价 jz_built_list"),
	NOTICE_NUM_11(11,"1,3","管家服务质量质疑-拜访类","雇主差评管家的任务，通知管家 ，有工单jz_built_list"),
	
	NOTICE_NUM_14(14,"1,3","管家服务质量质疑-跟进类","雇主差评管家的任务，通知管家 ，有工单jz_built_list"),
	
	NOTICE_NUM_12(12,"1,3","雇主反馈其他问题", "雇主反馈其他问题，有工单"),
	NOTICE_NUM_13(13, "2,3","保姆反馈其他问题", "保姆反馈其他问题，有工单");
	
	
	//type 5 6 7 8 11  12  13都是有工单的
	
	private Integer type;
	private String noticeUserType;//提供给工单创建通知时，只发给谁看  1雇主，2保姆，3管家，都有都通知
	private String typeDesc;  //type 5 6 7 11 12 13 是管家重新创建任务用的
	private String typeName;

//-----------------------------------------------------------------------------------------------------------
	
//管家的话术
	public static String getContentButler(Integer type, HmEmployRelation relation) {
		String content = null;
		if (type == HmNoticeEnum.NOTICE_NUM_1.getType())
			content = "保姆:" + relation.getServantName() + "发起请假申请";
		if (type == HmNoticeEnum.NOTICE_NUM_2.getType())
			content ="雇主:("+relation.getEmployerName()+")审批("+relation.getServantName()+")请假成功";
		if (type == HmNoticeEnum.NOTICE_NUM_3.getType())
			content ="雇主:("+relation.getEmployerName()+")审批("+relation.getServantName()+")请假拒绝";
		if (type == HmNoticeEnum.NOTICE_NUM_4.getType())
			content = "保姆:" + relation.getServantName() + "已下班打卡";
		if (type == HmNoticeEnum.NOTICE_NUM_9.getType())
			content = "管家:" + relation.getButlerName() + "（拜访类）任务已完成，快来评价吧";
		if (type == HmNoticeEnum.NOTICE_NUM_10.getType())
			content = "管家:" + relation.getButlerName() + "（拜访类）任务已完成，快来评价吧";
		
		if (type == HmNoticeEnum.NOTICE_NUM_5.getType())
			content = "保姆:" + relation.getServantName() + "，当日任务无法完成";
		else if (type == HmNoticeEnum.NOTICE_NUM_6.getType())
			content = "保姆:" + relation.getServantName() + "，缺勤打卡";
		else if (type == HmNoticeEnum.NOTICE_NUM_7.getType())
			content = "雇主（" + relation.getEmployerName() + "）质疑保姆（" + relation.getServantName() + "）打卡";
		else if (type == HmNoticeEnum.NOTICE_NUM_8.getType())
			content = "保姆:" + relation.getServantName() + "的服务记录差评";
		else if (type == HmNoticeEnum.NOTICE_NUM_11.getType())
			content = "管家:" + relation.getButlerName() + "的拜访任务，服务记录差评";
		else if (type == HmNoticeEnum.NOTICE_NUM_12.getType())
			content = "雇主:"+relation.getEmployerName() + "反馈其他问题";
		else if (type == HmNoticeEnum.NOTICE_NUM_13.getType())
			content = "保姆:"+relation.getServantName() + "反馈其他问题";
		else if (type == HmNoticeEnum.NOTICE_NUM_14.getType())
			content = "管家:" + relation.getButlerName() + "的跟进任务，服务记录差评";
		return content;
	}
	public static void main(String[] args) {
		String contentUser = getContentUser(5, "123132");
		System.out.println(contentUser);
		 HmEmployTask hmEmployTask=new HmEmployTask();
		 hmEmployTask.setTaskStartTime(LocalDateTime.now());
		String str="保姆" + hmEmployTask.getTaskStartTime().toLocalDate() + "的服务有任务无法完成，管家已知晓，正在跟进了解情况中！";
		 DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy年M月d日");
		System.out.println(dtf2.format(hmEmployTask.getTaskStartTime()));
	}
	/**
	 * 雇主和保姆的话术
	 * @param type
	 * @param time  2019年2月2日
	 * @return
	 */
	public static String getContentUser(Integer type,String ... time) {
		String content = null;
		if (type == HmNoticeEnum.NOTICE_NUM_1.getType()) {
			content = "保姆发起了"+time[0]+"的请假申请，需要您的审批！";
		}
		if (type == HmNoticeEnum.NOTICE_NUM_2.getType()) {
			content ="你提交的请假申请，雇主已审批通过";
		}
		if (type == HmNoticeEnum.NOTICE_NUM_3.getType()) {
			content ="你提交的请假申请，雇主审批未通过";
		}
		if (type == HmNoticeEnum.NOTICE_NUM_4.getType()) {
			content ="保姆"+time[0]+"的服务已经全部完成，评价一下吧！";
		}
		if (type == HmNoticeEnum.NOTICE_NUM_5.getType()) {
			content ="保姆"+time[0]+"的服务有任务无法完成，管家已知晓，正在跟进了解情况中！";
		}
		
//		雇主：保姆2019年2月2日的服务出现缺勤，管家已知晓，正在跟进了解情况中！
		//保姆：您在2019年2月2日的服务状态是缺勤，请主动联系管家反馈情况！
//		if (type == HmNoticeEnum.NOTICE_NUM_6.getType()) {
//			content = "";
//		}
		
		if (type == HmNoticeEnum.NOTICE_NUM_7.getType()) {
			content = "您对于"+time+"的保姆服务的质疑已通知管家，管家了解情况中！";
		}
		if (type == HmNoticeEnum.NOTICE_NUM_8.getType()) {
			content = "非常抱歉给您带来不好的服务体验，管家将会第一时间了解情况并跟进处理！";
		}
		if (type == HmNoticeEnum.NOTICE_NUM_9.getType()) {
			content = "管家此次服务您满意吗吗？快来评价一下！";
		}
		if (type == HmNoticeEnum.NOTICE_NUM_10.getType()) {
			content = "管家此次服务解决您的问题了吗？快来评价一下！";
		}
		 if (type == HmNoticeEnum.NOTICE_NUM_11.getType()) {
			content = "非常抱歉给您带来不好的管家服务体验，管家主管将会第一时间了解情况并监督管家及时处理您的反馈！";
		 }
		 if (type == HmNoticeEnum.NOTICE_NUM_12.getType()) {
				content = "管家已收到您的反馈，将会持续跟进处理！";
		 }
		 if (type == HmNoticeEnum.NOTICE_NUM_13.getType()) {
			content = "管家已收到您的反馈，将会持续跟进处理！";
		 }
		 if (type == HmNoticeEnum.NOTICE_NUM_14.getType()) {
			content = "非常抱歉给您带来不好的管家服务体验，管家主管将会第一时间了解情况并监督管家及时处理您的反馈！";
		 }
		return content;
	}
	
	//雇主未打卡啊话术
	public static String getNoClockServant(String   time) {
		return "保姆"+time+"的服务出现缺勤，管家已知晓，正在跟进了解情况中！";
	}
	//保姆
	public static String getNoClockCustomer(String   time) {
		return "您在"+time+"的服务状态是缺勤，请主动联系管家反馈情况！";
	}
	
	/**
	 * 保姆或雇主   各自的通知类型
	 * type 1保姆获取雇主发的通知;2保姆获取管家发的通知；3雇主获取保姆发送的通知，4雇主获取管家发送的通知
	 * @return
	 */
	public static List<String> getUserNoticeType(Integer type){
		
		List<String> list=new ArrayList<String>();
		if(type==null) {
			return list;
		}
		
		if(type.equals(1)) {
			//2雇主审批请假成功,3雇主审批请假失败
			list.add(HmNoticeEnum.NOTICE_NUM_2.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_3.getType().toString());
		}
		if(type.equals(2)) {
			//6保姆考勤问题 13保姆反馈其他问题
			list.add(HmNoticeEnum.NOTICE_NUM_6.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_13.getType().toString());
		}
		if(type.equals(3)) {
			//3雇主获取保姆发送的通知，
			list.add(HmNoticeEnum.NOTICE_NUM_1.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_4.getType().toString());
		}
		if(type.equals(4)) {
			//4雇主获取管家发送的通知
			list.add(HmNoticeEnum.NOTICE_NUM_5.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_6.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_7.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_8.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_9.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_10.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_12.getType().toString());
			list.add(HmNoticeEnum.NOTICE_NUM_13.getType().toString());
		}
		
		return list;
	}
 
	/**
	 * 保姆获取的--管家工单类型（不是通知）
	 * @return
	 */
	public static List<String> getCustomerNoticeType(){
		 //雇主获取管家的工单处理
		List<String> list=new ArrayList<String>();
		list.add(HmNoticeEnum.NOTICE_NUM_5.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_6.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_7.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_8.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_11.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_14.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_12.getType().toString());
		return list;
	}
	
	/**
	 * 保姆获取的--管家工单类型（不是通知）
	 * @return
	 */
	public static List<String> getServantNoticeType(){
		//下班打卡有无法完成的任务，缺勤未打卡的，雇主质疑打卡
		List<String> list=new ArrayList<String>();
		list.add(HmNoticeEnum.NOTICE_NUM_5.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_6.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_7.getType().toString());
		return list;
	}
	
	/**
	 * 管家获取的--管家工单类型（不是通知）
	 * @return
	 */
	public static List<String> getButlerNoticeType(){
		//下班打卡有无法完成的任务，缺勤未打卡的，雇主质疑打卡，差评管家的
		List<String> list=new ArrayList<String>();
		list.add(HmNoticeEnum.NOTICE_NUM_5.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_6.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_7.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_8.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_11.getType().toString());
		list.add(HmNoticeEnum.NOTICE_NUM_12.getType().toString());//
		list.add(HmNoticeEnum.NOTICE_NUM_13.getType().toString());//
		list.add(HmNoticeEnum.NOTICE_NUM_14.getType().toString());
		return list;
	}
	
	/**
	 * 管家小程序获取通知详情到前端的类型
	 * @param rId 三者关系id
	 * @param ticketId 自己创建工单时关联的工单id（特定的）
	 * @param type 通知类型
	 * @return
	 */
	public static Map<String,Object> getRelationTypeValue(String rId,Integer ticketId, Integer type) {
		Map<String,Object> data=new HashMap<String, Object>();
		
		data.put("relationOtherId", "");
		data.put("relationOtherName", "");
		data.put("relationOtherType", "");
		
		//在差评管家跟进类任务时，需要插入上一个工单的id
		//直接创建的任务是有工单id的
		if(ticketId!=null||type==HmNoticeEnum.NOTICE_NUM_12.getType()
				||type==HmNoticeEnum.NOTICE_NUM_13.getType()
				||type==HmNoticeEnum.NOTICE_NUM_14.getType()) {
			data.put("relationOtherId", rId);//ticketId
			data.put("relationOtherName", "跟进类工单");//工单
			data.put("relationOtherType", "3");
			return data;
		}
		
		if(type==HmNoticeEnum.NOTICE_NUM_11.getType()) {
			data.put("relationOtherId", rId);
			data.put("relationOtherName", "管家拜访任务");
			data.put("relationOtherType", "2");
			return data;
		}
		

		if(type==HmNoticeEnum.NOTICE_NUM_5.getType()
				||type==HmNoticeEnum.NOTICE_NUM_6.getType()
				||type==HmNoticeEnum.NOTICE_NUM_7.getType()
				||type==HmNoticeEnum.NOTICE_NUM_8.getType()) {
			data.put("relationOtherId", rId);
			data.put("relationOtherName", "保姆服务记录");
			data.put("relationOtherType", "1");
			return data;
		} 
		
		
		return data;
	}
	
	/*
	 *盒马小程序，创建任务，选择的任务类型 
	 */
	public static List<Map<String, Object>> getTaskTypeList() {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		//type 5 6 7 11 12 13 是管家重新创建任务用的
		for(HmNoticeEnum s:HmNoticeEnum.values()) { 
			
			Map<String,Object> data=new HashMap<String, Object>();
			
			//保姆任务类，
			if(s.getType()==NOTICE_NUM_5.getType()
					||s.getType()==NOTICE_NUM_6.getType()
					||s.getType()==NOTICE_NUM_7.getType()) {
				//||s.getType()==NOTICE_NUM_8.getType()
				data.put("type", s.getType());
				data.put("typeDesc", s.getTypeDesc());
				data.put("tasktype", 1);
				list.add(data);
			}
			
			//管家服务质量质疑-拜访类
			if(s.getType()==NOTICE_NUM_11.getType()) {
				data.put("type", s.getType());
				data.put("typeDesc", s.getTypeDesc());
				data.put("tasktype", 2);
				list.add(data);
			}
			
			//工单，雇主保姆反馈其他问题
			if(s.getType()==NOTICE_NUM_12.getType()||s.getType()==NOTICE_NUM_13.getType()) {
				data.put("type", s.getType());
				data.put("typeDesc", s.getTypeDesc());
				data.put("tasktype", 3);
				list.add(data);
			}  
		}
		
		return list;
	}
	
	/**
	 * 盒马小程序 新建跟进任务  任务来源
	 * @return
	 */
	public static List<Map<String, Object>> getTaskSourceTypeList() {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> e1 = new HashMap<String, Object>();
		e1.put("type", 1);
		e1.put("typeName", "雇主电话反馈");
		
		Map<String, Object> e2 = new HashMap<String, Object>();
		e2.put("type", 2);
		e2.put("typeName", "保姆电话反馈");

		Map<String, Object> e3 = new HashMap<String, Object>();
		e3.put("type", 3);
		e3.put("typeName", "雇主到店反馈");

		Map<String, Object> e4 = new HashMap<String, Object>();
		e4.put("type", 4);
		e4.put("typeName", "保姆到店反馈");
		
		Map<String, Object> e5 = new HashMap<String, Object>();
		e5.put("type", 5);
		e5.put("typeName", "雇主线下反馈");

		list.add(e1);
		list.add(e2);
		list.add(e3);
		list.add(e4);
		list.add(e5);

		return list;
	}
	

	public String getTypeDesc() {
		return typeDesc;
	}

	public void setTypeDesc(String typeDesc) {
		this.typeDesc = typeDesc;
	}

	private HmNoticeEnum(Integer type, String noticeUserType, String typeDesc, String typeName) {
		this.type = type;
		this.noticeUserType = noticeUserType;
		this.typeDesc = typeDesc;
		this.typeName = typeName;
	}

	public String getNoticeUserType() {
		return noticeUserType;
	}

	public void setNoticeUserType(String noticeUserType) {
		this.noticeUserType = noticeUserType;
	}

	public Integer getType() {
		return type;
	}

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

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public static String getNoticeUserTypeByType(Integer type) {
		if(type==null) {
			return null;
		}
		for(HmNoticeEnum s:HmNoticeEnum.values()) {
			if(s.getType()==type) {
				return s.getNoticeUserType();
			}
		}
		return null;
	}

}
