/** * 修改操作 * * @param pageIndex * @param backUrl * @param monthRecord * @param result * @param model * @return */ @RequestMapping(params = "method=modify", method = RequestMethod.POST) public String modify( Long pageIndex, String backUrl, MonthRecord monthRecord, BindingResult result, ModelMap model) { MonthRecord dbMonthRecord = monthRecordService.get(monthRecord.getRecordId()); BeanUtils.copySpecialProperties( monthRecord, dbMonthRecord, "creator,createdTime,modifier,modifiedTime"); model.addAttribute("monthRecord", monthRecord); try { monthRecordService.validateNotNull(monthRecord); monthRecordService.modify(monthRecord); } catch (OssRollbackCheckedException e) { log.error(e); if (null == e.getErrors() && e.getErrors().hasErrors()) { ValidatorUtils.convert2SpringError(e.getErrors(), result); model.addAttribute("message", MessageUtils.getInfoValue("FAIL_MODIFY")); } else { model.addAttribute( "message", MessageUtils.getInfoValue("FAIL_MODIFY") + "<br>" + e.getMessage()); } model.addAttribute("backUrl", backUrl); model.addAttribute("pageIndex", pageIndex); return "month_record/modify"; } return showList(pageIndex, model); }
/** * 显示月统计列表 * * @return */ @RequestMapping(params = "method=show", method = RequestMethod.GET) public String showList(Long pageIndex, ModelMap model) { List<MonthRecord> monthRecords = monthRecordService.getShowList(pageIndex); Long count = monthRecordService.getCount(); model.addAttribute("monthRecords", monthRecords); model.addAttribute("count", count); model.addAttribute("pageIndex", pageIndex); model.addAttribute("lastPageIndex", monthRecordService.getLastPage(count)); return "month_record/list"; }
/** * 重新统计 * * @param recordId * @param pageIndex * @param model * @return */ @RequestMapping(params = "method=reCount", method = RequestMethod.GET) public String reCount(Long recordId, Long pageIndex, ModelMap model) { MonthRecord monthRecord = monthRecordService.get(recordId); try { monthRecordService.reStatistics(monthRecord.getMonthTime()); model.addAttribute("message", MessageUtils.getInfoValue("SUCC_MODIFY")); } catch (OssRollbackCheckedException e) { log.error(e); model.addAttribute("message", MessageUtils.getInfoValue("FAIL_MODIFY")); } return showList(pageIndex, model); }
/** * 指定时间进行统计 * * @param dateTime * @param pageIndex * @param request * @param model * @return */ @RequestMapping(params = "method=add", method = RequestMethod.GET) public String add(Date dateTime, Long pageIndex, HttpServletRequest request, ModelMap model) { MonthRecord monthRecord = monthRecordService.getByMonthTime(dateTime); if (null != monthRecord) { model.addAttribute("message", MessageUtils.getExceptionValue("IS_EXISITS")); return showList(pageIndex, model); } try { monthRecordService.add(dateTime); model.addAttribute("message", MessageUtils.getInfoValue("SUCC_OPER")); } catch (OssRollbackCheckedException e) { log.equals(e); model.addAttribute("message", MessageUtils.getInfoValue("FAIL_OPER")); } return showList(pageIndex, model); }
/** * 查看 * * @param recordId * @param backUrl * @param request * @param model * @return */ @RequestMapping(params = "method=details", method = RequestMethod.GET) public String details(Long recordId, String backUrl, HttpServletRequest request, ModelMap model) { MonthRecord monthRecord = monthRecordService.get(recordId); model.addAttribute("monthRecord", monthRecord); model.addAttribute("backUrl", getBackUrl(backUrl, request)); return "month_record/details"; }
/** * 进入修改页面 * * @param pageIndex * @param recordId * @param request * @param model * @return */ @RequestMapping(params = "method=modify", method = RequestMethod.GET) public String modify(Long pageIndex, Long recordId, HttpServletRequest request, ModelMap model) { MonthRecord monthRecord = monthRecordService.get(recordId); model.addAttribute("monthRecord", monthRecord); model.addAttribute("backUrl", getBackUrl(null, request)); model.addAttribute("pageIndex", pageIndex); return "month_record/modify"; }