ssm农产品仓库管理系统系统源码和论文

本文介绍了基于SSM框架的农产品仓库管理系统,涵盖了系统选题背景、意义、国内外研究现状,以及具体的技术实现,如使用Java和MySQL,实现用户管理、订单操作和数据处理的后端接口。

ssm农产品仓库管理系统系统源码和论文064

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

  1. 选题的背景

中国是一个农产品生产的大国,可利用的农产品资源相对贫乏,传统的单纯依靠大量物质资源消耗和增加投入的发展模式已行不通了,而农产品信息技术在农产品上的普遍应用对农产品的发展将起到越来越重要的作用。我国蕴藏着丰富的科技信息资源,尤其是农产品信息资源,但是由于信息加工层次和水平比较低信息的附加值还没有得到充分的挖掘和利用,造成了农产品科技信息资源的严重浪费。因此如何有效地利用农产品信息资源是摆在我们面前的重要课题。

  1. 选题的意义

农产品仓库管理系统是通过入库业务,出库业务,入库搜索,出库搜索,物品管理等功能综合运用的管理系统。对库存业务的物流和成本管理全过程进行有效控制和跟踪,实现完善的仓库信息管理合理地利用农产品资源,使农产品的存储加工更加合理化、人性化,所以我们开发了该系统。开发此系统的目的对农产品信息进行规范化,连接数据库并在数据库中操纵数据,对数据进行添加、删除、修改等。随着信息技术的迅猛发展,越来越多的农产品管理企业开始摒弃传统的管理模式,采用高效的、可靠的计算机来进行企业内的各种业务管理以使企业内部管理更加清晰、 明了、高效、可靠。

  1. 研究现状

在研究过程中,目前国内及国外对于仓库的管理系统软件不在少数,但是具备智能化的就寥寥无几,有些仓库管理软件功能强大,但不实用;有些实用,但是软件界面不够友好;有些界面华丽,但是性能不够稳定。所以,我觉得我需要制作出一款,实用,界面友好,性能稳定,简单易于操作的农产品仓库管理系统。操作本系统的客户并不是专业的计算机从业人员,他们对于软件的初步认识就是,外观,所以,在jsp 技术上可以选择比较动态,美观大方的extjs 系统架构,该架构对于用户的提示友好,性能强大,动态性好,充分满足前台页面的实际需求。而一款软件有一件漂亮的外衣还是不够的,他还需要强大的内心,这个内心就是Java和数据库,他的骨架就是java,他的血液就是mysql。这样组成的软件才能成为一款优秀的农产品仓库管理系统。

  1. 研究内容

(1)了解当下市场中农产品存储的现状

分别通过网上问卷查找资料的形式或者实地考察访问的方式去了解现在的情况。

(2)网站设计模块的构想

针对所调查的情况,进行页面设计过程各个模块所需技术支持的研究。批量入库、批量出库、入库搜索、出库搜索、物品管理、用户注册、用户登录、用户留言、用户入库、用户出库等等。

(3)网站的实现

运用Java和MySQL等技术搭建完成本次的农产品仓库管理系统。农产品仓库管理系统是一个专门用来管理包括粮食、水果、蔬菜、 肉类、蛋类五种农产品的系统。该软件为“农产品仓库管理系统”此软件的开发是针对某些企业及公司仓库货物管理的繁琐操作。此系统按照不同的角色,系统可以分为两大部分用户和管理员。用户,该操作要求用户名和对应的密码才能进入系统执行相应的操作。管理员,该操作要求管理员名和对应的密码才能进入系统执行相应权限的操作。

package com.controller;


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

import com.entity.*;
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.view.EntrustInOutOrderView;
import com.utils.PageUtils;
import com.utils.R;

/**
 * 委托出入库订单
 * 后端接口
 * @author
 * @email
 * @date 2021-03-10
*/
@RestController
@Controller
@RequestMapping("/entrustInOutOrder")
public class EntrustInOutOrderController {
    private static final Logger logger = LoggerFactory.getLogger(EntrustInOutOrderController.class);

    @Autowired
    private EntrustInOutOrderService entrustInOutOrderService;


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


    //级联表service
    @Autowired
    private YonghuService yonghuService;
    @Autowired
    private EntrustInOutOrderListService entrustInOutOrderListService;
    @Autowired
    private GoodsService goodsService;


