@RequestMapping("/achatDetail/{userid}") public String achatDetail(@PathVariable int userid, Model model, Achat ac) { ac.setCreate_user(userid + ""); List<Achat> list = achatService.findAll(ac); for (Achat a : list) { String category_id = a.getCategory_id(); Category c = categoryService.get(Integer.parseInt(category_id)); a.setCategory_name(c.getName()); String state = a.getState(); a.setState(StringUtil.getState(state)); String uid = a.getCreate_user(); a.setCreate_username(userService.get(Integer.parseInt(uid)).getUsername()); String sid = a.getSupport_id(); if (sid != null) { a.setSupport_name(userService.get(Integer.parseInt(sid)).getUsername()); } else { a.setSupport_name("暂无供应商报价"); } } String start_date = ac.getStart_date(); String end_date = ac.getEnd_date(); if (start_date != null && end_date != null) { model.addAttribute("start_date", start_date); model.addAttribute("end_date", end_date); } model.addAttribute("achatlist", list); return "/front/user/achatDetail"; }
@RequestMapping("/checkPrice") public String checkPrice(Model model, Achat ac, HttpSession session) { User user = (User) session.getAttribute("user"); achatService.update(ac); ac = achatService.get(ac.getId()); // 将同意的那条流程更新之后,将另外两个供应商的数据删掉 Achat ac2 = new Achat(); ac2.setTitle(ac.getTitle()); ac2.setContent(ac.getContent()); ac2.setState("2"); List<Achat> others = achatService.findAll(ac2); for (Achat ac3 : others) { achatService.delete(ac3.getId()); } return "redirect:/user/achatDetail/" + user.getId(); }
@RequestMapping("/getNotification") public void getNotification(HttpServletResponse response, HttpSession session) { User user = (User) session.getAttribute("user"); Achat at = new Achat(); at.setSupport_id(user.getId() + ""); List<Achat> list = achatService.findAll(at); for (Achat a : list) { String category_id = a.getCategory_id(); Category c = categoryService.get(Integer.parseInt(category_id)); a.setCategory_name(c.getName()); String state = a.getState(); a.setState(StringUtil.getState(state)); } String json = JSON.toJSONString(list); try { response.getWriter().println(json); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }