基于javaweb+mysql的springboot物资发放管理系统(java+springboot+html+layui+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot物资发放管理系统(java+springboot+html+layui+mysql)
项目介绍
本项目有物资管理员与普通员工两种角色;
普通员工具有以下功能:申领物资;撤销申请;查看待领任务。 (1)申领物资:提交物资领取申请。 (2)撤销申请:对于物资管理员还未审核的申请,可以撤销;已审核的申请则不能撤销。 (3)查看待领任务:查看已通过审核的申请和物资管理员发起的领取任务。
物资管理员拥有以下功能:物资信息管理;物资入库;物资发放;查看物资库存;审批申请。 (1)物资信息管理:添加物资类别;添加、修改、删除物资信息;按名称或类别或编号查询物资信息。 (2)物资入库:增加物资的库存量;可以按入库时间来查看入库信息。 (3)物资发放:向指定人发放一定数量的物资,并在其领取后进行登记。 (4)查看物资库存:查看所有物资的库存量。 (5)审批申请:查看和审批物资领取申请,同意则员工可以领取物资,不同意则驳回该申请,不允许领取物资。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 8.0/5.7版本; 6.是否Maven项目:是;
技术栈
springboot+mysql+layui+CSS+JavaScript
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080 访问
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
List<Requisition> list = requisitionService.findAll(rv);
// 创建分页对象
PageInfo<Requisition> pageInfo = new PageInfo<>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 领用登记
* @param rt
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/distribute/received.action")
public String received(Requisition rt,HttpServletRequest request){
// 发放人
String uname = (String)request.getSession().getAttribute("uname");
rt.setRagent(uname);
// 领用日期
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
rt.setRtaketime(sdf.format(date));
HashMap<String, Object> map = new HashMap<>();
boolean result = requisitionService.received(rt);
if (result) {
map.put("success", true);
map.put("msg", "登记成功!");
} else {
map.put("success", false);
map.put("msg", "登记失败,库存不足或系统错误,请稍后重试!");
}
return JSON.toJSONString(map);
}
map.put("success", false);
map.put("msg", "登记失败,库存不足或系统错误,请稍后重试!");
}
return JSON.toJSONString(map);
}
/**
* 获取普通员工
* @return
*/
@RequestMapping(value = "/distribute/getUname.action")
@ResponseBody
public String getUname(){
Map<String, Object> map = new HashMap<>();
Integer utype = 0;
List<User> list = indexService.getUname(utype);
if (list != null) {
map.put("success", true);
map.put("data", list);
} else {
map.put("success", false);
}
return JSON.toJSONString(map);
}
/**
* 发布领取任务
* @param rt
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/distribute/give")
public String give(Requisition rt,HttpServletRequest request){
// 审核人
String uname = (String)request.getSession().getAttribute("uname");
rt.setRverifier(uname);
// 任务发布日期(即申请日期)
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
rt.setRapplytime(sdf.format(date));
// 申请类型
rt.setRtype("直接发放");
// 时间戳,作为主键
String rid = String.valueOf(date.getTime());
rt.setRid(rid);
HashMap<String, Object> map = new HashMap<>();
boolean result = requisitionService.give(rt);
if (result) {
map.put("success", true);
map.put("msg", "发布任务成功!");
} else {
map.put("success", false);
map.put("msg", "发布任务失败,请稍后重试!");
}
return JSON.toJSONString(map);
}
}
@Controller
@RequestMapping("/staff")
public class StaffController {
@Resource
private RequisitionService requisitionService;
@RequestMapping(value = "/apply.html")
public String apply() {
return "/staff/apply.html";
}
/**
* 查看申领信息,只能查看自己的
* @param rv
* @param request
* @return
/**
* 添加物资类别
*
* @param kd
* @return
*/
@ResponseBody
@RequestMapping(value = "/kind/add")
public String addKind(Kind kd) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(kd);
boolean result = kindService.addKind(kd);
if (result) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
@RequestMapping(value = "/putin.html")
public String putinRecords(){
return "/mh/putin.html";
}
/**
* 获取全部的物资名称
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/putin/getMname.action")
public String getMnameOptions() {
Map<String, Object> map = new HashMap<>();
List<Material> list = materialService.findAllMname();
if (list != null) {
map.put("success", true);
map.put("data", list);
} else {
map.put("success", false);
}
return JSON.toJSONString(map);
}
/**
* 物资入库
return "/mh/putin.html";
}
/**
* 获取全部的物资名称
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/putin/getMname.action")
public String getMnameOptions() {
Map<String, Object> map = new HashMap<>();
List<Material> list = materialService.findAllMname();
if (list != null) {
map.put("success", true);
map.put("data", list);
} else {
map.put("success", false);
}
return JSON.toJSONString(map);
}
/**
* 物资入库
* @param pi
* @return
*/
@ResponseBody
@RequestMapping(value = "/putin/add")
public String addPutinInfo(Putin pi,HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
// 获取经办人信息
String uname = (String)request.getSession().getAttribute("uname");
pi.setPagent(uname);
// 获取当前日期
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
pi.setPdate(sdf.format(date));
// 生成时间戳,保证主键的唯一性
String pno = String.valueOf(date.getTime());
pi.setPno(pno);
System.out.println(pi);
boolean result = putinService.addPutin(pi);
if (result) {
@Controller
@RequestMapping("/staff")
public class StaffController {
@Resource
private RequisitionService requisitionService;
@RequestMapping(value = "/apply.html")
public String apply() {
return "/staff/apply.html";
}
/**
* 查看申领信息,只能查看自己的
* @param rv
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/apply/list")
public DataGridViewResult applyList(RequisitionVo rv,HttpServletRequest request) {
String uname = (String)request.getSession().getAttribute("uname");
rv.setRtaker(uname);
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
List<Requisition> list = requisitionService.findRequisitionList(rv);
// 创建分页对象
PageInfo<Requisition> pageInfo = new PageInfo<>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 提交申请
*
* @param rt
list.add(mid);
}
boolean result = materialService.deleteMaterialInfo(list);
if (result) {
map.put("success", true);
map.put("msg", "删除成功!");
} else {
map.put("success", false);
map.put("msg", "删除失败!");
}
}
} catch (Exception e) {
e.printStackTrace();
map.put("success", false);
map.put("msg", "删除失败!");
}
return JSON.toJSONString(map);
}
/**
* 添加物资类别
*
* @param kd
* @return
*/
@ResponseBody
@RequestMapping(value = "/kind/add")
public String addKind(Kind kd) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(kd);
boolean result = kindService.addKind(kd);
if (result) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
@RequestMapping(value = "/putin.html")
public String putinRecords(){
return "/mh/putin.html";
}
/**
}
@Controller
@RequestMapping("/staff")
public class StaffController {
@Resource
private RequisitionService requisitionService;
@RequestMapping(value = "/apply.html")
public String apply() {
return "/staff/apply.html";
}
/**
* 查看申领信息,只能查看自己的
* @param rv
* @param request
* @return
*/
@ResponseBody
public String toLogin() {
return "/login";
}
@RequestMapping(value = "/home.html")
public String home() {
return "/home";
}
@RequestMapping(value = "/welcome.html")
public String welcome() {
return "/welcome";
}
/**
* 登录
*
* @param request
* @param session
* @return
*/
@ResponseBody
@RequestMapping(value = "/login.action")
public String login(@RequestBody Map<String, String> request, HttpSession session) {
Map<String, Object> map = new HashMap<>();
String uid = request.get("uid");
String password = request.get("password");
System.out.println("uid:" + uid + "--pwd:" + password);
User user = indexService.findUser(uid, password);
if (user != null) {
session.setAttribute("uid", uid);
session.setAttribute("uname", user.getUname());
session.setAttribute("utype", user.getUtype());
map.put("msg","登录成功");
map.put("success", true);
} else {
map.put("success", false);
map.put("msg", "账号或密码错误!");
}
return JSON.toJSONString(map);
}
/**
* 加载菜单列表
*
* @param session
* @return
String rid = String.valueOf(date.getTime());
rt.setRid(rid);
rt.setRstatus("申请中");
rt.setRtype("申请发放");
System.out.println(rt);
boolean result = requisitionService.add(rt);
if (result) {
map.put("success", true);
map.put("msg", "提交申请成功!");
} else {
map.put("success", false);
map.put("msg", "提交申请失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 撤销申请
* @param rid
* @return
*/
@ResponseBody
@RequestMapping(value = "/apply/revoke")
public String revoke(@RequestParam("rid") String rid) {
HashMap<String, Object> map = new HashMap<>();
boolean result = requisitionService.revoke(rid);
if (result) {
map.put("success", true);
map.put("msg", "撤销成功!");
} else {
map.put("success", false);
map.put("msg", "撤销失败,请稍后重试!");
}
return JSON.toJSONString(map);
}
@RequestMapping(value = "/todo.html")
public String todo(){
return "/staff/todo.html";
}
/**
* 待领取列表
* @param rv
* @return
*/
@ResponseBody
@RequestMapping(value = "/todo/list")
public DataGridViewResult todoList(RequisitionVo rv,HttpServletRequest request){
String uname = (String)request.getSession().getAttribute("uname");
map.put("msg", "添加失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 查看物资信息列表
*
* @param mv
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/list")
public DataGridViewResult materialInfoList(MaterialVo mv) {
// 设置分页信息
PageHelper.startPage(mv.getPage(), mv.getLimit());
// 查询
List<Material> list = materialService.findMaterialInfoListByPage(mv);
// 创建分页对象
PageInfo<Material> pageInfo = new PageInfo<Material>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 修改物资信息
*
* @param mi
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/update")
public String updateMaterialInfo(Material mi) {
HashMap<String, Object> map = new HashMap<>();
boolean result = materialService.updateMaterialInfo(mi);
if (result) {
map.put("success", true);
map.put("msg", "更改成功!");
} else {
@Controller
@RequestMapping("/mh")
public class MHController {
@Resource
private KindService kindService;
@Resource
private MaterialService materialService;
@Resource
private PutinService putinService;
@Resource
private StoreService storeService;
@Resource
private RequisitionService requisitionService;
@Resource
private IndexService indexService;
@RequestMapping(value = "/info.html")
public String materialInfo() {
return "/mh/material-info.html";
/**
* 添加物资类别
*
* @param kd
* @return
*/
@ResponseBody
@RequestMapping(value = "/kind/add")
public String addKind(Kind kd) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(kd);
boolean result = kindService.addKind(kd);
if (result) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
@RequestMapping(value = "/putin.html")
public String putinRecords(){
return "/mh/putin.html";
}
/**
* 获取全部的物资名称
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/putin/getMname.action")
public String getMnameOptions() {
Map<String, Object> map = new HashMap<>();
List<Material> list = materialService.findAllMname();
if (list != null) {
map.put("success", true);
map.put("data", list);
} else {
public String give(Requisition rt,HttpServletRequest request){
// 审核人
String uname = (String)request.getSession().getAttribute("uname");
rt.setRverifier(uname);
// 任务发布日期(即申请日期)
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
rt.setRapplytime(sdf.format(date));
// 申请类型
rt.setRtype("直接发放");
// 时间戳,作为主键
String rid = String.valueOf(date.getTime());
rt.setRid(rid);
// 申请进度
rt.setRstatus("待领取");
System.out.println(rt);
HashMap<String, Object> map = new HashMap<>();
boolean result = requisitionService.give(rt);
if (result) {
map.put("success", true);
map.put("msg", "发布任务成功!");
} else {
map.put("success", false);
map.put("msg", "发布任务失败,请稍后重试!");
}
return JSON.toJSONString(map);
}
}
@RequestMapping(value = "/login.html")
public String toLogin() {
return "/login";
}
@RequestMapping(value = "/home.html")
public String home() {
return "/home";
}
@RequestMapping(value = "/welcome.html")
public String welcome() {
return "/welcome";
}
/**
* 登录
*
* @param request
* @param session
* @return
*/
@ResponseBody
@RequestMapping(value = "/login.action")
public String login(@RequestBody Map<String, String> request, HttpSession session) {
Map<String, Object> map = new HashMap<>();
String uid = request.get("uid");
String password = request.get("password");
System.out.println("uid:" + uid + "--pwd:" + password);
User user = indexService.findUser(uid, password);
if (user != null) {
session.setAttribute("uid", uid);
session.setAttribute("uname", user.getUname());
session.setAttribute("utype", user.getUtype());
map.put("msg","登录成功");
map.put("success", true);
} else {
map.put("success", false);
map.put("msg", "账号或密码错误!");
}
return JSON.toJSONString(map);
}
/**
* 加载菜单列表
*
* @param session
* @return
*/
@ResponseBody
@RequestMapping(value = "/api/loadMenuList")
HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> data = new HashMap<>();
try {
if (file != null) {
String originalFilename = file.getOriginalFilename();
Date date = new Date();
String fileName = date.getTime() + "-" + originalFilename;
// 类路径
String classPath = "F:/IDEA/workspace/MMS/mms/target/classes/static";
// 父路径
String src = "/upload/";
File directory = new File(classPath, src);
if (!directory.exists()) {
directory.mkdir();
}
// 文件名
String imagePath = directory.getPath() + "\\" + fileName;
file.transferTo(new File(imagePath));
data.put("src", src + fileName);
map.put("code", 0);
map.put("msg", "上传成功!");
map.put("data", data);
return JSON.toJSONString(map);
} else {
map.put("code", -1);
map.put("msg", "请选择图片!");
return JSON.toJSONString(map);
}
} catch (Exception e) {
e.printStackTrace();
map.put("code", -1);
map.put("msg", "上传失败,请稍后重试!");
return JSON.toJSONString(map);
}
}
/**
* 添加物资信息
*
* @param mi
* @return
*/
@ResponseBody
} else {
map.put("success", false);
}
return JSON.toJSONString(map);
}
/**
* 发布领取任务
* @param rt
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/distribute/give")
public String give(Requisition rt,HttpServletRequest request){
// 审核人
String uname = (String)request.getSession().getAttribute("uname");
rt.setRverifier(uname);
// 任务发布日期(即申请日期)
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
rt.setRapplytime(sdf.format(date));
// 申请类型
rt.setRtype("直接发放");
// 时间戳,作为主键
String rid = String.valueOf(date.getTime());
rt.setRid(rid);
// 申请进度
rt.setRstatus("待领取");
System.out.println(rt);
HashMap<String, Object> map = new HashMap<>();
boolean result = requisitionService.give(rt);
if (result) {
map.put("success", true);
map.put("msg", "发布任务成功!");
} else {
map.put("success", false);
map.put("msg", "发布任务失败,请稍后重试!");
}
return JSON.toJSONString(map);
}
}
}
// 文件名
String imagePath = directory.getPath() + "\\" + fileName;
file.transferTo(new File(imagePath));
data.put("src", src + fileName);
map.put("code", 0);
map.put("msg", "上传成功!");
map.put("data", data);
return JSON.toJSONString(map);
} else {
map.put("code", -1);
map.put("msg", "请选择图片!");
return JSON.toJSONString(map);
}
} catch (Exception e) {
e.printStackTrace();
map.put("code", -1);
map.put("msg", "上传失败,请稍后重试!");
return JSON.toJSONString(map);
}
}
/**
* 添加物资信息
*
* @param mi
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/add")
public String addMaterialInfo(Material mi) {
HashMap<String, Object> map = new HashMap<>();
System.out.println(mi);
boolean result = materialService.addMaterialInfo(mi);
if (result) {
map.put("success", true);
map.put("msg", "添加成功!");
} else {
map.put("success", false);
map.put("msg", "添加失败,请稍后再试!");
}