一、项目页面
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>
以上代码贴出机型管理核心代码,用户相关代码这边就不做帖了,可自写。
后续会上传所有代码,有需要的话,可直接下载整个项目代码,项目前端文案、数据库连接,微做修改之后,可直接部署。
各位看客姥爷要是觉得还行,麻烦点个赞。