    /**
    * 后端列表
    */
    @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 = entrustInOutOrderService.queryPage(params);

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

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

    }

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

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


    /**
     * 新增 委托出库入库
     */
    @RequestMapping("/inOutOrder")
    public R inOutOrder(@RequestBody  Map<String, Object> params,HttpServletRequest request){
        logger.debug("inOutOrder方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if("用户".equals(role)){
            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));
            EntrustInOutOrderEntity one = entrustInOutOrderService.selectOne(new EntityWrapper<EntrustInOutOrderEntity>().eq("order_name", orderName));
            if(one != null){
                return R.error(orderName+"的委托订单名已经被使用");
            }

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

            //新增订单
            EntrustInOutOrderEntity entrustInOutOrderEntity = new EntrustInOutOrderEntity();
            entrustInOutOrderEntity.setYonghuId(Integer.parseInt(String.valueOf(request.getSession().getAttribute("userId"))));
            entrustInOutOrderEntity.setOrderName(orderName);
            entrustInOutOrderEntity.setOrderTypes(Integer.parseInt(String.valueOf(params.get("orderType"))));
            entrustInOutOrderEntity.setCaozuoTypes(2);//操作类型为未操作
            entrustInOutOrderEntity.setInsertTime(new Date());
            entrustInOutOrderEntity.setCreateTime(date);
            entrustInOutOrderService.insert(entrustInOutOrderEntity);


            if(entrustInOutOrderEntity.getId()!=null){
                //新增订单详情
                List<EntrustInOutOrderListEntity> inOutOrderListEntityList = new ArrayList<>();
                for(String i:ids){
                    EntrustInOutOrderListEntity entrustInOutOrderListEntity = new EntrustInOutOrderListEntity();
                    entrustInOutOrderListEntity.setEntrustInOutOrderId(entrustInOutOrderEntity.getId());
                    entrustInOutOrderListEntity.setGoodsId(Integer.valueOf(i));
                    entrustInOutOrderListEntity.setOrderNumber(Integer.valueOf(map.get(i)));
                    entrustInOutOrderListEntity.setEntrustTypes(1);//默认状态为不同意
                    entrustInOutOrderListEntity.setCreateTime(date);
                    inOutOrderListEntityList.add(entrustInOutOrderListEntity);
                }
                if(inOutOrderListEntityList != null && inOutOrderListEntityList.size()>0){
                    entrustInOutOrderListService.insertBatch(inOutOrderListEntityList);
                    return R.ok();
                }
            }else{
                return R.error("新增订单失败");
            }
            return R.ok();
        }else{
          return R.error("您没有委托权限");
        }
    }




    /**
     * 对委托的出入库订单进行审核
     */
    @RequestMapping("/examineInOutOrder")
    public R examineInOutOrder(@RequestBody  Map<String, Object> params,HttpServletRequest request){
        logger.debug("examineInOutOrder方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if("管理员".equals(role)){
            Date date = new Date();
            List<Integer> ids = (List<Integer>) params.get("list");//list为订单详情的id列表
            String id = String.valueOf(params.get("id"));//订单id的
            if(ids == null || ids.size() == 0){
                //如果全部都是不同意,会进入这里,直接修改订单状态为已操作就好了
                EntrustInOutOrderEntity order = new EntrustInOutOrderEntity();
                order.setId(Integer.valueOf(id));
                order.setCaozuoTypes(1);//设置操作状态为已操作
                order.setCaozuoName(String.valueOf(request.getSession().getAttribute("username")));//设置操作人名字
                order.setCaozuoTable(String.valueOf(request.getSession().getAttribute("tableName")));//设置操作人表名
                order.setUpdateTime(date);
                entrustInOutOrderService.updateById(order);
                return R.ok();
            }
            //订单详情
            List<EntrustInOutOrderListEntity> orderList = entrustInOutOrderListService.selectBatchIds(ids);//当天订单列表详情
            EntrustInOutOrderEntity entrustInOutOrderEntity = entrustInOutOrderService.selectById(id);//当前订单信息
            Map<Integer, Integer> map = new HashMap<>();
            for(EntrustInOutOrderListEntity o:orderList){
                o.setEntrustTypes(2);//设置订单为同意
                map.put(o.getGoodsId(), o.getOrderNumber());
            }
            if(entrustInOutOrderEntity != null){

                Set<Integer> goodIds = map.keySet();
                List<GoodsEntity> list = goodsService.selectBatchIds(goodIds);
                Integer orderTypes = entrustInOutOrderEntity.getOrderTypes();
                if(orderTypes == null){
                    return R.error(entrustInOutOrderEntity.getOrderName()+"的订单的委托类型有问题");
                }else if(orderTypes ==1 || orderTypes ==2){
                    for(GoodsEntity g:list){
                        if(orderTypes ==1 ){
                            //出库
                            int i = g.getGoodsNumber() - map.get(g.getId());
                            if(i<0){
                                Integer flag = g.getFlag();
                                String a="";
                                if(flag == 1){
                                    a="在使用状态";
                                }else{
                                    a="已经删除";
                                }
                                return R.error(g.getGoodsName()+"的商品出库后数量为负,请重新处理,商品是"+a);
                            }else{
                                g.setGoodsNumber(i);
                            }
                        }else if(orderTypes ==2){
                            //入库
                            g.setGoodsNumber(g.getGoodsNumber()+map.get(g.getId()));
                        }
                    }
                }else{
                    return R.error(entrustInOutOrderEntity.getOrderName()+"的订单的委托类型是"+orderTypes+"有问题");
                }

                //更新订单详情表
                entrustInOutOrderListService.updateBatchById(orderList);
                //更新订单表
                entrustInOutOrderEntity.setCaozuoTypes(1);//设置操作状态为已操作
                entrustInOutOrderEntity.setCaozuoName(String.valueOf(request.getSession().getAttribute("username")));//设置操作人名字
                entrustInOutOrderEntity.setCaozuoTable(String.valueOf(request.getSession().getAttribute("tableName")));//设置操作人表名
                entrustInOutOrderEntity.setUpdateTime(date);
                entrustInOutOrderService.updateById(entrustInOutOrderEntity);
                //修改物资的数量
                goodsService.updateBatchById(list);

            }else{
                return R.error("订单不存在");
            }
            return R.ok();
        }else{
            return R.error("您没有处理委托的权限");
        }
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());

        List<EntrustInOutOrderEntity> list = entrustInOutOrderService.selectList(new EntityWrapper<EntrustInOutOrderEntity>().in("id", ids));
        entrustInOutOrderService.deleteBatchIds(Arrays.asList(ids));
        List<Integer> entrustInOutOrderIds = new ArrayList<>();
        for(EntrustInOutOrderEntity order:list){
            entrustInOutOrderIds.add(order.getId());
        }
        if(entrustInOutOrderIds != null && entrustInOutOrderIds.size()>0){
            entrustInOutOrderListService.delete(new EntityWrapper<EntrustInOutOrderListEntity>().in("entrust_in_out_order_id", entrustInOutOrderIds));
        }
        return R.ok();
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值