package org.linlinjava.jz.service;

import com.alibaba.druid.support.logging.Log;
import com.alibaba.druid.support.logging.LogFactory;
import com.google.common.collect.Lists;

import org.apache.commons.lang3.StringUtils;
import org.linlinjava.jz.core.util.ResponseUtil;
import org.linlinjava.jz.db.domain.*;
import org.linlinjava.jz.db.service.CustomerClientService;
import org.linlinjava.jz.db.service.CustomerOrderService;
import org.linlinjava.jz.db.service.JzBuiltListService;
import org.linlinjava.jz.db.service.JzTicketRelationService;
import org.linlinjava.jz.db.service.JzTicketService;
import org.linlinjava.jz.db.service.hm.HmAppUserService;
import org.linlinjava.jz.db.service.hm.HmButlerTaskParentService;
import org.linlinjava.jz.db.service.hm.HmCommentService;
import org.linlinjava.jz.db.service.hm.HmEmployRelationService;
import org.linlinjava.jz.db.service.hm.HmNoticeUserService;
import org.linlinjava.jz.db.service.hm.HmTasktimeConfigService;
import org.linlinjava.jz.db.service.hm.HmNoticeService;
import org.linlinjava.jz.db.util.TicketStatusConstant;
import org.linlinjava.jz.db.util.hm.HmCommentEnum;
import org.linlinjava.jz.db.util.hm.HmNoticeEnum;
import org.linlinjava.jz.dto.HmNoticeDto;
import org.linlinjava.jz.dto.HmNoticeDto.UserNoticeDto;
import org.linlinjava.jz.dto.TicketAction;
import org.linlinjava.jz.dto.TicketAllinone;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

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;

/**
 * 处理盒马小程序通知内容 包括工单类和非工单类的
 */
@Service
public class NoticeService {

	private final Log logger = LogFactory.getLog(HmNoticeService.class);

	@Autowired
	private HmNoticeService noticeService;

	@Autowired
	private HmNoticeUserService noticeUserService;

	@Autowired
	private HmEmployRelationService employRelationService;

	@Autowired
	private JzBuiltListService builtListService;

	@Autowired
	private TicketService ticketService;

	@Autowired
	private JzTicketService jzTicketService;

	@Autowired
	private HmAppUserService appUserService;

	@Autowired
	private CustomerClientService customerClientService;

	@Autowired
	private JzTicketRelationService relationService;

	@Autowired
	HmTasktimeConfigService hmTasktimeConfigService;

	@Autowired
	HmButlerTaskParentService hmButlerTaskParentService;

	@Autowired
	HmCommentService commentService;

	@Autowired
	CustomerOrderService customerOrderService;

	private final DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
	
	
	/**
	 * 后台监听处理操作者已处理的通知
	 * @param userId
	 * @param rType
	 * @param rId
	 */
	public void noticeListens( Long userId,String rType,String rId) {
		HmNotice notice = noticeService.getNoticeByRidRtype(rId, rType);
		if(notice!=null) {
			List<HmNoticeUser> noticeUserList = noticeUserService.getNoReadNoticeIduserIdList(notice.getId(), userId);
			noticeUserList.forEach(e->{
				HmNoticeUser h=new HmNoticeUser();
				h.setId(e.getId());
				h.setIsRead(1);
				noticeUserService.update(h);
			});
		}
	}

