Java 實(shí)戰(zhàn)項(xiàng)目錘煉之小區(qū)物業(yè)管理系統(tǒng)的實(shí)現(xiàn)流程
一、項(xiàng)目簡(jiǎn)述
功能包括: 分為管理員及普通業(yè)主角色,業(yè)主信息,社區(qū)房屋,維護(hù) 管理,社區(qū)車輛,社區(qū)投訴,社區(qū)繳費(fèi),社區(qū)業(yè)務(wù)信息維 護(hù)等等功能。
二、項(xiàng)目運(yùn)行
環(huán)境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
項(xiàng)目技術(shù): JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + maven等等。
小區(qū)物業(yè)管理系統(tǒng)驗(yàn)證碼代碼:
/** * * Description: 驗(yàn)證碼生成器 */ public class Captcha { private static char mapTable[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; public static Map<String, Object> getImageCode(int width, int height, OutputStream os) { Map<String, Object> returnMap = new HashMap<String, Object>(); if (width <= 0) width = 60; if (height <= 0) height = 20; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // 獲取圖形上下文 Graphics g = image.getGraphics(); // 生成隨機(jī)類 Random random = new Random(); // 設(shè)定背景色 g.setColor(getRandColor(200, 250)); g.fillRect(0, 0, width, height); // 設(shè)定字體 g.setFont(new Font("Times New Roman", Font.PLAIN, 18)); // 隨機(jī)產(chǎn)生168條干擾線,使圖象中的認(rèn)證碼不易被其它程序探測(cè)到 g.setColor(getRandColor(160, 200)); for (int i = 0; i < 168; i++) { int x = random.nextInt(width); int y = random.nextInt(height); int xl = random.nextInt(12); int yl = random.nextInt(12); g.drawLine(x, y, x + xl, y + yl); } // 取隨機(jī)產(chǎn)生的碼 String strEnsure = ""; // 4代表4位驗(yàn)證碼,如果要生成更多位的認(rèn)證碼,則加大數(shù)值 for (int i = 0; i < 4; ++i) { strEnsure += mapTable[(int) (mapTable.length * Math.random())]; // 將認(rèn)證碼顯示到圖象中 g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); // 直接生成 String str = strEnsure.substring(i, i + 1); // 設(shè)置隨便碼在背景圖圖片上的位置 g.drawString(str, 13 * i + 20, 25); } // 釋放圖形上下文 g.dispose(); returnMap.put("image", image); returnMap.put("strEnsure", strEnsure); return returnMap; } // 給定范圍獲得隨機(jī)顏色 static Color getRandColor(int fc, int bc) { Random random = new Random(); if (fc > 255) fc = 255; if (bc > 255) bc = 255; int r = fc + random.nextInt(bc - fc); int g = fc + random.nextInt(bc - fc); int b = fc + random.nextInt(bc - fc); return new Color(r, g, b); } }
小區(qū)物業(yè)管理系統(tǒng)業(yè)主投訴代碼:
@Controller public class ComplainController { @Autowired ComplainService complainService; ComplainExample complainExample = new ComplainExample() ; @RequestMapping("/main") public String test() { return "main"; } /** * 全部投訴信息 */ @RequestMapping("/complain") public String complain(Model model) { List<Complain> list =complainService.findAll(); model.addAttribute("complainlist", list); return "complain"; } /** * 業(yè)主跳轉(zhuǎn)添加投訴頁(yè)面 */ @RequestMapping("/addcomplaint") public String addcomplaint() { return "addonecomplain"; } /** * 添加投訴到數(shù)據(jù)庫(kù) */ @RequestMapping("/savecomplain") public String savecomplain(Complain complain) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); Date date = new Date(); String d = format.format(date); complain.setStatedate(d); complainService.addOne(complain); return "addonecomplain"; } /** * 分類投訴信息 */ @RequestMapping("/complainstate") public String complainstate(Model model,String state) { List<Complain> list =complainService.findByState(state); model.addAttribute("complainlist", list); return "complain"; } /** * 查詢投訴信息 */ @RequestMapping("/mycomplaint") public String mycomplaint(Model model,HttpSession session) { System.out.println("mycomplaint:"+(int)session.getAttribute("owneruid")); List<Complain> list = complainService.findByOid((int) session.getAttribute("owneruid")); model.addAttribute("mycomplaintlist", list); return "mycomplaint"; } @RequestMapping("/test") public String test1() { return "test"; } }
未繳費(fèi)賬單控制器代碼:
/** * @category 未繳費(fèi)賬單控制器 * */ @Controller public class BillController { @Autowired private BillService billService; @Autowired private BillitemsService bitemService; @Autowired private OwnerService oService; private SimpleDateFormat cx = new SimpleDateFormat("yyyy-MM-dd"); /** * @category 跳轉(zhuǎn)至業(yè)主未繳費(fèi)展示頁(yè)面 * @param model * @return */ @RequestMapping("/unpay") public String unpay(Model model) { // SimpleDateFormat cx = new SimpleDateFormat("yyyy-MM-dd"); String start = "2010-01-01"; String stop = cx.format(new Date()); List<Owner> list = billService.findByOwner(); model.addAttribute("list", list); model.addAttribute("start", start); model.addAttribute("stop", stop); model.addAttribute("inputname", "請(qǐng)輸入姓名"); return "unpay"; } /** * @category 通過(guò)給定時(shí)間范圍展示和業(yè)主模糊姓名聯(lián)合查詢繳費(fèi)信息 * @param model * @param request * @return * @throws ParseException */ @RequestMapping("/unpaytime") public String unpayByTime(Model model, HttpServletRequest request, HttpSession session) throws ParseException { // 獲取分頁(yè)參數(shù)設(shè)置每頁(yè)展示的個(gè)數(shù) int pageSize = (int) session.getAttribute("pageSize"); // 獲取分頁(yè)參數(shù)設(shè)置傳進(jìn)來(lái)的頁(yè)碼是多少 int pageNum = (int) session.getAttribute("pageNum"); // 將字符串轉(zhuǎn)換為日期對(duì)象 Date start = cx.parse(request.getParameter("start")); Date stop = cx.parse(request.getParameter("stop")); // System.out.println(request.getParameter("start")); String name = request.getParameter("username"); // System.out.println(name); // 賬單的時(shí)間用于和stop和start比較 Date billdate; // 開(kāi)始時(shí)間戳 long startTime = start.getTime(); // 結(jié)束時(shí)間戳 long stopTime = stop.getTime(); long billtime; // 用該list給owner對(duì)象的billlist設(shè)值 List<Bill> billlist = new ArrayList<>(); // 查找所有 List<Owner> list1 = billService.findByOwner(); List<Owner> list = new ArrayList<>(); // 生成要返回的list for (int i = 0; i < list1.size(); i++) { double total = 0; // 循環(huán)遍歷得到的所有owner對(duì)象 for (int j = 0; j < list1.get(i).getBill().size(); j++) { //獲得owner單個(gè)訂單的時(shí)間戳 billdate = cx.parse(list1.get(i).getBill().get(j).getBilltime()); billtime = billdate.getTime(); //判斷訂單的時(shí)間戳是否在指定的范圍內(nèi),并且該owner的姓名要包含指定的字符串 try { if (billtime >= startTime && billtime <= stopTime && list1.get(i).getOname().contains(name)) { // 如果滿足上述條件,則將該條訂單信息添加到billlist中 billlist.add(list1.get(i).getBill().get(j)); // 計(jì)算總價(jià) total += list1.get(i).getBill().get(j).getBillitem().getBillitemmoney(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } // 如果該業(yè)主有未繳納的賬單,給該業(yè)主對(duì)象設(shè)置未繳納賬單,并將該對(duì)象放入要傳給前端的list中 if (billlist.size() > 0) { list1.get(i).setTotal(total); list1.get(i).setBill(billlist); list.add(list1.get(i)); } // 這里不能使用clear() 用list.clear()方法清空l(shuí)ist;用此方法,其它引用該list的值也會(huì)變成空。 billlist = new ArrayList<>(); } if (list.size() < 1) { model.addAttribute("nolist", "沒(méi)有查到相關(guān)信息呦,請(qǐng)您重新輸入查詢條件"); } // 計(jì)算查詢總數(shù) double listnum = list.size(); int totalnum = (int) Math.ceil(listnum / pageSize); List<Owner> list2 = FyResult.getOwnerList(pageSize, pageNum, list, "f"); // System.out.println(list.size()); session.setAttribute("start", request.getParameter("start")); session.setAttribute("stop", request.getParameter("stop")); model.addAttribute("list", list2); model.addAttribute("name", name); model.addAttribute("totalnum", totalnum); session.setAttribute("pageSize", pageSize); session.setAttribute("pageNum", pageNum); session.setAttribute("findList", list); return "unpay"; } /** * @category 收費(fèi)項(xiàng)目管理界面 * @param model * @return */ @RequestMapping("/sfmanage") public String shoufeiguanli(Model model) { BillitemsExample example = new BillitemsExample(); List<Billitems> list = bitemService.selectByExample(example); model.addAttribute("list", list); return "sfmanage"; } /** * @category 添加新的收費(fèi)項(xiàng)目 * @param model * @param billitem * @return */ @RequestMapping("/addbillitem") public String addbillitem(Model model, Billitems billitem) { // 判斷添加的收費(fèi)項(xiàng)目是否為一次性收費(fèi) if (billitem.getBillitemtype().equals("一次性")) { Date d = new Date(); // 生成一次性收費(fèi)的時(shí)間 // SimpleDateFormat itemtime = new SimpleDateFormat("yyyy-MM-dd"); String time = cx.format(d); billitem.setBillitemtime(time); // 添加到數(shù)據(jù)庫(kù) bitemService.insert(billitem); // 從數(shù)據(jù)庫(kù)查剛剛添加的收費(fèi)項(xiàng)目 Billitems item = bitemService.selectByNameAndTime(billitem.getBillitemname(), time); // 給所有的業(yè)主添加這個(gè)費(fèi)用收費(fèi) List<Owner> olist = oService.selectByExample(); int[] all = new int[olist.size()]; // 給數(shù)組all賦值業(yè)主的id for (int i = 0; i < all.length; i++) { all[i] = olist.get(i).getOid(); } Bill bill = new Bill(); bill.setBillitemid(item.getBillitemid()); bill.setPaystatus("未繳納"); bill.setBilltime(time); for (int i = 0; i < all.length; i++) { bill.setUid(all[i]); billService.addBill(bill); } return "redirect:sfmanage.action"; } bitemService.insert(billitem); return "redirect:sfmanage.action"; } /** * @category 搜索后展示繳費(fèi) * @param model * @param request * @return */ @RequestMapping("/showbyname") public String showbyname(Model model, HttpServletRequest request, HttpSession session) { int pageSize = (int) session.getAttribute("pageSize"); int pageNum = (int) session.getAttribute("pageNum"); String name = request.getParameter("username"); // System.out.println(name); List<Owner> list1 = billService.findByOwner(); List<Owner> list2 = FyResult.getOwnerList(pageSize, pageNum, list1, "f"); // System.out.println(list1.size()); List<Owner> list = new ArrayList<>(); for (int i = 0; i < list2.size(); i++) { // System.out.println(list1.get(i).getOname()); if (list1.get(i).getOname().contains(name)) { list.add(list1.get(i)); } } double listnum = list1.size(); int totalnum = (int) Math.ceil(listnum / pageSize); session.setAttribute("findList", list); session.setAttribute("pageSize", pageSize); session.setAttribute("pageNum", pageNum); model.addAttribute("list", list); model.addAttribute("inputname", name); model.addAttribute("totalnum", totalnum); return "unpay"; } /** * @category ajax搜索 * @param name * @return */ @RequestMapping("/showname") public @ResponseBody List<Owner> showname(String name) { System.out.println("進(jìn)來(lái)了"); List<Owner> list1 = oService.selectByExample(); List<Owner> list = new ArrayList<>(); for (int i = 0; i < list1.size(); i++) { if (list1.get(i).getOname().contains(name)) { list.add(list1.get(i)); } } return list; } @SuppressWarnings("unchecked") @RequestMapping("/unpayfy") public String unpayfy(Model model, HttpSession session, int pageSize, int pageNum, String type, HttpServletRequest request) { System.out.println(pageNum); String stop; String start; // SimpleDateFormat cx = new SimpleDateFormat("yyyy-MM-dd"); if (session.getAttribute("stop") != null) { stop = (String) session.getAttribute("stop"); } else { stop = cx.format(new Date()); } if (session.getAttribute("start") != null) { start = (String) session.getAttribute("start"); } else { start = "2010-01-01"; } List<Owner> list1 = new ArrayList<>(); if (session.getAttribute("findList") != null) { list1 = (List<Owner>) session.getAttribute("findList"); } else { list1 = billService.findByOwner(); } double listnum = list1.size(); int totalnum = (int) Math.ceil(listnum / pageSize); List<Owner> list = FyResult.getOwnerList(pageSize, pageNum, list1, type); if (type.equals("z")) { ++pageNum; if (pageNum > totalnum) { pageNum = totalnum; } } if (type.equals("j")) { --pageNum; if (pageNum < 1) { pageNum = 1; } } if(type.equals("f")) { if(pageNum<1) { pageNum=1; } if(pageNum>totalnum) { pageNum = totalnum; } } model.addAttribute("list", list); session.setAttribute("stop", stop); session.setAttribute("start", start); session.setAttribute("pageSize", pageSize); session.setAttribute("pageNum", pageNum); model.addAttribute("totalnum", totalnum); return "unpay"; } }
房間處理器:
/** * @category 房間處理器 * */ @Controller public class HouseController { @Autowired private HouseNumberService hService; /** * @category 通過(guò)傳入?yún)?shù)展示相應(yīng)的房屋信息 * @param type * @param model * @return */ @RequestMapping("/showhouse") public String showhouse(@RequestParam ("type") String type,Model model) { System.out.println(type); HousenumberExample example=new HousenumberExample(); List<Housenumber> list=hService.selectByExample(example); List<Housenumber> list1=new ArrayList<Housenumber>(); if(type.equals("a")) { model.addAttribute("list", list); model.addAttribute("can", "a"); return "house"; } else if(type.equals("x")) { for (int i = 0; i < list.size(); i++) { if(list.get(i).getStatus().equals("閑置")) { list1.add(list.get(i)); } } model.addAttribute("can", "x"); model.addAttribute("list", list1); return "house"; } else if(type.equals("y")) { for (int i = 0; i < list.size(); i++) { if(list.get(i).getStatus().equals("已出售")) { list1.add(list.get(i)); } } model.addAttribute("can", "y"); model.addAttribute("list", list1); return "house"; } return "mian"; } /** * @category 跳轉(zhuǎn)到更新房屋信息頁(yè)面 * @param model * @param homeid * @return */ @RequestMapping("/updatehouse") public String updatehouse(Model model,@RequestParam ("homeid") int homeid) { Housenumber house=hService.selectByPrimaryKey(homeid); model.addAttribute("house", house); return "updatehouse"; } /** * @category 跟新房屋信息 * @param model * @param house * @return */ @RequestMapping("/updatehouse1") public String updatehouse1(Model model, Housenumber house) { String type=house.getStatus(); if(type.equals("閑置")) { type="x"; }else if(type.equals("已出售")) { type="y"; } System.out.println(house.getStatus()); hService.updateByPrimaryKeySelective(house); model.addAttribute("house", house); return "redirect:showhouse.action?type="+type; } /** * @category 添加新的閑置房屋 * @param model * @param house * @return */ @RequestMapping("/addhouse") public String addhouse(Model model,Housenumber house) { house.setSaleprice(0); hService.insert(house); return "redirect:showhouse.action?type=a"; } }
工作提出意見(jiàn)或建議頁(yè)面:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <!DOCTYPE html> <html lang="en" class="no-js"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Fullscreen Form Interface</title> <meta name="description" content="Fullscreen Form Interface: A distraction-free form concept with fancy animations" /> <meta name="keywords" content="fullscreen form, css animations, distraction-free, web design" /> <meta name="author" content="Codrops" /> <link rel="shortcut icon" href="../favicon.ico" rel="external nofollow" > <link rel="stylesheet" type="text/css" href="static/css/normalize.css" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="static/css/demo.css" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="static/css/component.css" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="static/css/cs-select.css" rel="external nofollow" /> <link rel="stylesheet" type="text/css" href="static/css/cs-skin-boxes.css" rel="external nofollow" /> <script src="static/js/modernizr.custom.js"></script> </head> <body> <div class="container"> <div class="fs-form-wrap" id="fs-form-wrap"> <div class="fs-title"> <h1>歡迎對(duì)我們的工作提出意見(jiàn)或建議</h1> </div> <form id="myform" class="fs-form fs-form-full" autocomplete="off" action="savecomplain.action"> <ol class="fs-fields"> <li> <label class="fs-field-label fs-anim-upper" for="q1">請(qǐng)選擇投訴類型</label> <select name="type" class="fs-anim-lower"> <option value="房屋質(zhì)量問(wèn)題">房屋質(zhì)量問(wèn)題</option> <option value="公共空間、公共場(chǎng)地">公共空間、公共場(chǎng)地</option> <option value="設(shè)備設(shè)施、共用設(shè)施">設(shè)備設(shè)施、共用設(shè)施</option> <option value="景觀設(shè)計(jì)、綠化問(wèn)題">景觀設(shè)計(jì)、綠化問(wèn)題</option> <option value="小區(qū)四周的噪音污染">小區(qū)四周的噪音污染</option> <option value="物業(yè)服務(wù)不到位">物業(yè)服務(wù)不到位</option> <option value="物業(yè)管理費(fèi)及其他費(fèi)用問(wèn)題">物業(yè)管理費(fèi)及其他費(fèi)用問(wèn)題</option> <option value="物業(yè)管理不透明">物業(yè)管理不透明</option> </select> <!--<input class="fs-anim-lower" id="q1" name="q1" type="text" placeholder="您的名字" required/>--> </li> <li> <label class="fs-field-label fs-anim-upper" for="q2" data-info="We won't send you spam, we promise...">投訴詳情:</label> <input type="hidden" name="uid" value="${owneruid }"> <input class="fs-anim-lower" id="q2" name="content" type="text" placeholder="投訴詳情" required/> </li> </ol> <!-- /fs-fields --> <button class="fs-submit" type="submit">提交投訴</button> </form> <!-- /fs-form --> </div> <!-- /fs-form-wrap --> </div> <!-- /container --> <script src="static/js/classie.js"></script> <script src="static/js/selectFx.js"></script> <script src="static/js/fullscreenForm.js"></script> <script> (function() { var formWrap = document.getElementById('fs-form-wrap'); [].slice.call(document.querySelectorAll('select.cs-select')).forEach(function(el) { new SelectFx(el, { stickyPlaceholder: false, onChange: function(val) { document.querySelector('span.cs-placeholder').style.backgroundColor = val; } }); }); new FForm(formWrap, { onReview: function() { classie.add(document.body, 'overview'); // for demo purposes only } }); })(); </script> </body> </html>
以上就是Java 實(shí)戰(zhàn)項(xiàng)目錘煉之小區(qū)物業(yè)管理系統(tǒng)的實(shí)現(xiàn)流程的詳細(xì)內(nèi)容,更多關(guān)于Java 小區(qū)物業(yè)管理系統(tǒng)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Java使用DateTimeFormatter實(shí)現(xiàn)格式化時(shí)間
這篇文章主要介紹了Java使用DateTimeFormatter實(shí)現(xiàn)格式化時(shí)間,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01MyBatis入門學(xué)習(xí)教程(一)-MyBatis快速入門
MyBatis是一個(gè)支持普通SQL查詢,存儲(chǔ)過(guò)程和高級(jí)映射的優(yōu)秀持久層框架,這篇文章主要給大家分享MyBatis入門學(xué)習(xí)教程(一)-MyBatis快速入門,需要的朋友可以參考下2015-08-08Maven項(xiàng)目無(wú)法加載jdbc.properties的問(wèn)題解決
本文主要介紹了Maven項(xiàng)目無(wú)法加載jdbc.properties的問(wèn)題解決,文章首先分析了問(wèn)題的原因,然后提供了解決方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08Java實(shí)戰(zhàn)之網(wǎng)上書(shū)店管理系統(tǒng)的實(shí)現(xiàn)
本文將利用Java語(yǔ)言實(shí)現(xiàn)網(wǎng)上書(shū)店管理系統(tǒng)。其功能一般包括:圖書(shū)信息管理、用戶信息管理、圖書(shū)購(gòu)買、圖書(shū)訂單查看、圖書(shū)添加、圖書(shū)維護(hù)等等,感興趣的可以了解一下2022-06-06JavaWeb Spring開(kāi)發(fā)入門深入學(xué)習(xí)
這篇文章主要為大家詳細(xì)介紹了JavaWeb Spring開(kāi)發(fā)入門學(xué)習(xí)教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09SpringBoot項(xiàng)目從搭建到發(fā)布一條龍
這篇文章主要介紹了SpringBoot項(xiàng)目從搭建到發(fā)布一條龍,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-02帶你了解mybatis如何實(shí)現(xiàn)讀寫(xiě)分離
本篇文章主要介紹了MyBatis實(shí)現(xiàn)數(shù)據(jù)讀寫(xiě)分離的實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能給你帶來(lái)幫助2021-08-08使用Spring源碼報(bào)錯(cuò)java:找不到類 InstrumentationSavingAgent的問(wèn)題
這篇文章主要介紹了使用Spring源碼報(bào)錯(cuò)java:找不到類 InstrumentationSavingAgent的問(wèn)題,本文給大家分享解決方法,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10