基于java+ssm+jsp的电脑硬件库存管理系统

本文介绍了采用Java语言和Mysql数据库构建的电脑硬件库存管理系统,该系统解决了库存信息管理混乱、安全性差等问题,实现了硬件管理、库存统计、出入库订单管理和用户查询等功能,采用B/S架构和SSM框架,提高了信息管理的效率和安全性。
摘要由CSDN通过智能技术生成

项目介绍

互联网发展至今,无论是其理论还是技术都已经成熟,而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播,搭配信息管理工具可以很好地为人们提供服务。针对电脑硬件库存信息管理混乱,出错率高,信息安全性差,劳动强度大,费时费力等问题,采用电脑硬件库存管理系统可以有效管理,使信息管理能够更加科学和规范。

电脑硬件库存管理系统在idea环境中,使用Java语言进行编码,使用Mysql创建数据表保存本系统产生的数据。系统可以提供信息显示和相应服务,其管理员管理硬件和硬件类型,统计硬件库存数量,对订单进行出入库管理。用户查询公告,查询硬件和出入库订单。

总之,电脑硬件库存管理系统集中管理信息,有着保密性强,效率高,存储空间大,成本低等诸多优点。它可以降低信息管理成本,实现信息管理计算机化。

4.2 功能结构设计
在前面分析的管理员功能的基础上,进行接下来的设计工作,最终展示设计的管理员结构图(见下图)。管理员管理硬件和硬件类型,统计硬件库存数量,对订单进行出入库管理。
在这里插入图片描述
在前面分析的用户功能的基础上,进行接下来的设计工作,最终展示设计的用户结构图(见下图)。用户查询公告,查询硬件和出入库订单。
在这里插入图片描述

开发环境

编程语言:Java
数据库 :Mysql
系统架构:B/S
后端框架:SSM
编译工具:idea或者eclipse,jdk1.8,maven
支持定做:java/php/python/android/小程序ue/爬虫/c#/asp.net

系统实现

5.1.1 硬件管理
管理员进入指定功能操作区之后可以管理硬件。其页面见下图。管理员增删改查硬件信息。
在这里插入图片描述

图5.1 硬件管理页面

5.1.2 硬件统计
管理员进入指定功能操作区之后可以统计硬件数量。其页面见下图。管理员查看各种硬件的数量统计信息以及占比情况。
在这里插入图片描述

图5.2 硬件统计页面

5.1.3 出入库订单管理
管理员进入指定功能操作区之后可以管理出入库订单。其页面见下图。管理员对订单进行出入库操作。
在这里插入图片描述

图5.3 出入库订单管理页面

5.1.4 用户管理
管理员进入指定功能操作区之后可以管理用户。其页面见下图。本功能就是为了方便管理员增加用户,修改用户,批量删除用户而设置的。
在这里插入图片描述

图5.4 用户管理页面

5.2 用户功能实现
5.2.1 查询系统公告
用户进入指定功能操作区之后可以查询系统公告。其页面见下图。用户根据标题查询系统公告。
在这里插入图片描述

图5.5 查询系统公告页面

5.2.2 查询出入库订单
用户进入指定功能操作区之后可以查询出入库订单。其页面见下图。用户查询出入库订单可以根据出入库时间查询,也能根据订单名查询。
在这里插入图片描述

图5.6 查询出入库订单页面

5.2.3 查询硬件
用户进入指定功能操作区之后可以查询硬件。其页面见下图。用户查询硬件可以根据单价查询,也能根据数量查询。
在这里插入图片描述

图5.7 查询硬件页面

核心代码

package com.controller;


import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;

import com.entity.GoodsEntity;
import com.entity.InOutOrderListEntity;
import com.service.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;

import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;

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.InOutOrderEntity;

import com.entity.view.InOutOrderView;
import com.utils.PageUtils;
import com.utils.R;

/**
 * 出入库订单
 * 后端接口
 * @author
 * @email
 * @date
*/
@RestController
@Controller
@RequestMapping("/inOutOrder")
public class InOutOrderController {
    private static final Logger logger = LoggerFactory.getLogger(InOutOrderController.class);

    @Autowired
    private InOutOrderService inOutOrderService;


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


    //级联表service

    // 商品表
    @Autowired
    private GoodsService goodsService;
    //订单详情表
    @Autowired
    private InOutOrderListService inOutOrderListService;