	/**
	 * 查询通知详情 jim说 有些类型不会通知保姆，但保姆能看到管家处理过程(质疑打卡，无法完成任务。。)
	 * 
	 * @param noticeId 通知主表或者是
	 * @param userId   noticeuser的userid
	 * @return
	 */
	public Map<String, Object> getNoticeInfo(Long noticeId, Integer type) {
		Map<String, Object> data = new HashMap<String, Object>();

		HmNotice no = new HmNotice();
		List<HmNoticeUser> tempNoticeUser = new ArrayList<HmNoticeUser>();

		// 拜访类
		if (type.equals(HmCommentEnum.comment_num_1.getType())) {
			// 查拜访的，和拜访日志
			HmButlerTaskParent e = hmButlerTaskParentService.queryTaskLogByParentId(noticeId);
			no.setId(e.getId());
			no.setContent(e.getTaskTypeName());
			no.setType(1);// 1是拜访数据
			no.setCreateTime(e.getCreateTime());
			no.setEmployRelationId(e.getEmployRelationId());

			for (HmButlerTaskLog c : e.getButlerTaskLogList()) {
				HmNoticeUser nu = new HmNoticeUser();
				nu.setCreateTime(c.getCreateTime());
				nu.setNoticeContent(c.getOperateContent());
				nu.setTicketStatus(e.getStatus() == 1 ? "2" : "0");
				tempNoticeUser.add(nu);
			}
		}

		// 跟进类
		if (type.equals(HmCommentEnum.comment_num_2.getType())) {
			// 查noticeuser 始终拿到管家处理的工单
			no = noticeService.findById(noticeId.intValue());
			HmEmployRelation relation = employRelationService.queryById(no.getEmployRelationId());
			tempNoticeUser = noticeUserService.getNoticeIduserIdList(no.getId(), relation.getUserButlerId());// 不用userId
		}
		
		if(null==tempNoticeUser||tempNoticeUser.size()==0) {
			no.setStatus("0");
		}else {
			no.setStatus(tempNoticeUser.get(0).getTicketStatus());
		}

		// tb流程展示
		boolean boo = true;
		for (HmNoticeUser e : tempNoticeUser) {
			e.setTitle(e.getNoticeContent());
			e.setDescription(df.format(e.getCreateTime()));
			if (boo) {
				e.setSize("14");
				boo = false;
			} else {
				e.setSize("8");
			}
		}
		HmEmployRelation relation = employRelationService.queryById(no.getEmployRelationId());

		data.put("relationInfo", relation);
		data.put("userServant", appUserService.queryById(relation.getUserServantId()));
		data.put("userCustomer", appUserService.queryById(relation.getUserEmployerId()));
		data.put("userButler", appUserService.queryById(relation.getUserButlerId()));
		data.put("noticeuserList", tempNoticeUser);
		data.put("notice", no);

		// 评论
		HmComment comment = commentService.queryByRIdAndType(noticeId, type);
		data.put("comment", comment);
		data.put("isComment", comment == null ? false : true);

		// 跟进类特有的逻辑
		if (type.equals(HmCommentEnum.comment_num_2.getType())) {
			// 查ticket工单

			JzTicket ticket = jzTicketService.getTicketByNoticeId(noticeId.intValue());
			data.put("ticket", ticket);
			// 关系值
			data.put("relationOther",
					HmNoticeEnum.getRelationTypeValue(no.getrId(), no.getTicketId(), Integer.parseInt(no.getrType())));
		}

		return data;
	}

