作者主页:Java毕设网
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
一、项目介绍
自助售货管理系统,该系统分为前后台,两个项目,前台项目为autosale-1,后台项目为automanager1;启动时需要先启动automanager1,再启动autosale-1,否则会造成启动不成功的问题;
前台主要功能包括:
轮播图展示、商品列表、支付宝沙箱环境支付,注:需要配置自己的沙箱环境;
后台主要包括三种角色:管理员、维修员、补货员;
管理员主要功能包括:
员工管理、商品管理、商品类型管理、设备管理、销售报表、财务统计;
注:autosale默认启动的贩卖机编号为21,若想要添加商品,首先在商品管理中添加商品;然后在设备管理中,找到贩卖机编号为21的,查看设备状态是否为正常,若为正常,则点击管理设备按钮,然后点击上架,选择需要上架的商品即可;
维修员主要功能包括:
待维修请求处理、全部维修信息、所属设备列表;
补货员主要功能包括:
待补货请求处理、全部补货请求信息、所属设备列表;
二、环境需要
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项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
7.Zookeeper;
三、技术栈
1. 后端:SpringBoot + DUBBO
2. 前端:JSP+bootstrap+jQuery
四、使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置;
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,售卖端输入http://localhost:8084/autosale/ 登录
管理端输入:http://localhost:8088/autom/
五、运行截图
六、相关代码
选择管理控制器
/**
* @author YX
* @category 选择设备类型id、补货员id、维修员id的控制器
*/
@RestController
@RequestMapping("/chooseid")
public class ChooseIdController {
@Autowired
private VendermachinetypeService vendermachinetypeService;
@Autowired
private IServiceempService iServiceempService;
@Autowired
private ReplenishempService replenishempService;
//选择设备类型id
@RequestMapping("/chooseid")
public List<Vendermachinetype> chooseId(@RequestParam(value = "typeId", required = false) String typeId ,@RequestParam(value = "tid", required = false)Integer tid) {
List<Vendermachinetype> list = null;
if(typeId.equals("1")) {
list = vendermachinetypeService.findAll();
}
return list;
}
//选择补货员id
@RequestMapping("/chooserid")
public List<ReplenishempVO> chooseRid(@RequestParam(value = "areaid", required = false) String areaid ){
System.out.println(areaid);
return replenishempService.findByAreaid(areaid);
}
//选择维修员id
@RequestMapping("/choosesid")
public List<ServiceempVO> chooseSid(@RequestParam(value = "areaid", required = false) String areaid){
return iServiceempService.findByAreaid(areaid);
}
}
商品管理控制器
/**
* @author zxh
* @category 商品类控制器
*/
@Controller
@RequestMapping("/goods")
public class GoodsController {
@Autowired
private IGoodsService igoodsService;
@Autowired
private Page page;
/**
* @category 商品列表展示控制器
* @param model
* @param currentPage1
* @param pageSize1
* @return
*/
@RequestMapping("/showgoodslist")
public String findGoodsList(Model model, @RequestParam(value = "pageNum", required = false) String currentPage1,
@RequestParam(value = "pagesize", required = false) String pageSize1) {
int currentPage = currentPage1 == null ? 1 : Integer.valueOf(currentPage1);
int pageSize = pageSize1 == null ? 10 : Integer.valueOf(pageSize1);
int listCount = igoodsService.getGoodsPageCount();
List<GoodsVO> list = igoodsService.findGoodsList(currentPage, pageSize);
page.setValue(currentPage, pageSize, listCount);
model.addAttribute("page", page);
model.addAttribute("list", list);
System.out.println(list.size());
for (GoodsVO goodsVO : list) {
System.out.println(goodsVO.getGname());
}
return "goods/goods";
}
/**
* @category 查询所有商品控制器
* @return
*/
@RequestMapping("/findallgoods")
public @ResponseBody List<GoodsVO> findAllGoods() {
List<GoodsVO> list = igoodsService.findAllGoods();
return list;
}
/**
* @category 通过商品编号查询商品控制器
* @param gid
* @return
*/
@RequestMapping("/findbygid")
public @ResponseBody GoodsVO findById(Integer gid) {
GoodsVO goodsVO = igoodsService.findById(gid);
return goodsVO;
}
/**
* @category 通过商品名查询商品控制器
* @param gname
* @return
*/
@RequestMapping("/findbygname")
public @ResponseBody GoodsVO findByName(String gname) {
GoodsVO goodsVO = igoodsService.findByName(gname);
return goodsVO;
}
/**
* @category 删除商品控制器
* @param gid
* @return
*/
@RequestMapping("/deletebygid")
public String deleteById(Integer gid) {
igoodsService.deleteById(gid);
return "redirect:/goods/showgoodslist";
}
/**
* @category 跳转修改商品界面控制器
* @param model
* @param gid
* @return
*/
@RequestMapping("/toupdategoods")
public String update(Model model, @PathParam("gid") Integer gid) {
GoodsVO goodsVO = igoodsService.findById(gid);
model.addAttribute("gvo", goodsVO);
return "goods/updategoods";
}
/**
* @category 修改商品信息控制器
* @param goods
* @return
*/
@RequestMapping("/updategoods")
public String updateSave(Goods goods) {
igoodsService.update(goods);
return "forward:showgoodslist.action";
}
/**
* @category 添加商品控制器
* @param goods
* @return
* @throws IOException
* @throws IllegalStateException
*/
@RequestMapping("/addgoods")
public String insertGoods(Goods goods, Model model) throws IllegalStateException, IOException {
// 保存数据库的路径
String sqlPath = null;
// 定义autosale-1/src/main/webapp/static/images/的本地路径 windows系统参考此修改;
//String localPath = "D:\\autosale-1\\src\\main\\webapp\\static\\images\\";
// 定义autosale-1/src/main/webapp/static/images/的本地路径 Mac系统参考此修改;
String localPath = "/Users/hanmeng/Desktop/java源码/Springboot/019springboot自助售货管理系统(含报告)/源码/autosale-1/src/main/webapp/static/images/";
// 定义文件名
String filename = null;
if (!goods.getFile().isEmpty()) {
// 生成uuid作为文件名
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
// 获得文件类型(可以判断如果不是图片,禁止上传)
String contentType = goods.getFile().getContentType();
// 获得文件后缀名
String suffixName = contentType.substring(contentType.indexOf("/") + 1);
// 得到文件名
filename = uuid + "." + suffixName;
// 文件保存路径
goods.getFile().transferTo(new File(localPath + filename));
}
// 把图片的相对路径保存至数据库
sqlPath = "/images/" + filename;
System.out.println(sqlPath);
goods.setImg(sqlPath);
igoodsService.insertGoods(goods);
model.addAttribute("goods", goods);
return "forward:showgoodslist.action";
}
}
商品类型管理控制器
/**
* @author zxh
* @category 商品类型控制器
*/
@Controller
@RequestMapping("/gtype")
public class GoodsTypeController {
@Autowired
private IGoodsTypeService igoodsTypeService;
@Autowired
private IGoodsService igoodsService;
@Autowired
private Goods goods;
@Autowired
private Page page;
/**
* @category 商品类型列表展示控制器
* @param model
* @param currentPage1
* @param pageSize1
* @return
*/
@RequestMapping("/gtypelist")
public String findGoodsTypeList(Model model,@RequestParam(value="pageNum",required=false)String currentPage1,@RequestParam(value = "pagesize", required = false)String pageSize1) {
int currentPage = currentPage1 == null ? 1 : Integer.valueOf(currentPage1);
int pageSize = pageSize1 == null ? 10 : Integer.valueOf(pageSize1);
int listCount = igoodsTypeService.getGoodsTypePageCount();
List<Goodstype> list = igoodsTypeService.findGoodsTypeList(currentPage, pageSize);
page.setValue(currentPage, pageSize, listCount);
model.addAttribute("page", page);
model.addAttribute("list", list);
System.out.println(list.size());
for (Goodstype goodstype : list) {
System.out.println(goodstype.getGtypename());
}
return "goods/goodstype";
}
/**
* @category 查询所有商品类型控制器
* @return
*/
@RequestMapping("/showgtype")
public @ResponseBody List<Goodstype> findAllGoodsType(@RequestParam(value = "typeId", required = false) String typeId ,@RequestParam(value = "gtype", required = false)Integer gtype){
List<Goodstype> list = null;
if(typeId.equals("1")) {
list = igoodsTypeService.findAllGoodsType();
}
return list;
}
/**
* @category 通过类型编号查询商品类型控制器
* @param gtype
* @return
*/
@RequestMapping("/findgtype")
public @ResponseBody Goodstype findByGtype(Integer gtype) {
Goodstype goodstype = igoodsTypeService.findByGtype(gtype);
return goodstype;
}
/**
* @category 通过类型名查询商品类型控制器
* @param gtypename
* @return
*/
@RequestMapping("/findbytypename")
public @ResponseBody Goodstype findByGtypeName(String gtypename) {
Goodstype goodstype = igoodsTypeService.findByGtypeName(gtypename);
return goodstype;
}
/**
* @category 根据商品类型查询商品列表控制器
* @param model
* @param session
* @param currentPage1
* @param pageSize1
* @return
*/
@RequestMapping("/findgoodsbygtype")
public String findByGType(Model model, Integer gtype,HttpSession session,@RequestParam(value="pageNum",required=false)String currentPage1,@RequestParam(value = "pagesize", required = false)String pageSize1) {
int currentPage = currentPage1 == null ? 1 : Integer.valueOf(currentPage1);
int pageSize = pageSize1 == null ? 10 : Integer.valueOf(pageSize1);
int listCount = igoodsTypeService.getGoodsCountByGType(gtype);
List<GoodsVO> list = igoodsTypeService.findGoodsByGType(gtype, currentPage, pageSize);
page.setValue(currentPage, pageSize, listCount);
model.addAttribute("page", page);
model.addAttribute("list", list);
Goodstype goodstype = igoodsTypeService.findByGtype(gtype);
model.addAttribute("goodstype", goodstype);
System.out.println(list.size());
for (GoodsVO goodsVO : list) {
System.out.println(goodsVO.getGname());
}
return "goods/typegoods";
}
/**
* @category 跳转添加某一类商品控制器
* @param model
* @param gtype
* @return
*/
@RequestMapping("/toaddtypegoods")
public String toAddTypeGoods(Model model,@PathParam("gtype")Integer gtype) {
Goodstype goodstype = igoodsTypeService.findByGtype(gtype);
model.addAttribute("goodstype", goodstype);
goods.setValues(null,null, null, goodstype.getGtype(), null, null);
return "goods/addtypegoods";
}
/**
* @category 添加某一类型商品
* @param model
* @param goodstype
* @param goods
* @return
*/
@RequestMapping("/addtypegoods")
public String addTypeGoods(Model model,@PathParam("goods")Goods goods,@PathParam("gtype")Integer gtype) {
model.addAttribute("gtype", gtype);
System.out.println(gtype+"=======================================================");
goods.setGtype(gtype);
igoodsService.insertGoods(goods);
return "redirect:/gtype/findgoodsbygtype?gtype="+goods.getGtype();
}
/**
* @category 删除该类型下的商品
* @param gid
* @return
*/
@RequestMapping("/deltypegoodsbygid")
public String deleteById(Model model,@PathParam("gid")Integer gid) {
GoodsVO goodsVO = igoodsService.findById(gid);
boolean flag = igoodsService.deleteById(gid);
if(flag == false) {
model.addAttribute("msg", "删除失败,请重试!");
}
return "redirect:/gtype/findgoodsbygtype?gtype="+goodsVO.getGtype();
}
/**
* @category 删除商品类型控制器
* @param gtype
* @return
*/
@RequestMapping("/deletegtype")
public String deleteByGtype(Model model,@PathParam("gtype")Integer gtype) {
boolean flag = igoodsTypeService.deleteByGtype(gtype);
if(flag == false) {
model.addAttribute("msg", "删除失败,请重试!");
}
return "redirect:/gtype/gtypelist";
}
/**
* @category 跳转修改商品类型界面控制器
* @param model
* @param gid
* @return
*/
@RequestMapping("/toupdategtype")
public String update(Model model,Integer gtype) {
Goodstype goodstype = igoodsTypeService.findByGtype(gtype);
model.addAttribute("goodstype", goodstype);
return "goods/updategtype";
}
/**
* @category 修改商品类型控制器
* @param goods
* @return
*/
@RequestMapping("/updategtype")
public String updateGoodsType(Goodstype goodstype) {
igoodsTypeService.updateGoodsType(goodstype);
return "forward:gtypelist.action";
}
/**
* @category 添加商品类型控制器
* @param goods
* @return
*/
@RequestMapping("/addgtype")
public String insertGoods(Goodstype goodstype) {
igoodsTypeService.addGoodstype(goodstype);
return "forward:gtypelist.action";
}
/**
* @category 跳转到商品类型统计图界面
* @return
*/
@RequestMapping("/togtypemap")
public String toShowMap() {
return "goods/goodstypemap";
}
/**
* @category 商品类型统计控制器
* @return
*/
@RequestMapping("/gtypemap")
public @ResponseBody Map<Object, Object> getGoodsTypeCount(){
Map<Object, Object> bigMap = new HashMap<>();
Map<String, Integer> map = igoodsTypeService.getGoodsTypeCount();
//遍历Map
List<EchartsEntity> list = new ArrayList<EchartsEntity>();
for (Map.Entry<String, Integer> entry : map.entrySet()) {
//将名字和数字存放在VO对象内
EchartsEntity ec = new EchartsEntity(entry.getKey(),entry.getValue());
//将对象存放到list集合内
list.add(ec);
}
bigMap.put("keys", map.keySet());
bigMap.put("values", map.values());
bigMap.put("list", list);
return bigMap;
}
}