博主介绍:专注于Java(springboot ssm 等开发框架) vue .net php phython node.js uniapp 微信小程序 等诸多技术领域和毕业项目实战、企业信息化系统建设,从业十五余年开发设计教学工作
☆☆☆ 精彩专栏推荐订阅☆☆☆☆☆不然下次找不到哟
我的博客空间发布了2000+毕设题目 方便大家学习使用
感兴趣的可以先收藏起来,还有大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助更多的人
文末下方有源码获取地址
4.3功能结构设计
在确认管理员功能模块基础上,设计方案管理员的每一个功能,明确管理员功能的具体控制模块。管理员功能构造见下图。
图4.3 管理员功能结构图
4.4数据库设计
4.4.1 数据库E-R图
4.4.2 数据库表结构
在规划这一部分以前,首先要了解和掌握数据类型和每一个数据类型长度范畴,毕竟在一个特定数据表中,为了更好地了解,这里有一个典型的例子。比如,用户信息内容表中字段名是用户实体的属性。这时,必须设定字段名的数据类型和字段长度,并配有外键约束做为用户情况表的唯一鉴别。这都是数据库表结构设计方案要完成内容。依据仓储管理系统的功能分析和概念模型设计规定,显示设备的数据表构造。
表4.1字典表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
dic_code |
String |
字段 |
是 |
3 |
dic_name |
String |
字段名 |
是 |
4 |
code_index |
Integer |
编码 |
是 |
5 |
index_name |
String |
编码名字 |
是 |
6 |
super_id |
Integer |
父字段id |
是 |
7 |
beizhu |
String |
备注 |
是 |
8 |
create_time |
Date |
创建时间 |
是 |
表4.2公告表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
gonggao_name |
String |
公告名称 |
是 |
3 |
gonggao_types |
Integer |
公告类型 |
是 |
4 |
insert_time |
Date |
公告发布时间 |
是 |
5 |
gonggao_content |
String |
公告详情 |
是 |
6 |
create_time |
Date |
创建时间 |
是 |
表4.3仓库管理员表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
laoshi_name |
String |
仓库管理员姓名 |
是 |
3 |
laoshi_phone |
String |
仓库管理员手机号 |
是 |
4 |
laoshi_id_number |
String |
仓库管理员身份证号 |
是 |
5 |
laoshi_photo |
String |
仓库管理员头像 |
是 |
6 |
laoshi_email |
String |
仓库管理员邮箱 |
是 |
7 |
laoshi_address |
String |
仓库管理员住址 |
是 |
8 |
create_time |
Date |
创建时间 |
是 |
表4.4物资表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
wuzi_uuid_number |
String |
物资编号 |
是 |
3 |
wuzi_name |
String |
物资名称 |
是 |
4 |
wuzi_photo |
String |
物资照片 |
是 |
5 |
wuzi_danwei |
String |
单位 |
是 |
6 |
wuzi_types |
Integer |
物资类型 |
是 |
7 |
wuzi_kucun_number |
Integer |
物资数量 |
是 |
8 |
wuzi_yuzhi |
Integer |
警戒值 |
是 |
9 |
cangku_types |
Integer |
仓库 |
是 |
10 |
wuzi_content |
String |
物资介绍 |
是 |
11 |
insert_time |
Date |
录入时间 |
是 |
12 |
create_time |
Date |
创建时间 |
是 |
表4.5物资申请表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
xuesheng_id |
Integer |
用户 |
是 |
3 |
wuzi_id |
Integer |
物资 |
是 |
4 |
wuzi_shenqing_uuid_number |
String |
物资申请编号 |
是 |
5 |
wuzi_shenqing_types |
Integer |
物资申请类型 |
是 |
6 |
wuzi_shenqing_content |
String |
申请缘由 |
是 |
7 |
insert_time |
Date |
申请时间 |
是 |
8 |
sheqing_number |
Integer |
申请数量 |
是 |
9 |
yujiguihuan_time |
Date |
预计归还时间 |
是 |
10 |
wuzi_shenqing_zhuangtai_types |
Integer |
申请状态 |
是 |
11 |
wuzi_shenqing_yesno_types |
Integer |
审核状态 |
是 |
12 |
wuzi_shenqing_yesno_text |
String |
审核意见 |
是 |
13 |
wuzi_shenqing_shenhe_time |
Date |
审核时间 |
是 |
14 |
create_time |
Date |
创建时间 |
是 |
表4.6用户表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
xuesheng_uuid_number |
String |
学号 |
是 |
3 |
xuesheng_name |
String |
用户姓名 |
是 |
4 |
xuesheng_phone |
String |
用户手机号 |
是 |
5 |
xuesheng_id_number |
String |
用户身份证号 |
是 |
6 |
xuesheng_photo |
String |
用户头像 |
是 |
7 |
xuesheng_email |
String |
用户邮箱 |
是 |
8 |
xuesheng_address |
String |
用户住址 |
是 |
9 |
create_time |
Date |
创建时间 |
是 |
表4.7管理员表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
username |
String |
用户名 |
是 |
3 |
password |
String |
密码 |
是 |
4 |
role |
String |
角色 |
是 |
5 |
addtime |
Date |
新增时间 |
是 |
系统完成此章内容通常是表明系统的功效页面设计实际效果。在推进系统基本要素的前提下,如改动、加上、删掉等管理的功能,也显示出了系统各作用页面的实现效果。一方面,这个知识点与上述系统分析与系统设计要素相照应,另一方面也是具体结论的展示。
5.1管理员功能实现
5.1.1 物资管理
此页面让管理员管理物资的数据,物资管理页面见下图。此页面主要实现物资的增加、修改、删除、查看的功能。
图5-1 物资管理页面
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("/wuzi")
public class WuziController {
private static final Logger logger = LoggerFactory.getLogger(WuziController.class);
private static final String TABLE_NAME = "wuzi";
@Autowired
private WuziService wuziService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private GonggaoService gonggaoService;//公告
@Autowired
private LaoshiService laoshiService;//仓库管理员
@Autowired
private WuziShenqingService wuziShenqingService;//物资申请
@Autowired
private XueshengService xueshengService;//用户
@Autowired
private UsersService usersService;//管理员
/**
* 后端列表
*/
@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(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("xueshengId",request.getSession().getAttribute("userId"));
else if("仓库管理员".equals(role))
params.put("laoshiId",request.getSession().getAttribute("userId"));
CommonUtil.checkMap(params);
PageUtils page = wuziService.queryPage(params);
//字典表数据转换
List<WuziView> list =(List<WuziView>)page.getList();
for(WuziView 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);
WuziEntity wuzi = wuziService.selectById(id);
if(wuzi !=null){
//entity转view
WuziView view = new WuziView();
BeanUtils.copyProperties( wuzi , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WuziEntity wuzi, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,wuzi:{}",this.getClass().getName(),wuzi.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<WuziEntity> queryWrapper = new EntityWrapper<WuziEntity>()
.eq("wuzi_name", wuzi.getWuziName())
.eq("wuzi_danwei", wuzi.getWuziDanwei())
.eq("wuzi_types", wuzi.getWuziTypes())
.eq("wuzi_kucun_number", wuzi.getWuziKucunNumber())
.eq("wuzi_yuzhi", wuzi.getWuziYuzhi())
.eq("cangku_types", wuzi.getCangkuTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
WuziEntity wuziEntity = wuziService.selectOne(queryWrapper);
if(wuziEntity==null){
wuzi.setInsertTime(new Date());
wuzi.setCreateTime(new Date());
wuziService.insert(wuzi);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody WuziEntity wuzi, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,wuzi:{}",this.getClass().getName(),wuzi.toString());
WuziEntity oldWuziEntity = wuziService.selectById(wuzi.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
if("".equals(wuzi.getWuziPhoto()) || "null".equals(wuzi.getWuziPhoto())){
wuzi.setWuziPhoto(null);
}
wuziService.updateById(wuzi);//根据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<WuziEntity> oldWuziList =wuziService.selectBatchIds(Arrays.asList(ids));//要删除的数据
wuziService.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 xueshengId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
List<WuziEntity> wuziList = 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){
//循环
WuziEntity wuziEntity = new WuziEntity();
// wuziEntity.setWuziUuidNumber(data.get(0)); //物资编号 要改的
// wuziEntity.setWuziName(data.get(0)); //物资名称 要改的
// wuziEntity.setWuziPhoto("");//详情和图片
// wuziEntity.setWuziDanwei(data.get(0)); //单位 要改的
// wuziEntity.setWuziTypes(Integer.valueOf(data.get(0))); //物资类型 要改的
// wuziEntity.setWuziKucunNumber(Integer.valueOf(data.get(0))); //物资数量 要改的
// wuziEntity.setWuziYuzhi(Integer.valueOf(data.get(0))); //警戒值 要改的
// wuziEntity.setCangkuTypes(Integer.valueOf(data.get(0))); //仓库 要改的
// wuziEntity.setWuziContent("");//详情和图片
// wuziEntity.setInsertTime(date);//时间
// wuziEntity.setCreateTime(date);//时间
wuziList.add(wuziEntity);
//把要查询是否重复的字段放入map中
//物资编号
if(seachFields.containsKey("wuziUuidNumber")){
List<String> wuziUuidNumber = seachFields.get("wuziUuidNumber");
wuziUuidNumber.add(data.get(0));//要改的
}else{
List<String> wuziUuidNumber = new ArrayList<>();
wuziUuidNumber.add(data.get(0));//要改的
seachFields.put("wuziUuidNumber",wuziUuidNumber);
}
}
//查询是否重复
//物资编号
List<WuziEntity> wuziEntities_wuziUuidNumber = wuziService.selectList(new EntityWrapper<WuziEntity>().in("wuzi_uuid_number", seachFields.get("wuziUuidNumber")));
if(wuziEntities_wuziUuidNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(WuziEntity s:wuziEntities_wuziUuidNumber){
repeatFields.add(s.getWuziUuidNumber());
}
return R.error(511,"数据库的该表中的 [物资编号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
wuziService.insertBatch(wuziList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}
5.1.2 公告信息管理
公告信息管理页面提供的功能操作有:新增公告,修改公告,删除公告操作。下图就是公告信息管理页面。
图5.3 公告信息管理页面
5.1.3公告类型管理
公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。下图就是公告类型管理页面。
图5.4 公告类型列表页面
大家点赞、收藏、关注、评论啦 其他的定制服务 商务合作 下方联系卡片↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 或者私信作者