	/**
	 * 创建通知
	 * 
	 * @param dto
	 * @return
	 */
	@Transactional
	public Object create(@RequestBody HmNoticeDto dto) {

		HmEmployRelation relation = employRelationService.queryById(dto.getEmployRelationId());

		if (relation == null)
			return ResponseUtil.badArgumentValue();

		List<Long> appUserId = dto.getAppUserId();
		if (null != appUserId && appUserId.size() > 0) {
			// 插入通知
			Integer noticeId = insertNoticeUsers(dto, relation);

			/*************************** 处理提醒 *******************************************/
			// 通知雇主类别
//			if (dto.getRtype() == HmNoticeEnum.NOTICE_NUM_1.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_4.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_5.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_9.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_10.getType()) {
//
//			}
//			// 通知保姆类
//			if (dto.getRtype() == HmNoticeEnum.NOTICE_NUM_2.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_3.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_6.getType()) {
//
//			}
//
//			// 通知管家类
//			if (dto.getRtype() == HmNoticeEnum.NOTICE_NUM_5.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_6.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_7.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_8.getType()
//					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_11.getType()) {
//
//			}

			// 工单投诉类
			if (dto.getRtype() == HmNoticeEnum.NOTICE_NUM_5.getType()
					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_6.getType()
					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_7.getType()
					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_8.getType()
					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_11.getType()
					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_12.getType()
					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_13.getType()
					|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_14.getType()) {

				Integer campaignId = getCampaignId(dto.getRtype());
				if (campaignId == 0)
					return ResponseUtil.badArgumentValue();

				// 保姆信息 在customer表中是否存在 如果不存在 新增一条
				HmAppUser appCustomer = appUserService.queryById(relation.getUserServantId());
				Integer customerId = 0;
				CustomerClient customerClient = customerClientService.findUserByMobile(appCustomer.getPhone());
				if (customerClient == null) {
					customerClient = new CustomerClient();
					customerClient.setTel(appCustomer.getPhone());
					customerClient.setCreateTime(LocalDateTime.now());
					customerClient.setCustomerType((short) 1);
					customerClient.setCreateUser("app");
					customerClient.setChannelId(6);
					customerClient.setState(0);
					customerClient.setNickname(appCustomer.getNickName());
					customerClient.setCustomerName(relation.getServantName());
					customerClient.setSource("hmApp");
					customerClientService.add(customerClient);
				}
				customerId = customerClient.getId().intValue();

				// 获取管家在sys_user中的id
				HmAppUser bulter = appUserService.queryById(relation.getUserButlerId());
				Integer bulterId = Integer.valueOf(bulter.getSysUserid());

				// 提醒内容
				String content = HmNoticeEnum.getContentButler(dto.getRtype(), relation);

				// 新建提醒任务
				JzBuiltList builtList = new JzBuiltList();
				builtList.setCreateTime(LocalDateTime.now());
				builtList.setNextCallTime(LocalDateTime.now());
				builtList.setCampaignId(campaignId);
				builtList.setAssignedTime(LocalDateTime.now());
				builtList.setUserId(bulterId);
				builtList.setRemark(content);
				builtList.setCustomerId(customerId);
				builtListService.add(builtList);

				// 新建工单
				TicketAllinone ticketAllinone = new TicketAllinone();
				ticketAllinone.setAdminId(bulterId);

				JzTicket ticket = new JzTicket();
				ticket.setCustomerId(customerId);
				ticket.setTicketTitle(content);
				ticket.setTicketDes(content);
				ticket.setTicketType(2);// 2为盒马app工单
				ticket.setHandler(bulterId);
				ticket.setTaskSource(dto.getTaskSourceType());// 任务来源

				CustomerOrder customerOrder = customerOrderService.selectByOrderNo(relation.getOrderNo());
				ticket.setOrderId(customerOrder.getId().intValue());

				Integer vistTaskTime = hmTasktimeConfigService.getVistTaskTime();
				LocalDateTime expirationTime = LocalDateTime.now().plusDays(vistTaskTime);
				ticket.setExpirationTime(expirationTime);// 任务到期处理时间

				ticket.setSource("APP");
				ticket.setStatus(TicketStatusConstant.STATUS_PROCESSING);
				ticket.setSubstatus(TicketStatusConstant.STATUS_SUB_PENDING);
				ticket.setServicer(relation.getServantName());
				ticketAllinone.setTicket(ticket);

				// 投诉类型---咨询类型 需要根据线上配置修改getConsultId 返回id
				JzTicketConsult[] ticketConsults = new JzTicketConsult[1];
				ticketConsults[0] = new JzTicketConsult();
				ticketConsults[0].setConsultId(getConsultId(dto.getRtype()));
				ticketConsults[0].setDeleted(false);
				ticketAllinone.setConsults(ticketConsults);

				// 建立关联关系
				JzTicketRelation[] relations = new JzTicketRelation[1];
				relations[0] = new JzTicketRelation();
				relations[0].setCreateUser(ticketAllinone.getAdminId());
				relations[0].setType((short) 3);// 盒马小程序通知
				relations[0].setfId(noticeId);
				ticketAllinone.setRelations(relations);

				TicketAction action = new TicketAction();
				action.setMemo(HmNoticeEnum.getContentButler(dto.getRtype(), relation));
				ticketAllinone.setAction(action);

				ticketService.create(ticketAllinone);

			}

		}

		return ResponseUtil.ok();
	}

