ssm框架仓库系统源码和论文

本文介绍了如何利用Java和MySQL开发一个仓库管理系统,包括管理员和用户功能,以及B/S模式的高效应用。详细描述了数据处理、权限控制和前后端交互的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ssm框架仓库系统源码和论文210


 开发工具:idea 或eclipse
 数据库mysql5.7+
 数据库链接工具:navcat,小海豚等
  技术:ssm

摘  要

使用旧方法对仓库信息进行系统化管理已经不再让人们信赖了,把现在的网络信息技术运用在仓库信息的管理上面可以解决许多信息管理上面的难题,比如处理数据时间很长,数据存在错误不能及时纠正等问题。

这次开发的仓库管理系统有管理员和用户两个角色。管理员功能有个人中心,用户管理,物资管理,系统公告管理,基础数据管理。用户功能只可以注册登录,修改个人密码,查看物资信息和系统公告信息。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择B/S模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行仓库管理系统程序的开发,在数据库的选择上面,选择功能强大的MySQL数据库进行数据的存放操作。

仓库管理系统被人们投放于现在的生活中进行使用,该款管理类软件就可以让管理人员处理信息的时间介于十几秒之间。在这十几秒内就能完成信息的编辑等操作。有了这样的管理软件,仓库信息的管理就离无纸化办公的目标更贴近了。

关键词:仓库管理系统;Java;MySQL


Abstract

The systematic management of warehouse information using the old methods is no longer trusted by people. Applying the current network information technology to the management of warehouse information can solve many problems in information management, such as long data processing time, data errors that can not be corrected in time and so on.

The warehouse management system developed this time has two roles: administrator and user. Administrator functions include personal center, user management, material management, system announcement management and basic data management. The user function can only register, log in, modify personal password, view material information and system announcement information. After the network knowledge consulted by myself and the knowledge learned in the school classroom, I decided to develop the system and choose the B / S mode, which is an efficient mode to complete the system function development. This mode allows the operator to access the website based on the browser, use the mainstream Java language, an object-oriented language, to develop the program of the warehouse management system, and select the powerful MySQL database for data storage operation in the selection of the database.

The warehouse management system is put into use in people's current life. This management software allows managers to process information in more than ten seconds. Information editing and other operations can be completed within more than ten seconds. With such management software, the management of warehouse information is closer to the goal of paperless office.

Key WordsWarehouse management system; Java; MySQL

 

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"));
        }
        params.put("orderBy","id");
        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("/save")
    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();
    }


}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值