博主主页:一季春秋
博主简介:专注Java技术领域和毕业设计项目实战、Java、微信小程序、安卓等技术开发,远程调试部署、代码讲解、文档指导、ppt制作等技术指导。
主要内容:毕业设计(Java项目、小程序等)、简历模板、学习资料、面试题库、技术咨询。文末获取联系
精彩专栏推荐订阅 不然下次找不到哟
SpringBoot+Vue项目持续更新中
http://t.csdn.cn/1mgm8
高校食堂物流管理系统,主要的模块包括管理员;首页、个人中心、管理员管理、用户管理、采购人员管理、财务管理、供应商信息管理、商品管理、出入库管理、基础数据管理,财务;首页、个人中心、财务管理、供应商信息管理、商品管理、出入库管理,仓库管理员;首页、个人中心、采购人员管理、财务管理、供应商信息管理、商品管理、出入库管理,采购;首页、个人中心、采购人员管理、供应商信息管理、商品管理、出入库管理等功能。
开发语言:Java
使用框架:spring boot
前端技术:JavaScript、Vue 、css3
开发工具:IDEA/MyEclipse/Eclipse、Visual Studio Code
数据库:MySQL 5.7/8.0
数据库管理工具:phpstudy/Navicat
JDK版本:jdk1.8
Maven: apache-maven 3.8.1-bin
这些功能可以充分满足高校食堂物流管理系统的需求。此系统功能较为全面如下图系统功能结构如图所示。
用户管理功能模块
基础数据管理
出入库管理
商品管理
出入库详情关键代码
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("/shangpinChuruInoutList")
public class ShangpinChuruInoutListController {
private static final Logger logger = LoggerFactory.getLogger(ShangpinChuruInoutListController.class);
private static final String TABLE_NAME = "shangpinChuruInoutList";
@Autowired
private ShangpinChuruInoutListService shangpinChuruInoutListService;
@Autowired
private TokenService tokenService;
@Autowired
private CaigouService caigouService;//采购人员
@Autowired
private CaigouLiuyanService caigouLiuyanService;//采购留言
@Autowired
private CaiwuService caiwuService;//财务
@Autowired
private CaiwuLiuyanService caiwuLiuyanService;//财务留言
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private GongyingshangService gongyingshangService;//供应商信息
@Autowired
private ShangpinService shangpinService;//商品
@Autowired
private ShangpinChuruInoutService shangpinChuruInoutService;//出入库
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("采购人员".equals(role))
params.put("caigouId",request.getSession().getAttribute("userId"));
else if("财务".equals(role))
params.put("caiwuId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = shangpinChuruInoutListService.queryPage(params);
//字典表数据转换
List list =(List)page.getList();
for(ShangpinChuruInoutListView 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);
ShangpinChuruInoutListEntity shangpinChuruInoutList = shangpinChuruInoutListService.selectById(id);
if(shangpinChuruInoutList !=null){
//entity转view
ShangpinChuruInoutListView view = new ShangpinChuruInoutListView();
BeanUtils.copyProperties( shangpinChuruInoutList , view );//把实体数据重构到view中
//级联表 出入库
//级联表
ShangpinChuruInoutEntity shangpinChuruInout = shangpinChuruInoutService.selectById(shangpinChuruInoutList.getShangpinChuruInoutId());
if(shangpinChuruInout != null){
BeanUtils.copyProperties( shangpinChuruInout , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setShangpinChuruInoutId(shangpinChuruInout.getId());
}
//级联表 商品
//级联表
ShangpinEntity shangpin = shangpinService.selectById(shangpinChuruInoutList.getShangpinId());
if(shangpin != null){
BeanUtils.copyProperties( shangpin , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setShangpinId(shangpin.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShangpinChuruInoutListEntity shangpinChuruInoutList, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,shangpinChuruInoutList:{}",this.getClass().getName(),shangpinChuruInoutList.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper queryWrapper = new EntityWrapper()
.eq("shangpin_churu_inout_id", shangpinChuruInoutList.getShangpinChuruInoutId())
.eq("shangpin_id", shangpinChuruInoutList.getShangpinId())
.eq("shangpin_churu_inout_list_number", shangpinChuruInoutList.getShangpinChuruInoutListNumber())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ShangpinChuruInoutListEntity shangpinChuruInoutListEntity = shangpinChuruInoutListService.selectOne(queryWrapper);
if(shangpinChuruInoutListEntity==null){
shangpinChuruInoutList.setInsertTime(new Date());
shangpinChuruInoutList.setCreateTime(new Date());
shangpinChuruInoutListService.insert(shangpinChuruInoutList);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShangpinChuruInoutListEntity shangpinChuruInoutList, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,shangpinChuruInoutList:{}",this.getClass().getName(),shangpinChuruInoutList.toString());
ShangpinChuruInoutListEntity oldShangpinChuruInoutListEntity = shangpinChuruInoutListService.selectById(shangpinChuruInoutList.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
shangpinChuruInoutListService.updateById(shangpinChuruInoutList);//根据id更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List oldShangpinChuruInoutListList =shangpinChuruInoutListService.selectBatchIds(Arrays.asList(ids));//要删除的数据
shangpinChuruInoutListService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
List shangpinChuruInoutListList = new ArrayList<>();//上传的东西
Map> 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> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List data:dataList){
//循环
ShangpinChuruInoutListEntity shangpinChuruInoutListEntity = new ShangpinChuruInoutListEntity();
// shangpinChuruInoutListEntity.setShangpinChuruInoutId(Integer.valueOf(data.get(0))); //出入库 要改的
// shangpinChuruInoutListEntity.setShangpinId(Integer.valueOf(data.get(0))); //商品 要改的
// shangpinChuruInoutListEntity.setShangpinChuruInoutListNumber(Integer.valueOf(data.get(0))); //操作数量 要改的
// shangpinChuruInoutListEntity.setInsertTime(date);//时间
// shangpinChuruInoutListEntity.setCreateTime(date);//时间
shangpinChuruInoutListList.add(shangpinChuruInoutListEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
shangpinChuruInoutListService.insertBatch(shangpinChuruInoutListList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}