	/**
	 * 插入通知处理
	 * 
	 * @param dto
	 * @param relation
	 * @return
	 */
	private Integer insertNoticeUsers(HmNoticeDto dto, HmEmployRelation relation) {
		Integer noticeId =null;
		if (dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_1.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_2.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_3.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_4.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_5.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_7.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_8.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_9.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_10.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_11.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_12.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_13.getType())
				|| dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_14.getType())) {
			String content = "";
			content = HmNoticeEnum.getContentUser(dto.getRtype(),dto.getRemark());
			HmNotice notice = new HmNotice();
			BeanUtils.copyProperties(dto, notice);

			notice.setContent(content);
			notice.setrType(dto.getRtype().toString());
			  noticeId = noticeService.insertNotice(notice);

			List<Long> appUserId = dto.getAppUserId();
			for (Long u : appUserId) {
				if(u.equals(relation.getUserButlerId())) {
					//跳过管家的，管家的单独下面处理
					continue;
				}
				HmNoticeUser noticeUser = new HmNoticeUser();
				noticeUser.setNoticeId(notice.getId());
				noticeUser.setAppUserId(u);
				noticeUser.setTicketStatus("0");
				noticeUser.setNoticeContent(content);// getContent(dto.getRtype(), relation)
				noticeUserService.insert(noticeUser);
			}
		} 

		//保姆缺勤打卡，通知管家雇主保姆，有工单
		if (dto.getRtype().equals(HmNoticeEnum.NOTICE_NUM_6.getType())) {
			HmNotice notice = new HmNotice();
			BeanUtils.copyProperties(dto, notice);  
			noticeId=noticeService.insertNotice(notice);
			
			List<UserNoticeDto> userNoticeList = dto.getUserNoticeList();
			for(UserNoticeDto u:userNoticeList) {
				HmNoticeUser noticeUser = new HmNoticeUser();
				noticeUser.setNoticeId(noticeId.longValue());
				noticeUser.setAppUserId(u.getUserId());
				noticeUser.setTicketStatus("0");
				noticeUser.setNoticeContent(u.getContent());
				noticeUserService.insert(noticeUser);
			}
		}

		// 管家的
		if (dto.getRtype() == HmNoticeEnum.NOTICE_NUM_5.getType()
				|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_6.getType()
				|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_7.getType()
				|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_8.getType()
				|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_11.getType()
				|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_12.getType()
				|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_13.getType()
				|| dto.getRtype() == HmNoticeEnum.NOTICE_NUM_14.getType()) {
			// 管家是工单的通知，话术不一样
			HmNoticeUser noticeUser = new HmNoticeUser();
			noticeUser.setNoticeId(noticeId.longValue());
			noticeUser.setAppUserId(relation.getUserButlerId());
			noticeUser.setTicketStatus("0");
			noticeUser.setNoticeContent(HmNoticeEnum.getContentButler(dto.getRtype(), relation));
			noticeUserService.insert(noticeUser);
		}
		return noticeId;
	}

	public void addNoticeUsers(Integer ticketId, String comment, String ticketStatus) {
		Integer noticeId = relationService.findHmAppFIdById(ticketId);
		addNoticeUser(noticeId, comment, ticketStatus);
//   	 List<Long> postUserId = noticeService.getPostUserId(noticeId);
//   	 postUserId.forEach(e->{
//   		addNoticeUser(e.intValue(),comment,ticketStatus);
//   	 });

		// 工单完成发送 邀请评价
		if (TicketStatusConstant.STATUS_COMPLETED.toString().equals(ticketStatus)) {
			HmNotice notice = noticeService.findById(noticeId);
			HmEmployRelation hmEmployRelation = employRelationService.queryById(notice.getEmployRelationId());
			HmNoticeDto hmNoticeDto = new HmNoticeDto();
			hmNoticeDto.setAppUserId(Lists.newArrayList(hmEmployRelation.getUserButlerId()));
			hmNoticeDto.setEmployRelationId(hmEmployRelation.getId());
			hmNoticeDto.setrId(ticketId.toString());//noticeId.toString()
			hmNoticeDto.setCreateUserId(hmEmployRelation.getUserEmployerId());

//			hmNoticeDto.setContent("管家跟进任务完成，快来评价吧");
			hmNoticeDto.setRtype(HmNoticeEnum.NOTICE_NUM_10.getType());
			hmNoticeDto.setNoticeUserType(HmNoticeEnum.NOTICE_NUM_10.getNoticeUserType());
			create(hmNoticeDto);
		}
	}

	/**
	 * 新增通知过程 当工单完结时 再次通知到相关人员
	 * 
	 * @param noticeId ticketStatus TicketStatusConstant
	 */
	public void addNoticeUser(Integer noticeId, String content, String ticketStatus) {
		if (noticeId == null || noticeId == 0)
			return;

		HmNotice notice = noticeService.findById(noticeId);
		if (notice == null)
			return;
		// NOTICE_NUM_5(5, "保姆打卡有无法完成任务，通知雇主管家，有工单 hm_employ_clock"),
		// NOTICE_NUM_6(6, "保姆缺勤打卡，通知管家雇主保姆 hm_employ_clock"),
		// NOTICE_NUM_7(7, "雇主质疑打卡，通知管家，有工单，关联 hm_task_question_log"),
		// NOTICE_NUM_8(8, "保姆服务记录差评，通知管家 jz_built_list"),
		HmNoticeUser noticeUser = new HmNoticeUser();
		noticeUser.setCreateTime(LocalDateTime.now());
		noticeUser.setNoticeContent(content);
		noticeUser.setIsRead(1);//这个时候不通知，只是记录
		noticeUser.setNoticeId(notice.getId());
		noticeUser.setTicketStatus(ticketStatus);

		// 处理要通知的人
		List<Long> postUserId = noticeService.getPostUserId(noticeId);
		postUserId.forEach(e -> {
			noticeUser.setAppUserId(e);
			noticeUserService.insert(noticeUser);
		});
	}

