基于javaweb+mysql的springboot仓库管理系统(java+springboot+layui+html+thymeleaf+mysql+maven)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot仓库管理系统(java+springboot+layui+html+thymeleaf+mysql+maven)
项目介绍
仓库管理系统总共分为三个大的模块,分别是基础管理、仓库管理和系统管理。其中各个模块底下又有其子模块。 功能模块
一、基础管理
1、客户管理 客户列表 客户分页和模糊查询 客户添加、修改、删除、批量删除 2、供应商管理 供应商列表 供应商分页和模糊查询 供应商添加、修改、删除、批量删除 3、商品管理 商品列表 商品分页和模糊查询 商品添加、修改、删除、商品图片的上传
二、仓库管理
1.入库 订单查询、创建订单、删除订单 2.出库 订单查询、创建订单、删除订单 3.仓库基础设置 查询仓库、添加仓库、编辑仓库、删除仓库
三、系统管理
1、角色管理 全查询角色和模糊查询 角色的添加、修改、删除以及给角色分配权限 2、用户管理 全查询用户和模糊查询
用户的添加、修改、删除、重置密码以及给用户分配角色
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 8.0版本;
技术栈
-
后端:SpringBoot+Shiro+MybatisPlus
-
前端:HTML+CSS+Javascript+LayUI+DTree+Thymeleaf
使用说明
运行项目,输入localhost:8080/
管理员用户名:钱多多 密码:123456
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/output")
public class OutputFormController {
@Resource
private GoodsService goodsService;
@Resource
private CustomerService customerService;
@Resource
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
@RequestMapping("updateHouse")
public ResultObj updateHouse(StockVo stockVo){
QueryWrapper<Stock> queryWrapper = new QueryWrapper<Stock>();
queryWrapper.eq("house_id",stockVo.getHouseId());
queryWrapper.eq("goods_id",stockVo.getGoodsId());
Integer number = stockService.getOne(queryWrapper).getNumber();
try {
if(stockVo.getUpperAlert() < number){ //超出新的预警库存
return ResultObj.UPDATE_ERROR_EXCEED;
}else if(stockVo.getUnderAlert() > number){ //低于新的预警库存
return ResultObj.UPDATE_ERROR_UNDER;
}else {
stockService.updateByIds(stockVo);
return ResultObj.UPDATE_SUCCESS;
}
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
@RequestMapping("deleteHouse")
public ResultObj deleteHouse(Integer id){
try {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("house_id",id);
queryWrapper.notIn("goods_id",0);
if(stockService.count(queryWrapper)>1){ //库存中仍有货物,无法删除
return ResultObj.DELETE_ERROR_STOCK;
}
warehouseService.removeById(id);
queryWrapper = new QueryWrapper();
queryWrapper.eq("house_id",id);
stockService.remove(queryWrapper);
queryWrapper = new QueryWrapper();
queryWrapper.eq("role_id",id);
roleService.remove(queryWrapper);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
stockService.update(stock,updateWrapper);
return ResultObj.ADD_SUCCESS;
}
catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
@RequestMapping("deleteInput")
public ResultObj deleteInput(Integer id){
try {
inputFormService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/stock")
public class StockController {
}
}
/**
* 修改一个供应商
* @param providerVo
* @return
*/
@RequestMapping("updateProvider")
public ResultObj updateProvider(ProviderVo providerVo){
try {
providerService.updateById(providerVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
/**
* 删除一个供应商
* @param id
* @return
*/
@RequestMapping("deleteProvider")
public ResultObj deleteProvider(Integer id){
try {
providerService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
//提供下拉框
@RequestMapping("loadAllProviderForSelect")
public DataGridView loadAllProviderForSelect(){
QueryWrapper<Provider> queryWrapper = new QueryWrapper<Provider>();
List<Provider> list = providerService.list(queryWrapper);
return new DataGridView(list);
}
}
TbUser tbUser = (TbUser) WebUtils.getSession().getAttribute("user");
outputFormVo.setCreateTime(new Date());
outputFormVo.setUserId(tbUser.getUserId());
QueryWrapper<Stock> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("goods_id",outputFormVo.getGoodsId());
queryWrapper.eq("house_id",outputFormVo.getHouseId());
Stock stock = stockService.getOne(queryWrapper);
UpdateWrapper<Stock> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("goods_id",stock.getGoodsId());
updateWrapper.eq("house_id",stock.getHouseId());
System.out.println("stock = " + stock);
if(stock.getNumber()-outputFormVo.getChangeNumber() < stock.getUnderAlert()){
return ResultObj.ADD_ERROR_UNDER;
} else if(outputFormVo.getChangeNumber() ==0){
return ResultObj.ERROR_ZERO;
} else {
stock.setNumber(stock.getNumber()-outputFormVo.getChangeNumber());
}
outputFormService.save(outputFormVo);
stockService.update(stock,updateWrapper);
return ResultObj.ADD_SUCCESS;
}
catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
@RequestMapping("deleteOutput")
public ResultObj deleteInput(Integer id){
try {
outputFormService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
if(stockVo.getUpperAlert() < number){ //超出新的预警库存
return ResultObj.UPDATE_ERROR_EXCEED;
}else if(stockVo.getUnderAlert() > number){ //低于新的预警库存
return ResultObj.UPDATE_ERROR_UNDER;
}else {
stockService.updateByIds(stockVo);
return ResultObj.UPDATE_SUCCESS;
}
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
@RequestMapping("deleteHouse")
public ResultObj deleteHouse(Integer id){
try {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("house_id",id);
queryWrapper.notIn("goods_id",0);
if(stockService.count(queryWrapper)>1){ //库存中仍有货物,无法删除
return ResultObj.DELETE_ERROR_STOCK;
}
warehouseService.removeById(id);
queryWrapper = new QueryWrapper();
queryWrapper.eq("house_id",id);
stockService.remove(queryWrapper);
queryWrapper = new QueryWrapper();
queryWrapper.eq("role_id",id);
roleService.remove(queryWrapper);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
private RoleService roleService;
//查询所有角色
@RequestMapping("loadAllRole")
public DataGridView loadAllRole(RoleVo roleVo){
IPage<Role> page = new Page<Role>(roleVo.getPage(),roleVo.getLimit());
//QueryWrapper可用于查询功能
QueryWrapper<Role> queryWrapper = new QueryWrapper<Role>();
queryWrapper.like(StringUtils.isNotBlank(roleVo.getName()),"name",roleVo.getName());
queryWrapper.like(StringUtils.isNotBlank(roleVo.getRemark()),"remark",roleVo.getRemark());
queryWrapper.eq(roleVo.getAvailable()!=null,"available",roleVo.getAvailable());
// queryWrapper.orderByDesc("id");
roleService.page(page,queryWrapper);
return new DataGridView(page.getTotal(),page.getRecords());
}
//添加
@RequestMapping("addRole")
public ResultObj addRole(RoleVo roleVo){
try {
roleVo.setCreatetime(new Date());
roleService.save(roleVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
//修改
@RequestMapping("updateRole")
public ResultObj updateRole(RoleVo roleVo){
try {
roleService.updateById(roleVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
//删除
@RequestMapping("deleteRole")
public ResultObj deleteRole(Integer id){
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/stock")
public class StockController {
@Resource
private GoodsService goodsService;
@Resource
private WarehouseService warehouseService;
@Resource
private StockService stockService;
@Resource
private RoleService roleService;
@RequestMapping("loadAllGoodsForHouseSelect")
public DataGridView loadAllGoodsForHouseSelect(Integer houseId){
QueryWrapper<Stock> queryWrapper = new QueryWrapper();
queryWrapper.eq(null!=houseId,"house_id",houseId);
List<Stock> list = stockService.list(queryWrapper);
for (Stock stock : list) {
Goods goods = goodsService.getById(stock.getGoodsId());
if( null != goods){
stock.setName(goods.getName());
}
}
return new DataGridView((list));
}
@RequestMapping("loadAllStock")
@RestController
@RequestMapping("login")
public class LoginController {
@RequestMapping("login")
public ResultObj login(String loginName, String password){
Subject subject = SecurityUtils.getSubject();
//token认证
AuthenticationToken token = new UsernamePasswordToken(loginName, password);
try{
//对用户进行认证登陆
subject.login(token);
//通过subject获取以认证活动的user
ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//将user存储到session中
WebUtils.getSession().setAttribute("user",activeUser.getTbUser());
return ResultObj.LOGIN_SUCCESS;
} catch (AuthenticationException e){
e.printStackTrace();
return ResultObj.LOGIN_ERROR_PASS;
}
}
}
queryWrapper.eq("house_id",stockVo.getHouseId());
queryWrapper.eq("goods_id",stockVo.getGoodsId());
Integer number = stockService.getOne(queryWrapper).getNumber();
try {
if(stockVo.getUpperAlert() < number){ //超出新的预警库存
return ResultObj.UPDATE_ERROR_EXCEED;
}else if(stockVo.getUnderAlert() > number){ //低于新的预警库存
return ResultObj.UPDATE_ERROR_UNDER;
}else {
stockService.updateByIds(stockVo);
return ResultObj.UPDATE_SUCCESS;
}
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
}
}
@RequestMapping("deleteHouse")
public ResultObj deleteHouse(Integer id){
try {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("house_id",id);
queryWrapper.notIn("goods_id",0);
if(stockService.count(queryWrapper)>1){ //库存中仍有货物,无法删除
return ResultObj.DELETE_ERROR_STOCK;
}
warehouseService.removeById(id);
queryWrapper = new QueryWrapper();
queryWrapper.eq("house_id",id);
stockService.remove(queryWrapper);
queryWrapper = new QueryWrapper();
queryWrapper.eq("role_id",id);
roleService.remove(queryWrapper);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
TbUser tbUser = (TbUser) WebUtils.getSession().getAttribute("user");
if(tbUser.getRoleId() == Constast.USER_TYPE_SUPER){ //超级管理员拥有所有菜单
list = leftmenuService.list(queryWrapper);
}else { //普通仓管没有系统管理
//根据用户ID+角色+权限去查询
queryWrapper.notIn("id",Constast.SUPER_USER_OWN); //反选id为4的列,要让普通仓管没有系统管理的menu
list = leftmenuService.list(queryWrapper);
}
List<TreeNode> treeNodes = new ArrayList<>();
for (Leftmenu leftmenu: list) {
Integer id = leftmenu.getId();
Integer pid = leftmenu.getPid();
String title = leftmenu.getTitle();
String icon = leftmenu.getIcon();
String href = leftmenu.getHref();
Boolean spread = leftmenu.getOpen()==Constast.OPEN_TRUE?true:false;
treeNodes.add(new TreeNode(id,pid,title,icon,href,spread));
}
//用获得的菜单信息生成相应的Json
List<TreeNode> list1 = TreeNodeBuilder.build(treeNodes,1);
return new DataGridView(list1);
}
}
@RestController
@RequestMapping("login")
public class LoginController {
@RequestMapping("login")
public ResultObj login(String loginName, String password){
Subject subject = SecurityUtils.getSubject();
//token认证
AuthenticationToken token = new UsernamePasswordToken(loginName, password);
try{
//对用户进行认证登陆
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/output")
public class OutputFormController {
@Resource
private GoodsService goodsService;
@Resource
private CustomerService customerService;
@Resource
private OutputFormService outputFormService;
@Resource
private StockService stockService;
public class InputFormController {
@Resource
private GoodsService goodsService;
@Resource
private ProviderService providerService;
@Resource
private InputFormService inputFormService;
@Resource
private StockService stockService;
@Resource
private WarehouseService warehouseService;
@Resource
private TbUserService tbUserService;
@RequestMapping("loadAllInput")
public DataGridView loadAllInput(InputFormVo inputFormVo) {
IPage<InputForm> page = new Page<>(inputFormVo.getPage(), inputFormVo.getLimit());
QueryWrapper<InputForm> queryWrapper = new QueryWrapper();
queryWrapper.eq(null!=inputFormVo.getFormId(),"form_id",inputFormVo.getFormId());
queryWrapper.eq(null != inputFormVo.getProviderId() && inputFormVo.getProviderId()!=0,"provider_id",inputFormVo.getProviderId());
// queryWrapper.like(StringUtils.isNotBlank(inputFormVo.getName()),"name",inputFormVo.getName());
// queryWrapper.eq(inputFormVo.getPrice()!=null,"price",inputFormVo.getPrice());
TbUser user = (TbUser) WebUtils.getSession().getAttribute("user");
queryWrapper.eq(0!=user.getRoleId(),"house_id",user.getRoleId());
inputFormService.page(page,queryWrapper);
List<InputForm> records = page.getRecords();
for(InputForm inputForm : records){
Provider provider = providerService.getById(inputForm.getProviderId());
if (null != provider){
inputForm.setProviderName(provider.getName());
inputForm.setAddress(provider.getAddress());
}
Goods goods = goodsService.getById(inputForm.getGoodsId());
if(null != goods){
inputForm.setGoodsName(goods.getName());
*/
@RestController
@RequestMapping("/stock")
public class StockController {
@Resource
private GoodsService goodsService;
@Resource
private WarehouseService warehouseService;
@Resource
private StockService stockService;
@Resource
private RoleService roleService;
@RequestMapping("loadAllGoodsForHouseSelect")
public DataGridView loadAllGoodsForHouseSelect(Integer houseId){
QueryWrapper<Stock> queryWrapper = new QueryWrapper();
queryWrapper.eq(null!=houseId,"house_id",houseId);
List<Stock> list = stockService.list(queryWrapper);
for (Stock stock : list) {
Goods goods = goodsService.getById(stock.getGoodsId());
if( null != goods){
stock.setName(goods.getName());
}
}
return new DataGridView((list));
}
@RequestMapping("loadAllStock")
public DataGridView loadAllStock(StockVo stockVo){
IPage<Stock> page = new Page<>(stockVo.getPage(),stockVo.getLimit());
QueryWrapper<Stock> queryWrapper = new QueryWrapper<Stock>();
queryWrapper.eq(null != stockVo.getGoodsId() && stockVo.getGoodsId() !=0,"goods_id",stockVo.getGoodsId());
TbUser tbUser = (TbUser) WebUtils.getSession().getAttribute("user");
if(tbUser.getRoleId()!=0){
queryWrapper.eq(0!=tbUser.getRoleId(),"house_id",tbUser.getRoleId());
}else {
queryWrapper.eq(null != stockVo.getHouseId() && stockVo.getHouseId() !=0,"house_id",stockVo.getHouseId());
queryWrapper = new QueryWrapper();
queryWrapper.eq("role_id",id);
roleService.remove(queryWrapper);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/output")
public class OutputFormController {
inputFormService.save(inputFormVo);
stockService.update(stock,updateWrapper);
return ResultObj.ADD_SUCCESS;
}
catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
}
}
@RequestMapping("deleteInput")
public ResultObj deleteInput(Integer id){
try {
inputFormService.removeById(id);
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
}
}
}
return "/index/index";
}
/*
* 跳转到工作台
* */
@RequestMapping("toDesktopManager")
public String toDesktopManager(){
return "/index/desktopManager";
}
/**
* 跳转到角色管理
* @return
*/
@RequestMapping("toRoleManager")
public String toRoleManager(){
return "/role/roleManager";
}
/**
* 跳转到用户管理
* @return
*/
@RequestMapping("toUserManager")
public String toUserManager(){
return "/user/userManager";
}
@RequestMapping("toGoodsManager")
public String toGoodsManager(){
return "/goods/goodsManager";
}
@RequestMapping("toProviderManager")
public String toProviderManager(){
return "/provider/providerManager";
}
@RequestMapping("toCustomerManager")
public String toCustomerManager(){
return "/customer/customerManager";
}
@RequestMapping("toInputManager")
public String toInputManager(){
return "/input/inputManager";
}
@RestController
@RequestMapping("login")
public class LoginController {
@RequestMapping("login")
public ResultObj login(String loginName, String password){
Subject subject = SecurityUtils.getSubject();
//token认证
AuthenticationToken token = new UsernamePasswordToken(loginName, password);
try{
//对用户进行认证登陆
subject.login(token);
//通过subject获取以认证活动的user
ActiveUser activeUser = (ActiveUser) subject.getPrincipal();
//将user存储到session中
WebUtils.getSession().setAttribute("user",activeUser.getTbUser());
return ResultObj.LOGIN_SUCCESS;
} catch (AuthenticationException e){
e.printStackTrace();
return ResultObj.LOGIN_ERROR_PASS;
}
}
}