項目編号:BS-XX-145
一,項目簡介
農産品進銷存系統是針對商店、商場、超市的進銷存業務處理的計算機化而設計,為進銷存業務的處理人員提供計算機化的服務,改變以往的手工操作,提高工作效率,進而增強競争力。本系統提供的服務主要有商品的進貨、銷售、庫存管理以及相應的報表、查詢功能等。系統使用前後端分離模式開發實作,背景使用springboot+mybatis開發,前端使用vue+nodejs實作,通過接口遠端調用。系統前端主要實作産品的展銷功能,背景主要實作相關的資料管理功能,具體的功能實作如下:
- 系統使用者管理
- 商品管理
- 客戶管理
- 供應商管理
- 進貨管理
- 銷售管理
- 統計報表
- 前台輪播廣告圖管理
二,環境介紹
語言環境:Java: jdk1.8
資料庫:Mysql: mysql5.7
應用伺服器:Tomcat: tomcat8.5.31
開發工具:IDEA或eclipse
背景開發技術:Springboot+mybatis
前台開發技術:nodejs+vue
三,系統展示
前端頁面及功能展示
産品購買:
背景使用者登陸
使用者管理
商品管理
客戶管理
供應商管理
商品進貨
退貨查詢
商品銷售
商品退貨查詢
統計報表
輪播圖管理
四,核心代碼展示
package com.example.demo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.dto.QueryDTO;
import com.example.demo.entity.Customer;
import com.example.demo.entity.Good;
import com.example.demo.result.DataGridViewResult;
import com.example.demo.result.Result;
import com.example.demo.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Description: 客戶
* date: 2022/9/30 23:46
* @author: znz
* @since JDK 1.8
*/
@RestController
public class CustomerController {
@Autowired
private CustomerService customerService;
/**
* 分頁查詢
* @param queryDTO
* @return
*/
@PostMapping("api/cust/list")
public Result customerList(@RequestBody QueryDTO queryDTO){
return new Result(200,"",customerService.selectCustomerPage(queryDTO));
}
/**
* 添加
* @param customer
* @return
*/
@PostMapping("api/cust/add")
public Result addCustomer(@RequestBody Customer customer){
return new Result(200,"",customerService.addCustomer(customer));
}
/**
* 更新/修改
* @param customer
* @return
*/
@PostMapping("api/cust/update")
public Result updateCustomer(@RequestBody Customer customer){
System.out.println(customer);
return new Result(200,"",customerService.updateCustomer(customer));
}
/**
* 删除
* @param custid
* @return
*/
@PostMapping("api/cust/delete")
public Result deleteCustomer(Integer custid){
return new Result(200,"",customerService.deleteCustomer(custid));
}
/**
* 批量删除
* @param custids
* @return
*/
@PostMapping("api/cust/delete/batch")
public Result batchDeleteCustomer(@RequestBody List<Integer> custids){
customerService.batchDelete(custids);
return new Result(200,"","");
}
/**
* 加載下拉框
*
* @return
*/
@RequestMapping("api/cust/AllCust")
public DataGridViewResult loadAllCust() {
QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
List<Customer> list = customerService.list(queryWrapper);
return new DataGridViewResult(list);
}
/**
* 根據客戶id加載客戶名稱
* @param
* @return
*/
@PostMapping("api/cust/loadCustById")
public DataGridViewResult loadCustById(Integer custid) {
QueryWrapper<Customer> goodsQueryWrapper = new QueryWrapper<>();
goodsQueryWrapper.eq(custid != 0, "custid", custid);
Customer customer = customerService.getById(custid);
return new DataGridViewResult(customer);
}
}
package com.example.demo.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.example.demo.dto.QueryDTO;
import com.example.demo.entity.Good;
import com.example.demo.entity.Provider;
import com.example.demo.mapper.GoodMapper;
import com.example.demo.result.DataGridViewResult;
import com.example.demo.result.Result;
import com.example.demo.service.GoodService;
import com.example.demo.service.ProviderService;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* Description:
* date: 2022/9/18 23:56
* @author: znz
* @since JDK 1.8
*/
@RestController
public class GoodController {
@Autowired
private GoodService service;
@Autowired
private GoodMapper goodMapper;
/**
* 分頁查詢
* @param queryDTO
* @return
*/
@PostMapping("api/good/list")
public Result goodList(@RequestBody QueryDTO queryDTO){
return new Result(200,"",service.selectGoodPage(queryDTO));
}
@PostMapping("api/good/listpro")
public Result goodProList(String keyword){
return new Result(200,"",goodMapper.selectname(keyword));
}
/**
* 前台顯示
* @return
*/
@PostMapping("api/good/lists")
public Result goodLists(){
return new Result(200,"",service.list());
}
/**
* 前台查詢商品名稱
* @return
*/
@PostMapping("api/good/selectlists")
public Result goodSelectLists(String keyword){
return new Result(200,"",goodMapper.selectgood(keyword));
}
/**
* 添加
* @param good
* @return
*/
@PostMapping("api/good/add")
public Result addGood(@RequestBody Good good){
// 随機的商品編号
String bering = RandomStringUtils.randomAlphanumeric(8);
good.setCommbering(bering);
good.setInventory(0);
return new Result(200,"",service.addGood(good));
}
/**
* 更新/修改
* @param good
* @return
*/
@PostMapping("api/good/update")
public Result updateGoods(@RequestBody Good good){
return new Result(200,"",service.updateGood(good));
}
/**
* 删除
* @param commid
* @return
*/
@PostMapping("api/good/delete")
public Result deleteGood(Integer commid){
return new Result(200,"",service.deleteGood(commid));
}
/**
* 批量删除
* @param commids
* @return
*/
@PostMapping("api/good/delete/batch")
public Result batchDeleteGood(@RequestBody List<Integer> commids){
service.batchDelete(commids);
return new Result(200,"","");
}
/**
* 根據商品id加載商品資訊
* @param
* @return
*/
@PostMapping("api/good/loadGoodById")
public DataGridViewResult loadGoodsById(Integer commid) {
QueryWrapper<Good> goodsQueryWrapper = new QueryWrapper<>();
goodsQueryWrapper.eq(commid != 0, "commid", commid);
Good good = service.getById(commid);
System.out.println(good);
return new DataGridViewResult(good);
}
/**
* 根據供應商id加載商品資訊
* @param
* @return
*/
@PostMapping("api/good/loadProById")
public DataGridViewResult loadProById(Integer providerid) {
QueryWrapper<Good> goodsQueryWrapper = new QueryWrapper<>();
goodsQueryWrapper.eq(providerid != 0, "providerid", providerid);
Good good = service.getById(providerid);
System.out.println(good);
return new DataGridViewResult(good);
}
/**
* 加載下拉框
*
* @return
*/
@RequestMapping("api/good/AllGood")
public DataGridViewResult loadAllGoods() {
QueryWrapper<Good> queryWrapper = new QueryWrapper<>();
List<Good> list = service.list(queryWrapper);
return new DataGridViewResult(list);
}
}
package com.example.demo.controller;
import com.example.demo.result.SysResult;
import org.apache.tomcat.util.http.fileupload.FileUtils;
import org.springframework.http.MediaType;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
@RestController
public class ImageudController {
/**
* 檔案上傳
* @param picture
* @param request
* @return
*/
@RequestMapping("/api/good/upload")
public SysResult upload(@RequestParam("picture") MultipartFile picture, HttpServletRequest request) {
// 擷取檔案在伺服器的儲存位置
// String path = request.getSession().getServletContext().getRealPath("/upload");
// 将檔案存儲到vue的static檔案友善修改整理
String path = "E:/vue/demo-vue/static/upload";
File filePath = new File(path);
System.out.println("檔案的儲存路徑:" + path);
if (!filePath.exists() && !filePath.isDirectory()) {
System.out.println("目錄不存在,建立目錄:" + filePath);
filePath.mkdir();
}
//擷取原始檔案名稱(包含格式)
String originalFileName = picture.getOriginalFilename();
System.out.println("原始檔案名稱:" + originalFileName);
//擷取檔案類型,以最後一個`.`為辨別
String type = originalFileName.substring(originalFileName.lastIndexOf(".") + 1);
System.out.println("檔案類型:" + type);
//擷取檔案名稱(不包含格式)
String name = originalFileName.substring(0, originalFileName.lastIndexOf("."));
//設定檔案新名稱: 目前時間+檔案名稱(不包含格式)
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String date = sdf.format(d);
String fileName = date + name + "." + type;
System.out.println("新檔案名稱:" + fileName);
//在指定路徑下建立一個檔案
File targetFile = new File(path, fileName);
//将檔案儲存到指定位置
try {
picture.transferTo(targetFile);
System.out.println("上傳成功");
//将檔案在指定存儲路徑傳回
return new SysResult(true,"/upload/" + fileName);
} catch (IOException e) {
System.out.println("上傳失敗");
e.printStackTrace();
return new SysResult(false, "上傳失敗");
}
}
/**
* 檔案上傳
* @param image
* @param request
* @return
*/
@RequestMapping("/api/sildeshow/upload")
public SysResult uploads(@RequestParam("image") MultipartFile image, HttpServletRequest request) {
// 擷取檔案在伺服器的儲存位置
// String path = request.getSession().getServletContext().getRealPath("/upload");
// 将檔案存儲到vue的static檔案友善修改整理
String path = "E:/vue/demo-vue/static/upload";
File filePath = new File(path);
System.out.println("檔案的儲存路徑:" + path);
if (!filePath.exists() && !filePath.isDirectory()) {
System.out.println("目錄不存在,建立目錄:" + filePath);
filePath.mkdir();
}
//擷取原始檔案名稱(包含格式)
String originalFileName = image.getOriginalFilename();
System.out.println("原始檔案名稱:" + originalFileName);
//擷取檔案類型,以最後一個`.`為辨別
String type = originalFileName.substring(originalFileName.lastIndexOf(".") + 1);
System.out.println("檔案類型:" + type);
//擷取檔案名稱(不包含格式)
String name = originalFileName.substring(0, originalFileName.lastIndexOf("."));
//設定檔案新名稱: 目前時間+檔案名稱(不包含格式)
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String date = sdf.format(d);
String fileName = date + name + "." + type;
System.out.println("新檔案名稱:" + fileName);
//在指定路徑下建立一個檔案
File targetFile = new File(path, fileName);
//将檔案儲存到指定位置
try {
image.transferTo(targetFile);
System.out.println("上傳成功");
//将檔案在指定存儲路徑傳回
return new SysResult(true,"/upload/" + fileName);
} catch (IOException e) {
System.out.println("上傳失敗");
e.printStackTrace();
return new SysResult(false, "上傳失敗");
}
}
}
package com.example.demo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.dto.QueryDTO;
import com.example.demo.entity.Good;
import com.example.demo.entity.Provider;
import com.example.demo.entity.User;
import com.example.demo.result.DataGridViewResult;
import com.example.demo.result.Result;
import com.example.demo.service.ProviderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Author znz
* @Date 2022/10/3 0:06
* @Version 1.0
*/
@RestController
public class ProviderController {
@Autowired
private ProviderService service;
/**
* 分頁查詢
* @param queryDTO
* @return
*/
@PostMapping("api/provider/list")
public Result providerList(@RequestBody QueryDTO queryDTO){
return new Result(200,"",service.selectProviderPage(queryDTO));
}
/**
* 添加
* @param provider
* @return
*/
@PostMapping("api/provider/add")
public Result addProvider(@RequestBody Provider provider){
return new Result(200,"",service.addProvider(provider));
}
/**
* 更新/修改
* @param provider
* @return
*/
@PostMapping("api/provider/update")
public Result updateProvider(@RequestBody Provider provider){
return new Result(200,"",service.updateProvider(provider));
}
/**
* 删除
* @param providerid
* @return
*/
@PostMapping("api/provider/delete")
public Result deleteProvider(Integer providerid){
return new Result(200,"",service.deleteProvider(providerid));
}
/**
* 批量删除
* @param providerids
* @return
*/
@PostMapping("api/provider/delete/batch")
public Result batchDeleteProvider(@RequestBody List<Integer> providerids){
service.batchDelete(providerids);
return new Result(200,"","");
}
/**
* 根據供應商id加載供應商資訊
* @param
* @return
*/
@PostMapping("api/provider/loadProviderById")
public DataGridViewResult loadProviderById(Integer providerid) {
QueryWrapper<Provider> goodsQueryWrapper = new QueryWrapper<>();
goodsQueryWrapper.eq(providerid != 0, "providerid", providerid);
Provider provider = service.getById(providerid);
System.out.println(provider);
return new DataGridViewResult(provider);
}
/**
* 根據供應商id加載供應商資訊
* @param
* @return
*/
@PostMapping("api/provider/loadProviderByIds")
public DataGridViewResult loadProviderByIds(Integer providerid) {
QueryWrapper<Provider> goodsQueryWrapper = new QueryWrapper<>();
goodsQueryWrapper.eq(providerid != 0, "providerid", providerid);
Provider provider = service.getById(providerid);
System.out.println(provider);
return new DataGridViewResult(provider);
}
/**
* 加載下拉框
*
* @return
*/
@RequestMapping("api/provider/AllProvider")
public DataGridViewResult loadAllProvider() {
QueryWrapper<Provider> queryWrapper = new QueryWrapper<>();
List<Provider> list = service.list(queryWrapper);
return new DataGridViewResult(list);
}
}
五,項目總結
本項目功能齊全,基于前後端開發模式,前端和背景分别獨立運作,并且提供了進銷存商品展銷的前端頁面來供浏覽,比較适合做畢業設計使用。