基于SSM的公交车信息管理系统的设计与实现

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:Vue
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


目录

一、项目简介

二、系统功能

三、系统项目截图

个人中心

管理员管理

司机管理

用户管理

位置信息管理

基础数据管理

车辆信息管理

公交线路管理

公告信息管理

排班信息管理

四、核心代码

登录相关

文件上传

封装


一、项目简介

当下,正处于信息化的时代,许多行业顺应时代的变化,结合使用计算机技术向数字化、信息化建设迈进。以前相关行业对于公交车信息的管理和控制,采用人工登记的方式保存相关数据,这种以人力为主的管理模式已然落后。本人结合使用主流的程序开发技术,设计了一款基于SSM的公交车信息管理系统,可以较大地减少人力、财力的损耗,方便相关人员及时更新和保存信息。本系统主要以B/S模式进行实现,在idea集成平台上,运用Java语言编写相关代码,设计相关的系统功能模块,MySQL数据库存放数据资源,管理和控制相关的系统信息,SSM框架设计和开发系统功能架构,最后通过使用Tomcat服务器,在浏览器中发布设计的系统,并且完成系统与数据库的交互工作。本文对系统进行实现的可行性分析,设计的功能及数据库规划,以及设计的主要功能模块测试等内容做了较为详细的介绍,并且在本文中也展示了系统主要的功能模块设计界面和操作界面,并对其做出了必要的解释说明,方便用户对系统进行操作和使用,以及后期的相关人员对系统进行更新和维护。本系统的实现可以极大地提高相关行业的工作效率,提升用户的使用体验,因此在现实生活中运用本系统具有很大的使用价值。


二、系统功能

系统的总体功能设计,是需求分析的下个阶段,是系统实现的上个阶段,它是系统详细功能设计的一个大方向,也就是说系统的各类子功能模块的设计,都是以总体功能设计为目标而进行的。通过对系统进行需求分析可知,可以大致了解系统具体所需要的相关的主要功能模块。本系统主要的功能需求包括车辆信息管理、公交线路管理等模块。

 



三、系统项目截图

个人中心

通过设计的个人中心功能模块,用户可以选择修改账号密码,查看个人资料信息,通过不定期的对个人账户密码进行更新,保障个人信息安全

 

管理员管理

通过设计的管理员管理功能模块,管理用户可以管理相关的管理员用户信息资料,比如进行查看管理员的用户名信息,更新管理员的密码信息,删除已经注销的管理员用户信息记录等操作 

 

司机管理

通过设计的司机管理功能模块,管理用户可以管理相关的司机用户信息资料,比如进行查看司机用户的详细资料,修改司机的手机号码,删除已经注销的司机用户信息记录等操作

 

用户管理

通过设计的用户管理功能模块,管理用户可以管理相关的用户信息资料,比如进行查看用户的详细资料,修改用户的电子邮箱,删除已经注销的用户信息记录等操作

 

位置信息管理

通过设计的位置信息管理功能模块,管理用户可以管理相关的公交车位置信息记录,比如进行查看位置信息的详细内容,修改车辆的大致位置,删除已经失效的位置信息记录等操作

 

基础数据管理

通过设计的基础数据管理功能模块,管理用户可以管理相关的车辆类型、线路类型、公告类型信息记录,比如进行查看车辆类型、线路类型、公告类型信息的详细内容,修改车辆类型、线路类型、公告类型的名称信息,删除失效的车辆类型、线路类型、公告类型信息记录等操作

 

 

车辆信息管理

通过设计的车辆信息管理功能模块,管理用户可以管理相关的车辆信息记录,比如进行查看车辆信息的详细内容,修改车辆类型信息,删除失效的车辆信息记录等操作

 

公交线路管理

通过设计的公交线路管理功能模块,管理用户可以管理相关的公交线路信息资料,比如进行查看公交线路信息的详细内容,修改公交线路名称信息,删除已经失效的公交线路信息记录等操作

 

