源码获取:俺的博客首页 "资源" 里下载! 

项目介绍

基于Springboot+vue实现的校车调度管理系统

本系统包含管理员、驾驶员两个个角色。

管理员角色:驾驶员信息管理、车辆信息管理、借调车辆管理、工作管理、车辆运营管理、报销申请审核。

驾驶员角色:个人信息查看、工作查看、借调车辆申请、车辆使用申请、报销申请提交。


环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
4.数据库:MySql 5.7/8.0版本均可;
5.是否Maven项目:是;


技术栈

后端:SpringBoot+Mybaits
前端:Vue+elementui


使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入地址:
后台登录页面
http://localhost:8080/springbootr4le2/admin/dist/index.html#/login
管理员账户:admin 密码:admin
驾驶员账户:驾驶员工号1 密码:123456

注意项目文件路径中不能含有中文、空格、特殊字符等,否则图片会上传不成功。

文档结构文档:

借调车辆:

工作管理:

车辆管理:

修改个人信息:

报销申请展示:

登录页面:

驾驶员展示页面:

用户信息管理控制层:

@Controller
@RequestMapping("/user")
public class UserController extends BaseController {
	
	@Resource
	private UserService userService;
	
	@RequestMapping("/list")
	public String login(HttpServletRequest request,HttpSession session,User user){
		return "user/user_list";
	}
	/**
	 * 跳转至注册页面
	 * @return
	 */
	@RequestMapping("/toPage")
	public String toPage(){
		return "user/signUp";
	}

	/**
	 * 用户注册 uLevel默认为0 用户模式
	 * @param user
	 * @return 提示信息
	 */
	@RequestMapping("/signUp")
	@ResponseBody
	public int signUp(User user){
		int signUp =0;
		if(user!=null){
			signUp= userService.insertSelective(user);
		}
		return  signUp>0?0:1;
	}
	/**
	 * 验证登陆 成功跳转至管理页面 失败返回登录
	 * @param user
	 * @param session
	 * @return
	 */
	@RequestMapping("/login")
	public String login(User user,HttpSession session,Model model){
		String uri="";
		List<User> checkUserLogin = userService.checkUserLogin(user);
			if (checkUserLogin!=null && checkUserLogin.size()>0) {
				User user2 = checkUserLogin.get(0);
				session.setAttribute("userOn",user2 );
				session.setAttribute("msg", null);
				uri="index";
			}else{
				session.setAttribute("msg", "用户名或者密码错误");
				uri="redirect:/";
			}
		return uri;
	}
	@RequestMapping("/out")
	public String out(HttpSession session){
		session.invalidate();
		return "redirect:/";
	}
	
	/**数据获取*/
	@RequestMapping("/getData")
	@ResponseBody
	public String getData(HttpServletResponse response,HttpServletRequest request,String userName){
		Integer offset = Integer.parseInt(request.getParameter("offset"));//开始条数
		Integer limit = Integer.parseInt(request.getParameter("limit"));//每页条数
		HashMap<String, Object> paramMap = new HashMap<String,Object>();
		paramMap.put("userName", userName);
	    List<User> users = userService.selectAll(paramMap);
	    return TableData.getJson2Table(users, offset, limit);
	}
	@RequestMapping("/edit")
	public String editWork(HttpServletRequest request,Model model){
		try {
			String id = request.getParameter("id");
			User user=new User();
			if(StringUtil.isNotEmpty(id)){
				user = userService.selectByPrimaryKey(Integer.parseInt(id));
			}
			model.addAttribute("user", user);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "user/user_edit";
	}
	@RequestMapping("/add")
	@ResponseBody
	public Integer addWorker(HttpServletRequest request,User user){
		int record=0;
		//设置用户等级 默认为0
		if(user.getuLevel()==null){
			user.setuLevel(0);
		}
		if( user.getuId()==null){
			/*设置id*/
			record= userService.insertSelective(user);
		}else{
			record= userService.updateByPrimaryKeySelective(user);
		}
		return record;
	}
	@RequestMapping("/delById")
	@ResponseBody
	public Integer deleteWorker(HttpServletRequest request){
		String ids = request.getParameter("id");
		if(StringUtil.isNotEmpty(ids)){
			String[] sIds = ids.split(",");
			for (String sId : sIds) {
				userService.deleteByPrimaryKey(Integer.parseInt(sId));
			}
			return 1;
		}else{
			return 0;
		}
	}
}

机床管理控制层:

@Controller
@RequestMapping("/station")
public class StationController extends BaseController {
	
