基于springboot+mybatis设备管理后台,可直接上线项目!

一、项目页面

1、登录页面
登录后才可进入
注:用户名密码登录,登录完成之后才可进入页面,必须一个员工一个账号,外加一个仓库管理账号。

2、首页设备统计
设备统计
注:设备统计页面,包含各种机型状态,机型总表,记录机型名称、设备号、转移场详情等信息。当需要借手机时,可直接搜索到对应人员。

3、个人持有页面
个人持有页面
注:本页面查看自己名下所有机型,可将持有机型转出到其他人员。无需借助管理员之手。

4、待处理页面在这里插入图片描述
注:本界面用来处理,待转入设备,当有人将设备转给你的时候,你可以选择对应操作。

5、仓库管理页面
在这里插入图片描述
注:仓库管理员账号,可在本页面获取到所有机型,观察机型动态,报废部分机型等。

6、用户管理页面主要是用户权限调配、信息完善等、这里不做截图展示了

二、数据库方面
1、user表在这里插入图片描述

2、phone表
在这里插入图片描述
3、usergroup表
在这里插入图片描述

三、代码目录

在这里插入图片描述
四、关键代码
1、controller层

package com.hykb.manager.Controller;

import com.hykb.manager.entity.PageModel;
import com.hykb.manager.entity.Phone;
import com.hykb.manager.entity.User;
import com.hykb.manager.service.PhoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@RequestMapping("/phone")
public class PhoneController {
    @Autowired
    PhoneService phoneService;

    @RequestMapping("/toMyPhone")//跳转我的设备页
    public String toMyPhone() {
        return "myPhone";
    }

    @RequestMapping("/toAllPhone")//跳转所有设备页
    public String toAllPhone(HttpServletRequest request) {
        Map<String,Object> typeMap = phoneService.getTypeMap();
        request.setAttribute("typeMap",typeMap);
        return "allPhone";
    }
    @RequestMapping("/toMine")//跳转待处理设备页面
    public String toMine() {
        return "toMine";
    }

    @RequestMapping("/toPhoneM")//跳转设备管理页面
    public String toPhoneM() {
        return "phoneM";
    }

    @RequestMapping("/getPhoneListByPage")
    @ResponseBody//分页展示
    public PageModel<Phone> getPhoneListByPage(Phone phone, int currentPage, int pageSize, int totalRecord) {
        return phoneService.getPhoneListByPage(phone, currentPage, pageSize, totalRecord);
    }

    @RequestMapping("/getPhoneNoteList")
    @ResponseBody//分页展示
    public PageModel<Phone> getPhoneNoteList(HttpServletRequest request) {
        int currentPage=1;
        int pageSize=1000;
        int totalRecord=-1;
        User sessionInfo = (User) request.getAttribute("userInfo");
        Phone phone=new Phone();
        phone.setTargetUser(sessionInfo.getUserName());
        phone.setToMine("toMine");
        return phoneService.getPhoneListByPage(phone, currentPage, pageSize, totalRecord);
    }

    @RequestMapping("/addPhone")
    @ResponseBody//机型入库
    public String addPhone(Phone phone,HttpServletRequest request){
        User sessionInfo= (User) request.getAttribute("userInfo");
        if (phoneService.addPhone(phone,sessionInfo)){
            return "新机入库成功!";
        }else {
            return "机型入库失败,请重新提交!";
        }
    }

    @RequestMapping("/givePhone")
    @ResponseBody//机型转交
    public String givePhone(int pTarget,String targetName,int pId,HttpServletRequest request){
        User sessionInfo= (User) request.getAttribute("userInfo");
        if (phoneService.givePhone(pTarget,targetName,pId, sessionInfo)){
            return "提交机型转出至"+targetName+"成功!";
        }else {
            return "提交机型转出至"+targetName+"失败,请重试!";
        }
    }

