Java项目:193Springboot + vue实现的便利店信息管理系统(含论文)

 作者主页:源码空间站2022​​​​​​​

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

基于Springboot + vue实现的便利店信息管理系统

系统包含员工、管理员两个角色

员工:登录、个人中心、供应商信息管理、商品管理、收银管理等功能

管理员:登录、个人中心、基础数据管理、供应商信息管理、商品管理、采购管理、收银管理、员工管理等功能

使用人群:
正在做毕设的学生,或者需要项目实战练习的Java学习者

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
4.数据库:MySql 5.7/8.0版本均可;

5.是否Maven项目:是;

技术栈

后端:SpringBoot+Mybaits

前端:Vue + elementui

使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4.运行项目,在浏览器中输入地址:
后台登录页面
http://localhost:8080/bianlidian/admin/dist/index.html#/login
管理员账户:admin 密码:admin

员工:a1 密码:123456

运行截图

论文

截图

相关代码

GoodsChuruInoutController











package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
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.*;
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.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 采购
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/goodsChuruInout")
public class GoodsChuruInoutController {
    private static final Logger logger = LoggerFactory.getLogger(GoodsChuruInoutController.class);

    @Autowired
    private GoodsChuruInoutService goodsChuruInoutService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service
    @Autowired
    private GongyingshangService gongyingshangService;

    // 列表详情的表级联service
    @Autowired
    private GoodsChuruInoutListService goodsChuruInoutListService;
//    @Autowired
//    private YonghuService yonghuService;
    @Autowired
    private GoodsService goodsService;
    @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"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = goodsChuruInoutService.queryPage(params);

