基于Springboot实现汽车4S店销售管理系统
Posted 编程指南针
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于Springboot实现汽车4S店销售管理系统相关的知识,希望对你有一定的参考价值。
作者主页:编程指南针
作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助
文末获取源码
项目编号:BS-XX-126
一,项目简介
本项目基于Springboot框架开发实现,主要针对汽车4S店的销售信息进行管理,名为4S管家,主要包含管理员用户和员工用户,主要实现的功能有汽车销售信息管理、配件销售订单管理、售后服务订单管理、库存管理、客户管理、员工管理、系统用户管理、日志管理、系统说明等。特色功能包含图形报表统计功能,数据导入导出功能等。
二,环境介绍
语言环境:Java: jdk1.8
数据库:mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
后台开发技术:Springboot+Mybatis
前端开发技术:Bootstrap+Jquery+Ajax
三,系统展示
系统登陆
仪表盘
汽车订单管理
配件订单管理
售后订单管理
汽车库存管理
配件库存管理
客户管理
员工管理
员工管理
日志管理
Druid监控
四,核心代码展示
package com.gk.carshopsys.controller;
import com.github.pagehelper.PageInfo;
import com.gk.carshopsys.annotation.Log;
import com.gk.carshopsys.pojo.Admin;
import com.gk.carshopsys.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;
import javax.servlet.http.HttpSession;
import java.lang.reflect.Array;
import java.sql.Date;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class AdminController
@Autowired
private AdminService adminService;
//初始页面跳转登录页
@RequestMapping("/")
public String tologin()
return "login";
;
//跳转登录页
@RequestMapping("/login")
public String login()
return "login";
;
//主页跳转
@RequestMapping("/index")
public String toindex()return "index";
//登录页响应页面跳转
@PostMapping ("/login.action")
public String adminlogin(@RequestParam("user") String user,
@RequestParam("username") String username,
@RequestParam("password") String password, Model model, HttpSession session)
Admin admin=adminService.loginAdmin(username,password);
if(admin!=null)
session.setAttribute("loginUser",username);
return "redirect:/index";
else
model.addAttribute("msg", "密码或者账号有误,请重新输入");
return "login";
;
//退出登录
@RequestMapping("/logout")
public String logout(HttpSession session)
session.invalidate();
return "redirect:/login";
;
//管理员用户列表跳转
@RequestMapping("/adminlist")
public String toadminlist()
return "adminlist";
;
//返回管理员用户列表
@Log("查询管理员")
@RequestMapping("/adminlist/query")
@ResponseBody
public List<Admin> findAdmin(@RequestBody Map<String,String> param)
String username = param.get("username");
String id_s = param.get("id");
if (id_s!=null && !id_s.equals(""))
try
Integer id = Integer.parseInt(id_s);
return adminService.findAdminByIdAndUsername(id,username);
catch (ClassCastException e)
return adminService.findAdminByIdAndUsername(null,username);
else
return adminService.findAdminByIdAndUsername(null,username);
;
//管理员用户添加
//RedirectAttributesModelMap类防止重定向后model丢失
@Log("添加管理员")
@PostMapping("/adminlist/add")
public String adminlistadd(@RequestParam("add_adminname") String username,
@RequestParam("add_password") String password,RedirectAttributesModelMap model)
int result = adminService.addAdmin(username,password);
if(result==-1)
model.addFlashAttribute("addmsg","插入失败,用户名已存在,请重新插入");
return "redirect:/adminlist";
if(result==1)
model.addFlashAttribute("addmsg","插入成功");
else
model.addFlashAttribute("addmsg","插入未知错误");
return "redirect:/adminlist";
;
// 管理员用户更新
@Log("修改管理员")
@PostMapping("/adminlist/upadte")
public String adminlistupadte(@RequestParam("update_id") Integer id,
@RequestParam("update_adminname") String username,
@RequestParam("update_password") String password,RedirectAttributesModelMap model)
int result=adminService.updateAdmin(id,username,password);
if(result==-1)
model.addFlashAttribute("updatemsg","修改失败,用户名已存在,请重新修改");
return "redirect:/adminlist";
if (result==1)
model.addFlashAttribute("updatemsg","修改成功");
else
model.addFlashAttribute("updatemsg","修改失败,未知错误");
return "redirect:/adminlist";
;
//管理员用户批量删除
@Log("删除管理员")
@ResponseBody
@RequestMapping("/adminlist/del")
public Map<String,Integer> adminlistdel(@RequestBody List<Integer> ids)
int result = adminService.delAdmin(ids);
Map<String,Integer> map = new HashMap<>();
map.put("code",result);
return map;
package com.gk.carshopsys.controller;
import com.alibaba.excel.EasyExcel;
import com.gk.carshopsys.annotation.Log;
import com.gk.carshopsys.pojo.Car;
import com.gk.carshopsys.pojo.Cust;
import com.gk.carshopsys.service.CarService;
import com.gk.carshopsys.utils.CarDataListener;
import com.gk.carshopsys.utils.CustDataListener;
import com.gk.carshopsys.utils.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class CarController
@Autowired
private CarService carService;
//Excel参数
private HashMap<String,String> param;
//excel传参
@PostMapping("/carlist/excelparamset")
@ResponseBody
public void excelset(@RequestBody HashMap<String,String> params)
param= params;
//excel下载
@Log("导出汽车库存")
@GetMapping("/carlist/excelexport")
@ResponseBody
public String excelexport(HttpServletResponse response) throws Exception
//导出的参数
String id_s = param.get("id");
String carname = param.get("carname");
String brand = param.get("brand");
String color = param.get("color");
String type = param.get("type");
String configuration = param.get("configuration");
String low_price = param.get("low_price");//需要转型
String hight_price = param.get("hight_price");//需要转型
Car car = new Car();
if(id_s!=null && !id_s.equals(""))
try
Long id = Long.valueOf(id_s);
car.setId(id);
catch (ClassCastException e)
finally
car.setBrand(brand);
car.setCarname(carname);
car.setColor(color);
car.setType(type);
car.setConfiguration(configuration);
car.setBrand(brand);
car.setCarname(carname);
car.setColor(color);
car.setType(type);
car.setConfiguration(configuration);
ExcelUtils.export2Web(response, "汽车库存表", "汽车库存信息",Car.class,carService.findCar(car,low_price,hight_price));
return "success";
// easyexcel上传文件
@Log("导入汽车库存")
@PostMapping("/carlist/excelimport")
public String upload(MultipartFile file, RedirectAttributesModelMap model) throws IOException
EasyExcel.read(file.getInputStream(), Car.class, new CarDataListener(carService)).sheet().doRead();
return "redirect:/carlist";
//批量删除车型
@Log("删除汽车库存")
@ResponseBody
@RequestMapping("/carlist/del")
public Map<String,Integer> carlistdel(@RequestBody List<Integer> ids)
int result = carService.delCar(ids);
Map<String,Integer> map = new HashMap<>();
map.put("code",result);
return map;
@Log("更新汽车库存")
@RequestMapping("/carlist/update")
public String carUpdate(@RequestParam("update_id") Long id,
@RequestParam("update_brand") String brand,
@RequestParam("update_carname") String carname,
@RequestParam("update_price") Long price,
@RequestParam("update_color") String color,
@RequestParam("update_type") String type,
@RequestParam("update_quantity") Long quantity,
@RequestParam("update_configuration") String configuration,
RedirectAttributesModelMap model)
Car car = new Car(id,brand,carname,price,color,type,quantity,configuration);
int result =carService.updateCar(car);
if(result==1)
model.addFlashAttribute("addmsg","修改成功");
else
model.addFlashAttribute("addmsg","修改失败");
return "redirect:/carlist";
//查询车辆库存
@Log("查询汽车库存")
@RequestMapping("/carlist/query")
@ResponseBody
public List<Car> queryCar(@RequestBody HashMap<String,String> params)
String id_s = params.get("id");
String carname = params.get("carname");
String brand = params.get("brand");
String color = params.get("color");
String type = params.get("type");
String configuration = params.get("configuration");
String low_price = params.get("low_price");//需要转型
String hight_price = params.get("hight_price");//需要转型
Car car = new Car();
if(id_s!=null && !id_s.equals(""))
try
Long id = Long.valueOf(id_s);
car.setId(id);
catch (ClassCastException e)
finally
car.setBrand(brand);
car.setCarname(carname);
car.setColor(color);
car.setType(type);
car.setConfiguration(configuration);
car.setBrand(brand);
car.setCarname(carname);
car.setColor(color);
car.setType(type);
car.setConfiguration(configuration);
return carService.findCar(car,low_price,hight_price);
@Log("添加汽车库存")
@RequestMapping("/carlist/add")
public String carAdd(@RequestParam("add_brand") String brand,
@RequestParam("add_carname") String carname,
@RequestParam("add_price") Long price,
@RequestParam("add_color") String color,
@RequestParam("add_type") String type,
@RequestParam("add_quantity") Long quantity,
@RequestParam("add_configuration") String configuration,
RedirectAttributesModelMap model)
Car car = new Car(brand,carname,price,color,type,quantity,configuration);
int result =carService.addCar(car);
if(result==1)
model.addFlashAttribute("addmsg","添加车型成功");
else
model.addFlashAttribute("addmsg","添加车型失败,未知错误");
return "redirect:/carlist";
//跳转车辆库存管理页面
@RequestMapping("/carlist")
public String tocarlist()
return "carlist";
package com.gk.carshopsys.controller;
import com.alibaba.excel.EasyExcel;
import com.gk.carshopsys.annotation.Log;
import com.gk.carshopsys.pojo.Car;
import com.gk.carshopsys.pojo.CarOrder;
import com.gk.carshopsys.pojo.CarOrderImport;
import com.gk.carshopsys.pojo.Cust;
import com.gk.carshopsys.service.CarOrderService;
import com.gk.carshopsys.utils.CarDataListener;
import com.gk.carshopsys.utils.CarOrderDataListener;
import com.gk.carshopsys.utils.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class CarOrderController
@Autowired
CarOrderService carOrderService;
//Excel参数
private HashMap<String,String> param;
//excel传参
@PostMapping("/carorderlist/excelparamset")
@ResponseBody
public void excelset(@RequestBody HashMap<String,String> params)
param= params;
//excel下载
@Log("导出汽车订单")
@GetMapping("/carorderlist/excelexport")
@ResponseBody
public String excelexport(HttpServletResponse response) throws Exception
ExcelUtils.export2Web(response, "汽车订单表", "订单信息",CarOrder.class,carOrderService.findCarOrder(param));
return "success";
// easyexcel上传文件
@Log("导入汽车订单")
@PostMapping("/carorderlist/excelimport")
public String upload(MultipartFile file, RedirectAttributesModelMap model) throws IOException
EasyExcel.read(file.getInputStream(), CarOrderImport.class, new CarOrderDataListener(carOrderService)).sheet().doRead();
return "redirect:/carorderlist";
@RequestMapping("/carorderlist")
public String toCarOrder()
return "carorderlist";
@Log("查询汽车订单")
@RequestMapping("/carorderlist/query")
@ResponseBody
public List<CarOrder> quryCarOrderList(@RequestBody HashMap<String,String> params)
return carOrderService.findCarOrder(params);
@Log("添加汽车订单")
@RequestMapping("/carorderlist/add")
public String addCarOrder(@RequestParam("add_carid") Long carid,
@RequestParam("add_custid") Long custid,
@RequestParam("add_empnum") String empnum,
@RequestParam("add_quantity") Integer quantity,
@RequestParam("add_state") String state,
@RequestParam("add_remarks") String remarks, RedirectAttributesModelMap model)
int result = carOrderService.addCarOrder(carid,custid,empnum,quantity,state,remarks);
if (result==-1)
model.addFlashAttribute("addmsg","添加失败,车辆不存在");
return "redirect:/carorderlist";
if (result==-2)
model.addFlashAttribute("addmsg","添加失败,客户不存在");
return "redirect:/carorderlist";
if (result==-3)
model.addFlashAttribute("addmsg","添加失败,员工不存在");
return "redirect:/carorderlist";
if (result==-4)
model.addFlashAttribute("addmsg","添加失败,库存不足");
return "redirect:/carorderlist";
if (result==1)
model.addFlashAttribute("addmsg","添加订单成功");
return "redirect:/carorderlist";
else
model.addFlashAttribute("addmsg","添加订单失败,未知错误");
return "redirect:/carorderlist";
@Log("更新汽车订单")
@RequestMapping("/carorderlist/update")
public String updateCarOrder(@RequestParam("update_id") Long id,
@RequestParam("update_state") String state,
@RequestParam("update_remarks") String remarks,
@RequestParam("update_quantity") Long quantity,
@RequestParam("update_carid") Long carid,RedirectAttributesModelMap model)
CarOrder carOrder = new CarOrder();
carOrder.setId(id);
carOrder.setRemarks(remarks);
carOrder.setCarid(carid);
if(state.equals("取消订单"))
carOrder.setState("已取消");
else
carOrder.setState(state);
int result = carOrderService.updateCarOrderById(carOrder,quantity);
if (result==1)
model.addFlashAttribute("addmsg","修改订单成功");
return "redirect:/carorderlist";
else
model.addFlashAttribute("addmsg","修改订单失败,未知错误");
return "redirect:/carorderlist";
//批量删除订单
//订单批量删除
@Log("删除汽车订单")
@ResponseBody
@RequestMapping("/carorderlist/del")
public Map<String,Integer> carorderlistdel(@RequestBody List<Integer> ids)
int result = carOrderService.delCarOrder(ids);
Map<String,Integer> map = new HashMap<>();
map.put("code",result);
return map;
package com.gk.carshopsys.controller;
import com.alibaba.excel.EasyExcel;
import com.gk.carshopsys.annotation.Log;
import com.gk.carshopsys.pojo.Cust;
import com.gk.carshopsys.pojo.Emp;
import com.gk.carshopsys.service.CustService;
import com.gk.carshopsys.utils.CustDataListener;
import com.gk.carshopsys.utils.EmpDataListener;
import com.gk.carshopsys.utils.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class CustController
@Autowired
CustService custService;
//Excel参数
private HashMap<String,String> param;
//excel传参
@PostMapping("/custlist/excelparamset")
@ResponseBody
public void excelset(@RequestBody HashMap<String,String> params)
param= params;
//excel下载
@Log("导出客户")
@GetMapping("/custlist/excelexport")
@ResponseBody
public String excelexport(HttpServletResponse response) throws Exception
//导出的参数
String custid_s = param.get("custid");
String custname = param.get("custname");
String job = param.get("job");
String address = param.get("address");
Cust cust = new Cust();
if (custid_s!=null && !custid_s.equals(""))
try
Long custid=Long.parseLong(custid_s);
cust.setid(custid);
catch (ClassCastException e)
finally
cust.setCust_name(custname);
cust.setJob(job);
cust.setAddress(address);
ExcelUtils.export2Web(response, "客户表", "客户信息",Cust.class,custService.findCust(cust));
return "success";
else
cust.setCust_name(custname);
cust.setJob(job);
cust.setAddress(address);
ExcelUtils.export2Web(response, "客户表", "客户信息",Cust.class,custService.findCust(cust));
return "success";
// easyexcel上传文件
@Log("导入客户")
@PostMapping("/custlist/excelimport")
public String upload(MultipartFile file, RedirectAttributesModelMap model) throws IOException
EasyExcel.read(file.getInputStream(), Cust.class, new CustDataListener(custService)).sheet().doRead();
return "redirect:/custlist";
//跳转客户管理页面
@RequestMapping("/custlist")
public String tocustlist()
return "custlist";
//返回查询客户列表
@Log("查询客户")
@RequestMapping("/custlist/query")
@ResponseBody
public List<Cust> findcust(@RequestBody HashMap<String,String> params)
//接收的数据
String custid_s = params.get("custid");
String custname = params.get("custname");
String job = params.get("job");
String address = params.get("address");
Cust cust = new Cust();
if (custid_s!=null && !custid_s.equals(""))
try
Long custid=Long.parseLong(custid_s);
cust.setid(custid);
catch (ClassCastException e)
finally
cust.setCust_name(custname);
cust.setJob(job);
cust.setAddress(address);
return custService.findCust(cust);
else
cust.setCust_name(custname);
cust.setJob(job);
cust.setAddress(address);
return custService.findCust(cust);
// 添加客户
@Log("添加客户")
@PostMapping("/custlist/add")
public String addcust(@RequestParam("add_custname") String name,
@RequestParam("add_sex") String sex,
@RequestParam("add_job") String job,
@RequestParam("add_telphone") String telphone,
@RequestParam("add_address") String address,
RedirectAttributesModelMap model)
Cust add_cust =new Cust(name,sex,job,telphone,address);
int result = custService.addCust(add_cust);
if(result==1)
model.addFlashAttribute("addmsg","添加客户成功");
return "redirect:/custlist";
else
model.addFlashAttribute("addmsg","添加客户失败,未知错误");
return "redirect:/custlist";
//更新修改客户
@Log("更新客户")
@PostMapping("/custlist/update")
public String updatecust(@RequestParam("update_custid") Long id,
@RequestParam("update_custname") String name,
@RequestParam("update_sex") String sex,
@RequestParam("update_job") String job,
@RequestParam("update_telphone") String telphone,
@RequestParam("update_address") String address,
RedirectAttributesModelMap model)
Cust update_cust =new Cust(id,name,sex,job,telphone,address);
int result = custService.updateCust(update_cust);
if(result==1)
model.addFlashAttribute("updatemsg","修改客户成功");
return "redirect:/custlist";
else
model.addFlashAttribute("updatemsg","修改客户失败,未知错误");
return "redirect:/custlist";
//批量删除客户
//客户批量删除
@Log("删除客户")
@ResponseBody
@RequestMapping("/custlist/del")
public Map<String,Integer> custlistdel(@RequestBody List<Integer> ids)
int result = custService.delCust(ids);
Map<String,Integer> map = new HashMap<>();
map.put("code",result);
return map;
五,项目总结
项目整体设计简洁大方,功能实用性强,前后端交互比较符合人性化需求,比较适合用做毕业设计和课程设计使用。
以上是关于基于Springboot实现汽车4S店销售管理系统的主要内容,如果未能解决你的问题,请参考以下文章
计算机毕业设计springboot+vue+elementUI 4S店车辆销售维修管理系统
计算机毕业设计之java+springboot基于vue的4S店车辆管理系统