Bootstrap

基于javaweb+mysql的springboot仓库管理系统(java+springboot+layui+html+thymeleaf+mysql+实训报告)

基于javaweb+mysql的springboot仓库管理系统(java+springboot+layui+html+thymeleaf+mysql+实训报告)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot仓库管理系统(java+springboot+layui+html+thymeleaf+mysql+实训报告)

项目介绍

仓库管理系统总共分为三个大的模块,分别是基础管理、仓库管理和系统管理。其中各个模块底下又有其子模块。 功能模块

一、基础管理

1、客户管理 客户列表 客户分页和模糊查询 客户添加、修改、删除、批量删除 2、供应商管理 供应商列表 供应商分页和模糊查询 供应商添加、修改、删除、批量删除 3、商品管理 商品列表 商品分页和模糊查询 商品添加、修改、删除、商品图片的上传

二、仓库管理

1.入库 订单查询、创建订单、删除订单 2.出库 订单查询、创建订单、删除订单 3.仓库基础设置 查询仓库、添加仓库、编辑仓库、删除仓库

三、系统管理

1、角色管理 全查询角色和模糊查询 角色的添加、修改、删除以及给角色分配权限 2、用户管理 全查询用户和模糊查询

用户的添加、修改、删除、重置密码以及给用户分配角色

环境需要

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 8.0版本;

技术栈

  1. 后端:SpringBoot+Shiro+MybatisPlus

  2. 前端:HTML+CSS+Javascript+LayUI+DTree+Thymeleaf

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目,输入localhost:8080/ 登录 5. 管理员用户名:钱多多 密码:123456
            queryWrapper.eq("goods_id",goodsId);
            queryWrapper.eq("house_id",houseId);
            Stock stock = stockService.getOne(queryWrapper);
            UpdateWrapper<Stock> updateWrapper = new UpdateWrapper<>();
            if(null != stock){              //如果库存中有这件商品
                updateWrapper.eq("goods_id",stock.getGoodsId());
                updateWrapper.eq("house_id",stock.getHouseId());
            }else {                         //如果库存中没有这件商品
                QueryWrapper<Stock> query = new QueryWrapper();
                query.eq("house_id",houseId);
                query.eq("goods_id",0);
                Integer upperAlert = stockService.getOne(query).getUpperAlert();
                if(changeNumber < upperAlert){
                    Stock stock1 = new Stock(goodsId,houseId,changeNumber,upperAlert,0);
                    System.out.println("stock1 = " + stock1);
                    stockService.save(stock1);
                    inputFormService.save(inputFormVo);
                    return ResultObj.ADD_SUCCESS;
                }

            }
            if(changeNumber+stock.getNumber() > stock.getUpperAlert()){
                return ResultObj.ADD_ERROR_EXCEED;
            }else if(inputFormVo.getChangeNumber() ==0){
                return ResultObj.ERROR_ZERO;
            } else {
                stock.setNumber(inputFormVo.getChangeNumber()+stock.getNumber());
            }
            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 {
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }

    //提供下拉框
    @RequestMapping("loadAllGoodsForSelect")
    public DataGridView loadAllProviderForSelect(){
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
        List<Goods> list = goodsService.list(queryWrapper);
        return new DataGridView(list);
    }

    //提供下拉框
    @RequestMapping("loadAllGoodsForSpecialSelect")
    public DataGridView loadAllProviderForSpecialSelect(Integer providerId){
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
        queryWrapper.eq(null!=providerId,"provider_id",providerId);
        List<Goods> list = goodsService.list(queryWrapper);
        for (Goods goods : list) {
            Provider provider = providerService.getById(goods.getProviderId());
            if (null!=provider){
                goods.setProviderName(provider.getName());
            }
        }
        return new DataGridView(list);
    }

}

        try {
            Integer houseId = warehouseService.getMaximumId()+1;
            stockVo.setHouseId(houseId);
            stockVo.setGoodsId(0);
            stockVo.setNumber(0);
            stockService.save(stockVo);

            Warehouse warehouse = new Warehouse();
            warehouse.setHouseId(houseId);
            warehouse.setName(stockVo.getHouseName());
            warehouse.setAddress(stockVo.getAddress());
            warehouseService.save(warehouse);

            Role role = new Role();
            role.setAvailable(0);
            role.setName(houseId+"号仓库管理员");
            role.setRoleId(houseId);
            role.setCreatetime(new Date());
            roleService.save(role);

            return ResultObj.ADD_SUCCESS;
        } catch (Exception e) {
            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;
        }
 */
@RestController
@RequestMapping("/input")
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());

    /*
    * 跳转到首页
    *
    * */
    @RequestMapping("index")
    public String index(){
        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";
    }


/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Resource
    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;
            outputFormService.removeById(id);
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }

}

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;
}

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/user")
public class TbUserController {
    @Resource
    private TbUserService tbUserService;

