// 修改 @RequestMapping(value = "/update", method = RequestMethod.POST) @ResponseBody public Object update( Long id, String lotnum, String controlbaseid, String producetime, String exp, String vender, String expkf, String description) { ControlNumInfo controlNumInfo = null; try { controlNumInfo = controlNumInfoService.selectByPrimaryKey(id); controlNumInfo.setLotnum(lotnum); ControlBaseInfo controlBaseInfo = new ControlBaseInfo(); controlBaseInfo.setId(Long.valueOf(controlbaseid)); controlNumInfo.setControlbaseid(controlBaseInfo); controlNumInfo.setVender(vender); controlNumInfo.setExpkf(Long.valueOf(expkf)); controlNumInfo.setDescription(description); controlNumInfo.setFoundman(UserContextHelper.getUserName()); controlNumInfo.setProducetime(Kalendar.getParse(producetime)); controlNumInfo.setExp(Kalendar.getParse(exp)); controlNumInfo.setFoundtime(new Date()); controlNumInfoService.updateByPrimaryKeySelective(controlNumInfo); LOG.info("质控品批号修改成功,ID为{}", id); } catch (NumberFormatException e) { e.printStackTrace(); LOG.info("质控品批号修改失败,ID为{}", id); } return controlNumInfo; }
// 列表页中返回json数据 @RequestMapping("/jsonList") public Object jsonList(HttpServletRequest request, HttpServletResponse response) { int pageSize = request.getParameter("limit") == null ? 10 : Integer.parseInt(request.getParameter("limit")); Map filter = getFilterMap(request); int currentResult = Integer.parseInt(request.getParameter("offset")); PageInfo pageInfo = new PageInfo(); pageInfo.setShowCount(pageSize); pageInfo.setCurrentResult(currentResult); pageInfo.setFilter(filter); pageInfo.setSortField("id"); pageInfo.setOrder("asc"); List<ControlNumInfo> controlNumInfos = controlNumInfoService.selectListPage(pageInfo); Json json = new Json(); if (pageInfo.getTotalResult() > 0) { json.add("total", pageInfo.getTotalResult()); for (ControlNumInfo controlNumInfo : controlNumInfos) { Json json_a = new Json(); json_a.add("id", String.valueOf(controlNumInfo.getId())); json_a.add("lotnum", controlNumInfo.getLotnum()); json_a.add("producetime", Kalendar.getFormat(controlNumInfo.getProducetime())); json_a.add("exp", Kalendar.getFormat(controlNumInfo.getExp())); json_a.add("vender", controlNumInfo.getVender()); json_a.add("expkf", String.valueOf(controlNumInfo.getExpkf())); json_a.add("foundtime", Kalendar.getFormat(controlNumInfo.getFoundtime())); json_a.add("description", controlNumInfo.getDescription()); json_a.add("foundman", controlNumInfo.getFoundman()); json_a.add("controlbaseid", String.valueOf(controlNumInfo.getControlbaseid().getId())); json_a.add("controlbasename", controlNumInfo.getControlbaseid().getControlmername()); json.add("rows", json_a); } } else { Json json_a = new Json(); json.add("total", 0); json.add("rows", json_a); } response.setContentType("application/json;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); PrintWriter pw = null; try { pw = response.getWriter(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } pw.write(json.toString()); pw.flush(); return null; }