作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
源码描述:
一、源码介绍
汽车维修管理系统源码使用ssm框架,maven,bootsrap,mysql实现,带数据库。
二、主要功能
分为2个角色,管理员和顾客;
顾客登录后,操作我的车辆,预约订单,历史订单;
管理员登录后,操作订单管理,员工管理,机位管理,用户管理,零件管理。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;
6.数据库:MySql 5.7/8.0等版本均可;
1. 后端:Spring springmvc mybatis
2. 前端:JSP+css+javascript+jQuery+bootstrap+layui
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置,然后运行;
4. 运行成功后,在浏览器中输入:http://localhost:8080/
管理员账号密码:admin/admin
用户账号密码:user/123456
CarController
- package com.chillax.controller;
-
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- import com.chillax.bean.Car;
- import com.chillax.bean.User;
- import com.chillax.service.CarService;
- import com.chillax.utils.BaseController;
- import com.chillax.utils.DateUtils;
- import com.chillax.utils.StringUtil;
- import com.chillax.utils.TableData;
- @Controller
- @RequestMapping("/car")
- public class CarController extends BaseController {
-
- @Resource
- private CarService carService;
- /**页面跳转*/
- @RequestMapping("/list")
- public String workList(HttpServletRequest request,HttpSession session){
- String tag = request.getParameter("tag");
- request.setAttribute("tag", tag);
- return "car/car_list";
- }
- /**数据获取*/
- @RequestMapping("/getData")
- @ResponseBody
- public String getData(HttpServletResponse response,HttpServletRequest request,String carName){
- Integer offset = Integer.parseInt(request.getParameter("offset"));//开始条数
- Integer limit = Integer.parseInt(request.getParameter("limit"));//每页条数
- Map
paramMap=new HashMap(); - String tag = request.getParameter("tag");
- User userOn=(User)request.getSession().getAttribute("userOn");
- if(!StringUtil.isEmpty(tag)){
- paramMap.put("tag", tag);//tag 标注是否查出在维修车辆 tag=1 不查出
- }
- paramMap.put("userId", userOn.getuId());
- paramMap.put("carName", carName);
- List
cars = carService.selectAllByUser(paramMap); - return TableData.getJson2Table(cars, offset, limit);
- }
- /**编辑零件信息 */
- @RequestMapping("/edit")
- public String editWork(HttpServletRequest request,Model model){
- try {
- String id = request.getParameter("id");
- Car car = new Car();
- if(StringUtil.isNotEmpty(id)){
- car = carService.selectByPrimaryKey(id);
- }
- model.addAttribute("car", car);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "car/car_edit";
- }
- @RequestMapping("/add")
- @ResponseBody
- public Integer addWorker(HttpServletRequest request,Car car){
- int record=0;
- User user=(User)request.getSession().getAttribute("userOn");
- if( StringUtil.isEmpty(car.getCarId())){
- /*设置关联用户id*/
- car.setUserId(user.getuId());
- car.setCarId(StringUtil.getStringId());
- record= carService.insertSelective(car);
- }else{
- record= carService.updateByPrimaryKeySelective(car);
- }
- 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) {
- carService.deleteByPrimaryKey(sId);
- }
- return 1;
- }else{
- return 0;
- }
- }
-
- @RequestMapping("/selectCar")
- @ResponseBody
- public Integer selectCar(HttpServletRequest request,HttpSession session,String carId){
- if(!StringUtil.isEmpty(carId)){
- Car preCar = carService.selectByPrimaryKey(carId);
- session.setAttribute("preCar", preCar);
- }
- return 1;
- }
-
-
- @RequestMapping("/getCarTypeData")
- @ResponseBody
- public List
- if(StringUtil.isEmpty(month)){
- month=DateUtils.getYearMonths(1).get(0);
- }
- Map
map=new HashMap(); - map.put("date",month);
- List
- return list;
- }
- }
OrderController
- package com.chillax.controller;
-
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.chillax.bean.Car;
- import com.chillax.bean.Order;
- import com.chillax.bean.OrderPart;
- import com.chillax.bean.OrderWorker;
- import com.chillax.bean.Part;
- import com.chillax.bean.SStation;
- import com.chillax.bean.User;
- import com.chillax.bean.Worker;
- import com.chillax.service.CarService;
- import com.chillax.service.OrderPartService;
- import com.chillax.service.OrderService;
- import com.chillax.service.OrderWorkerService;
- import com.chillax.service.PartService;
- import com.chillax.service.StationService;
- import com.chillax.service.WorkerService;
- import com.chillax.utils.BaseController;
- import com.chillax.utils.DateUtils;
- import com.chillax.utils.StringUtil;
-
- @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
paramMap=new HashMap(); - paramMap.put("orderId", orderId);
- //通过id查出只能是一条数据
- List
- String[] imgurls = order.get(0).get("imgUrls").toString().split(",");
- //查询所有待使用的机床
- List
stations=stationService.selectAll(new HashMap(){{put("s_state", "完好待使用");}}); - //查询所有空闲的工人 state=1空闲 2在忙 0离职
- List
workers = workerService.selectWorkersByAttr(new Worker(){{setwState(1);}}); - //查询所有可使用零件
- List
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
paramMap=new HashMap(); - paramMap.put("state", state);
- List
- 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
- 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
paramMap=new HashMap(); - paramMap.put("orderId", orderId);
- //通过id查出只能是一条数据
- List
- 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
- //查询所有零件
- List
-
- //查询所有待使用的机床
- List
stations=stationService.selectAll(new HashMap(){{put("s_state", "完好待使用");}}); - //查询所有空闲的工人 state=1空闲 2在忙 0离职
- List
workers = workerService.selectWorkersByAttr(new Worker(){{setwState(1);}}); - //查询所有可使用零件
- List
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
paramMap=new HashMap(); - paramMap.put("orderId", orderId);
- //通过id查出只能是一条数据
- List
- Map
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
- //查询所有零件
- List
- 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
paramMap=new HashMap(); - paramMap.put("userId", user.getuId());
- List
- 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
- 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
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
- request.setAttribute("count", list.size());
- List
yearMonths = DateUtils.getYearMonths(6);//获取半年日期 - request.setAttribute("yearMonths", yearMonths);
-
- List
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;
- }
-
- }
如果也想学习本系统,下面领取。关注并回复:238ssm