目录

一、项目简介

二、项目背景

三、项目目标

四、系统设计与实现

1.数据库设计

2.系统架构设计

3.系统功能设计

五、系统项目截图

1.登录页面

2.采购员登录

3.财务员登录

4.后勤员登录

5.管理员登录

六、核心代码

1.登录相关

2.文件上传

3.封装


一、项目简介

本文介绍的是基于SSM框架的疫情物资管理系统,该系统旨在提高物资管理的效率和质量,为疫情期间的防控工作提供支持。为了实现该系统的目标,我们设计了以下主要功能:修改密码、个人信息修改、采购员管理、财务员管理、后勤员管理、物资分类管理、物资采购管理、财务报销管理、入库信息管理、申领信息管理等。

本系统的采用了Spring、SpringMVC和MyBatis(SSM)框架,其中Spring提供了依赖注入、AOP等基础设施,提高了代码的可维护性和可扩展性;Spring MVC负责分发请求和控制器的映射,使得系统具有良好的结构性和可控性;MyBatis则是本系统的数据访问层,实现了对数据的快速访问和高效操作。

本系统的用户角色主要分为采购员、财务员和后勤员,他们对应的职责不同。采购员主要负责物资的采购和管理,财务员负责对物资的财务报销管理,后勤员则负责对物资的存储、管理和发放。本系统为每个用户提供了专属的登录账号和密码,并且允许用户在登录后修改自己的密码和个人信息。

物资的分类管理是本系统的重点之一,因为物资种类繁多,需要进行适当分类才能更好的管理。我们设计了物资分类树状图,在这个页面上对物资进行分类管理。采购员可以在物资采购管理模块中提交采购请求,财务员审核通过后,方可进行采购操作。采购或者领取到的物资需要入库管理,管理员可以在入库信息管理模块中对其进行记录。申领物资时,用户需要在申领信息管理中填写申领表单,经过管理员审核后,方可领取物资。

总之,本系统提供了完善的物资管理解决方案,实现了对物资采购、存储、管理和领取的全程监控和管理,为疫情期间的防控工作提供了有力的支持。未来我们将进一步完善该系统,扩展其功能和适用性,提供更好的服务。


二、项目背景

在当前疫情期间,物资的管理和调配变得格外重要,各级政府、企事业单位和社会各界都积极参与疫情防控工作。然而,由于物资调配任务的复杂性和新冠疫情的特殊性,许多地区和单位的物资采购、管理、调配和申领等方面还存在许多问题。因此,设计一款基于SSM框架的疫情物资管理系统,可以帮助各级单位更好地统计物资的供需信息、实现精细化管理和科学调配,大大提高物资利用率和工作效率。


三、项目目标

本项目的最终目标是设计一款基于SSM框架的疫情物资管理系统,通过系统对不同角色的权限设置和操作,实现物资采购、入库、管理和申领等业务流程,大大提高物资利用率和工作效率。

四、系统设计与实现

1.数据库设计

本系统采用MySQL数据库,设计了物资信息、员工信息、采购信息、财务信息、后勤信息等5个主要数据表。其中,员工信息表包括员工ID、员工姓名、员工身份、员工密码、联系方式等字段;物资信息表包括物资ID、物资名称、物资种类、物资规格、物资价格等字段;采购信息表包括采购信息ID、采购物资ID、采购日期、采购数量、采购员ID等字段;财务信息表包括报销信息ID、报销日期、报销金额、报销员工ID等字段;后勤信息表包括入库信息ID、入库日期、入库物资ID、入库数量、入库员工ID、出库信息ID、出库日期、出库物资ID、出库数量、出库员工ID等字段。

2.系统架构设计

本系统采用SSM框架,包括Spring、SpringMVC和MyBatis三个主要模块。其中,Spring负责管理对象的生命周期和依赖关系,SpringMVC负责处理请求和响应,MyBatis负责映射数据库和执行SQL语句。同时,前端采用Bootstrap框架,可以提高系统的界面美观度和易用性。

3.系统功能设计

(1)登录模块

用户通过输入用户名和密码后,系统会根据用户身份信息判断用户的权限,并展示对应页面。

(2)修改密码模块

用户可以在系统中修改自己的密码,保障密码的安全性。

(3)个人信息修改模块

用户可以在系统中修改自己的个人信息,包括联系方式等字段。

(4)采购员管理模块

采购员可以查看物资信息、提交采购申请、查看采购历史等功能。其中,提交采购申请包括填写采购物资种类、数量和价格等信息,等待财务审核。

(5)财务员管理模块

财务员可以对采购申请进行审核和报销,以及查看财务报销历史等功能。其中,审核采购申请包括查看采购物资种类、数量和价格等信息,审核通过后将报销金额记录到财务报销信息表中,等待下一步入库操作。

(6)后勤员管理模块

后勤员可以对物资进行入库操作,包括填写入库物资信息、数量和日期等字段。同时,后勤员还可以对已入库的物资进行出库操作,包括填写出库物资信息、数量和日期等字段。

(7)物资分类管理模块

管理员可以对物资进行分类管理,包括新增物资种类、删除物资种类和修改物资种类等功能。

(8)物资采购管理模块

管理员可以查看所有采购信息、审核采购申请和删除采购信息等功能。

(9)财务报销管理模块

管理员可以查看财务报销历史,介入审核过程等功能。

(10)入库信息管理模块

管理员可以查看所有入库信息、删除入库信息等功能。

(11)申领信息管理模块

管理员可以查看所有申领信息、审核申领信息等功能。

五、系统项目截图

1.登录页面

管理员、采购员、财务员、后勤员都在这里进行登录。

基于SSM的疫情物资管理系统-LMLPHP

2.采购员登录

采购员进入系统可以看到有物资分类管理、物资采购管理、财务报销管理。

基于SSM的疫情物资管理系统-LMLPHP

3.财务员登录

财务员登录到系统可以看到有物资采购、财务报销功能。

基于SSM的疫情物资管理系统-LMLPHP

4.后勤员登录

后期人员登录后可以看到有采购管理、入库信息管理、申领信息管理。

基于SSM的疫情物资管理系统-LMLPHP

5.管理员登录

管理员进入系统可以看到有修改密码、个人信息修改、采购员管理、财务员管理、后勤员管理、物资分类管理、物资采购管理、财务报销管理、入库信息管理、申领信息管理等。

基于SSM的疫情物资管理系统-LMLPHP


六、核心代码

1.登录相关


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

2.文件上传

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

3.封装

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}
06-02 02:43