Java:jdk1.8
Mysql:8.0.11
Tomcat:8.0.28
机票查询
1.航行类型
2.出发城市
3.到达城市
4.出发日期
5.返回日期
选择航班
1.航班信息
2.起飞时间
3.到达时间
4.机票价格
填写乘客信息
1.姓名
2.护照
3.座位偏好
4.添加乘客
5.联系人
6.订单信息确认
7.提交订单
订单详情页
1.订单详细信息
2.航班详细信息
3.乘机人详细信息
4.联系人详细信息
/* create database */
drop database if exists AIRLINE_1;
drop database if exists AIRLINE_2;
drop database if exists AIRLINE_3;
drop database if exists ABS;
create database AIRLINE_1;
create database AIRLINE_2;
create database AIRLINE_3;
create database ABS;
/* create table of database Airline*/
use AIRLINE_1;
create table airline(
code varchar(3) not null primary key,
name varchar(20) not null,
discount float(2,2) not null
);
create table airport(
code varchar(4) not null primary key,
name varchar(20) not null,
city varchar(20) not null,
country varchar(20) not null,
connTime int(3) not null /* minute */
);
create table airplane(
name varchar(20) not null primary key,
type varchar(10) not null
);
create table seat(
id int(3) not null primary key auto_increment,
relativeID int(3) not null, /* 飞机上作为的相对编号 */
row int(3) not null,
num int(3) not null,
type varchar(12) not null, /* windowSeat middleSeat aisleSeat*/
flightID int(10) not null, /* Table:airplane Item:id */
passport varchar(20) /* passenger passport */
);
create table flight(
id int(10) not null primary key,
airlineCode varchar(3) not null,
number int(6) not null,
depatureDate Date not null,
depatureTime time not null,
arrivalDate Date not null,
arrivalTime time not null,
fare float(6,2) not null,
depatureAirport varchar(4) not null, /* Table:airport Item:code */
arrivalAirport varchar(4) not null, /* Table:airport Item:code */
airplaneName varchar(20) not null, /* Table:airplane Item:name */
airplaneType varchar(10) not null /* Table:airplane Item:type */
);
use AIRLINE_2;
create table airline(
code varchar(3) not null primary key,
name varchar(20) not null,
discount float(2,2) not null
);
create table airport(
code varchar(4) not null primary key,
name varchar(20) not null,
city varchar(20) not null,
country varchar(20) not null,
connTime int(3) not null /* minute */
);
create table airplane(
name varchar(20) not null primary key,
type varchar(10) not null
);
create table seat(
id int(3) not null primary key auto_increment,
relativeID int(3) not null, /* 飞机上作为的相对编号 */
row int(3) not null,
num int(3) not null,
type varchar(12) not null, /* windowSeat middleSeat aisleSeat*/
flightID int(10) not null, /* Table:airplane Item:id */
passport varchar(20) /* passenger passport */
);
create table flight(
id int(10) not null primary key,
airlineCode varchar(3) not null,
number int(6) not null,
depatureDate Date not null,
depatureTime time not null,
arrivalDate Date not null,
arrivalTime time not null,
fare float(6,2) not null,
depatureAirport varchar(4) not null, /* Table:airport Item:code */
arrivalAirport varchar(4) not null, /* Table:airport Item:code */
airplaneName varchar(20) not null, /* Table:airplane Item:name */
airplaneType varchar(10) not null /* Table:airplane Item:type */
);
use AIRLINE_3;
create table airline(
code varchar(3) not null primary key,
name varchar(20) not null,
discount float(2,2) not null
);
create table airport(
code varchar(4) not null primary key,
name varchar(20) not null,
city varchar(20) not null,
country varchar(20) not null,
connTime int(3) not null /* minute */
);
create table airplane(
name varchar(20) not null primary key,
type varchar(10) not null
);
create table seat(
id int(3) not null primary key auto_increment,
relativeID int(3) not null, /* 飞机上作为的相对编号 */
row int(3) not null,
num int(3) not null,
type varchar(12) not null, /* windowSeat middleSeat aisleSeat*/
flightID int(10) not null, /* Table:airplane Item:id */
passport varchar(20) /* passenger passport */
);
create table flight(
id int(10) not null primary key,
airlineCode varchar(3) not null,
number int(6) not null,
depatureDate Date not null,
depatureTime time not null,
arrivalDate Date not null,
arrivalTime time not null,
fare float(6,2) not null,
depatureAirport varchar(4) not null, /* Table:airport Item:code */
arrivalAirport varchar(4) not null, /* Table:airport Item:code */
airplaneName varchar(20) not null, /* Table:airplane Item:name */
airplaneType varchar(10) not null /* Table:airplane Item:type */
);
/* create table of database ABS*/
use ABS;
create table airline(
code varchar(3) not null primary key,
name varchar(20) not null,
discount float(2,2) not null
);
create table flightInfo(
id int(10) not null primary key auto_increment,
airlineCode varchar(3) not null, /* Table:airline Item:code */
flightID int(10) not null, /* Database:Airline Table:flight Item: */
number int(6) not null, /* Database:Airline Table:flight Item:number */
depatureDate Date not null, /* Database:Airline Table:flight Item:depatureDate */
depatureTime time not null, /* Database:Airline Table:flight Item:depatureTime */
arrivalDate Date not null, /* Database:Airline Table:flight Item:arrivalDate */
arrivalTime time not null, /* Database:Airline Table:flight Item:arrivalTime */
fare float(6,2) not null, /* Database:Airline Table:flight Item:fare */
depatureAirport varchar(4) not null, /* Database:Airline Table:flight Item:depatureAirport */
arrivalAirport varchar(4) not null, /* Database:Airline Table:flight Item:arrivalAirport */
airlineName varchar(20) not null, /* Table:airline Item:name */
airplaneName varchar(20) not null, /* Database:Airline Table:airplane Item:name */
airplaneType varchar(10) not null, /* 大:240 中:160 小:80 */
depatureAirportName varchar(20) not null,
arrivalAirportName varchar(20) not null,
depatureAirportCity varchar(20) not null,
arrivalAirportCity varchar(20) not null,
airplaneEmptySeats int(3) not null /* Database:Airline Table:airplane Item:conunt of empty seats */
);
create table airport(
code varchar(4) not null primary key,
name varchar(20) not null,
city varchar(20) not null,
country varchar(20) not null,
connTime int(3) not null /* minute */
);
create table passenger(
passport varchar(20) not null, /* no primary key for test */
name varchar(20) not null
);
create table trip(
id int(10) not null primary key,
flightInfoID int(10) not null, /* Database:Airline Table:flight Item: */
fare float(6,2) not null, /* fare不同于 flightInfo中的 fare */
passport varchar(20) not null, /* Table:passenger Item:passport */
seatID int(3) not null /* Database:Airline Table:seat Item:relativeID */
);
create table orders(
id int(10) not null, /* id 相同的为同一个订单 */
tripID int(10) not null, /* Table:tirp Item:id */
createDate date not null,
createTime time not null,
totalFare float(6,2) not null,
contactName varchar(20) not null,
contactPhone varchar(20) not null
);
package com.abs.action;
import java.sql.Date;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.*;
import com.abs.db.DBName;
import com.abs.factory.DaoFactory;
import com.abs.model.*;
public class SearchAction {
public static List<FlightInfo> searchFlightDirectly(String departureCity, String arrivalCity, String departureDateString) throws Exception {
List<FlightInfo> list = null;
Date departureDate = null;
if (checkDate(departureDateString)) {
// 测试Date格式是否合格
departureDate = Date.valueOf(departureDateString);
}
list = DaoFactory.getFlightInfoDaoInstance(DBName.ABS).findByAirport(departureCity, arrivalCity, departureDate);
return list;
}
public static List<List<FlightInfo>> searchFlightTransfer(String departureCity, String arrivalCity, String departureDateString) throws Exception {
List<List<FlightInfo>> list = new ArrayList<List<FlightInfo>>();
Date departureDate = null;
if (checkDate(departureDateString)) {
// 测试Date格式是否合格
departureDate = Date.valueOf(departureDateString);
}
List<FlightInfo> departureList = DaoFactory.getFlightInfoDaoInstance(DBName.ABS).findByDepatureAirport(departureCity, departureDate);
for (FlightInfo depatureFlight : departureList) {
Airport transferAirport = DaoFactory.getAirportDaoInstance(DBName.ABS).findByCode(depatureFlight.getArrivalAirport());
if(null != transferAirport){
int connTime = transferAirport.getConnTime();
Time depatureTime = new Time(depatureFlight.getArrivalTime().getTime() + connTime * 60 * 1000);
String transferCity = depatureFlight.getArrivalAirportCity();
List<FlightInfo> arrivalList = DaoFactory.getFlightInfoDaoInstance(DBName.ABS).findByTransferArrivalAirport(transferCity, arrivalCity, departureDate, depatureTime);
for (FlightInfo arrivalFlight : arrivalList) {
List<FlightInfo> item = new ArrayList<FlightInfo>();
if(depatureFlight.getAirlineCode().equals(arrivalFlight.getAirlineCode())){
double discount = DaoFactory.getAirlineDaoInstance(DBName.ABS).findByCode(depatureFlight.getAirlineCode()).getDiscount();
arrivalFlight.setFare(arrivalFlight.getFare() * discount);
}
item.add(depatureFlight);
item.add(arrivalFlight);
list.add(item);
}
}else {
System.err.println(depatureFlight.getArrivalAirportCity() + depatureFlight.getArrivalAirport() + ":没有找到机场信息");
}
}
return list;
}
public static boolean checkDate(String date) {
String regex= "^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))";
return Pattern.compile(regex).matcher(date).matches();
}
}
package com.abs.action;
import java.sql.Date;
import java.sql.Time;
import java.util.List;
import com.abs.db.DBName;
import com.abs.factory.DaoFactory;
import com.abs.model.Flight;
import com.abs.model.FlightInfo;
import com.abs.model.Orders;
import com.abs.model.Passenger;
import com.abs.model.Seat;
import com.abs.model.Trip;
public class OrderAction {
public static Orders createOrder(List<FlightInfo> flightInfos, List<Passenger> passengers, String[] seatTypeList, String contactName, String contactPhone) throws Exception {
// 生成订单编号
Orders.addIdCounter();
Orders order = null;
double total = 0;
for (FlightInfo flightInfo : flightInfos) {
total += flightInfo.getFare();
}
total = total * passengers.size(); // 计算总费用
for (Passenger passenger : passengers) {
DaoFactory.getPassengerDaoInstance(DBName.ABS).add(passenger);
}
for (FlightInfo flightInfo : flightInfos) {
for (Passenger passenger : passengers) {
Trip trip = new Trip();
trip.setId(Trip.getIdCounter());
trip.setFlightInfoID(flightInfo.getId());
trip.setFare(flightInfo.getFare());
trip.setPassport(passenger.getPassport());
trip.setSeatID(OrderAction.orderSeat(flightInfo, passenger, seatTypeList[passengers.indexOf(passenger)])); // 分配座位
flightInfo.setAirplaneEmptySeats(flightInfo.getAirplaneEmptySeats() - 1); // 空闲座位数 - 1
DaoFactory.getFlightInfoDaoInstance(DBName.ABS).addPassenger(flightInfo.getId()); // 空闲座位数 - 1
DaoFactory.getTripDaoInstance(DBName.ABS).add(trip);
Orders orders = new Orders();
orders.setId(Orders.getIdCounter()); // 同一个订单号,代表为同一个订单
orders.setTripID(trip.getId()); // 每个Orders item 与一个 Trip 一一对应
java.util.Date date = new java.util.Date();
orders.setCreateDate(new Date(date.getTime()));
orders.setCreateTime(new Time(date.getTime()));
orders.setTotalFare(total);
orders.setContactName(contactName);
orders.setContactPhone(contactPhone);
DaoFactory.getOrdersDaoInstance(DBName.ABS).add(orders);
order = orders; // 返回一个 Orders item用于显示
}
}
return order;
}
public static int orderSeat(FlightInfo flightInfo, Passenger passenger, String seatType) throws Exception {
int seatID = -1;
String airlineCode = flightInfo.getAirlineCode();
Flight flight = null;
// airline_1 MU(东方航空), airline_2 CZ(南方航空), airline_3 CA(中国国航)
if(airlineCode.equals("MU")){
// airline_1 MU(东方航空)
flight = DaoFactory.getFlightDaoInstance(DBName.AIRLINE_1).findByID(flightInfo.getFlightID());
List<Seat> emptySeats = DaoFactory.getSeatDaoInstance(DBName.AIRLINE_1).findEmptySeatByFlightID(flight.getId());
if (emptySeats.size() > 0) {
Seat seat = null;
for (Seat emptySeat : emptySeats) {
if(emptySeat.getType() == seatType){
seat = emptySeat;
break;
}
}
if(seat == null){
seat = emptySeats.get(0);
}
seat.setPassport(passenger.getPassport());
DaoFactory.getSeatDaoInstance(DBName.AIRLINE_1).modify(seat);
seatID = seat.getRelativeID();
}
}else if (airlineCode.equals("CZ")) {
// airline_2 CZ(南方航空)
flight = DaoFactory.getFlightDaoInstance(DBName.AIRLINE_2).findByID(flightInfo.getFlightID());
List<Seat> emptySeats = DaoFactory.getSeatDaoInstance(DBName.AIRLINE_2).findEmptySeatByFlightID(flight.getId());
if (emptySeats.size() > 0) {
Seat seat = null;
for (Seat emptySeat : emptySeats) {
if(emptySeat.getType() == seatType){
seat = emptySeat;
}
}
if(seat == null){
seat = emptySeats.get(0);
}
seat.setPassport(passenger.getPassport());
DaoFactory.getSeatDaoInstance(DBName.AIRLINE_2).modify(seat);
seatID = seat.getRelativeID();
}
}else {
// airline_3 CA(中国国航)
flight = DaoFactory.getFlightDaoInstance(DBName.AIRLINE_3).findByID(flightInfo.getFlightID());
List<Seat> emptySeats = DaoFactory.getSeatDaoInstance(DBName.AIRLINE_3).findEmptySeatByFlightID(flight.getId());
if (emptySeats.size() > 0) {
Seat seat = null;
for (Seat emptySeat : emptySeats) {
if(emptySeat.getType() == seatType){
seat = emptySeat;
}
}
if(seat == null){
seat = emptySeats.get(0);
}
seat.setPassport(passenger.getPassport());
DaoFactory.getSeatDaoInstance(DBName.AIRLINE_3).modify(seat);
seatID = seat.getRelativeID();
}
}
return seatID;
}
}
package com.abs.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import com.abs.dao.AirlineDao;
import com.abs.db.DBConnection;
import com.abs.db.DBName;
import com.abs.model.Airline;
public class AirlineDaoImpl implements AirlineDao {
private Connection conn = null;
private PreparedStatement pstmt = null;
public AirlineDaoImpl(Connection conn) {
// TODO Auto-generated constructor stub
this.conn = conn;
}
@Override
public boolean add(Airline airline) throws Exception {
// TODO Auto-generated method stub
String sql = "insert into airline(code, name, discount) values(?,?,?)";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setString(1, airline.getCode());
this.pstmt.setString(2, airline.getName());
this.pstmt.setDouble(3, airline.getDiscount());
int update = this.pstmt.executeUpdate();
this.pstmt.close();
if(update > 0){
return true;
}else{
return false;
}
}
@Override
public Airline findByCode(String code) throws Exception {
// TODO Auto-generated method stub
String sql = "select * from airline where code=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setString(1, code);
ResultSet resultSet = this.pstmt.executeQuery();
Airline airline = null;
if(resultSet.next()){
airline = new Airline();
airline.setCode(resultSet.getString(1));
airline.setName(resultSet.getString(2));
airline.setDiscount(resultSet.getDouble(3));
}
this.pstmt.close();
return airline;
}
@Override
public List<Airline> findAll() throws Exception {
// TODO Auto-generated method stub
String sql = "select * from airline";
this.pstmt = this.conn.prepareStatement(sql);
ResultSet resultSet = this.pstmt.executeQuery();
List<Airline> list = new ArrayList<>();
Airline airline = null;
while(resultSet.next()){
airline = new Airline();
airline.setCode(resultSet.getString(1));
airline.setName(resultSet.getString(2));
airline.setDiscount(resultSet.getDouble(3));
list.add(airline);
}
this.pstmt.close();
return list;
}
public static void main(String args[]) throws Exception {
Airline airline = new Airline();
airline.setCode("MU");
airline.setName("东方航空");
airline.setDiscount(0.9);
new AirlineDaoImpl(new DBConnection().getConnection(DBName.AIRLINE_1)).add(airline);
}
}
package com.abs.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.sql.*;
import java.util.List;
import com.abs.dao.FlightDao;
import com.abs.db.DBName;
import com.abs.factory.DaoFactory;
import com.abs.model.Flight;
public class FlightDaoImpl implements FlightDao {
private Connection conn = null;
private PreparedStatement pstmt = null;
public FlightDaoImpl(Connection conn) {
// TODO Auto-generated constructor stub
this.conn = conn;
}
@Override
public boolean add(Flight flight) throws Exception {
// TODO Auto-generated method stub
String sql = "insert into flight(id, airlineCode, number, depatureDate, depatureTime, arrivalDate, arrivalTime, fare, "
+ "depatureAirport, arrivalAirport, airplaneName, airplaneType) values(?,?,?,?,?,?,?,?,?,?,?,?)";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setInt(1, flight.getId());
this.pstmt.setString(2, flight.getAirlineCode());
this.pstmt.setInt(3, flight.getNumber());
this.pstmt.setDate(4, flight.getDepatureDate());
this.pstmt.setTime(5, flight.getDepatureTime());
this.pstmt.setDate(6, flight.getArrivalDate());
this.pstmt.setTime(7, flight.getArrivalTime());
this.pstmt.setDouble(8, flight.getFare());
this.pstmt.setString(9, flight.getDepatureAirport());
this.pstmt.setString(10, flight.getArrivalAirport());
this.pstmt.setString(11, flight.getAirplaneName());
this.pstmt.setString(12, flight.getAirplaneType());
int update = this.pstmt.executeUpdate();
this.pstmt.close();
if(update > 0){
return true;
}else {
return false;
}
}
@Override
public Flight findByID(int id) throws Exception {
// TODO Auto-generated method stub
String sql = "select * from flight where id=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setInt(1, id);
ResultSet resultSet = this.pstmt.executeQuery();
Flight flight = null;
if(resultSet.next()){
flight = new Flight();
flight.setId(resultSet.getInt(1));
flight.setAirlineCode(resultSet.getString(2));
flight.setNumber(resultSet.getInt(3));
flight.setDepatureDate(resultSet.getDate(4));
flight.setDepatureTime(resultSet.getTime(5));
flight.setArrivalDate(resultSet.getDate(6));
flight.setArrivalTime(resultSet.getTime(7));
flight.setFare(resultSet.getDouble(8));
flight.setDepatureAirport(resultSet.getString(9));
flight.setArrivalAirport(resultSet.getString(10));
flight.setAirplaneName(resultSet.getString(11));
flight.setAirplaneType(resultSet.getString(12));
}
this.pstmt.close();
return flight;
}
@Override
public List<Flight> findAll() throws Exception {
// TODO Auto-generated method stub
String sql = "select * from flight";
this.pstmt = this.conn.prepareStatement(sql);
ResultSet resultSet = this.pstmt.executeQuery();
List<Flight> list = new ArrayList<>();
Flight flight = null;
while(resultSet.next()){
flight = new Flight();
flight.setId(resultSet.getInt(1));
flight.setAirlineCode(resultSet.getString(2));
flight.setNumber(resultSet.getInt(3));
flight.setDepatureDate(resultSet.getDate(4));
flight.setDepatureTime(resultSet.getTime(5));
flight.setArrivalDate(resultSet.getDate(6));
flight.setArrivalTime(resultSet.getTime(7));
flight.setFare(resultSet.getDouble(8));
flight.setDepatureAirport(resultSet.getString(9));
flight.setArrivalAirport(resultSet.getString(10));
flight.setAirplaneName(resultSet.getString(11));
flight.setAirplaneType(resultSet.getString(12));
}
this.pstmt.close();
return list;
}
public static void main(String agrs[]) throws Exception {
Flight flight = new Flight();
flight.setNumber(123);
flight.setDepatureDate(new Date(new java.util.Date().getTime()));
flight.setDepatureTime(new Time(new java.util.Date().getTime()));
flight.setArrivalDate(new Date(new java.util.Date().getTime()));
flight.setArrivalTime(new Time(new java.util.Date().getTime()));
flight.setFare(599.0);
flight.setDepatureAirport("ecb");
flight.setArrivalAirport("abc");
flight.setAirplaneName("空客A320");
flight.setAirplaneType("中");
DaoFactory.getFlightDaoInstance(DBName.AIRLINE_1).add(flight);
}
}
package com.abs.dao.impl;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import com.abs.dao.FlightInfoDao;
import com.abs.db.DBName;
import com.abs.factory.DaoFactory;
import com.abs.model.FlightInfo;
public class FlightInfoDaoImpl implements FlightInfoDao {
private Connection conn = null;
private PreparedStatement pstmt = null;
public FlightInfoDaoImpl(Connection conn) {
// TODO Auto-generated constructor stub
this.conn = conn;
}
@Override
public boolean add(FlightInfo flightInfo) throws Exception {
// TODO Auto-generated method stub
String sql = "insert into flightInfo(airlineCode, flightID, number, "
+ "depatureDate, depatureTime, arrivalDate, arrivalTime,"
+ "fare, depatureAirport, arrivalAirport, airlineName, airplaneName,"
+ "airplaneType, depatureAirportName, arrivalAirportName, depatureAirportCity, arrivalAirportCity, airplaneEmptySeats) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setString(1, flightInfo.getAirlineCode());
this.pstmt.setInt(2, flightInfo.getFlightID());
this.pstmt.setInt(3, flightInfo.getNumber());
this.pstmt.setDate(4, flightInfo.getDepatureDate());
this.pstmt.setTime(5, flightInfo.getDepatureTime());
this.pstmt.setDate(6, flightInfo.getArrivalDate());
this.pstmt.setTime(7, flightInfo.getArrivalTime());
this.pstmt.setDouble(8, flightInfo.getFare());
this.pstmt.setString(9, flightInfo.getDepatureAirport());
this.pstmt.setString(10, flightInfo.getArrivalAirport());
this.pstmt.setString(11, flightInfo.getAirlineName());
this.pstmt.setString(12, flightInfo.getAirplaneName());
this.pstmt.setString(13, flightInfo.getAirplaneType());
this.pstmt.setString(14, flightInfo.getDepatureAirportName());
this.pstmt.setString(15, flightInfo.getArrivalAirportName());
this.pstmt.setString(16, flightInfo.getDepatureAirportCity());
this.pstmt.setString(17, flightInfo.getArrivalAirportCity());
this.pstmt.setInt(18, flightInfo.getAirplaneEmptySeats());
int update = this.pstmt.executeUpdate();
this.pstmt.close();
if(update > 0){
return true;
}else {
return false;
}
}
@Override
public FlightInfo findByID(int id) throws Exception {
// TODO Auto-generated method stub
String sql = "select * from flightInfo where id=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setInt(1, id);
ResultSet resultSet = this.pstmt.executeQuery();
FlightInfo flightInfo = null;
if(resultSet.next()){
flightInfo = new FlightInfo();
flightInfo.setId(resultSet.getInt(1));
flightInfo.setAirlineCode(resultSet.getString(2));
flightInfo.setFlightID(resultSet.getInt(3));
flightInfo.setNumber(resultSet.getInt(4));
flightInfo.setDepatureDate(resultSet.getDate(5));
flightInfo.setDepatureTime(resultSet.getTime(6));
flightInfo.setArrivalDate(resultSet.getDate(7));
flightInfo.setArrivalTime(resultSet.getTime(8));
flightInfo.setFare(resultSet.getDouble(9));
flightInfo.setDepatureAirport(resultSet.getString(10));
flightInfo.setArrivalAirport(resultSet.getString(11));
flightInfo.setAirlineName(resultSet.getString(12));
flightInfo.setAirplaneName(resultSet.getString(13));
flightInfo.setAirplaneType(resultSet.getString(14));
flightInfo.setDepatureAirportName(resultSet.getString(15));
flightInfo.setArrivalAirportName(resultSet.getString(16));
flightInfo.setDepatureAirportCity(resultSet.getString(17));
flightInfo.setArrivalAirportCity(resultSet.getString(18));
flightInfo.setAirplaneEmptySeats(resultSet.getInt(19));
}
this.pstmt.close();
return flightInfo;
}
@Override
public List<FlightInfo> findByAirport(String depatureAirportCity, String arrivalAirportCity, Date depatureDate) throws Exception {
// TODO Auto-generated method stub
String sql = "select * from flightInfo where depatureAirportCity=? and arrivalAirportCity=? and depatureDate=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setString(1, depatureAirportCity);
this.pstmt.setString(2, arrivalAirportCity);
this.pstmt.setDate(3, depatureDate);
ResultSet resultSet = this.pstmt.executeQuery();
List<FlightInfo> list = new ArrayList<>();
FlightInfo flightInfo = null;
while(resultSet.next()){
flightInfo = new FlightInfo();
flightInfo.setId(resultSet.getInt(1));
flightInfo.setAirlineCode(resultSet.getString(2));
flightInfo.setFlightID(resultSet.getInt(3));
flightInfo.setNumber(resultSet.getInt(4));
flightInfo.setDepatureDate(resultSet.getDate(5));
flightInfo.setDepatureTime(resultSet.getTime(6));
flightInfo.setArrivalDate(resultSet.getDate(7));
flightInfo.setArrivalTime(resultSet.getTime(8));
flightInfo.setFare(resultSet.getDouble(9));
flightInfo.setDepatureAirport(resultSet.getString(10));
flightInfo.setArrivalAirport(resultSet.getString(11));
flightInfo.setAirlineName(resultSet.getString(12));
flightInfo.setAirplaneName(resultSet.getString(13));
flightInfo.setAirplaneType(resultSet.getString(14));
flightInfo.setDepatureAirportName(resultSet.getString(15));
flightInfo.setArrivalAirportName(resultSet.getString(16));
flightInfo.setDepatureAirportCity(resultSet.getString(17));
flightInfo.setArrivalAirportCity(resultSet.getString(18));
flightInfo.setAirplaneEmptySeats(resultSet.getInt(19));
list.add(flightInfo);
}
this.pstmt.close();
return list;
}
@Override
public List<FlightInfo> findByDepatureAirport(String depatureAirportCity, Date depatureDate) throws Exception {
// TODO Auto-generated method stub
String sql = "select * from flightInfo where depatureAirportCity=? and depatureDate=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setString(1, depatureAirportCity);
this.pstmt.setDate(2, depatureDate);
ResultSet resultSet = this.pstmt.executeQuery();
List<FlightInfo> list = new ArrayList<>();
FlightInfo flightInfo = null;
while(resultSet.next()){
flightInfo = new FlightInfo();
flightInfo.setId(resultSet.getInt(1));
flightInfo.setAirlineCode(resultSet.getString(2));
flightInfo.setFlightID(resultSet.getInt(3));
flightInfo.setNumber(resultSet.getInt(4));
flightInfo.setDepatureDate(resultSet.getDate(5));
flightInfo.setDepatureTime(resultSet.getTime(6));
flightInfo.setArrivalDate(resultSet.getDate(7));
flightInfo.setArrivalTime(resultSet.getTime(8));
flightInfo.setFare(resultSet.getDouble(9));
flightInfo.setDepatureAirport(resultSet.getString(10));
flightInfo.setArrivalAirport(resultSet.getString(11));
flightInfo.setAirlineName(resultSet.getString(12));
flightInfo.setAirplaneName(resultSet.getString(13));
flightInfo.setAirplaneType(resultSet.getString(14));
flightInfo.setDepatureAirportName(resultSet.getString(15));
flightInfo.setArrivalAirportName(resultSet.getString(16));
flightInfo.setDepatureAirportCity(resultSet.getString(17));
flightInfo.setArrivalAirportCity(resultSet.getString(18));
flightInfo.setAirplaneEmptySeats(resultSet.getInt(19));
list.add(flightInfo);
}
this.pstmt.close();
return list;
}
@Override
public List<FlightInfo> findByTransferArrivalAirport(String depatureAirportCity, String arrivalAirportCity, Date depatureDate, Time depatureTime) throws Exception {
// TODO Auto-generated method stub
String sql = "select * from flightInfo where depatureAirportCity=? and arrivalAirportCity=? and depatureDate>=? and depatureTime>=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setString(1, depatureAirportCity);
this.pstmt.setString(2, arrivalAirportCity);
this.pstmt.setDate(3, depatureDate);
this.pstmt.setTime(4, depatureTime);
ResultSet resultSet = this.pstmt.executeQuery();
List<FlightInfo> list = new ArrayList<>();
FlightInfo flightInfo = null;
while(resultSet.next()){
flightInfo = new FlightInfo();
flightInfo.setId(resultSet.getInt(1));
flightInfo.setAirlineCode(resultSet.getString(2));
flightInfo.setFlightID(resultSet.getInt(3));
flightInfo.setNumber(resultSet.getInt(4));
flightInfo.setDepatureDate(resultSet.getDate(5));
flightInfo.setDepatureTime(resultSet.getTime(6));
flightInfo.setArrivalDate(resultSet.getDate(7));
flightInfo.setArrivalTime(resultSet.getTime(8));
flightInfo.setFare(resultSet.getDouble(9));
flightInfo.setDepatureAirport(resultSet.getString(10));
flightInfo.setArrivalAirport(resultSet.getString(11));
flightInfo.setAirlineName(resultSet.getString(12));
flightInfo.setAirplaneName(resultSet.getString(13));
flightInfo.setAirplaneType(resultSet.getString(14));
flightInfo.setDepatureAirportName(resultSet.getString(15));
flightInfo.setArrivalAirportName(resultSet.getString(16));
flightInfo.setDepatureAirportCity(resultSet.getString(17));
flightInfo.setArrivalAirportCity(resultSet.getString(18));
flightInfo.setAirplaneEmptySeats(resultSet.getInt(19));
list.add(flightInfo);
}
this.pstmt.close();
return list;
}
@Override
public int addPassenger(int id) throws Exception {
// TODO Auto-generated method stub
String sql = "select airplaneEmptySeats from flightInfo where id=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setInt(1, id);
ResultSet resultSet = this.pstmt.executeQuery();
int emptySeats = 0;
if(resultSet.next()){
emptySeats = resultSet.getInt(1);
}
emptySeats--;
sql = "update flightInfo set airplaneEmptySeats=? where id=?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setInt(1, emptySeats);
this.pstmt.setInt(2, id);
this.pstmt.executeUpdate();
this.pstmt.close();
return emptySeats;
}
}
package com.abs.servlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.abs.db.DBName;
import com.abs.factory.DaoFactory;
import com.abs.model.FlightInfo;
public class BookingServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String[] fIDList = request.getParameterValues("flightInfoID");
List<FlightInfo> flightInfoList = new ArrayList<FlightInfo>();
try {
for (String idString : fIDList) {
FlightInfo flightInfo = DaoFactory.getFlightInfoDaoInstance(DBName.ABS).findByID(Integer.parseInt(idString));
if(null != flightInfo){
flightInfoList.add(flightInfo);
}
}
// discount of same airline
if(flightInfoList.size() == 2){
FlightInfo f1 = flightInfoList.get(0);
FlightInfo f2 = flightInfoList.get(1);
if(f1.getAirlineCode().equals(f2.getAirlineCode())){
double discount = DaoFactory.getAirlineDaoInstance(DBName.ABS).findByCode(f1.getAirlineCode()).getDiscount();
f2.setFare(f2.getFare() * discount);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("flightInfoList", flightInfoList);
request.getRequestDispatcher("/booking.jsp").forward(request,response);
}
}
package com.abs.servlet;
import java.io.IOException;
import java.sql.Date;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.abs.action.SearchAction;
import com.abs.model.FlightInfo;
public class SearchServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String departureCity = request.getParameter("departureCity");
String arrivalCity = request.getParameter("arrivalCity");
String departureDate = request.getParameter("departureDate");
//String returnDate = request.getParameter("returnDate");
request.setAttribute("currentDepartureCity", departureCity);
request.setAttribute("currentArrivalCity", arrivalCity);
request.setAttribute("currentDepartureDate", departureDate);
//request.setAttribute("currentReturnDate", returnDate);
List<FlightInfo> list = null;
List<List<FlightInfo>> transferList = null;
// directly flight
try {
list = SearchAction.searchFlightDirectly(departureCity, arrivalCity, departureDate);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(list.size() > 0){
Collections.sort(list,new Comparator<FlightInfo>(){
@Override
public int compare(FlightInfo o1, FlightInfo o2) {
// TODO Auto-generated method stub
return o1.getDepatureTime().compareTo(o2.getDepatureTime());
}});
request.setAttribute("list", list);
}else {
// transfer flight
try {
transferList = SearchAction.searchFlightTransfer(departureCity, arrivalCity, departureDate);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(transferList.size() > 0){
Collections.sort(transferList,new Comparator<List<FlightInfo>>(){
@Override
public int compare(List<FlightInfo> o1, List<FlightInfo> o2) {
// TODO Auto-generated method stub
return o1.get(0).getDepatureTime().compareTo(o2.get(0).getDepatureTime());
}});
request.setAttribute("transferList", transferList);
}else{
// 显示没有结果
request.setAttribute("noResult", "noResult");
}
// ******* test only ******** transfer path
for (List<FlightInfo> list2 : transferList) {
for (FlightInfo flightInfo : list2) {
System.out.println(flightInfo.getDepatureAirportCity() + " " + flightInfo.getArrivalAirportCity());
}
System.out.println("***********************");
}
}
request.getRequestDispatcher("/resultList.jsp").forward(request,response);
}
}
package com.abs.service;
import java.util.List;
import com.abs.dao.AirlineDao;
import com.abs.dao.impl.AirlineDaoImpl;
import com.abs.db.DBConnection;
import com.abs.db.DBName;
import com.abs.model.Airline;
public class AirlineService implements AirlineDao {
private DBConnection dbconn = null;
private AirlineDao AirlineDao = null;
private AirlineDao ABSDao = null;
public AirlineService(DBName dbName) throws Exception {
// TODO Auto-generated constructor stub
this.dbconn = new DBConnection();
this.AirlineDao = new AirlineDaoImpl(dbconn.getConnection(dbName));
this.ABSDao = new AirlineDaoImpl(dbconn.getConnection(DBName.ABS));
}
@Override
public boolean add(Airline airline) throws Exception {
// TODO Auto-generated method stub
boolean airlineFlag = false;
boolean ABSFlag = false;
try {
airlineFlag = this.AirlineDao.add(airline);
ABSFlag = this.ABSDao.add(airline);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return (airlineFlag && ABSFlag);
}
@Override
public Airline findByCode(String code) throws Exception {
// TODO Auto-generated method stub
Airline airline = null;
try {
airline = this.ABSDao.findByCode(code);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return airline;
}
@Override
public List<Airline> findAll() throws Exception {
// TODO Auto-generated method stub
List<Airline> list = null;
try {
list = this.ABSDao.findAll();
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return list;
}
}
package com.abs.service;
import java.sql.Date;
import java.sql.Time;
import java.util.List;
import com.abs.dao.FlightInfoDao;
import com.abs.dao.impl.FlightInfoDaoImpl;
import com.abs.db.DBConnection;
import com.abs.db.DBName;
import com.abs.model.FlightInfo;
public class FlightInfoService implements FlightInfoDao {
private DBConnection dbconn = null;
private FlightInfoDao dao = null;
public FlightInfoService(DBName dbName) throws Exception {
// TODO Auto-generated constructor stub
this.dbconn = new DBConnection();
this.dao = new FlightInfoDaoImpl(dbconn.getConnection(dbName));
}
@Override
public boolean add(FlightInfo flightInfo) throws Exception {
// TODO Auto-generated method stub
boolean flag = false;
try {
flag = this.dao.add(flightInfo);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return flag;
}
@Override
public FlightInfo findByID(int id) throws Exception {
// TODO Auto-generated method stub
FlightInfo flightInfo = null;
try {
flightInfo = this.dao.findByID(id);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return flightInfo;
}
@Override
public List<FlightInfo> findByAirport(String depatureAirportCity, String arrivalAirportCity, Date depatureDate) throws Exception {
// TODO Auto-generated method stub
List<FlightInfo> list = null;
try {
list = this.dao.findByAirport(depatureAirportCity, arrivalAirportCity, depatureDate);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return list;
}
@Override
public List<FlightInfo> findByDepatureAirport(String depatureAirportCity, Date depatureDate) throws Exception {
// TODO Auto-generated method stub
List<FlightInfo> list = null;
try {
list = this.dao.findByDepatureAirport(depatureAirportCity, depatureDate);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return list;
}
@Override
public List<FlightInfo> findByTransferArrivalAirport(String depatureAirportCity, String arrivalAirportCity, Date depatureDate, Time depatureTime) throws Exception {
// TODO Auto-generated method stub
List<FlightInfo> list = null;
try {
list = this.dao.findByTransferArrivalAirport(depatureAirportCity, arrivalAirportCity, depatureDate,depatureTime);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return list;
}
@Override
public int addPassenger(int id) throws Exception {
// TODO Auto-generated method stub
int emptySeats = -1;
try {
emptySeats = this.dao.addPassenger(id);
} catch (Exception e) {
// TODO: handle exception
throw e;
}finally {
this.dbconn.closeAll();
}
return emptySeats;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ABS_Bookingtitle>
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="<%=basePath%>">
<link rel="SHORTCUT ICON" href="<%=path %>/images/airplane.icon"/>
<link rel="stylesheet" href="<%=path %>/css/cube.css">
<link rel="SHORTCUT ICON" href="<%=path %>/images/airplane.icon"/>
<link rel="stylesheet" type="text/css" href="<%=path %>/css/absBase.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/css/booking.css">
<script type="text/javascript" src="js/booking.js">script>
head>
<body>
<div class="abs_container clearfix b_container">
<form action="servlet/OrderServlet" method="post" class="b_form">
<span class="b_form_title">乘客span>
<div id="b_formItem_container">
<div class="b_form_item clearfix">
<div class="bf_item_idArea">
<span class="bf_item_id">1span>
div>
<div class="bf_item_textArea">
<div class="bf_item_text clearfix">
<span>姓 名:span>
<div>
<input type="text" name="name" onfocus="textOnFocus(this)" onblur="textOnBlur(this)">
div>
div>
<div class="bf_item_text clearfix">
<span>护 照:span>
<div>
<input type="text" name="passport" onfocus="textOnFocus(this)" onblur="textOnBlur(this)">
div>
div>
<div class="bf_item_seatType">
<span>座位偏好:span>
<label class="user_unSelect">
<input class="bf_item_radioBut" type="radio" checked="checked" name="seatType1" value="default"/>默认
label>
<label class="user_unSelect">
<input class="bf_item_radioBut" type="radio" name="seatType1" value="windowSeat"/>靠窗
label>
<label class="user_unSelect">
<input class="bf_item_radioBut" type="radio" name="seatType1" value="middleSeat"/>中间
label>
<label class="user_unSelect">
<input class="bf_item_radioBut" type="radio" name="seatType1" value="aisleSeat"/>靠过道
label>
div>
div>
<div class="bf_item_subtotalArea">
<div class="bf_item_delete clearfix">
<span onclick="deleteItem(this)">删除span>
<img src="images/close_icon.png" onclick="deleteItem(this)">
div>
<div class="bf_item_subtotal">
<c:forEach items="${flightInfoList}" var="flightInfo">
<span>¥
<fmt:formatNumber type="number" groupingUsed="false" value="${flightInfo.fare}" />
span>
c:forEach>
div>
div>
div>
div>
<div>
<button class="b_form_addItem" type="button" onclick="addItem()">+ 添加乘客button>
div>
<div class="b_form_mainPassenger">
<span class="b_form_title">联系人span>
<div class="bf_passenger_info clearfix">
<div class="bfp_info_text">
<span>姓 名:span>
<div>
<input type="text" name="contact" onfocus="textOnFocus(this)" onblur="textOnBlur(this)">
div>
div>
<div class="bfp_info_text">
<span>手机号:span>
<div>
<input type="text" name="phone" onfocus="textOnFocus(this)" onblur="textOnBlur(this)">
div>
div>
div>
div>
<c:forEach items="${flightInfoList}" var="flightInfo">
<input type="hidden" name="flightInfoID" value="${flightInfo.id}">
c:forEach>
<div>
<input class="b_form_submit" type="submit" name="submitButton" value="提交订单">
div>
form>
<div class="b_order">
<c:set var="totalFare" value="0"/>
<div class="b_order_info">
<c:forEach items="${flightInfoList}" var="flightInfo">
<div class="bo_info_item">
<div class="bo_info_flightArea">
<span class="bo_info_num">span>
<span class="bo_info_date">
<fmt:formatDate value="${flightInfo.depatureDate}" type="both" pattern="MM-dd"/>
span>
<span class="bo_info_city">${flightInfo.depatureAirportCity}span>
<img class="bo_info_arrow" src="images/info_arrow_icon.png">
<span class="bo_info_city">${flightInfo.arrivalAirportCity}span>
div>
<div class="bo_info_airlineArea">
<span class="bo_info_airline">${flightInfo.airlineName} ${flightInfo.airlineCode}${flightInfo.number}span>
<span class="bo_info_plane">${flightInfo.airplaneName}span>
div>
<div class="bo_info_timeArea clearfix">
<span class="bo_info_time">
<fmt:formatDate value="${flightInfo.depatureTime}" type="both" pattern="HH:mm"/>
span>
<img src="images/info_costTime_icon.png">
<span class="bo_info_costTime">span>
<span class="bo_info_time">
<fmt:formatDate value="${flightInfo.arrivalTime}" type="both" pattern="HH:mm"/>
span>
div>
<div class="bo_info_airportArea">
<span class="bo_info_airport">${flightInfo.depatureAirportName}span>
<img class="bo_info_timeline" src="images/info_timeline_icon.png">
<span class="bo_info_airport">${flightInfo.arrivalAirportName}span>
div>
div>
c:forEach>
div>
<div class="b_order_detail">
<c:forEach items="${flightInfoList}" var="flightInfo">
<div class="bo_detail_item">
<div class="bo_detail_subtotal clearfix">
<span class="bo_detail_title">机票span>
<span class="bo_detail_value">¥
<span class="bo_detail_fare">
<fmt:formatNumber type="number" groupingUsed="false" value="${flightInfo.fare}" />
<c:set var="totalFare" value="${totalFare + flightInfo.fare}"/>
span>
×
<span class="bo_detail_num">1span>
span>
div>
div>
c:forEach>
div>
<div class="b_order_cost">
¥
<span id="o_totalFare">
<fmt:formatNumber type="number" groupingUsed="false" value="${totalFare}" />
span>
div>
div>
div>
<div id="b_formItem">
<div class="b_form_item clearfix">
<div class="bf_item_idArea">
<span class="bf_item_id">${num}span>
div>
<div class="bf_item_textArea">
<div class="bf_item_text clearfix">
<span>姓 名:span>
<div>
<input type="text" name="name" onfocus="textOnFocus(this)" onblur="textOnBlur(this)">
div>
div>
<div class="bf_item_text clearfix">
<span>护 照:span>
<div>
<input type="text" name="passport" onfocus="textOnFocus(this)" onblur="textOnBlur(this)">
div>
div>
<div class="bf_item_seatType">
<span>座位偏好:span>
<label>
<input class="bf_item_radioBut" type="radio" checked="checked" name="seatType1" value="default" id="b_seat_default" />默认
label>
<label>
<input class="bf_item_radioBut" type="radio" name="seatType1" value="windowSeat" id="b_seat_widnow" />靠窗
label>
<label>
<input class="bf_item_radioBut" type="radio" name="seatType1" value="middleSeat" id="b_seat_middle" />中间
label>
<label>
<input class="bf_item_radioBut" type="radio" name="seatType1" value="aisleSeat" id="b_seat_aisle" />靠过道
label>
div>
div>
<div class="bf_item_subtotalArea">
<div class="bf_item_delete clearfix">
<span onclick="deleteItem(this)">删除span>
<img src="images/close_icon.png" onclick="deleteItem(this)">
div>
<div class="bf_item_subtotal">
<c:forEach items="${flightInfoList}" var="flightInfo">
<span>¥
<fmt:formatNumber type="number" groupingUsed="false" value="${flightInfo.fare}" />
span>
c:forEach>
div>
div>
div>
div>
body>
html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ABS_GenerateOrdertitle>
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="<%=basePath%>">
<link rel="SHORTCUT ICON" href="<%=path %>/images/airplane.icon"/>
<link rel="stylesheet" href="<%=path %>/css/cube.css">
<link rel="SHORTCUT ICON" href="<%=path %>/images/airplane.icon"/>
<link rel="stylesheet" type="text/css" href="<%=path %>/css/absBase.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/css/generateOrder.css">
<script type="text/javascript" src="<%=path %>/js/generateOrder.js">script>
head>
<body>
<div class="abs_container clearfix g_container">
<div class="g_order clearfix">
<div class="g_title">
<span>订单信息span>
div>
<div class="g_content">
<div class="g_order_info">
<div class="go_info_detail">
<div class="go_info_title">
<span>订单状态span>
<span>订单号span>
<span>预定日期span>
<span>预定方式span>
<span>支付方式span>
div>
<div class="go_info_value">
<span class="go_info_styleBlod">已出票span>
<span class="go_info_styleBlod">${order.id}span>
<span>
<fmt:formatDate value="${order.createDate}" type="both" pattern="yyyy-MM-dd"/>
<fmt:formatDate value="${order.createTime}" type="both" pattern="HH:mm:ss"/>
span>
<span>网上预定span>
<span>支付宝span>
div>
div>
<div class="go_info_total">
<span>总金额span>
<em>¥em>
<span>
<fmt:formatNumber type="number" groupingUsed="false" value="${order.totalFare}" />
span>
div>
div>
div>
<div class="g_extend">
<button class="go_extend_but" type="button">打印订单button>
<button class="go_extend_but go_eb_cancel" type="button">取消订单button>
div>
div>
<div class="g_flight clearfix">
<div class="g_title">
<span>航班span>
div>
<div class="g_content">
<div class="g_flight_info">
<c:set var="count" value="0"/>
<c:forEach items="${flightInfoList}" var="flightInfo">
<c:set var="count" value="${count + 1}"/>
c:forEach>
<c:forEach items="${flightInfoList}" var="flightInfo" varStatus="currentStatus">
<c:if test="${currentStatus.count == 1}">
<div class="gf_info_title">
<c:if test="${count <=1}">
<span>单程span>
c:if>
<c:if test="${count > 1}">
<span>转机span>
c:if>
div>
c:if>
<c:if test="${currentStatus.count != 1}">
<div class="gf_info_title">
<span>span>
div>
c:if>
<div class="gf_info_value">
<div class="gf_info_item">
<div class="gf_info_main">
<span>
<fmt:formatDate value="${flightInfo.depatureDate}" type="both" pattern="yyyy-MM-dd"/>
span>
<span>${flightInfo.depatureAirportCity}—${flightInfo.arrivalAirportCity}span>
div>
<div class="gf_info_detail">
<div class="gf_info_airline">
<span>${flightInfo.airlineName}span>
<span>${flightInfo.airlineCode}${flightInfo.number}span>
<span>${flightInfo.airplaneName}span>
div>
<div class="gf_info_time">
<div class="gf_info_depart">
<span class="gfi_time">
<fmt:formatDate value="${flightInfo.depatureTime}" type="both" pattern="HH:mm"/>
span>
<span>${flightInfo.depatureAirportName}span>
div>
<img src="images/result_arrow.png">
<div class="gf_info_arrive">
<span class="gfi_time">
<fmt:formatDate value="${flightInfo.arrivalTime}" type="both" pattern="HH:mm"/>
span>
<span>${flightInfo.arrivalAirportName}span>
div>
<div class="gf_info_costTime">
<img src="images/g_costTime_icon.png">
<span class="gfi_costTime">span>
div>
div>
div>
div>
div>
c:forEach>
div>
div>
<div class="g_extend">div>
div>
<div class="g_passenger clearfix">
<div class="g_title">
<span>乘机人span>
div>
<div class="g_content">
<div class="g_passenger_info">
<c:forEach items="${passengers}" var="passenger" varStatus="currentStatus">
<div class="gp_info_item">
<div class="gp_info_num">
<span>${currentStatus.count}span>
div>
<div class="gp_info_title">
<span>姓名span>
<span>证件信息span>
div>
<div class="gp_info_value">
<span>${passenger.name}span>
<span>护照 ${passenger.passport}span>
div>
div>
c:forEach>
div>
div>
<div class="g_extend">div>
div>
<div class="g_contact clearfix">
<div class="g_title">
<span>联系人span>
div>
<div class="g_content">
<div class="g_passenger_info">
<div class="g_contact_left">
div>
<div class="gp_contact_item">
<div class="gp_info_title">
<span>姓 名span>
<span>联系方式span>
div>
<div class="gp_info_value">
<span>${order.contactName}span>
<span>${order.contactPhone}span>
div>
div>
div>
div>
<div class="g_extend">div>
div>
div>
body>
html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ABS_Searchtitle>
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="<%=basePath%>">
<link rel="SHORTCUT ICON" href="<%=path %>/images/airplane.icon"/>
<link rel="stylesheet" href="<%=path %>/css/cube.css">
<link rel="SHORTCUT ICON" href="<%=path %>/images/airplane.icon"/>
<link rel="stylesheet" type="text/css" href="<%=path %>/css/absBase.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/css/search.css">
<script type="text/javascript" src="<%=path %>/js/search.js">script>
head>
<body>
<div class="s_box">
<form action="servlet/SearchServlet" method="post" class="s_box_container">
<div class="s_row s_tab_line clearfix">
<button type="button" class="s_tab">国内机票button>
<button type="button" class="s_tab">国际机票button>
div>
<div class="s_row">
<span class="s_label">航行类型span>
<label for="s_radio_oneWay" class="user_unSelect">
<input class="s_radioBut" type="radio" name="tripType" value="oneWay" id="s_radio_oneWay" checked="checked" onclick="radioButClick(this)">单程
label>
<label for="s_radio_roundTrip" class="user_unSelect">
<input class="s_radioBut" type="radio" name="tripType" value="roundTrip" id="s_radio_roundTrip" onclick="radioButClick(this)">往返
label>
div>
<div class="s_row">
<span class="s_label">出发城市span>
<select class="s_text" name="departureCity">
<option>option>
<option value ="武汉">武汉option>
<option value ="北京">北京option>
<option value ="上海">上海option>
<option value ="广州">广州option>
<option value ="深圳">深圳option>
<option value ="成都">成都option>
<option value ="沈阳">沈阳option>
<option value ="西藏">西藏option>
select>
<span class="s_label">出发日期span>
<input id="dDate" class="s_text s_date" type="date" name="departureDate">
div>
<div class="s_row">
<span class="s_label">到达城市span>
<select class="s_text" name="arrivalCity">
<option>option>
<option value ="北京">北京option>
<option value ="武汉">武汉option>
<option value ="上海">上海option>
<option value ="广州">广州option>
<option value ="深圳">深圳option>
<option value ="成都">成都option>
<option value ="沈阳">沈阳option>
<option value ="西藏">西藏option>
select>
<span class="s_label">返回日期span>
<input id="aDate" class="s_text s_date" type="date" name="returnDate" id="s_returnDate" disabled="disabled">
div>
<div class="s_row">
<input class="s_submit" type="submit" value="搜索机票">
div>
form>
div>
body>
html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ABS_ResultListtitle>
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="<%=basePath%>">
<link rel="SHORTCUT ICON" href="<%=path %>/images/airplane.icon"/>
<link rel="stylesheet" href="css/cube.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/css/absBase.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/css/resultList.css">
<script type="text/javascript" src="<%=path %>/js/reslutList.js">script>
head>
<body onload="InitSelect('${currentDepartureCity}', '${currentArrivalCity}')">
<div class="abs_container clearfix r_container" id="tripItemContainer">
<form action="servlet/SearchServlet" method="post" class="r_top clearfix">
<select class="r_top_select" onchange="selectChange(this)">
<option value ="oneWay">单程option>
<option value ="roundTrip">往返option>
select>
<div class="r_top_text">
<img class="r_icon" src="images/departure_icon.png">
<select id="departureSelect" name="departureCity" onfocus="textOnFocus(this)" onblur="textOnBlur(this)" >
<option>option>
<option value ="武汉">武汉option>
<option value ="北京">北京option>
<option value ="上海">上海option>
<option value ="广州">广州option>
<option value ="深圳">深圳option>
<option value ="成都">成都option>
<option value ="沈阳">沈阳option>
<option value ="西藏">西藏option>
select>
div>
<div class="r_top_text">
<img class="r_icon" src="images/departure_time_icon.png">
<select id="arrivalSelect" name="arrivalCity" onfocus="textOnFocus(this)" onblur="textOnBlur(this)" >
<option>option>
<option value ="武汉">武汉option>
<option value ="北京">北京option>
<option value ="上海">上海option>
<option value ="广州">广州option>
<option value ="深圳">深圳option>
<option value ="成都">成都option>
<option value ="沈阳">沈阳option>
<option value ="西藏">西藏option>
select>
div>
<div class="r_top_text">
<img class="r_icon" src="images/desi_icon.png">
<input id="dDate" type="date" name="departureDate" onfocus="textOnFocus(this)" onblur="textOnBlur(this)" value="${currentDepartureDate}">
div>
<div class="r_top_text">
<img class="r_icon" src="images/desi_time_icon.png">
<input id="aDate" type="date" name="returnDate" onfocus="textOnFocus(this)" onblur="textOnBlur(this)" id="s_returnDate" disabled="disabled">
div>
<input class="r_top_but" type="submit" value="重新搜索">
form>
<div class="r_title clearfix" id="r_title">
<span class="r_title_header">航班信息span>
<label id="r_label_1" class="r_title_item1 user_unSelect" onclick="changeSortType('r_label_1')">
<span>起飞时间span>
<div class="r_title_sortIcon">
<img src="images/icon_up_blue.png">
<img src="images/icon_down_gray.png">
div>
label>
<label id="r_label_2" class="r_title_item2 user_unSelect" onclick="changeSortType('r_label_2')">
<span>到达时间span>
<div class="r_title_sortIcon">
<img src="images/icon_up_gray.png">
<img src="images/icon_down_gray.png">
div>
label>
<label id="r_label_3" class="r_title_item3 user_unSelect" onclick="changeSortType('r_label_3')">
<span>价格span>
<div class="r_title_sortIcon">
<img src="images/icon_up_gray.png">
<img src="images/icon_down_gray.png">
div>
label>
div>
<%-- 直达航班 --%>
<c:forEach items="${list}" var="item" varStatus="current">
<div class="r_resultItem clearfix tripItem">
<div class="r_resultItemBox clearfix">
<div class="r_result_col width_20">div>
<div class="r_result_col width_180">
<span class="r_airline">${item.airlineName} <span>${item.airlineCode}${item.number}span>span>
<span class="r_airplane">${item.airplaneName} span>
div>
<div class="r_result_col width_140">
<span class="r_departureTime">
<fmt:formatDate value="${item.depatureTime}" type="both" pattern="HH:mm"/>
span>
<span class="r_departureCity">${item.depatureAirportName}span>
div>
<div class="r_result_col width_100">
<img class="r_arrow" src="images/result_arrow.png">
div>
<div class="r_result_col width_140">
<span class="r_destinationTime">
<fmt:formatDate value="${item.arrivalTime}" type="both" pattern="HH:mm"/>
span>
<span class="r_destinationCity">${item.arrivalAirportName}span>
div>
<div class="r_result_col width_150 r_detail">
<span>
<fmt:formatNumber type="number" groupingUsed="false" value="${item.fare}" />
* ${1}
span>
div>
<div class="r_result_col width_150">
<span class="r_price">¥
<span>
<fmt:formatNumber type="number" groupingUsed="false" value="${item.fare}" />
span>
span>
div>
<div class="r_result_col width_100">
<form action="servlet/BookingServlet" method="post" class="r_button_box">
<%-- 提交被选中的 FlightInfo的 id --%>
<input type="hidden" name="flightInfoID" value="${item.id}">
<input class="r_button" type="submit" value="提交">
<c:if test="${item.airplaneEmptySeats < 10}">
<span class="r_emptySeats">${item.airplaneEmptySeats}张span>
c:if>
form>
div>
div>
div>
c:forEach>
<%-- 中转组合航班 --%>
<c:forEach items="${transferList}" var="listItem" varStatus="current">
<div class="r_resultItem clearfix tripItem">
<div class="r_resultItemBox clearfix">
<div class="r_result_col width_20">div>
<div class="r_result_col width_180">
<c:forEach items="${listItem}" var="item" begin="0" end="0">
<span class="r_airline">${item.airlineName} <span>${item.airlineCode}${item.number}span>span>
c:forEach>
<c:forEach items="${listItem}" var="item" begin="1" end="1">
<span class="r_airline">${item.airlineName} <span>${item.airlineCode}${item.number}span>span>
c:forEach>
div>
<div class="r_result_col width_140">
<c:forEach items="${listItem}" var="item" begin="0" end="0">
<span class="r_departureTime">
<fmt:formatDate value="${item.depatureTime}" type="both" pattern="HH:mm"/>
span>
<span class="r_departureCity">${item.depatureAirportName}span>
c:forEach>
div>
<div class="r_result_col width_100">
<span class="r_transfer1_trans1">经停span>
<img class="r_transfer1_arrow" src="images/result_arrow.png">
<c:forEach items="${listItem}" var="item" begin="0" end="0">
<span class="r_transfer1_trans2">${item.arrivalAirportCity}span>
c:forEach>
div>
<div class="r_result_col width_140">
<c:forEach items="${listItem}" var="item" begin="1" end="1">
<span class="r_destinationTime">
<fmt:formatDate value="${item.arrivalTime}" type="both" pattern="HH:mm"/>
span>
<span class="r_destinationCity">${item.arrivalAirportName}span>
c:forEach>
div>
<div class="r_result_col width_150">
<c:forEach items="${listItem}" var="item" begin="0" end="0">
<span class="r_transfer1_fare">
<fmt:formatNumber type="number" groupingUsed="false" value="${item.fare}" />
* 1
span>
<c:set var="fare1" value="${item.fare}"/>
c:forEach>
<c:forEach items="${listItem}" var="item" begin="1" end="1">
<span class="r_transfer1_fare">
<fmt:formatNumber type="number" groupingUsed="false" value="${item.fare}" />
* 1
span>
<c:set var="fare2" value="${item.fare}"/>
c:forEach>
div>
<div class="r_result_col width_150">
<span class="r_price">
¥
<span>
<fmt:formatNumber type="number" groupingUsed="false" value="${fare1 + fare2}" />
span>
span>
div>
<div class="r_result_col width_100">
<form action="servlet/BookingServlet" method="post" class="r_button_box">
<%-- 提交被选中的 FlightInfo的 id --%>
<c:forEach items="${listItem}" var="item">
<input type="hidden" name="flightInfoID" value="${item.id}">
c:forEach>
<input class="r_button" type="submit" value="提交">
<c:forEach items="${listItem}" var="item" begin="0" end="0">
<c:set var="seat1" value="${item.airplaneEmptySeats}"/>
c:forEach>
<c:forEach items="${listItem}" var="item" begin="1" end="1">
<c:set var="seat2" value="${item.airplaneEmptySeats}"/>
c:forEach>
<c:if test="${(seat1" >
<span class="r_emptySeats">${seat1span>
c:if>
form>
div>
div>
div>
c:forEach>
<c:if test="${noResult == 'noResult'}">
<div class="r_noResult">
<span>抱歉! 没有查询到结果span>
div>
c:if>
div>
body>
html>
Java+JSP实现学生图书管理系统
Java+JSP实现学生信息管理系统
Java+JSP实现用户信息管理系统
Java+Servlet+JSP实现学生成绩管理系统
Java+Servlet+JSP实现宠物诊所管理系统
Java+SSM+Easyui实现网上考试系统
Java+Springboot+H-ui实现营销管理系统
Java+Springboot+Mybatis+Bootstrap实现网上商城系统
Java+Swing实现斗地主游戏
Java+Swing实现图书管理系统
Java+Swing实现医院管理系统
Java+Swing实现仓库管理系统
Java+Swing实现考试管理系统
Java+Swing实现通讯录管理系统
Java+Swing实现停车场管理系统
Java+Swing实现学生信息管理系统
Java+Swing实现学生宿舍管理系统
Java+Swing实现学生选课管理系统
Java+Swing实现学生成绩管理系统
Java+Swing实现学校教材管理系统
Java+Swing实现学校教务管理系统
Java+Swing实现企业人事管理系统
Java+Swing实现电子相册管理系统
Java+Swing实现自助取款机(ATM)系统
Java+Swing实现超市管理系统-TXT存储信息
Java+Swing实现宠物商店管理系统-TXT存储信息
点击以下链接获取源码,数据库文件在sql文件夹下面。
Java(servlet+jdbc+jsp+mysql)实现Web航空订票系统源码
如有侵权请联系我删除。
年轻人,冲冲冲!