        //字典表数据转换
        List<GoodsChuruInoutView> list =(List<GoodsChuruInoutView>)page.getList();
        for(GoodsChuruInoutView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        GoodsChuruInoutEntity goodsChuruInout = goodsChuruInoutService.selectById(id);
        if(goodsChuruInout !=null){
            //entity转view
            GoodsChuruInoutView view = new GoodsChuruInoutView();
            BeanUtils.copyProperties( goodsChuruInout , view );//把实体数据重构到view中

                //级联表
                GongyingshangEntity gongyingshang = gongyingshangService.selectById(goodsChuruInout.getGongyingshangId());
                if(gongyingshang != null){
                    BeanUtils.copyProperties( gongyingshang , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setGongyingshangId(gongyingshang.getId());
                }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody GoodsChuruInoutEntity goodsChuruInout, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,goodsChuruInout:{}",this.getClass().getName(),goodsChuruInout.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");
        Wrapper<GoodsChuruInoutEntity> queryWrapper = new EntityWrapper<GoodsChuruInoutEntity>()
            .eq("gongyingshang_id", goodsChuruInout.getGongyingshangId())
            .eq("goods_churu_inout_uuid_number", goodsChuruInout.getGoodsChuruInoutUuidNumber())
            .eq("goods_churu_inout_name", goodsChuruInout.getGoodsChuruInoutName())
            .eq("goods_churu_inout_types", goodsChuruInout.getGoodsChuruInoutTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        GoodsChuruInoutEntity goodsChuruInoutEntity = goodsChuruInoutService.selectOne(queryWrapper);
        if(goodsChuruInoutEntity==null){
            goodsChuruInout.setInsertTime(new Date());
            goodsChuruInout.setCreateTime(new Date());
            goodsChuruInoutService.insert(goodsChuruInout);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody GoodsChuruInoutEntity goodsChuruInout, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,goodsChuruInout:{}",this.getClass().getName(),goodsChuruInout.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");
        //根据字段查询是否有相同数据
        Wrapper<GoodsChuruInoutEntity> queryWrapper = new EntityWrapper<GoodsChuruInoutEntity>()
            .notIn("id",goodsChuruInout.getId())
            .andNew()
            .eq("gongyingshang_id", goodsChuruInout.getGongyingshangId())
            .eq("goods_churu_inout_uuid_number", goodsChuruInout.getGoodsChuruInoutUuidNumber())
            .eq("goods_churu_inout_name", goodsChuruInout.getGoodsChuruInoutName())
            .eq("goods_churu_inout_types", goodsChuruInout.getGoodsChuruInoutTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        GoodsChuruInoutEntity goodsChuruInoutEntity = goodsChuruInoutService.selectOne(queryWrapper);
        if(goodsChuruInoutEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      goodsChuruInout.set
            //  }
            goodsChuruInoutService.updateById(goodsChuruInout);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }
    /**
    * 出库
    */
    @RequestMapping("/outGoodsChuruInoutList")
    public R outGoodsChuruInoutList(@RequestBody  Map<String, Object> params,HttpServletRequest request){
        logger.debug("outGoodsChuruInoutList方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");

        //取出采购名称并判断是否存在
        String goodsChuruInoutName = String.valueOf(params.get("goodsChuruInoutName"));
        Wrapper<GoodsChuruInoutEntity> queryWrapper = new EntityWrapper<GoodsChuruInoutEntity>()
            .eq("goods_churu_inout_name", goodsChuruInoutName)
            ;
        GoodsChuruInoutEntity goodsChuruInoutSelectOne = goodsChuruInoutService.selectOne(queryWrapper);
        if(goodsChuruInoutSelectOne != null)
            return R.error(511,"采购名称已被使用");


    //取当前表的级联表并判断是否前台传入

        //String gongyingshangId = String.valueOf(params.get("gongyingshangId"));
        //if(StringUtil.isEmpty(gongyingshangId))
        //    return R.error(511,"供应商不能为空");

        Map<String, Integer> map = (Map<String, Integer>) params.get("map");
        if(map == null || map.size() == 0)
            return R.error(511,"列表内容不能为空");


        Set<String> ids = map.keySet();

        List<GoodsEntity> goodsList = goodsService.selectBatchIds(ids);
        if(goodsList == null || goodsList.size() == 0){
            return R.error(511,"查数据库查不到数据");
        }else{
            for(GoodsEntity w:goodsList){
                Integer value = w.getGoodsKucunNumber()-map.get(String.valueOf(w.getId()));
                if(value <0){
                    return R.error(511,"出库数量大于库存数量");
                }
                w.setGoodsKucunNumber(value);
            }
        }

        //当前表
        GoodsChuruInoutEntity goodsChuruInoutEntity = new GoodsChuruInoutEntity<>();
            goodsChuruInoutEntity.setGongyingshangId(null);
            goodsChuruInoutEntity.setGoodsChuruInoutUuidNumber(String.valueOf(new Date().getTime()));
            goodsChuruInoutEntity.setGoodsChuruInoutName(goodsChuruInoutName);
            goodsChuruInoutEntity.setGoodsChuruInoutTypes(1);
            goodsChuruInoutEntity.setGoodsChuruInoutContent("");
            goodsChuruInoutEntity.setInsertTime(new Date());
            goodsChuruInoutEntity.setCreateTime(new Date());

        boolean insertGoodsChuruInout = goodsChuruInoutService.insert(goodsChuruInoutEntity);
        if(insertGoodsChuruInout){
            //级联表
            ArrayList<GoodsChuruInoutListEntity> goodsChuruInoutLists = new ArrayList<>();
            for(String id:ids){
                GoodsChuruInoutListEntity goodsChuruInoutListEntity = new GoodsChuruInoutListEntity();
                    goodsChuruInoutListEntity.setGoodsChuruInoutId(goodsChuruInoutEntity.getId());
                    goodsChuruInoutListEntity.setGoodsId(Integer.valueOf(id));
                    goodsChuruInoutListEntity.setGoodsChuruInoutListNumber(map.get(id));
                    goodsChuruInoutListEntity.setInsertTime(new Date());
                    goodsChuruInoutListEntity.setCreateTime(new Date());
                goodsChuruInoutLists.add(goodsChuruInoutListEntity);
                goodsService.updateBatchById(goodsList);
            }
            goodsChuruInoutListService.insertBatch(goodsChuruInoutLists);
        }
        return R.ok();
    }

    /**
    *采购
    */
    @RequestMapping("/inGoodsChuruInoutList")
    public R inGoodsChuruInoutList(@RequestBody  Map<String, Object> params,HttpServletRequest request){
        logger.debug("inGoodsChuruInoutList方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        //params:{"map":{"1":2,"2":3},"wuziOutinName":"订单1"}

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(StringUtil.isEmpty(role))
            return R.error(511,"权限为空");

        //取当前表名称并判断
        String goodsChuruInoutName = String.valueOf(params.get("goodsChuruInoutName"));
        Wrapper<GoodsChuruInoutEntity> queryWrapper = new EntityWrapper<GoodsChuruInoutEntity>()
            .eq("goods_churu_inout_name", goodsChuruInoutName)
            ;
        GoodsChuruInoutEntity goodsChuruInoutSelectOne = goodsChuruInoutService.selectOne(queryWrapper);
        if(goodsChuruInoutSelectOne != null)
            return R.error(511,"采购名称已被使用");


        //取当前表的级联表并判断是否前台传入

        String gongyingshangId = String.valueOf(params.get("gongyingshangId"));
        if(StringUtil.isEmpty(gongyingshangId))
            return R.error(511,"供应商不能为空");

        Map<String, Integer> map = (Map<String, Integer>) params.get("map");
        if(map == null || map.size() == 0)
            return R.error(511,"列表内容不能为空");

        Set<String> ids = map.keySet();

        List<GoodsEntity> goodsList = goodsService.selectBatchIds(ids);
        if(goodsList == null || goodsList.size() == 0){
            return R.error(511,"查数据库查不到数据");
        }else{
            for(GoodsEntity w:goodsList){
                w.setGoodsKucunNumber(w.getGoodsKucunNumber()+map.get(String.valueOf(w.getId())));
            }
        }

        //当前表
        GoodsChuruInoutEntity goodsChuruInoutEntity = new GoodsChuruInoutEntity<>();
            goodsChuruInoutEntity.setGongyingshangId(Integer.valueOf(gongyingshangId));
            goodsChuruInoutEntity.setGoodsChuruInoutUuidNumber(String.valueOf(new Date().getTime()));
            goodsChuruInoutEntity.setGoodsChuruInoutName(goodsChuruInoutName);
            goodsChuruInoutEntity.setGoodsChuruInoutTypes(2);
            goodsChuruInoutEntity.setGoodsChuruInoutContent("");
            goodsChuruInoutEntity.setInsertTime(new Date());
            goodsChuruInoutEntity.setCreateTime(new Date());


        boolean insertGoodsChuruInout = goodsChuruInoutService.insert(goodsChuruInoutEntity);
        if(insertGoodsChuruInout){
            //级联表
            ArrayList<GoodsChuruInoutListEntity> goodsChuruInoutLists = new ArrayList<>();
            for(String id:ids){
                GoodsChuruInoutListEntity goodsChuruInoutListEntity = new GoodsChuruInoutListEntity();
                goodsChuruInoutListEntity.setGoodsChuruInoutId(goodsChuruInoutEntity.getId());
                goodsChuruInoutListEntity.setGoodsId(Integer.valueOf(id));
                goodsChuruInoutListEntity.setGoodsChuruInoutListNumber(map.get(id));
                goodsChuruInoutListEntity.setInsertTime(new Date());
                goodsChuruInoutListEntity.setCreateTime(new Date());
                goodsChuruInoutLists.add(goodsChuruInoutListEntity);
                goodsService.updateBatchById(goodsList);
            }
            goodsChuruInoutListService.insertBatch(goodsChuruInoutLists);
        }

        return R.ok();
    }
    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        goodsChuruInoutService.deleteBatchIds(Arrays.asList(ids));
        goodsChuruInoutListService.delete(new EntityWrapper<GoodsChuruInoutListEntity>().in("goods_churu_inout_id",ids));
        return R.ok();
    }

    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        try {
            List<GoodsChuruInoutEntity> goodsChuruInoutList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            GoodsChuruInoutEntity goodsChuruInoutEntity = new GoodsChuruInoutEntity();
//                            goodsChuruInoutEntity.setGongyingshangId(Integer.valueOf(data.get(0)));   //供应商 要改的
//                            goodsChuruInoutEntity.setGoodsChuruInoutUuidNumber(data.get(0));                    //采购流水号 要改的
//                            goodsChuruInoutEntity.setGoodsChuruInoutName(data.get(0));                    //采购名称 要改的
//                            goodsChuruInoutEntity.setGoodsChuruInoutTypes(Integer.valueOf(data.get(0)));   //出采购类型 要改的
//                            goodsChuruInoutEntity.setGoodsChuruInoutContent("");//照片
//                            goodsChuruInoutEntity.setInsertTime(date);//时间
//                            goodsChuruInoutEntity.setCreateTime(date);//时间
                            goodsChuruInoutList.add(goodsChuruInoutEntity);


                            //把要查询是否重复的字段放入map中
                                //采购流水号
                                if(seachFields.containsKey("goodsChuruInoutUuidNumber")){
                                    List<String> goodsChuruInoutUuidNumber = seachFields.get("goodsChuruInoutUuidNumber");
                                    goodsChuruInoutUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> goodsChuruInoutUuidNumber = new ArrayList<>();
                                    goodsChuruInoutUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("goodsChuruInoutUuidNumber",goodsChuruInoutUuidNumber);
                                }
                        }

                        //查询是否重复
                         //采购流水号
                        List<GoodsChuruInoutEntity> goodsChuruInoutEntities_goodsChuruInoutUuidNumber = goodsChuruInoutService.selectList(new EntityWrapper<GoodsChuruInoutEntity>().in("goods_churu_inout_uuid_number", seachFields.get("goodsChuruInoutUuidNumber")));
                        if(goodsChuruInoutEntities_goodsChuruInoutUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(GoodsChuruInoutEntity s:goodsChuruInoutEntities_goodsChuruInoutUuidNumber){
                                repeatFields.add(s.getGoodsChuruInoutUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [采购流水号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        goodsChuruInoutService.insertBatch(goodsChuruInoutList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }





}

如果也想学习本系统,下面领取。关注并回复:193springboot

  • 26
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值