一、项目简介

为了加强影院放映及售票管理,降低运营成本,有序安排电影放映,通过影院管理系统的开发,将现有的人工管理排场及售票放映等模式改为系统自动化操作及售票模式,特开发此套系统 国内电影院的售票系统不完善,有很多问题存在,售票效率低下,管理混乱。现今社会是个讲究效率的社会,时间就是金钱。开发简单,便于操作的的软件不仅可以节省时间,还可以节省人力,物理,财力等。建立的影院售票系统,要把影院的售票管理、订票管理,财务管理等日常管理工作实行计算机统一管理,以提高工作效率和管理水平。 通过本系统软件,能帮助售票人员利用计算机,快速方便地对影院售票情况,订票情况,等进行高效的管理。

二、关键技术 

  1. 开发环境:eclipse
  2. 数据库:Navicat Premium
  3. 框架:Spring  + Mybatis +SpringMVC 

三、具备功能

1.用户:可以查看个人信息和电影信息,可以购买电影票

     用户需输入密码和账号才可登录,登录成功后可选择“查看电影”和“查看个人信息”。

     查看电影:里面有影院相关的电影信息(电影名,放映时间,票价)

     查看个人信息:里面有用户的购买信息(用户名,购买的电影,座位号,放映时间)

     用户如没有账号,可以注册账号,注册页面有姓名,电话,密码

2.管理员:可以查看用户信息(可删除用户购票信息)和查看电影信息(可增加电影信息)

     管理员需输入账号和密码可登录,登录成功后可选择查看“顾客信息”和添加“电影信息”

     顾客信息:里面有顾客名及购买电影票信息,也可以删除顾客信息

     电影信息:管理员可以查看影院和电影信息也可增加电影信息

四、实现效果 

java电源管理 电影院管理系统_java-ee

 五、数据库

java电源管理 电影院管理系统_System_02

 六、相关代码

 1.controller

package controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import entity.Movie;
import entity.Movies;
import entity.Ticket;
import entity.User;
import service.UserService;
@Controller
public class UserController {
	@Resource
	private UserService userService;
	/*用户登录*/
	
	@RequestMapping("/login1")
	public String login1(String usercode,String userpassword,Model model,HttpSession session){
		//通过账号和密码查询用户
		User user=userService.findUser(usercode, userpassword);
		if(user!=null){
			//将用户添加到Session
			session.setAttribute("USER_SESSION", user);
			//跳转页面
			return "user/get1";
		}
		
		return "user/login1";
	}
	@RequestMapping("/showMoviesList")
	public String showMoviesList(Model model)
	{
		System.out.println("Controller");
		//List<Goods> goodsList=goodsService.getGoodsListForMapper();
		List<Map<String,Object>> moviesList=userService.showMoviesList();
		model.addAttribute("moviesList", moviesList);
		System.out.println("moviesList="+moviesList);
		return "user/moviesList";
	}
	@RequestMapping("/getTicketList")
	public String getTicketList(Model model,HttpSession session)
	{
		System.out.println("Controller");
		User au=(User)session.getAttribute("USER_SESSION");
		//List<Goods> goodsList=goodsService.getGoodsListForMapper();
		List<Map<String,Object>> ticketList=userService.getTicketList(au.getUsercode());
		model.addAttribute("ticketList", ticketList);
		System.out.println("ticketList="+ticketList);
		
		return "user/ticketList";
	}
	
	//注册
	@RequestMapping("/registerUser")
	public String registerUser()
	{
		System.out.println("in register");
		return "user/registerUser";
	}
	@RequestMapping("/insertUser")
	public String registerUser(User user,Model model)
	{
		System.out.println("in registerUser");
		boolean result=userService.registerUser(user);
		System.out.println("resu="+result);
		if(result)
			return "user/login1";
		else
		{
			model.addAttribute("msg","用户名重复!");
			return "user/registerUser";
		}
	}
	//返回
		@RequestMapping("/getLogin1")
		public String getLogin1(Model model)
		{
			
			return "user/login1";
		}
		//更新
		@RequestMapping("/updateTicket")
		public String updateTicket(int id,Model model)
		{
			System.out.println("id="+id);
			model.addAttribute("id",id);
			return "user/updateTicket";
		}
		@RequestMapping("/saveTicket")
		public String saveTicket(Ticket ticket)
		{
			System.out.println("in saveTicket"+ticket.getId());
			userService.updateTicket(ticket);
			return "redirect:getTicketList";
		}
		//添加
		@RequestMapping("/addTicket")
		public String addTicket()
		{
			System.out.println("in addMovies");
			return "user/addTicket";
		}
		