//    public Object read(Integer noticeId) {
//        return ResponseUtil.ok();
//    }

	public Object list() {

		List<HmNoticeUser> list = Lists.newArrayList();

		return ResponseUtil.ok(list);
	}

	/**
	 * 返回对应的campaignid任务id 请根据线上实际情况 修改
	 *
	 * @param type
	 * @return
	 */
	private Integer getCampaignId(Integer type) {
		if (type == HmNoticeEnum.NOTICE_NUM_5.getType())
			return 20;
		if (type == HmNoticeEnum.NOTICE_NUM_6.getType())
			return 21;
		if (type == HmNoticeEnum.NOTICE_NUM_7.getType())
			return 22;
		if (type == HmNoticeEnum.NOTICE_NUM_8.getType())
			return 23;

		if (type == HmNoticeEnum.NOTICE_NUM_11.getType())
			return 24;

		if (type == HmNoticeEnum.NOTICE_NUM_14.getType())
			return 25;

		if (type == HmNoticeEnum.NOTICE_NUM_12.getType())
			return 26;
		if (type == HmNoticeEnum.NOTICE_NUM_13.getType())
			return 27;

		return 0;
	}

//	private String getContent(Integer type, HmEmployRelation relation) {
//		// NOTICE_NUM_5(5, "保姆打卡有无法完成任务，通知雇主管家，有工单 hm_employ_clock"),
//		// NOTICE_NUM_6(6, "保姆缺勤打卡，通知管家雇主保姆 hm_employ_clock"),
//		// NOTICE_NUM_7(7, "雇主质疑打卡，通知管家，有工单，关联 hm_task_question_log"),
//		// NOTICE_NUM_8(8, "保姆服务记录差评，通知管家 jz_built_list"),
//		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;
//	}

	private Integer getConsultId(Integer type) {
		if (type == HmNoticeEnum.NOTICE_NUM_5.getType())
			return 69;
		if (type == HmNoticeEnum.NOTICE_NUM_6.getType())
			return 70;
		if (type == HmNoticeEnum.NOTICE_NUM_7.getType())
			return 71;
		if (type == HmNoticeEnum.NOTICE_NUM_8.getType())
			return 72;

		if (type == HmNoticeEnum.NOTICE_NUM_11.getType())
			return 73;
		if (type == HmNoticeEnum.NOTICE_NUM_12.getType())
			return 74;
		if (type == HmNoticeEnum.NOTICE_NUM_13.getType())
			return 75;
		if (type == HmNoticeEnum.NOTICE_NUM_14.getType())
			return 76;
//
//		if (type == HmTicketActionContans.TASK_SOURCE_TYPE_101)
//			return 65;
//		if (type == HmTicketActionContans.TASK_SOURCE_TYPE_102)
//			return 66;
//		if (type == HmTicketActionContans.TASK_SOURCE_TYPE_103)
//			return 67;
//		if (type == HmTicketActionContans.TASK_SOURCE_TYPE_104)
//			return 68;
//		if (type == HmTicketActionContans.TASK_SOURCE_TYPE_105)
//			return 69;

		return 0;
	}

}