公告信息管理

通过设计的公告信息管理功能模块,用户可以管理相关的公告信息记录,比如进行查看公告信息的详细内容,修改公告图片信息,删除失效的公告信息记录等操作

 

排班信息管理

通过设计的排班信息管理功能模块,用户可以管理相关的排班信息记录,比如进行查看排班信息的详细内容,修改排班开始时间和结束时间信息,删除失效的排班信息记录等操作

 


四、核心代码

登录相关


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

文件上传

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

封装

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

  • 22
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数据库公交车管理系统课程设计 课程设计 课题题目: 公交车管理系统 学 部: 理工学部 专 业: 班 级: 学 号: 姓 名: 指导老师: 例如: 1. 数据库设计(全局E-R图及各表) 例如: Bus(车辆信息表): "主码 "列名 "数据类型 "宽度 "小数位 "空否 "取值范围 "备 注 " "Pk "Cid "char "5 " "N " "公交车编号 " "外码 "id "char "5 " "N " "司机编号 " " "Nid "Char "10 " "N " "路线编号 " " "leixing "Char "5 " "N " "车辆类型 " " "nian "Int "5 " "N " "使用年限 " " "time "Datetime "1 " "N " "购买时间 " siji表: "主码 "列名 "数据类型 "宽度 "小数位 "空否 "取值范围 "备 注 " "Pk "id "char "5 " "N " "司机编号 " " "mingzi "char "5 " "N " "司机名字 " " "xingbie "Char "10 " "N " "司机性别 " " "age "Char "5 " "N " "年龄 " " "Age2 "Int "5 " "N " "驾龄 " (注意各表有无联系) 2. 系统实现(各页面及描述) 建立siji表: 建立bus表: 增加: 修改: 删除: 单表查询: 多表查询: 嵌套查询: 3. 小结(心得体会) 通过这次课程设计,我学到了如何运用SQL2008实现各种增加删除和修改功能,丰富自己 的知识并且提高对SQL等软件的实际操作能力。使我们对已经学习过的数据库课程的进一 步的掌握,对知识进行最大程度的消化融汇。因此这次的课程设计对我们来说具有非常 重要的作用:为以后学生工作做必要的准备和实践,提高自身对数据库开发的能力。 此次设计公交车管理系统,虽然简单,但是却十分实用,极大的方便了用户对公交车 信息和线路的操作,节省了大量的工作量。对以后开发各种数据库积累了宝贵的经验。 4. 开发工具和参考文献 操作系统:Window7 软件配置:Microsoft SQL Server 2008 数据库配置:Microsoft SQL Server 2008 在PC机中新建数据库,建立各个数据表 、关系图 数据库系统概论(第五版)作者:王珊 5. 源程序清单 建表 建立bus 表: CREATE table bus (cid char(10)not null primary key, id char(10)not null, Nid char(10)not null, leixing char(10)not null, nian char(10)not null, time DATETIME not null primary key cid foreign key (id) references siji(id) ); 建立siji表: CREATE table siji (id char(10)not null primary key, mingzi char(10)not null, xingbie char(2)not null, age int not null, age2 char(5)not null, constraint C1 check(age>=25 and age2>=5), tel char(12) not null) 增加数据到bus表中 insert into bus(cid,id,nid,leixing,nian,time) values('1','1','1','单层公车,'8','2016 06 01'); insert into bus(cid,id,nid,leixing,nian,time) values('2','2,'2','单层公车,'5','2016 06 01'); insert into bus(cid,id,nid,leixing,nian,time) values('3','3','3','双层公车,'8','2016 06 01'); 删除数据: delete from bus where id='1'; 修改数据: update bus set nian=10 where id='1'; 单表查询: select cid,id,nid,leixing,nian,time from bus where id=1; 多表查询: select cid,xingbie from bus,siji where bus.id=siji.id and age='30'; 嵌套查询: select Nid from bus where

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值