首页 > 其他分享 >物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现

时间:2023-12-08 18:31:47浏览次数:24  
标签:info account return SpringBoot success Result import 物资 防疫


作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、Python项目、前端项目、人工智能与大数据、简历模板、学习资料、面试题库、技术互助

收藏点赞不迷路  关注作者有好处

文末获取源码 

 项目编号:BS-XX-192

一,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

开发技术:Springboot和Vue+HTML

二,项目简介

科学技术的快速更新和发展,有效的推动了计算机技术的进步,从而为计算机技术在社会上的推广运用奠定了坚实的基础。计算机的出现有限的推动了社会各行各业的进步与发展,为人类历史文明与文化的传播提供了有效的路径,帮助人类的发展制造了大量的财富。由于科学技术是社会发展的第一生产力,而科学技术发展的组成就是计算机技术的运用与推广。近年来,因其计算机技术的发展,其应用领域已经从刚开始的军事和科学研究领域逐步蔓延到人们生产、生活等各个方面。如今,人类社会发展从工业化走向高度信息化,计算机技术对人们的影响也在日渐增大。

随着信息化时代的到来,管理系统都趋向于智能化、系统化,防疫物资管理系统也不例外,但目前国内仍都使用人工管理,市场规模越来越大,同时信息量也越来越庞大,人工管理显然已无法应对时代的变化。计算机具有最为普通的存储功能,运算和控制功能,输入输出功能。这些功能,能够很快提高效率,节约时间,不断缩小计算成本,人力成本,同时他比手工化操作更具有科学性,规范性,准确性。所以防疫物资管理系统能很好地解决这一问题,轻松应对防疫物资管理平时的工作,既能提高人力物力财力,又能加快工作的效率,取代人工管理是必然趋势。

该防疫物资管理系统以SpringBoot作为框架,B/S模式以及MySql作为后台运行的数据库,同时使用Tomcat用为系统的服务器。本系统主要包括首页、个人中心、用户管理、物资管理、物资类型管理、物资租借、在线交流管理社区公告管理、新闻资讯管理、租赁表管理、外来人员报备等功能,通过这些功能的实现基本能够满足日常防疫物资管理的操作。

本文着重阐述了防疫物资管理系统的分析、设计与实现,首先介绍开发系统和环境配置、数据库的设计,接着说明功能模块的详细实现,最后进行了总结。

普通用户用例

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_02编辑

管理员

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_03

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_04编辑

超级管理员

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_05

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_06编辑

三,系统展示

用户注册

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_07

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_08编辑

登录

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_09

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_10编辑

系统首页

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_11

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_12编辑

物资商品

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_13

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_14编辑

购物车

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_15

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_16编辑

公告管理

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_17

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_18编辑

后台管理

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_19

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_20编辑

其它界面展示略

四,核心代码展示

package com.example.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.AdminInfo;
import com.example.service.AdminInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.AdminInfoVo;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.example.service.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Value;
import cn.hutool.core.util.StrUtil;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping(value = "/adminInfo")
public class AdminInfoController {

    @Resource
    private AdminInfoService adminInfoService;

    @PostMapping
    public Result<AdminInfo> add(@RequestBody AdminInfoVo adminInfo) {
        adminInfoService.add(adminInfo);
        return Result.success(adminInfo);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Long id) {
        adminInfoService.delete(id);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody AdminInfoVo adminInfo) {
        adminInfoService.update(adminInfo);
        return Result.success();
    }

    @GetMapping("/{id}")
    public Result<AdminInfo> detail(@PathVariable Long id) {
        AdminInfo adminInfo = adminInfoService.findById(id);
        return Result.success(adminInfo);
    }

    @GetMapping
    public Result<List<AdminInfoVo>> all() {
        return Result.success(adminInfoService.findAll());
    }

