Spring中的aware接口详情
305
2022-09-15
Java 实战项目锤炼之小区物业管理系统的实现流程
一、项目简述
功能包括: 分为管理员及普通业主角色,业主信息,社区房屋,维护 管理,社区车辆,社区投诉,社区缴费,社区业务信息维 护等等功能。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: jsP +Spring + SpringMVC + MyBatis + html+ css + javascript + jquery + Ajax + maven等等。
小区物业管理系统验证码代码:
/**
*
* Description: 验证码生成器
*/
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
Map
if (width <= 0)
width = 60;
if (height <= 0)
height = 20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
// 获取图形上下文
Graphics g = image.getGraphics();
// 生成随机类
Random random = new Random();
// 设定背景色
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, width, height);
// 设定字体
g.setFont(new Font("Times New Roman", Font.PLAIN, 18));
// 随机产生168条干扰线,使图象中的认证码不易被其它程序探测到
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);
}
// 取随机产生的码
String strEnsure = "";
// 4代表4位验证码,如果要生成更多位的认证码,则加大数值
for (int i = 0; i < 4; ++i) {
strEnsure += mapTable[(int) (mapTable.length * Math.random())];
// 将认证码显示到图象中
g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
// 直接生成
String str = strEnsure.substring(i, i + 1);
// 设置随便码在背景图图片上的位置
g.drawString(str, 13 * i + 20, 25);
}
// 释放图形上下文
g.dispose();
returnMap.put("image", image);
returnMap.put("strEnsure", strEnsure);
return returnMap;
}
// 给定范围获得随机颜色
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);
}
}
小区物业管理系统业主投诉代码:
@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
model.addAttribute("complainlist", list);
return "complain";
}
/**
* 业主跳转添加投诉页面
*/
@RequestMapping("/addcomplaint")
public String addcomplaint() {
return "addonecomplain";
}
/**
* 添加投诉到数据库
*/
@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
model.addAttribute("complainlist", list);
return "complain";
}
/**
* 查询投诉信息
*/
@RequestMapping("/mycomplaint")
public String mycomplaint(Model model,HttpSession session) {
System.out.println("mycomplaint:"+(int)session.getAttribute("owneruid"));
List
model.addAttribute("mycomplaintlist", list);
return "mycomplaint";
}
@RequestMapping("/test")
public String test1() {
return "test";
}
}
未缴费账单控制器代码:
/**
* @category 未缴费账单控制器
*
*/
@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 跳转至业主未缴费展示页面
* @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
model.addAttribute("list", list);
model.addAttribute("start", start);
model.addAttribute("stop", stop);
model.addAttribute("inputname", "请输入姓名");
return "unpay";
}
/**
* @category 通过给定时间范围展示和业主模糊姓名联合查询缴费信息
* @param model
* @param request
* @return
* @throws ParseException
*/
@RequestMapping("/unpaytime")
public String unpayByTime(Model model, HttpServletRequest request, HttpSession session) throws ParseException {
// 获取分页参数设置每页展示的个数
int pageSize = (int) session.getAttribute("pageSize");
// 获取分页参数设置传进来的页码是多少
int pageNum = (int) session.getAttribute("pageNum");
// 将字符串转换为日期对象
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);
// 账单的时间用于和stop和start比较
Date billdate;
// 开始时间戳
long startTime = start.getTime();
// 结束时间戳
long stopTime = stop.getTime();
long billtime;
// 用该list给owner对象的billlist设值
List
// 查找所有
List
List
// 生成要返回的list
for (int i = 0; i < list1.size(); i++) {
double total = 0;
// 循环遍历得到的所有owner对象
for (int j = 0; j < list1.get(i).getBill().size(); j++) {
//获得owner单个订单的时间戳
billdate = cx.parse(list1.get(i).getBill().get(j).getBilltime());
billtime = billdate.getTime();
//判断订单的时间戳是否在指定的范围内,并且该owner的姓名要包含指定的字符串
try {
if (billtime >= startTime && billtime <= stopTime && list1.get(i).getOname().contains(name)) {
// 如果满足上述条件,则将该条订单信息添加到billlist中
billlist.add(list1.get(i).getBill().get(j));
// 计算总价
total += list1.get(i).getBill().get(j).getBillitem().getBillitemmoney();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 如果该业主有未缴纳的账单,给该业主对象设置未缴纳账单,并将该对象放入要传给前端的list中
if (billlist.size() > 0) {
list1.get(i).setTotal(total);
list1.get(i).setBill(billlist);
list.add(list1.get(i));
}
// 这里不能使用clear() 用list.clear()方法清空list;用此方法,其它引用该list的值也会变成空。
billlist = new ArrayList<>();
}
if (list.size() < 1) {
model.addAttribute("nolist", "没有查到相关信息呦,请您重新输入查询条件");
}
// 计算查询总数
double listnum = list.size();
int totalnum = (int) Math.ceil(listnum / pageSize);
List
// 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 收费项目管理界面
* @param model
* @return
*/
@RequestMapping("/sfmanage")
public String shoufeiguanli(Model model) {
BillitemsExample example = new BillitemsExample();
List
model.addAttribute("list", list);
return "sfmanage";
}
/**
* @category 添加新的收费项目
* @param model
* @param billitem
* @return
*/
@RequestMapping("/addbillitem")
public String addbillitem(Model model, Billitems billitem) {
// 判断添加的收费项目是否为一次性收费
if (billitem.getBillitemtype().equals("一次性")) {
Date d = new Date();
// 生成一次性收费的时间
// SimpleDateFormat itemtime = new SimpleDateFormat("yyyy-MM-dd");
String time = cx.format(d);
billitem.setBillitemtime(time);
// 添加到数据库
bitemService.insert(billitem);
// 从数据库查刚刚添加的收费项目
Billitems item = bitemService.selectByNameAndTime(billitem.getBillitemname(), time);
// 给所有的业主添加这个费用收费
List
int[] all = new int[olist.size()];
// 给数组all赋值业主的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 搜索后展示缴费
* @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
List
// System.out.println(list1.size());
List
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
System.out.println("进来了");
List
List
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
if (session.getAttribute("findList") != null) {
list1 = (List
} else {
list1 = billService.findByOwner();
}
double listnum = list1.size();
int totalnum = (int) Math.ceil(listnum / pageSize);
List
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 通过传入参数展示相应的房屋信息
* @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
List
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 跳转到更新房屋信息页面
* @param model
* @param homeid
* @return
*/
@RequestMapping("/updatehouse")
public String updatehouse(Model model,@RequestParam ("homeid") int homeid) {
Housenumber house=hService.selectByPrimaryKey(homeid);
model.adhttp://dAttribute("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";
}
}
工作提出意见或建议页面:
<%@ 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"%>
JbfJt
(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
}
});
})();
以上就是Java 实战项目锤炼之小区物业管理系统的实现流程的详细内容,更多关于Java 小区物业管理系统的资料请关注我们其它相关文章!
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~