package main.java.com.zte.controller.system; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import org.apache.shiro.SecurityUtils; import org.apache.shiro.session.Session; import org.apache.shiro.subject.Subject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import main.java.com.zte.controller.base.BaseController; import main.java.com.zte.entity.Page; import main.java.com.zte.entity.charts.Option; import main.java.com.zte.entity.charts.Series; import main.java.com.zte.service.PmExceptionService; import main.java.com.zte.util.Const; import main.java.com.zte.util.PageData; @Controller @RequestMapping(value = "/pmException") public class PmExceptionController extends BaseController { @Resource(name = "pmExceptionService") private PmExceptionService pmExceptionService; @RequestMapping(value = "/list") public ModelAndView list(Page page, @RequestParam(value = "taskId", required = false) String taskId) throws Exception { ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); try { pd = this.getPageData(); Subject currentUser = SecurityUtils.getSubject(); Session session = currentUser.getSession(); String userName = (String) session .getAttribute(Const.SESSION_USERNAME); // 获取session中的用户名 pd.put(Const.SESSION_USERNAME, userName); taskId = "1467859122980"; pd.put("taskId", taskId); page.setPd(pd); List<PageData> pmExceptions = pmExceptionService .pmExceptionlistPage(page); mv.addObject("pmExceptions", pmExceptions); mv.addObject("pd", pd); mv.setViewName("pm/exception_list"); } catch (Exception e) { logger.error(e.toString(), e); } return mv; } @RequestMapping(value = "/charts_month") public ModelAndView chartsForMonth(Page page, @RequestParam(value = "taskId", required = false) String taskId) throws Exception { ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); try { pd = this.getPageData(); Subject currentUser = SecurityUtils.getSubject(); Session session = currentUser.getSession(); String userName = (String) session .getAttribute(Const.SESSION_USERNAME); // 获取session中的用户名 pd.put(Const.SESSION_USERNAME, userName); pd.put("taskId", taskId); page.setPd(pd); List<PageData> chartsForMonthResult = pmExceptionService .pmExceptionlistPage(page); List<Series> seriesList = new ArrayList<Series>(); // 存放类别数据 List<String> categoryList = new ArrayList<String>(); // 存放所有 Option options = new Option(); if (!chartsForMonthResult.isEmpty()) { for (PageData pmChart : chartsForMonthResult) { Series series = new Series(); List<Double> datas = new ArrayList<Double>(); if (!seriesList.contains(pmChart.get("TAGS"))) { series.setName(pmChart.get("TAGS").toString()); String pmDatas = pmChart.getString("EXCEPTION_COUNT") .toString(); Double data = Double.valueOf(pmDatas.trim()); datas.add(data); } } } mv.addObject("chartsForMonthResult", chartsForMonthResult); mv.addObject("pd", pd); mv.setViewName("pm/exception_list"); } catch (Exception e) { logger.error(e.toString(), e); } return mv; } @RequestMapping(value = "/exception_detail") public ModelAndView exceptionDetail( Page page, @RequestParam(value = "exception_id", required = false) String exception_id) throws Exception { ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); try { pd = this.getPageData(); pd.put("exception_id", exception_id); page.setPd(pd); List<PageData> pmExceptions = pmExceptionService .pmExceptionlistPage(page); mv.addObject("pmExceptions", pmExceptions); mv.addObject("pd", pd); mv.setViewName("pm/exception_list"); } catch (Exception e) { logger.error(e.toString(), e); } return mv; } }
时间: 2024-11-12 19:23:53