    @GetMapping("/page/{name}")
    public Result<PageInfo<AdminInfoVo>> page(@PathVariable String name,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "5") Integer pageSize,
                                                HttpServletRequest request) {
        return Result.success(adminInfoService.findPage(name, pageNum, pageSize, request));
    }

    @PostMapping("/register")
    public Result<AdminInfo> register(@RequestBody AdminInfo adminInfo) {
        if (StrUtil.isBlank(adminInfo.getName()) || StrUtil.isBlank(adminInfo.getPassword())) {
            throw new CustomException(ResultCode.PARAM_ERROR);
        }
        return Result.success(adminInfoService.add(adminInfo));
    }

    /**
    * 批量通过excel添加信息
    * @param file excel文件
    * @throws IOException
    */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {

        List<AdminInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(AdminInfo.class);
        if (!CollectionUtil.isEmpty(infoList)) {
            // 处理一下空数据
            List<AdminInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getName())).collect(Collectors.toList());
            for (AdminInfo info : resultList) {
                adminInfoService.add(info);
            }
        }
        return Result.success();
    }

    @GetMapping("/getExcelModel")
    public void getExcelModel(HttpServletResponse response) throws IOException {
        // 1. 生成excel
        Map<String, Object> row = new LinkedHashMap<>();
		row.put("name", "admin");
		row.put("password", "123456");
		row.put("nickName", "管理员");
		row.put("sex", "男");
		row.put("age", 22);
		row.put("birthday", "TIME");
		row.put("phone", "18843232356");
		row.put("address", "上海市");
		row.put("code", "111");
		row.put("email", "[email protected]");
		row.put("cardId", "342425199001116372");
		row.put("level", 1);

        List<Map<String, Object>> list = CollUtil.newArrayList(row);

        // 2. 写excel
        ExcelWriter writer = ExcelUtil.getWriter(true);
        writer.write(list, true);

        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename=adminInfoModel.xlsx");

        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        writer.close();
        IoUtil.close(System.out);
    }
}

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_21

package com.example.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.Account;
import com.example.entity.AuthorityInfo;
import com.example.exception.CustomException;
import com.example.entity.AdminInfo;
import com.example.entity.BusinessInfo;
import com.example.entity.UserInfo;

import com.example.service.AdminInfoService;
import com.example.service.BusinessInfoService;
import com.example.service.UserInfoService;

import org.springframework.web.bind.annotation.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import cn.hutool.json.JSONUtil;

import java.util.*;
import java.util.stream.Collectors;

@RestController
public class AccountController {

    @Value("${authority.info}")
    private String authorityStr;

	@Resource
	private AdminInfoService adminInfoService;
	@Resource
	private BusinessInfoService businessInfoService;
	@Resource
	private UserInfoService userInfoService;


    /**
     * 用户登陆
     * @param account
     * @param request
     * @return
     */
    @PostMapping("/login")
    public Result<Account> login(@RequestBody Account account, HttpServletRequest request) {
        if (StrUtil.isBlank(account.getName()) || StrUtil.isBlank(account.getPassword()) || account.getLevel() == null) {
            throw new CustomException(ResultCode.PARAM_LOST_ERROR);
        }
        Integer level = account.getLevel();
        Account login = new Account();
		if (1 == level) {
			login = adminInfoService.login(account.getName(), account.getPassword());
		}
		if (2 == level) {
			login = businessInfoService.login(account.getName(), account.getPassword());
		}
		if (3 == level) {
			login = userInfoService.login(account.getName(), account.getPassword());
		}

        request.getSession().setAttribute("user", login);//设置session
        return Result.success(login);
    }

    @PostMapping("/register")//注册
    public Result<Account> register(@RequestBody Account account) {
        Integer level = account.getLevel();
        Account login = new Account();
		if (1 == level) {//超级管理员
			AdminInfo info = new AdminInfo();
			BeanUtils.copyProperties(account, info);//将account的属性copy到info对象中
			login = adminInfoService.add(info);
		}
		if (2 == level) {//普通管理员
			BusinessInfo info = new BusinessInfo();
			BeanUtils.copyProperties(account, info);
			login = businessInfoService.add(info);
		}
		if (3 == level) {//普通社区用户
			UserInfo info = new UserInfo();
			BeanUtils.copyProperties(account, info);
			login = userInfoService.add(info);
		}

        return Result.success(login);
    }

    @GetMapping("/logout")
    public Result logout(HttpServletRequest request) {
        request.getSession().setAttribute("user", null);
        return Result.success();
    }

    @GetMapping("/auth")
    public Result getAuth(HttpServletRequest request) {
        Object user = request.getSession().getAttribute("user");
        if(user == null) {
            return Result.error("401", "未登录");
        }
        return Result.success(user);
    }

    @GetMapping("/getAccountInfo")
    public Result<Object> getAccountInfo(HttpServletRequest request) {
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) {
            return Result.success(new Object());
        }
        Integer level = account.getLevel();
		if (1 == level) {
			return Result.success(adminInfoService.findById(account.getId()));
		}
		if (2 == level) {
			return Result.success(businessInfoService.findById(account.getId()));
		}
		if (3 == level) {
			return Result.success(userInfoService.findById(account.getId()));
		}

