Home > Java > javaTutorial > body text

How to implement the commodity purchase, sale and inventory management system based on Springboot

王林
Release: 2023-05-11 08:55:13
forward
857 people have browsed it

1. Project Introduction

This project implements a purchase, sales and inventory management system based on springboot. It mainly manages the purchase, sales and inventory of related goods opened by users in online stores. The functions are relatively complete and have complete functions. The permission management system allows you to design roles and assign permissions according to your needs. The granularity of permissions can achieve page-level permission control, which is excellent for the entire project. The main functions implemented are as follows:

Basic management module: including three sub-modules: customer management, supplier management, and product management

Purchasing management module: including product purchase, returns, and product management Several sub-check blocks for return query

Sales management: including product sales, returns, and several sub-check blocks for sales return query

System management: including department management, menu management, authority management, role management, Five sub-modules of user management

Other management: including login log query, system announcement management, icon management and other sub-modules

Personal center: including personal information management, password modification and other related functions

2. Environment introduction

Language environment: Java: jdk1.8

Database: Mysql: mysql5.7 / Redis cache database

Application server: Tomcat: tomcat8.5.31

Development tools: IDEA or eclipse

Backend development technology: Springboot Mybatis-plus Shiro

Front-end development technology: Bootstrap Layui Freemarker template

3. System display

Super administrator login system: system/123456

How to implement the commodity purchase, sale and inventory management system based on Springboot

##Basic management - Customer management

How to implement the commodity purchase, sale and inventory management system based on Springboot

Basic Management—Supplier Management

How to implement the commodity purchase, sale and inventory management system based on Springboot

Basic Management—Commodity Management

How to implement the commodity purchase, sale and inventory management system based on Springboot

Purchasing Management —Product purchase You can also realize returns here

How to implement the commodity purchase, sale and inventory management system based on Springboot

Restocking management—Commodity return inquiry

How to implement the commodity purchase, sale and inventory management system based on Springboot

Sales management&mdash ;Commodity sales

How to implement the commodity purchase, sale and inventory management system based on Springboot

Sales management—Sales return query

How to implement the commodity purchase, sale and inventory management system based on Springboot

System management---Department management

How to implement the commodity purchase, sale and inventory management system based on Springboot

System Management---Menu Management

How to implement the commodity purchase, sale and inventory management system based on Springboot

System Management---Permission Management

How to implement the commodity purchase, sale and inventory management system based on Springboot

System Management---Role Management

How to implement the commodity purchase, sale and inventory management system based on Springboot

System Management---User Management

How to implement the commodity purchase, sale and inventory management system based on Springboot

Other management - Login log

How to implement the commodity purchase, sale and inventory management system based on Springboot##Other management - System announcement

##4. Core code displayHow to implement the commodity purchase, sale and inventory management system based on Springboot

package com.dev.shop.bus.controller;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
 
@Controller
@RequestMapping("bus")
public class BusinessController {
 
    /**
     * 跳转到客户管理页面
     * @return
     */
    @RequestMapping("toCustomerManager")
    public String toCustomerManager(){
        return "business/customer/customerManager";
    }
 
    /**
     * 跳转到供应商管理页面
     * @return
     */
    @RequestMapping("toProviderManager")
    public String toProviderManager(){
        return "business/provider/providerManager";
    }
 
    /**
     * 跳转到商品管理页面
     * @return
     */
    @RequestMapping("toGoodsManager")
    public String toGoodsManager(){
        return "business/goods/goodsManager";
    }
 
    /**
     * 跳转到进货管理页面
     * @return
     */
    @RequestMapping("toInportManager")
    public String toInportManager(){
        return "business/inport/inportManager";
    }
 
    /**
     * 跳转到退货管理页面
     * @return
     */
    @RequestMapping("toOutportManager")
    public String toOutportManager(){
        return "business/outport/outportManager";
    }
 
    /**
     * 跳转到商品销售管理页面
     * @return
     */
    @RequestMapping("toSalesManager")
    public String toSalesManager(){
        return "business/sales/salesManager";
    }
 
    /**
     * 跳转到商品销售管理页面
     * @return
     */
    @RequestMapping("toSalesbackManager")
    public String toSalesbackManager(){
        return "business/salesback/salesbackManager";
    }
 
}
Copy after login
package com.dev.shop.bus.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dev.shop.bus.entity.Customer;
import com.dev.shop.bus.service.ICustomerService;
import com.dev.shop.bus.vo.CustomerVo;
import com.dev.shop.sys.common.Constast;
import com.dev.shop.sys.common.DataGridView;
import com.dev.shop.sys.common.ResultObj;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
 
