• Java项目:SSM汽车维修管理系统源码


    作者主页:夜未央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

    1. package com.chillax.controller;
    2. import java.util.HashMap;
    3. import java.util.List;
    4. import java.util.Map;
    5. import javax.annotation.Resource;
    6. import javax.servlet.http.HttpServletRequest;
    7. import javax.servlet.http.HttpServletResponse;
    8. import javax.servlet.http.HttpSession;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.ui.Model;
    11. import org.springframework.web.bind.annotation.RequestMapping;
    12. import org.springframework.web.bind.annotation.ResponseBody;
    13. import com.chillax.bean.Car;
    14. import com.chillax.bean.User;
    15. import com.chillax.service.CarService;
    16. import com.chillax.utils.BaseController;
    17. import com.chillax.utils.DateUtils;
    18. import com.chillax.utils.StringUtil;
    19. import com.chillax.utils.TableData;
    20. @Controller
    21. @RequestMapping("/car")
    22. public class CarController extends BaseController {
    23. @Resource
    24. private CarService carService;
    25. /**页面跳转*/
    26. @RequestMapping("/list")
    27. public String workList(HttpServletRequest request,HttpSession session){
    28. String tag = request.getParameter("tag");
    29. request.setAttribute("tag", tag);
    30. return "car/car_list";
    31. }
    32. /**数据获取*/
    33. @RequestMapping("/getData")
    34. @ResponseBody
    35. public String getData(HttpServletResponse response,HttpServletRequest request,String carName){
    36. Integer offset = Integer.parseInt(request.getParameter("offset"));//开始条数
    37. Integer limit = Integer.parseInt(request.getParameter("limit"));//每页条数
    38. Map paramMap=new HashMap();
    39. String tag = request.getParameter("tag");
    40. User userOn=(User)request.getSession().getAttribute("userOn");
    41. if(!StringUtil.isEmpty(tag)){
    42. paramMap.put("tag", tag);//tag 标注是否查出在维修车辆 tag=1 不查出
    43. }
    44. paramMap.put("userId", userOn.getuId());
    45. paramMap.put("carName", carName);
    46. List cars = carService.selectAllByUser(paramMap);
    47. return TableData.getJson2Table(cars, offset, limit);
    48. }
    49. /**编辑零件信息 */
    50. @RequestMapping("/edit")
    51. public String editWork(HttpServletRequest request,Model model){
    52. try {
    53. String id = request.getParameter("id");
    54. Car car = new Car();
    55. if(StringUtil.isNotEmpty(id)){
    56. car = carService.selectByPrimaryKey(id);
    57. }
    58. model.addAttribute("car", car);
    59. } catch (Exception e) {
    60. e.printStackTrace();
    61. }
    62. return "car/car_edit";
    63. }
    64. @RequestMapping("/add")
    65. @ResponseBody
    66. public Integer addWorker(HttpServletRequest request,Car car){
    67. int record=0;
    68. User user=(User)request.getSession().getAttribute("userOn");
    69. if( StringUtil.isEmpty(car.getCarId())){
    70. /*设置关联用户id*/
    71. car.setUserId(user.getuId());
    72. car.setCarId(StringUtil.getStringId());
    73. record= carService.insertSelective(car);
    74. }else{
    75. record= carService.updateByPrimaryKeySelective(car);
    76. }
    77. return record;
    78. }
    79. /**删除机床*/
    80. @RequestMapping("/delById")
    81. @ResponseBody
    82. public Integer deleteWorker(HttpServletRequest request){
    83. String ids = request.getParameter("id");
    84. if(StringUtil.isNotEmpty(ids)){
    85. String[] sIds = ids.split(",");
    86. for (String sId : sIds) {
    87. carService.deleteByPrimaryKey(sId);
    88. }
    89. return 1;
    90. }else{
    91. return 0;
    92. }
    93. }
    94. @RequestMapping("/selectCar")
    95. @ResponseBody
    96. public Integer selectCar(HttpServletRequest request,HttpSession session,String carId){
    97. if(!StringUtil.isEmpty(carId)){
    98. Car preCar = carService.selectByPrimaryKey(carId);
    99. session.setAttribute("preCar", preCar);
    100. }
    101. return 1;
    102. }
    103. @RequestMapping("/getCarTypeData")
    104. @ResponseBody
    105. public List> getCarTypeData(HttpServletRequest request,String month){
    106. if(StringUtil.isEmpty(month)){
    107. month=DateUtils.getYearMonths(1).get(0);
    108. }
    109. Map map=new HashMap();
    110. map.put("date",month);
    111. List> list = carService.selectCarTypeData(map);
    112. return list;
    113. }
    114. }

    OrderController

    1. package com.chillax.controller;
    2. import java.text.ParseException;
    3. import java.text.SimpleDateFormat;
    4. import java.util.Date;
    5. import java.util.HashMap;
    6. import java.util.List;
    7. import java.util.Map;
    8. import javax.annotation.Resource;
    9. import javax.servlet.http.HttpServletRequest;
    10. import javax.servlet.http.HttpServletResponse;
    11. import javax.servlet.http.HttpSession;
    12. import org.springframework.stereotype.Controller;
    13. import org.springframework.web.bind.annotation.RequestMapping;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. import com.alibaba.fastjson.JSONArray;
    16. import com.alibaba.fastjson.JSONObject;
    17. import com.chillax.bean.Car;
    18. import com.chillax.bean.Order;
    19. import com.chillax.bean.OrderPart;
    20. import com.chillax.bean.OrderWorker;
    21. import com.chillax.bean.Part;
    22. import com.chillax.bean.SStation;
    23. import com.chillax.bean.User;
    24. import com.chillax.bean.Worker;
    25. import com.chillax.service.CarService;
    26. import com.chillax.service.OrderPartService;
    27. import com.chillax.service.OrderService;
    28. import com.chillax.service.OrderWorkerService;
    29. import com.chillax.service.PartService;
    30. import com.chillax.service.StationService;
    31. import com.chillax.service.WorkerService;
    32. import com.chillax.utils.BaseController;
    33. import com.chillax.utils.DateUtils;
    34. import com.chillax.utils.StringUtil;
    35. @Controller
    36. @RequestMapping("/order")
    37. public class OrderController extends BaseController {
    38. private final Integer WARNING_COUNT=20;
    39. @Resource
    40. private CarService carService;
    41. @Resource
    42. private StationService stationService;
    43. @Resource
    44. private PartService partService;
    45. @Resource
    46. private OrderPartService orderPartService;
    47. @Resource
    48. private OrderWorkerService orderWorkerService;
    49. @Resource
    50. private WorkerService workerService;
    51. @Resource
    52. private OrderService orderService;
    53. /** 页面跳转 预定页面 */
    54. @RequestMapping("/toPreOrder")
    55. public String toPreOrder(HttpServletRequest request, HttpSession session,
    56. String carId) {
    57. return "order/preOrder";
    58. }
    59. /** 订单预定 */
    60. @RequestMapping("/preOrder")
    61. @ResponseBody
    62. public Integer preOrder(HttpServletRequest request, HttpSession session,
    63. String imgurls, String arriveTime, String desc) {
    64. // User user=(User)session.getAttribute("userOn");
    65. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    66. Date arrDate = null;
    67. try {
    68. arrDate = format.parse(arriveTime);
    69. } catch (ParseException e) {
    70. e.printStackTrace();
    71. }
    72. Car car = (Car) session.getAttribute("preCar");
    73. car.setCarState(1);
    74. int updateCar = carService.updateByPrimaryKeySelective(car);
    75. Order order = new Order();
    76. order.setOrderId(StringUtil.getStringId());
    77. order.setCarId(car.getCarId());
    78. order.setoDescribe(desc);
    79. // 0 预约中 1预约成功 2正在执行 3完成 4拒绝
    80. order.setoState("0");
    81. order.setArriveTime(arrDate);
    82. order.setOrdertime(new Date());
    83. order.setImgUrls(imgurls);
    84. int updateOrder = orderService.insertSelective(order);
    85. return updateOrder+updateCar;
    86. }
    87. /** 订单操作 */
    88. @RequestMapping("/manage")
    89. public String manageOrder(HttpServletRequest request, HttpSession session,String orderId) {
    90. Map paramMap=new HashMap();
    91. paramMap.put("orderId", orderId);
    92. //通过id查出只能是一条数据
    93. List> order = orderService.selectOrderByAttr(paramMap);
    94. String[] imgurls = order.get(0).get("imgUrls").toString().split(",");
    95. //查询所有待使用的机床
    96. List stations=stationService.selectAll(new HashMap(){{put("s_state", "完好待使用");}});
    97. //查询所有空闲的工人 state=1空闲 2在忙 0离职
    98. List workers = workerService.selectWorkersByAttr(new Worker(){{setwState(1);}});
    99. //查询所有可使用零件
    100. List parts = partService.selectAll();
    101. request.setAttribute("imgurls",imgurls);
    102. request.setAttribute("dealOrder",order.get(0));
    103. request.setAttribute("stations",stations);
    104. request.setAttribute("workers",workers);
    105. request.setAttribute("parts",parts);
    106. return "order/manageOrder";
    107. }
    108. /** 页面跳转 */
    109. @RequestMapping("/list")
    110. public String workList(HttpServletRequest request, HttpSession session,String state) {
    111. Map paramMap=new HashMap();
    112. paramMap.put("state", state);
    113. List> order = orderService.selectOrderByAttr(paramMap);
    114. session.setAttribute("order", order);
    115. request.setAttribute("state", state);
    116. return "order/order_list";
    117. }
    118. /** */
    119. @RequestMapping("/accept")
    120. @ResponseBody
    121. public String acceptOrder(HttpServletResponse response,HttpServletRequest request,String orderId,
    122. String remark,String stationId) {
    123. String success="1";
    124. //获取订单id 机床id 员工id集合 零件id num集合
    125. String selectedWorker=request.getParameter("selectedWorker");
    126. String[] workers = selectedWorker.split(",");
    127. String selParts=request.getParameter("parts");
    128. JSONArray parts=JSONArray.parseArray(selParts);
    129. //修改订单状态 修改机床状态 更新order-worker order-part表
    130. try {
    131. Order order = orderService.selectByPrimaryKey(orderId);
    132. order.setStationId(Integer.parseInt(stationId));
    133. order.setoState("1");//1进行中
    134. order.setRemark(remark);
    135. order.setBegintime(new Date());
    136. orderService.updateByPrimaryKeySelective(order);//更新order
    137. SStation station = stationService.selectByPrimaryKey(Integer.parseInt(stationId));
    138. station.setsState("完好在使用");
    139. stationService.updateByPrimaryKeySelective(station);
    140. for(int i=0;i
    141. JSONObject jo = parts.getJSONObject(i);
    142. String pId = jo.get("id").toString();
    143. int num = Integer.parseInt(jo.get("num").toString());
    144. orderPartService.insert(new OrderPart(orderId, pId,num));
    145. Part part = partService.selectByPrimaryKey(pId);
    146. part.setPartNum(part.getPartNum()-num);
    147. partService.updateByPrimaryKeySelective(part);
    148. }
    149. for(String id :workers){
    150. orderWorkerService.insert(new OrderWorker(orderId,id));
    151. Worker worker = workerService.selectByPrimaryKey(id);
    152. worker.setwState(0);//忙碌
    153. workerService.updateByPrimaryKeySelective(worker);
    154. }
    155. } catch (Exception e) {
    156. success="0";
    157. }
    158. return success;
    159. }
    160. /** 修改订单*/
    161. @RequestMapping("/edit")
    162. public String edit(HttpServletRequest request,String orderId){
    163. Map paramMap=new HashMap();
    164. paramMap.put("orderId", orderId);
    165. //通过id查出只能是一条数据
    166. List> order = orderService.selectOrderByAttr(paramMap);
    167. String[] imgurls = order.get(0).get("imgUrls").toString().split(",");
    168. //查询机床
    169. SStation station = stationService.selectByPrimaryKey(Integer.parseInt(order.get(0).get("s_id").toString()));
    170. //查询工人 0在忙 1 空闲
    171. List> selWorkers = orderWorkerService.selectByOrderId(order.get(0).get("o_id").toString());
    172. //查询所有零件
    173. List> selParts = orderPartService.selectByOrderId(order.get(0).get("o_id").toString());
    174. //查询所有待使用的机床
    175. List stations=stationService.selectAll(new HashMap(){{put("s_state", "完好待使用");}});
    176. //查询所有空闲的工人 state=1空闲 2在忙 0离职
    177. List workers = workerService.selectWorkersByAttr(new Worker(){{setwState(1);}});
    178. //查询所有可使用零件
    179. List parts = partService.selectAll();
    180. request.setAttribute("imgurls",imgurls);
    181. request.setAttribute("dealOrder",order.get(0));
    182. request.setAttribute("stations",stations);
    183. request.setAttribute("workers",workers);
    184. request.setAttribute("parts",parts);
    185. request.setAttribute("station",station);//已选中station
    186. request.setAttribute("selWorkers",selWorkers);
    187. request.setAttribute("selParts",selParts);
    188. request.setAttribute("readonly", 0);//非只读
    189. return "order/orderDetail";
    190. }
    191. /** 订单详情*/
    192. @RequestMapping("/detail")
    193. public String detail(HttpServletRequest request,String orderId){
    194. Map paramMap=new HashMap();
    195. paramMap.put("orderId", orderId);
    196. //通过id查出只能是一条数据
    197. List> order = orderService.selectOrderByAttr(paramMap);
    198. Map orderMap = order.get(0);
    199. String[] imgurls = orderMap.get("imgUrls").toString().split(",");
    200. if (orderMap.get("s_id")==null) {
    201. request.setAttribute("station",null);
    202. request.setAttribute("selWorkers",null);
    203. request.setAttribute("selParts",null);
    204. }else{
    205. //查询机床
    206. SStation station = stationService.selectByPrimaryKey(Integer.parseInt(orderMap.get("s_id").toString()));
    207. //查询工人 0在忙 1 空闲
    208. List> workers = orderWorkerService.selectByOrderId(orderMap.get("o_id").toString());
    209. //查询所有零件
    210. List> parts = orderPartService.selectByOrderId(orderMap.get("o_id").toString());
    211. request.setAttribute("station",station);
    212. request.setAttribute("selWorkers",workers);
    213. request.setAttribute("selParts",parts);
    214. }
    215. request.setAttribute("imgurls",imgurls);
    216. request.setAttribute("dealOrder",order.get(0));
    217. request.setAttribute("readonly", 1);//只读
    218. return "order/orderDetail";
    219. }
    220. /** 订单*/
    221. @RequestMapping("/userOrder")
    222. public String userOrder(HttpServletRequest request,HttpSession sessions){
    223. User user= (User)sessions.getAttribute("userOn");
    224. Map paramMap=new HashMap();
    225. paramMap.put("userId", user.getuId());
    226. List> orders = orderService.selectOrderByAttr(paramMap);//返回用户的多个订单
    227. request.setAttribute("orders", orders);
    228. return "order/userOrder";
    229. }
    230. @RequestMapping("/done")
    231. @ResponseBody
    232. public String doneOrder(HttpServletResponse response,HttpServletRequest request,String orderId) {
    233. String msg="1";
    234. //更新 1订单状态 2更新机床 3更新员工状态 4更新车辆状态
    235. List> ws = orderWorkerService.selectByOrderId(orderId);
    236. Order order = orderService.selectByPrimaryKey(orderId);
    237. try {
    238. //1
    239. order.setEndtime(new Date());
    240. order.setoState("2");//2完成
    241. orderService.updateByPrimaryKeySelective(order);
    242. //2
    243. SStation station = stationService.selectByPrimaryKey(order.getStationId());
    244. station.setsState("完好待使用");
    245. stationService.updateByPrimaryKeySelective(station);
    246. //4
    247. Car car = carService.selectByPrimaryKey(order.getCarId());
    248. car.setCarState(0);
    249. carService.updateByPrimaryKeySelective(car);
    250. //3
    251. for (Map map : ws) {
    252. String wId= (String)map.get("w_id");
    253. Worker worker = workerService.selectByPrimaryKey(wId);
    254. worker.setwState(1);//1空闲
    255. workerService.updateByPrimaryKeySelective(worker);
    256. }
    257. } catch (Exception e) {
    258. msg="0";
    259. }
    260. return msg;
    261. }
    262. /** 订单*/
    263. @RequestMapping("/home")
    264. public String homePage(HttpServletRequest request,HttpSession sessions){
    265. List> list= orderService.selectOrderByAttr(new HashMap(){{put("state", 0);}});
    266. request.setAttribute("count", list.size());
    267. List yearMonths = DateUtils.getYearMonths(6);//获取半年日期
    268. request.setAttribute("yearMonths", yearMonths);
    269. List parts = partService.selectAll();
    270. for (int i = 0; i < parts.size(); i++) {
    271. if(parts.get(i).getPartNum()>parts.get(i).getWarning()){
    272. parts.remove(i);
    273. }
    274. }
    275. request.setAttribute("parts", parts);
    276. return "home";
    277. }
    278. /** */
    279. @RequestMapping("/reject")
    280. @ResponseBody
    281. public String rejectOrder(HttpServletRequest request,String orderId,String remark) {
    282. String success="1";
    283. //获取订单id 机床id 员工id集合 零件id num集合
    284. //修改订单状态 修改机床状态 更新order-worker order-part表
    285. try {
    286. Order order = orderService.selectByPrimaryKey(orderId);
    287. order.setoState("2");//3拒绝
    288. order.setRemark(remark);
    289. order.setEndtime(new Date());
    290. orderService.updateByPrimaryKeySelective(order);//更新order
    291. Car car = carService.selectByPrimaryKey(order.getCarId());
    292. car.setCarState(0);
    293. carService.updateByPrimaryKeySelective(car);
    294. } catch (Exception e) {
    295. success="0";
    296. }
    297. return success;
    298. }
    299. }

    如果也想学习本系统,下面领取。关注并回复:238ssm 

  • 相关阅读:
    有哪些原因会导致excel文档损坏打不开?
    uniapp 设置重写uni-body-page样式,输入字母转大写
    chatgpt赋能python:Python随机选择数字
    Mac OS 使用ScreenCaptureKit进行窗口抓取和系统声音抓取
    webpack构建vue项目 基础09之生产环境 打包为zip文件 与 public静态文件的copy
    自己写了个Java RMI(远程方法调用)的实现案例
    通过浏览器打开某个应用程序
    算法笔记(1)线段树
    强化学习与视觉语言模型之间的碰撞,UC伯克利提出语言奖励调节LAMP框架
    在Vue3中使用Element Plus Icon图标的几种方式
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/127602588