        return Result.success(new Object());
    }

    @GetMapping("/getSession")
    public Result<Map<String, String>> getSession(HttpServletRequest request) {
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) {
            return Result.success(new HashMap<>(1));
        }
        Map<String, String> map = new HashMap<>(1);
        map.put("username", account.getName());
        return Result.success(map);
    }

    @GetMapping("/getAuthority")//获取登录身份级别信息
    public Result<List<AuthorityInfo>> getAuthorityInfo() {
        List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
        return Result.success(authorityInfoList);
    }

    /**
    * 获取当前用户所能看到的模块信息
    * @param request
    * @return
    */
    @GetMapping("/authority")
    public Result<List<Integer>> getAuthorityInfo(HttpServletRequest request) {
        Account user = (Account) request.getSession().getAttribute("user");
        if (user == null) {
            return Result.success(new ArrayList<>());
        }
        JSONArray objects = JSONUtil.parseArray(authorityStr);
        for (Object object : objects) {
            JSONObject jsonObject = (JSONObject) object;
            if (user.getLevel().equals(jsonObject.getInt("level"))) {
                JSONArray array = JSONUtil.parseArray(jsonObject.getStr("models"));
                List<Integer> modelIdList = array.stream().map((o -> {
                    JSONObject obj = (JSONObject) o;
                    return obj.getInt("modelId");
                    })).collect(Collectors.toList());
                return Result.success(modelIdList);
            }
        }
        return Result.success(new ArrayList<>());
    }

    @GetMapping("/permission/{modelId}")
    public Result<List<Integer>> getPermission(@PathVariable Integer modelId, HttpServletRequest request) {
        List<AuthorityInfo> authorityInfoList = JSONUtil.toList(JSONUtil.parseArray(authorityStr), AuthorityInfo.class);
        Account user = (Account) request.getSession().getAttribute("user");
        if (user == null) {
            return Result.success(new ArrayList<>());
        }
        Optional<AuthorityInfo> optional = authorityInfoList.stream().filter(x -> x.getLevel().equals(user.getLevel())).findFirst();
        if (optional.isPresent()) {
            Optional<AuthorityInfo.Model> firstOption = optional.get().getModels().stream().filter(x -> x.getModelId().equals(modelId)).findFirst();
            if (firstOption.isPresent()) {
                List<Integer> info = firstOption.get().getOperation();
                return Result.success(info);
            }
        }
        return Result.success(new ArrayList<>());
    }

    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody Account info, HttpServletRequest request) {
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) {
            return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
        }
        String oldPassword = SecureUtil.md5(info.getPassword());
        if (!oldPassword.equals(account.getPassword())) {
            return Result.error(ResultCode.PARAM_PASSWORD_ERROR.code, ResultCode.PARAM_PASSWORD_ERROR.msg);
        }
        info.setPassword(SecureUtil.md5(info.getNewPassword()));
        Integer level = account.getLevel();
		if (1 == level) {
			AdminInfo adminInfo = new AdminInfo();
			BeanUtils.copyProperties(info, adminInfo);
			adminInfoService.update(adminInfo);
		}
		if (2 == level) {
			BusinessInfo businessInfo = new BusinessInfo();
			BeanUtils.copyProperties(info, businessInfo);
			businessInfoService.update(businessInfo);
		}
		if (3 == level) {
			UserInfo userInfo = new UserInfo();
			BeanUtils.copyProperties(info, userInfo);
			userInfoService.update(userInfo);
		}

        info.setLevel(level);
        info.setName(account.getName());
        // 清空session,让用户重新登录
        request.getSession().setAttribute("user", null);
        return Result.success();
    }

    @PostMapping("/resetPassword")
    public Result resetPassword(@RequestBody Account account) {
        Integer level = account.getLevel();
		if (1 == level) {
			AdminInfo info = adminInfoService.findByUserName(account.getName());
			if (info == null) {
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			adminInfoService.update(info);
		}
		if (2 == level) {
			BusinessInfo info = businessInfoService.findByUserName(account.getName());
			if (info == null) {
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			businessInfoService.update(info);
		}
		if (3 == level) {
			UserInfo info = userInfoService.findByUserName(account.getName());
			if (info == null) {
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			userInfoService.update(info);
		}

        return Result.success();
    }
}

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_22

五,相关作品展示

基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目

基于Nodejs、Vue等前端技术开发的前端实战项目

基于微信小程序和安卓APP应用开发的相关作品

基于51单片机等嵌入式物联网开发应用

基于各类算法实现的AI智能应用

基于大数据实现的各类数据管理和推荐系统

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_23

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_24编辑

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_25

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_26编辑

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_27

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_28编辑

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_29

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_30编辑

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_31

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_32编辑

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_33

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_34编辑

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_35

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_防疫物资管理系统_36编辑

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_37

物资管理|基于SpringBoot技术的防疫物资管理系统设计与实现_物资管理系统_38编辑



标签:info,account,return,SpringBoot,success,Result,import,物资,防疫
From: https://blog.51cto.com/u_16147814/8741247

相关文章

  • springboot热部署配置
    第一步pom文件 <!--引入热部署依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></......
  • SpringBoot高级开发(9)Spring中的HttpSession
    1、简述HttpSession是javaWeb提供的,用来处理会话事务的。session数据保存在后台,当然首次开启会话(即调用req.getSession())的时候也会将该SessionID数值传给前端用作Cookie2、作用范围首次访问服务器开始,浏览器关闭后就结束。后端的Session可以存储30分钟,如果30分钟无任何请求,就......
  • SpringBoot+线程池实现高频调用http接口并多线程解析json数据
    场景Springboot+FastJson实现解析第三方http接口json数据为实体类(时间格式化转换、字段包含中文):https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/134872936Java中ExecutorService线程池的使用(Runnable和Callable多线程实现):https://blog.csdn.net/BADAO_LIUMAN......
  • Springboot+FastJson实现解析第三方http接口json数据为实体类(时间格式化转换、字段包
    场景若依前后端分离版手把手教你本地搭建环境并运行项目:https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/108465662在上面搭建SpringBoot项目的基础上,并且在项目中引入fastjson、hutool、lombok等所需依赖后。系统需要对接第三方http接口获取返回的数据,并将json数......
  • 记录springboot的一次使用socketio的经历
    pom中加入依赖<dependency><groupId>com.corundumstudio.socketio</groupId><artifactId>netty-socketio</artifactId><version>2.0.6</version></dependency>......
  • MySQL服务器8核32G max_connections设置为10000的情况,springboot里面的Druid参数配置
    MySQL服务器8核32Gmax_connections设置为10000的情况,springboot里面的Druid参数配置多少合适啊,MySQL服务器8核32G,max_connections设置为10000,确实是相当大的一个配置啊。对于Druid的参数配置,得看你系统的具体情况。一般来说,你可以考虑以下几个参数:initialSize:连接池的初始大小,你......
  • springboot蜗牛兼职网的设计与实现-计算机毕业设计源码+LW文档
    摘 要随着科学技术的飞速发展,社会的方方面面、各行各业都在努力与现代的先进技术接轨,通过科技手段来提高自身的优势,蜗牛兼职网当然也不能排除在外。蜗牛兼职网是以实际运用为开发背景,运用软件工程原理和开发方法,采用springboot框架构建的一个管理系统。整个开发过程首先对软件系......
  • @SpringBootTest与@RunWith注解的区别
    @SpringBootTest与@RunWith注解的区别@SpringBootTest与@RunWith注解的区别在于:@SpringBootTest是spring的注解,用于加载ApplicationContext,启动spring容器;而@RunWith是junit的注解,它指定了junit测试的时候使用的Runner(运行器)类。通常@SpringBootTest与@RunWith这两个是配合使......
  • springboot018母婴商城-计算机毕业设计源码+LW文档
    一、选题背景以母婴人群和准母婴人群及其家庭群体为目标用户。站在整个社会产业的角度,有些产业为所有用户提供某类基本需求,有些产业为某类用户提供某类特定需求,而母婴产业是最终满足特定人群相关多元化需求的一个宽辐射市场。母婴产品及服务最终以线上与线下为出口抵达用户,从市场......
  • springboot019高校心理教育辅导设计与实现-计算机毕业设计源码+LW文档
    1.1选题的意义和目的当今社会,经济飞速发展,科技日新月异,人际关系复杂多变,整个社会生活节奏越来越快,人们承受的生活压力越来越大。而对于在校大学生来说,他们还未完全融入到社会之中,但他们却依然要面对这些社会问题,他们要不断地学习新的知识,要开始学会如何解决身边地人际关系问题,要面......