基于javaweb+mysql的springboot物资发放管理系统(java+springboot+html+layui+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的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.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 8.0/5.7版本;
技术栈
springboot+mysql+layui+CSS+JavaScript
使用说明
运行项目,在浏览器中输入http://localhost:8080 访问
String pno = String.valueOf(date.getTime());
pi.setPno(pno);
System.out.println(pi);
boolean result = putinService.addPutin(pi);
if (result) {
map.put("success", true);
map.put("msg", "入库成功!");
} else {
map.put("success", false);
map.put("msg", "入库失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 查询物资入库信息
* @param pv
* @return
*/
@RequestMapping(value = "/putin/list")
@ResponseBody
public DataGridViewResult findPutinList(PutinVo pv){
// 设置分页信息
PageHelper.startPage(pv.getPage(), pv.getLimit());
// 查询
List<Putin> list = putinService.findPutinList(pv);
// 创建分页对象
PageInfo<Putin> pageInfo = new PageInfo<Putin>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
@RequestMapping(value = "/store.html")
public String storeInfo(){
return "/mh/store.html";
}
/**
* 查询物资的库存信息
* @param sv
* @return
*/
@RequestMapping(value = "/store/list")
@ResponseBody
public DataGridViewResult findStoreList(StoreVo sv){
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
/**
* 审批申请
* @param rt
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/approve/approve.action")
public String doApprove(Requisition rt,HttpServletRequest request){
// 审核人
String uname = (String)request.getSession().getAttribute("uname");
rt.setRverifier(uname);
System.out.println(rt);
HashMap<String, Object> map = new HashMap<>();
boolean result = requisitionService.updateRstatus(rt);
if (result) {
map.put("success", true);
map.put("msg", "审核成功!");
} else {
map.put("success", false);
map.put("msg", "审核失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 物资发放页面
* @return
*/
@RequestMapping(value = "/distribute.html")
public String distribute(){
return "/mh/distribute.html";
}
/**
* 查询所有的领用记录
* @param rv
* @return
*/
@RequestMapping(value = "/distribute/list")
@ResponseBody
public DataGridViewResult distributeList(RequisitionVo rv){
// 设置分页信息
PageHelper.startPage(rv.getPage(), rv.getLimit());
// 查询
List<Requisition> list = requisitionService.findAll(rv);
@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")
return JSON.toJSONString(map);
}
/**
* 上传物资图片
*
* @param file
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/uploadImage")
public String uploadImage(MultipartFile file, HttpServletRequest request) {
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);
}
}
/**
* 添加物资信息
*
@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";
}
/**
* 获取全部种类
*
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/getOptions.action")
public String getSelectOptions() {
Map<String, Object> map = new HashMap<>();
List<Kind> list = kindService.findAllKind();
if (list != null) {
map.put("success", true);
map.put("data", list);
} else {
map.put("success", false);
Kind kind = new Kind("005", "其它");
map.put("data", kind);
}
System.out.println(map);
return JSON.toJSONString(map);
}
/**
* 上传物资图片
*
* @param file
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/uploadImage")
public String uploadImage(MultipartFile file, HttpServletRequest request) {
HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> data = new HashMap<>();
* @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", "删除失败!");
}
return JSON.toJSONString(map);
}
/**
* 添加物资类别
*
* @param kd
* @return
*/
@ResponseBody
@RequestMapping(value = "/kind/add")
public String addKind(Kind kd) {
* @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", "提交申请成功!");
} 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);
}
/**
* 撤销申请
* @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());
// 查询
List<Requisition> list = requisitionService.findRequisitionList(rv);
// 创建分页对象
PageInfo<Requisition> pageInfo = new PageInfo<Requisition>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
public String getSelectOptions() {
Map<String, Object> map = new HashMap<>();
List<Kind> list = kindService.findAllKind();
if (list != null) {
map.put("success", true);
map.put("data", list);
} else {
map.put("success", false);
Kind kind = new Kind("005", "其它");
map.put("data", kind);
}
System.out.println(map);
return JSON.toJSONString(map);
}
/**
* 上传物资图片
*
* @param file
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/info/uploadImage")
public String uploadImage(MultipartFile file, HttpServletRequest request) {
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);
}
/**
* 待领取列表
* @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("/")
public class IndexController {
@Resource
private IndexService indexService;
@Resource
private MenuService menuService;
@RequestMapping(value = "/")
public String index() {
return "/login";
}
/**
* 添加物资类别
*
* @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);
}
/**
pi.setPno(pno);
System.out.println(pi);
boolean result = putinService.addPutin(pi);
if (result) {
map.put("success", true);
map.put("msg", "入库成功!");
} else {
map.put("success", false);
map.put("msg", "入库失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 查询物资入库信息
* @param pv
* @return
*/
@RequestMapping(value = "/putin/list")
@ResponseBody
public DataGridViewResult findPutinList(PutinVo pv){
// 设置分页信息
PageHelper.startPage(pv.getPage(), pv.getLimit());
// 查询
List<Putin> list = putinService.findPutinList(pv);
// 创建分页对象
PageInfo<Putin> pageInfo = new PageInfo<Putin>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
@RequestMapping(value = "/store.html")
public String storeInfo(){
return "/mh/store.html";
}
/**
* 查询物资的库存信息
* @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);
// 按接口要求返回数据
* @param request
* @return
*/
@ResponseBody
@RequestMapping(value = "/approve/approve.action")
public String doApprove(Requisition rt,HttpServletRequest request){
// 审核人
String uname = (String)request.getSession().getAttribute("uname");
rt.setRverifier(uname);
System.out.println(rt);
HashMap<String, Object> map = new HashMap<>();
boolean result = requisitionService.updateRstatus(rt);
if (result) {
map.put("success", true);
map.put("msg", "审核成功!");
} else {
map.put("success", false);
map.put("msg", "审核失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 物资发放页面
* @return
*/
@RequestMapping(value = "/distribute.html")
public String distribute(){
return "/mh/distribute.html";
}
/**
* 查询所有的领用记录
* @param rv
* @return
*/
@RequestMapping(value = "/distribute/list")
@ResponseBody
public DataGridViewResult distributeList(RequisitionVo rv){
// 设置分页信息
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 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", "更改失败!");
}
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");
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);
}
}
@Controller
@RequestMapping("/staff")
public class StaffController {
@Resource
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;
}
}
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) {
map.put("success", true);
map.put("msg", "入库成功!");
} else {
map.put("success", false);
map.put("msg", "入库失败,请稍后再试!");
}
return JSON.toJSONString(map);
}
/**
* 查询物资入库信息
* @param pv
* @return
*/
@RequestMapping(value = "/putin/list")
@ResponseBody
public DataGridViewResult findPutinList(PutinVo pv){
// 设置分页信息
PageHelper.startPage(pv.getPage(), pv.getLimit());
// 查询
List<Putin> list = putinService.findPutinList(pv);
// 创建分页对象
PageInfo<Putin> pageInfo = new PageInfo<Putin>(list);
// 按接口要求返回数据
DataGridViewResult data = new DataGridViewResult(pageInfo.getTotal(), pageInfo.getList());
return data;
}
@RequestMapping(value = "/store.html")
public String storeInfo(){
return "/mh/store.html";
}
/**
* 查询物资的库存信息
* @param sv
* @return
*/
@RequestMapping(value = "/store/list")
@ResponseBody