基于springboot实现功能超全企业进销存系统
Posted 编程指南针
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于springboot实现功能超全企业进销存系统相关的知识,希望对你有一定的参考价值。
作者主页:编程指南针
简介:20年开发经验、Java领域优质创作者、CSDN博客专家 Java项目、简历模板、学习资料、面试题库、技术互助
文末获取源码
↵
项目编号:BS-XX-099
后台开发:Springboot+mybatis+springmvc
前台开发:bootstrap+easyui+jquery+highcharts
数据库:mysql
开发工具:IDEA / ECLIPSE
应用服务器:TOMCAT8.5
本系统基于springboot实现了一个功能十分完整的企业进销存系统,主要功能包括:用户的登录注册、客户信息增添改查、来往客户信息查询等、商品的进货和销售、采购订单明细、销售订单明细、库存盘点、商品查询及分类、商品价格调整、进销存报表、商品库存预警、系统退出、角色管理、用户管理、权限分配、数据统计图形报表、等等,功能可以说是十分完整,整个系统设计简洁大方,运行无误。
下面展示一下系统的主要功能:
登陆页面:
管理主页面
系统管理-角色管理
系统管理-用户管理
基础资料-供应商管理
基础资料-客户管理
基础资料-商品分类和商品管理
基础资料-期初库存管理
统计报表—供应商统计
统计报表—按日统计
库存管理-商品报损
库存管理-库存报警
销售管理—销售出货
销售管理—销售单据查询
进货管理—进货入库
进货管理—进货单据查询
进货管理—退货出库
篇幅所限,只展示部分功能,整体来说,此系统还是十分优秀,包含了进销存常见所有的功能需求。
部分核心实现代码:
package com.jude.controller.admin;
import com.jude.service.LogService;
import com.jude.entity.Customer;
import com.jude.entity.Log;
import com.jude.service.CustomerService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 后台管理客户Controller
* @author znz
*
*/
@RestController
@RequestMapping("/admin/customer")
public class CustomerAdminController
@Resource
private CustomerService customerService;
@Resource
private LogService logService;
/**
* 分页查询客户信息
* @param customer
* @param page
* @param rows
* @return
* @throws Exception
*/
@RequestMapping("/list")
@RequiresPermissions(value = "客户管理" )
public Map<String,Object> list(Customer customer, @RequestParam(value="page",required=false)Integer page, @RequestParam(value="rows",required=false)Integer rows)throws Exception
List<Customer> customerList=customerService.list(customer, page, rows, Direction.ASC, "id");
Long total=customerService.getCount(customer);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("rows", customerList);
resultMap.put("total", total);
logService.save(new Log(Log.SEARCH_ACTION,"查询客户信息")); // 写入日志
return resultMap;
/**
* 下拉框模糊查询
* @param q
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/comboList")
@RequiresPermissions(value = "销售出库","客户退货","销售单据查询","客户退货查询",logical=Logical.OR)
public List<Customer> comboList(String q)throws Exception
if(q==null)
q="";
return customerService.findByName("%"+q+"%");
/**
* 添加或者修改客户信息
* @param customer
* @return
* @throws Exception
*/
@RequestMapping("/save")
@RequiresPermissions(value = "客户管理" )
public Map<String,Object> save(Customer customer)throws Exception
if(customer.getId()!=null) // 写入日志
logService.save(new Log(Log.UPDATE_ACTION,"更新客户信息"+customer));
else
logService.save(new Log(Log.ADD_ACTION,"添加客户信息"+customer));
Map<String, Object> resultMap = new HashMap<>();
customerService.save(customer);
resultMap.put("success", true);
return resultMap;
/**
* 删除客户信息
* @param id
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/delete")
@RequiresPermissions(value = "客户管理" )
public Map<String,Object> delete(String ids)throws Exception
Map<String, Object> resultMap = new HashMap<>();
String []idsStr=ids.split(",");
for(int i=0;i<idsStr.length;i++)
int id=Integer.parseInt(idsStr[i]);
logService.save(new Log(Log.DELETE_ACTION,"删除客户信息"+customerService.findById(id))); // 写入日志
customerService.delete(id);
resultMap.put("success", true);
return resultMap;
package com.jude.controller.admin;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jude.service.CustomerReturnListGoodsService;
import com.jude.service.CustomerReturnListService;
import com.jude.service.LogService;
import com.jude.util.DateUtil;
import com.jude.util.StringUtil;
import com.jude.entity.CustomerReturnList;
import com.jude.entity.CustomerReturnListGoods;
import com.jude.entity.Log;
import com.jude.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 客户退货单Controller类
* @author Administrator
*
*/
@RestController
@RequestMapping("/admin/customerReturnList")
public class CustomerReturnListAdminController
@Resource
private CustomerReturnListService customerReturnListService;
@Resource
private CustomerReturnListGoodsService customerReturnListGoodsService;
@Resource
private LogService logService;
@Resource
private UserService userService;
@InitBinder
public void initBinder(WebDataBinder binder)
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(true);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); //true:允许输入空值,false:不能为空值
/**
* 根据条件分页查询客户退货单信息
* @param customerReturnList
* @param page
* @param rows
* @return
* @throws Exception
*/
@RequestMapping("/list")
@RequiresPermissions(value = "客户退货查询" )
public Map<String,Object> list(CustomerReturnList customerReturnList)throws Exception
Map<String, Object> resultMap = new HashMap<>();
List<CustomerReturnList> customerReturnListList=customerReturnListService.list(customerReturnList, Direction.DESC, "customerReturnDate");
resultMap.put("rows", customerReturnListList);
return resultMap;
/**
* 根据客户退货单id查询所有客户退货单商品
* @param customerReturnListId
* @return
* @throws Exception
*/
@RequestMapping("/listGoods")
@RequiresPermissions(value = "客户退货查询" )
public Map<String,Object> listGoods(Integer customerReturnListId)throws Exception
if(customerReturnListId==null)
return null;
Map<String, Object> resultMap = new HashMap<>();
List<CustomerReturnListGoods> customerReturnListGoodsList=customerReturnListGoodsService.listByCustomerReturnListId(customerReturnListId);
resultMap.put("rows", customerReturnListGoodsList);
return resultMap;
/**
* 客户统计 获取客户退货单的所有商品信息
* @param purchaseList
* @param purchaseListGoods
* @return
* @throws Exception
*/
@RequestMapping("/listCount")
@RequiresPermissions(value = "客户统计" )
public Map<String,Object> listCount(CustomerReturnList customerReturnList,CustomerReturnListGoods customerReturnListGoods)throws Exception
Map<String, Object> resultMap = new HashMap<>();
List<CustomerReturnList> customerReturnListList=customerReturnListService.list(customerReturnList, Direction.DESC, "customerReturnDate");
for(CustomerReturnList crl:customerReturnListList)
customerReturnListGoods.setCustomerReturnList(crl);
List<CustomerReturnListGoods> crlList=customerReturnListGoodsService.list(customerReturnListGoods);
for(CustomerReturnListGoods crlg:crlList)
crlg.setCustomerReturnList(null);
crl.setCustomerReturnListGoodsList(crlList);
resultMap.put("rows", customerReturnListList);
return resultMap;
/**
* 获取客户退货单号
* @param type
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/getCustomerReturnNumber")
@RequiresPermissions(value = "客户退货")
public String genBillCode(String type)throws Exception
StringBuffer biilCodeStr=new StringBuffer();
biilCodeStr.append("XT");
biilCodeStr.append(DateUtil.getCurrentDateStr()); // 拼接当前日期
String customerReturnNumber=customerReturnListService.getTodayMaxCustomerReturnNumber(); // 获取当天最大的客户退货单号
if(customerReturnNumber!=null)
biilCodeStr.append(StringUtil.formatCode(customerReturnNumber));
else
biilCodeStr.append("0001");
return biilCodeStr.toString();
/**
* 添加客户退货单 以及所有客户退货单商品
* @param customerReturnList
* @param goodsJson
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
@RequiresPermissions(value = "客户退货")
public Map<String,Object> save(CustomerReturnList customerReturnList,String goodsJson)throws Exception
Map<String, Object> resultMap = new HashMap<>();
customerReturnList.setUser(userService.findByUserName((String) SecurityUtils.getSubject().getPrincipal())); // 设置操作用户
Gson gson = new Gson();
List<CustomerReturnListGoods> plgList=gson.fromJson(goodsJson, new TypeToken<List<CustomerReturnListGoods>>().getType());
customerReturnListService.save(customerReturnList, plgList);
logService.save(new Log(Log.ADD_ACTION,"添加客户退货单"));
resultMap.put("success", true);
return resultMap;
/**
* 修改退货单的支付状态
* @param id
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/update")
@RequiresPermissions(value = "客户统计")
public Map<String,Object> update(Integer id)throws Exception
Map<String, Object> resultMap = new HashMap<>();
CustomerReturnList customerReturnList=customerReturnListService.findById(id);
customerReturnList.setState(1); // 修改成支付状态
customerReturnListService.update(customerReturnList);
resultMap.put("success", true);
return resultMap;
/**
* 根据id删除客户退货单信息 包括客户退货单里的商品
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/delete")
@RequiresPermissions(value = "客户退货查询" )
public Map<String,Object> delete(Integer id)throws Exception
Map<String, Object> resultMap = new HashMap<>();
customerReturnListService.delete(id);
logService.save(new Log(Log.DELETE_ACTION,"删除客户退货单信息"+customerReturnListService.findById(id))); // 写入日志
resultMap.put("success", true);
return resultMap;
package com.jude.controller.admin;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jude.entity.PurchaseListGoods;
import com.jude.service.LogService;
import com.jude.util.StringUtil;
import com.jude.entity.Log;
import com.jude.entity.PurchaseList;
import com.jude.service.PurchaseListGoodsService;
import com.jude.service.PurchaseListService;
import com.jude.service.UserService;
import com.jude.util.DateUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 进货单Controller类
* @author Administrator
*
*/
@RestController
@RequestMapping("/admin/purchaseList")
public class PurchaseListAdminController
@Resource
private PurchaseListService purchaseListService;
@Resource
private PurchaseListGoodsService purchaseListGoodsService;
@Resource
private LogService logService;
@Resource
private UserService userService;
@InitBinder
public void initBinder(WebDataBinder binder)
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(true);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); //true:允许输入空值,false:不能为空值
/**
* 根据条件分页查询进货单信息
* @param purchaseList
* @param page
* @param rows
* @return
* @throws Exception
*/
@RequestMapping("/list")
@RequiresPermissions(value = "进货单据查询" )
public Map<String,Object> list(PurchaseList purchaseList)throws Exception
Map<String, Object> resultMap = new HashMap<>();
List<PurchaseList> purchaseListList=purchaseListService.list(purchaseList, Direction.DESC, "purchaseDate");
resultMap.put("rows", purchaseListList);
return resultMap;
/**
* 根据进货单id查询所有进货单商品
* @param purchaseListId
* @return
* @throws Exception
*/
@RequestMapping("/listGoods")
@RequiresPermissions(value = "进货单据查询" )
public Map<String,Object> listGoods(Integer purchaseListId)throws Exception
if(purchaseListId==null)
return null;
Map<String, Object> resultMap = new HashMap<>();
List<PurchaseListGoods> purchaseListGoodsList=purchaseListGoodsService.listByPurchaseListId(purchaseListId);
resultMap.put("rows", purchaseListGoodsList);
return resultMap;
/**
* 客户统计 获取进货单的所有商品信息
* @param purchaseList
* @param purchaseListGoods
* @return
* @throws Exception
*/
@RequestMapping("/listCount")
@RequiresPermissions(value = "客户统计" )
public Map<String,Object> listCount(PurchaseList purchaseList,PurchaseListGoods purchaseListGoods)throws Exception
Map<String, Object> resultMap = new HashMap<>();
List<PurchaseList> purchaseListList=purchaseListService.list(purchaseList, Direction.DESC, "purchaseDate");
for(PurchaseList pl:purchaseListList)
purchaseListGoods.setPurchaseList(pl);
List<PurchaseListGoods> plgList=purchaseListGoodsService.list(purchaseListGoods);
for(PurchaseListGoods plg:plgList)
plg.setPurchaseList(null);
pl.setPurchaseListGoodsList(plgList);
resultMap.put("rows", purchaseListList);
return resultMap;
/**
* 获取进货单号
* @param type
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/getPurchaseNumber")
@RequiresPermissions(value = "进货入库")
public String genBillCode(String type)throws Exception
StringBuffer biilCodeStr=new StringBuffer();
biilCodeStr.append("JH");
biilCodeStr.append(DateUtil.getCurrentDateStr()); // 拼接当前日期
String purchaseNumber=purchaseListService.getTodayMaxPurchaseNumber(); // 获取当天最大的进货单号
if(purchaseNumber!=null)
biilCodeStr.append(StringUtil.formatCode(purchaseNumber));
else
biilCodeStr.append("0001");
return biilCodeStr.toString();
/**
* 添加进货单 以及所有进货单商品 以及 修改商品的成本均价
* @param purchaseList
* @param goodsJson
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
@RequiresPermissions(value = "进货入库")
public Map<String,Object> save(PurchaseList purchaseList,String goodsJson)throws Exception
Map<String, Object> resultMap = new HashMap<>();
purchaseList.setUser(userService.findByUserName((String) SecurityUtils.getSubject().getPrincipal())); // 设置操作用户
Gson gson = new Gson();
List<PurchaseListGoods> plgList=gson.fromJson(goodsJson, new TypeToken<List<PurchaseListGoods>>().getType());
purchaseListService.save(purchaseList, plgList);
logService.save(new Log(Log.ADD_ACTION,"添加进货单"));
resultMap.put("success", true);
return resultMap;
/**
* 修改进货单的支付状态
* @param id
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/update")
@RequiresPermissions(value = "供应商统计")
public Map<String,Object> update(Integer id)throws Exception
Map<String, Object> resultMap = new HashMap<>();
PurchaseList purchaseList=purchaseListService.findById(id);
purchaseList.setState(1); // 修改成支付状态
purchaseListService.update(purchaseList);
resultMap.put("success", true);
return resultMap;
/**
* 根据id删除进货单信息 包括进货单里的商品
* @param id
* @return
* @throws Exception
*/
@RequestMapping("/delete")
@RequiresPermissions(value = "进货单据查询" )
public Map<String,Object> delete(Integer id)throws Exception
Map<String, Object> resultMap = new HashMap<>();
purchaseListService.delete(id);
logService.save(new Log(Log.DELETE_ACTION,"删除进货单信息"+purchaseListService.findById(id))); // 写入日志
resultMap.put("success", true);
return resultMap;
package com.jude.controller.admin;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.jude.entity.Log;
import com.jude.entity.Menu;
import com.jude.entity.Role;
import com.jude.service.*;
import com.jude.util.StringUtil;
import com.jude.entity.RoleMenu;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* 后台管理角色Controller
* @author znz
*
*/
@RestController
@RequestMapping("/admin/role")
public class RoleAdminController
@Resource
private RoleService roleService;
@Resource
private UserRoleService userRoleService;
@Resource
private MenuService menuService;
@Resource
private RoleMenuService roleMenuService;
@Resource
private LogService logService;
/**
* 查询所有角色
* @return
* @throws Exception
*/
@RequestMapping("/listAll")
@RequiresPermissions(value = "角色管理" )
public Map<String,Object> listAll()throws Exception
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("rows", roleService.listAll());
logService.save(new Log(Log.SEARCH_ACTION,"查询所有角色信息")); // 写入日志
return resultMap;
/**
* 分页查询角色信息
* @param user
* @param page
* @param rows
* @return
* @throws Exception
*/
@RequestMapping("/list")
@RequiresPermissions(value = "角色管理" )
public Map<String,Object> list(Role role, @RequestParam(value="page",required=false)Integer page, @RequestParam(value="rows",required=false)Integer rows)throws Exception
List<Role> roleList=roleService.list(role, page, rows, Direction.ASC, "id");
Long total=roleService.getCount(role);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("rows", roleList);
resultMap.put("total", total);
logService.save(new Log(Log.SEARCH_ACTION,"查询角色信息")); // 写入日志
return resultMap;
/**
* 添加或者修改角色信息
* @param role
* @return
* @throws Exception
*/
@RequestMapping("/save")
@RequiresPermissions(value = "角色管理" )
public Map<String,Object> save(Role role)throws Exception
if(role.getId()!=null) // 写入日志
logService.save(new Log(Log.UPDATE_ACTION,"更新角色信息"+role));
else
logService.save(new Log(Log.ADD_ACTION,"添加角色信息"+role));
Map<String, Object> resultMap = new HashMap<>();
roleService.save(role);
resultMap.put("success", true);
return resultMap;
/**
* 删除角色信息
* @param id
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/delete")
@RequiresPermissions(value = "角色管理" )
public Map<String,Object> delete(Integer id)throws Exception
logService.save(new Log(Log.DELETE_ACTION,"删除角色信息"+roleService.findById(id))); // 写入日志
Map<String, Object> resultMap = new HashMap<>();
userRoleService.deleteByRoleId(id); // 删除用户角色关联信息
roleService.delete(id);
resultMap.put("success", true);
return resultMap;
/**
* 根据父节点获取所有复选框权限菜单树
* @param parentId
* @param roleId
* @return
* @throws Exception
*/
@PostMapping("/loadCheckMenuInfo")
@RequiresPermissions(value = "角色管理" )
public String loadCheckMenuInfo(Integer parentId,Integer roleId)throws Exception
List<Menu> menuList=menuService.findByRoleId(roleId); // 根据角色查询所有权限菜单信息
List<Integer> menuIdList=new LinkedList<Integer>();
for(Menu menu:menuList)
menuIdList.add(menu.getId());
return getAllCheckedMenuByParentId(parentId,menuIdList).toString();
/**
* 根据父节点ID和权限菜单ID集合获取复选框菜单节点
* @param parentId
* @param menuIdList
* @return
*/
private JsonArray getAllCheckedMenuByParentId(Integer parentId,List<Integer> menuIdList)
JsonArray jsonArray=this.getCheckedMenuByParentId(parentId, menuIdList);
for(int i=0;i<jsonArray.size();i++)
JsonObject jsonObject=(JsonObject) jsonArray.get(i);
if("open".equals(jsonObject.get("state").getAsString()))
continue;
else
jsonObject.add("children", getAllCheckedMenuByParentId(jsonObject.get("id").getAsInt(),menuIdList));
return jsonArray;
/**
* 根据父节点ID和权限菜单ID集合获取复选框菜单节点
* @param parentId
* @param menuIdList
* @return
*/
private JsonArray getCheckedMenuByParentId(Integer parentId,List<Integer> menuIdList)
List<Menu> menuList=menuService.findByParentId(parentId);
JsonArray jsonArray=new JsonArray();
for(Menu menu:menuList)
JsonObject jsonObject=new JsonObject();
int menuId=menu.getId();
jsonObject.addProperty("id", menuId); // 节点id
jsonObject.addProperty("text", menu.getName()); // 节点名称
if(menu.getState()==1)
jsonObject.addProperty("state", "closed"); // 根节点
else
jsonObject.addProperty("state", "open"); // 叶子节点
if(menuIdList.contains(menuId))
jsonObject.addProperty("checked", true);
jsonObject.addProperty("iconCls", menu.getIcon());
jsonArray.add(jsonObject);
return jsonArray;
/**
* 保存角色权限设置
* @param menuIds
* @param roleId
* @return
* @throws Exception
*/
@RequestMapping("/saveMenuSet")
@RequiresPermissions(value = "角色管理" )
public Map<String,Object> saveMenuSet(String menuIds,Integer roleId)throws Exception
Map<String, Object> resultMap = new HashMap<>();
roleMenuService.deleteByRoleId(roleId); // 根据角色id删除所有角色权限关联实体
if(StringUtil.isNotEmpty(menuIds))
String idsStr[]=menuIds.split(",");
for(int i=0;i<idsStr.length;i++) // 然后添加所有角色权限关联实体
RoleMenu roleMenu=new RoleMenu();
roleMenu.setRole(roleService.findById(roleId));
roleMenu.setMenu(menuService.findById(Integer.parseInt(idsStr[i])));
roleMenuService.save(roleMenu);
resultMap.put("success", true);
logService.save(new Log(Log.ADD_ACTION,"保存角色权限设置")); // 写入日志
return resultMap;
以上是关于基于springboot实现功能超全企业进销存系统的主要内容,如果未能解决你的问题,请参考以下文章
基于javaweb仓库理系统设计与实现进销存管理.rar(论文+毕业设计+源码+答辩PPT)