	@Resource
	private StationService stationService;
	/**页面跳转*/
	@RequestMapping("/list")
	public String workList(HttpServletRequest request,HttpSession session,Worker worker){
		return "station/station_list";
	}
	/**数据获取*/
	@RequestMapping("/getData")
	@ResponseBody
	public String getData(HttpServletResponse response,HttpServletRequest request){
		Integer offset = Integer.parseInt(request.getParameter("offset"));//开始条数
		Integer limit = Integer.parseInt(request.getParameter("limit"));//每页条数
		List<SStation> wList = stationService.selectAll(null);
		return TableData.getJson2Table(wList, offset, limit);
	}
	/**编辑机床信息 */
	@RequestMapping("/edit")
	public String editWork(HttpServletRequest request,Model model){
		try {
			String id = request.getParameter("id");
			SStation station = new SStation();
			if(StringUtil.isNotEmpty(id)){
				station = stationService.selectByPrimaryKey(Integer.parseInt(id));
			}
			model.addAttribute("station", station);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "station/station_edit";
	}
	/**添加机床*/
	@RequestMapping("/add")
	@ResponseBody
	public Integer addWorker(HttpServletRequest request,SStation station){
		int record=0;
		station.setBegintime(new Date());
		//获取工作人员Id
		if(station.getsId()==null){
			record= stationService.insertSelective(station);
		}else{
			record= stationService.updateByPrimaryKeySelective(station);
		}
		return record;
	}
	/**删除机床*/
	@RequestMapping("/delById")
	@ResponseBody
	public Integer deleteWorker(HttpServletRequest request){
		String ids = request.getParameter("id");
		if(StringUtil.isNotEmpty(ids)){
			String[] sIds = ids.split(",");
			for (String sId : sIds) {
				stationService.deleteByPrimaryKey(Integer.parseInt(sId));
			}
			return 1;
		}else{
			return 0;
		}
	}
}

 员工管理控制层:

@Controller
@RequestMapping("/worker")
public class WorkerController extends BaseController {
	
	@Resource
	private WorkerService workerService;
	/**页面跳转*/
	@RequestMapping("/list")
	public String workList(HttpServletRequest request,HttpSession session,Worker worker){
		return "worker/worker_list";
	}
	/**数据获取*/
	@RequestMapping("/getData")
	@ResponseBody
	public String getData(HttpServletResponse response,HttpServletRequest request){
		Integer offset = Integer.parseInt(request.getParameter("offset"));//开始条数
		Integer limit = Integer.parseInt(request.getParameter("limit"));//每页条数
		Worker worker=new Worker();
		String workerName=request.getParameter("workerName");
		worker.setwName(workerName);
		List<Worker> wList = workerService.selectWorkersByAttr(worker);
		return TableData.getJson2Table(wList, offset, limit);
	}
	/**编辑员工信息 */
	@RequestMapping("/edit")
	public String addWork(HttpServletRequest request,Model model){
		try {
			String id = request.getParameter("id");
			Worker worker = null;
			if(StringUtil.isEmpty(id)){
				worker = new Worker();
			}else{
				worker = workerService.selectByPrimaryKey(id);
			}
			model.addAttribute("worker", worker);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "worker/worker_edit";
	}
	/**添加员工*/
	@RequestMapping("/add")
	@ResponseBody
	public Integer addWorker(HttpServletRequest request,Worker worker){
		int record;
		//获取工作人员Id
		if(StringUtil.isEmpty(worker.getwId())){
			worker.setwId(StringUtil.getStringId());
			record= workerService.insertSelective(worker);
		}else{
			record= workerService.updateByPrimaryKeySelective(worker);
		}
		return record;
	}
	/**删除员工*/
	@RequestMapping("/delById")
	@ResponseBody
	public Integer deleteWorker(HttpServletRequest request){
		String ids = request.getParameter("id");
		if(StringUtil.isNotEmpty(ids)){
			String[] wIds = ids.split(",");
			for (String wId : wIds) {
				workerService.deleteByPrimaryKey(wId);
			}
			return 1;
		}else{
			return 0;
		}
	}
	
	@RequestMapping("/getWorkData")
	@ResponseBody
	public List<Map<String,Object>> getWorkData(HttpServletRequest request,String month){
		Map<String,Object> param =new  HashMap<String, Object>();
		if (StringUtil.isEmpty(month)) {
			month=DateUtils.getYearMonths(1).get(0);
		}
		param.put("date", month);
		List<Map<String,Object>> selectWork = workerService.selectWork(param);
		request.setAttribute("selMonth", month);
		return selectWork;
	}
}

订单管理控制层:

@Controller
@RequestMapping("/order")
public class OrderController extends BaseController {

