自助停车管理系统

Posted 池鱼i_

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自助停车管理系统相关的知识,希望对你有一定的参考价值。

 

一、 语言和环境

 

  1. 实现语言JAVA
  2. 环境要求

MyEclipse/S2SH+mysql/SqlServer/Oracle

 

二、 功能要求

 

开发一套智能停车系统,为方便进行操作管理,提供以下需求,该项目主要需要实现:

1、打开首页界面,自动跳转进入首页,如下页面(图-1)。

 

图-3-2

  1. 点击“结束停车”超链接时,“结束停车”超链接隐藏,后台计算停车时长和停车费用,跳转到停车列表页面,如下图(图-3-3)

 

                          图-3-3

   

三、 数据库设计

 

其数据库表参见如下:

 

 

表名

tbl_parking

中文表名称

停车表

序号

字段名称

字段说明

类型

备注

1

pId

停车编号

int

主键

2

carNo

汽车牌号

varchar

 

3

pMark

备注

Varchar

 

 

表名

tbl_parking_detail

中文表名称

停车详情表

序号

字段名称

字段说明

类型

备注

1

pdId

停车详情编号

int

主键

2

pId

停车单编号

int

停车表外键

3

beginDate

停车开始时间

datetime

 

4

endDate

停车结束时间

datetime

 

5

pDur

停车时长

int

 

6

pCost

停车费用

float

1小时5元,不足1小时按1小时计算

 

四、 具体要求及推荐实现步骤

 

  1. 建立数据库mydb和各数据表。注意各个字段要求。每张表中至少添加3条测试用数据。
  2. 创建selfPark应用程序。
  3. 设计首页及自动跳转配置。

 

  1. 设计停车新增,全查页面。

 

  1. 设计停车计时,计费功能。

 

  1. 完成项目,打包源程序,并提交。

 

五、 注意事项

 

  1. 请注意界面美观,控件摆放整齐。

 

  1. 请注意代码的书写、命名符合规范,在代码中添加必要的注释。

 

  1. 请注意操作数据库时进行必要的异常处理。

 

数据库的创建