    /*查询用户*/
    @RequestMapping("loadAllUser")
    public DataGridView loadAllUser(UserVo userVo){
        IPage<TbUser> page = new Page<>(userVo.getPage(),userVo.getLimit());
        //用获得的菜单信息生成相应的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{
            //对用户进行认证登陆
            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;
            userVo.setSalt(salt);
            //设置密码
            //userVo.setPassword(new Md5Hash(userVo.getPassword(),salt,2).toString());
            //设置性别
            String sex = userVo.getSex()=="1"?"男":"女";
            userVo.setSex(sex);
            tbUserService.save(userVo);
            return ResultObj.ADD_SUCCESS;
        }catch (Exception e){
            e.printStackTrace();
            return ResultObj.ADD_ERROR;
        }
    }

    @RequestMapping("updateUser")
    public ResultObj updateUser(UserVo userVo){
        try {
            //userVo.setPassword(new Md5Hash(userVo.getPassword(),userVo.getSalt(),2).toString());
//            //设置性别
            String sex = "1".equals(userVo.getSex())?"男":"女";
            userVo.setSex(sex);
            tbUserService.updateById(userVo);
            return ResultObj.UPDATE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.UPDATE_ERROR;
        }
    }
    @RequestMapping("deleteUser")
    public ResultObj deleteUser(Integer id){
        try {
            this.tbUserService.removeById(id);
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }
}

                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;
        }
    }

}


@Controller
@RequestMapping("/sys")
public class SystemController {

    /*
    * 跳转到登陆页面
     * @return
    * */
    @RequestMapping("toLogin")
    public String toLogin(){
        return "/index/login";
    }

    /*
    * 跳转到首页
    *
    * */
    @RequestMapping("index")
    public String index(){
        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";
    }

        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.notIn("goods_id",0);
        stockService.page(page,queryWrapper);
        List<Stock> records = page.getRecords();
        for (Stock stock : records) {
            Warehouse warehouse = warehouseService.getById(stock.getHouseId());
            if(null != warehouse){
                stock.setHouseName(warehouse.getName());
                stock.setAddress(warehouse.getAddress());
            }
            Goods goods = goodsService.getById(stock.getGoodsId());
            if(null != goods){
                stock.setName(goods.getName());
                stock.setSize(goods.getSize());
                stock.setPackages(goods.getPackages());
                stock.setPrice(goods.getPrice());
            }
        }
        return new DataGridView(page.getTotal(),page.getRecords());
    }

    @RequestMapping("addHouse")
    public ResultObj addHouse(StockVo stockVo){
        try {
            Integer houseId = warehouseService.getMaximumId()+1;
            stockVo.setHouseId(houseId);
            stockVo.setGoodsId(0);
            stockVo.setNumber(0);
            stockService.save(stockVo);

            Warehouse warehouse = new Warehouse();
            warehouse.setHouseId(houseId);
            warehouse.setName(stockVo.getHouseName());
            warehouse.setAddress(stockVo.getAddress());
            warehouseService.save(warehouse);

            Role role = new Role();
            role.setAvailable(0);
            role.setName(houseId+"号仓库管理员");
            role.setRoleId(houseId);
            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;
        }
    }

}


/**
 * <p>
 *  菜单管理控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Resource
    private LeftmenuService leftmenuService;

    //动态生成左边导航菜单栏,通过生成Json传送到前端页面实现
    @RequestMapping("loadIndexLeftMenuJson")
    public DataGridView loadIndexLeftMenuJson(){
        //查询所有菜单
        QueryWrapper<Leftmenu> queryWrapper = new QueryWrapper<>();
        List<Leftmenu> list = null;
        //获得用户  判断用户的类型
        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();
            queryWrapper.eq("role_id",id);
            roleService.remove(queryWrapper);

            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }

}

/**
 * <p>
 *  前端控制器
 * </p>
 *

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/warehouse")
public class WarehouseController {

    @Resource
    WarehouseService warehouseService;
    //提供下拉框
    @RequestMapping("loadAllHouseForSelect")
    public DataGridView loadAllHouseForSelect(){
        QueryWrapper<Warehouse> queryWrapper = new QueryWrapper<Warehouse>();
        TbUser tbUser = (TbUser) WebUtils.getSession().getAttribute("user");
        queryWrapper.eq(0!=tbUser.getRoleId(),"house_id",tbUser.getRoleId());
        List<Warehouse> list = warehouseService.list(queryWrapper);
        return new DataGridView(list);
    }

}

    public ResultObj deleteGoods(Integer id){
        try {
            goodsService.removeById(id);
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }

    //提供下拉框
    @RequestMapping("loadAllGoodsForSelect")
    public DataGridView loadAllProviderForSelect(){
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
        List<Goods> list = goodsService.list(queryWrapper);
        return new DataGridView(list);
    }

    //提供下拉框
    @RequestMapping("loadAllGoodsForSpecialSelect")
    public DataGridView loadAllProviderForSpecialSelect(Integer providerId){
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
        queryWrapper.eq(null!=providerId,"provider_id",providerId);
        List<Goods> list = goodsService.list(queryWrapper);
        for (Goods goods : list) {
            Provider provider = providerService.getById(goods.getProviderId());
            if (null!=provider){
                goods.setProviderName(provider.getName());
            }
        }
        return new DataGridView(list);
    }

}

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

;