停车记录管理系统 - 添加、查询、编辑、删除停车记录
/**
-
停车记录控制器 */ @Controller @RequestMapping(value = "/jilu", produces = {"application/json;charset=UTF-8"}) public class JiluController extends BaseController { @Resource private JiluService jiluService;
@RequestMapping(value = "/page/add") public String addPage(ModelMap modelMap) { List
cheweis = cheweiService.query(); modelMap.put('cheweiList', cheweis); return "/jilu/jilu_add"; } @RequestMapping(value = "/query") public String query(HttpServletRequest request, @RequestParam(required = false, defaultValue = "1") int startId, @RequestParam(required = false, defaultValue = "1") int pageIndex, @RequestParam(required = false, defaultValue = "10") int pageSize, @RequestParam(required = false) String searchKey, ModelMap modelMap) { if (StringUtils.isNotEmpty(searchKey)) { pageSize = 100; } Page
result = jiluService.selectByPage(startId, pageIndex, pageSize, searchKey); modelMap.put('jiluList', result.getResult()); if (StringUtils.isEmpty(searchKey)) { modelMap.put('page', getPageInfo(result).getHtml()); } List cheweis = cheweiService.query(); modelMap.put('cheweiList', cheweis); return "/jilu/jilu_list"; } @RequestMapping(value = "/add", method = RequestMethod.POST) @ResponseBody public String editTiku(HttpServletRequest request, Jilu jilu, ModelMap modelMap) { if (jilu.getId() == null) { modelMap.put('result', new ResponseVo(jiluService.insertSelective(jilu) ? ResponseType.ADD_SUCCESS : ResponseType.ADD_FAIL)); Chewei chewei = cheweiService.selectByPrimaryKey(jilu.getCheweiid()); chewei.setState(0); cheweiService.updateByPrimaryKey(chewei); } return FastjsonUtils.serialize(modelMap); }
@RequestMapping(value = "/del/{id}") @ResponseBody public String del(@PathVariable Integer id, ModelMap modelMap) { Jilu jiluS = jiluService.selectByPrimaryKey(id); Chewei chewei = cheweiService.selectByPrimaryKey(jiluS.getCheweiid()); chewei.setState(1); cheweiService.updateByPrimaryKey(chewei); Jilu jilu = new Jilu(); jilu.setId(id); // 直接删除 boolean result = jiluService.deleteByPrimaryKey(id); // 更新删除 modelMap.put('result', new ResponseVo(result ? ResponseType.DEL_SUCCESS : ResponseType.DEL_FAIL)); return FastjsonUtils.serialize(modelMap); }
@RequestMapping(value = "/edit", method = RequestMethod.POST) @ResponseBody public String edit(HttpServletRequest request, Jilu jilu, ModelMap modelMap) { long zongjia = 0; long shichang = (long) Math.ceil(((jilu.getChushijian().getTime() - jilu.getRushijian().getTime()) / (1000 * 60 * 60.0)));
Chewei chewei = cheweiService.selectByPrimaryKey(jilu.getCheweiid()); Feiyong feiyong = feiyongService.selectByLeixing(chewei.getLeixing()); zongjia = (long) (feiyong.getJiage() * shichang); jilu.setDanjia((double) zongjia); modelMap.put('result', new ResponseVo(jiluService.updateByPrimaryKeySelective(jilu) ? ResponseType.EDIT_SUCCESS : ResponseType.EDIT_FAIL)); chewei.setState(1); cheweiService.updateByPrimaryKey(chewei); return FastjsonUtils.serialize(modelMap);}
@RequestMapping(value = "/jiaofei/{id}", method = RequestMethod.POST) @ResponseBody public String jiaofei(@PathVariable Integer id, ModelMap modelMap) { Jilu jilu = jiluService.selectByPrimaryKey(id); jilu.setChushijian(new Date()); long zongjia = 0; long shichang = (long) Math.ceil(((jilu.getChushijian().getTime() - jilu.getRushijian().getTime()) / (1000 * 60 * 60.0)));
Chewei chewei = cheweiService.selectByPrimaryKey(jilu.getCheweiid()); Feiyong feiyong = feiyongService.selectByLeixing(chewei.getLeixing()); zongjia = (long) (feiyong.getJiage() * shichang); jilu.setDanjia((double) zongjia); modelMap.put('result', new ResponseVo(jiluService.updateByPrimaryKeySelective(jilu) ? ResponseType.JIAOFEI_SUCCESS : ResponseType.JIAOFEI_FAIL)); chewei.setState(1); cheweiService.updateByPrimaryKey(chewei); return FastjsonUtils.serialize(modelMap);}
@RequestMapping(value = "/page/edit/{id}") public String editTiku(@PathVariable Integer id, ModelMap modelMap) { Jilu result = jiluService.selectByPrimaryKey(id); List
cheweis = cheweiService.query(); modelMap.put('cheweiList', cheweis); modelMap.put('result', result); return "/jilu/jilu_edit"; } @RequestMapping(value = "/page/lintongji") public String lintongji() { return "/tongji/lintongji_list"; }
@RequestMapping(value = "/tj/day") @ResponseBody public String getTongjiByDay(Integer days, ModelMap modelMap) { Tongji tongji = jiluService.getTongjiByDay(days); modelMap.put('tongji', tongji); return FastjsonUtils.serialize(modelMap); } }
原文地址: https://www.cveoy.top/t/topic/nEFL 著作权归作者所有。请勿转载和采集!