/** 批量删除会议列表内容 */
 @RequestMapping(value = "deleteMeeting.html", method = RequestMethod.POST)
 @ResponseBody
 public Return deleteMeeting(
     HttpServletRequest req, HttpServletResponse res, @RequestParam("mId") String ids) {
   Return re = meetingService.removeAllMeeting(ids);
   return re;
 }
 /** 跳转新建会议列表页面 */
 @RequestMapping(value = "newMeeting.html", method = RequestMethod.GET)
 public ModelAndView newMeeting(
     HttpServletRequest req, HttpServletResponse res, String mId, ModelMap model) {
   // mId为空新建,不为空修改
   if (mId != null) {
     MeetingBo mb = meetingService.getMeeting(mId);
     model.put("mb", mb);
   } else {
     model.put("mb", new MeetingBo());
   }
   return new ModelAndView("meetingManage/newMeeting", model);
 }
 /** 跳转安排人员页面 */
 @RequestMapping(value = "turnStaff.html", method = RequestMethod.GET)
 public ModelAndView meetingStaff(
     HttpServletRequest req, HttpServletResponse res, ModelMap model) {
   String mId = req.getParameter("mId");
   // mId为空新建,不为空修改
   if (mId != null) {
     MeetingBo mb = meetingService.getMeeting(mId);
     model.put("mb", mb);
   } else {
     model.put("mb", new MeetingBo());
   }
   ;
   return new ModelAndView("meetingManage/meetingStaff");
 }
  /** 保存会议内容 */
  @RequestMapping(value = "saveMeeting.html", method = RequestMethod.POST)
  public ModelAndView saveMeeting(HttpServletRequest req, ModelMap model) {
    UserInfoBo user = (UserInfoBo) req.getSession().getAttribute("user");
    MeetingCon mc = new MeetingCon();
    String name = req.getParameter("name");
    String start_date = req.getParameter("start_date");
    String end_date = req.getParameter("end_date");
    String start_hour = req.getParameter("start_hour");
    String start_minute = req.getParameter("start_minute");
    String start_second = req.getParameter("start_second");
    String end_hour = req.getParameter("end_hour");
    String end_minute = req.getParameter("end_minute");
    String end_second = req.getParameter("end_second");
    String master_name = req.getParameter("master_name");
    String teacher_name = req.getParameter("teacher_name");
    String remarks = req.getParameter("remarks");
    String _maxAttend = req.getParameter("maxAttend");
    if (_maxAttend == "" || _maxAttend == null) {
      int maxAttend = 0;
      mc.setMaxAttend(maxAttend);
    }
    if (_maxAttend != "" && _maxAttend != null) {
      int maxAttend = Integer.parseInt(_maxAttend);
      mc.setMaxAttend(maxAttend);
    }

    mc.setName(name);
    mc.setStart_date(start_date);
    mc.setEnd_date(end_date);
    mc.setStart_hour(start_hour);
    mc.setStart_minute(start_minute);
    mc.setStart_second(start_second);
    mc.setEnd_hour(end_hour);
    mc.setEnd_minute(end_minute);
    mc.setEnd_second(end_second);
    mc.setMaster_id(master_name);
    mc.setTeacher_id(teacher_name);
    mc.setRemarks(remarks);
    mc.setStatus(0);
    mc.setCreater_id(user.getUid());
    mc.setCreate_date(DateTool.getNowShort()); // 保存当前日期

    Return re = meetingService.newMeeting(mc);
    mc.setmId(re.getCode());
    return new ModelAndView("redirect:turnStaff.html?mId=" + mc.getmId(), model);
  }
  /** 修改会议内容 */
  @RequestMapping(value = "saveModifiedMeeting.html", method = RequestMethod.POST)
  public ModelAndView saveModifiedMeeting(HttpServletRequest req, ModelMap model) {
    String mId = req.getParameter("mId");
    String bool = req.getParameter("bools");
    if (bool.equals("true")) {
      return new ModelAndView("redirect:turnStaff.html?mId=" + mId, model);
    }

    String name = req.getParameter("name");
    String start_date = req.getParameter("start_date");
    String end_date = req.getParameter("end_date");
    String start_hour = req.getParameter("start_hour");
    String start_minute = req.getParameter("start_minute");
    String start_second = req.getParameter("start_second");
    String end_hour = req.getParameter("end_hour");
    String end_minute = req.getParameter("end_minute");
    String end_second = req.getParameter("end_second");
    String master_name = req.getParameter("master_name");
    String teacher_name = req.getParameter("teacher_name");
    String _maxAttend = req.getParameter("maxAttend");
    int maxAttend = Integer.parseInt(_maxAttend);
    String remarks = req.getParameter("remarks");

    MeetingCon mc = new MeetingCon();
    UserInfoBo user = (UserInfoBo) req.getSession().getAttribute("user");
    mc.setmId(mId);
    mc.setName(name);
    mc.setStart_date(start_date);
    mc.setEnd_date(end_date);
    mc.setStart_hour(start_hour);
    mc.setStart_minute(start_minute);
    mc.setStart_second(start_second);
    mc.setEnd_hour(end_hour);
    mc.setEnd_minute(end_minute);
    mc.setEnd_second(end_second);
    mc.setMaster_id(master_name);
    mc.setTeacher_id(teacher_name);
    mc.setMaxAttend(maxAttend);
    mc.setRemarks(remarks);
    mc.setUpdater_id(user.getUid());
    mc.setUpdate_date(DateTool.getShortDate()); // 保存当前修改日期

    meetingService.newMeeting(mc);
    return new ModelAndView("redirect:turnStaff.html?mId=" + mId, model);
  }
  /** 会议管理列表首页 */
  @RequestMapping(value = "meetingManageList.html", method = RequestMethod.GET)
  public ModelAndView turnIndex(
      HttpServletRequest req, HttpServletResponse res, String mId, ModelMap model) {
    // mId为空新建,不为空修改
    if (mId != null) {
      MeetingBo mb = meetingService.getMeeting(mId);
      model.put("mb", mb);
    } else {
      model.put("mb", new MeetingBo());
    }

    UserInfoBo user = (UserInfoBo) req.getSession().getAttribute("user");
    Map<String, String> con = new HashMap<String, String>();
    con.put("uid", user.getUid());
    OrganizationBo ob = userInfoService.getManageOrg(con);
    model.put("orgDepOriId", ob.getOrgId());
    return new ModelAndView("meetingManage/meetingManageList", model);
  }
 /** 跳转修改会议内容页面 */
 @RequestMapping(value = "meetingInfo.html", method = RequestMethod.GET)
 public ModelAndView meetingInfo(HttpServletRequest req, HttpServletResponse res, ModelMap model) {
   String mId = req.getParameter("mId");
   boolean bool = false;
   // mId为空新建,不为空修改
   if (mId != null) {
     MeetingBo mb = meetingService.getMeeting(mId);
     model.put("mb", mb);
     if (mb.getStatus() == 1) // 发布不允许修改
     {
       bool = true;
     }
   } else {
     model.put("mb", new MeetingBo());
   }
   ;
   model.put("bool", bool);
   return new ModelAndView("meetingManage/meetingInfo", model);
 }
 /** AJAX方式的更新 用于改变会议的发布状态 */
 @RequestMapping(value = "ajax/update.html", method = RequestMethod.POST)
 @ResponseBody
 public Return ajaxupdate(MeetingCon con, HttpServletRequest request) {
   Return re = meetingService.newMeeting(con);
   return re;
 }
  @Override
  protected void onHandleRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      String type = request.getParameter("type");
      String typeId = request.getParameter("typeId");
      Integer sAccountId = Integer.parseInt(request.getParameter("sAccountId"));
      String siteURL = request.getParameter("siteURL");
      String timeZoneId = request.getParameter("timeZone");
      TimeZone timeZone = TimezoneMapper.getTimezone(timeZoneId);
      String username = request.getParameter("username");
      String localeParam = request.getParameter("locale");
      Locale locale = LocaleHelper.toLocale(localeParam);

      String html = "";
      if (ProjectTypeConstants.PROJECT.equals(type)) {
        ProjectService service = ApplicationContextUtil.getSpringBean(ProjectService.class);
        SimpleProject project = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipProject(locale, project, siteURL, timeZone);
      } else if (ProjectTypeConstants.MESSAGE.equals(type)) {
        MessageService service = ApplicationContextUtil.getSpringBean(MessageService.class);
        SimpleMessage message = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipMessage(locale, message, siteURL, timeZone);
      } else if (ProjectTypeConstants.MILESTONE.equals(type)) {
        MilestoneService service = ApplicationContextUtil.getSpringBean(MilestoneService.class);
        SimpleMilestone mileStone = service.findById(Integer.parseInt(typeId), sAccountId);
        html =
            ProjectTooltipGenerator.generateToolTipMilestone(locale, mileStone, siteURL, timeZone);
      } else if (ProjectTypeConstants.BUG.equals(type)) {
        BugService service = ApplicationContextUtil.getSpringBean(BugService.class);
        SimpleBug bug = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipBug(locale, bug, siteURL, timeZone);
      } else if (ProjectTypeConstants.TASK.equals(type)) {
        ProjectTaskService service = ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
        SimpleTask task = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipTask(locale, task, siteURL, timeZone);
      } else if (ProjectTypeConstants.RISK.equals(type)) {
        RiskService service = ApplicationContextUtil.getSpringBean(RiskService.class);
        SimpleRisk risk = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipRisk(locale, risk, siteURL, timeZone);
      } else if (ProjectTypeConstants.PROBLEM.equals(type)) {
        ProblemService service = ApplicationContextUtil.getSpringBean(ProblemService.class);
        SimpleProblem problem = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipProblem(locale, problem, siteURL, timeZone);
      } else if (ProjectTypeConstants.BUG_VERSION.equals(type)) {
        VersionService service = ApplicationContextUtil.getSpringBean(VersionService.class);
        SimpleVersion version = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipVersion(locale, version, siteURL, timeZone);
      } else if (ProjectTypeConstants.BUG_COMPONENT.equals(type)) {
        ComponentService service = ApplicationContextUtil.getSpringBean(ComponentService.class);
        SimpleComponent component = service.findById(Integer.parseInt(typeId), sAccountId);
        html =
            ProjectTooltipGenerator.generateToolTipComponent(locale, component, siteURL, timeZone);
      } else if (ProjectTypeConstants.PAGE.equals(type)) {
        ProjectPageService pageService =
            ApplicationContextUtil.getSpringBean(ProjectPageService.class);
        Page page = pageService.getPage(typeId, username);
        html = ProjectTooltipGenerator.generateToolTipPage(locale, page, siteURL, timeZone);
      } else if (ProjectTypeConstants.STANDUP.equals(type)) {
        StandupReportService service =
            ApplicationContextUtil.getSpringBean(StandupReportService.class);
        SimpleStandupReport standup = service.findById(Integer.parseInt(typeId), sAccountId);
        html = ProjectTooltipGenerator.generateToolTipStandUp(locale, standup, siteURL, timeZone);
      } else if (CrmTypeConstants.ACCOUNT.equals(type)) {
        AccountService service = ApplicationContextUtil.getSpringBean(AccountService.class);
        SimpleAccount account = service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateToolTipAccount(locale, account, siteURL);
      } else if (CrmTypeConstants.CONTACT.equals(type)) {
        ContactService service = ApplicationContextUtil.getSpringBean(ContactService.class);
        SimpleContact contact = service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateToolTipContact(locale, contact, siteURL, timeZone);
      } else if (CrmTypeConstants.CAMPAIGN.equals(type)) {
        CampaignService service = ApplicationContextUtil.getSpringBean(CampaignService.class);
        SimpleCampaign account = service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateTooltipCampaign(locale, account, siteURL, timeZone);
      } else if (CrmTypeConstants.LEAD.equals(type)) {
        LeadService service = ApplicationContextUtil.getSpringBean(LeadService.class);
        SimpleLead lead = service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateTooltipLead(locale, lead, siteURL, timeZone);
      } else if (CrmTypeConstants.OPPORTUNITY.equals(type)) {
        OpportunityService service = ApplicationContextUtil.getSpringBean(OpportunityService.class);
        SimpleOpportunity opportunity = service.findById(Integer.parseInt(typeId), sAccountId);
        html =
            CrmTooltipGenerator.generateTooltipOpportunity(locale, opportunity, siteURL, timeZone);
      } else if (CrmTypeConstants.CASE.equals(type)) {
        CaseService service = ApplicationContextUtil.getSpringBean(CaseService.class);
        SimpleCase cases = service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateTooltipCases(locale, cases, siteURL, timeZone);
      } else if (CrmTypeConstants.MEETING.equals(type)) {
        MeetingService service = ApplicationContextUtil.getSpringBean(MeetingService.class);
        SimpleMeeting meeting = service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateToolTipMeeting(locale, meeting, siteURL, timeZone);
      } else if (CrmTypeConstants.CALL.equals(type)) {
        CallService service = ApplicationContextUtil.getSpringBean(CallService.class);
        SimpleCall call = service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateToolTipCall(locale, call, siteURL, timeZone);
      } else if (CrmTypeConstants.TASK.equals(type)) {
        TaskService service = ApplicationContextUtil.getSpringBean(TaskService.class);
        com.esofthead.mycollab.module.crm.domain.SimpleTask crmTask =
            service.findById(Integer.parseInt(typeId), sAccountId);
        html = CrmTooltipGenerator.generateToolTipCrmTask(locale, crmTask, siteURL, timeZone);
      } else if ("User".equals(type)) {
        UserService service = ApplicationContextUtil.getSpringBean(UserService.class);
        SimpleUser user = service.findUserByUserNameInAccount(username, sAccountId);
        html = CommonTooltipGenerator.generateTooltipUser(locale, user, siteURL, timeZone);
      } else {
        LOG.error("Can not generate tooltip for item has type " + type);
      }

      response.setCharacterEncoding("UTF-8");
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      out.println(html);
      return;
    } catch (Exception e) {
      LOG.error("Error while get html tooltip attachForm TooltipGeneratorServletRequestHandler", e);
      String html = null;
      PrintWriter out = response.getWriter();
      out.println(html);
      return;
    }
  }