项目编号: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 list(Customer customer, @RequestParam(value="page",required=false)Integer page, @RequestParam(value="rows",required=false)Integer rows)throws Exception{
List customerList=customerService.list(customer, page, rows, Direction.ASC, "id");
Long total=customerService.getCount(customer);
Map 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 comboList(String q)throws Exception{
if(q==null){
q="";
}
return customerService.findByName("%"+q+"%");
}
/**
* 添加或者修改客户信息
* @param customer
* @return
* @throws Exception
*/
@RequestMapping("/save")
@RequiresPermissions(value = { "客户管理" })
public Map 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 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 delete(String ids)throws Exception{
Map resultMap = new HashMap<>();
String []idsStr=ids.split(",");
for(int i=0;i
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 list(CustomerReturnList customerReturnList)throws Exception{
Map resultMap = new HashMap<>();
List 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 listGoods(Integer customerReturnListId)throws Exception{
if(customerReturnListId==null){
return null;
}
Map resultMap = new HashMap<>();
List customerReturnListGoodsList=customerReturnListGoodsService.listByCustomerReturnListId(customerReturnListId);
resultMap.put("rows", customerReturnListGoodsList);
return resultMap;
}
/**
* 客户统计 获取客户退货单的所有商品信息
* @param purchaseList
* @param purchaseListGoods
* @return
* @throws Exception
*/
@RequestMapping("/listCount")
@RequiresPermissions(value = { "客户统计" })
public Map listCount(CustomerReturnList customerReturnList,CustomerReturnListGoods customerReturnListGoods)throws Exception{
Map resultMap = new HashMap<>();
List customerReturnListList=customerReturnListService.list(customerReturnList, Direction.DESC, "customerReturnDate");
for(CustomerReturnList crl:customerReturnListList){
customerReturnListGoods.setCustomerReturnList(crl);
List 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 save(CustomerReturnList customerReturnList,String goodsJson)throws Exception{
Map resultMap = new HashMap<>();
customerReturnList.setUser(userService.findByUserName((String) SecurityUtils.getSubject().getPrincipal())); // 设置操作用户
Gson gson = new Gson();
List plgList=gson.fromJson(goodsJson, new TypeToken>(){}.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 update(Integer id)throws Exception{
Map 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 delete(Integer id)throws Exception{
Map 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 list(PurchaseList purchaseList)throws Exception{
Map resultMap = new HashMap<>();
List 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 listGoods(Integer purchaseListId)throws Exception{
if(purchaseListId==null){
return null;
}
Map resultMap = new HashMap<>();
List purchaseListGoodsList=purchaseListGoodsService.listByPurchaseListId(purchaseListId);
resultMap.put("rows", purchaseListGoodsList);
return resultMap;
}
/**
* 客户统计 获取进货单的所有商品信息
* @param purchaseList
* @param purchaseListGoods
* @return
* @throws Exception
*/
@RequestMapping("/listCount")
@RequiresPermissions(value = { "客户统计" })
public Map listCount(PurchaseList purchaseList,PurchaseListGoods purchaseListGoods)throws Exception{
Map resultMap = new HashMap<>();
List purchaseListList=purchaseListService.list(purchaseList, Direction.DESC, "purchaseDate");
for(PurchaseList pl:purchaseListList){
purchaseListGoods.setPurchaseList(pl);
List 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 save(PurchaseList purchaseList,String goodsJson)throws Exception{
Map resultMap = new HashMap<>();
purchaseList.setUser(userService.findByUserName((String) SecurityUtils.getSubject().getPrincipal())); // 设置操作用户
Gson gson = new Gson();
List plgList=gson.fromJson(goodsJson, new TypeToken>(){}.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 update(Integer id)throws Exception{
Map 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 delete(Integer id)throws Exception{
Map 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 listAll()throws Exception{
Map 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 list(Role role, @RequestParam(value="page",required=false)Integer page, @RequestParam(value="rows",required=false)Integer rows)throws Exception{
List roleList=roleService.list(role, page, rows, Direction.ASC, "id");
Long total=roleService.getCount(role);
Map 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 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 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 delete(Integer id)throws Exception{
logService.save(new Log(Log.DELETE_ACTION,"删除角色信息"+roleService.findById(id))); // 写入日志
Map 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