文章目录
- 前言
- 项目介绍
- 技术介绍
- 功能介绍
- 核心代码
- 数据库参考
- 系统效果图
前言
示
文章底部名片,获取项目的完整演示视频,免费解答技术疑问
项目介绍
小型超市商品管理系统是一款针对小型超市日常运营需求设计的软件解决方案。该系统主要内容有商品类别管理、商品库存管理、入库信息管理、销售订单管理等功能,实现了对超市商品的全面管理。它简化了商品管理流程,提高了工作效率,有助于超市管理者实时掌握商品动态,优化库存结构,降低运营成本。
本论文将总体分析小型超市商品需求,再从不同角度分析具体功能需求,运用net相关技术,采用MySQL数据库,讨论如何设计并实现一个小型超市商品管理系统。分析和设计主要从管理员、采购员和销售员三个角色上展开研究,介绍了各个功能模块的实现,并通过系统测试对小型超市商品管理系统进行调试,将各个功能的测试结果与期望设计进行逐一比对,找出BUG和欠缺之处,从而进一步优化改进系统。
本套基于Java的小型超市商品管理系统的设计与实现,希望能让用户通过互联网得到方便而快捷的系统管理体验,在此基础的同时提高工作效益。
技术介绍
开发软件:VS 2017 (版本2017以上即可,不能低于2017)
数据库:SqlServer2008r2(数据库版本无限制,都可以导入)
开发模式:mvc
浏览器:谷歌浏览器
功能介绍
本文从小型超市商品管理的实际需要出发,为降低系统的耦合性,完成了系统总体架构的设计,以提高系统的重用性、可适用性及可维护性。系统包括管理员、采购员和销售员三个角色;
管理员负责对整个系统进行管理和监控,而其他用户则负责执行具体的管理工作。管理员、采购员和销售员
系统整体模块分为管理员、采购员和销售员三大用户角色,整体功能设计图如下所示:
图4-1 系统整体功能图
核心代码
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Newtonsoft.Json;
using Xiezn.Core.Business.Services;
using Xiezn.Core.Common.Helpers;
using Xiezn.Core.Models.ViewModel;
namespace Xiezn.Core.Controllers
{
/// <summary>
/// 公共接口
/// </summary>
[Route("[action]")]
public class CommonController : Controller
{
private readonly IHostingEnvironment _hostingEnvironment;
private readonly string _savePath;
private readonly CommonService _bll;
private readonly ConfigService _configBLL;
/// <summary>
/// 构造函数
/// </summary>
public CommonController(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
_savePath = _hostingEnvironment.WebRootPath + Path.DirectorySeparatorChar + ConfigHelper.GetConfig("SchemaName") + Path.DirectorySeparatorChar + "upload" + Path.DirectorySeparatorChar;
_bll = new CommonService();
_configBLL = new ConfigService();
}
/// <summary>
/// 获取某表的某个字段列表接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="columnName">列名</param>
/// <returns></returns>
[HttpGet("{tableName}/{columnName}")]
public JsonResult Option(string tableName, string columnName)
{
try
{
int level = Convert.ToInt32(HttpContext.Request.Query["level"]);
string parent = HttpContext.Request.Query["parent"];
string conditionColumn = HttpContext.Request.Query["conditionColumn"];
string conditionValue = HttpContext.Request.Query["conditionValue"];
if (!string.IsNullOrEmpty(conditionColumn) && !string.IsNullOrEmpty(conditionValue))
{
return Json(new { Code = 0, Data = _bll.Common(tableName, columnName, "", 0, "option", 0, 0, " AND " + conditionColumn + " = '" + conditionValue + "' ") });
}
if (level == 0)
{
return Json(new { Code = 0, Data = _bll.Common(tableName, columnName, parent, level) });
}
else
{
return Json(new { Code = 0, Data = _bll.Common(tableName, columnName) });
}
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 根据option字段值获取某表的单行记录接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="columnName">列名</param>
/// <param name="columnValue">列值</param>
/// <returns></returns>
[HttpGet("{tableName}/{columnName}")]
public JsonResult Follow(string tableName, string columnName, string columnValue)
{
try
{
return Json(new { Code = 0, Data = _bll.Common(tableName, columnName, columnValue, 0, "follow") });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 根据主键id修改table表的sfsh状态接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="id">主键id</param>
/// <param name="sfsh">当前审核状态(是/否)</param>
/// <returns></returns>
[HttpPost("{tableName}")]
[Authorize(Roles = "Admin,Client")]
public JsonResult Sh(string tableName, int id, string sfsh)
{
try
{
if (_bll.Common(tableName, id.ToString(), sfsh, 0, "sh") > 0)
{
return Json(new { Code = 0, Msg = "更新成功!" });
}
return Json(new { Code = -1, Msg = "更新失败!" });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 获取需要提醒的记录数接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="columnName">列名</param>
/// <param name="type">类型(1表示数字比较提醒,2表示日期比较提醒)</param>
/// <param name="remindStart">remindStart小于等于columnName满足条件提醒,当比较日期时,该值表示天数</param>
/// <param name="remindEnd">columnName小于等于remindEnd 满足条件提醒,当比较日期时,该值表示天数</param>
/// <returns></returns>
[HttpGet("{tableName}/{columnName}/{type}")]
public JsonResult Remind(string tableName, string columnName, int type, int remindStart, int remindEnd)
{
try
{
return Json(new { Code = 0, Count = _bll.Common(tableName, columnName, "", type, "remind", remindStart, remindEnd) });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 计算规则接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="columnName">列名</param>
/// <returns></returns>
[HttpGet("{tableName}/{columnName}")]
public JsonResult Cal(string tableName, string columnName)
{
try
{
return Json(new { Code = 0, Data = _bll.Common(tableName, columnName, "", 0, "cal") });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 人脸比较
/// </summary>
/// <param name="face1">图片1名称</param>
/// <param name="face2">图片2名称</param>
/// <returns></returns>
[HttpGet]
public JsonResult MatchFace(string face1, string face2)
{
try
{
BaiduAiHelper.clientId = _configBLL.GetValueByName("APIKey");
BaiduAiHelper.clientSecret = _configBLL.GetValueByName("SecretKey");
BaiduAiHelper.GetAccessToken();
List<FaceMatchViewModel> matchInfo = new List<FaceMatchViewModel>
{
new FaceMatchViewModel { image = FuncHelper.ImageToBase64(_savePath + face1) },
new FaceMatchViewModel { image = FuncHelper.ImageToBase64(_savePath + face2) }
};
string result = BaiduAiHelper.FaceMatch(JsonConvert.SerializeObject(matchInfo));
dynamic resObj = JsonConvert.DeserializeObject(result);
if (resObj.error_code == 0)
{
return Json(new { Code = 0, Score = resObj.result.score, Msg = "匹配成功!" });
}
else
{
return Json(new { Code = -1, Score = 0, Msg = "匹配失败!" });
}
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 定位接口(根据经纬度坐标获取到省市县(区)信息)
/// </summary>
/// <param name="lat">经度</param>
/// <param name="lng">纬度</param>
/// <returns></returns>
[HttpGet]
public JsonResult Location(double lat, double lng)
{
try
{
AddressViewModel addressViewModel = BaiduAiHelper.GetAddress(_configBLL.GetValueByName("baidu_ditu_ak"), lng, lat);
if (addressViewModel == null)
{
return Json(new { Code = -1, Msg = "位置信息获取失败!" });
}
else
{
return Json(new { Code = 0, Data = addressViewModel });
}
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 类别统计接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="columnName">列名</param>
/// <returns></returns>
[HttpGet("{tableName}/{columnName}")]
public JsonResult Group(string tableName, string columnName)
{
try
{
return Json(new { Code = 0, Data = _bll.Common(tableName, columnName, "", 0, "group") });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 按值统计接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="xColumnName">列名</param>
/// <param name="yColumnName">列名</param>
/// <returns></returns>
[HttpGet("{tableName}/{xColumnName}/{yColumnName}")]
public JsonResult Value(string tableName, string xColumnName, string yColumnName)
{
try
{
return Json(new { Code = 0, Data = _bll.Common(tableName, xColumnName, yColumnName, 0, "value") });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 按时间统计类型接口
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="xColumnName">列名</param>
/// <param name="yColumnName">列名</param>
/// <param name="timeStatType">类型</param>
/// <returns></returns>
[HttpGet("{tableName}/{xColumnName}/{yColumnName}/{timeStatType}")]
public JsonResult Value(string tableName, string xColumnName, string yColumnName, string timeStatType)
{
try
{
return Json(new { Code = 0, Data = _bll.StatDate(tableName, xColumnName, yColumnName, timeStatType) });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
/// <summary>
/// 数据备份
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Mysqldump()
{
string filepath = _savePath + "mysql.dmp";
// Linux
string cmd = "/bin/bash";
string strInput = "/usr/bin/mysqldump -h127.0.0.1 -uroot -P3306 -p123456 net2h303777 > " + filepath;
// Windows
// string cmd = "cmd.exe";
// string strInput = "D:\\mysqldump -h127.0.0.1 -uroot -P3306 -p123456 net2h303777 > " + filepath;
Process p = new Process();
p.StartInfo.FileName = cmd;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(strInput);
p.StandardInput.AutoFlush = true;
p.StandardInput.Close();
string strOuput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
var stream = System.IO.File.OpenRead(filepath);
return File(stream, "application/octet-stream", "mysql.dmp");
}
/// md5加密接口
[HttpGet("{encryption}")]
public IActionResult Encrypt(string encryption)
{
try
{
string text = HttpContext.Request.Query["text"];
string data = FuncHelper.MD5(text);
return Json(new { Code = 0,Data = data });
}
catch (Exception ex)
{
return Json(new { Code = 500, Msg = ex.Message });
}
}
}
}
数据库参考
--
-- Current Database: `netm28u50w3`
--
/*!40000 DROP DATABASE IF EXISTS `netm28u50w3`*/;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `netm28u50w3` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `netm28u50w3`;
--
-- Table structure for table `caigouyuan`
--
DROP TABLE IF EXISTS `caigouyuan`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `caigouyuan` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`caigougonghao` varchar(200) DEFAULT NULL COMMENT '采购工号',
`caigouxingming` varchar(200) DEFAULT NULL COMMENT '采购姓名',
`mima` varchar(200) DEFAULT NULL COMMENT '密码',
`xingbie` varchar(200) DEFAULT NULL COMMENT '性别',
`zhicheng` varchar(200) DEFAULT NULL COMMENT '职称',
`lianxidianhua` varchar(200) DEFAULT NULL COMMENT '联系电话',
`touxiang` longtext COMMENT '头像',
PRIMARY KEY (`id`),
UNIQUE KEY `caigougonghao` (`caigougonghao`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COMMENT='采购员';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `caigouyuan`
--
LOCK TABLES `caigouyuan` WRITE;
/*!40000 ALTER TABLE `caigouyuan` DISABLE KEYS */;
INSERT INTO `caigouyuan` VALUES (11,'2024-04-02 10:04:53','采购工号1','采购姓名1','123456','男','职称1','13823888881','upload/caigouyuan_touxiang1.jpg'),(12,'2024-04-02 10:04:53','采购工号2','采购姓名2','123456','男','职称2','13823888882','upload/caigouyuan_touxiang2.jpg'),(13,'2024-04-02 10:04:53','采购工号3','采购姓名3','123456','男','职称3','13823888883','upload/caigouyuan_touxiang3.jpg'),(14,'2024-04-02 10:04:53','采购工号4','采购姓名4','123456','男','职称4','13823888884','upload/caigouyuan_touxiang4.jpg'),(15,'2024-04-02 10:04:53','采购工号5','采购姓名5','123456','男','职称5','13823888885','upload/caigouyuan_touxiang5.jpg'),(16,'2024-04-02 10:04:53','采购工号6','采购姓名6','123456','男','职称6','13823888886','upload/caigouyuan_touxiang6.jpg'),(17,'2024-04-02 10:04:53','采购工号7','采购姓名7','123456','男','职称7','13823888887','upload/caigouyuan_touxiang7.jpg'),(18,'2024-04-02 10:04:53','采购工号8','采购姓名8','123456','男','职称8','13823888888','upload/caigouyuan_touxiang8.jpg');
/*!40000 ALTER TABLE `caigouyuan` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `config`
--
DROP TABLE IF EXISTS `config`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(100) NOT NULL COMMENT '配置参数名称',
`value` varchar(100) DEFAULT NULL COMMENT '配置参数值',
`url` varchar(500) DEFAULT NULL COMMENT 'url',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='配置文件';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `config`
--
LOCK TABLES `config` WRITE;
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
INSERT INTO `config` VALUES (1,'picture1','upload/picture1.jpg',NULL),(2,'picture2','upload/picture2.jpg',NULL),(3,'picture3','upload/picture3.jpg',NULL);
/*!40000 ALTER TABLE `config` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `gongyingshang`
--
DROP TABLE IF EXISTS `gongyingshang`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `gongyingshang` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gongyingshang` varchar(200) NOT NULL COMMENT '供应商',
`dizhi` varchar(200) DEFAULT NULL COMMENT '地址',
`lianxidianhua` varchar(200) DEFAULT NULL COMMENT '联系电话',
`fuzeren` varchar(200) NOT NULL COMMENT '负责人',
`zhiwu` varchar(200) DEFAULT NULL COMMENT '职务',
`yingyezhizhaohaoma` varchar(200) DEFAULT NULL COMMENT '营业执照号码',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=79 DEFAULT CHARSET=utf8 COMMENT='供应商';
/*!40101 SET character_set_client = @saved_cs_client */;
系统效果图