    @RequestMapping("/getPhone")
    @ResponseBody//转交机型处理
    public String getPhone(boolean isGet,int pTarget,int pId,HttpServletRequest request){
        User sessionInfo= (User) request.getAttribute("userInfo");
        if (phoneService.getPhone(isGet,pTarget,pId,sessionInfo)){
            if (isGet){
                return "同意接收设备成功!";
            }else {
                return "拒绝接收设备成功!";
            }
        }else {
            if (isGet){
                return "同意接收设备成功,请重试!";
            }else {
                return "拒绝接收设备失败,请重试!";
            }
        }
    }

    @RequestMapping("/givePhoneUp")
    @ResponseBody//设备报废
    public String givePhoneUp(int pId,String pName){
        if(phoneService.givePhoneUp(pId)){
            return "设备”"+pName+"“报废成功!";
        }else {
            return "设备“"+pName+"”报废失败,请重试!";
        }
    }

    @RequestMapping("/updateNote")
    @ResponseBody//更新备注
    public String updateNote(int pId,String pNote){
        if(phoneService.updateNote(pId,pNote)){
            return "更新备注成功!";
        }else {
            return "更新备注失败,请重试!";
        }
    }


    @RequestMapping("/updatePhone")
    @ResponseBody//更新机型
    public String updatePhone(int pId, String pNote, String pName, String pNum){
        if(phoneService.updatePhone(pId,pNote,pName,pNum)){
            return "修改机型信息成功!";
        }else {
            return "修改机型信息失败!,请重试!";
        }
    }
}

2、service层

package com.hykb.manager.Controller;

import com.hykb.manager.entity.PageModel;
import com.hykb.manager.entity.Phone;
import com.hykb.manager.entity.User;
import com.hykb.manager.service.PhoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@RequestMapping("/phone")
public class PhoneController {
    @Autowired
    PhoneService phoneService;

    @RequestMapping("/toMyPhone")//跳转我的设备页
    public String toMyPhone() {
        return "myPhone";
    }

    @RequestMapping("/toAllPhone")//跳转所有设备页
    public String toAllPhone(HttpServletRequest request) {
        Map<String,Object> typeMap = phoneService.getTypeMap();
        request.setAttribute("typeMap",typeMap);
        return "allPhone";
    }
    @RequestMapping("/toMine")//跳转待处理设备页面
    public String toMine() {
        return "toMine";
    }

    @RequestMapping("/toPhoneM")//跳转设备管理页面
    public String toPhoneM() {
        return "phoneM";
    }

    @RequestMapping("/getPhoneListByPage")
    @ResponseBody//分页展示
    public PageModel<Phone> getPhoneListByPage(Phone phone, int currentPage, int pageSize, int totalRecord) {
        return phoneService.getPhoneListByPage(phone, currentPage, pageSize, totalRecord);
    }

    @RequestMapping("/getPhoneNoteList")
    @ResponseBody//分页展示
    public PageModel<Phone> getPhoneNoteList(HttpServletRequest request) {
        int currentPage=1;
        int pageSize=1000;
        int totalRecord=-1;
        User sessionInfo = (User) request.getAttribute("userInfo");
        Phone phone=new Phone();
        phone.setTargetUser(sessionInfo.getUserName());
        phone.setToMine("toMine");
        return phoneService.getPhoneListByPage(phone, currentPage, pageSize, totalRecord);
    }

    @RequestMapping("/addPhone")
    @ResponseBody//机型入库
    public String addPhone(Phone phone,HttpServletRequest request){
        User sessionInfo= (User) request.getAttribute("userInfo");
        if (phoneService.addPhone(phone,sessionInfo)){
            return "新机入库成功!";
        }else {
            return "机型入库失败,请重新提交!";
        }
    }

    @RequestMapping("/givePhone")
    @ResponseBody//机型转交
    public String givePhone(int pTarget,String targetName,int pId,HttpServletRequest request){
        User sessionInfo= (User) request.getAttribute("userInfo");
        if (phoneService.givePhone(pTarget,targetName,pId, sessionInfo)){
            return "提交机型转出至"+targetName+"成功!";
        }else {
            return "提交机型转出至"+targetName+"失败,请重试!";
        }
    }

