目录
1 最终效果
1.1整体效果
1.2 维修保养统计echarts图表
2 项目说明
车辆综合管理系统包含如下功能:车辆管理、驾驶员信息管理、车辆使用油耗信息管理、车辆年检信息管理、车辆维修保养记录管理、以及维修保养次数的百度echarts统计折线图显示
本项目使用JavaBean Servlet MVC开发,相同功能的SSM Spring+SpringMVC+MyBatis开发的在其他课程中展示.
本项目使用mysql数据库,也可以移植到 SQL server中使用
3 代码结构
4 数据库实体描述
车辆分类信息:名称、介绍、选项
车辆信息:类型、品牌、型号、车架号、颜色、排量、选项
驾驶员信息:姓名、性别、联系电话、住址、驾驶证号
维护保养信息:车辆、时间、内容、费用
年检信息:车牌号、年检时间、到期时间、费用、经办人
油耗信息:车牌号、公里数、加油量、费用、时间
表1t_admin 管理员表
字段名称 | 字段类型 | 说明 |
userId | int | 编号 |
userName | varchar | 用户名 |
userPw | varchar | 密码 |
role | varchar | 角色 |
表2 car车辆表
字段名称 | 字段类型 | 说明 |
id | int | - |
ph | varchar | 牌号 |
xh | varchar | 名称 |
cj | varchar | 厂家 |
sj | varchar | 日期 |
jg | varchar | 价格 |
zt | varchar | 状态 |
url | varchar | 图片 |
bz | varchar | 备注 |
flag | varchar | 状态 |
表3 t_jiashiyuan 驾驶员管理
字段名称 | 字段类型 | 说明 |
id | int | 编号 |
name | varchar | 名称 |
sex | varchar | 性别 |
age | varchar | 年龄 |
tel | varchar | 电话 |
address | varchar | 地址 |
表4 t_catelog 车型分类
字段名称 | 字段类型 | 说明 |
id | int | 编号 |
name | varchar | 名称 |
jieshao | varchar | 介绍 |
del | varchar | 是否删除 |
5 统计代码实现
5.1 后端JAVA代码
package com.action;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.orm.Total;
import com.service.liuService;
public class total_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("totalMana"))
{
totalMana(req, res);
}
}
public void totalMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List totalList =new ArrayList();
List<Integer> cheliang_id_list=liuService.getAllCheliang_id();
for(int i=0;i<cheliang_id_list.size();i++)
{
int cheliang_id=cheliang_id_list.get(i);
//int totalShuliang=liuService.getCheliangGuzhangShuliang(cheliang_id);
Total total=new Total();
total.setCheliang_id(cheliang_id);
//total.setTotal(totalShuliang);
total.setCheliang_name(liuService.getCheliangName(cheliang_id));
totalList.add(total);
}
req.setAttribute("totalList", totalList);
req.getRequestDispatcher("admin/total/totalMana.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
5.2 前端JSP代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<jsp:useBean id="loginService" scope="page" class="com.service.loginService"></jsp:useBean>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="<%=path %>/css/base.css" />
<script language=javascript src='<%=path %>/js/popcalendar.js'></script>
<script src="<%=path %>/js/echarts.common.min.js" type="text/javascript"></script>
<script language="javascript">
</script>
</head>
<body leftmargin="2" topmargin="9" background='<%=path %>/images/allbg.gif'>
<div>
<form action="<%=path %>/weihubaoyang?type=tongji" name="formAdd" method="post">
开始时间:
<input name="kaishi" readonly="readonly" id="kaishi" type="text" onClick="popUpCalendar(this, kaishi, 'yyyy-mm-dd'); return false;"/>
结束时间:
<input name="jieshu" readonly="readonly" id="jieshu" type="text" onClick="popUpCalendar(this, jieshu, 'yyyy-mm-dd'); return false;"/>
<input type="submit" value="统计"/>
</form>
</div>
<%
String weihutianshu = (String)request.getAttribute("weihutianshu");
String weihushuju = (String)request.getAttribute("weihushuju");
String baoyangtianshu = (String)request.getAttribute("baoyangtianshu");
String baoyangshuju = (String)request.getAttribute("baoyangshuju");
%>
<div id="weihu" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('weihu'));
// 指定图表的配置项和数据
var option = {
title: {
text: '每日车辆维护'
},
tooltip: {},
legend: {
data:['维护']
},
xAxis: {
data: [<%=weihutianshu%>],
axisLabel:{
rotate:45, //刻度旋转45度角
textStyle:{
color:"red",
fontSize:12
}
}
},
yAxis: {},
series: [{
name: '车辆',
type: 'line',
data: [<%=weihushuju%>]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
<div id="baoyang" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('baoyang'));
// 指定图表的配置项和数据
var option = {
title: {
text: '每日车辆保养'
},
tooltip: {},
legend: {
data:['保养']
},
xAxis: {
data: [<%=baoyangtianshu%>],
axisLabel:{
rotate:45, //刻度旋转45度角
textStyle:{
color:"red",
fontSize:12
}
}
},
yAxis: {},
series: [{
name: '车辆',
type: 'line',
data: [<%=baoyangshuju%>]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
</html>