/** * @created 2014年12月5日 下午5:57:35 * @author leijj 类说明 : */ @SuppressWarnings({"unchecked", "rawtypes", "unused"}) public class ResumeMainController extends Entry { @Override protected void setOtherData(HttpServletRequest request, HttpServletResponse response, Map model) throws Exception { String action = request.getParameter("a"); model.put("type", request.getParameter("type")); if ("myrecruit".equals(action)) { // 我收藏的职位 myrecruit(request, response, model); } else if ("recruitresume".equals(action)) { // 已投递简历的职位 recruitresume(request, response, model); } } /** * @author leijj 功能: 我收藏的职位查询 * @param request * @param response * @param model * @throws Exception */ private void myrecruit(HttpServletRequest request, HttpServletResponse response, Map model) throws Exception { String recruitType = get(request, "recruitType"); User user = userManager.getUserByCode(SessionHelper.getUserCode(request)); int curPage = getInt(request, "curPage", 1); Message msg = resumeManager.getMyRecruits(curPage, 9, user == null ? 0 : user.getId()); model.put("msg", msg); } private void recruitresume(HttpServletRequest request, HttpServletResponse response, Map model) throws Exception { String recruitType = get(request, "recruitType"); User user = userManager.getUserByCode(SessionHelper.getUserCode(request)); int curPage = getInt(request, "curPage", 1); Message msg = resumeManager.getMyResumeRecruits(curPage, 9, user == null ? 0 : user.getId()); model.put("msg", msg); } @Override protected String getCurrentMenu() { return "影人"; } @Override protected void setMetaData(HttpServletRequest request, Map model) { model.put("title", "合众映画"); model.put("keywords", "合众映画"); model.put("description", "合众映画"); } @Override protected Menu[] getInfoMenus(HttpServletRequest request, int infoType) { String class1 = "", class2 = "", class3 = ""; switch (infoType) { case 1: class1 = "current"; break; case 2: class2 = "current"; break; case 3: class3 = "current"; break; default: break; } List<Menu> list = new ArrayList<Menu>(); // list.add(new Menu(1, "我的简历","/resume/myresume.do?infoType=1", class1, -999,0)); list.add(new Menu(2, "职位收藏", "/resume/myrecruit.do?a=myrecruit&infoType=2", class2, -999, 0)); list.add( new Menu( 3, "已投简历", "/resume/recruitresume.do?a=recruitresume&infoType=3", class3, -999, 0)); return (Menu[]) list.toArray(new Menu[0]); } private UserManager userManager = (UserManager) Context.getBean(UserManager.class); private UserResumeManager resumeManager = (UserResumeManager) Context.getBean(UserResumeManager.class); }
/** * 职位订阅 * * @author wang.yq */ public class SubscibeRecruitJob { Log log = Context.getLog("invest"); protected void execute() throws Exception { log.info("开始执行定时任务:SubscibeRecruitJob"); try { StringBuilder sb = new StringBuilder(); Map<String, String> map = new HashMap<String, String>(); // 1.获取订阅列表 RecruitSubscibe[] subs = null; subs = recruitSubscibeManager.queryRecruitSubscibe(); // 2.找到要发送的职位信息 if (subs != null && subs.length > 0) { for (int i = 0; i < subs.length; i++) { RecruitSubscibe rs = subs[i]; int cityid = rs.getCityId(); int recid = rs.getRecId(); // 获得职位 UserRecruit[] recs = recruitManager.queryRecruitsSubscibe(cityid, recid); map.put(rs.getMail(), getRecs(rs.getId(), recs)); // 4.更新职位订阅发送时间 recruitSubscibeManager.updatePostTime(String.valueOf(rs.getId())); } } // 3.发送职位信息 for (String key : map.keySet()) { String mail = key; String content = map.get(key); try { EmailSender emailSender = EMailSenderHelper.getEmailSender(); // 邮件发送服务器信息先组装好 emailSender.setSubject("合众映画——职位订阅"); // 邮件标题 emailSender.setContent(content); // 邮件内容 emailSender.setTime(DateUtils.getTimestamp()); // 邮件发送时间 emailSender.setToAddress(mail); SimpleMailSender mailSender = new SimpleMailSender(); mailSender.setMailInfo(emailSender); mailSender.sendHtmlMail(); } catch (Exception e) { log.debug("职位订阅发送邮件失败。" + e.getMessage()); } } } catch (Exception e) { log.info("执行定时任务错误:SubscibeRecruitJob"); log.info("errorinfo:" + e.getMessage()); } log.info("结束执行定时任务:SubscibeRecruitJob"); } public SubscibeRecruitJob() { // TODO Auto-generated constructor stub } /** * 组织职位样式 * * @param recs * @return * @throws Exception */ private String getRecs(Integer id, UserRecruit[] recs) throws Exception { StringBuilder sb = new StringBuilder(); String urlString = "http://home.crowdcine.cn"; try { urlString = ParamReader.getSEOConfig("当前网址"); } catch (Exception e) { } if (recs != null && recs.length > 0) { for (int i = 0; i < recs.length; i++) { sb.append( "<p><a href=\"" + urlString + "/recruit/DetailMain.do?a=detail&id" + recs[i].getId() + "\">"); sb.append(recs[i].getTypeName() + " " + recs[i].getCityName()); sb.append("</a></p>"); } } sb.append( "<a href=\"" + urlString + "/recruit/uesrRecruitSubscibe.do?a=cancelRecruitSubscibe&id=" + String.valueOf(id) + "\">取消职位订阅</a>"); return sb.toString(); } private RecruitSubscibeManager recruitSubscibeManager = (RecruitSubscibeManager) Context.getBean(RecruitSubscibeManager.class); private RecruitManager recruitManager = (RecruitManager) Context.getBean(RecruitManager.class); }