    @RequestMapping("/getPhone")
    @ResponseBody//转交机型处理
    public String getPhone(boolean isGet,int pTarget,int pId,HttpServletRequest request){
        User sessionInfo= (User) request.getAttribute("userInfo");
        if (phoneService.getPhone(isGet,pTarget,pId,sessionInfo)){
            if (isGet){
                return "同意接收设备成功!";
            }else {
                return "拒绝接收设备成功!";
            }
        }else {
            if (isGet){
                return "同意接收设备成功,请重试!";
            }else {
                return "拒绝接收设备失败,请重试!";
            }
        }
    }

    @RequestMapping("/givePhoneUp")
    @ResponseBody//设备报废
    public String givePhoneUp(int pId,String pName){
        if(phoneService.givePhoneUp(pId)){
            return "设备”"+pName+"“报废成功!";
        }else {
            return "设备“"+pName+"”报废失败,请重试!";
        }
    }

    @RequestMapping("/updateNote")
    @ResponseBody//更新备注
    public String updateNote(int pId,String pNote){
        if(phoneService.updateNote(pId,pNote)){
            return "更新备注成功!";
        }else {
            return "更新备注失败,请重试!";
        }
    }


    @RequestMapping("/updatePhone")
    @ResponseBody//更新机型
    public String updatePhone(int pId, String pNote, String pName, String pNum){
        if(phoneService.updatePhone(pId,pNote,pName,pNum)){
            return "修改机型信息成功!";
        }else {
            return "修改机型信息失败!,请重试!";
        }
    }
}

3、dao层接口

package com.hykb.manager.dao;


import com.hykb.manager.entity.PageModel;
import com.hykb.manager.entity.Phone;
import com.hykb.manager.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository // 也可以使用@Component,效果都是一样的,只是为了声明为bean
@Mapper
public interface PhoneMapper {
    int getPhoneCount(@Param("pName") String pName, @Param("pNum") String pNum, @Param("holdingName") String holdingName,@Param("holdingUser") String holdingUser,@Param("toMine")String toMine,
                      @Param("pStatus") String pStatus, @Param("targetName") String targetName,@Param("targetUser") String targetUser, @Param("groupName") String groupName, @Param("startIndex") int startIndex, @Param("pageSize") int pageSize);

    List<Phone> getPhoneListByPage(@Param("pName") String pName, @Param("pNum") String pNum, @Param("holdingName") String holdingName,@Param("holdingUser") String holdingUser,@Param("toMine")String toMine,
                                   @Param("pStatus") String pStatus, @Param("targetName") String targetName,@Param("targetUser") String targetUser, @Param("groupName") String groupName, @Param("startIndex") int startIndex, @Param("pageSize") int pageSize);

    int addPhone(Phone phone);

    int getTypeCount(@Param("type1") String type1, @Param("type2") String type2, @Param("type3")String type3);

    int updatePhone(Phone phone);

    int getCountById(@Param("pHolding") int pHolding);
}

