前言
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本进销存管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此进销存管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了会员基础数据的管理,商品的入库与销售,设备管理,盘点管理,公告管理等功能。进销存管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
系统功能概述
Java SSM进销存管理系统,后端基于SSM框架进行开发设计,前端页面效果通过使用JSP进行编码实现,主要实现了员工跟管理员角色,将实现商品管理、出入库管理等功能。
开发环境
开发语言:Java 框架:springboot JDK版本:JDK1.8 服务器:tomcat7
数据库:mysql5.7(一定要5.7版本) 数据库工具:Navicat11 开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9 浏览器:谷歌浏览器后台路径地址:localhost:8080/项目名称/admin/dist/index.html
前台路径地址:localhost:8080/项目名称/front/dist/index.html (无前台不需要输入)管理员账号:admin 管理员密码:admin
开发技术简介
Java简介
Java是一种面向对象的静态式编程语言。Java编程语言具有多线程和对象定向的特点。其特点是根据方案的属性将方案分为几个不同的模块,这些模块是封闭的和多样化的,在申请过程中具有很强的独立性。Java语言在计算机软件开发过程中的运用可以达到交互操作的目的,通过各种形式的交换,可以有效地处理所需的数据,从而确保计算机软件开发的可控性和可见性。开发java语言时,保留了网络接口,Java保留的缺省网络接口可以与web应用程序编程所依赖的类别库相匹配。为了使Java开发的应用程序更加稳定和强健,Java会自动收集程序中的垃圾,并处理程序中存在的异常。Java语言是日常开发过程中广泛使用的通用基本语言。其中Java语言课程库、句子、语法规则和关键字经常用于计算机软件的开发和编程。
面向对象编程是Java语言最显着的特点。它具有原始接口和补充接口以及继承,不仅可以实现相同类型的单个继承,而且还支持接口之间的多个继承,从而实现类、接口和接口之间以及类和接口之间的有效通信。Java的面向对象特性主要包括三个方面:继承、多态性和封装。封装是Java的核心,可以封装所有数据操作。多态性是指由面向对象行为派生的相关行为。继承作为特殊编程模式有两种类型:父类和子类,这两种类型的属性具有相同的功能和特性。对于父类的属性特性,子类可以实现继承和优化。
Spring Boot框架介绍
SpringBoot是近几年最为流行的后台开发框架,它的诞生一改过去Spring框架开发中繁琐的配置,极大地简化了Spring应用的搭建和开发。SpringBoot框架不仅保有了Spring框架中的所有优秀特性,还通过使用特定的配置方式,在底层帮助开发人员在工程创建是就预先做了很多配置,这样在开发时就不再需要开发人员过多进行繁琐的配置了。另外在SpringBoot中集成了大量框架,这就使得开发人员不再需要到处寻找在导入开发中需要依赖的jar包,同时也解决了依赖包版本冲突问题,从而提高了依赖包引用的稳定性,从而实现了对Spring应用搭建和开发过程的简化。
MySQL数据库
MySQL是一种关系型的数据库管理系统,属于Oracle旗下的产品。MySQL的语言是非结构化的,使用的用户可以在数据上进行工作。这个数据库管理系统一经问世就受到了社会的广泛关注。在各个方面,与同等的数据库相比,MySQL的优点极为突出,它的运行速度快,适用的范围广泛,而且数据库的安全性这一方面独树一帜。在语言结构方面,MySQL的语言简单,其他数据库需要一大段代码来实现的操作,MySQL仅需要一小部分代码甚至几行。综上所述,MySQL这种关系型数据库管理系统,已经成为了开发者进行项目的数据开发、存储的不二之选。MySQL的功能也多种多样,如数据操纵和数据库的建立维护等。而且该数据库的数据共享性高、冗余度低而且容易扩充。MySQL在安全性这一方面也具有自身的特点,它应用了用户的标识和鉴别技术,对试图和数据进行加密,确保资料信息的可靠性。介于数据库系统的功能与强大等性质之间,本数据库系统的设计中主要使用了MySQL实现对数据的处理。基于Web的付费自习室管理系统运用MySQL数据库,在Web应用这一块,MySQL是最好的选择。对于该系统整个的开发、搭建、运行和维护具有极其重要的作用。
详细视频演示
请联系我获取更详细的演示视频
系统功能部分效果
核心代码
package com.controller;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;
/**
* 上传文件映射表
*/
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
@Autowired
private ConfigService configService;
/**
* 上传文件
*/
@RequestMapping("/upload")
public R upload(@RequestParam("file") MultipartFile file, String type,HttpServletRequest request) throws Exception {
if (file.isEmpty()) {
throw new EIException("上传文件不能为空");
}
String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
String fileName = new Date().getTime()+"."+fileExt;
File dest = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName);
file.transferTo(dest);
if(StringUtils.isNotBlank(type) && type.equals("1")) {
ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
if(configEntity==null) {
configEntity = new ConfigEntity();
configEntity.setName("faceFile");
configEntity.setValue(fileName);
} else {
configEntity.setValue(fileName);
}
configService.insertOrUpdate(configEntity);
}
return R.ok().put("file", fileName);
}
/**
* 下载文件
*/
@IgnoreAuth
@RequestMapping("/download")
public void download(@RequestParam String fileName, HttpServletRequest request, HttpServletResponse response) {
try {
File file = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+fileName);
if (file.exists()) {
response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName+"\"");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(FileUtils.readFileToByteArray(file), response.getOutputStream());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
package com.controller;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.GoodsEntity;
import com.service.GoodsService;
import com.entity.view.GoodsView;
import com.utils.PageUtils;
import com.utils.R;
/**
* 物资
* 后端接口
* @author
* @email
* @date
*/
@RestController
@Controller
@RequestMapping("/goods")
public class GoodsController {
private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);
@Autowired
private GoodsService goodsService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
params.put("flagStart",1);params.put("flagEnd",1);params.put("orderBy","id");
PageUtils page = goodsService.queryPage(params);
//字典表数据转换
List<GoodsView> list =(List<GoodsView>)page.getList();
for(GoodsView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
GoodsEntity goods = goodsService.selectById(id);
if(goods !=null){
//entity转view
GoodsView view = new GoodsView();
BeanUtils.copyProperties( goods , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody GoodsEntity goods, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,goods:{}",this.getClass().getName(),goods.toString());
Wrapper<GoodsEntity> queryWrapper = new EntityWrapper<GoodsEntity>()
.eq("goods_name", goods.getGoodsName())
.eq("danwei", goods.getDanwei())
.eq("flag", goods.getFlag())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GoodsEntity goodsEntity = goodsService.selectOne(queryWrapper);
if(goodsEntity==null){
goods.setCreateTime(new Date());
goods.setFlag(1);
goodsService.insert(goods);
return R.ok();
}else {
return R.error(511,"["+goods.getGoodsName()+"]商品的单位["+goods.getDanwei()+"]已经存在在数据库中");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody GoodsEntity goods, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,goods:{}",this.getClass().getName(),goods.toString());
//根据字段查询是否有相同数据
Wrapper<GoodsEntity> queryWrapper = new EntityWrapper<GoodsEntity>()
.notIn("id",goods.getId())
.andNew()
.eq("goods_name", goods.getGoodsName())
.eq("danwei", goods.getDanwei())
.eq("flag", goods.getFlag());
logger.info("sql语句:"+queryWrapper.getSqlSegment());
GoodsEntity goodsEntity = goodsService.selectOne(queryWrapper);
if("".equals(goods.getGoodsPhoto()) || "null".equals(goods.getGoodsPhoto())){
goods.setGoodsPhoto(null);
}
if(goodsEntity==null){
goodsService.updateById(goods);//根据id更新
return R.ok();
}else {
return R.error(511,"["+goods.getGoodsName()+"]商品的单位["+goods.getDanwei()+"]已经存在在数据库中");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<GoodsEntity> list=new ArrayList<>();
for(Integer i:ids){
GoodsEntity goods = new GoodsEntity();
goods.setFlag(2);
goods.setId(i);
list.add(goods);
}
if(list!= null && list.size()>0){
goodsService.updateBatchById(list);
return R.ok();
}else{
return R.error("没有选择要删除的数据");
}
}
}
package com.controller;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.DictionaryEntity;
import com.service.DictionaryService;
import com.entity.view.DictionaryView;
import com.service.YuangongService;
import com.utils.PageUtils;
import com.utils.R;
/**
* 字典表
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/dictionary")
public class DictionaryController {
private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);
@Autowired
private DictionaryService dictionaryService;
@Autowired
private TokenService tokenService;
//级联表service
@Autowired
private YuangongService yuangongService;
/**
* 后端列表
*/
@RequestMapping("/page")
@IgnoreAuth
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
params.put("orderBy","id");
PageUtils page = dictionaryService.queryPage(params);
//字典表数据转换
List<DictionaryView> list =(List<DictionaryView>)page.getList();
for(DictionaryView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
DictionaryEntity dictionary = dictionaryService.selectById(id);
if(dictionary !=null){
//entity转view
DictionaryView view = new DictionaryView();
BeanUtils.copyProperties( dictionary , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role)){
return R.error(511,"权限为空");
}
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.eq("code_index", dictionary.getCodeIndex())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){
dictionary.setCreateTime(new Date());
dictionaryService.insert(dictionary);
//如果字典表新增数据的话,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role)){
return R.error(511,"权限为空");
}
//根据字段查询是否有相同数据
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.notIn("id",dictionary.getId())
.eq("dic_code", dictionary.getDicCode())
.eq("code_index", dictionary.getCodeIndex())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// dictionary.set
// }
dictionaryService.updateById(dictionary);//根据id更新
//如果字典表修改数据的话,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
dictionaryService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
package com.controller;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.PandianOrderListEntity;
import com.service.PandianOrderListService;
import com.entity.view.PandianOrderListView;
import com.service.GoodsService;
import com.entity.GoodsEntity;
import com.service.PandianOrderService;
import com.entity.PandianOrderEntity;
import com.service.YuangongService;
import com.utils.PageUtils;
import com.utils.R;
/**
* 盘点详情
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/pandianOrderList")
public class PandianOrderListController {
private static final Logger logger = LoggerFactory.getLogger(PandianOrderListController.class);
@Autowired
private PandianOrderListService pandianOrderListService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private GoodsService goodsService;
@Autowired
private PandianOrderService pandianOrderService;
@Autowired
private YuangongService yuangongService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role)){
return R.error(511,"权限为空");
}
else if("员工".equals(role)){
params.put("yuangongId",request.getSession().getAttribute("userId"));
}
params.put("orderBy","id");
PageUtils page = pandianOrderListService.queryPage(params);
//字典表数据转换
List<PandianOrderListView> list =(List<PandianOrderListView>)page.getList();
for(PandianOrderListView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
PandianOrderListEntity pandianOrderList = pandianOrderListService.selectById(id);
if(pandianOrderList !=null){
//entity转view
PandianOrderListView view = new PandianOrderListView();
BeanUtils.copyProperties( pandianOrderList , view );//把实体数据重构到view中
//级联表
GoodsEntity goods = goodsService.selectById(pandianOrderList.getGoodsId());
if(goods != null){
BeanUtils.copyProperties( goods , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setGoodsId(goods.getId());
}
//级联表
PandianOrderEntity pandianOrder = pandianOrderService.selectById(pandianOrderList.getPandianOrderId());
if(pandianOrder != null){
BeanUtils.copyProperties( pandianOrder , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setPandianOrderId(pandianOrder.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody PandianOrderListEntity pandianOrderList, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,pandianOrderList:{}",this.getClass().getName(),pandianOrderList.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role)){
return R.error(511,"权限为空");
}
pandianOrderList.setInsertTime(new Date());
pandianOrderList.setCreateTime(new Date());
pandianOrderListService.insert(pandianOrderList);
return R.ok();
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody PandianOrderListEntity pandianOrderList, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,pandianOrderList:{}",this.getClass().getName(),pandianOrderList.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role)){
return R.error(511,"权限为空");
}
pandianOrderListService.updateById(pandianOrderList);//根据id更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
pandianOrderListService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}