基于javaweb+mysql的ssm实验室设备预约管理(java+ssm+jsp+javascript+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM实验室设备预约管理(java+ssm+jsp+javascript+mysql)
项目介绍
本项目为后台管理系统,分为管理员、老师、学生三种角色; 管理员角色包含以下功能: 信息管理:用户管理; 基础管理:实验室管理,实验室申请记录,设备管理,设备记录管理,耗材管理,耗材记录管理等功能。 统计管理:查询统计管理;
老师角色包含以下功能: 信息管理:个人信息修改; 基础管理:实验室管理、实验室申请管理、设备管理、设备记录管理,耗材管理,耗材记录管理等功能。
学生角色包含以下功能: 信息管理:个人信息修改;
基础管理:实验室管理、实验室申请管理、设备管理、设备记录管理,耗材管理,耗材记录管理等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/shiyanshi 登录
String jscode = "";
jscode+="<img style=\"cursor: hand\" οnclick=\"uploadimg()\" src=\"/pianotrainwebstie/js/nopic.jpg\" id=txt height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename\" id=\"filename\" value=\"\" />";
return jscode;
}
public static String getImgUpInfo2(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" οnclick=\"uploadimg2()\" src=\"/pianotrainwebstie/js/nopic.jpg\" id=txt2 height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename2\" id=\"filename2\" value=\"\" />";
return jscode;
}
public static String getImgUpInfo3(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" οnclick=\"uploadimg3()\" src=\"/pianotrainwebstie/js/nopic.jpg\" id=txt3 height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename3\" id=\"filename3\" value=\"\" />";
return jscode;
}
public static String getImgUpInfo4(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" οnclick=\"uploadimg4()\" src=\"/pianotrainwebstie/js/nopic.jpg\" id=txt4 height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename4\" id=\"filename4\" value=\"\" />";
return jscode;
}
public static String getImgUpInfo5(int height)
{
String jscode = "";
jscode+="<img style=\"cursor: hand\" οnclick=\"uploadimg5()\" src=\"/pianotrainwebstie/js/nopic.jpg\" id=txt5 height=\""+height+"\"/>";
jscode+="<input type=hidden name=\"filename5\" id=\"filename5\" value=\"\" />";
// 文件上传
public String fileUpload(@RequestParam(value="file",required=false)MultipartFile file,
HttpServletRequest request,String img){
String path=request.getSession().getServletContext().getRealPath("upload");
System.out.println("path==="+path);
System.out.println("file==="+file);
String fileName=file.getOriginalFilename();
System.out.println("fileName==="+fileName);
File targetFile=new File(path,fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
try {
file.transferTo(targetFile);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String pa=request.getContextPath()+"/upload/"+fileName;
System.out.println("path==="+pa);
if(fileName!=null&&!fileName.equals("")){
img=fileName;
}else{
img=null;
}
return img;
}
/*实验室*/
// 分页查询
@RequestMapping("admin/shiYanShiForderList.do")
public String shiYanShiList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session){
Sysuser u=(Sysuser)session.getAttribute("auser");
if(u==null){
return "admin/login";
}else{
if(page==null||page.equals("")){
page="1";
}
out.print(obj);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
out.close();
}
}
@RequestMapping("reg.do")
public String addReg(Sysuser user, HttpSession session) {
user.setIsdel("1");
user.setUtype("会员");
Timestamp time=new Timestamp(System.currentTimeMillis());
user.setPubtime(time.toString());
userService.add(user);
return "fore_login";
}
// 添加用户
@RequestMapping("admin/addUser.do")
public String addUser(Sysuser user, HttpSession session) {
user.setIsdel("1");
Timestamp time=new Timestamp(System.currentTimeMillis());
user.setPubtime(time.toString());
userService.add(user);
return "redirect:userList.do";
}
// 管理员注册
@RequestMapping("admin/addUser2.do")
public String addUser2(Sysuser user, HttpSession session) {
user.setIsdel("1");
Timestamp time=new Timestamp(System.currentTimeMillis());
user.setPubtime(time.toString());
userService.add(user);
return "admin/login";
}
// 处理更新用户的信息
@RequestMapping("admin/doUpdateUser.do")
public String doUpdateUser(ModelMap map, int id) {
System.out.println("id=="+id);
map.put("user",userService.getById(id));
return "admin/update_user";
}
// 更新用户的信息
@RequestMapping("admin/updateUser.do")
public String updateUser(Sysuser user) {
userService.update(user);
return "redirect:userList.do";
}
// 查询所有用户的信息
@RequestMapping("admin/userList.do")
if(fileName!=null&&!fileName.equals("")){
img=fileName;
}else{
img=null;
}
return img;
}
}
public class testFilter extends HttpServlet implements Filter {
private FilterConfig filterConfig;
// Handle the passed-in FilterConfig
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
}
// Process the request/response pair
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) {
/*try {
((HttpServletResponse) response).setHeader("Pragma", "No-cache");
((HttpServletResponse) response).setHeader("Cache-Control", "no-cache");
((HttpServletResponse) response).setHeader("Expires", "0");
//request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
filterChain.doFilter(request, response);
} catch (ServletException sx) {
filterConfig.getServletContext().log(sx.getMessage());
} catch (IOException iox) {
filterConfig.getServletContext().log(iox.getMessage());
}*/
/*HttpServletRequest req = null;
HttpSession session = req.getSession();
HashMap user = (HashMap)session.getAttribute("admin");
System.out.println("bbbbbbbbbbbbbbbbbbb--==="+user.get("uname"));*/
try {
//request.getRequestDispatcher("http://localhost:8080/xsgl").forward(request, response);
((HttpServletResponse)response).sendRedirect("http://localhost:808/tbm/index.jsp");
} catch (Exception e) {
// TODO Auto-generated catch block
String path=request.getSession().getServletContext().getRealPath("upload");
System.out.println("path==="+path);
System.out.println("file==="+file);
String fileName=file.getOriginalFilename();
System.out.println("fileName==="+fileName);
File targetFile=new File(path,fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
try {
file.transferTo(targetFile);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String pa=request.getContextPath()+"/upload/"+fileName;
System.out.println("path==="+pa);
if(fileName!=null&&!fileName.equals("")){
img=fileName;
}else{
img=null;
}
return img;
}
/*实验室*/
// 分页查询
@RequestMapping("admin/shiYanShiForderList.do")
public String shiYanShiList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session){
Sysuser u=(Sysuser)session.getAttribute("auser");
if(u==null){
return "admin/login";
}else{
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page), PageBean.PAGESIZE);
Map<String, Object> pmap=new HashMap<String,Object>();
Map<String, Object> cmap=new HashMap<String,Object>();
/*Map<String, Object> smap=new HashMap<String,Object>();*/
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", pageBean.getPageSize());
if(u.getUtype().equals("管理员")){
pmap.put("uid",null);
cmap.put("uid",null);
}else{
pmap.put("uid",u.getUid());
Map<String, Object> pmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", pageBean.getPageSize());
Map<String, Object> cmap=new HashMap<String,Object>();
if(cd.getName()!=null&&!cd.getName().equals("")){
cmap.put("name", cd.getName());
pmap.put("name", cd.getName());
}
cmap.put("ftype", "耗材");
pmap.put("ftype", "耗材");
int total=ShiYanService.getCount(cmap);
pageBean.setTotal(total);
List<ShiYan> list=ShiYanService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
session.setAttribute("p", 2);
return "admin/list_HaoCai";
}
@RequestMapping("admin/deleteHaoCai.do")
public String deleteHaoCai(int id){
ShiYanService.delete(id);
return "redirect:HaoCaiList.do";
}
}
yp.setUid(u.getUid());
yp.setStatus("待审核");
yp.setIsdel("1");
yp.setFid(id);
yp.setEtime("实验室");
yp.setPubtime(time.toString().substring(0, 19));
orderService.add(yp);
return "success";
}
}
/*设备管理*/
// 分页查询
@RequestMapping("admin/sheBeiForderList.do")
public String sheBeiForderList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session){
Sysuser u=(Sysuser)session.getAttribute("auser");
if(u==null){
return "admin/login";
}else{
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page), PageBean.PAGESIZE);
Map<String, Object> pmap=new HashMap<String,Object>();
Map<String, Object> cmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", pageBean.getPageSize());
if(u.getUtype().equals("管理员")){
pmap.put("uid",null);
cmap.put("uid",null);
}else{
pmap.put("uid",u.getUid());
cmap.put("uid",u.getUid());
}
pmap.put("etime","设备");
cmap.put("etime","设备");
int total=orderService.getCount(cmap);
pageBean.setTotal(total);
List<Forder> list=orderService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
map.put("ulist", userService.getAll(null));
map.put("slist", shiYanService.getAll(null));
session.setAttribute("p", 1);
return "admin/list_order_sheBei";
}
}
// 添加设备申请
shiYan.setPubtime(time.toString().substring(0, 19));
ShiYanService.add(shiYan);
return "redirect:HaoCaiList.do";
}
@RequestMapping("admin/doUpdateHaoCai.do")
public String doUpdateHaoCai(ModelMap map,int id){
map.put("sy", ShiYanService.getById(id));
return "admin/update_HaoCai";
}
@RequestMapping("admin/updateHaoCai.do")
public String updateHaoCai(HttpServletRequest request,ShiYan ShiYan){
ShiYanService.update(ShiYan);
return "redirect:HaoCaiList.do";
}
// 分页查询
@RequestMapping("admin/HaoCaiList.do")
public String haoCaiList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session){
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page), PageBean.PAGESIZE);
Map<String, Object> pmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", pageBean.getPageSize());
Map<String, Object> cmap=new HashMap<String, Object>();
pmap.put("ftype", null);
cmap.put("name", null);
cmap.put("ftype", "耗材");
pmap.put("ftype", "耗材");
int total=ShiYanService.getCount(cmap);
pageBean.setTotal(total);
List<ShiYan> list=ShiYanService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
session.setAttribute("p", 1);
return "admin/list_HaoCai";
}
// 分页模糊查询
@RequestMapping("admin/vagueHaoCaiList.do")
public String vagueHaoCaiList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session,ShiYan cd){
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page),PageBean.PAGESIZE);
Map<String, Object> pmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
e.printStackTrace();
}
String pa=request.getContextPath()+"/upload/"+fileName;
System.out.println("path==="+pa);
if(fileName!=null&&!fileName.equals("")){
img=fileName;
}else{
img=null;
}
return img;
}
}
public class testFilter extends HttpServlet implements Filter {
private FilterConfig filterConfig;
// Handle the passed-in FilterConfig
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
}
// Process the request/response pair
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) {
/*try {
((HttpServletResponse) response).setHeader("Pragma", "No-cache");
((HttpServletResponse) response).setHeader("Cache-Control", "no-cache");
((HttpServletResponse) response).setHeader("Expires", "0");
//request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
filterChain.doFilter(request, response);
} catch (ServletException sx) {
filterConfig.getServletContext().log(sx.getMessage());
} catch (IOException iox) {
filterConfig.getServletContext().log(iox.getMessage());
}*/
/*HttpServletRequest req = null;
radio+="<label><input type='radio' name='"+name+"' "+check+" value=\""+optionstr+"\">"+optionstr+"</label>\n";
dxii++;
}*/
return radio;
}
public static void writeExcel(String fileName,String prosstr,java.util.List<List> plist,HttpServletRequest request, HttpServletResponse response){
WritableWorkbook wwb = null;
String cols = "";
for(String str:prosstr.split("@"))
{
cols+=str.split("-")[0]+",";
}
cols = cols.substring(0,cols.length()-1);
String where = request.getAttribute("where")==null?"":request.getAttribute("where").toString();
/* List<List> mlist = new CommDAO().selectforlist("select "+cols+" from "+fileName+" "+where+" order by id desc");*/
fileName = request.getRealPath("/")+"/upfile/"+Info.generalFileName("a.xls");
String[] pros = prosstr.split("@");
try {
//首先要使用Workbook类的工厂方法创建一个可写入的工作薄(Workbook)对象
wwb = Workbook.createWorkbook(new File(fileName));
} catch (IOException e) {
e.printStackTrace();
}
if(wwb!=null){
//创建一个可写入的工作表
//Workbook的createSheet方法有两个参数,第一个是工作表的名称,第二个是工作表在工作薄中的位置
WritableSheet ws = wwb.createSheet("sheet1", 0);
ws.setColumnView(0,20);
ws.setColumnView(1,20);
ws.setColumnView(2,20);
ws.setColumnView(3,20);
ws.setColumnView(4,20);
ws.setColumnView(5,20);
try {
for(int i=0;i<pros.length;i++)
{
Label label1 = new Label(i, 0,"");
label1.setString(pros[i]);
ws.addCell(label1);
}
} catch (RowsExceededException e1) {
// TODO Auto-generated catch block
}
cmap.put("ftype", "耗材");
pmap.put("ftype", "耗材");
int total=ShiYanService.getCount(cmap);
pageBean.setTotal(total);
List<ShiYan> list=ShiYanService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
session.setAttribute("p", 2);
return "admin/list_HaoCai";
}
@RequestMapping("admin/deleteHaoCai.do")
public String deleteHaoCai(int id){
ShiYanService.delete(id);
return "redirect:HaoCaiList.do";
}
}
return sesuu.substring(0,10);
}
/**
* 计算两个时期之间的天数
*
*/
public static int dayToday(String DATE1, String DATE2) {
int i = 0;
if(DATE1.indexOf(" ")>-1)
DATE1 = DATE1.substring(0,DATE1.indexOf(" "));
if(DATE2.indexOf(" ")>-1)
DATE2 = DATE2.substring(0,DATE2.indexOf(" "));
String[] d1 = DATE1.split("-");
if(d1[1].length()==1)
{
DATE1 = d1[0]+"-0"+d1[1];
}else{
DATE1 = d1[0]+"-"+d1[1];
}
if(d1[2].length()==1)
{
DATE1 = DATE1+"-0"+d1[2];
}else{
DATE1 = DATE1+"-"+d1[2];
}
String[] d2 = DATE2.split("-");
if(d2[1].length()==1)
{
DATE2 = d2[0]+"-0"+d2[1];
}else{
DATE2 = d2[0]+"-"+d2[1];
}
if(d2[2].length()==1)
{
public String aLogin() {
return "admin/login";
}
// 处理修改个人信息
@RequestMapping("showInfo.do")
public String showInfo(HttpSession session,ModelMap map) {
Sysuser u=(Sysuser)session.getAttribute("user");
if(u==null){
return "fore_login";
}else{
map.put("user", userService.getById(u.getUid()));
return "showUserinfo";
}
}
// 处理修改个人信息
@RequestMapping("addShowInfo.do")
public String addShowInfo(HttpSession session,ModelMap map,Sysuser user) {
userService.update(user);
return "success";
}
// 文件上传
public String fileUpload(@RequestParam(value="file",required=false)MultipartFile file,
HttpServletRequest request,String img){
String path=request.getSession().getServletContext().getRealPath("upload");
System.out.println("path==="+path);
System.out.println("file==="+file);
String fileName=file.getOriginalFilename();
System.out.println("fileName==="+fileName);
File targetFile=new File(path,fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
try {
file.transferTo(targetFile);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String pa=request.getContextPath()+"/upload/"+fileName;
System.out.println("path==="+pa);
if(fileName!=null&&!fileName.equals("")){
img=fileName;
}else{
img=null;
}
return img;
}
}
@RequestMapping("checkmibao.do")
public void checkMB(Sysuser user,HttpServletResponse response,HttpSession session){
JSONObject obj=new JSONObject();
Sysuser u=userService.getById(user.getUid());
String q=u.getQuestion();
if(u==null||u.equals("")){
obj.put("info", "ng");
}else{
if(q.equals(user.getQuestion())){
obj.put("info", u.getPwd());
}else{
obj.put("info", "ng");
}
}
response.setContentType("text/html;charset=utf-8");
PrintWriter out=null;
try {
out=response.getWriter();
out.print(obj);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
out.close();
}
}
// 验证用户名是否存在
@RequestMapping("checkUname.do")
public void checkReg(Sysuser user,HttpServletResponse response){
Map map=new HashMap();
map.put("uname", user.getUname());
System.out.println("uname==="+user.getUname());
System.out.println("uname222==="+userService.checkUname(map));
JSONObject obj=new JSONObject();
if(userService.checkUname(map)!=null){
System.out.println("uname233333333333===");
obj.put("info", "ng");
return "redirect:showUserInfo.do";
}
@RequestMapping("admin/login.do")
public String aLogin() {
return "admin/login";
}
// 处理修改个人信息
@RequestMapping("showInfo.do")
public String showInfo(HttpSession session,ModelMap map) {
Sysuser u=(Sysuser)session.getAttribute("user");
if(u==null){
return "fore_login";
}else{
map.put("user", userService.getById(u.getUid()));
return "showUserinfo";
}
}
// 处理修改个人信息
@RequestMapping("addShowInfo.do")
public String addShowInfo(HttpSession session,ModelMap map,Sysuser user) {
userService.update(user);
return "success";
}
// 文件上传
public String fileUpload(@RequestParam(value="file",required=false)MultipartFile file,
HttpServletRequest request,String img){
String path=request.getSession().getServletContext().getRealPath("upload");
System.out.println("path==="+path);
System.out.println("file==="+file);
String fileName=file.getOriginalFilename();
System.out.println("fileName==="+fileName);
File targetFile=new File(path,fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
try {
file.transferTo(targetFile);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String pa=request.getContextPath()+"/upload/"+fileName;
System.out.println("path==="+pa);
pmap.put("pageSize", pageBean.getPageSize());
pmap.put("uname", user.getUname());
Map cmap=new HashMap();
/* pmap.put("utype", "会员");
cmap.put("utype", "会员");*/
int total = userService.getCount(pmap);
pageBean.setTotal(total);
List<Sysuser> list = userService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
session.setAttribute("p", 2);
return "admin/user_list";
}
@RequestMapping("admin/deleteUser.do")
public String deleteUser(int id){
userService.delete(id);
return "redirect:userList.do";
}
}
}else{
Forder f=orderService.getById(id);
ShiYan syy=shiYanService.getById(f.getFid());
syy.setSnum(syy.getSnum()-f.getSnum());
shiYanService.update(syy);
f.setStatus("审核成功");
f.setKid(id);
orderService.update(f);
return "success";
}
}
/*耗材*/
// 分页查询
@RequestMapping("admin/haoCaiForderList.do")
public String haoCaiForderList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session){
Sysuser u=(Sysuser)session.getAttribute("auser");
if(u==null){
return "admin/login";
}else{
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page), PageBean.PAGESIZE);
Map<String, Object> pmap=new HashMap<String,Object>();
Map<String, Object> cmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", pageBean.getPageSize());
if(u.getUtype().equals("管理员")){
pmap.put("uid",null);
cmap.put("uid",null);
}else{
pmap.put("uid",u.getUid());
cmap.put("uid",u.getUid());
}
pmap.put("etime","耗材");
cmap.put("etime","耗材");
int total=orderService.getCount(cmap);
pageBean.setTotal(total);
List<Forder> list=orderService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
map.put("ulist", userService.getAll(null));
map.put("slist", shiYanService.getAll(null));
session.setAttribute("p", 1);
return "admin/list_order_haoCai";
}
}