4、mapper

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hykb.manager.dao.PhoneMapper">
    <!--获取手机总数-->
    <select id="getPhoneCount" resultType="int">
        select count(p.p_Id)
        from phone p left join users u1 on u1.userId = p.p_Holding LEFT JOIN usergroup g on u1.userGroup=g.groupId left
        join users u2 on u2.userId = p.p_Target
        <where>
            <if test="pName != '' and pName != null">
                and p.p_Name like '%${pName}%'
            </if>
            <if test="toMine != '' and toMine != null">
                and u1.userRealName != u2.userRealName
            </if>
            <if test="pNum != '' and pNum != null">
                and p.p_Num like '%${pNum}%'
            </if>
            <if test="holdingName != '' and holdingName != null">
                and u1.userRealName like '%${holdingName}%'
            </if>
            <if test="holdingUser != '' and holdingUser != null">
                and u1.userName = #{holdingUser}
            </if>
            <if test="pStatus != '' and pStatus != null">
                and p.p_Status = #{pStatus}
            </if>
            <if test="targetName != '' and targetName != null">
                and u2.userRealName like '%${targetName}%'
            </if>
            <if test="targetUser != '' and targetUser != null">
                and u2.userName = #{targetUser}
            </if>
            <if test="groupName != '' and groupName != null">
                and g.groupName like '%${groupName}%'
            </if>
        </where>
        <if test="pageSize != null and pageSize != ''">
            order by p_Id desc limit #{startIndex},#{pageSize};
        </if>
    </select>
    <!--分页获取机型列表-->
    <select id="getPhoneListByPage" resultType="com.hykb.manager.entity.Phone">
        select p.p_Id as pId
        , p.p_Name as pName
        , p.p_Num as pNum
        , u1.userRealName as holdingName
        , p.p_Holding as holdingId
        , u1.userName as holdingUser
        , g.groupName as groupName
        , p.p_Record as pRecord
        , p.p_Status as pStatus
        , u2.userRealName as targetName
        , p.p_Target as targetId
        , u2.userName as targetUser
        , DATE_FORMAT( p.p_Time , "%Y-%m-%d %H:%m:%s" )as pTime
        , DATE_FORMAT( p.add_Time, "%Y-%m-%d %H:%m:%s" ) as addTime
        , p.p_Note as pNote
        from phone p left join users u1 on u1.userId = p.p_Holding LEFT JOIN usergroup g on u1.userGroup=g.groupId left
        join users u2 on u2.userId = p.p_Target
        <where>
            <if test="pName != '' and pName != null">
                and p.p_Name like '%${pName}%'
            </if>
            <if test="toMine != '' and toMine != null">
                and u1.userRealName != u2.userRealName
            </if>
            <if test="pNum != '' and pNum != null">
                and p.p_Num like '%${pNum}%'
            </if>
            <if test="holdingName != '' and holdingName != null">
                and u1.userRealName like '%${holdingName}%'
            </if>
            <if test="holdingUser != '' and holdingUser != null">
                and u1.userName = #{holdingUser}
            </if>
            <if test="pStatus != '' and pStatus != null">
                and p.p_Status = #{pStatus}
            </if>
            <if test="targetName != '' and targetName != null">
                and u2.userRealName like '%${targetName}%'
            </if>
            <if test="targetUser != '' and targetUser != null">
                and u2.userName = #{targetUser}
            </if>
            <if test="groupName != '' and groupName != null">
                and g.groupName like '%${groupName}%'
            </if>
        </where>
        <if test="pageSize != null and pageSize != ''">
            order by p_Id desc limit #{startIndex},#{pageSize};
        </if>
    </select>

    <select id="getCountById" resultType="int">
        select count(p_Id) from phone where p_Holding=#{pHolding} or p_Target=#{pHolding}
    </select>

    <!--添加新设备-->
    <insert id="addPhone" parameterType="com.hykb.manager.entity.Phone" useGeneratedKeys="true">
        insert into phone(p_Name,p_Num,p_Holding,p_Record,p_Note,p_Status,p_Time,add_Time) values (#{pName},#{pNum},"3839",#{pRecord},#{pNote},"库存",now(),now())
    </insert>

    <!--获取我的设备列表-->
    <select id="getToMyPhoneListByPage" resultType="com.hykb.manager.entity.Phone">
        select p.p_Id as pId
        , p.p_Name as pName
        , p.p_Num as pNum
        , p.p_Record as pRecord
        , u1.userRealName as holdingName
        , p.p_Status as pStatus
        , DATE_FORMAT( p.p_Time , "%Y-%m-%d %H:%m:%s" )as pTime
        , p.p_Note as pNote
        FROM phone p LEFT JOIN users u on p.p_Holding= u.userId
        <where>
            <if test="pHolding != '' and pHolding != null">
                p_Target=#{pTarget} and p_Holding!=p_Target
            </if>
            <if test="p_Name != '' and p_Name != null">
                and p.p_Name like '%${pName}%'
            </if>
            <if test="pNum != '' and pNum != null">
                and p.p_Num like '%${pNum}%'
            </if>
            <if test="holdingName != '' and holdingName != null">
                and u.userRealName like '%${holdingName}%'
            </if>
        </where>
        <if test="pageSize != null and pageSize != ''">
            order by p_Id desc limit #{startIndex},#{pageSize};
        </if>
    </select>

    <!--获取机型统计数-->
    <select id="getTypeCount" resultType="int">
        select count(p_Id) from phone
        <where>
            <if test="type1 != '' and type1 != null">
                and quarter(add_Time)=quarter(now())
            </if>
            <if test="type2 != '' and type2 != null">
                and p_Status!="库存"
            </if>
            <if test="type3 != '' and type3 != null">
                and p_Status="库存"
            </if>
        </where>
    </select>

    <update id="updatePhone" parameterType="com.hykb.manager.entity.Phone" flushCache="false">
        update phone
        <set>
            <if test="pName != '' and pName != null">
                p_Name=#{pName},
            </if>
            <if test="pNum != '' and pNum != null">
                p_Num=#{pNum},
            </if>
            <if test="pHolding != '' and pHolding != null">
                p_Holding=#{pHolding},
            </if>
            <if test="pRecord != '' and pRecord != null">
                p_Record = concat(p_Record,#{pRecord}),
            </if>
            <if test="pNote != '' and pNote != null">
                p_Note =#{pNote},
            </if>
            <if test="pStatus != '' and pStatus != null">
                p_Status =#{pStatus},
            </if>
            <if test="pTarget != '' and pTarget != null">
                p_Target =#{pTarget},
            </if>
            <if test="isGet== 'yes'">
                p_Holding =p_Target,
            </if>
            <if test="isGet== 'no'">
                p_Target = p_Holding,
            </if>
            p_Time = now()
        </set>
        where p_Id = #{pId}
    </update>

</mapper>

以上代码贴出机型管理核心代码,用户相关代码这边就不做帖了,可自写。

后续会上传所有代码,有需要的话,可直接下载整个项目代码,项目前端文案、数据库连接,微做修改之后,可直接部署。

各位看客姥爷要是觉得还行,麻烦点个赞。

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
随着计算机技术的迅猛发展以及Internet进入商业和社会应用阶段,设备的种类、数量越来越多,如何利用先进的网络技术和日新月异的计算机设备来有效地收集、处理这些设备,建立以信息化为核心的管理体制,减轻管理人员和业务人员的数据处理负担,极大地提高设备管理效率和管理手段,己经成为当今社会的潮流。在现代化大型研究所信息化管理体系建设中,设备管理系统被看作是重中之重。因为设备是工厂生产中的主体,随着科学技术的不断发展,生产设备日益机械化、自动化、大型化、高速化和复杂化,设备在现代工业生产中的作用和影响也随之增大,在整个工业生产过程中对设备的依赖程度也越来越高。设备管理的各项制度、流程涉及的点多面广。  本课程就是基于设备实现的后端管理系统,包含几大模块:设备管理、巡检管理、报修管理、采购管理、系统管理(用户管理、角色管理、菜单管理、日志管理、字典管理等)基于SpringBoot+Vue技术栈实现,包含了SpringBootMyBatis、MySQL、Spring Secutury、验证码技术、Vue技术等,课程会讲解整个部署过程,有需要的伙伴可以使用。 本课程不涉及细节讲解,主要是从项目环境搭建和代码启动和效果演示进行讲解,适合直接需要代码的学员。课程会讲解整个部署过程,有需要的伙伴可以直接使用或进行二次开发

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值