@RestController
@RequestMapping("/customer")
public class CustomerController {
 
    @Autowired
    private ICustomerService customerService;
 
    /**
     * 查询所有的客户
     * @param customerVo
     * @return
     */
    @RequestMapping("loadAllCustomer")
    public DataGridView loadAllCustomer(CustomerVo customerVo){
        //1.声明一个分页page对象
        IPage<Customer> page = new Page(customerVo.getPage(),customerVo.getLimit());
        //2.声明一个queryWrapper
        QueryWrapper<Customer> queryWrapper = new QueryWrapper();
        queryWrapper.like(StringUtils.isNotBlank(customerVo.getCustomername()),"customername",customerVo.getCustomername());
        queryWrapper.like(StringUtils.isNotBlank(customerVo.getConnectionpersion()),"connectionpersion",customerVo.getConnectionpersion());
        queryWrapper.like(StringUtils.isNotBlank(customerVo.getPhone()),"phone",customerVo.getPhone());
        customerService.page(page,queryWrapper);
        return new DataGridView(page.getTotal(),page.getRecords());
    }
 
    /**
     * 添加一个客户
     * @param customerVo
     * @return
     */
    @RequestMapping("addCustomer")
    public ResultObj addCustomer(CustomerVo customerVo){
        try {
            customerService.save(customerVo);
            return ResultObj.ADD_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.ADD_ERROR;
        }
    }
 
    /**
     * 修改一个客户
     * @param customerVo
     * @return
     */
    @RequestMapping("updateCustomer")
    public ResultObj updateCustomer(CustomerVo customerVo){
        try {
            customerService.updateById(customerVo);
            return ResultObj.UPDATE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.UPDATE_ERROR;
        }
    }
 