/*
Navicat MySQL Data Transfer

Source Server         : localhost_3306
Source Server Version : 50731
Source Host           : localhost:3306
Source Database       : gjb

Target Server Type    : MYSQL
Target Server Version : 50731
File Encoding         : 65001

Date: 2021-06-18 09:51:34
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for tbl_parking
-- ----------------------------
DROP TABLE IF EXISTS `tbl_parking`;
CREATE TABLE `tbl_parking` (
  `pId` int(11) NOT NULL AUTO_INCREMENT,
  `carNo` varchar(50) DEFAULT NULL,
  `pMark` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`pId`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of tbl_parking
-- ----------------------------
INSERT INTO `tbl_parking` VALUES ('1', '浙A66666', '123456');
INSERT INTO `tbl_parking` VALUES ('2', '京A11111', '123456');
INSERT INTO `tbl_parking` VALUES ('3', '豫L99999', '123456');
INSERT INTO `tbl_parking` VALUES ('4', 'fdsdf', 'sdfww');
INSERT INTO `tbl_parking` VALUES ('5', '买东i下', '浙A·99999');

-- ----------------------------
-- Table structure for tbl_parking_detail
-- ----------------------------
DROP TABLE IF EXISTS `tbl_parking_detail`;
CREATE TABLE `tbl_parking_detail` (
  `pdId` int(11) NOT NULL AUTO_INCREMENT,
  `pId` int(11) DEFAULT NULL,
  `beginDate` datetime NOT NULL,
  `endDate` datetime DEFAULT NULL,
  `pDur` int(11) DEFAULT NULL,
  `pCost` float DEFAULT NULL,
  PRIMARY KEY (`pdId`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of tbl_parking_detail
-- ----------------------------
INSERT INTO `tbl_parking_detail` VALUES ('1', '1', '2019-05-15 17:06:30', '2019-05-15 18:06:30', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('2', '4', '2019-05-15 17:06:30', '2019-05-15 18:06:30', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('3', '2', '2019-05-15 17:06:30', '2019-05-15 19:06:30', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('4', '3', '2019-05-15 17:06:30', '2019-05-15 20:06:30', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('5', '5', '2021-05-20 16:40:19', '2021-05-20 16:42:43', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('6', '5', '2021-05-20 16:42:41', '2021-05-20 16:42:43', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('7', '5', '2021-05-20 16:42:41', '2021-05-20 16:42:43', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('8', '5', '2021-05-20 16:42:41', '2021-05-20 16:42:43', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('9', '5', '2021-05-20 16:42:41', '2021-05-20 16:42:43', '1', '5');
INSERT INTO `tbl_parking_detail` VALUES ('10', '5', '2021-05-20 16:42:42', '2021-05-20 16:42:43', '1', '5');

spring配置文件

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    https://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    https://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop
    https://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx
    https://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/mvc
    https://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <context:component-scan base-package="cn.hp"></context:component-scan>

    <mvc:annotation-driven></mvc:annotation-driven>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="viewResolver">
        <property name="prefix" value="/WEB-INF/pages/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
        <!-- 需要修改此处的 xxx为 当前项目的数据库名称 -->
        <property name="url" value="jdbc:mysql://localhost:3306/gjb?characterEncoding=utf8"></property>
        <property name="username" value="root"></property>
        <property name="password" value="123456"></property>
    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="cn.hp.dao"></property>
    </bean>


    <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
        <property name="dataSource" ref="dataSource"></property>
        <property name="configLocation" value="classpath:mybatis_config.xml"></property>
    </bean>
</beans>

mybatis.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

</configuration>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

    <servlet>
        <servlet-name>springMVC</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring_config.xml</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>springMVC</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.js</url-pattern>
        <url-pattern>*.css</url-pattern>
    </servlet-mapping>

</web-app>

controller包下

controller类

package cn.hp.controller;

import cn.hp.model.TblParking;
import cn.hp.model.TblParkingDetail;
import cn.hp.service.GjbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class GjbController 
    @Autowired
    private GjbService gjbService;

    @RequestMapping("/showAll")
    public  String showAll(HttpServletRequest request)
        List list= gjbService.showAll();
        request.setAttribute("list",list);
        return "showAll";
    
    @RequestMapping("/add")
    public  String add(TblParking tblParking)
     boolean  addFlag=  gjbService.add(tblParking);
     if(addFlag)
         return "redirect:showAll";
     else
         return "forward:add.jsp";
     
    


dao包下

mapper实现类、

package cn.hp.dao;

import cn.hp.model.TblParking;
import cn.hp.model.TblParkingDetail;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface GjbMapper 


    List showAll();
    int add(TblParking tblParking);



mapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="cn.hp.dao.GjbMapper">
    <resultMap id="map1" type="cn.hp.model.TblParkingDetail">
        <id column="pdId" property="pdId"></id>
        <result column="pId" property="pId"></result>
        <result column="beginDate" property="beginDate"></result>
        <result column="endDate" property="endDate"></result>
        <result column="pDur" property="pDur"></result>
        <result column="pCost" property="pCost"></result>
        <association property="tblParking" javaType="cn.hp.model.TblParking">
            <id column="pId" property="pId"></id>
            <result column="carNo" property="carNo"></result>
            <result column="pMark" property="pMark"></result>
        </association>
    </resultMap>


    <select id="showAll" resultMap="map1">
        select * from  tbl_parking  left  join  tbl_parking_detail  on  tbl_parking.pId=tbl_parking_detail.pId
    </select>
        <insert id="add" parameterType="cn.hp.model.TblParking">
        insert into tbl_parking  values (null,#carNo,#pMark);

    </insert>


</mapper>

model包

TblParking

package cn.hp.model;

public class TblParking 
    private  int pId;
    private  String carNo;
    private  String pMark;

    public int getpId() 
        return pId;
    

    public void setpId(int pId) 
        this.pId = pId;
    

    public String getCarNo() 
        return carNo;
    

    public void setCarNo(String carNo) 
        this.carNo = carNo;
    

    public String getpMark() 
        return pMark;
    

    public void setpMark(String pMark) 
        this.pMark = pMark;
    

    @Override
    public String toString() 
        return "TblParking" +
                "pId=" + pId +
                ", carNo='" + carNo + '\\'' +
                ", pMark='" + pMark + '\\'' +
                '';
    

 

 

TblParkingDetail

package cn.hp.model;

public class TblParkingDetail 
    private int pdId;
    private  int pId;
    private String beginDate;
    private String endDate;
    private  int pDur;
    private float pCost;

    private  TblParking tblParking;

    @Override
    public String toString() 
        return "TblParkingDetail" +
                "pdId=" + pdId +
                ", pId=" + pId +
                ", beginDate='" + beginDate + '\\'' +
                ", endDate='" + endDate + '\\'' +
                ", pDur=" + pDur +
                ", pCost=" + pCost +
                ", tblParking=" + tblParking +
                '';
    

    public TblParking getTblParking() 
        return tblParking;
    

    public void setTblParking(TblParking tblParking) 
        this.tblParking = tblParking;
    

    public int getPdId() 
        return pdId;
    

    public void setPdId(int pdId) 
        this.pdId = pdId;
    

    public int getpId() 
        return pId;
    

    public void setpId(int pId) 
        this.pId = pId;
    

    public String getBeginDate() 
        return beginDate;
    

    public void setBeginDate(String beginDate) 
        this.beginDate = beginDate;
    

    public String getEndDate() 
        return endDate;
    

    public void setEndDate(String endDate) 
        this.endDate = endDate;
    

    public int getpDur() 
        return pDur;
    

    public void setpDur(int pDur) 
        this.pDur = pDur;
    

    public float getpCost() 
        return pCost;
    

    public void setpCost(float pCost) 
        this.pCost = pCost;
    

service包

service

package cn.hp.service;

import cn.hp.dao.GjbMapper;
import cn.hp.model.TblParking;
import cn.hp.model.TblParkingDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GjbService 

    @Autowired
    private GjbMapper gjbMapper;

    public List showAll() 
        return  gjbMapper.showAll();
    
    public boolean add(TblParking tblParking) 
        int i = gjbMapper.add(tblParking);
        if(i>0)
            return true;
        
        return false;
    


index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>停车计费</title>
  </head>
  <body>
<a href="add.jsp">停车</a><br/>
  <a href="showAll">停车列表</a>
  </body>
</html>

add.jsp

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1>新增停车</h1>
<form action="add">
    汽车牌号:<input type="text" name="carNo"><br/>
    <h5 style="color: red">1小时5元,不足一小时按一小时计算</h5>
    备注信息:<textarea name="pMark" placeholder="可在此输入备注信息,200字以内" cols="9" rows="6"></textarea><br/>
    <input type="submit" value="确认添加">
</form>
</body>
</html>

WEB -INF下pages    show.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>停车列表</title>
</head>
<body>
<h5 align="center">停车列表</h5>

<table border="1px" align="center" cellspacing="0px">
    <tr style="text-align: center">
        <th>停车序号</th>
        <th>汽车牌号</th>
        <th>停车开始时间</th>
        <th>停车结束时间</th>
        <th>停车时长(小时)</th>
        <th>停车费用(元)</th>
        <th>备注信息</th>
        <th>操作内容</th>
    </tr>
    <c:forEach items="$list" var="tblparkingdatail">
        <tr style="text-align: center">
            <td>$tblparkingdatail.pdId</td>
            <td>$tblparkingdatail.tblParking.carNo</td>
            <td>$tblparkingdatail.beginDate</td>
            <td>$tblparkingdatail.endDate</td>
            <td>$tblparkingdatail.pDur</td>
            <td>$tblparkingdatail.pCost</td>
            <td>$tblparkingdatail.tblParking.pMark</td>
            <td>
                <a href="beginDate?pId=$tblparkingdatail.pdId">开始停车</a>
                <a href="endTime?pId=$tblparkingdatail.pdId">结束停车</a>
            </td>


        </tr>


    </c:forEach>



    <tr>
        <td align="center" colspan="8">
            <a href="add.jsp">新增停车</a>
        </td>
    </tr>


</table>


</body>
</html>

 

以上是关于自助停车管理系统的主要内容,如果未能解决你的问题,请参考以下文章

推荐一个完善的停车管理系统(停车收费物业管理物联网自助缴费)含源码

2022停车场自助停取车微信小程序的设计与实现.rar(毕业论文+项目源码)

智慧停车场-车牌识别自动计费系统

车牌识别基于matlab模拟停车位管理系统

车牌识别一体机在停车场的应用场景

装备资讯 | 首个城市级基于大倾角视频识别的路内停车系统落地