		@RequestMapping("/insertTicket")
		public String insertTicket(Ticket ticket,Model model)
		{
			System.out.println("in insertTicket");
			boolean result=userService.addTicket(ticket);
			System.out.println("resu="+result);
			if(result)
				return "redirect:getTicketList";
			else
			{
				model.addAttribute("msg","电影名重复!");
				return "user/addTicket";
			}
		}
		//删除
		 @RequestMapping("/deleteTicket")
		    public String deleteTicket(Ticket ticket)
		    {
			 System.out.println("in deleteTicket"+ticket.getId());
				userService.deleteTicket(ticket);
				return "redirect:getTicketList";

		    }		
     //评论
		 @RequestMapping("/checkMovie")
	        public String checkMovie()//页面跳转
	        {
	          System.out.println("in checkMovie");
	          return "user/checkMovie";
	        }
		
		
}

2.service

package service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import dao.MovieMapper;
import dao.TicketMapper;
import dao.UserDao;
import entity.Movie;
import entity.Movies;
import entity.Ticket;
import entity.User;
@Service
public class UserService {
	@Resource
	private UserDao userDao;
	public User findUser(String usercode,String userpassword){
		User user=this.userDao.findUser(usercode, userpassword);
		return user;
	}
	@Resource
	private TicketMapper ticketMapper;
	public List<Map<String,Object>> showMoviesList()
	{
		List moviesList=ticketMapper.showMoviesList();
		return moviesList;

	}
	public List<Map<String,Object>> getTicketList(String usercode)
	{
		List ticketList=ticketMapper.getTicketList(usercode);
		return ticketList;

	}
	
	//注册
	public boolean registerUser(User user) {
		User aUser=ticketMapper.getUserByUsername(user.getUsername());
		if(aUser==null)
		{	
			int i=ticketMapper.registerUser(user);
			if(i==1)
				return true;
			else
				return false;
		}else
		{
			return false;
		}
		
	}
	//更新
		public void updateTicket(Ticket ticket) {
			int rs=ticketMapper.updateTicket(ticket);
			System.out.println("rs="+rs);
		}
		 //添加
	  	public boolean addTicket(Ticket ticket) {
	  		Ticket aTicket=ticketMapper.getTicketByName(ticket.getName());
	  		if(aTicket==null)
	  		{	
	  			int i=ticketMapper.addTicket(ticket);
	  			if(i==1)
	  				return true;
	  			else
	  				return false;
	  		}else
	  		{
	  			return false;
	  		}
	  		
	  	}
	  //删除
		 
	      public void deleteTicket(Ticket ticket) {
	    	  int rr=ticketMapper.deleteTicket(ticket);
	  		System.out.println("rr="+rr);
		    }
  	}

3.Dao

package dao;

import org.apache.ibatis.annotations.Param;

import entity.User;

public interface UserDao {
/*通过账号和密码查询用户*/
	public User findUser(@Param("usercode") String usercode,
			@Param("userpassword") String userpassword);
	
	 

	
}

4.Interceptor

package interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import entity.Customer;
import entity.User;

public class UserInterceptor implements HandlerInterceptor{
	@Override
	public boolean preHandle(HttpServletRequest request, 
		HttpServletResponse response, Object handler) throws Exception {
	    // 获取请求的URL  
        String url = request.getRequestURI();  
        // URL:除了login.jsp是可以公开访问的,其它的URL都进行拦截控制  
        if(url.indexOf("/login1")>=0||url.indexOf("/login2")>=0){  
            return true;  
        }  
        // 获取Session  
        HttpSession session = request.getSession();  
        User user = (User) session.getAttribute("USER_SESSION");
        Customer customer=(Customer) session.getAttribute("CUSTOMER_SESSION");
        // 判断Session中是否有用户数据,如果有,则返回true,继续向下执行
        if(user != null||customer !=null){
            return true;  
        }
         // 不符合条件的给出提示信息,并转发到登录页面
         request.setAttribute("msg", "您还没有登录,请先登录!");
         request.getRequestDispatcher("/WEB-INF/views/user/login1.jsp")
                                                .forward(request, response);
		return false;
	}
	
	@Override
	public void postHandle(HttpServletRequest request, 
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		System.out.println("postHandle");
	}
	@Override
	public void afterCompletion(HttpServletRequest request, 
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		System.out.println("afterHandle");
	}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<style>
       
         body{
            
            background: #FAEBD7;
            text-align: center;
        }
        table{
            
            display: flex;
            justify-content: center;
            text-align: center;
        }
        
    </style>
<script type="text/javascript">
	function register()
	{
		window.location.href="registerUser";
	}
</script>
</head>
<body>
    用户登录
 ${msg}
   <form action="login1" method="post">
		<table>
		
			<tr>
				<td>用户名</td>
				<td><input name="usercode" type="text" ></td>
			</tr>
			<tr>
				<td>密码</td>
				<td><input name="userpassword" type="text" ></td>
			</tr>
			
		</table>
		<input type="submit" value="登录" >
		<tr>
			<td><input type="button" value="注册 " onclick="register()"></td>
		</tr>
	</form>

</body>
</html>