    /**
    * 后端列表
    */
    @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.isNotEmpty(role) && "用户".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        }
        PageUtils page = inOutOrderService.queryPage(params);

        //字典表数据转换
        List<InOutOrderView> list =(List<InOutOrderView>)page.getList();
        for(InOutOrderView 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);
        InOutOrderEntity inOutOrder = inOutOrderService.selectById(id);
        if(inOutOrder !=null){
            //entity转view
            InOutOrderView view = new InOutOrderView();
            BeanUtils.copyProperties( inOutOrder , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("ve")
    public R save(@RequestBody InOutOrderEntity inOutOrder, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,inOutOrder:{}",this.getClass().getName(),inOutOrder.toString());
        Wrapper<InOutOrderEntity> queryWrapper = new EntityWrapper<InOutOrderEntity>()
            .eq("order_name", inOutOrder.getOrderName())
            .eq("caozuo_name", inOutOrder.getCaozuoName())
            .eq("caozuo_table", inOutOrder.getCaozuoTable())
            .eq("order_types", inOutOrder.getOrderTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        InOutOrderEntity inOutOrderEntity = inOutOrderService.selectOne(queryWrapper);
        if(inOutOrderEntity==null){
            inOutOrder.setInsertTime(new Date());
            inOutOrder.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      inOutOrder.set
        //  }
            inOutOrderService.insert(inOutOrder);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody InOutOrderEntity inOutOrder, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,inOutOrder:{}",this.getClass().getName(),inOutOrder.toString());
        //根据字段查询是否有相同数据
        Wrapper<InOutOrderEntity> queryWrapper = new EntityWrapper<InOutOrderEntity>()
            .notIn("id",inOutOrder.getId())
            .eq("order_name", inOutOrder.getOrderName())
            .eq("caozuo_name", inOutOrder.getCaozuoName())
            .eq("caozuo_table", inOutOrder.getCaozuoTable())
            .eq("order_types", inOutOrder.getOrderTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        InOutOrderEntity inOutOrderEntity = inOutOrderService.selectOne(queryWrapper);
        if(inOutOrderEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      inOutOrder.set
            //  }
            inOutOrderService.updateById(inOutOrder);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
     * 出库
     */
    @RequestMapping("/outOrder")
    public R outGoods(@RequestBody  Map<String, Object> params,HttpServletRequest request){
        logger.debug("outGoods方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        Map<String, Integer> map = (Map<String, Integer>) params.get("map");
        String orderName = String.valueOf(params.get("orderName"));
        InOutOrderEntity one = inOutOrderService.selectOne(new EntityWrapper<InOutOrderEntity>().eq("order_name", orderName));
        if(one != null){
            return R.error(orderName+"的订单名已经被使用");
        }

        Set<String> ids = map.keySet();
        List<GoodsEntity> list = goodsService.selectList(new EntityWrapper<GoodsEntity>().in("id", ids));
        Date date = new Date();
        for(GoodsEntity g:list){
            Integer shiyongnumber = map.get(String.valueOf(g.getId()));
            if(g.getGoodsNumber()==null || shiyongnumber == null){
                return R.error(g.getGoodsName()+"的库存数量为空或者出库数量为空");
            }else if(g.getGoodsNumber()-shiyongnumber<0){
                return R.error(g.getGoodsName()+"的出库数量:"+shiyongnumber+"不能大于库存数量"+g.getGoodsNumber());
            }else{
                //正常出库
                g.setGoodsNumber(g.getGoodsNumber()-shiyongnumber);
            }
        }
        //修改库存
        goodsService.updateBatchById(list);

        //新增订单
        InOutOrderEntity inOutOrderEntity = new InOutOrderEntity();
        inOutOrderEntity.setCreateTime(date);
        inOutOrderEntity.setInsertTime(date);
        inOutOrderEntity.setCaozuoName(String.valueOf(request.getSession().getAttribute("username")));
        inOutOrderEntity.setCaozuoTable(String.valueOf(request.getSession().getAttribute("tableName")));
        inOutOrderEntity.setOrderTypes(1);//设置订单为出库
        inOutOrderEntity.setOrderName(orderName);
        inOutOrderService.insert(inOutOrderEntity);

        if(inOutOrderEntity.getId()!=null){
            //新增订单详情
            List<InOutOrderListEntity> inOutOrderListEntityList = new ArrayList<>();
            for(String i:ids){
                InOutOrderListEntity inOutOrderListEntity = new InOutOrderListEntity();
                inOutOrderListEntity.setCreateTime(date);
                inOutOrderListEntity.setGoodsId(Integer.valueOf(i));
                inOutOrderListEntity.setInOutOrderId(inOutOrderEntity.getId());
                inOutOrderListEntity.setOrderNumber(map.get(i));
                inOutOrderListEntityList.add(inOutOrderListEntity);
            }
            if(inOutOrderListEntityList != null && inOutOrderListEntityList.size()>0){
                inOutOrderListService.insertBatch(inOutOrderListEntityList);
                return R.ok();
            }
        }else{
            return R.error("新增订单失败");
        }
        return R.ok();
    }

    /**
     * 入库
     */
    @RequestMapping("/inOrder")
    public R inGoods(@RequestBody  Map<String, Object> params,HttpServletRequest request){
        logger.debug("inGoods方法:,,Controller:{},,map:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        Map<String, Integer> map = (Map<String, Integer>) params.get("map");
        String orderName = String.valueOf(params.get("orderName"));
        InOutOrderEntity one = inOutOrderService.selectOne(new EntityWrapper<InOutOrderEntity>().eq("order_name", orderName));
        if(one != null){
            return R.error(orderName+"的订单名已经被使用");
        }
        Set<String> ids = map.keySet();

        List<GoodsEntity> list = goodsService.selectList(new EntityWrapper<GoodsEntity>().in("id", ids));
        Date date = new Date();
        for(GoodsEntity g:list){
            Integer rukunumber = map.get(String.valueOf(g.getId()));
            Integer oldGoodsNumber = g.getGoodsNumber();
            if(rukunumber == null){
                return R.error(g.getGoodsName()+"的入库数量为空");
            }else if( oldGoodsNumber== null || oldGoodsNumber == 0){
                g.setGoodsNumber(rukunumber);
            }else{
                g.setGoodsNumber(oldGoodsNumber+rukunumber);
            }
        }
        //修改库存
        goodsService.updateBatchById(list);

        //新增订单
        InOutOrderEntity inOutOrderEntity = new InOutOrderEntity();
        inOutOrderEntity.setCreateTime(date);
        inOutOrderEntity.setInsertTime(date);
        inOutOrderEntity.setCaozuoName(String.valueOf(request.getSession().getAttribute("username")));
        inOutOrderEntity.setCaozuoTable(String.valueOf(request.getSession().getAttribute("tableName")));
        inOutOrderEntity.setOrderTypes(2);//设置订单为入库
        inOutOrderEntity.setOrderName(orderName);
        inOutOrderService.insert(inOutOrderEntity);

        if(inOutOrderEntity.getId()!=null){
            //新增订单详情
            List<InOutOrderListEntity> inOutOrderListEntityList = new ArrayList<>();
            for(String i:ids){
                InOutOrderListEntity inOutOrderListEntity = new InOutOrderListEntity();
                inOutOrderListEntity.setCreateTime(date);
                inOutOrderListEntity.setGoodsId(Integer.parseInt(i));
                inOutOrderListEntity.setInOutOrderId(inOutOrderEntity.getId());
                inOutOrderListEntity.setOrderNumber(map.get(i));
                inOutOrderListEntityList.add(inOutOrderListEntity);
            }
            if(inOutOrderListEntityList != null && inOutOrderListEntityList.size()>0){
                inOutOrderListService.insertBatch(inOutOrderListEntityList);
                return R.ok();
            }
        }else{
            return R.error("新增订单失败");
        }
        return R.ok();
    }
    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<InOutOrderEntity> list = inOutOrderService.selectList(new EntityWrapper<InOutOrderEntity>().in("id", ids));
        inOutOrderService.deleteBatchIds(Arrays.asList(ids));
        List<Integer> inOutOrderIds = new ArrayList<>();
        for(InOutOrderEntity order:list){
            inOutOrderIds.add(order.getId());
        }
        if(inOutOrderIds != null && inOutOrderIds.size()>0){
            inOutOrderListService.delete(new EntityWrapper<InOutOrderListEntity>().in("in_out_order_id", inOutOrderIds));
        }
        return R.ok();
    }


}

论文参考

在这里插入图片描述

目 录
第1章 绪论 1
1.1 课题背景 1
1.2 课题意义 1
1.3 研究内容 2
第2章 开发环境与技术 3
2.1 MYSQL数据库 3
2.2 JSP技术 3
2.3 SSM框架 4
第3章 系统分析 5
3.1 可行性分析 5
3.1.1 技术可行性 5
3.1.2 经济可行性 5
3.1.3 操作可行性 5
3.2 系统流程 6
3.2.1 操作流程 6
3.2.2 登录流程 6
3.2.3 删除信息流程 7
3.2.4 添加信息流程 8
3.3 性能需求 8
3.4 功能需求 9
第4章 系统设计 12
4.1 设计原则 12
4.2 功能结构设计 12
4.3 数据库设计 13
4.3.1 数据库概念设计 14
4.3.2 数据库物理设计 16
第5章 系统实现 19
5.1 管理员功能实现 19
5.1.1 硬件管理 19
5.1.2 硬件统计 19
5.1.3 出入库订单管理 20
5.1.4 用户管理 20
5.2 用户功能实现 21
5.2.1 查询系统公告 21
5.2.2 查询出入库订单 21
5.2.3 查询硬件 22
第6章 系统测试 23
6.1 功能测试 23
6.1.1 登录功能测试 23
6.1.2 修改密码功能测试 24
6.2 测试结果 24
结 论 25
致 谢 26
参考文献 27

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

q_2781179521

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值