    /**
     * 删除一个客户
     * @param id 客户的ID
     * @return
     */
    @RequestMapping("deleteCustomer")
    public ResultObj deleteCustomer(Integer id){
        try {
            customerService.removeById(id);
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }
 
    /**
     * 批量删除客户
     * @param customerVo 选中的客户
     * @return
     */
    @RequestMapping("batchDeleteCustomer")
    public ResultObj batchDeleteCustomer(CustomerVo customerVo){
        try {
            Collection<Serializable> idList = new ArrayList<Serializable>();
            for (Integer id : customerVo.getIds()) {
                idList.add(id);
            }
            customerService.removeByIds(idList);
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }
 
    /**
     * 加载所有客户的下拉列表
     * @return
     */
    @RequestMapping("loadAllCustomerForSelect")
    public DataGridView loadAllCustomerForSelect(){
        QueryWrapper<Customer> queryWrapper = new QueryWrapper<Customer>();
        queryWrapper.eq("available", Constast.AVAILABLE_TRUE);
        List<Customer> list = customerService.list(queryWrapper);
        return new DataGridView(list);
    }
 
}
Copy after login
package com.dev.shop.bus.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dev.shop.bus.entity.Goods;
import com.dev.shop.bus.entity.Provider;
import com.dev.shop.bus.service.IGoodsService;
import com.dev.shop.bus.service.IProviderService;
import com.dev.shop.bus.vo.GoodsVo;
import com.dev.shop.sys.common.AppFileUtils;
import com.dev.shop.sys.common.Constast;
import com.dev.shop.sys.common.DataGridView;
import com.dev.shop.sys.common.ResultObj;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
@RequestMapping("/goods")
public class GoodsController {
 
    @Autowired
    private IGoodsService goodsService;
 
    @Autowired
    private IProviderService providerService;
 
    /**
     * 查询商品
     * @param goodsVo
     * @return
     */
    @RequestMapping("loadAllGoods")
    public DataGridView loadAllGoods(GoodsVo goodsVo){
        IPage<Goods> page = new Page<>(goodsVo.getPage(),goodsVo.getLimit());
        QueryWrapper<Goods> queryWrapper = new QueryWrapper();
        queryWrapper.eq(goodsVo.getProviderid()!=null&&goodsVo.getProviderid()!=0,"providerid",goodsVo.getProviderid());
        queryWrapper.like(StringUtils.isNotBlank(goodsVo.getGoodsname()),"goodsname",goodsVo.getGoodsname());
        queryWrapper.like(StringUtils.isNotBlank(goodsVo.getProductcode()),"productcode",goodsVo.getProductcode());
        queryWrapper.like(StringUtils.isNotBlank(goodsVo.getPromitcode()),"promitcode",goodsVo.getPromitcode());
        queryWrapper.like(StringUtils.isNotBlank(goodsVo.getDescription()),"description",goodsVo.getDescription());
        queryWrapper.like(StringUtils.isNotBlank(goodsVo.getSize()),"size",goodsVo.getSize());
        queryWrapper.orderByDesc("id");
        goodsService.page(page,queryWrapper);
        List<Goods> records = page.getRecords();
        for (Goods goods : records) {
            Provider provider = providerService.getById(goods.getProviderid());
            if (null!=provider){
                goods.setProvidername(provider.getProvidername());
            }
        }
        return new DataGridView(page.getTotal(),page.getRecords());
    }
 
    /**
     * 添加商品
     * @param goodsVo
     * @return
     */
    @RequestMapping("addGoods")
    public ResultObj addGoods(GoodsVo goodsVo){
        try {
            if (goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().endsWith("_temp")){
                String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg());
                goodsVo.setGoodsimg(newName);
            }
            goodsService.save(goodsVo);
            return ResultObj.ADD_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.ADD_ERROR;
        }
    }
 
    /**
     * 修改商品
     * @param goodsVo
     * @return
     */
    @RequestMapping("updateGoods")
    public ResultObj updateGoods(GoodsVo goodsVo){
        try {
            //商品图片不是默认图片
            if (!(goodsVo.getGoodsimg()!=null&&goodsVo.getGoodsimg().equals(Constast.DEFAULT_IMG))){
                if (goodsVo.getGoodsimg().endsWith("_temp")){
                    String newName = AppFileUtils.renameFile(goodsVo.getGoodsimg());
                    goodsVo.setGoodsimg(newName);
                    //删除原先的图片
                    String oldPath = goodsService.getById(goodsVo.getId()).getGoodsimg();
                    AppFileUtils.removeFileByPath(oldPath);
                }
            }
            goodsService.updateById(goodsVo);
            return ResultObj.UPDATE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.UPDATE_ERROR;
        }
    }
 
    /**
     * 删除商品
     * @param id
     * @return
     */
    @RequestMapping("deleteGoods")
    public ResultObj deleteGoods(Integer id,String goodsimg){
        try {
            //删除商品的图片
            AppFileUtils.removeFileByPath(goodsimg);
            goodsService.removeById(id);
            return ResultObj.DELETE_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.DELETE_ERROR;
        }
    }
 
    /**
     * 加载所有可用的商品
     * @return
     */
    @RequestMapping("loadAllGoodsForSelect")
    public DataGridView loadAllGoodsForSelect(){
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
        queryWrapper.eq("available",Constast.AVAILABLE_TRUE);
        List<Goods> list = goodsService.list(queryWrapper);
        for (Goods goods : list) {
            Provider provider = providerService.getById(goods.getProviderid());
            if (null!=provider){
                goods.setProvidername(provider.getProvidername());
            }
        }
        return new DataGridView(list);
    }
 
    /**
     * 根据供应商ID查询商品信息
     * @param providerid    供应商ID
     * @return
     */
    @RequestMapping("loadGoodsByProviderId")
    public DataGridView loadGoodsByProviderId(Integer providerid){
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
        queryWrapper.eq("available",Constast.AVAILABLE_TRUE);
        queryWrapper.eq(providerid!=null,"providerid",providerid);
        List<Goods> list = goodsService.list(queryWrapper);
        for (Goods goods : list) {
            Provider provider = providerService.getById(goods.getProviderid());
            if (null!=provider){
                goods.setProvidername(provider.getProvidername());
            }
        }
        return new DataGridView(list);
    }
 
 
 
}
Copy after login
package com.dev.shop.bus.entity;
 
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
 
import java.io.Serializable;
 
 
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("bus_customer")
@ToString
public class Customer implements Serializable {
 
    private static final long serialVersionUID=1L;
 
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
 
    private String customername;
 
    private String zip;
 
    private String address;
 
    private String telephone;
 
    private String connectionpersion;
 
    private String phone;
 
    private String bank;
 
    private String account;
 
    private String email;
 
    private String fax;
 
    private Integer available;
 
 
}
Copy after login

The above is the detailed content of How to implement the commodity purchase, sale and inventory management system based on Springboot. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template