Java项目:仓库管理系统(java+SSM+JSP+JS+Layui+Mysql)

 源码获取:俺的博客首页 "资源" 里下载!

项目介绍

基于SSM的仓库管理系统

角色:管理员、用户

员工:员工登录系统后,可以查看主页,个人中心,客户信息管理,供应商管理,货物信息管理,货物入库管理,货物出库管理等功能,还能对每个功能逐一进行相应操作

管理员:管理员登录系统后,可以查看主页,个人中心,员工管理,客户信息管理,供应商管理,仓库信息管理,货物类型管理,货物信息管理,货物入库管理,货物出库管理等功能,还能对每个功能逐一进行相应操作


环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7/8.0版本均可;
5.是否Maven项目:是;


技术栈

后端:SSM(Spring+SpringMVC+Mybatis)

前端:JSP+CSS+JS+JQUERY+Layui


使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

 

 

 

 库存管理控制层:

@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());
            if(null != goods){
                inputForm.setGoodsName(goods.getName());
                inputForm.setSize(goods.getSize());
                inputForm.setPackages(goods.getPackages());
                inputForm.setPrice(goods.getPrice());
            }
            TbUser tbUser = tbUserService.getById(inputForm.getUserId());
            if(null != tbUser){
                inputForm.setUserName(tbUser.getName());
            }

            Warehouse warehouse = warehouseService.getById(inputForm.getHouseId());
            if(null != warehouse){
                inputForm.setHouseName(warehouse.getName());
            }
        }
        return new DataGridView(page.getTotal(),page.getRecords());
    }
    @RequestMapping("addInput")
    public ResultObj addInput(InputFormVo inputFormVo){
        try {
            TbUser tbUser = (TbUser) WebUtils.getSession().getAttribute("user");
            inputFormVo.setCreateTime(new Date());
            inputFormVo.setUserId(tbUser.getUserId());
            Integer goodsId = inputFormVo.getGoodsId();
            Integer houseId = inputFormVo.getHouseId();
            Integer changeNumber = inputFormVo.getChangeNumber();
            QueryWrapper<Stock> queryWrapper = new QueryWrapper<>();
            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 {
            inputFormService.removeById(id);
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }
}

供应商管理控制层: 

@RestController
@RequestMapping("/provider")
public class ProviderController {

    @Resource
    private ProviderService providerService;


    @RequestMapping("loadAllProvider")
    public DataGridView loadAllProvider(ProviderVo providerVo){
        //1.声明一个分页page对象
        IPage<Provider> page = new Page(providerVo.getPage(),providerVo.getLimit());
        //2.声明一个queryWrapper
        QueryWrapper<Provider> queryWrapper = new QueryWrapper();
        queryWrapper.eq(null != providerVo.getProviderId() && providerVo.getProviderId()!=0,"provider_id",providerVo.getProviderId());
        queryWrapper.like(StringUtils.isNotBlank(providerVo.getManager()),"manager",providerVo.getManager());
        queryWrapper.like(StringUtils.isNotBlank(providerVo.getTalePhone()),"tale_phone",providerVo.getTalePhone());
        providerService.page(page,queryWrapper);
        return new DataGridView(page.getTotal(),page.getRecords());
    }

    /**
     * 添加一个供应商
     * @param providerVo
     * @return
     */
    @RequestMapping("addProvider")
    public ResultObj addProvider(ProviderVo providerVo){
        try {
            providerService.save(providerVo);
            return ResultObj.ADD_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.ADD_ERROR;
        }
    }

    /**
     * 修改一个供应商
     * @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);
    }


}

出货管理控制层:

@RestController
@RequestMapping("/output")
public class OutputFormController {

    @Resource
    private GoodsService goodsService;

    @Resource
    private CustomerService customerService;

    @Resource
    private OutputFormService outputFormService;

    @Resource
    private StockService stockService;

    @Resource
    private WarehouseService warehouseService;

    @Resource
    private TbUserService tbUserService;

    @RequestMapping("loadAllOutput")
    public DataGridView loadAllOutput(OutputFormVo outputFormVo) {
        IPage<OutputForm> page = new Page<>(outputFormVo.getPage(),outputFormVo.getLimit());
        QueryWrapper<OutputForm> queryWrapper = new QueryWrapper();
        queryWrapper.eq(null!=outputFormVo.getFormId(),"form_id",outputFormVo.getFormId());
        queryWrapper.eq(null != outputFormVo.getCustomerId() && outputFormVo.getCustomerId()!=0,"customer_id",outputFormVo.getCustomerId());
        TbUser user = (TbUser) WebUtils.getSession().getAttribute("user");
        queryWrapper.eq(null!=user.getRoleId() && 0!=user.getRoleId(),"house_id",user.getRoleId());
        outputFormService.page(page,queryWrapper);
        List<OutputForm> records = page.getRecords();
        for(OutputForm outputForm : records){
            Customer customer = customerService.getById(outputForm.getCustomerId());
            if (null != customer){
                outputForm.setCustomerName(customer.getName());
                outputForm.setAddress(customer.getAddress());
            }
            Goods goods = goodsService.getById(outputForm.getGoodsId());
            if(null != goods){
                outputForm.setGoodsName(goods.getName());
                outputForm.setSize(goods.getSize());
                outputForm.setPackages(goods.getPackages());
                outputForm.setPrice(goods.getPrice());
            }
            TbUser tbUser = tbUserService.getById(outputForm.getUserId());
            if(null != tbUser){
                outputForm.setUserName(tbUser.getName());
            }

            Warehouse warehouse = warehouseService.getById(outputForm.getHouseId());
            if(null != warehouse){
                outputForm.setHouseName(warehouse.getName());
            }
        }
        return new DataGridView(page.getTotal(),page.getRecords());
    }

    @RequestMapping("addOutput")
    public ResultObj addOutput(OutputFormVo outputFormVo){
        try {
            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;
        }
    }

}

源码获取:俺的博客首页 "资源" 里下载!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

beyondwild

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值