SpringBoot毕业设计物资管理系统:Vue前端+MySQL数据库完整实现

39 阅读2分钟

一、个人简介

💖💖作者:计算机编程果茶熊 💙💙个人简介:曾长期从事计算机专业培训教学,担任过编程老师,同时本人也热爱上课教学,擅长Java、微信小程序、Python、Golang、安卓Android等多个IT方向。会做一些项目定制化开发、代码讲解、答辩教学、文档编写、也懂一些降重方面的技巧。平常喜欢分享一些自己开发中遇到的问题的解决办法,也喜欢交流技术,大家有技术代码这一块的问题可以问我! 💛💛想说的话:感谢大家的关注与支持! 💜💜 网站实战项目 安卓/小程序实战项目 大数据实战项目 计算机毕业设计选题 💕💕文末获取源码联系计算机编程果茶熊

二、系统介绍

开发语言:Java+Python 数据库:MySQL 系统架构:B/S 后端框架:SpringBoot(Spring+SpringMVC+Mybatis)+Django 前端:Vue+HTML+CSS+JavaScript+jQuery

三、视频解说

SpringBoot毕业设计物资管理系统:Vue前端+MySQL数据库完整实现

四、部分功能展示

在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述

五、部分代码展示


import org.apache.spark.sql.SparkSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@RestController
@RequestMapping("/api")
public class MaterialManagementController {
    
    private static final SparkSession spark = SparkSession.builder()
            .appName("MaterialManagement")
            .master("local[*]")
            .getOrCreate();
    
    @Autowired
    private MaterialService materialService;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private StockInService stockInService;
    
    // 物资管理核心功能
    @PostMapping("/material/add")
    public Result addMaterial(@RequestBody Material material) {
        if (material.getName() == null || material.getName().trim().isEmpty()) {
            return Result.error("物资名称不能为空");
        }
        if (material.getCategoryId() == null) {
            return Result.error("物资分类不能为空");
        }
        QueryWrapper<Material> wrapper = new QueryWrapper<>();
        wrapper.eq("name", material.getName()).eq("category_id", material.getCategoryId());
        Material existMaterial = materialService.getOne(wrapper);
        if (existMaterial != null) {
            return Result.error("该分类下已存在同名物资");
        }
        Category category = categoryService.getById(material.getCategoryId());
        if (category == null) {
            return Result.error("所选分类不存在");
        }
        material.setCreateTime(LocalDateTime.now());
        material.setUpdateTime(LocalDateTime.now());
        material.setStatus(1);
        if (material.getMinStock() == null) {
            material.setMinStock(0);
        }
        if (material.getMaxStock() == null) {
            material.setMaxStock(999999);
        }
        if (material.getCurrentStock() == null) {
            material.getCurrentStock();
        }
        boolean saved = materialService.save(material);
        if (saved) {
            return Result.success("物资添加成功", material);
        }
        return Result.error("物资添加失败");
    }
    
    // 物资分类管理核心功能
    @PostMapping("/category/manage")
    public Result manageCategory(@RequestBody CategoryRequest request) {
        if (request.getOperation().equals("add")) {
            if (request.getName() == null || request.getName().trim().isEmpty()) {
                return Result.error("分类名称不能为空");
            }
            QueryWrapper<Category> wrapper = new QueryWrapper<>();
            wrapper.eq("name", request.getName());
            if (request.getParentId() != null) {
                wrapper.eq("parent_id", request.getParentId());
            }
            Category existCategory = categoryService.getOne(wrapper);
            if (existCategory != null) {
                return Result.error("该层级下已存在同名分类");
            }
            Category category = new Category();
            category.setName(request.getName());
            category.setDescription(request.getDescription());
            category.setParentId(request.getParentId());
            category.setCreateTime(LocalDateTime.now());
            category.setStatus(1);
            if (request.getParentId() != null) {
                Category parent = categoryService.getById(request.getParentId());
                if (parent == null) {
                    return Result.error("父级分类不存在");
                }
                category.setLevel(parent.getLevel() + 1);
            } else {
                category.setLevel(1);
            }
            categoryService.save(category);
            return Result.success("分类创建成功", category);
        } else if (request.getOperation().equals("update")) {
            Category category = categoryService.getById(request.getId());
            if (category == null) {
                return Result.error("分类不存在");
            }
            if (request.getName() != null) {
                QueryWrapper<Category> wrapper = new QueryWrapper<>();
                wrapper.eq("name", request.getName()).ne("id", request.getId());
                if (category.getParentId() != null) {
                    wrapper.eq("parent_id", category.getParentId());
                }
                Category existCategory = categoryService.getOne(wrapper);
                if (existCategory != null) {
                    return Result.error("该层级下已存在同名分类");
                }
                category.setName(request.getName());
            }
            category.setDescription(request.getDescription());
            category.setUpdateTime(LocalDateTime.now());
            categoryService.updateById(category);
            return Result.success("分类更新成功", category);
        }
        return Result.error("无效的操作类型");
    }
    
    // 入库管理核心功能
    @PostMapping("/stockin/process")
    public Result processStockIn(@RequestBody StockInRequest request) {
        if (request.getMaterialId() == null) {
            return Result.error("物资ID不能为空");
        }
        if (request.getQuantity() == null || request.getQuantity() <= 0) {
            return Result.error("入库数量必须大于0");
        }
        if (request.getUnitPrice() == null || request.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0) {
            return Result.error("单价必须大于0");
        }
        Material material = materialService.getById(request.getMaterialId());
        if (material == null) {
            return Result.error("物资不存在");
        }
        if (request.getWarehouseId() != null) {
            Warehouse warehouse = warehouseService.getById(request.getWarehouseId());
            if (warehouse == null) {
                return Result.error("仓库不存在");
            }
        }
        StockIn stockIn = new StockIn();
        stockIn.setMaterialId(request.getMaterialId());
        stockIn.setQuantity(request.getQuantity());
        stockIn.setUnitPrice(request.getUnitPrice());
        stockIn.setTotalPrice(request.getUnitPrice().multiply(new BigDecimal(request.getQuantity())));
        stockIn.setWarehouseId(request.getWarehouseId());
        stockIn.setSupplierId(request.getSupplierId());
        stockIn.setBatchNo(generateBatchNo());
        stockIn.setInTime(LocalDateTime.now());
        stockIn.setOperatorId(getCurrentUserId());
        stockIn.setRemark(request.getRemark());
        stockIn.setStatus(1);
        boolean saved = stockInService.save(stockIn);
        if (saved) {
            Integer currentStock = material.getCurrentStock();
            if (currentStock == null) {
                currentStock = 0;
            }
            material.setCurrentStock(currentStock + request.getQuantity());
            material.setUpdateTime(LocalDateTime.now());
            materialService.updateById(material);
            return Result.success("入库操作成功", stockIn);
        }
        return Result.error("入库操作失败");
    }
    
    private String generateBatchNo() {
        return "IN" + System.currentTimeMillis();
    }
    
    private Long getCurrentUserId() {
        return 1L;
    }
}

六、部分文档展示

在这里插入图片描述

七、END

💕💕文末获取源码联系计算机编程果茶熊