	private final Integer WARNING_COUNT=20;
	
	@Resource
	private CarService carService;

	@Resource
	private StationService stationService;

	@Resource
	private PartService partService;
	@Resource
	private OrderPartService orderPartService;
	
	@Resource
	private OrderWorkerService orderWorkerService;

	@Resource
	private WorkerService workerService;

	@Resource
	private OrderService orderService;

	/** 页面跳转 预定页面 */
	@RequestMapping("/toPreOrder")
	public String toPreOrder(HttpServletRequest request, HttpSession session,
			String carId) {
		return "order/preOrder";
	}

	/** 订单预定 */
	@RequestMapping("/preOrder")
	@ResponseBody
	public Integer preOrder(HttpServletRequest request, HttpSession session,
			String imgurls, String arriveTime, String desc) {
		// User user=(User)session.getAttribute("userOn");
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date arrDate = null;
		try {
			arrDate = format.parse(arriveTime);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		Car car = (Car) session.getAttribute("preCar");
		car.setCarState(1);
		int updateCar = carService.updateByPrimaryKeySelective(car);
		Order order = new Order();
		order.setOrderId(StringUtil.getStringId());
		order.setCarId(car.getCarId());
		order.setoDescribe(desc);
		// 0 预约中 1预约成功 2正在执行 3完成 4拒绝
		order.setoState("0");
		order.setArriveTime(arrDate);
		order.setOrdertime(new Date());
		order.setImgUrls(imgurls);
		int updateOrder = orderService.insertSelective(order);
		return updateOrder+updateCar;
	}

	/** 订单操作 */
	@RequestMapping("/manage")
	public String manageOrder(HttpServletRequest request, HttpSession session,String orderId) {
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("orderId", orderId);
		//通过id查出只能是一条数据
 		List<Map<String, Object>> order = orderService.selectOrderByAttr(paramMap);
 		String[] imgurls = order.get(0).get("imgUrls").toString().split(",");
 		//查询所有待使用的机床
 		List<SStation> stations=stationService.selectAll(new HashMap<String, Object>(){{put("s_state", "完好待使用");}});
 		//查询所有空闲的工人 state=1空闲 2在忙 0离职
 		List<Worker> workers = workerService.selectWorkersByAttr(new Worker(){{setwState(1);}});
 		//查询所有可使用零件
 		List<Part> parts = partService.selectAll();
 		request.setAttribute("imgurls",imgurls);
 		request.setAttribute("dealOrder",order.get(0));
 		request.setAttribute("stations",stations);
 		request.setAttribute("workers",workers);
 		request.setAttribute("parts",parts);
 		return "order/manageOrder";
	}
	
	/** 页面跳转 */
	@RequestMapping("/list")
	public String workList(HttpServletRequest request, HttpSession session,String state) {
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("state", state);
 		List<Map<String, Object>> order = orderService.selectOrderByAttr(paramMap);
 		session.setAttribute("order", order);
 		request.setAttribute("state", state);
		return "order/order_list";
	}

	/**  */
	@RequestMapping("/accept")
	@ResponseBody
	public String acceptOrder(HttpServletResponse response,HttpServletRequest request,String orderId,
			String remark,String stationId) {
		String success="1";
		//获取订单id 机床id 员工id集合 零件id num集合
		String selectedWorker=request.getParameter("selectedWorker");
		String[] workers = selectedWorker.split(",");
		String selParts=request.getParameter("parts");
		JSONArray parts=JSONArray.parseArray(selParts);
		//修改订单状态 修改机床状态 更新order-worker order-part表
		try {
				
				Order order = orderService.selectByPrimaryKey(orderId);
				order.setStationId(Integer.parseInt(stationId));
				order.setoState("1");//1进行中
				order.setRemark(remark);
				order.setBegintime(new Date());
				orderService.updateByPrimaryKeySelective(order);//更新order
				
				SStation station = stationService.selectByPrimaryKey(Integer.parseInt(stationId));
				station.setsState("完好在使用");
				stationService.updateByPrimaryKeySelective(station);
				for(int i=0;i<parts.size();i++){
					JSONObject jo = parts.getJSONObject(i);
					String pId = jo.get("id").toString();
					 int num = Integer.parseInt(jo.get("num").toString());
					orderPartService.insert(new OrderPart(orderId, pId,num));
					Part part = partService.selectByPrimaryKey(pId);
					part.setPartNum(part.getPartNum()-num);
					partService.updateByPrimaryKeySelective(part);
				}
				
				for(String id :workers){
					orderWorkerService.insert(new OrderWorker(orderId,id));
					Worker worker = workerService.selectByPrimaryKey(id);
					worker.setwState(0);//忙碌
					workerService.updateByPrimaryKeySelective(worker);
				}
				
		} catch (Exception e) {
			success="0";
		}
		return success;
	}

	/** 修改订单*/
	@RequestMapping("/edit")
	public String edit(HttpServletRequest request,String orderId){
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("orderId", orderId);
		//通过id查出只能是一条数据
 		List<Map<String, Object>> order = orderService.selectOrderByAttr(paramMap);
 		String[] imgurls = order.get(0).get("imgUrls").toString().split(",");
 		//查询机床
    	SStation station = stationService.selectByPrimaryKey(Integer.parseInt(order.get(0).get("s_id").toString()));
 		//查询工人 0在忙 1 空闲
 		List<Map<String, Object>> selWorkers = orderWorkerService.selectByOrderId(order.get(0).get("o_id").toString());
 		//查询所有零件
 		List<Map<String, Object>> selParts = orderPartService.selectByOrderId(order.get(0).get("o_id").toString());
 		
 		//查询所有待使用的机床
 		List<SStation> stations=stationService.selectAll(new HashMap<String, Object>(){{put("s_state", "完好待使用");}});
 		//查询所有空闲的工人 state=1空闲 2在忙 0离职
 		List<Worker> workers = workerService.selectWorkersByAttr(new Worker(){{setwState(1);}});
 		//查询所有可使用零件
 		List<Part> parts = partService.selectAll();
 		
 		request.setAttribute("imgurls",imgurls);
 		request.setAttribute("dealOrder",order.get(0));
 		request.setAttribute("stations",stations);
 		request.setAttribute("workers",workers);
 		request.setAttribute("parts",parts);
 		request.setAttribute("station",station);//已选中station
 		request.setAttribute("selWorkers",selWorkers);
 		request.setAttribute("selParts",selParts);
 		request.setAttribute("readonly", 0);//非只读
 		return "order/orderDetail";
	}
	
	/** 订单详情*/
	@RequestMapping("/detail")
	public String detail(HttpServletRequest request,String orderId){
		Map<String, Object> paramMap=new HashMap<String, Object>();
		paramMap.put("orderId", orderId);
		//通过id查出只能是一条数据
 		List<Map<String, Object>> order = orderService.selectOrderByAttr(paramMap);
 		Map<String, Object> orderMap = order.get(0);
 		String[] imgurls = orderMap.get("imgUrls").toString().split(",");
 		if (orderMap.get("s_id")==null) {
 			request.setAttribute("station",null);
 			request.setAttribute("selWorkers",null);
 			request.setAttribute("selParts",null);
 		}else{
 			//查询机床
 			SStation station = stationService.selectByPrimaryKey(Integer.parseInt(orderMap.get("s_id").toString()));
 			//查询工人 0在忙 1 空闲
 			List<Map<String, Object>> workers = orderWorkerService.selectByOrderId(orderMap.get("o_id").toString());
 			//查询所有零件
 			List<Map<String, Object>> parts = orderPartService.selectByOrderId(orderMap.get("o_id").toString());
 			request.setAttribute("station",station);
 			request.setAttribute("selWorkers",workers);
 			request.setAttribute("selParts",parts);
 		}
 		request.setAttribute("imgurls",imgurls);
 		request.setAttribute("dealOrder",order.get(0));
 		request.setAttribute("readonly", 1);//只读
		return "order/orderDetail";
	}
	/** 订单*/
	@RequestMapping("/userOrder")
	public String userOrder(HttpServletRequest request,HttpSession sessions){
		User user= (User)sessions.getAttribute("userOn");
		Map<String,Object> paramMap=new HashMap<String, Object>();
		paramMap.put("userId", user.getuId());
		List<Map<String, Object>> orders = orderService.selectOrderByAttr(paramMap);//返回用户的多个订单
		request.setAttribute("orders", orders);
		return "order/userOrder";
	}
	@RequestMapping("/done")
	@ResponseBody
	public String doneOrder(HttpServletResponse response,HttpServletRequest request,String orderId) {
		String msg="1";
		//更新  1订单状态 2更新机床 3更新员工状态 4更新车辆状态
		List<Map<String,Object>> ws = orderWorkerService.selectByOrderId(orderId);
		Order order = orderService.selectByPrimaryKey(orderId);
		try {
			//1
			order.setEndtime(new Date());
			order.setoState("2");//2完成
			orderService.updateByPrimaryKeySelective(order);
			//2
			SStation station = stationService.selectByPrimaryKey(order.getStationId());
			station.setsState("完好待使用");
			stationService.updateByPrimaryKeySelective(station);
			//4
			Car car = carService.selectByPrimaryKey(order.getCarId());
			car.setCarState(0);
			carService.updateByPrimaryKeySelective(car);
			//3
			for (Map<String, Object> map : ws) {
				String wId= (String)map.get("w_id");
				Worker worker = workerService.selectByPrimaryKey(wId);
				worker.setwState(1);//1空闲
				workerService.updateByPrimaryKeySelective(worker);
			}
		} catch (Exception e) {
			msg="0";
		}
		return msg;
	}
	
	/** 订单*/
	@RequestMapping("/home")
	public String homePage(HttpServletRequest request,HttpSession sessions){
		List<Map<String, Object>> list= orderService.selectOrderByAttr(new HashMap<String, Object>(){{put("state", 0);}});
		request.setAttribute("count", list.size());
		List<String> yearMonths = DateUtils.getYearMonths(6);//获取半年日期
		request.setAttribute("yearMonths", yearMonths);
		
		List<Part> parts = partService.selectAll();
		for (int i = 0; i < parts.size(); i++) {
			if(parts.get(i).getPartNum()>parts.get(i).getWarning()){
				parts.remove(i);
			}
		}
		request.setAttribute("parts", parts);
		return "home";
	}
	/**  */
	@RequestMapping("/reject")
	@ResponseBody
	public String rejectOrder(HttpServletRequest request,String orderId,String remark) {
		String success="1";
		//获取订单id 机床id 员工id集合 零件id num集合
		//修改订单状态 修改机床状态 更新order-worker order-part表
		try {
				
				Order order = orderService.selectByPrimaryKey(orderId);
				order.setoState("2");//3拒绝
				order.setRemark(remark);
				order.setEndtime(new Date());
				orderService.updateByPrimaryKeySelective(order);//更新order
				Car car = carService.selectByPrimaryKey(order.getCarId());
				car.setCarState(0);
				carService.updateByPrimaryKeySelective(car);
		} catch (Exception e) {
			success="0";
		}
		return success;
	}

}

 登陆过滤管理控制层:

public class CommonInterceptor extends HandlerInterceptorAdapter {

	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws ServletException, Exception {
		
        HttpSession session = request.getSession();  
        User user= (User)session.getAttribute("user");
	        if(user == null ){
	        	session.setAttribute("msg", "您还没有登录或登录已超时,请重新登录,然后再刷新本功能!");
//	        	request.setAttribute("msg", "您还没有登录或登录已超时,请重新登录,然后再刷新本功能!");
	        	response.sendRedirect(request.getContextPath());
//	        	request.getRequestDispatcher("/").forward(request, response);
	            return false;  
	        }
        return true;  
		}

	
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) {

	}

	
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex) {
//		System.out.println("----------------------异常时拦截------------------");
	}
}

源码获取:俺的博客首页 "资源" 里下载!

Logo

前往低代码交流专区

更多推荐