基于javaweb+mysql的springboot物资发放管理系统(java+springboot+html+layui+mysql+maven)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot物资发放管理系统(java+springboot+html+layui+mysql+maven)
项目介绍
本项目有物资管理员与普通员工两种角色;
普通员工具有以下功能:申领物资;撤销申请;查看待领任务。 (1)申领物资:提交物资领取申请。 (2)撤销申请:对于物资管理员还未审核的申请,可以撤销;已审核的申请则不能撤销。 (3)查看待领任务:查看已通过审核的申请和物资管理员发起的领取任务。
物资管理员拥有以下功能:物资信息管理;物资入库;物资发放;查看物资库存;审批申请。 (1)物资信息管理:添加物资类别;添加、修改、删除物资信息;按名称或类别或编号查询物资信息。 (2)物资入库:增加物资的库存量;可以按入库时间来查看入库信息。 (3)物资发放:向指定人发放一定数量的物资,并在其领取后进行登记。 (4)查看物资库存:查看所有物资的库存量。 (5)审批申请:查看和审批物资领取申请,同意则员工可以领取物资,不同意则驳回该申请,不允许领取物资。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 8.0/5.7版本;
技术栈
springboot+mysql+layui+CSS+JavaScript
使用说明
运行项目,在浏览器中输入http://localhost:8080 访问
} 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", "添加失败,请稍后再试!");
}
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());
*/
@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);
}
}
@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);
}
/**
* 物资入库
* @param pi
* @return
*/
@ResponseBody
@RequestMapping(value = "/putin/add")
public String addPutinInfo(Putin pi,HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
// 获取经办人信息
* 查询物资的库存信息
* @param sv
* @return
*/
@RequestMapping(value = "/store/list")
@ResponseBody
public DataGridViewResult findStoreList(StoreVo sv){
// 设置分页信息
PageHelper.startPage(sv.getPage(), sv.getLimit());
// 查询
List<Store> list = storeService.findStoreList(sv);
// 创建分页对象
PageInfo<Store> pageInfo = new PageInfo<Store>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
@RequestMapping(value = "/approve.html")
public String approve(){
return "/mh/approve.html";
}
/**
* 查询待审核的领用申请
* @param rv
* @return
*/
@RequestMapping(value = "/approve/list")
@ResponseBody
public DataGridViewResult approveList(RequisitionVo rv){
rv.setRstatus("申请中");
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
List<Requisition> list = requisitionService.findApproveList(rv);
// 创建分页对象
PageInfo<Requisition> pageInfo = new PageInfo<>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 审批申请
* @param rt
// 申请类型
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);
}
}
@Controller
@RequestMapping("/staff")
public class StaffController {
@Resource
private RequisitionService requisitionService;
@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 {
map.put("success", false);
map.put("msg", "更改失败!");
}
return JSON.toJSONString(map);
}
/**
* 删除物资信息
*
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/delete")
public String deleteMaterialInfo(HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
String params = request.getParameter("params");
try {
if (!params.equals("") && params != "") {
// 获取mid数组
JSONArray jsonArray = JSONArray.parseArray(params);
List<String> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject obj = jsonArray.getJSONObject(i);
String mid = (String) obj.get("mid");
System.out.println(mid);
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", "删除失败!");
} 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";
}
/**
* 获取全部的物资名称
*
map.put("success", false);
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 {
map.put("success", false);
map.put("msg", "更改失败!");
}
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");
rv.setRtaker(uname);
rv.setRstatus("待领取");
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
*/
@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");
rv.setRtaker(uname);
rv.setRstatus("待领取");
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
List<Requisition> list = requisitionService.findRequisitionList(rv);
// 创建分页对象
PageInfo<Requisition> pageInfo = new PageInfo<Requisition>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
}
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")
public String loadMenuList(HttpSession session) {
Integer utype = (Integer) session.getAttribute("utype");
String initJson = menuService.loadMenuList(utype);
return initJson;
}
/**
* 退出登录
*
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");
rv.setRtaker(uname);
rv.setRstatus("待领取");
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
List<Requisition> list = requisitionService.findRequisitionList(rv);
// 创建分页对象
PageInfo<Requisition> pageInfo = new PageInfo<Requisition>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
}
@Controller
@RequestMapping("/")
*/
@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
* @return
*/
@ResponseBody
@RequestMapping(value = "/apply/add")
public String addPutinInfo(Requisition rt, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
// 获取领用人
String uname = (String) request.getSession().getAttribute("uname");
rt.setRtaker(uname);
// 生成时间戳,保证主键的唯一性
Date date = new Date();
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", "提交申请成功!");
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");
rv.setRtaker(uname);
rv.setRstatus("待领取");
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
List<Requisition> list = requisitionService.findRequisitionList(rv);
// 创建分页对象
PageInfo<Requisition> pageInfo = new PageInfo<Requisition>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
}
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
@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", "添加失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
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")
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
@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 {