Compare commits

..

No commits in common. 'master' and 'develop' have entirely different histories.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 559 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 865 KiB

@ -1,283 +0,0 @@
# 航班表
use air_data;
CREATE TABLE flights
(
flight_id VARCHAR(20) PRIMARY KEY, # 航班号
airline_company VARCHAR(100) NOT NULL, # 航空公司
departure_location VARCHAR(100) NOT NULL, # 出发地点
destination_location VARCHAR(100) NOT NULL, # 目的地位置
departure_time DATETIME NOT NULL, # 出发时间
arrival_time DATETIME NOT NULL, # 到达时间
boarding_time DATETIME NOT NULL, # 登机时间
gate VARCHAR(20), # 登机口
delay_status ENUM ('on_time', 'delayed',
'cancelled') DEFAULT 'on_time', # 延迟状态
destination_image VARCHAR(255), # 目的地图片
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP # 创建时间
);
INSERT INTO flights (flight_id, airline_company, departure_location, destination_location, departure_time, arrival_time, boarding_time, gate, delay_status, destination_image) VALUES
('CA123', 'Air China', 'Beijing (PEK)', 'Tokyo (NRT)', '2024-03-20 08:30:00', '2024-03-20 12:45:00', '2024-03-20 07:45:00', 'A12', 'on_time', '/images/tokyo.jpg'),
('UA789', 'United Airlines', 'New York (JFK)', 'London (LHR)', '2024-03-20 14:15:00', '2024-03-20 23:30:00', '2024-03-20 13:30:00', 'B7', 'on_time', '/images/london.jpg'),
('EK521', 'Emirates', 'Dubai (DXB)', 'Singapore (SIN)', '2024-03-20 09:45:00', '2024-03-20 17:20:00', '2024-03-20 09:00:00', 'C15', 'delayed', '/images/singapore.jpg'),
('LH430', 'Lufthansa', 'Frankfurt (FRA)', 'New York (JFK)', '2024-03-20 11:20:00', '2024-03-20 14:35:00', '2024-03-20 10:35:00', 'D22', 'on_time', '/images/newyork.jpg'),
('SQ305', 'Singapore Airlines', 'Singapore (SIN)', 'Sydney (SYD)', '2024-03-20 16:40:00', '2024-03-20 22:15:00', '2024-03-20 15:55:00', 'E8', 'on_time', '/images/sydney.jpg'),
('BA117', 'British Airways', 'London (LHR)', 'Dubai (DXB)', '2024-03-20 13:10:00', '2024-03-20 22:45:00', '2024-03-20 12:25:00', 'F3', 'on_time', '/images/dubai.jpg'),
('AF385', 'Air France', 'Paris (CDG)', 'Tokyo (NRT)', '2024-03-20 10:50:00', '2024-03-21 06:20:00', '2024-03-20 10:05:00', 'G11', 'on_time', '/images/tokyo.jpg'),
('JL065', 'Japan Airlines', 'Tokyo (NRT)', 'Los Angeles (LAX)', '2024-03-20 15:30:00', '2024-03-20 09:15:00', '2024-03-20 14:45:00', 'H5', 'on_time', '/images/losangeles.jpg'),
('DL289', 'Delta Air Lines', 'Atlanta (ATL)', 'Paris (CDG)', '2024-03-20 18:25:00', '2024-03-21 08:10:00', '2024-03-20 17:40:00', 'A9', 'delayed', '/images/paris.jpg'),
('CX831', 'Cathay Pacific', 'Hong Kong (HKG)', 'Vancouver (YVR)', '2024-03-20 12:05:00', '2024-03-20 08:50:00', '2024-03-20 11:20:00', 'B14', 'on_time', '/images/vancouver.jpg'),
('QF2', 'Qantas', 'London (LHR)', 'Singapore (SIN)', '2024-03-20 19:40:00', '2024-03-21 17:25:00', '2024-03-20 18:55:00', 'C6', 'on_time', '/images/singapore.jpg'),
('KL887', 'KLM', 'Amsterdam (AMS)', 'New York (JFK)', '2024-03-20 14:55:00', '2024-03-20 17:20:00', '2024-03-20 14:10:00', 'D18', 'on_time', '/images/newyork.jpg'),
('EY451', 'Etihad Airways', 'Abu Dhabi (AUH)', 'Sydney (SYD)', '2024-03-20 21:15:00', '2024-03-21 17:40:00', '2024-03-20 20:30:00', 'E4', 'on_time', '/images/sydney.jpg'),
('TK15', 'Turkish Airlines', 'Istanbul (IST)', 'Tokyo (NRT)', '2024-03-20 08:10:00', '2024-03-20 23:45:00', '2024-03-20 07:25:00', 'F9', 'cancelled', '/images/tokyo.jpg'),
('AA125', 'American Airlines', 'Chicago (ORD)', 'London (LHR)', '2024-03-20 16:50:00', '2024-03-21 06:25:00', '2024-03-20 16:05:00', 'G13', 'on_time', '/images/london.jpg'),
('NZ5', 'Air New Zealand', 'Auckland (AKL)', 'Los Angeles (LAX)', '2024-03-20 13:35:00', '2024-03-20 05:20:00', '2024-03-20 12:50:00', 'H7', 'on_time', '/images/losangeles.jpg'),
('BR87', 'EVA Air', 'Taipei (TPE)', 'Vancouver (YVR)', '2024-03-20 11:45:00', '2024-03-20 06:30:00', '2024-03-20 11:00:00', 'A3', 'delayed', '/images/vancouver.jpg'),
('LH730', 'Lufthansa', 'Munich (MUC)', 'Dubai (DXB)', '2024-03-20 09:20:00', '2024-03-20 15:55:00', '2024-03-20 08:35:00', 'B10', 'on_time', '/images/dubai.jpg'),
('SQ25', 'Singapore Airlines', 'Frankfurt (FRA)', 'New York (JFK)', '2024-03-20 17:30:00', '2024-03-20 20:15:00', '2024-03-20 16:45:00', 'C8', 'on_time', '/images/newyork.jpg'),
('UA863', 'United Airlines', 'San Francisco (SFO)', 'Sydney (SYD)', '2024-03-20 22:05:00', '2024-03-22 06:40:00', '2024-03-20 21:20:00', 'D5', 'on_time', '/images/sydney.jpg');
# 乘客表
CREATE TABLE passengers
(
id_card VARCHAR(18) PRIMARY KEY, #身份证号
name VARCHAR(100) NOT NULL, # 姓名
is_vip BOOLEAN DEFAULT FALSE, # 是否是VIP
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP # 创建时间
);
-- 插入测试数据到 passengers 表
INSERT INTO passengers (id_card, name, is_vip) VALUES
('110101199001011234', '张三', TRUE),
('110101199002022345', '李四', FALSE),
('110101199003033456', '王五', TRUE),
('110101199004044567', '赵六', FALSE),
('110101199005055678', '钱七', TRUE),
('110101199006066789', '孙八', FALSE),
('110101199007077890', '周九', TRUE),
('110101199008088901', '吴十', FALSE),
('110101199009099012', '郑十一', TRUE),
('110101199010101123', '王十二', FALSE);
update passengers set name = 'ZHANG' where id_card = '110101199001011234';
# 管理员表
CREATE TABLE admins
(
admin_id VARCHAR(18) PRIMARY KEY, # 管理员id
username VARCHAR(50) UNIQUE NOT NULL, # 账号
password_hash VARCHAR(255) NOT NULL, # 密码
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP # 创建时间
);
INSERT INTO admins (admin_id, username, password_hash) VALUES
('100000000000000001', 'admin01', '100001'),
('100000000000000002', 'admin02', '100002'),
('100000000000000003', 'admin03', '100003'),
('100000000000000004', 'admin04', '100004'),
('100000000000000005', 'admin05', '100005'),
('100000000000000006', 'superadmin', '100006'),
('100000000000000007', 'sysadmin', '100007'),
('100000000000000008', 'webmaster', '100008'),
('100000000000000009', 'rootadmin', '100009'),
('100000000000000010', 'masteradmin', '100010');
# 飞机座位
CREATE TABLE flight_seats
(
seat_id INT PRIMARY KEY AUTO_INCREMENT, # 座位号
flight_id VARCHAR(20) NOT NULL, # 航班号
seat_number VARCHAR(10) NOT NULL, # 座位
seat_row INT NOT NULL, # 行号
seat_column CHAR(1) NOT NULL, # 列号
seat_class ENUM ('economy', 'business', 'first') DEFAULT 'economy', # 座位类型
is_available BOOLEAN DEFAULT TRUE, # 是否可用
UNIQUE KEY unique_flight_seat (flight_id, seat_number),
FOREIGN KEY (flight_id) REFERENCES flights (flight_id)
);
delete from flight_seats;
INSERT INTO flight_seats (flight_id, seat_number, seat_row, seat_column, seat_class, is_available) VALUES
-- 航班 CA123 (Air China) - 假设 A330 布局
('CA123', '1A', 1, 'A', 'first', TRUE),
('CA123', '1B', 1, 'B', 'first', TRUE),
('CA123', '1C', 1, 'C', 'first', TRUE),
('CA123', '1D', 1, 'D', 'first', TRUE),
('CA123', '2A', 2, 'A', 'first', TRUE),
('CA123', '2B', 2, 'B', 'first', TRUE),
('CA123', '2C', 2, 'C', 'first', TRUE),
('CA123', '2D', 2, 'D', 'first', TRUE),
('CA123', '5A', 5, 'A', 'business', TRUE),
('CA123', '5B', 5, 'B', 'business', TRUE),
('CA123', '5C', 5, 'C', 'business', TRUE),
('CA123', '5D', 5, 'D', 'business', TRUE),
('CA123', '5E', 5, 'E', 'business', TRUE),
('CA123', '5F', 5, 'F', 'business', TRUE),
('CA123', '10A', 10, 'A', 'economy', TRUE),
('CA123', '10B', 10, 'B', 'economy', TRUE),
('CA123', '10C', 10, 'C', 'economy', TRUE),
('CA123', '10D', 10, 'D', 'economy', TRUE),
('CA123', '10E', 10, 'E', 'economy', TRUE),
('CA123', '10F', 10, 'F', 'economy', TRUE),
-- 航班 UA789 (United Airlines) - 假设 777 布局
('UA789', '1A', 1, 'A', 'first', TRUE),
('UA789', '1B', 1, 'B', 'first', TRUE),
('UA789', '1C', 1, 'C', 'first', TRUE),
('UA789', '1D', 1, 'D', 'first', TRUE),
('UA789', '4A', 4, 'A', 'business', TRUE),
('UA789', '4B', 4, 'B', 'business', TRUE),
('UA789', '4C', 4, 'C', 'business', TRUE),
('UA789', '4D', 4, 'D', 'business', TRUE),
('UA789', '4E', 4, 'E', 'business', TRUE),
('UA789', '4F', 4, 'F', 'business', TRUE),
('UA789', '8A', 8, 'A', 'economy', TRUE),
('UA789', '8B', 8, 'B', 'economy', TRUE),
('UA789', '8C', 8, 'C', 'economy', TRUE),
('UA789', '8D', 8, 'D', 'economy', TRUE),
('UA789', '8E', 8, 'E', 'economy', TRUE),
('UA789', '8F', 8, 'F', 'economy', TRUE),
-- 航班 EK521 (Emirates) - 假设 A380 布局
('EK521', '1A', 1, 'A', 'first', TRUE),
('EK521', '1B', 1, 'B', 'first', TRUE),
('EK521', '2A', 2, 'A', 'first', TRUE),
('EK521', '2B', 2, 'B', 'first', TRUE),
('EK521', '5A', 5, 'A', 'business', TRUE),
('EK521', '5B', 5, 'B', 'business', TRUE),
('EK521', '5C', 5, 'C', 'business', TRUE),
('EK521', '5D', 5, 'D', 'business', TRUE),
('EK521', '6A', 6, 'A', 'business', TRUE),
('EK521', '6B', 6, 'B', 'business', TRUE),
('EK521', '6C', 6, 'C', 'business', TRUE),
('EK521', '6D', 6, 'D', 'business', TRUE),
('EK521', '15A', 15, 'A', 'economy', TRUE),
('EK521', '15B', 15, 'B', 'economy', TRUE),
('EK521', '15C', 15, 'C', 'economy', TRUE),
('EK521', '15D', 15, 'D', 'economy', TRUE),
('EK521', '15E', 15, 'E', 'economy', TRUE),
('EK521', '15F', 15, 'F', 'economy', TRUE),
-- 继续为其他航班添加座位数据...
-- 航班 LH430 (Lufthansa)
('LH430', '1A', 1, 'A', 'first', TRUE),
('LH430', '1B', 1, 'B', 'first', TRUE),
('LH430', '1C', 1, 'C', 'first', TRUE),
('LH430', '1D', 1, 'D', 'first', TRUE),
('LH430', '4A', 4, 'A', 'business', TRUE),
('LH430', '4B', 4, 'B', 'business', TRUE),
('LH430', '4C', 4, 'C', 'business', TRUE),
('LH430', '4D', 4, 'D', 'business', TRUE),
('LH430', '8A', 8, 'A', 'economy', TRUE),
('LH430', '8B', 8, 'B', 'economy', TRUE),
('LH430', '8C', 8, 'C', 'economy', TRUE),
('LH430', '8D', 8, 'D', 'economy', TRUE),
('LH430', '8E', 8, 'E', 'economy', TRUE),
('LH430', '8F', 8, 'F', 'economy', TRUE),
-- 航班 SQ305 (Singapore Airlines)
('SQ305', '1A', 1, 'A', 'first', TRUE),
('SQ305', '1B', 1, 'B', 'first', TRUE),
('SQ305', '2A', 2, 'A', 'first', TRUE),
('SQ305', '2B', 2, 'B', 'first', TRUE),
('SQ305', '5A', 5, 'A', 'business', TRUE),
('SQ305', '5B', 5, 'B', 'business', TRUE),
('SQ305', '5C', 5, 'C', 'business', TRUE),
('SQ305', '5D', 5, 'D', 'business', TRUE),
('SQ305', '10A', 10, 'A', 'economy', TRUE),
('SQ305', '10B', 10, 'B', 'economy', TRUE),
('SQ305', '10C', 10, 'C', 'economy', TRUE),
('SQ305', '10D', 10, 'D', 'economy', TRUE),
('SQ305', '10E', 10, 'E', 'economy', TRUE),
('SQ305', '10F', 10, 'F', 'economy', TRUE);
# 订单表
CREATE TABLE orders
(
order_id VARCHAR(50) PRIMARY KEY, # 订单号
passenger_id VARCHAR(18) NOT NULL, # 乘客id
flight_id VARCHAR(20) NOT NULL, # 航班号
seat_id INT NOT NULL, # 关联座位表
food_name VARCHAR(100), # 食物名称
notes TEXT, # 备注信息
boarding_status BOOLEAN DEFAULT FALSE, # 登机状态
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, # 创建时间
FOREIGN KEY (passenger_id) REFERENCES passengers (id_card), # 外键
FOREIGN KEY (flight_id) REFERENCES flights (flight_id), # 外键
FOREIGN KEY (seat_id) REFERENCES flight_seats (seat_id) # 外键
);
-- 初始化所有乘客均未登机
update orders set boarding_status = FALSE;
-- 删除座位外键约束
alter table orders drop foreign key orders_ibfk_3;
-- 修改座位可为null值
alter table orders modify seat_id int NULL;
-- 重新添加外键
alter table orders add constraint fk_orders_seat foreign key (seat_id) references flight_seats(seat_id);
update orders set seat_id = null;
INSERT INTO orders (order_id, passenger_id, flight_id, seat_id, food_name, notes, boarding_status) VALUES
-- 张三的订单
('ORD20240320001', '110101199001011234', 'CA123', 1, '牛肉饭', '需要毛毯', TRUE),
('ORD20240320002', '110101199001011234', 'UA789', 2, '素食餐', '靠窗座位偏好', FALSE),
-- 李四的订单
('ORD20240320003', '110101199002022345', 'EK521', 3, '鸡肉面', '生日特别服务', FALSE),
('ORD20240320004', '110101199002022345', 'LH430', 4, '海鲜餐', '过敏:花生', TRUE),
-- 王五的订单
('ORD20240320005', '110101199003033456', 'SQ305', 5, '儿童餐', '带婴儿旅行', TRUE),
('ORD20240320006', '110101199003033456', 'BA117', 6, '糖尿病餐', '需要胰岛素冷藏', FALSE),
-- 赵六的订单
('ORD20240320007', '110101199004044567', 'AF385', 10, '普通餐', '第一次飞行', TRUE),
('ORD20240320008', '110101199004044567', 'JL065', 15, '牛肉饭', '无特殊要求', FALSE),
-- 钱七的订单
('ORD20240320009', '110101199005055678', 'DL289', 20, '素食餐', 'VIP服务', TRUE),
('ORD20240320010', '110101199005055678', 'CX831', 21, '低盐餐', '心脏病人', TRUE),
-- 孙八的订单
('ORD20240320011', '110101199006066789', 'QF2', 22, '海鲜餐', '庆祝纪念日', FALSE),
('ORD20240320012', '110101199006066789', 'KL887', 33, '鸡肉面', '中转航班', TRUE),
-- 周九的订单
('ORD20240320013', '110101199007077890', 'EY451', 43, '水果拼盘', '减肥餐', FALSE),
('ORD20240320014', '110101199007077890', 'TK15', 44, '牛肉饭', '商务会议材料', TRUE),
-- 吴十的订单
('ORD20240320015', '110101199008088901', 'AA125', 56, '普通餐', '无特殊要求', FALSE),
('ORD20240320016', '110101199008088901', 'NZ5', 57, '儿童餐', '带儿童旅行', TRUE),
-- 郑十一的订单
('ORD20240320017', '110101199009099012', 'BR87', 58, '糖尿病餐', '需要医疗协助', TRUE),
('ORD20240320018', '110101199009099012', 'LH730', 59, '素食餐', 'VIP通道', TRUE),
-- 王十二的订单
('ORD20240320019', '110101199010101123', 'SQ25', 60, '低脂餐', '健身饮食', FALSE),
('ORD20240320020', '110101199010101123', 'UA863', 61, '海鲜餐', '过敏:贝类', TRUE),
-- 额外的订单,展示更多航班组合
('ORD20240320021', '110101199001011234', 'EK521', 62, '牛肉饭', '回程航班', FALSE),
('ORD20240320022', '110101199003033456', 'UA789', 63, '普通餐', '公司出差', TRUE),
('ORD20240320023', '110101199005055678', 'CA123', 71, '素食餐', '环保旅行', TRUE),
('ORD20240320024', '110101199007077890', 'SQ305', 72, '糖尿病餐', '定期检查', FALSE),
('ORD20240320025', '110101199009099012', 'LH430', 73, '海鲜餐', '蜜月旅行', TRUE);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

Before

Width:  |  Height:  |  Size: 500 KiB

After

Width:  |  Height:  |  Size: 500 KiB

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Before

Width:  |  Height:  |  Size: 263 KiB

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before

Width:  |  Height:  |  Size: 491 KiB

After

Width:  |  Height:  |  Size: 491 KiB

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Before

Width:  |  Height:  |  Size: 808 B

After

Width:  |  Height:  |  Size: 808 B

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Before

Width:  |  Height:  |  Size: 561 KiB

After

Width:  |  Height:  |  Size: 561 KiB

Before

Width:  |  Height:  |  Size: 245 KiB

After

Width:  |  Height:  |  Size: 245 KiB

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 180 KiB

Before

Width:  |  Height:  |  Size: 146 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

Before

Width:  |  Height:  |  Size: 510 KiB

After

Width:  |  Height:  |  Size: 510 KiB

Before

Width:  |  Height:  |  Size: 266 KiB

After

Width:  |  Height:  |  Size: 266 KiB

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

@ -1 +1 @@
1326854870744 1327854870744 1326854870743 1326854870745 1326854870746 1326854870747 1326854870748 1326854870749 1316854870545 1316854870544 123 1326854870744 1327854870744 1326854870743 1326854870745 1326854870746 1326854870747 1326854870748 1326854870749 1316854870545 1316854870544

Before

Width:  |  Height:  |  Size: 349 KiB

After

Width:  |  Height:  |  Size: 349 KiB

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Before

Width:  |  Height:  |  Size: 566 KiB

After

Width:  |  Height:  |  Size: 566 KiB

Before

Width:  |  Height:  |  Size: 493 KiB

After

Width:  |  Height:  |  Size: 493 KiB

Before

Width:  |  Height:  |  Size: 306 KiB

After

Width:  |  Height:  |  Size: 306 KiB

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 189 KiB

@ -1,9 +0,0 @@
# MySQL修改日志
此文件记录添加数据库模块修改的文件详情方便后续调试以及修复bug。
1. Main_Frame文件 T649 -> T664 将引用的eachFlight.java切换为Flight.java类。
2. Confirm_Panel.java文件 T67 -> T76 读取航班信息文件改为读取数据库。
3. 修改Flights_Panel.java文件
4. 修改Seats_Panel.java文件
5. 修改文件Print_Panel.java
6. bug1用户选择座位时航班显示重复和错位。
7. bug2依旧是航班选择页面添加目的地图片。

@ -1,13 +0,0 @@
db.url=jdbc:mysql://localhost:3306/air_data?useSSL=false&serverTimezone=UTC&characterEncoding=utf8
db.username=root
db.password=830729tjf
db.driver=com.mysql.cj.jdbc.Driver
db.pool.maximumPoolSize=20
db.pool.minimumIdle=5
db.pool.connectionTimeout=30000
db.pool.idleTimeout=300000
db.pool.maxLifetime=1800000

@ -1,23 +1,8 @@
package constant; package constant;
/** /**
* Title : Constant.java * Title : Constant.java
* Description : 使 * Description : This class is a constant class.
* <p>
*
* 1.
* 2.
* 3. 便
* 使
* public static final访
*/ */
public class Constant { public class Constant {
//资源相对路径
public static String RESOURCE_PATH = "resource/"; public static String RESOURCE_PATH = "resource/";
/*
*/
private Constant() {
throw new AssertionError("工具类不应被实例化!");
}
} }

@ -1,24 +0,0 @@
package dao;
import model_new.Admin;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public interface AdminDao {
Optional<Admin> findById(String id); // 根据ID查找管理员对象
List<Admin> findAll(); // 获取所有管理员对象
boolean save(Admin admin); // 保存管理员信息
boolean update(Admin admin); // 修改管理员信息
boolean delete(String id); // 删除管理员信息
}

@ -1,32 +0,0 @@
package dao;
import model_new.Flight;
import model_new.User;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public interface FlightDao {
// 按航班号查找航班
Optional<Flight> findByFlightId(String FlightId);
// 查找所有航班
List<Flight> findAll();
// 增加航班信息
boolean save(Flight flight);
// 修改航班信息
boolean update(Flight flight);
// 删除某个航班
boolean delete(String FlightId);
// 检查某个航班是否存在
boolean existsByFlightId(String flightId);
}

@ -1,44 +0,0 @@
package dao;
import model_new.FlightSeat;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
* 访
*/
public interface FlightSeatDao {
// 基本CRUD操作
Optional<FlightSeat> findById(Integer seatId);
List<FlightSeat> findAll();
boolean save(FlightSeat seat);
boolean update(FlightSeat seat);
boolean delete(Integer seatId);
// 特定查询方法
List<FlightSeat> findByFlightId(String flightId);
List<FlightSeat> findAvailableSeatsByFlightId(String flightId);
// 根据航班和舱位等级查找
List<FlightSeat> findByFlightIdAndClass(String flightId, String seatClass);
// 根据航班ID和座位号查找
Optional<FlightSeat> findByFlightIdAndSeatNumber(String flightId, String seatNumber);
// 检查方法 - 检查航班ID和座位号存在性
boolean existsByFlightIdAndSeatNumber(String flightId, String seatNumber);
// 统计方法
// 根据航班ID统计可用座位
int countAvailableSeatsByFlightId(String flightId);
// 按航班ID统计总座位数
int countTotalSeatsByFlightId(String flightId);
// 批量操作方法
// 批量更新可用性
boolean batchUpdateAvailability(List<Integer> seatIds, Boolean isAvailable);
// 批量更新座位
boolean batchInsertSeats(List<FlightSeat> seats);
}

@ -1,49 +0,0 @@
package dao;
import model_new.Order;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public interface OrderDao {
// 1. 创建新订单
boolean save(Order order);
List<Order> findAll();
// 2. 根据订单ID查询订单
Optional<Order> findOrderById(String orderId);
// 3. 根据乘客身份证号查询所有订单
List<Order> findOrdersByPassengerId(String passengerId);
// 4. 根据航班号查询所有订单
List<Order> findOrdersByFlightId(String flightId);
// 5. 更新订单信息(食物、备注等)
int updateOrder(Order order);
// 6. 更新登机状态
int updateBoardingStatus(String orderId, boolean boardingStatus);
// 7. 删除订单
int deleteOrder(String orderId);
// 8. 根据座位号和航班号查询订单(检查座位是否被占用)
Order findOrderBySeatAndFlight(int seatId, String flightId);
// 9. 统计某个航班的订单数量
int countOrdersByFlightId(String flightId);
// 10. 获取某个乘客的VIP订单
List<Order> findVipOrdersByPassengerId(String passengerId);
// 12. 根据创建时间范围查询订单
List<Order> findOrdersByCreateTimeRange(Date startTime, Date endTime);
}

@ -1,30 +0,0 @@
package dao;
import model_new.Passenger;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public interface PassengerDao {
// 根据身份证号查找乘客
Optional<Passenger> findById(String id_card); // 根据ID查找管理员对象
// 查找所有乘客对象
List<Passenger> findAll(); // 获取所有管理员对象
// 添加乘客
boolean save(Passenger passenger); // 保存管理员信息
// 修改乘客信息
boolean update(Passenger passenger); // 修改管理员信息
// 删除乘客
boolean delete(String id_card); // 删除管理员信息
}

@ -1,20 +0,0 @@
package dao;
import model_new.User;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public interface UserDao {
Optional<User> findById(Integer id);
List<User> findAll();
boolean save(User user);
boolean update(User user);
boolean delete(Integer id);
Optional<User> findByUsername(String username);
boolean existsByUsername(String username);
}

@ -1,174 +0,0 @@
package dao.impl;
import dao.AdminDao;
import model_new.Admin;
import utils.DatabaseUtil;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public class AdminDaoImpl implements AdminDao {
/**
* ID
* @param id String
* @return Optional<Admin>
*
*/
@Override
public Optional<Admin> findById(String id) {
String sql = "SELECT * FROM admins WHERE admin_id = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, id);
ResultSet rs = pstmt.executeQuery();
// 如果连接池里面有对象我们封装到Optional容器中
if (rs.next()) {
return Optional.of(mapResultSetToAdmin(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
// 为什么返回容器传统方法是返回null值调用方稍有不慎就会空指针异常
// 这里封装到容器就会避免这种情况
return Optional.empty();
}
/**
*
* @return List<Admin>
*/
@Override
public List<Admin> findAll() {
// 创建用户列表用于存储查询结果
List<Admin> list = new ArrayList<>();
// 定义查询所有用户的SQL语句按ID排序
String sql = "select * from admins order by admin_id";
// 异常检测
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
Statement stmt = conn.createStatement(); // 创建Statement对象
ResultSet rs = stmt.executeQuery(sql) // 执行查询并获取结果集
) {
while (rs.next()) {
list.add(mapResultSetToAdmin(rs)); // 添加Admin对象到链表
}
} catch (SQLException e) {
// 打印数据库异常信息
e.printStackTrace();
}
return list;
}
/**
*
* @param admin Admin
* @return boolean
*/
@Override
public boolean save(Admin admin) {
String sql = "INSERT INTO admins (admin_id, username, password_hash) VALUES (?, ?, ?)";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, admin.getAdmin_id());
pstmt.setString(2, admin.getUsername());
pstmt.setString(3, admin.getPassword());
int affectedRows = pstmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
@Override
public boolean update(Admin admin) {
String sql = "UPDATE admins SET username = ?, password_hash = ? WHERE admin_id = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, admin.getUsername());
pstmt.setString(2, admin.getPassword());
pstmt.setString(3, admin.getAdmin_id());
int affectedRows = pstmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
@Override
public boolean delete(String id) {
String sql = "DELETE FROM admins WHERE admin_id = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, id);
int affectedRows = pstmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
* ResultSetUser
*
* @param rs
* @return User
* @throws SQLException 访
* <p>
*
* 1.
* 2.
*/
private Admin mapResultSetToAdmin(ResultSet rs) throws SQLException {
Admin admin = new Admin();
admin.setAdmin_id(rs.getString("admin_id"));
admin.setPassword(rs.getString("password_hash"));
admin.setUsername(rs.getString("username"));
admin.setCreated_at(rs.getTimestamp("created_at"));
return admin;
}
}

@ -1,241 +0,0 @@
package dao.impl;
import dao.FlightDao;
import model_new.Flight;
import utils.DatabaseUtil;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public class FlightDaoImpl implements FlightDao {
/**
* ID
* @param FlightId
* @return
*/
@Override
public Optional<Flight> findByFlightId(String FlightId) {
// 定义查询SQL语句使用占位符?防止SQL注入
String sql = "SELECT * FROM flights WHERE flight_id = ?";
// 使用try-with-resources自动管理数据库资源确保连接、语句和结果集被正确关闭
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
PreparedStatement stmt = conn.prepareStatement(sql) // 创建预编译语句
) {
// 设置查询参数:将第一个占位符?替换为实际用户的ID
stmt.setString(1, FlightId);
// 执行查询并获取结果集
ResultSet rs = stmt.executeQuery();
// 检查结果集是否有数据
if (rs.next()) {
// 如果有数据将ResultSet映射为User对象并包装在Optional中返回
return Optional.of(mapResultSetToFlight(rs));
}
} catch (SQLException e) {
// 记录数据库操作异常实际项目中应该使用日志框架而不是printStackTrace
e.printStackTrace();
}
// 如果没有找到用户返回空的Optional对象
return Optional.empty();
}
@Override
public List<Flight> findAll() {
// 创建用户列表用于存储查询结果
List<Flight> flights = new ArrayList<>();
// 定义查询所有用户的SQL语句按ID排序
String sql = "SELECT * FROM flights ORDER BY flight_id";
// 使用try-with-resources自动管理数据库资源
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
Statement stmt = conn.createStatement(); // 创建Statement对象
ResultSet rs = stmt.executeQuery(sql) // 执行查询并获取结果集
) {
// 遍历结果集中所有记录
while (rs.next()) {
// 将每条记录转换为User对象并添加到列表中
flights.add(mapResultSetToFlight(rs));
}
} catch (SQLException e) {
// 处理数据库异常
e.printStackTrace();
}
// 返回用户列表,可能为空
return flights;
}
/**
*
* @param flight
* @return
*/
@Override
public boolean save(Flight flight) {
String sql = "INSERT INTO flights (flight_id, airline_company, departure_location, " +
"destination_location, departure_time, arrival_time, boarding_time, " +
"gate, delay_status, destination_image) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
// 设置参数
stmt.setString(1, flight.getFlight_id());
stmt.setString(2, flight.getAirline_company());
stmt.setString(3, flight.getDeparture_location());
stmt.setString(4, flight.getDestination_location());
stmt.setTimestamp(5, new Timestamp(flight.getDeparture_time().getTime()));
stmt.setTimestamp(6, new Timestamp(flight.getArrival_time().getTime()));
stmt.setTimestamp(7, new Timestamp(flight.getBoarding_time().getTime()));
stmt.setString(8, flight.getGate());
stmt.setString(9, flight.getDelay_status());
stmt.setString(10, flight.getDestination_image());
int affectedRows = stmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
*
* @param flight
* @return
*/
@Override
public boolean update(Flight flight) {
String sql = "UPDATE flights SET " +
"airline_company = ?, " +
"departure_location = ?, " +
"destination_location = ?, " +
"departure_time = ?, " +
"arrival_time = ?, " +
"boarding_time = ?, " +
"gate = ?, " +
"delay_status = ?, " +
"destination_image = ? " +
"WHERE flight_id = ?";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
// 设置参数
stmt.setString(1, flight.getAirline_company());
stmt.setString(2, flight.getDeparture_location());
stmt.setString(3, flight.getDestination_location());
stmt.setTimestamp(4, new Timestamp(flight.getDeparture_time().getTime()));
stmt.setTimestamp(5, new Timestamp(flight.getArrival_time().getTime()));
stmt.setTimestamp(6, new Timestamp(flight.getBoarding_time().getTime()));
stmt.setString(7, flight.getGate());
stmt.setString(8, flight.getDelay_status());
stmt.setString(9, flight.getDestination_image());
stmt.setString(10, flight.getFlight_id());
int affectedRows = stmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
*
* @param flightId
* @return
*/
@Override
public boolean delete(String flightId) {
String sql = "DELETE FROM flights WHERE flight_id = ?";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setString(1, flightId);
int affectedRows = stmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
*
* @param flightId
* @return
*/
@Override
public boolean existsByFlightId(String flightId) {
String sql = "SELECT 1 FROM flights WHERE flight_id = ?";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setString(1, flightId);
ResultSet rs = stmt.executeQuery();
return rs.next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
private Flight mapResultSetToFlight(ResultSet rs) throws SQLException {
Flight flight = new Flight();
flight.setFlight_id(rs.getString("flight_id"));
flight.setAirline_company(rs.getString("airline_company"));
flight.setDeparture_location(rs.getString("departure_location"));
flight.setDestination_location(rs.getString("destination_location"));
flight.setDeparture_time(rs.getTimestamp("departure_time"));
flight.setArrival_time(rs.getTimestamp("arrival_time"));
flight.setBoarding_time(rs.getTimestamp("boarding_time"));
flight.setGate(rs.getString("gate"));
flight.setDelay_status(rs.getString("delay_status"));
flight.setDestination_image(rs.getString("destination_image"));
flight.setCreated_at(rs.getTimestamp("created_at"));
return flight;
}
}

@ -1,377 +0,0 @@
package dao.impl;
import dao.FlightSeatDao;
import model_new.FlightSeat;
import utils.DatabaseUtil;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
* 访
*/
public class FlightSeatDaoImpl implements FlightSeatDao {
@Override
public Optional<FlightSeat> findById(Integer seatId) {
String sql = "SELECT * FROM flight_seats WHERE seat_id = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, seatId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
return Optional.of(mapResultSetToFlightSeat(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return Optional.empty();
}
@Override
public List<FlightSeat> findAll() {
List<FlightSeat> seats = new ArrayList<>();
String sql = "SELECT * FROM flight_seats ORDER BY seat_id";
try (Connection conn = DatabaseUtil.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql)) {
while (rs.next()) {
seats.add(mapResultSetToFlightSeat(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return seats;
}
@Override
public boolean save(FlightSeat seat) {
String sql = "INSERT INTO flight_seats (flight_id, seat_number, seat_row, seat_column, seat_class, is_available) " +
"VALUES (?, ?, ?, ?, ?, ?)";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
stmt.setString(1, seat.getFlight_id());
stmt.setString(2, seat.getSeat_number());
stmt.setInt(3, seat.getSeat_row());
stmt.setString(4, String.valueOf(seat.getSeat_column()));
stmt.setString(5, seat.getSeat_class());
stmt.setBoolean(6, seat.isIs_available());
int affectedRows = stmt.executeUpdate();
// 获取自增主键
if (affectedRows > 0) {
try (ResultSet generatedKeys = stmt.getGeneratedKeys()) {
if (generatedKeys.next()) {
seat.setSeat_id(generatedKeys.getInt(1)); // 将座位编号传回座位对象
}
}
}
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean update(FlightSeat seat) {
String sql = "UPDATE flight_seats SET flight_id = ?, seat_number = ?, seat_row = ?, " +
"seat_column = ?, seat_class = ?, is_available = ? WHERE seat_id = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, seat.getFlight_id());
stmt.setString(2, seat.getSeat_number());
stmt.setInt(3, seat.getSeat_row());
stmt.setString(4, String.valueOf(seat.getSeat_column()));
stmt.setString(5, seat.getSeat_class());
stmt.setBoolean(6, seat.isIs_available());
stmt.setInt(7, seat.getSeat_id());
// 获取修改的行数
int affectedRows = stmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean delete(Integer seatId) {
String sql = "DELETE FROM flight_seats WHERE seat_id = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, seatId);
int affectedRows = stmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
@Override
public List<FlightSeat> findByFlightId(String flightId) {
List<FlightSeat> seats = new ArrayList<>();
String sql = "SELECT * FROM flight_seats WHERE flight_id = ? ORDER BY seat_row, seat_column";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, flightId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
seats.add(mapResultSetToFlightSeat(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return seats;
}
public List<FlightSeat> findAvailableSeatsByFlightId(String flightId) {
List<FlightSeat> seats = new ArrayList<>();
String sql = "SELECT * FROM flight_seats WHERE flight_id = ? AND is_available = TRUE ORDER BY seat_row, seat_column";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, flightId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
seats.add(mapResultSetToFlightSeat(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return seats;
}
@Override
public List<FlightSeat> findByFlightIdAndClass(String flightId, String seatClass) {
List<FlightSeat> seats = new ArrayList<>();
String sql = "SELECT * FROM flight_seats WHERE flight_id = ? AND seat_class = ? ORDER BY seat_row, seat_column";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, flightId);
stmt.setString(2, seatClass);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
seats.add(mapResultSetToFlightSeat(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return seats;
}
@Override
public Optional<FlightSeat> findByFlightIdAndSeatNumber(String flightId, String seatNumber) {
String sql = "SELECT * FROM flight_seats WHERE flight_id = ? AND seat_number = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, flightId);
stmt.setString(2, seatNumber);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
return Optional.of(mapResultSetToFlightSeat(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return Optional.empty();
}
@Override
public boolean existsByFlightIdAndSeatNumber(String flightId, String seatNumber) {
String sql = "SELECT 1 FROM flight_seats WHERE flight_id = ? AND seat_number = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, flightId);
stmt.setString(2, seatNumber);
ResultSet rs = stmt.executeQuery();
return rs.next();
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public int countAvailableSeatsByFlightId(String flightId) {
String sql = "SELECT COUNT(*) FROM flight_seats WHERE flight_id = ? AND is_available = TRUE";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, flightId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
return rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public int countTotalSeatsByFlightId(String flightId) {
String sql = "SELECT COUNT(*) FROM flight_seats WHERE flight_id = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, flightId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
return rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public boolean batchUpdateAvailability(List<Integer> seatIds, Boolean isAvailable) {
if (seatIds == null || seatIds.isEmpty()) {
return true;
}
// 构建IN子句的占位符
StringBuilder placeholders = new StringBuilder();
for (int i = 0; i < seatIds.size(); i++) {
placeholders.append("?");
if (i < seatIds.size() - 1) {
placeholders.append(",");
}
}
String sql = "UPDATE flight_seats SET is_available = ? WHERE seat_id IN (" + placeholders + ")";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setBoolean(1, isAvailable);
for (int i = 0; i < seatIds.size(); i++) {
stmt.setInt(i + 2, seatIds.get(i));
}
int affectedRows = stmt.executeUpdate();
return affectedRows > 0;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
@Override
public boolean batchInsertSeats(List<FlightSeat> seats) {
if (seats == null || seats.isEmpty()) {
return true;
}
String sql = "INSERT INTO flight_seats (flight_id, seat_number, seat_row, seat_column, seat_class, is_available) " +
"VALUES (?, ?, ?, ?, ?, ?)";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
for (FlightSeat seat : seats) {
stmt.setString(1, seat.getFlight_id());
stmt.setString(2, seat.getSeat_number());
stmt.setInt(3, seat.getSeat_row());
stmt.setString(4, String.valueOf(seat.getSeat_column()));
stmt.setString(5, seat.getSeat_class());
stmt.setBoolean(6, seat.isIs_available());
stmt.addBatch();
}
int[] results = stmt.executeBatch();
// 获取生成的主键
try (ResultSet generatedKeys = stmt.getGeneratedKeys()) {
int index = 0;
while (generatedKeys.next() && index < seats.size()) {
seats.get(index).setSeat_id(generatedKeys.getInt(1));
index++;
}
}
return results.length == seats.size();
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
/**
* ResultSetFlightSeat
*/
private FlightSeat mapResultSetToFlightSeat(ResultSet rs) throws SQLException {
FlightSeat seat = new FlightSeat();
seat.setSeat_id(rs.getInt("seat_id"));
seat.setFlight_id(rs.getString("flight_id"));
seat.setSeat_number(rs.getString("seat_number"));
seat.setSeat_row(rs.getInt("seat_row"));
seat.setSeat_column(rs.getString("seat_column").charAt(0)); // 获取第一个字符即可
seat.setSeat_class(rs.getString("seat_class"));
seat.setIs_available(rs.getBoolean("is_available"));
return seat;
}
}

@ -1,399 +0,0 @@
package dao.impl;
import dao.OrderDao;
import model_new.Order;
import model_new.User;
import utils.DatabaseUtil;
import java.sql.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public class OrderDaoImpl implements OrderDao {
// 1. 创建新订单
@Override
public boolean save(Order order) {
// 定义插入SQL语句
String sql = "INSERT INTO orders (" +
"order_id," +
"passenger_id," +
"flight_id," +
"seat_id," +
"food_name," +
"notes," +
"boarding_status" +
") VALUES (?, ?, ?, ?, ?, ?, ?)";
// 使用try-with-resources自动管理数据库资源
try (
Connection conn = DatabaseUtil.getConnection();
// 创建PreparedStatement并指定需要返回自动生成的键
PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)
) {
// 设置插入参数传入的值需要是String类型
stmt.setString(1, order.getOrder_id());
stmt.setString(2, order.getPassenger_id());
stmt.setString(3, order.getFlight_id());
stmt.setString(4, String.valueOf(order.getSeat_id()));
stmt.setString(5, order.getFood_name());
stmt.setString(6, order.getNotes());
stmt.setString(7, String.valueOf(order.isBoarding_status()));
// 执行插入操作,返回受影响的行数
int affectedRows = stmt.executeUpdate();
// 检查插入是否成功
if (affectedRows > 0) {
return true;
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
@Override
public List<Order> findAll() {
// 创建用户列表用于存储查询结果
List<Order> orders = new ArrayList<>();
// 定义查询所有用户的SQL语句按ID排序
String sql = "SELECT * FROM orders ORDER BY order_id";
// 使用try-with-resources自动管理数据库资源
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
Statement stmt = conn.createStatement(); // 创建Statement对象
ResultSet rs = stmt.executeQuery(sql) // 执行查询并获取结果集
) {
// 遍历结果集中所有记录
while (rs.next()) {
// 将每条记录转换为User对象并添加到列表中
orders.add(mapResultSetToOrder(rs));
}
} catch (SQLException e) {
// 处理数据库异常
e.printStackTrace();
}
// 返回用户列表,可能为空
return orders;
}
// 通过订单号查询订单,唯一一个订单
@Override
public Optional<Order> findOrderById(String orderId) {
// 定义查询SQL语句使用占位符?防止SQL注入
String sql = "SELECT * FROM orders WHERE order_id = ?";
// 使用try-with-resources自动管理数据库资源确保连接、语句和结果集被正确关闭
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
PreparedStatement stmt = conn.prepareStatement(sql) // 创建预编译语句
) {
// 设置查询参数:将第一个占位符?替换为实际用户的ID
stmt.setString(1, orderId);
// 执行查询并获取结果集
ResultSet rs = stmt.executeQuery();
// 检查结果集是否有数据
if (rs.next()) {
// 如果有数据将ResultSet映射为User对象并包装在Optional中返回
return Optional.of(mapResultSetToOrder(rs));
}
} catch (SQLException e) {
// 记录数据库操作异常
e.printStackTrace();
}
// 如果没有找到用户返回空的Optional对象
return Optional.empty();
}
// 通过乘客ID查询订单可能有多个订单
@Override
public List<Order> findOrdersByPassengerId(String passengerId) {
List<Order> orders = new ArrayList<>();
// 定义查询SQL语句使用占位符?防止SQL注入
String sql = "SELECT * FROM orders WHERE passenger_id = ?";
// 使用try-with-resources自动管理数据库资源确保连接、语句和结果集被正确关闭
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
PreparedStatement stmt = conn.prepareStatement(sql) // 创建预编译语句
) {
// 设置查询参数:将第一个占位符?替换为实际用户的ID
stmt.setString(1, passengerId);
// 执行查询并获取结果集
ResultSet rs = stmt.executeQuery();
// 检查结果集是否有数据
while (rs.next()) {
orders.add(mapResultSetToOrder(rs));
}
} catch (SQLException e) {
// 记录数据库操作异常实际项目中应该使用日志框架而不是printStackTrace
e.printStackTrace();
}
// 如果没有找到用户返回空的Optional对象
return orders;
}
// 通过航班号查询订单,通常管理员操作
@Override
public List<Order> findOrdersByFlightId(String flightId) {
// 创建用户列表用于存储查询结果
List<Order> orders = new ArrayList<>();
// 定义查询所有用户的SQL语句按ID排序
String sql = "SELECT * FROM orders where flight_id = ?";
// 使用try-with-resources自动管理数据库资源
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
PreparedStatement stmt = conn.prepareStatement(sql) // 创建预编译语句
) {
stmt.setString(1, flightId);
// 遍历结果集中所有记录
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
orders.add(mapResultSetToOrder(rs));
}
} catch (SQLException e) {
// 处理数据库异常
e.printStackTrace();
}
// 返回用户列表,可能为空
return orders;
}
// 修改订单信息,例如登机状态等,通常乘客和管理员都可调用
@Override
public int updateOrder(Order order) {
String sql = "UPDATE orders SET seat_id = ?, " +
"food_name = ?, notes = ?, boarding_status = ? WHERE order_id = ?";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setInt(1, order.getSeat_id());
stmt.setString(2, order.getFood_name());
stmt.setString(3, order.getNotes());
stmt.setBoolean(4, order.isBoarding_status());
stmt.setString(5, order.getOrder_id());
// 返回更改了多少行
return stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
// 修改订单的登机状态
@Override
public int updateBoardingStatus(String orderId, boolean boardingStatus) {
String sql = "UPDATE orders SET boarding_status = ? WHERE order_id = ?";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setBoolean(1, boardingStatus);
stmt.setString(2, orderId);
// 返回多少行受影响
return stmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
// 删除订单
@Override
public int deleteOrder(String orderId) {
String sql = "DELETE FROM orders WHERE order_id = ?";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setString(1, orderId);
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
// 根据座位号和航班号查询订单
@Override
public Order findOrderBySeatAndFlight(int seatId, String flightId) {
String sql = "SELECT * FROM orders WHERE seat_id = ? AND flight_id = ?";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setInt(1, seatId);
stmt.setString(2, flightId);
// 获取结果集
ResultSet rs = stmt.executeQuery();
// 是否有数据
if (rs.next()) {
return mapResultSetToOrder(rs);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 统计某个航班的订单数量
@Override
public int countOrdersByFlightId(String flightId) {
String sql = "SELECT COUNT(*) FROM orders WHERE flight_id = ?";
// 使用try进行数据库的连接
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setString(1, flightId);
// 获取查询结果集
ResultSet rs = stmt.executeQuery();
// 判断结果集是否有数据
if (rs.next()) {
// 返回第一个数据
return rs.getInt(1);
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
// 查看VIP乘客的订单
@Override
public List<Order> findVipOrdersByPassengerId(String passengerId) {
List<Order> orders = new ArrayList<>();
String sql = "SELECT o.* FROM orders o " +
"JOIN passengers p ON o.passenger_id = p.id_card " +
"WHERE o.passenger_id = ? AND p.is_vip = TRUE " +
"ORDER BY o.created_at DESC";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setString(1, passengerId);
ResultSet rs = stmt.executeQuery();
// 遍历查询结果
while (rs.next()) {
orders.add(mapResultSetToOrder(rs));
}
} catch (Exception e) {
e.printStackTrace();
}
return orders;
}
// 根据创建时间范围查询订单
@Override
public List<Order> findOrdersByCreateTimeRange(Date startTime, Date endTime) {
List<Order> orders = new ArrayList<>();
String sql = "SELECT * FROM orders WHERE created_at BETWEEN ? AND ? ORDER BY created_at DESC";
try (
Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)
) {
stmt.setTimestamp(1, new Timestamp(startTime.getTime()));
stmt.setTimestamp(2, new Timestamp(endTime.getTime()));
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
orders.add(mapResultSetToOrder(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return orders;
}
private Order mapResultSetToOrder(ResultSet rs) throws SQLException {
Order order = new Order();
order.setOrder_id(rs.getString("order_id"));
order.setPassenger_id(rs.getString("passenger_id"));
order.setFlight_id(rs.getString("flight_id"));
order.setSeat_id(rs.getInt("seat_id"));
order.setFood_name(rs.getString("food_name"));
order.setNotes(rs.getString("notes"));
order.setBoarding_status(rs.getBoolean("boarding_status"));
order.setCreated_at(rs.getTimestamp("created_at"));
return order;
}
}

@ -1,101 +0,0 @@
package dao.impl;
import dao.PassengerDao;
import model_new.Passenger;
import utils.DatabaseUtil;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @author
* @version 1.0
*/
public class PassengerDaoImpl implements PassengerDao {
@Override
public Optional<Passenger> findById(String id_card) {
// 定义查询SQL语句使用占位符?防止SQL注入
String sql = "SELECT * FROM passengers WHERE id_card = ?";
// 使用try-with-resources自动管理数据库资源确保连接、语句和结果集被正确关闭
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
PreparedStatement stmt = conn.prepareStatement(sql) // 创建预编译语句
) {
// 设置查询参数:将第一个占位符?替换为实际用户的ID
stmt.setString(1, id_card);
// 执行查询并获取结果集
ResultSet rs = stmt.executeQuery();
// 检查结果集是否有数据
if (rs.next()) {
// 如果有数据将ResultSet映射为User对象并包装在Optional中返回
return Optional.of(mapResultSetToPassenger(rs));
}
} catch (SQLException e) {
// 记录数据库操作异常实际项目中应该使用日志框架而不是printStackTrace
e.printStackTrace();
}
// 如果没有找到乘客,则返回空
return Optional.empty();
}
@Override
public List<Passenger> findAll() {
// 创建用户列表用于存储查询结果
List<Passenger> list = new ArrayList<>();
// 定义查询所有用户的SQL语句按ID排序
String sql = "select * from passengers order by id_card";
// 异常检测
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
Statement stmt = conn.createStatement(); // 创建Statement对象
ResultSet rs = stmt.executeQuery(sql) // 执行查询并获取结果集
) {
while (rs.next()) {
list.add(mapResultSetToPassenger(rs));
}
} catch (SQLException e) {
// 打印数据库异常信息
e.printStackTrace();
}
return list;
}
@Override
public boolean save(Passenger passenger) {
return false;
}
@Override
public boolean update(Passenger passenger) {
return false;
}
@Override
public boolean delete(String id_card) {
return false;
}
private Passenger mapResultSetToPassenger(ResultSet rs) throws SQLException {
Passenger passenger = new Passenger();
passenger.setId_card(rs.getString("id_card"));
passenger.setName(rs.getString("name"));
passenger.setIs_vip(rs.getBoolean("is_vip"));
passenger.setCreated_at(rs.getTimestamp("created_at"));
return passenger;
}
}

@ -1,255 +0,0 @@
package dao.impl;
import dao.UserDao;
import model_new.User;
import utils.DatabaseUtil;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* UserDao
* usersCRUD
*
* @author
* @version 1.0
*/
public class UserDaoImpl implements UserDao {
/**
* ID
*
* @param id ID
* @return OptionalOptional
* <p>
*
* 1. 使PreparedStatementSQL
* 2. 使try-with-resources
* 3. 使Optionalnull
*/
@Override
public Optional<User> findById(Integer id) {
// 定义查询SQL语句使用占位符?防止SQL注入
String sql = "SELECT * FROM users WHERE id = ?";
// 使用try-with-resources自动管理数据库资源确保连接、语句和结果集被正确关闭
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
PreparedStatement stmt = conn.prepareStatement(sql) // 创建预编译语句
) {
// 设置查询参数:将第一个占位符?替换为实际用户的ID
stmt.setInt(1, id);
// 执行查询并获取结果集
ResultSet rs = stmt.executeQuery();
// 检查结果集是否有数据
if (rs.next()) {
// 如果有数据将ResultSet映射为User对象并包装在Optional中返回
return Optional.of(mapResultSetToUser(rs));
}
} catch (SQLException e) {
// 记录数据库操作异常实际项目中应该使用日志框架而不是printStackTrace
e.printStackTrace();
}
// 如果没有找到用户返回空的Optional对象
return Optional.empty();
}
/**
*
*
* @return List
* <p>
*
* 1. ID
* 2. 使Statement
*/
@Override
public List<User> findAll() {
// 创建用户列表用于存储查询结果
List<User> users = new ArrayList<>();
// 定义查询所有用户的SQL语句按ID排序
String sql = "SELECT * FROM users ORDER BY id";
// 使用try-with-resources自动管理数据库资源
try (
Connection conn = DatabaseUtil.getConnection(); // 获取数据库连接
Statement stmt = conn.createStatement(); // 创建Statement对象
ResultSet rs = stmt.executeQuery(sql) // 执行查询并获取结果集
) {
// 遍历结果集中所有记录
while (rs.next()) {
// 将每条记录转换为User对象并添加到列表中
users.add(mapResultSetToUser(rs));
}
} catch (SQLException e) {
// 处理数据库异常
e.printStackTrace();
}
// 返回用户列表,可能为空
return users;
}
/**
*
*
* @param user
* @return truefalse
*
*
* 1. ID
* 2. 使PreparedStatementSQL
* 3. Statement.RETURN_GENERATED_KEYS
*/
@Override
public boolean save(User user) {
// 定义插入SQL语句不包含id字段id是自增主键
String sql = "INSERT INTO users (username, password, email, phone) VALUES (?, ?, ?, ?)";
// 使用try-with-resources自动管理数据库资源
try (
Connection conn = DatabaseUtil.getConnection();
// 创建PreparedStatement并指定需要返回自动生成的键
PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)
) {
// 设置插入参数
stmt.setString(1, user.getUsername());
stmt.setString(2, user.getPassword());
stmt.setString(3, user.getEmail());
stmt.setString(4, user.getPhone());
// 执行插入操作,返回受影响的行数
int affectedRows = stmt.executeUpdate();
// 检查插入是否成功
if (affectedRows > 0) {
// 获取自动生成的主键用户ID
try (ResultSet generatedKeys = stmt.getGeneratedKeys()) {
if (generatedKeys.next()) {
// 将生成的主键设置回User对象
user.setId(generatedKeys.getInt(1));
}
}
return true;
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
*
*
* @param user
* @return truefalse
*
*
*/
@Override
public boolean update(User user) {
return false;
}
/**
* ID
*
* @param id ID
* @return truefalse
*
*
*/
@Override
public boolean delete(Integer id) {
return false;
}
/**
*
*
* @param username
* @return OptionalOptional
*
*
* 1.
* 2.
*/
@Override
public Optional<User> findByUsername(String username) {
String sql = "SELECT * FROM users WHERE username = ?";
try (Connection conn = DatabaseUtil.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, username);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
return Optional.of(mapResultSetToUser(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return Optional.empty();
}
/**
*
*
* @param username
* @return truefalse
*
*
*
*/
@Override
public boolean existsByUsername(String username) {
return false;
}
/**
* ResultSetUser
*
* @param rs
* @return User
* @throws SQLException 访
*
*
* 1.
* 2.
*/
private User mapResultSetToUser(ResultSet rs) throws SQLException {
User user = new User();
user.setId(rs.getInt("id"));
user.setUsername(rs.getString("username"));
user.setPassword(rs.getString("password"));
user.setEmail(rs.getString("email"));
user.setPhone(rs.getString("phone"));
user.setCreateTime(rs.getTimestamp("create_time"));
user.setUpdateTime(rs.getTimestamp("update_time"));
return user;
}
}

@ -2,156 +2,81 @@ package frame;
import frame.AdminPanel.Admin_Flights_Panel; import frame.AdminPanel.Admin_Flights_Panel;
import frame.AdminPanel.Admin_Information; import frame.AdminPanel.Admin_Information;
// 导入使用订单号登录的界面,在此文件中没有使用
import frame.UserPanel.Check_in_bookingNum_Panel; import frame.UserPanel.Check_in_bookingNum_Panel;
import model.*; import model.*;
import model_new.Admin;
import service.AdminService;
import service.FlightService;
import utils.BackGroundImagePanle; import utils.BackGroundImagePanle;
// 导入布局类,此文件中没有使用
import utils.MyLayout; import utils.MyLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
// 导入事件接口,但此文件中并未使用
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
/** /**
* Title : Admin_Frame.java * Title : Admin_Frame.java
* Description : * Description : This class is a template for building the administrator interface.
* <p>
*
* 1.
* 2.
* 3.
* 4.
* <p>
*
* 1.
* 2. 使
* 3.
* 4.
*/ */
public class Admin_Frame extends JFrame{ public class Admin_Frame extends JFrame{
/*
使
*/
public JPanel panelMiddle; public JPanel panelMiddle;
/*
0
1
2
3退
*/
public static int pageNumber=0; public static int pageNumber=0;
/*
*/
public static String IDnum=""; public static String IDnum="";
/*
false
true
*/
public static boolean flag; public static boolean flag;
/*
*/
String temp=null; String temp=null;
/*
1.
2.
3.
1. logo
2.
3.
*/
public static Admin admin_f = null;
public void build_Admin_Frame(){ public void build_Admin_Frame(){
// 创建主窗口
JFrame frameAdmin = new JFrame("Heathrow Admin"); JFrame frameAdmin = new JFrame("Heathrow Admin");
// 设置跨平台外观
try{ try{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }
// 设置窗口位置和大小
frameAdmin.setBounds(320,90,1200,900); frameAdmin.setBounds(320,90,1200,900);
// 禁止调整窗口大小
frameAdmin.setResizable(false); frameAdmin.setResizable(false);
//设置主布局为边布局 //设置布局
frameAdmin.setLayout(new BorderLayout()); frameAdmin.setLayout(new BorderLayout());
//设置上层panel
// ==================== 创建三个主要面板区域 ====================
// 顶部面板 - 用于显示logo和系统标题
JPanel panelTop = new JPanel(); JPanel panelTop = new JPanel();
panelTop.setBackground(new Color(96,62,151)); panelTop.setBackground(new Color(96,62,151));
//设置中层panel
// 中间面板 - 使用卡片布局实现页面切换
CardLayout cardLayout = new CardLayout(); CardLayout cardLayout = new CardLayout();
this.panelMiddle = new JPanel(cardLayout); this.panelMiddle = new JPanel(cardLayout);
//设置下层panel
// 底部面板 - 用于放置导航按钮
JPanel panelBottom = new JPanel(); JPanel panelBottom = new JPanel();
panelBottom.setBackground(new Color(96,62,151)); panelBottom.setBackground(new Color(96,62,151));
// ==================== 设置卡片布局页面 ==================== //设置卡片布局
// 主登录页面
JPanel main = new JPanel(); JPanel main = new JPanel();
main.setLayout(null); // 使用绝对布局 main.setLayout(null);
main.setBackground(new Color(72,46,115)); // 背景颜色 main.setBackground(new Color(72,46,115));
// 航班管理页面
Admin_Flights_Panel flights = new Admin_Flights_Panel(); Admin_Flights_Panel flights = new Admin_Flights_Panel();
temp = Admin_Flights_Panel.flight_num; // 获取航班号 temp = Admin_Flights_Panel.flight_num;
// 信息查看页面
Admin_Information Information = new Admin_Information(temp); Admin_Information Information = new Admin_Information(temp);
panelMiddle.add(main,"0");
panelMiddle.add(flights,"1");
panelMiddle.add(Information,"2");
// 将各个页面添加到卡片布局中
panelMiddle.add(main,"0"); // 主登录页面
panelMiddle.add(flights,"1"); // 航班管理页面
panelMiddle.add(Information,"2"); // 信息查看页面
// ==================== 将面板添加到主窗口 ====================
//添加三层panel至布局 //添加三层panel至布局
frameAdmin.add(panelTop,BorderLayout.NORTH); frameAdmin.add(panelTop,BorderLayout.NORTH);
frameAdmin.add(panelMiddle,BorderLayout.CENTER); frameAdmin.add(panelMiddle,BorderLayout.CENTER);
frameAdmin.add(panelBottom,BorderLayout.SOUTH); frameAdmin.add(panelBottom,BorderLayout.SOUTH);
// 设置各面板的尺寸 //设置布局位置
panelTop.setPreferredSize(new Dimension(1200,110)); panelTop.setPreferredSize(new Dimension(1200,110));
panelMiddle.setPreferredSize(new Dimension(1200,680)); panelMiddle.setPreferredSize(new Dimension(1200,680));
panelBottom.setPreferredSize(new Dimension(1200,110)); panelBottom.setPreferredSize(new Dimension(1200,110));
//设置顶层菜单布局
// ==================== 顶部面板设置 ====================
panelTop.setLayout(null); panelTop.setLayout(null);
//设置左上角logo //设置左上角logo
BackGroundImagePanle PanelLogo= new BackGroundImagePanle("logo_heathrow.png"); BackGroundImagePanle PanelLogo= new BackGroundImagePanle("logo_heathrow.png");
PanelLogo.setBounds(0,0,300,110); PanelLogo.setBounds(0,0,300,110);
panelTop.add(PanelLogo); panelTop.add(PanelLogo);
// 设置右上角系统标题 //设置右上角文字
JLabel jLabelAdmin = new JLabel("Administrator system"); JLabel jLabelAdmin = new JLabel("Administrator system");
jLabelAdmin.setFont(new Font (Font.DIALOG, Font.BOLD, 38)); jLabelAdmin.setFont(new Font (Font.DIALOG, Font.BOLD, 38));
jLabelAdmin.setForeground(Color.white);//设置文字的颜色 jLabelAdmin.setForeground(Color.white);//设置文字的颜色
@ -159,23 +84,19 @@ public class Admin_Frame extends JFrame{
panelTop.add(jLabelAdmin); panelTop.add(jLabelAdmin);
// ==================== 主登录页面组件设置 ====================
// 创建输入框(用于显示输入的账号/密码)
JTextField inputArea = new JTextField("", 30); JTextField inputArea = new JTextField("", 30);
//外观设计 //外观设计
inputArea.setBounds(284,105,632,50); // 设置位置和大小 inputArea.setBounds(284,105,632,50);
inputArea.setFont(new Font (Font.DIALOG,Font.BOLD, 40)); // 设置字体 inputArea.setFont(new Font (Font.DIALOG,Font.BOLD, 40));
inputArea.setHorizontalAlignment(JTextField.CENTER); // 文字居中 inputArea.setHorizontalAlignment(JTextField.CENTER);
inputArea.setForeground(Color.WHITE); // 白色文字 inputArea.setForeground(Color.WHITE);
inputArea.setBackground(new Color(72,46,115)); // 背景颜色 inputArea.setBackground(new Color(72,46,115));
inputArea.setEditable(false); // 禁止直接编辑 inputArea.setEditable(false);
inputArea.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); // 白色边框 inputArea.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 创建提示标签
JLabel BookingNumHint = new JLabel(""); JLabel BookingNumHint = new JLabel("");
// 根据登录状态设置不同的提示文字
if (!flag){ if (!flag){
BookingNumHint.setText("PLEASE ENTER THE ADMINISTRATOR ACCOUNT"); BookingNumHint.setText("PLEASE ENTER THE ADMINISTRATOR ACCOUNT");
}else { }else {
@ -183,16 +104,14 @@ public class Admin_Frame extends JFrame{
} }
BookingNumHint.setBounds(184,45,816,50); BookingNumHint.setBounds(184,45,816,50);
//外观设计 //外观设计
BookingNumHint.setFont(new Font(Font.DIALOG,Font.BOLD,29)); // 设置字体 BookingNumHint.setFont(new Font(Font.DIALOG,Font.BOLD,29));//设置文字字体
BookingNumHint.setForeground(Color.white); // 白色文字 BookingNumHint.setForeground(Color.white);//设置文字的颜色
BookingNumHint.setOpaque(true); // 设置透明 BookingNumHint.setOpaque(true);//设置透明效果
BookingNumHint.setBackground(new Color(72,46,115)); // 背景颜色 BookingNumHint.setBackground(new Color(72,46,115));//设置背景颜色
BookingNumHint.setPreferredSize(new Dimension(800,80));//设置长宽 BookingNumHint.setPreferredSize(new Dimension(800,80));//设置长宽
BookingNumHint.setHorizontalAlignment(JLabel.CENTER); // 文字居中 BookingNumHint.setHorizontalAlignment(JLabel.CENTER);//设置对齐方式
// ==================== 创建数字键盘按钮 ==================== //创建0-9和delete按钮
// 创建0-9 数字按钮和删除按钮
JButton button1 = new JButton("1"); JButton button1 = new JButton("1");
JButton button2 = new JButton("2"); JButton button2 = new JButton("2");
JButton button3 = new JButton("3"); JButton button3 = new JButton("3");
@ -205,84 +124,75 @@ public class Admin_Frame extends JFrame{
JButton button0 = new JButton("0"); JButton button0 = new JButton("0");
JButton delete = new JButton("Delete"); JButton delete = new JButton("Delete");
// 设置按钮1的外观和位置 //按钮外观设计
button1.setBounds(485,215,75,75); button1.setBounds(485,215,75,75);
button1.setBackground(new Color(96,62,151)); // 背景颜色 button1.setBackground(new Color(96,62,151));//设置背景颜色
button1.setForeground(Color.white); // 文字颜色 button1.setForeground(Color.white);//设置文字颜色
button1.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); //字体大小 button1.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));//设置字体大小
button1.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); //白色边框 button1.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));//设置边框
//以下同理
// 设置按钮2的外观和位置
button2.setBounds(575,215,75,75); button2.setBounds(575,215,75,75);
button2.setBackground(new Color(96,62,151)); button2.setBackground(new Color(96,62,151));
button2.setForeground(Color.white); button2.setForeground(Color.white);
button2.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button2.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button2.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button2.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮3的外观和位置
button3.setBounds(665,215,75,75); button3.setBounds(665,215,75,75);
button3.setBackground(new Color(96,62,151)); button3.setBackground(new Color(96,62,151));
button3.setForeground(Color.white); button3.setForeground(Color.white);
button3.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button3.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button3.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button3.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮4的外观和位置
button4.setBounds(485,305,75,75); button4.setBounds(485,305,75,75);
button4.setBackground(new Color(96,62,151)); button4.setBackground(new Color(96,62,151));
button4.setForeground(Color.white); button4.setForeground(Color.white);
button4.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button4.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button4.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button4.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮5的外观和位置
button5.setBounds(575,305,75,75);
button5.setBackground(new Color(96,62,151));
button5.setForeground(Color.white);
button5.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button5.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮6的外观和位置
button6.setBounds(665,305,75,75); button6.setBounds(665,305,75,75);
button6.setBackground(new Color(96,62,151)); button6.setBackground(new Color(96,62,151));
button6.setForeground(Color.white); button6.setForeground(Color.white);
button6.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button6.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button6.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button6.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮7的外观和位置 button5.setBounds(575,305,75,75);
button5.setBackground(new Color(96,62,151));
button5.setForeground(Color.white);
button5.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button5.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
button7.setBounds(487,395,75,75); button7.setBounds(487,395,75,75);
button7.setBackground(new Color(96,62,151)); button7.setBackground(new Color(96,62,151));
button7.setForeground(Color.white); button7.setForeground(Color.white);
button7.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button7.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button7.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button7.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮8的外观和位置
button8.setBounds(575,395,75,75); button8.setBounds(575,395,75,75);
button8.setBackground(new Color(96,62,151)); button8.setBackground(new Color(96,62,151));
button8.setForeground(Color.white); button8.setForeground(Color.white);
button8.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button8.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button8.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button8.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮9的外观和位置
button9.setBounds(665,395,75,75); button9.setBounds(665,395,75,75);
button9.setBackground(new Color(96,62,151)); button9.setBackground(new Color(96,62,151));
button9.setForeground(Color.white); button9.setForeground(Color.white);
button9.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button9.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button9.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button9.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置按钮0的外观和位置
button0.setBounds(575,485,75,75); button0.setBounds(575,485,75,75);
button0.setBackground(new Color(96,62,151)); button0.setBackground(new Color(96,62,151));
button0.setForeground(Color.white); button0.setForeground(Color.white);
button0.setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); button0.setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
button0.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); button0.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置删除按钮的外观和位置
delete.setBounds(790,215,126,75); delete.setBounds(790,215,126,75);
delete.setBackground(new Color(96,62,151)); delete.setBackground(new Color(96,62,151));
delete.setForeground(Color.white); delete.setForeground(Color.white);
delete.setFont(new Font (Font.DIALOG, Font.PLAIN, 30)); delete.setFont(new Font (Font.DIALOG, Font.PLAIN, 30));
delete.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); delete.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 将所有按钮添加到主面板 //将按钮添加到panel上
main.add(button1); main.add(button1);
main.add(button3); main.add(button3);
main.add(button2); main.add(button2);
@ -297,8 +207,14 @@ public class Admin_Frame extends JFrame{
main.add(inputArea); main.add(inputArea);
main.add(BookingNumHint); main.add(BookingNumHint);
// ==================== 数字按钮事件监听器 ==================== //为按钮添加监听事件
// 按钮0的点击事件 button0.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
button0.addActionListener(new AbstractAction() { button0.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -308,7 +224,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮1的点击事件
button1.addActionListener(new AbstractAction() { button1.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -317,7 +232,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮2的点击事件
button2.addActionListener(new AbstractAction() { button2.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -326,7 +240,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮3的点击事件
button3.addActionListener(new AbstractAction() { button3.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -335,7 +248,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮4的点击事件
button4.addActionListener(new AbstractAction() { button4.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -344,7 +256,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮5的点击事件
button5.addActionListener(new AbstractAction() { button5.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -353,7 +264,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮6的点击事件
button6.addActionListener(new AbstractAction() { button6.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -362,7 +272,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮7的点击事件
button7.addActionListener(new AbstractAction() { button7.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -371,7 +280,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮8的点击事件
button8.addActionListener(new AbstractAction() { button8.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -380,7 +288,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 按钮9的点击事件
button9.addActionListener(new AbstractAction() { button9.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -389,7 +296,6 @@ public class Admin_Frame extends JFrame{
} }
}); });
// 删除按钮的点击事件
delete.addActionListener(new AbstractAction() { delete.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -398,152 +304,84 @@ public class Admin_Frame extends JFrame{
IDnum=IDnum.substring(0,IDnum.length()-1); IDnum=IDnum.substring(0,IDnum.length()-1);
inputArea.setText(IDnum); inputArea.setText(IDnum);
} }
else;//若没有内容,则不执行删除
} }
}); });
// ==================== 底部导航按钮设置 ==================== //设置按钮
// 设置按钮尺寸
Dimension preferredSize = new Dimension(170,100); Dimension preferredSize = new Dimension(170,100);
// 创建返回按钮
JButton jButtonLeft = new JButton("RETURN"); JButton jButtonLeft = new JButton("RETURN");
jButtonLeft.setPreferredSize(preferredSize); jButtonLeft.setPreferredSize(preferredSize);
// 创建继续按钮
JButton jButtonRight = new JButton("CONTINUE"); JButton jButtonRight = new JButton("CONTINUE");
jButtonRight.setPreferredSize(preferredSize); jButtonRight.setPreferredSize(preferredSize);
// 使用Box布局管理底部按钮 //设置box布局
Box b1=Box.createHorizontalBox();//创建横向Box容器 Box b1=Box.createHorizontalBox();//创建横向Box容器
panelBottom.add(b1); panelBottom.add(b1);
b1.add(Box.createVerticalStrut(10)); // 添加垂直间距 b1.add(Box.createVerticalStrut(10));
b1.add(jButtonLeft); b1.add(jButtonLeft);
b1.add(Box.createHorizontalStrut(770)); // 添加水平间距 b1.add(Box.createHorizontalStrut(770));
b1.add(jButtonRight); // 添加继续按钮 b1.add(jButtonRight);//添加按钮2
// 设置按钮字体和颜色 //设置按钮字体
jButtonLeft.setFont(new Font (Font.DIALOG, Font.PLAIN, 25)); jButtonLeft.setFont(new Font (Font.DIALOG, Font.PLAIN, 25));
jButtonLeft.setForeground(Color.white); jButtonLeft.setForeground(Color.white);
jButtonLeft.setBackground(new Color(218,65,71)); // 红色背景 jButtonLeft.setBackground(new Color(218,65,71));
jButtonRight.setFont(new Font (Font.DIALOG, Font.PLAIN, 25)); jButtonRight.setFont(new Font (Font.DIALOG, Font.PLAIN, 25));
jButtonRight.setForeground(Color.white); jButtonRight.setForeground(Color.white);
jButtonRight.setBackground(new Color(218,65,71)); // 红色背景 jButtonRight.setBackground(new Color(218,65,71));
// 确保按钮可见
jButtonLeft.setVisible(true); jButtonLeft.setVisible(true);
jButtonRight.setVisible(true); jButtonRight.setVisible(true);
// ==================== 继续按钮事件处理 ====================
jButtonRight.addActionListener(new AbstractAction() { jButtonRight.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(pageNumber<3) { if(pageNumber<3) {
pageNumber++; // 页面编号递增 pageNumber++;
} }
// 根据当前页面编号执行相应操作
if(pageNumber==0){ if(pageNumber==0){
// 显示主登录页面
cardLayout.show(panelMiddle,"0"); cardLayout.show(panelMiddle,"0");
}else if(pageNumber==1){ }else if(pageNumber==1){
if (!flag && IDnum.equals("123456")){
AdminService adminService=new AdminService(); BookingNumHint.setText("PLEASE ENTER YOUR PASSWORD");
// 登录验证逻辑 JOptionPane.showMessageDialog(null, "Now please enter the" +
// if (!flag && IDnum.equals("123456")){ " administrator password.", "warning", JOptionPane.INFORMATION_MESSAGE);
// // 账号正确,提示输入密码 inputArea.setText("");
// BookingNumHint.setText("PLEASE ENTER YOUR PASSWORD"); flag=true;
// JOptionPane.showMessageDialog(null, "Now please enter the" + IDnum="";
// " administrator password.", "warning", JOptionPane.INFORMATION_MESSAGE); pageNumber=0;
// inputArea.setText(""); // 清空输入框 }else if(flag && IDnum.equals("000000")){
// flag=true; // 设置为密码输入状态 inputArea.setText("");
// IDnum=""; // 清空输入缓存 IDnum="";
// pageNumber=0; // 保持在当前页面 flag=false;
// }else if(flag && IDnum.equals("000000")){ cardLayout.show(panelMiddle,"1");
// // 密码正确,进入航班管理页面 }else if(!flag){
// inputArea.setText(""); JOptionPane.showMessageDialog(null, "Your account number is entered" +
// IDnum=""; " incorrectly. Please re-enter it.", "warning", JOptionPane.INFORMATION_MESSAGE);
// flag=false; // 重置登录状态 inputArea.setText("");
// cardLayout.show(panelMiddle,"1"); // 显示航班管理页面 IDnum="";
// }else if(!flag){ pageNumber=0;
// // 账号错误 }else{
// JOptionPane.showMessageDialog(null, "Your account number is entered" + JOptionPane.showMessageDialog(null, "Your password is entered" +
// " incorrectly. Please re-enter it.", "warning", JOptionPane.INFORMATION_MESSAGE); " incorrectly. Please re-enter it.", "warning", JOptionPane.INFORMATION_MESSAGE);
// inputArea.setText(""); inputArea.setText("");
// IDnum=""; IDnum="";
// pageNumber=0; pageNumber=0;
// }else{
// // 密码错误
// JOptionPane.showMessageDialog(null, "Your password is entered" +
// " incorrectly. Please re-enter it.", "warning", JOptionPane.INFORMATION_MESSAGE);
// inputArea.setText("");
// IDnum="";
// pageNumber=0;
// }
if (!flag) {
// 此时只输入了账号
Admin admin = adminService.getAdminById(IDnum); // 查找是否存在此账号
if (admin != null) {
// 账号正确,提示输入密码
admin_f = admin; // 找到这个账号
// 打印账号
System.out.println("账号正确!" + admin_f);
BookingNumHint.setText("PLEASE ENTER YOUR PASSWORD");
JOptionPane.showMessageDialog(null,
"Now please enter the administrator password.",
"Information", JOptionPane.INFORMATION_MESSAGE);
inputArea.setText("");
flag = true; // 切换到“输密码”状态
IDnum = ""; // 清空输入缓存
pageNumber = 0; // 仍停在登录页
} else {
// 账号错误
System.out.println("账号错误!");
JOptionPane.showMessageDialog(null,
"Your account number is entered incorrectly. Please re-enter it.",
"Warning", JOptionPane.INFORMATION_MESSAGE);
inputArea.setText("");
IDnum = "";
pageNumber = 0;
}
} else {
// 账号已经验证成功
if (admin_f != null && IDnum.equals(admin_f.getPassword())) {
// 密码输入正确
System.out.println("这里密码输入正确,进入航班页面");
inputArea.setText("");
IDnum = "";
flag = false;
admin_f = null; // 重置管理员
cardLayout.show(panelMiddle, "1");
} else {
// 密码错误
JOptionPane.showMessageDialog(null,
"Your password is entered incorrectly. Please re-enter it.",
"Warning", JOptionPane.INFORMATION_MESSAGE);
inputArea.setText("");
IDnum = "";
pageNumber = 0;
}
} }
}else if(pageNumber==2){ }else if(pageNumber==2){
// 进入信息查看页面 temp = Admin_Flights_Panel.flight_num;
temp = Admin_Flights_Panel.flight_num; // 获取航班号 flight f = new flight();
FlightService flightService = new FlightService(); if(f.isFlight(temp)==1) {
if(flightService.findFlightById(temp).isPresent()) {
// 航班号有效,显示信息页面
Admin_Information Information = new Admin_Information(temp); Admin_Information Information = new Admin_Information(temp);
panelMiddle.add(Information, "2"); panelMiddle.add(Information, "2");
cardLayout.show(panelMiddle, "2"); cardLayout.show(panelMiddle, "2");
jButtonRight.setText("EXIT"); // 更改按钮文字为退出 jButtonRight.setText("EXIT");
}else if(!flightService.findFlightById(temp).isPresent()){ }else if(f.isFlight(temp)==0){
// 航班号无效,显示错误信息
pageNumber--; pageNumber--;
JOptionPane.showMessageDialog(null, "Flight is selected incorrectly." + JOptionPane.showMessageDialog(null, "Flight is selected incorrectly." +
" Please re-enter it.", "warning", JOptionPane.INFORMATION_MESSAGE); " Please re-enter it.", "warning", JOptionPane.INFORMATION_MESSAGE);
@ -551,78 +389,37 @@ public class Admin_Frame extends JFrame{
} }
}else if(pageNumber==3){ }else if(pageNumber==3){
// 退出系统
System.exit(0); System.exit(0);
} }
} }
}); });
// ==================== 返回按钮事件处理 ====================
jButtonLeft.addActionListener(new AbstractAction() { jButtonLeft.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if(pageNumber>=0) { if(pageNumber>=0) {
pageNumber--; // 页面编号递减 pageNumber--;
} }
// 根据页面编号执行相应操作
if(pageNumber==-1){ if(pageNumber==-1){
pageNumber=0; pageNumber=0;
System.exit(0); System.exit(0);
}else if(pageNumber==0) { }else if(pageNumber==0) {
// 返回登录页面
BookingNumHint.setText("PLEASE ENTER THE ADMINISTRATOR ACCOUNT"); BookingNumHint.setText("PLEASE ENTER THE ADMINISTRATOR ACCOUNT");
cardLayout.show(panelMiddle, "0"); cardLayout.show(panelMiddle, "0");
}else if(pageNumber==1){ }else if(pageNumber==1){
cardLayout.show(panelMiddle,"1"); cardLayout.show(panelMiddle,"1");
jButtonRight.setText("CONTINUE"); // 恢复按钮文字 jButtonRight.setText("CONTINUE");
}else if(pageNumber==2){ }else if(pageNumber==2){
// 返回信息查看页面
cardLayout.show(panelMiddle,"2"); cardLayout.show(panelMiddle,"2");
} }
} }
}); });
// ==================== 窗口设置 ====================
//设置关闭事件 //设置关闭事件
frameAdmin.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frameAdmin.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
// 显示窗口
frameAdmin.setVisible(true); frameAdmin.setVisible(true);
} }
/**
* -
*
* <p></p>
*
* <p>使</p>
* <ul>
* <li></li>
* <li>123456</li>
* <li>000000</li>
* </ul>
*
* @param args 使
*/
public static void main(String[] args) {
// 在事件分发线程中创建GUI确保线程安全
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// 创建Admin_Frame实例
Admin_Frame adminFrame = new Admin_Frame();
// 构建并显示管理员界面
adminFrame.build_Admin_Frame();
}
});
}
} }

@ -1,100 +1,26 @@
package frame; package frame;
import frame.Main_Frame;
import java.awt.*; import java.awt.*;
/** /**
* * Title : Init.java
* * Description : This class is the startup class for launching the user interface.
* <p>Title: Init.java</p>
* <p>Description: </p>
*
* <p></p>
* <ul>
* <li></li>
* <li></li>
* <li></li>
* </ul>
*
* <p></p>
* <ul>
* <li>使</li>
* <li></li>
* </ul>
*
* <p></p>
* <ol>
* <li></li>
* <li></li>
* <li></li>
* </ol>
*
* @author Jinfeng Tao
* @version 1.0
* @since 2025
*/ */
public class Init { public class Init {
/**
*
*
* <p>使
* </p>
*
* <p></p>
* <ul>
* <li></li>
* <li></li>
* <li></li>
* </ul>
*/
public static CardLayout cardLayout = new CardLayout(); public static CardLayout cardLayout = new CardLayout();
/** public CardLayout getCardLayout()
*
*
* <p>访
* </p>
*
* @return CardLayout
*
* <p>使</p>
* <pre>
* CardLayout layout = new Init().getCardLayout();
* layout.show(panel, "nextPage");
* </pre>
*/
public static CardLayout getCardLayout()
{ {
return cardLayout; return cardLayout;
} }
/**
*
*
* <p>JavaJVM</p>
*
* <p></p>
* <ol>
* <li></li>
* <li></li>
* <li></li>
* </ol>
*/
public static void main(String[] args) { public static void main(String[] args) {
// 创建主框架示例并构建用户界面 new Main_Frame().buildMainFrame(cardLayout);
// 将卡片布局管理器传递给主框架,确保界面切换的一致性
new Main_Frame().buildMainFrame(getCardLayout());
// 输出用户提示信息
System.out.println("Please input ID!"); System.out.println("Please input ID!");
} }
/**
*
*/
private Init() {
// 采用单例设计模式
}
} }

@ -1,49 +1,12 @@
package frame; package frame;
/** /**
* * Title : Init_Admin.java
* * Description : This class is the startup class for launching the admin interface.
* <p>Title: Init_Admin.java</p>
* <p>Description: </p>
*
* <p></p>
* <ul>
* <li></li>
* <li></li>
* <li></li>
* </ul>
*
* @author Jinfeng Tao
* @version 1.0
* @since 2025
*/ */
public class Init_Admin { public class Init_Admin {
/**
*
*
* <p>访</p>
*
* <p></p>
* <ol>
* <li>Admin_Framebuild_Admin_Frame()</li>
* <li>(IDnum)</li>
* <li>(flag)false</li>
* </ol>
*
* <p></p>
* <ul>
* <li>123456</li>
* <li>000000</li>
* </ul>
*/
public static void main(String[] args) { public static void main(String[] args) {
// 创建管理员框架实例并构建管理员界面
new Admin_Frame().build_Admin_Frame(); new Admin_Frame().build_Admin_Frame();
// 重置管理员身份标识为空字符串
Admin_Frame.IDnum=""; Admin_Frame.IDnum="";
// 重置登录状态标志为false未登录状态
Admin_Frame.flag=false; Admin_Frame.flag=false;
} }
} }

@ -2,11 +2,7 @@ package frame;
import frame.UserPanel.*; import frame.UserPanel.*;
import model_new.FlightSeat; import model.*;
import model_new.Order;
import service.FlightSeatService;
import service.OrderService;
import service.PassengerService;
import utils.BackGroundImagePanle; import utils.BackGroundImagePanle;
import utils.GBC; import utils.GBC;
import utils.MyLayout; import utils.MyLayout;
@ -14,88 +10,24 @@ import utils.MyLayout;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.List; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
/** /**
* * Title : Main_Frame.java
* * Description : This class is a template for building the user interface.
* <p>Title: Main_Frame.java</p>
* <p>Description: </p>
*
* <p></p>
* <ul>
* <li></li>
* <li></li>
* <li></li>
* <li></li>
* </ul>
*
* <p></p>
* <ol>
* <li> </li>
* </ol>
*
* @author Jinfeng Tao
* @version 1.0
* @since 2025
*/ */
public class Main_Frame extends JFrame { public class Main_Frame extends JFrame {
/**
*
* 0:
* 1:
* 2:
* 3:
* 4:
* 5:
* 6:
* 7:
* 8:
* 9:
* 10:
* 11:
* 12: 退
*/
public static int pageNum=0; public static int pageNum=0;
/** public static String orderNum="1326854870743";//订单号
* - public static String IDNum="360124200102040017";//ID号
*/ public static String flightNum="BA0570";//航班号
// public static String orderNum="1326854870743";//订单号
public static String orderNum="ORD20240320002";//订单号
/**
* -
*/
public static String IDNum="110101199001011234";//ID号
/**
* -
*/
// public static String flightNum="BA0570";//航班号
public static String flightNum="CA123";//航班号
/**
* -
*/
public static String foodType="0";//食物种类 public static String foodType="0";//食物种类
/** public static String temp="";//id值
* -
*/
public static String temp="110101199001011234";//id值
/**
* -
*/
public static boolean flag = false; public static boolean flag = false;
/**
* -
*/
public static String req="NOTE";//需求 public static String req="NOTE";//需求
// 各个功能面板的引用
// 该类并未使用这些变量
public Check_in_Panel check_in; public Check_in_Panel check_in;
public Check_in_Panel flights; public Check_in_Panel flights;
public Check_in_Panel foods; public Check_in_Panel foods;
@ -106,190 +38,129 @@ public class Main_Frame extends JFrame {
public Check_in_Panel scanNum; public Check_in_Panel scanNum;
public Check_in_Panel confirm; public Check_in_Panel confirm;
/**
* - 使
*/
public JPanel panelMiddle; public JPanel panelMiddle;
/**
* - /
*/
public JButton jButtonRight; public JButton jButtonRight;
/**
* - /
*/
public JButton jButtonLeft; public JButton jButtonLeft;
/**
*
*
* <p></p>
* <ul>
* <li></li>
* <li></li>
* <li></li>
* <li></li>
* </ul>
*
* <p></p>
* <ul>
* <li>Logo</li>
* <li></li>
* <li></li>
* </ul>
*
* @param cardLayout
*/
public void buildMainFrame(CardLayout cardLayout){ public void buildMainFrame(CardLayout cardLayout){
// 创建主窗口
JFrame frame = new JFrame("Heathrow"); JFrame frame = new JFrame("Heathrow");
OrderService orderService = new OrderService(); // 定义订单服务类
PassengerService passengerService = new PassengerService();
// 设置跨平台外观
try{ try{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }
// 设置窗口位置和大小
frame.setBounds(300,80,1200,900); frame.setBounds(300,80,1200,900);
frame.setResizable(false); // 禁止调整窗口大小 frame.setResizable(false);
// 设置主布局为边界布局 //设置布局
frame.setLayout(new BorderLayout()); frame.setLayout(new BorderLayout());
//设置上层panel
// ==================== 创建三个主要面板区域 ====================
// 顶部面板 - 用于显示logo和流程导航菜单
JPanel panelTop = new JPanel(); JPanel panelTop = new JPanel();
panelTop.setBackground(new Color(96,62,151)); panelTop.setBackground(new Color(96,62,151));
//设置中层panel
// 中间面板 - 使用卡片布局实现多步骤流程
this.panelMiddle = new JPanel(cardLayout); this.panelMiddle = new JPanel(cardLayout);
//设置下层panel
// 底部面板 - 用于放置导航按钮
JPanel panelBottom = new JPanel(); JPanel panelBottom = new JPanel();
panelBottom.setBackground(new Color(96,62,151)); panelBottom.setBackground(new Color(96,62,151));
// ==================== 创建导航按钮 ==================== //设置按钮
// 设置按钮尺寸
Dimension preferredSize = new Dimension(170,100); Dimension preferredSize = new Dimension(170,100);
// 创建帮助按钮
this.jButtonLeft = new JButton("HELP"); this.jButtonLeft = new JButton("HELP");
jButtonLeft.setPreferredSize(preferredSize); jButtonLeft.setPreferredSize(preferredSize);
// 创建继续按钮
this.jButtonRight = new JButton("CONTINUE"); this.jButtonRight = new JButton("CONTINUE");
jButtonRight.setPreferredSize(preferredSize); jButtonRight.setPreferredSize(preferredSize);
// ==================== 初始化所有功能面板 ==================== //设置卡片布局
// 主页面
JPanel main = new JPanel(); JPanel main = new JPanel();
main.setBackground(new Color(72,46,115)); // 背景颜色 main.setBackground(new Color(72,46,115));
// 各个功能面板
Check_in_Panel check_in = new Check_in_Panel(this.panelMiddle,this.jButtonRight); Check_in_Panel check_in = new Check_in_Panel(this.panelMiddle,this.jButtonRight);
Flights_Panel flights = new Flights_Panel(); Flights_Panel flights = new Flights_Panel();
Foods_Panel foods = new Foods_Panel(); Foods_Panel foods = new Foods_Panel();
//Seats_Panel seats = new Seats_Panel(); // 尚未实现 //Seats_Panel seats = new Seats_Panel();
Print_Panel print = new Print_Panel(); Print_Panel print = new Print_Panel();
Check_in_bookingNum_Panel bookingNum = new Check_in_bookingNum_Panel(); // 预定手机号登录 Check_in_bookingNum_Panel bookingNum = new Check_in_bookingNum_Panel();
Check_in_idNum_Panel idNum = new Check_in_idNum_Panel(); // 身份证号登录 Check_in_idNum_Panel idNum = new Check_in_idNum_Panel();
Check_in_scanNum_Panel scanNum = new Check_in_scanNum_Panel(); // 读卡登录 Check_in_scanNum_Panel scanNum = new Check_in_scanNum_Panel();
//Confirm_Panel confirm = new Confirm_Panel(); // 尚未实现 //Confirm_Panel confirm = new Confirm_Panel();
Pay_Panel payPanel = new Pay_Panel(); // 支付页面 Pay_Panel payPanel = new Pay_Panel();
Video_Panel videoPanel = new Video_Panel(); Video_Panel videoPanel = new Video_Panel();
// 设置主页面布局
main.setLayout(new MyLayout(main)); main.setLayout(new MyLayout(main));
//左侧的颜色
// 左侧颜色面板
JPanel Panel1 = new JPanel(); JPanel Panel1 = new JPanel();
Panel1.setBackground(new Color(72,46,115)); Panel1.setBackground(new Color(72,46,115));
main.add(Panel1,new GBC(0,0,1,1). main.add(Panel1,new GBC(0,0,1,1).
setFill(GBC.BOTH).setIpad(60, 680).setWeight(0, 10)); setFill(GBC.BOTH).setIpad(60, 680).setWeight(0, 10));
// 中间危险品提示图片 //中间的图片
BackGroundImagePanle PanelDangerous= new BackGroundImagePanle("Dangerous.png"); BackGroundImagePanle PanelDangerous= new BackGroundImagePanle("Dangerous.png");
main.add(PanelDangerous,new GBC(1,0,1,1). main.add(PanelDangerous,new GBC(1,0,1,1).
setFill(GBC.BOTH).setIpad(1050, 680).setWeight(10, 0)); setFill(GBC.BOTH).setIpad(1050, 680).setWeight(10, 0));
// 右侧颜色面板 //右侧颜色
JPanel Panel3 = new JPanel(); JPanel Panel3 = new JPanel();
Panel3.setBackground(new Color(72,46,115)); Panel3.setBackground(new Color(72,46,115));
main.add(Panel3,new GBC(2,0,1,1). main.add(Panel3,new GBC(2,0,1,1).
setFill(GBC.BOTH).setIpad(50, 680).setWeight(0, 10)); setFill(GBC.BOTH).setIpad(50, 680).setWeight(0, 10));
// ==================== 映射卡片布局 ==================== //映射卡片布局
panelMiddle.add(main,"0");
// 将所有功能面板添加到卡片布局中,并分配标识符 panelMiddle.add(check_in,"1");
panelMiddle.add(main, "0"); // 主页面 panelMiddle.add(bookingNum,"2");
panelMiddle.add(check_in, "1"); // 值机面板 panelMiddle.add(idNum,"3");
panelMiddle.add(bookingNum, "2"); // 预订号输入 panelMiddle.add(scanNum,"4");
panelMiddle.add(idNum, "3"); // 身份证输入 panelMiddle.add(flights,"5");
panelMiddle.add(scanNum, "4"); // 扫描号码输入 //panelMiddle.add(seats,"6");
panelMiddle.add(flights, "5"); // 航班选择 panelMiddle.add(foods,"7");
//panelMiddle.add(confirm,"8");
// panelMiddle.add(seats, "6"); // 座位选择(注释掉) panelMiddle.add(payPanel,"9");
panelMiddle.add(foods, "7"); // 餐食选择 panelMiddle.add(print,"10");
// panelMiddle.add(confirm, "8"); // 信息确认(注释掉) panelMiddle.add(videoPanel,"11");
panelMiddle.add(payPanel, "9"); // 支付
panelMiddle.add(print, "10"); // 打印
panelMiddle.add(videoPanel, "11"); // 视频演示
// ==================== 将面板添加到主窗口 ==================== //添加三层panel至布局
frame.add(panelTop,BorderLayout.NORTH); frame.add(panelTop,BorderLayout.NORTH);
frame.add(panelMiddle,BorderLayout.CENTER); frame.add(panelMiddle,BorderLayout.CENTER);
frame.add(panelBottom,BorderLayout.SOUTH); frame.add(panelBottom,BorderLayout.SOUTH);
// 设置各面板的尺寸 //设置布局位置
panelTop.setPreferredSize(new Dimension(1200,110)); panelTop.setPreferredSize(new Dimension(1200,110));
panelMiddle.setPreferredSize(new Dimension(1200,680)); panelMiddle.setPreferredSize(new Dimension(1200,680));
panelBottom.setPreferredSize(new Dimension(1200,110)); panelBottom.setPreferredSize(new Dimension(1200,110));
// 设置关闭操作 //设置关闭事件
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
// ==================== 顶部面板设置 ====================
//设置顶层菜单布局 //设置顶层菜单布局
panelTop.setLayout(new BorderLayout()); panelTop.setLayout(new BorderLayout());
//设置左上角logo //设置左上角logo
BackGroundImagePanle PanelLogo= new BackGroundImagePanle("logo_heathrow.png"); BackGroundImagePanle PanelLogo= new BackGroundImagePanle("logo_heathrow.png");
// 创建右侧菜单面板
JPanel panelMenu = new JPanel(); JPanel panelMenu = new JPanel();
panelMenu.setBackground(new Color(96,62,151)); panelMenu.setBackground(new Color(96,62,151));
// 将logo和菜单添加到顶部面板 //添加到顶层菜单布局
panelTop.add(PanelLogo,BorderLayout.WEST); panelTop.add(PanelLogo,BorderLayout.WEST);
panelTop.add(panelMenu,BorderLayout.EAST); panelTop.add(panelMenu,BorderLayout.EAST);
//添加到左上角
// 设置组件尺寸
PanelLogo.setPreferredSize(new Dimension(300,110)); PanelLogo.setPreferredSize(new Dimension(300,110));
panelMenu.setPreferredSize(new Dimension(900,110)); panelMenu.setPreferredSize(new Dimension(900,110));
// ==================== 创建流程导航标签 ==================== //创建右上角按钮
// 创建表示不同流程步骤的标签
JLabel label1 = new JLabel(" CHECK IN",JLabel.CENTER); JLabel label1 = new JLabel(" CHECK IN",JLabel.CENTER);
JLabel label2 = new JLabel("FLIGHTS",JLabel.CENTER); JLabel label2 = new JLabel("FLIGHTS",JLabel.CENTER);
JLabel label3 = new JLabel("SEATS",JLabel.CENTER); JLabel label3 = new JLabel("SEATS",JLabel.CENTER);
JLabel label4 = new JLabel("FOODS",JLabel.CENTER); JLabel label4 = new JLabel("FOODS",JLabel.CENTER);
JLabel label5 = new JLabel("PRINT",JLabel.CENTER); JLabel label5 = new JLabel("PRINT",JLabel.CENTER);
// 设置标签字体和颜色 //设置标签字体
label1.setFont(new Font (Font.DIALOG, Font.BOLD, 28)); label1.setFont(new Font (Font.DIALOG, Font.BOLD, 28));
label1.setForeground(Color.white);//设置文字的颜色 label1.setForeground(Color.white);//设置文字的颜色
label2.setFont(new Font (Font.DIALOG, Font.BOLD, 28)); label2.setFont(new Font (Font.DIALOG, Font.BOLD, 28));
@ -301,7 +172,6 @@ public class Main_Frame extends JFrame {
label5.setFont(new Font (Font.DIALOG, Font.BOLD, 28)); label5.setFont(new Font (Font.DIALOG, Font.BOLD, 28));
label5.setForeground(Color.white);//设置文字的颜色 label5.setForeground(Color.white);//设置文字的颜色
// 将标签添加到菜单面板
panelMenu.setLayout(new GridLayout(1, 5)); panelMenu.setLayout(new GridLayout(1, 5));
panelMenu.add(label1); panelMenu.add(label1);
panelMenu.add(label2); panelMenu.add(label2);
@ -309,88 +179,72 @@ public class Main_Frame extends JFrame {
panelMenu.add(label4); panelMenu.add(label4);
panelMenu.add(label5); panelMenu.add(label5);
// ==================== 底部按钮布局 ==================== //设置box布局
// 使用Box布局管理底部按钮
Box b1=Box.createHorizontalBox(); //创建横向Box容器 Box b1=Box.createHorizontalBox(); //创建横向Box容器
panelBottom.add(b1); panelBottom.add(b1);
b1.add(Box.createVerticalStrut(10)); // 添加垂直间距 b1.add(Box.createVerticalStrut(10));
b1.add(jButtonLeft); // 添加帮助按钮 b1.add(jButtonLeft);
b1.add(Box.createHorizontalStrut(570)); // 添加水平间距 b1.add(Box.createHorizontalStrut(570));
b1.add(jButtonRight); // 添加继续按钮 b1.add(jButtonRight); //添加按钮2
// 设置按钮字体和颜色 //设置按钮字体
jButtonLeft.setFont(new Font (Font.DIALOG, Font.PLAIN, 25)); jButtonLeft.setFont(new Font (Font.DIALOG, Font.PLAIN, 25));
jButtonLeft.setForeground(Color.white); jButtonLeft.setForeground(Color.white);
jButtonLeft.setBackground(new Color(218,65,71)); // 红色背景 jButtonLeft.setBackground(new Color(218,65,71));
jButtonRight.setFont(new Font (Font.DIALOG, Font.PLAIN, 25)); jButtonRight.setFont(new Font (Font.DIALOG, Font.PLAIN, 25));
jButtonRight.setForeground(Color.white); jButtonRight.setForeground(Color.white);
jButtonRight.setBackground(new Color(218,65,71)); // 红色背景 jButtonRight.setBackground(new Color(218,65,71));
// 确保按钮可见
jButtonLeft.setVisible(true); jButtonLeft.setVisible(true);
jButtonRight.setVisible(true); jButtonRight.setVisible(true);
// ==================== 继续按钮事件处理 ====================
//设置按钮事件 //设置按钮事件
jButtonRight.addActionListener(new AbstractAction() { jButtonRight.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 限制页面编号不超过最大值
if(pageNum<12){ if(pageNum<12){
pageNum++; pageNum++;
} }
// 根据当前页面编号执行相应操作
if(pageNum==0){ if(pageNum==0){
// 显示主页面
cardLayout.show(panelMiddle,"0"); cardLayout.show(panelMiddle,"0");
label1.setBackground(new Color(96,62,151)); label1.setBackground(new Color(96,62,151));
}else if(pageNum==1){ }else if(pageNum==1){
// 体温检测页面
String temperature; String temperature;
double d=10000; // 默认值,表示未输入 double d=10000;
// 弹出输入对话框获取体温
temperature =JOptionPane.showInputDialog(null,"Please enter your temperature, e.g. 36.8"); temperature =JOptionPane.showInputDialog(null,"Please enter your temperature, e.g. 36.8");
// 验证体温输入格式
if (temperature!=null&&temperature.length()!=0){ if (temperature!=null&&temperature.length()!=0){
for (int i = 0;i<temperature.length();i++){ for (int i = 0;i<temperature.length();i++){
if (!Character.isDigit(temperature.charAt(i))){ if (!Character.isDigit(temperature.charAt(i))){
if(temperature.charAt(i)!='.'){ if(temperature.charAt(i)!='.'){
temperature="false"; // 标记为无效输入 temperature="false";
} }
} }
} }
if(!temperature.equals("false")){ if(!temperature.equals("false")){
d=Double.parseDouble(temperature); // 转换为数字 d=Double.parseDouble(temperature);
} }
} }
//if (temperature!=null){
// 体温验证逻辑 // d=Double.parseDouble(temperature);
//}
if (d<=37.3&&d>=35.5){ if (d<=37.3&&d>=35.5){
// 体温正常,进入值机流程
label1.setOpaque(true); label1.setOpaque(true);
label2.setBackground(new Color(96,62,151)); label2.setBackground(new Color(96,62,151));
label1.setBackground(new Color(72,46,115)); label1.setBackground(new Color(72,46,115));
cardLayout.show(panelMiddle,"1"); cardLayout.show(panelMiddle,"1");
panelBottom.setBackground(new Color(72,46,115)); panelBottom.setBackground(new Color(72,46,115));
jButtonLeft.setText("RETURN"); jButtonLeft.setText("RETURN");
jButtonRight.setVisible(false); // 隐藏继续按钮 jButtonRight.setVisible(false);
}else if(d==10000){ }else if(d==10000){
// 未输入体温值
JOptionPane.showMessageDialog(null, "You have" + JOptionPane.showMessageDialog(null, "You have" +
" entered incorrect information.", "warning", JOptionPane.INFORMATION_MESSAGE); " entered incorrect information.", "warning", JOptionPane.INFORMATION_MESSAGE);
pageNum--; pageNum--;
} else { } else {
// 体温异常
JOptionPane.showMessageDialog(null, "Your temperature is abnormal. " + JOptionPane.showMessageDialog(null, "Your temperature is abnormal. " +
"Please contact the airport staff immediately.", "warning", JOptionPane.INFORMATION_MESSAGE); "Please contact the airport staff immediately.", "warning", JOptionPane.INFORMATION_MESSAGE);
pageNum--; pageNum--;
@ -398,37 +252,21 @@ public class Main_Frame extends JFrame {
}else if(pageNum==2){ }else if(pageNum==2){
// 预订号输入页面 - 更新界面状态
label1.setOpaque(true); label1.setOpaque(true);
label2.setBackground(new Color(96,62,151)); label2.setBackground(new Color(96,62,151));
label1.setBackground(new Color(72,46,115)); label1.setBackground(new Color(72,46,115));
System.out.println("预定号输入页面");
}else if(pageNum==3){ }else if(pageNum==3){
// 身份验证逻辑
label1.setBackground(new Color(96,62,151)); label1.setBackground(new Color(96,62,151));
label2.setBackground(new Color(72,46,115)); label2.setBackground(new Color(72,46,115));
//输入了正确的id直接进入下一页
System.out.println("页面3 订单号验证"); if(order.isOrder(Check_in_bookingNum_Panel.IDnum)==1){
// 验证预订号是否正确
if(orderService.getOrderById(Check_in_bookingNum_Panel.IDnum).isPresent()){
System.out.println(Check_in_bookingNum_Panel.IDnum); System.out.println(Check_in_bookingNum_Panel.IDnum);
// 根据预订号查找身份证号
// temp=passenger_order.find_id_num(Check_in_bookingNum_Panel.IDnum);
temp = "DD"; // 获取乘客身份证号
temp=passenger_order.find_id_num(Check_in_bookingNum_Panel.IDnum);
Flights_Panel flights = new Flights_Panel(); Flights_Panel flights = new Flights_Panel();
temp = orderService.getOrderById(Check_in_bookingNum_Panel.IDnum).get().getPassenger_id();
// 跳过中间步骤,直接进入航班选择
pageNum=4; pageNum=4;
panelMiddle.add(flights,"5"); panelMiddle.add(flights,"5");
cardLayout.show(panelMiddle,"5"); cardLayout.show(panelMiddle,"5");
@ -438,9 +276,9 @@ public class Main_Frame extends JFrame {
System.out.println("Welcome Boarding!"); System.out.println("Welcome Boarding!");
} }
//输入了错误的id重新输入
else { else {
// 预订号错误
System.out.println(Check_in_bookingNum_Panel.IDnum); System.out.println(Check_in_bookingNum_Panel.IDnum);
System.out.println("Wrong booking number!"); System.out.println("Wrong booking number!");
@ -454,22 +292,20 @@ public class Main_Frame extends JFrame {
} }
}else if(pageNum==4){ }else if(pageNum==4){
// 身份证验证逻辑
label1.setBackground(new Color(96,62,151)); label1.setBackground(new Color(96,62,151));
label2.setBackground(new Color(72,46,115)); label2.setBackground(new Color(72,46,115));
//情况一第一次输入了正确的id则flag为真 //情况一第一次输入了正确的id则flag为真
// System.out.println("Please input ID!");
System.out.println("页面4 身份验证逻辑"); if(passenger.isPassenger(Check_in_idNum_Panel.IDnum)==1&&flag == false){
if(passengerService.getPassengerById(Check_in_idNum_Panel.IDnum).isPresent()&&flag == false){
temp=Check_in_idNum_Panel.IDnum; temp=Check_in_idNum_Panel.IDnum;
System.out.println(temp); System.out.println(temp);
// 提示输入姓名
JOptionPane.showMessageDialog(null, "Now please enter your name", "tips", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Now please enter your name", "tips", JOptionPane.INFORMATION_MESSAGE);
flag = true; // 设置标志,表示已输入正确身份证 flag = true;
Check_in_idNum_Panel idNum = new Check_in_idNum_Panel(); Check_in_idNum_Panel idNum = new Check_in_idNum_Panel();
panelMiddle.add(idNum,"3"); panelMiddle.add(idNum,"3");
cardLayout.show(panelMiddle,"3"); cardLayout.show(panelMiddle,"3");
@ -477,13 +313,11 @@ public class Main_Frame extends JFrame {
System.out.println("Please input Surname!"); System.out.println("Please input Surname!");
// 情况2已输入正确身份证现在输入正确姓名 //情况二在flag为真即正确输入了id时姓名也正确成功登陆
}else if(flag == true&&passenger_order.isSurname(temp,Check_in_idNum_Panel.IDnum)==1){
}else if(flag == true&&passengerService.getPassengerById(temp).get().getName().equals(Check_in_idNum_Panel.IDnum)){
System.out.println(Check_in_idNum_Panel.IDnum); System.out.println(Check_in_idNum_Panel.IDnum);
// 进入航班选择页面
Flights_Panel flights1 = new Flights_Panel(); Flights_Panel flights1 = new Flights_Panel();
panelMiddle.add(flights1,"5"); panelMiddle.add(flights1,"5");
cardLayout.show(panelMiddle,"5"); cardLayout.show(panelMiddle,"5");
@ -491,14 +325,14 @@ public class Main_Frame extends JFrame {
jButtonRight.setBackground(new Color(218,65,71)); jButtonRight.setBackground(new Color(218,65,71));
pageNum++; pageNum++;
temp=""; temp="";
flag = false; // 重置标志 flag = false;
Check_in_idNum_Panel idNum = new Check_in_idNum_Panel(); Check_in_idNum_Panel idNum = new Check_in_idNum_Panel();
panelMiddle.add(idNum,"3"); panelMiddle.add(idNum,"3");
System.out.println("Welcome Boarding!"); System.out.println("Welcome Boarding!");
// 情况3已输入正确身份证但仍输入身份证应该输入姓名 //情况三在flag为真即正确输入了id时仍然在输入id则报错
}else if(orderService.getOrderById(Check_in_idNum_Panel.IDnum).isPresent()&&flag == true){ }else if(passenger.isPassenger(Check_in_idNum_Panel.IDnum)==1&&flag == true){
System.out.println(Check_in_idNum_Panel.IDnum); System.out.println(Check_in_idNum_Panel.IDnum);
@ -510,8 +344,8 @@ public class Main_Frame extends JFrame {
System.out.println("Wrong Surname!"); System.out.println("Wrong Surname!");
// 情况4已输入正确身份证但输入错误姓名 //情况四在flag为真输错姓名报错
}else if(!passengerService.getPassengerById(temp).get().getName().equals(Check_in_idNum_Panel.IDnum)&&flag == true){ }else if(passenger_order.isSurname(temp,Check_in_idNum_Panel.IDnum)==0&&flag == true){
System.out.println(Check_in_idNum_Panel.IDnum); System.out.println(Check_in_idNum_Panel.IDnum);
@ -524,8 +358,8 @@ public class Main_Frame extends JFrame {
System.out.println("Wrong SurName!"); System.out.println("Wrong SurName!");
// 情况5第一次就输入错误身份证 //情况五第一次就输错了id
} else if(orderService.getOrderById(Check_in_idNum_Panel.IDnum).isEmpty()&&flag == false){ } else if(passenger.isPassenger(Check_in_idNum_Panel.IDnum)==0&&flag == false){
System.out.println(Check_in_idNum_Panel.IDnum); System.out.println(Check_in_idNum_Panel.IDnum);
@ -543,12 +377,10 @@ public class Main_Frame extends JFrame {
}else if(pageNum==5){ }else if(pageNum==5){
// 航班选择页面 - 更新界面状态
label2.setOpaque(true); label2.setOpaque(true);
label1.setBackground(new Color(96,62,151)); label1.setBackground(new Color(96,62,151));
label2.setBackground(new Color(72,46,115)); label2.setBackground(new Color(72,46,115));
temp="110101199001011234"; // 这里默认扫描证件号 temp="360124200102040016";
System.out.println("页面5 航班选择页面 身份证号" + temp);
Flights_Panel flights1 = new Flights_Panel(); Flights_Panel flights1 = new Flights_Panel();
panelMiddle.add(flights1,"5"); panelMiddle.add(flights1,"5");
cardLayout.show(panelMiddle,"5"); cardLayout.show(panelMiddle,"5");
@ -564,34 +396,12 @@ public class Main_Frame extends JFrame {
}else if(pageNum==6){ }else if(pageNum==6){
// 航班确认逻辑
// 如果航班号不为空
if (!Objects.equals(Flights_Panel.flight_num, "")){ if (!Objects.equals(Flights_Panel.flight_num, "")){
// 确认航班选择
int n = JOptionPane.showConfirmDialog(null, "Are" + int n = JOptionPane.showConfirmDialog(null, "Are" +
" you sure you chose: "+ Flights_Panel.flight_num + "?", "CHECK",JOptionPane.YES_NO_OPTION);//返回的是按钮的index i=0或者1 " you sure you chose: "+ Flights_Panel.flight_num + "?", "CHECK",JOptionPane.YES_NO_OPTION);//返回的是按钮的index i=0或者1
if (n==0){ if (n==0){
// 用户确认选择 if(!flight.isBoarding(Flights_Panel.flight_num,Flights_Panel.idNum)){
OrderService orderService = new OrderService();
Optional<Order> optionalOrder = orderService.getOrderById(Flights_Panel.flight_order); // 根据用户的身份证号查找订单
// for (Order order1 : optionalOrder) {
// if (order1.getFlight_id().equals(Flights_Panel.flight_num)) {
// // 找到该订单,判断是否已经登机
// if (order1.isBoarding_status()) {
// flag = true; // 乘客已经登机
// }
// break;
// }
// }
Order order = optionalOrder.get();
// 这里有个bug如果乘客经常从北京往返上海提前买了同一列航班的好几张往返票日期不同
// 匹配票据的时候没有对日期进行判断
if(!order.isBoarding_status()){
// 用户尚未登机,进入座位选择
label3.setOpaque(true); label3.setOpaque(true);
label2.setBackground(new Color(96,62,151)); label2.setBackground(new Color(96,62,151));
label3.setBackground(new Color(72,46,115)); label3.setBackground(new Color(72,46,115));
@ -599,19 +409,14 @@ public class Main_Frame extends JFrame {
panelMiddle.add(seats,"6"); panelMiddle.add(seats,"6");
cardLayout.show(panelMiddle,"6"); cardLayout.show(panelMiddle,"6");
}else { }else {
// 用户已登机,不允许再次登机
JOptionPane.showMessageDialog(null, "You have already boarded the plane." + JOptionPane.showMessageDialog(null, "You have already boarded the plane." +
" You can't board again.", "warning", JOptionPane.INFORMATION_MESSAGE); " You can't board again.", "warning", JOptionPane.INFORMATION_MESSAGE);
pageNum--; pageNum--;
} }
}else { }else {
// 用户取消选择
pageNum--; pageNum--;
} }
}else { }else {pageNum--;
// 未选择航班
pageNum--;
JOptionPane.showMessageDialog(null, "Please choose" + JOptionPane.showMessageDialog(null, "Please choose" +
" your flight first.", "Tips", JOptionPane.INFORMATION_MESSAGE); " your flight first.", "Tips", JOptionPane.INFORMATION_MESSAGE);
} }
@ -619,15 +424,11 @@ public class Main_Frame extends JFrame {
}else if(pageNum==7){ }else if(pageNum==7){
// 座位确认逻辑
if (!Objects.equals(Seats_Panel.letter, "0")){ if (!Objects.equals(Seats_Panel.letter, "0")){
// 确认座位选择
int n = JOptionPane.showConfirmDialog(null, "Are" + int n = JOptionPane.showConfirmDialog(null, "Are" +
" you sure you chose: "+ Seats_Panel.letter +" " " you sure you chose: "+ Seats_Panel.letter +" "
+Seats_Panel.number+"?", "CHECK",JOptionPane.YES_NO_OPTION);//返回的是按钮的index i=0或者1 +Seats_Panel.number+"?", "CHECK",JOptionPane.YES_NO_OPTION);//返回的是按钮的index i=0或者1
if (n==0){ if (n==0){
// 用户确认选择,进入餐食选择
label4.setOpaque(true); label4.setOpaque(true);
label3.setBackground(new Color(96,62,151)); label3.setBackground(new Color(96,62,151));
label4.setBackground(new Color(72,46,115)); label4.setBackground(new Color(72,46,115));
@ -635,21 +436,16 @@ public class Main_Frame extends JFrame {
panelMiddle.add(foods,"7"); panelMiddle.add(foods,"7");
cardLayout.show(panelMiddle,"7"); cardLayout.show(panelMiddle,"7");
}else { }else {
// 用户取消选择
pageNum--; pageNum--;
} }
}else { }else {pageNum--;
// 未选择座位
pageNum--;
JOptionPane.showMessageDialog(null, "Please choose" + JOptionPane.showMessageDialog(null, "Please choose" +
" your seat first.", "Tips", JOptionPane.INFORMATION_MESSAGE); " your seat first.", "Tips", JOptionPane.INFORMATION_MESSAGE);
} }
}else if(pageNum==8) { }else if(pageNum==8) {
// 餐食确认逻辑
if (!Objects.equals(Foods_Panel.food, "")) { if (!Objects.equals(Foods_Panel.food, "")) {
// 进入信息确认页面
label5.setOpaque(true); label5.setOpaque(true);
label4.setBackground(new Color(96, 62, 151)); label4.setBackground(new Color(96, 62, 151));
label5.setBackground(new Color(72, 46, 115)); label5.setBackground(new Color(72, 46, 115));
@ -657,22 +453,16 @@ public class Main_Frame extends JFrame {
panelMiddle.add(confirm, "8"); panelMiddle.add(confirm, "8");
cardLayout.show(panelMiddle, "8"); cardLayout.show(panelMiddle, "8");
jButtonRight.setText("CONFIRM"); jButtonRight.setText("CONFIRM");
jButtonRight.setBackground(new Color(132, 177, 132)); // 绿色背景 jButtonRight.setBackground(new Color(132, 177, 132));
}else { }else {pageNum--;
// 未选择餐食
pageNum--;
JOptionPane.showMessageDialog(null, "Please choose" + JOptionPane.showMessageDialog(null, "Please choose" +
" your food first.", "Tips", JOptionPane.INFORMATION_MESSAGE); " your food first.", "Tips", JOptionPane.INFORMATION_MESSAGE);
} }
}else if(pageNum==9){//进入支付
}else if(pageNum==9){
// 支付页面 - 确认所有信息
int n = JOptionPane.showConfirmDialog(null, "Are you sure all" + int n = JOptionPane.showConfirmDialog(null, "Are you sure all" +
" the information is correct?", "CHECK",JOptionPane.YES_NO_OPTION);//返回的是按钮的index i=0或者1 " the information is correct?", "CHECK",JOptionPane.YES_NO_OPTION);//返回的是按钮的index i=0或者1
if (n==0){ if (n==0){
// 用户确认信息正确,进入支付
Pay_Panel payPanel = new Pay_Panel(); Pay_Panel payPanel = new Pay_Panel();
panelMiddle.add(payPanel,"9"); panelMiddle.add(payPanel,"9");
label5.setOpaque(true); label5.setOpaque(true);
@ -682,90 +472,44 @@ public class Main_Frame extends JFrame {
jButtonRight.setText("CONTINUE"); jButtonRight.setText("CONTINUE");
jButtonRight.setBackground(new Color(218,65,71)); jButtonRight.setBackground(new Color(218,65,71));
}else { }else {
// 用户需要修改信息
pageNum--; pageNum--;
} }
}else if(pageNum==10){ }else if(pageNum==10){//进入打印
// 打印登机牌页面
Print_Panel print = new Print_Panel(); Print_Panel print = new Print_Panel();
panelMiddle.add(print,"10"); panelMiddle.add(print,"10");
//保存座位
// ==================================== 源代码1 ================================================= eachFlight.seat_choose(flightNum,Seats_Panel.letter,Seats_Panel.number);
// 保存用户选择到系统 flight.add_seat(Flights_Panel.flight_order,Seats_Panel.letter,Seats_Panel.number);
// 保存座位选择行和列 - 座位实体类 //保存食物
// eachFlight.seat_choose(flightNum,Seats_Panel.letter,Seats_Panel.number); flight.add_food(Flights_Panel.flight_order,Foods_Panel.food);
// flight.add_seat(Flights_Panel.flight_order,Seats_Panel.letter,Seats_Panel.number); //保存已登机
// //保存食物 - 订单类 flight.boarding(Flights_Panel.flight_order);
// flight.add_food(Flights_Panel.flight_order,Foods_Panel.food); //保存注释
// //保存已登机 - 订单类 flight.add_note(Flights_Panel.flight_order,req);
// flight.boarding(Flights_Panel.flight_order);
// //保存注释 - 订单类
// flight.add_note(Flights_Panel.flight_order,req);
// ==================================== 源代码2 =================================================
// ==================================== 修改版1 =================================================
// 保存用户选择到系统
// 创建航班座位服务对象
FlightSeat flightSeat = new FlightSeat(Flights_Panel.flight_num,
Seats_Panel.number+Seats_Panel.letter.charAt(4), Integer.parseInt(Seats_Panel.number),
String.valueOf(Seats_Panel.letter.charAt(4)), "economy", false);
FlightSeatService flightSeatService = new FlightSeatService();
flightSeatService.addSeat(flightSeat); // 添加一个座位状态置位false表示座位已被占用
// 创建航班订单服务对象
OrderService orderService = new OrderService();
Optional<Order> op = orderService.getOrderById(Flights_Panel.flight_order); // 根据订单号查询订单,返回容器
Order order = op.get(); // 获取容器中的对象
order.setFood_name(Foods_Panel.food); // 修改餐食
order.setBoarding_status(true); // 修改为已登机
order.setNotes(req); // 保存注释
order.setSeat_id(flightSeat.getSeat_id()); // 修改链接的座位号
System.out.println("==============修改订单==============");
System.out.println(order);
orderService.updateOrder(order); // 修改订单
// ==================================== 修改版2 =================================================
cardLayout.show(panelMiddle,"10"); cardLayout.show(panelMiddle,"10");
}else if(pageNum==11){ }else if(pageNum==11){//进入展示动画
// 行李标签演示页面
cardLayout.show(panelMiddle,"11"); cardLayout.show(panelMiddle,"11");
jButtonRight.setText("FINISH"); jButtonRight.setText("FINISH");
}else if(pageNum==12){ }else if(pageNum==12){//进入展示动画
// 完成流程,退出系统
System.exit(0); System.exit(0);
} }
} }
}); });
// ==================== 帮助/返回按钮事件处理 ====================
jButtonLeft.addActionListener(new AbstractAction() { jButtonLeft.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 限制页面编号不低于最小值
if (pageNum>=0){ if (pageNum>=0){
pageNum--; pageNum--;
} }
// 根据当前编号执行相应操作 if (pageNum==-1){
if (pageNum == -1) { JOptionPane.showMessageDialog(null, "Please wait a moment. " +
// 请求人工帮助 "We have called for manual help for you.", "Manual help", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "Please wait a moment. " +
"We have called for manual help for you.", "Manual help", JOptionPane.INFORMATION_MESSAGE);
pageNum++; pageNum++;
}else if(pageNum==0){ }else if(pageNum==0){
// 返回主页面
cardLayout.show(panelMiddle,"0"); cardLayout.show(panelMiddle,"0");
label1.setBackground(new Color(96,62,151)); label1.setBackground(new Color(96,62,151));
jButtonLeft.setText("HELP"); jButtonLeft.setText("HELP");
@ -774,7 +518,6 @@ public class Main_Frame extends JFrame {
jButtonRight.setBackground(new Color(218,65,71)); jButtonRight.setBackground(new Color(218,65,71));
}else if(pageNum==1){ }else if(pageNum==1){
// 返回值机页面
temp=""; temp="";
flag = false; flag = false;
Check_in_bookingNum_Panel bookingNum = new Check_in_bookingNum_Panel(); Check_in_bookingNum_Panel bookingNum = new Check_in_bookingNum_Panel();
@ -788,7 +531,6 @@ public class Main_Frame extends JFrame {
}else if(pageNum==2){ }else if(pageNum==2){
// 返回身份证输入页面
temp=""; temp="";
flag = false; flag = false;
Check_in_idNum_Panel idNum = new Check_in_idNum_Panel(); Check_in_idNum_Panel idNum = new Check_in_idNum_Panel();
@ -801,7 +543,6 @@ public class Main_Frame extends JFrame {
cardLayout.show(panelMiddle,"1"); cardLayout.show(panelMiddle,"1");
}else if(pageNum==3){ }else if(pageNum==3){
// 返回值机页面(多步返回)
temp=""; temp="";
flag = false; flag = false;
label1.setOpaque(true); label1.setOpaque(true);
@ -813,7 +554,6 @@ public class Main_Frame extends JFrame {
}else if(pageNum==4){ }else if(pageNum==4){
// 返回值机页面(多步返回)
temp=""; temp="";
flag = false; flag = false;
Check_in_bookingNum_Panel bookingNum = new Check_in_bookingNum_Panel(); Check_in_bookingNum_Panel bookingNum = new Check_in_bookingNum_Panel();
@ -830,21 +570,18 @@ public class Main_Frame extends JFrame {
}else if(pageNum==5){ }else if(pageNum==5){
// 返回航班选择页面
label2.setOpaque(true); label2.setOpaque(true);
label3.setBackground(new Color(96,62,151)); label3.setBackground(new Color(96,62,151));
label2.setBackground(new Color(72,46,115)); label2.setBackground(new Color(72,46,115));
cardLayout.show(panelMiddle,"5"); cardLayout.show(panelMiddle,"5");
}else if(pageNum==6){ }else if(pageNum==6){
// 返回座位选择页面
label3.setOpaque(true); label3.setOpaque(true);
label4.setBackground(new Color(96,62,151)); label4.setBackground(new Color(96,62,151));
label3.setBackground(new Color(72,46,115)); label3.setBackground(new Color(72,46,115));
cardLayout.show(panelMiddle,"6"); cardLayout.show(panelMiddle,"6");
}else if(pageNum==7){ }else if(pageNum==7){
// 返回餐食选择页面
label4.setOpaque(true); label4.setOpaque(true);
label5.setBackground(new Color(96,62,151)); label5.setBackground(new Color(96,62,151));
label4.setBackground(new Color(72,46,115)); label4.setBackground(new Color(72,46,115));
@ -853,7 +590,6 @@ public class Main_Frame extends JFrame {
jButtonRight.setBackground(new Color(218,65,71)); jButtonRight.setBackground(new Color(218,65,71));
}else if(pageNum==8){ }else if(pageNum==8){
// 返回信息确认页面
label4.setOpaque(true); label4.setOpaque(true);
cardLayout.show(panelMiddle,"8"); cardLayout.show(panelMiddle,"8");
jButtonRight.setText("CONFIRM"); jButtonRight.setText("CONFIRM");
@ -862,18 +598,15 @@ public class Main_Frame extends JFrame {
} }
else if(pageNum==9){ else if(pageNum==9){
// 返回支付页面
cardLayout.show(panelMiddle,"9"); cardLayout.show(panelMiddle,"9");
} }
else if(pageNum==10){ else if(pageNum==10){
// 返回打印页面
cardLayout.show(panelMiddle,"10"); cardLayout.show(panelMiddle,"10");
jButtonRight.setText("CONTINUE"); jButtonRight.setText("CONTINUE");
} }
else if(pageNum==11){ else if(pageNum==11){
// 返回视频演示页面
cardLayout.show(panelMiddle,"11"); cardLayout.show(panelMiddle,"11");
jButtonRight.setText("CONTINUE"); jButtonRight.setText("CONTINUE");
} }
@ -885,21 +618,4 @@ public class Main_Frame extends JFrame {
frame.setVisible(true); frame.setVisible(true);
} }
/**
*
* @param args
*/
public static void main(String[] args) {
// 在事件分发线程中创建GUI确保线程安全
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// 创建Admin_Frame实例
Main_Frame mainFrame = new Main_Frame();
// 构建并显示管理员界面
mainFrame.buildMainFrame(new CardLayout());
}
});
}
} }

@ -9,66 +9,66 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
/** /**
* * Title : Check_in_Panel.java
* Description : This class is a directory for building three login modes.
*/ */
public class Check_in_Panel extends JPanel { public class Check_in_Panel extends JPanel {
// 构造方法:初始化登录选择面板,接收中间内容面板和右侧功能按钮用于界面切换
public Check_in_Panel(JPanel panelMiddle, JButton jButtonRight){ public Check_in_Panel(JPanel panelMiddle, JButton jButtonRight){
// 设置深紫色背景,统一主题 //设置背景颜色
setBackground(new Color(72,46,115)); setBackground(new Color(72,46,115));
//设置初始面板
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setBackground(new Color(72,46,115)); panel.setBackground(new Color(72,46,115));
panel.setPreferredSize(new Dimension(1200,680)); panel.setPreferredSize(new Dimension(1200,680));
add(panel); add(panel);
// 使用自定义布局管理器控制组件布局
panel.setLayout(new MyLayout(panel)); panel.setLayout(new MyLayout(panel));
// 顶部空白面板,调整内容位置
JPanel Panel1 = new JPanel(); JPanel Panel1 = new JPanel();
Panel1.setBackground(new Color(72,46,115)); Panel1.setBackground(new Color(72,46,115));
panel.add(Panel1, new GBC(0,0,3,1).setFill(GBC.BOTH).setIpad(1200, 58).setWeight(10, 0)); panel.add(Panel1, new GBC(0,0,3,1).
setFill(GBC.BOTH).setIpad(1200, 58).setWeight(10, 0));
// 左侧空白面板,平衡布局
JPanel Panel2 = new JPanel(); JPanel Panel2 = new JPanel();
Panel2.setBackground(new Color(72,46,115)); Panel2.setBackground(new Color(72,46,115));
panel.add(Panel2,new GBC(0,1,1,5).setFill(GBC.BOTH).setIpad(260, 544).setWeight(10, 10)); panel.add(Panel2,new GBC(0,1,1,5).
setFill(GBC.BOTH).setIpad(260, 544).setWeight(10, 10));
// 预订号登录按钮容器
JPanel Panel3 = new JPanel(); JPanel Panel3 = new JPanel();
panel.add(Panel3,new GBC(1,1).setFill(GBC.BOTH).setIpad(200, 100).setWeight(10, 10)); panel.add(Panel3,new GBC(1,1).
setFill(GBC.BOTH).setIpad(200, 100).setWeight(10, 10));
// 按钮间隔面板
JPanel Panel4 = new JPanel(); JPanel Panel4 = new JPanel();
Panel4.setBackground(new Color(72,46,115)); Panel4.setBackground(new Color(72,46,115));
panel.add(Panel4,new GBC(1,2).setFill(GBC.BOTH).setIpad(200, 68).setWeight(10, 10)); panel.add(Panel4,new GBC(1,2).
setFill(GBC.BOTH).setIpad(200, 68).setWeight(10, 10));
// 身份证号登录按钮容器
JPanel Panel5 = new JPanel(); JPanel Panel5 = new JPanel();
panel.add(Panel5,new GBC(1,3).setFill(GBC.BOTH).setIpad(200, 100).setWeight(10, 10)); panel.add(Panel5,new GBC(1,3).
setFill(GBC.BOTH).setIpad(200, 100).setWeight(10, 10));
// 按钮间隔面板
JPanel Panel6 = new JPanel(); JPanel Panel6 = new JPanel();
Panel6.setBackground(new Color(72,46,115)); Panel6.setBackground(new Color(72,46,115));
panel.add(Panel6,new GBC(1,4).setFill(GBC.BOTH).setIpad(200, 68).setWeight(10, 10)); panel.add(Panel6,new GBC(1,4).
setFill(GBC.BOTH).setIpad(200, 68).setWeight(10, 10));
// 扫描身份证登录按钮容器
JPanel Panel7 = new JPanel(); JPanel Panel7 = new JPanel();
panel.add(Panel7,new GBC(1,5).setFill(GBC.BOTH).setIpad(200, 100).setWeight(10, 10)); panel.add(Panel7,new GBC(1,5).
setFill(GBC.BOTH).setIpad(200, 100).setWeight(10, 10));
// 右侧空白面板,平衡布局
JPanel Panel8 = new JPanel(); JPanel Panel8 = new JPanel();
Panel8.setBackground(new Color(72,46,115)); Panel8.setBackground(new Color(72,46,115));
panel.add(Panel8,new GBC(2,1 ,1,5).setFill(GBC.BOTH).setIpad(260,544).setWeight(10, 0)); panel.add(Panel8,new GBC(2,1 ,1,5).
setFill(GBC.BOTH).setIpad(260,544).setWeight(10, 0));
// 底部空白面板,调整内容位置
JPanel Panel9 = new JPanel(); JPanel Panel9 = new JPanel();
Panel9.setBackground(new Color(72,46,115)); Panel9.setBackground(new Color(72,46,115));
panel.add(Panel9,new GBC(0,6,3,1).setFill(GBC.BOTH).setIpad(1200,78).setWeight(10, 0)); panel.add(Panel9,new GBC(0,6,3,1).
setFill(GBC.BOTH).setIpad(1200,78).setWeight(10, 0));
// 创建三种登录方式按钮(浅紫色背景、白色文字)
JButton buttonTOP = new JButton("INPUT THE BOOKING NUMBER"); JButton buttonTOP = new JButton("INPUT THE BOOKING NUMBER");
buttonTOP.setBackground(new Color(96,62,151)); buttonTOP.setBackground(new Color(96,62,151));
buttonTOP.setFont(new Font (Font.DIALOG,Font.BOLD, 42)); buttonTOP.setFont(new Font (Font.DIALOG,Font.BOLD, 42));
@ -85,7 +85,7 @@ public class Check_in_Panel extends JPanel {
buttonBOT.setForeground(Color.white); buttonBOT.setForeground(Color.white);
// 按钮添加到对应容器,占满容器
Panel3.setLayout(new GridLayout(1, 1)); Panel3.setLayout(new GridLayout(1, 1));
Panel3.add(buttonTOP); Panel3.add(buttonTOP);
Panel5.setLayout(new GridLayout(1, 1)); Panel5.setLayout(new GridLayout(1, 1));
@ -93,31 +93,57 @@ public class Check_in_Panel extends JPanel {
Panel7.setLayout(new GridLayout(1, 1)); Panel7.setLayout(new GridLayout(1, 1));
Panel7.add(buttonBOT); Panel7.add(buttonBOT);
// 预订号登录按钮事件:切换到预订号登录面板,更新右侧按钮状态 buttonTOP.addActionListener(new AbstractAction() {
buttonTOP.addActionListener(e -> { @Override
Init.cardLayout.show(panelMiddle, "2"); public void actionPerformed(ActionEvent e) {
Main_Frame.pageNum++; Init.cardLayout.show(panelMiddle, "2");
jButtonRight.setText("CONTINUE"); Main_Frame.pageNum++;
jButtonRight.setBackground(new Color(132, 177, 132)); jButtonRight.setText("CONTINUE");
jButtonRight.setVisible(true); jButtonRight.setBackground(new Color(132, 177, 132));
jButtonRight.setVisible(true);
}
}); });
// 身份证号登录按钮事件:切换到身份证号登录面板,更新右侧按钮状态 buttonMID.addActionListener(new AbstractAction() {
buttonMID.addActionListener(e -> { @Override
Init.cardLayout.show(panelMiddle, "3"); public void actionPerformed(ActionEvent e) {
jButtonRight.setText("CONTINUE"); Init.cardLayout.show(panelMiddle, "3");
jButtonRight.setBackground(new Color(132, 177, 132)); jButtonRight.setText("CONTINUE");
jButtonRight.setVisible(true); jButtonRight.setBackground(new Color(132, 177, 132));
Main_Frame.pageNum += 2; jButtonRight.setVisible(true);
Main_Frame.pageNum=Main_Frame.pageNum+2;
}
}); });
// 扫描登录按钮事件:切换到扫描登录面板,更新右侧按钮状态 buttonBOT.addActionListener(new AbstractAction() {
buttonBOT.addActionListener(e -> { @Override
Init.cardLayout.show(panelMiddle, "4"); public void actionPerformed(ActionEvent e) {
Main_Frame.pageNum += 3; Init.cardLayout.show(panelMiddle, "4");
jButtonRight.setText("CONTINUE"); Main_Frame.pageNum=Main_Frame.pageNum+3;
jButtonRight.setBackground(new Color(132, 177, 132)); jButtonRight.setText("CONTINUE");
jButtonRight.setVisible(true); jButtonRight.setBackground(new Color(132, 177, 132));
jButtonRight.setVisible(true);
}
}); });
/*JButton jButton = new JButton("121");
panel.add(jButton);
jButton.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
Init.cardLayout.show(panelMiddle, "8");
}
});*/
} }
}
}

@ -244,24 +244,5 @@ public class Check_in_bookingNum_Panel extends JPanel {
; // 若没有内容,则不执行删除 ; // 若没有内容,则不执行删除
} }
}); });
// -------- Ctrl+V 粘贴功能 --------
BookingNumInputArea.addKeyListener(new java.awt.event.KeyAdapter() {
@Override
public void keyPressed(java.awt.event.KeyEvent e) {
if (e.isControlDown() && e.getKeyCode() == java.awt.event.KeyEvent.VK_V) {
try {
String paste = (String) Toolkit.getDefaultToolkit()
.getSystemClipboard()
.getData(java.awt.datatransfer.DataFlavor.stringFlavor);
if (paste != null) {
paste = paste.trim(); // 去掉首尾空白
IDnum = paste; // 同步静态变量
BookingNumInputArea.setText(paste); // 显示到输入框
}
} catch (Exception ignored) { /* 粘贴失败则静默忽略 */ }
}
}
});
} }
} }

@ -7,57 +7,41 @@ import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* Title : Check_in_idNum_Panel.java * Title : Check_in_idNum_Panel.java
* Description : 使 * Description : This class is used to build an interface for logging in with an id number.
*
*
* (Main_Frame.flag = false)
* (Main_Frame.flag = true)
*/ */
// 身份证号登录面板类继承自JPanel用于实现身份证号/姓氏输入的交互界面
public class Check_in_idNum_Panel extends JPanel { public class Check_in_idNum_Panel extends JPanel {
// 静态变量:存储用户输入的身份证号 //
//
//IDNum_panel本来就是输入的身份证号放在这个静态变量里了。
public static String IDnum = ""; public static String IDnum = "";
// 静态变量:存储用户输入的姓氏
public static String Surname = ""; public static String Surname = "";
//
//
// 初始化身份证号登录面板的所有组件和布局
public Check_in_idNum_Panel(){ public Check_in_idNum_Panel(){
// 设置当前面板背景色为深紫 //设置背景颜
setBackground(new Color(72,46,115)); setBackground(new Color(72,46,115));
// 创建内部主容器面板,统一管理所有组件 //设置初始面板
JPanel panel = new JPanel(); JPanel panel = new JPanel();
// 主容器面板背景色与外层面板一致 panel.setBackground(new Color(72,46,115));//设置背景颜色
panel.setBackground(new Color(72,46,115)); panel.setPreferredSize(new Dimension(1200,680));//设置尺寸
// 设置主容器面板首选尺寸
panel.setPreferredSize(new Dimension(1200,680));
// 将主容器面板添加到当前面板
add(panel); add(panel);
// 主容器采用绝对布局(手动控制组件位置) panel.setLayout(null);//关闭布局设置,采用绝对布局
panel.setLayout(null);
// 创建文本输入框:用于显示输入的身份证号或姓氏,不可手动编辑
JTextField IDNumInputArea = new JTextField("", 30); JTextField IDNumInputArea = new JTextField("", 30);
IDNumInputArea.setText(""); //外观设计
// 设置输入框位置和尺寸 IDNumInputArea.setText("");//初始化文本框为空
IDNumInputArea.setBounds(284,105,632,50); IDNumInputArea.setBounds(284,105,632,50);//设置尺寸和绝对坐标
// 设置输入框字体样式 IDNumInputArea.setFont(new Font (Font.DIALOG,Font.BOLD, 40));//设置字体
IDNumInputArea.setFont(new Font (Font.DIALOG,Font.BOLD, 40)); IDNumInputArea.setHorizontalAlignment(JTextField.CENTER);//文本居中
// 文本居中显示 IDNumInputArea.setForeground(Color.WHITE);//设置文本颜色
IDNumInputArea.setHorizontalAlignment(JTextField.CENTER); IDNumInputArea.setBackground(new Color(72,46,115));//设置背景
// 设置文本和背景颜色
IDNumInputArea.setForeground(Color.WHITE);
IDNumInputArea.setBackground(new Color(72,46,115));
// 设置输入框不可手动编辑(仅通过虚拟键盘输入)
IDNumInputArea.setEditable(false); IDNumInputArea.setEditable(false);
// 添加白色边框 IDNumInputArea.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));//设置边框
IDNumInputArea.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); panel.add(IDNumInputArea);//将文本框添加到面板里
// 将输入框添加到主容器
panel.add(IDNumInputArea);
// 创建提示标签:显示当前输入要求(身份证号/姓氏)
JLabel IDNumHint = new JLabel(""); JLabel IDNumHint = new JLabel("");
if (!Main_Frame.flag){ if (!Main_Frame.flag){
IDNumHint.setText("ENTER YOUR ID NUMBER AND SELECT CONFIRM"); IDNumHint.setText("ENTER YOUR ID NUMBER AND SELECT CONFIRM");
@ -65,37 +49,33 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumHint.setText("NOW ENTER YOUR SURNAME AND SELECT CONFIRM"); IDNumHint.setText("NOW ENTER YOUR SURNAME AND SELECT CONFIRM");
} }
// 设置提示标签位置和尺寸 //外观设计
IDNumHint.setBounds(184,45,816,50); IDNumHint.setBounds(184,45,816,50);
// 设置提示标签字体样式 IDNumHint.setFont(new Font(Font.DIALOG,Font.BOLD,29));//设置文字字体
IDNumHint.setFont(new Font(Font.DIALOG,Font.BOLD,29)); IDNumHint.setForeground(Color.white);//设置文字的颜色
// 设置文字和背景颜色
IDNumHint.setForeground(Color.white);
IDNumHint.setOpaque(true); IDNumHint.setOpaque(true);
IDNumHint.setBackground(new Color(72,46,115)); IDNumHint.setBackground(new Color(72,46,115));
// 设置标签首选尺寸
IDNumHint.setPreferredSize(new Dimension(800,80)); IDNumHint.setPreferredSize(new Dimension(800,80));
// 文字居中显示
IDNumHint.setHorizontalAlignment(JLabel.CENTER); IDNumHint.setHorizontalAlignment(JLabel.CENTER);
// 将提示标签添加到主容器
panel.add(IDNumHint); panel.add(IDNumHint);
// 第一行按钮数字键1-0共10个 //
//
//用四个Arraylisy分别存放四行的按钮并通过for循环一次递增坐标和属性设置
//
//
ArrayList<JButton> first_row = new ArrayList<>(); ArrayList<JButton> first_row = new ArrayList<>();
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
first_row.add(new JButton()); first_row.add(new JButton());
panel.add(first_row.get(i)); panel.add(first_row.get(i));
// 设置按钮样式(背景、文字颜色、字体、边框)
first_row.get(i).setBackground(new Color(96,62,151)); first_row.get(i).setBackground(new Color(96,62,151));
first_row.get(i).setForeground(Color.white); first_row.get(i).setForeground(Color.white);
first_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); first_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
first_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); first_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 按索引设置按钮文本、位置和点击事件(点击追加对应数字到输入框)
switch(i){ switch(i){
case 0: case 0: first_row.get(i).setText("1");
first_row.get(i).setText("1");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e)->{ first_row.get(i).addActionListener((e)->{
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -104,8 +84,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 1: case 1: first_row.get(i).setText("2");
first_row.get(i).setText("2");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -114,8 +93,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 2: case 2: first_row.get(i).setText("3");
first_row.get(i).setText("3");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -124,8 +102,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 3: case 3: first_row.get(i).setText("4");
first_row.get(i).setText("4");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -134,8 +111,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 4: case 4: first_row.get(i).setText("5");
first_row.get(i).setText("5");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -144,8 +120,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 5: case 5: first_row.get(i).setText("6");
first_row.get(i).setText("6");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -154,8 +129,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 6: case 6: first_row.get(i).setText("7");
first_row.get(i).setText("7");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -164,8 +138,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 7: case 7: first_row.get(i).setText("8");
first_row.get(i).setText("8");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -174,8 +147,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 8: case 8: first_row.get(i).setText("9");
first_row.get(i).setText("9");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -184,8 +156,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 9: case 9: first_row.get(i).setText("0");
first_row.get(i).setText("0");
first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75); first_row.get(i).setBounds(105 + 90 * i, 202, 75, 75);
first_row.get(i).addActionListener((e) -> { first_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -197,21 +168,17 @@ public class Check_in_idNum_Panel extends JPanel {
} }
} }
// 第二行按钮字母键Q-P共10个
ArrayList<JButton> second_row = new ArrayList<>(); ArrayList<JButton> second_row = new ArrayList<>();
for(int i = 0; i < 10; i++){ for(int i = 0; i < 10; i++){
//JButton temp = new JButton();
second_row.add(new JButton()); second_row.add(new JButton());
panel.add(second_row.get(i)); panel.add(second_row.get(i));
// 设置按钮样式
second_row.get(i).setBackground(new Color(96,62,151)); second_row.get(i).setBackground(new Color(96,62,151));
second_row.get(i).setForeground(Color.white); second_row.get(i).setForeground(Color.white);
second_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); second_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
second_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); second_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 按索引设置按钮文本、位置和点击事件(点击追加对应字母到输入框)
switch(i){ switch(i){
case 0: case 0: second_row.get(i).setText("Q");
second_row.get(i).setText("Q");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -220,8 +187,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 1: case 1: second_row.get(i).setText("W");
second_row.get(i).setText("W");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -230,8 +196,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 2: case 2: second_row.get(i).setText("E");
second_row.get(i).setText("E");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -240,8 +205,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 3: case 3: second_row.get(i).setText("R");
second_row.get(i).setText("R");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -250,8 +214,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 4: case 4: second_row.get(i).setText("T");
second_row.get(i).setText("T");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -260,8 +223,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 5: case 5: second_row.get(i).setText("Y");
second_row.get(i).setText("Y");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -270,8 +232,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 6: case 6: second_row.get(i).setText("U");
second_row.get(i).setText("U");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -280,8 +241,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 7: case 7: second_row.get(i).setText("I");
second_row.get(i).setText("I");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -290,8 +250,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 8: case 8: second_row.get(i).setText("O");
second_row.get(i).setText("O");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -300,8 +259,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 9: case 9: second_row.get(i).setText("P");
second_row.get(i).setText("P");
second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75); second_row.get(i).setBounds(105 + 90 * i, 287, 75, 75);
second_row.get(i).addActionListener((e) -> { second_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -313,22 +271,18 @@ public class Check_in_idNum_Panel extends JPanel {
} }
} }
// 第三行按钮字母键A-L共9个
ArrayList<JButton> third_row = new ArrayList<>(); ArrayList<JButton> third_row = new ArrayList<>();
for(int i = 0; i < 9; i++){ for(int i = 0; i < 9; i++){
third_row.add(new JButton()); third_row.add(new JButton());
panel.add(third_row.get(i)); panel.add(third_row.get(i));
// 设置按钮样式
third_row.get(i).setBackground(new Color(96,62,151)); third_row.get(i).setBackground(new Color(96,62,151));
third_row.get(i).setForeground(Color.white); third_row.get(i).setForeground(Color.white);
third_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); third_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
third_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); third_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 按索引设置按钮文本、位置和点击事件(点击追加对应字母到输入框)
switch(i){ switch(i){
case 0: case 0: third_row.get(i).setText("A");
third_row.get(i).setText("A");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -337,8 +291,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 1: case 1: third_row.get(i).setText("S");
third_row.get(i).setText("S");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -347,8 +300,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 2: case 2: third_row.get(i).setText("D");
third_row.get(i).setText("D");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -357,8 +309,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 3: case 3: third_row.get(i).setText("F");
third_row.get(i).setText("F");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -367,8 +318,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 4: case 4: third_row.get(i).setText("G");
third_row.get(i).setText("G");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -377,8 +327,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 5: case 5: third_row.get(i).setText("H");
third_row.get(i).setText("H");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -387,8 +336,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 6: case 6: third_row.get(i).setText("J");
third_row.get(i).setText("J");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -397,8 +345,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 7: case 7: third_row.get(i).setText("K");
third_row.get(i).setText("K");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -407,8 +354,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 8: case 8: third_row.get(i).setText("L");
third_row.get(i).setText("L");
third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75); third_row.get(i).setBounds(160 + 90 * i, 372, 75, 75);
third_row.get(i).addActionListener((e) -> { third_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -420,21 +366,18 @@ public class Check_in_idNum_Panel extends JPanel {
} }
} }
// 第四行按钮字母键Z-M共9个前7个有效
ArrayList<JButton> fourth_row = new ArrayList<>(); ArrayList<JButton> fourth_row = new ArrayList<>();
for(int i = 0; i < 9; i++){ for(int i = 0; i < 9; i++){
fourth_row.add(new JButton()); fourth_row.add(new JButton());
panel.add(fourth_row.get(i)); panel.add(fourth_row.get(i));
// 设置按钮样式
fourth_row.get(i).setBackground(new Color(96,62,151)); fourth_row.get(i).setBackground(new Color(96,62,151));
fourth_row.get(i).setForeground(Color.white); fourth_row.get(i).setForeground(Color.white);
fourth_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45)); fourth_row.get(i).setFont(new Font (Font.DIALOG, Font.PLAIN, 45));
fourth_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); fourth_row.get(i).setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 按索引设置按钮文本、位置和点击事件(点击追加对应字母到输入框)
switch(i){ switch(i){
case 0: case 0: fourth_row.get(i).setText("Z");
fourth_row.get(i).setText("Z");
fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75); fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75);
fourth_row.get(i).addActionListener((e) -> { fourth_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -443,8 +386,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 1: case 1: fourth_row.get(i).setText("X");
fourth_row.get(i).setText("X");
fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75); fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75);
fourth_row.get(i).addActionListener((e) -> { fourth_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -453,8 +395,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 2: case 2: fourth_row.get(i).setText("C");
fourth_row.get(i).setText("C");
fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75); fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75);
fourth_row.get(i).addActionListener((e) -> { fourth_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -463,8 +404,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 3: case 3: fourth_row.get(i).setText("V");
fourth_row.get(i).setText("V");
fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75); fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75);
fourth_row.get(i).addActionListener((e) -> { fourth_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -473,8 +413,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 4: case 4: fourth_row.get(i).setText("B");
fourth_row.get(i).setText("B");
fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75); fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75);
fourth_row.get(i).addActionListener((e) -> { fourth_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -483,8 +422,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 5: case 5: fourth_row.get(i).setText("N");
fourth_row.get(i).setText("N");
fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75); fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75);
fourth_row.get(i).addActionListener((e) -> { fourth_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -493,8 +431,7 @@ public class Check_in_idNum_Panel extends JPanel {
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
}); });
break; break;
case 6: case 6: fourth_row.get(i).setText("M");
fourth_row.get(i).setText("M");
fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75); fourth_row.get(i).setBounds(250 + 90 * i, 457, 75, 75);
fourth_row.get(i).addActionListener((e) -> { fourth_row.get(i).addActionListener((e) -> {
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
@ -505,45 +442,23 @@ public class Check_in_idNum_Panel extends JPanel {
} }
} }
// 创建删除按钮:删除输入框中最后一个字符 //添加删除键,原理同上
JButton delete = new JButton("Delete"); JButton delete = new JButton("Delete");
panel.add(delete); panel.add(delete);
// 设置删除按钮样式
delete.setBackground(new Color(96,62,151)); delete.setBackground(new Color(96,62,151));
delete.setForeground(Color.white); delete.setForeground(Color.white);
delete.setFont(new Font (Font.DIALOG, Font.PLAIN, 30)); delete.setFont(new Font (Font.DIALOG, Font.PLAIN, 30));
delete.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); delete.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
// 设置删除按钮位置和尺寸
delete.setBounds(1015,202,126,75); delete.setBounds(1015,202,126,75);
// 点击事件删除输入框最后一个字符同步更新IDnum
delete.addActionListener((e) -> { delete.addActionListener((e) -> {
//若存在文本则执行删除操作,无则不执行
if( IDNumInputArea.getText().length() > 0 ){ if( IDNumInputArea.getText().length() > 0 ){
String temp = IDNumInputArea.getText(); String temp = IDNumInputArea.getText();
temp = temp.substring(0, temp.length() - 1); temp = temp.substring(0, temp.length() - 1);
IDnum = temp; IDnum = temp;
IDNumInputArea.setText(temp); IDNumInputArea.setText(temp);
} }
}); else;
// 给 IDNumInputArea 绑定 Ctrl+V 粘贴键盘事件
IDNumInputArea.addKeyListener(new java.awt.event.KeyAdapter() {
@Override
public void keyPressed(java.awt.event.KeyEvent e) {
if (e.isControlDown() && e.getKeyCode() == java.awt.event.KeyEvent.VK_V) {
try {
// 获取系统剪贴板内容
java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String paste = (String) clipboard.getData(java.awt.datatransfer.DataFlavor.stringFlavor);
if (paste != null) {
paste = paste.trim(); // 去掉首尾空白
IDnum = paste; // 同步到静态变量
IDNumInputArea.setText(paste); // 显示到输入框
}
} catch (Exception ex) {
// 粘贴失败时静默忽略,也可弹出提示
}
}
}
}); });

@ -6,45 +6,47 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
/** /**
* * <p>This page is mainly used to log in passengers by scanning their ID cards.</p>
* @author *
* @author Qingwei Gao
* @version 3.1 * @version 3.1
*/ */
public class Check_in_scanNum_Panel extends JPanel { public class Check_in_scanNum_Panel extends JPanel {
// 构造方法:初始化扫描登录面板
public Check_in_scanNum_Panel(){ public Check_in_scanNum_Panel(){
// 设置深紫色背景72,46,115 //Set background color
setBackground(new Color(72,46,115)); setBackground(new Color(72,46,115));
// 创建内部面板用于布局管理 //Set initial panel
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setBackground(new Color(72,46,115)); panel.setBackground(new Color(72,46,115));
panel.setPreferredSize(new Dimension(1200,680)); panel.setPreferredSize(new Dimension(1200,680));
add(panel); add(panel);
// 创建操作提示标签
JLabel label1 = new JLabel("PLEASE PUT YOUR ID DOCUMENT UNDER THE CAMERA TO SCAN"); JLabel label1 = new JLabel("PLEASE PUT YOUR ID DOCUMENT UNDER THE CAMERA TO SCAN");
JLabel label2 = new JLabel("AFTER COMPLETING THE SCAN, CLICK CONFIRM"); JLabel label2 = new JLabel("AFTER COMPLETING THE SCAN, CLICK CONFIRM");
// 创建身份证扫描示意图标签
JLabel icon = new JLabel(); JLabel icon = new JLabel();
int width = 600, height = 300; // 图片和标签尺寸 int width = 600,height = 300;//This is the width and height of the picture and JLabel
// 加载并缩放身份证示意图(从常量类获取资源路径) ImageIcon image = new ImageIcon(Constant.RESOURCE_PATH + "card.png");//Instantiate imageicon object
ImageIcon image = new ImageIcon(Constant.RESOURCE_PATH + "card.png"); image.setImage(image.getImage().getScaledInstance(width, height,Image.SCALE_DEFAULT ));
image.setImage(image.getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT));
icon.setIcon(image); icon.setIcon(image);
// 设置提示文字样式白色28号对话框字体 label1.setFont(new Font(Font.DIALOG,Font.PLAIN,28));//Set text font
label1.setFont(new Font(Font.DIALOG, Font.PLAIN, 28)); label1.setForeground(Color.white);//Set text color
label1.setForeground(Color.white); label2.setFont(new Font(Font.DIALOG,Font.PLAIN,28));//Set text font
label2.setFont(new Font(Font.DIALOG, Font.PLAIN, 28)); label2.setForeground(Color.white);//Set text color
label2.setForeground(Color.white);
// 采用绝对布局手动定位组件
panel.setLayout(null); panel.setLayout(null);
label1.setBounds(150, 50, 1000, 50); // 顶部提示文字
label1.setBounds(150,50,1000,50);
panel.add(label1); panel.add(label1);
label2.setBounds(250, 100, 1000, 50); // 操作确认提示 label2.setBounds(250,100,1000,50);
panel.add(label2); panel.add(label2);
icon.setBounds(300, -180, 1000, 1000); // 身份证示意图(向上偏移布局) icon.setBounds(300,-180,1000,1000);
panel.add(icon); panel.add(icon);
} }
} }

@ -3,51 +3,40 @@ package frame.UserPanel;
import constant.Constant; import constant.Constant;
import frame.Main_Frame; import frame.Main_Frame;
import model_new.Flight; import model.eachFlight;
import service.FlightService;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
/** /**
* <p>This page is mainly for passengers to confirm the previously selected information for final confirmation.</p> * <p>This page is mainly for passengers to confirm the previously selected information for final confirmation.</p>
* <p></p>
* *
* @author Qingwei Gao * @author Qingwei Gao
* @version 3.1 * @version 3.1
*/ */
public class Confirm_Panel extends JPanel { public class Confirm_Panel extends JPanel {
/**
* -
*/
public Confirm_Panel() { public Confirm_Panel() {
//设置当前面板背景颜色为深紫色(72, 46, 115) //Set background color
setBackground(new Color(72, 46, 115)); setBackground(new Color(72, 46, 115));
//创建一个内部主面板 //Set initial panel
JPanel panel = new JPanel(); JPanel panel = new JPanel();
//设置内部主面板背景颜色与外层一致
panel.setBackground(new Color(72, 46, 115)); panel.setBackground(new Color(72, 46, 115));
//设置内部主面板首选尺寸为1200x680像素
panel.setPreferredSize(new Dimension(1200, 680)); panel.setPreferredSize(new Dimension(1200, 680));
//将内部主面板添加到当前面板
add(panel); add(panel);
//创建一个信息展示子面板(用于显示航班等信息)
JPanel panel1 = new JPanel(); JPanel panel1 = new JPanel();
//设置信息展示面板背景颜色为紫色(96,62,151)
panel1.setBackground(new Color(96,62,151)); panel1.setBackground(new Color(96,62,151));
//将食品选择面板中选择的食品类型赋值给主框架的foodType变量
Main_Frame.foodType=Foods_Panel.food; Main_Frame.foodType=Foods_Panel.food;
// ==================== 创建所有文本标签 ====================
// 提示信息标签
JLabel label1 = new JLabel("PLEASE PUT YOUR "); JLabel label1 = new JLabel("PLEASE PUT YOUR ");
JLabel label2 = new JLabel("ID DOCUMENT"); JLabel label2 = new JLabel("ID DOCUMENT");
JLabel label3 = new JLabel("UNDER THE CAMERA TO SCAN"); JLabel label3 = new JLabel("UNDER THE CAMERA TO SCAN");
@ -57,51 +46,19 @@ public class Confirm_Panel extends JPanel {
JLabel label7 = new JLabel("COMPLETING THE SCAN"); JLabel label7 = new JLabel("COMPLETING THE SCAN");
JLabel label8 = new JLabel("CLICK"); JLabel label8 = new JLabel("CLICK");
JLabel label9 = new JLabel("CONFIRM"); JLabel label9 = new JLabel("CONFIRM");
// 信息标题标签
JLabel label11 = new JLabel("BOARDING TIME"); JLabel label11 = new JLabel("BOARDING TIME");
JLabel label12 = new JLabel("GATE"); JLabel label12 = new JLabel("GATE");
JLabel label13 = new JLabel("SEATS"); JLabel label13 = new JLabel("SEATS");
JLabel label14 = new JLabel("FOODS"); JLabel label14 = new JLabel("FOODS");
// 具体信息标签
JLabel label15 = new JLabel(Main_Frame.flightNum); JLabel label15 = new JLabel(Main_Frame.flightNum);
JLabel label16 = new JLabel(eachFlight.boardingTime(Main_Frame.flightNum));
// ===============================================修改前======================================= JLabel label17 = new JLabel(eachFlight.GATE(Main_Frame.flightNum));
// JLabel label16 = new JLabel(eachFlight.boardingTime(Main_Frame.flightNum));
// JLabel label17 = new JLabel(eachFlight.GATE(Main_Frame.flightNum));
// JLabel label18 = new JLabel(Seats_Panel.number+" "+Seats_Panel.letter);
// JLabel label19 = new JLabel(Main_Frame.foodType);
// JLabel label20 = new JLabel(eachFlight.COMPANY(Main_Frame.flightNum));
// ===============================================修改前=======================================
// ===============================================修改后=======================================
FlightService flightService = new FlightService(); // 创建航班服务函数
Optional<Flight> optionalFlight = flightService.findFlightById(Main_Frame.flightNum); // 查找对应的航班
Flight flight = optionalFlight.orElse(new Flight()); // 如果航班不存在则创建一个新对象
// 获取Flight对象方法二
// if (optionalFlight.isPresent()) {
// Flight flight = optionalFlight.get();
// }
// 获取航班登机时间
JLabel label16 = new JLabel(flight.getBoarding_time().toLocalDateTime().format(DateTimeFormatter.ofPattern("HH:mm")));
// 获取航班登机口
JLabel label17 = new JLabel(flight.getGate());
// 获取座位位置
JLabel label18 = new JLabel(Seats_Panel.number+" "+Seats_Panel.letter); JLabel label18 = new JLabel(Seats_Panel.number+" "+Seats_Panel.letter);
//显示选择的食品类型(从主框架获取)
JLabel label19 = new JLabel(Main_Frame.foodType); JLabel label19 = new JLabel(Main_Frame.foodType);
// 获取航空公司名 JLabel label20 = new JLabel(eachFlight.COMPANY(Main_Frame.flightNum));
JLabel label20 = new JLabel(flight.getAirline_company());
// ===============================================修改后=======================================
// ==================== 设置标签字体和颜色 ====================
// 设置普通文本标签样式
label1.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//Set text font label1.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//Set text font
label1.setForeground(Color.white);//Set text color label1.setForeground(Color.white);//Set text color
label3.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//Set text font label3.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//Set text font
@ -112,28 +69,24 @@ public class Confirm_Panel extends JPanel {
label6.setForeground(Color.white);//Set text color label6.setForeground(Color.white);//Set text color
label8.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//Set text font label8.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//Set text font
label8.setForeground(Color.white);//Set text color label8.setForeground(Color.white);//Set text color
// 设置加粗文本标签样式
label2.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font label2.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label2.setForeground(Color.white);//Set text color label2.setForeground(Color.white);//Set text color
label5.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label5.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label5.setForeground(Color.white);//Set text color label5.setForeground(Color.white);//Set text color
label7.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label7.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label7.setForeground(Color.white);//Set text color label7.setForeground(Color.white);//Set text color
label9.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label9.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label9.setForeground(Color.white);//Set text color label9.setForeground(Color.white);//Set text color
label11.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label11.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label11.setForeground(Color.white);//Set text color label11.setForeground(Color.white);//Set text color
label12.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label12.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label12.setForeground(Color.white);//Set text color label12.setForeground(Color.white);//Set text color
label13.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label13.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label13.setForeground(Color.white);//Set text color label13.setForeground(Color.white);//Set text color
label14.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label14.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label14.setForeground(Color.white);//Set text color label14.setForeground(Color.white);//Set text color
label15.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font(加粗) label15.setFont(new Font(Font.DIALOG,Font.BOLD,26));//Set text font
label15.setForeground(Color.white);//Set text color label15.setForeground(Color.white);//Set text color
// 设置信息显示标签样式(普通字体)
label16.setFont(new Font(Font.DIALOG,Font.PLAIN,26));//Set text font label16.setFont(new Font(Font.DIALOG,Font.PLAIN,26));//Set text font
label16.setForeground(Color.white);//Set text color label16.setForeground(Color.white);//Set text color
label17.setFont(new Font(Font.DIALOG,Font.PLAIN,26));//Set text font label17.setFont(new Font(Font.DIALOG,Font.PLAIN,26));//Set text font
@ -146,54 +99,38 @@ public class Confirm_Panel extends JPanel {
label20.setForeground(Color.white);//Set text color label20.setForeground(Color.white);//Set text color
// ==================== 创建和设置图标 ====================
JLabel icon = new JLabel(); JLabel icon = new JLabel();
int width = 600,height = 300;// 图片和JLabel的宽度和高度 int width = 600,height = 300;//This is the width and height of the picture and JLabel
ImageIcon image = new ImageIcon(Constant.RESOURCE_PATH + "card.png");// 实例化ImageIcon对象 ImageIcon image = new ImageIcon(Constant.RESOURCE_PATH + "card.png");//Instantiate imageicon object
image.setImage(image.getImage().getScaledInstance(width, height,Image.SCALE_DEFAULT )); image.setImage(image.getImage().getScaledInstance(width, height,Image.SCALE_DEFAULT ));
//为图标标签设置缩放后的图片
icon.setIcon(image); icon.setIcon(image);
// ==================== 设置布局和添加组件 ====================
panel.setLayout(null);// 使用绝对布局
// 设置图标位置并添加到面板 panel.setLayout(null);
icon.setBounds(300,-350,1000,1000); icon.setBounds(300,-350,1000,1000);
//将图标标签添加到主面板
panel.add(icon); panel.add(icon);
// 设置信息面板位置并添加到主面板
panel1.setBounds(100,300,1000,150); panel1.setBounds(100,300,1000,150);
//将信息展示面板添加到主面板
panel.add(panel1); panel.add(panel1);
// ==================== 创建特殊需求按钮 ====================
JButton button = new JButton("<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SPECIAL<br>REQUIREMENT</html>");//add button JButton button = new JButton("<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SPECIAL<br>REQUIREMENT</html>");//add button
//设置按钮字体
button.setFont(new Font(Font.DIALOG,Font.PLAIN,20));//Set text font button.setFont(new Font(Font.DIALOG,Font.PLAIN,20));//Set text font
//设置按钮文字颜色为白色
button.setForeground(Color.white);//Set text color button.setForeground(Color.white);//Set text color
//设置按钮背景颜色为红色(218,65,71)
button.setBackground(new Color(218,65,71));//Set background color button.setBackground(new Color(218,65,71));//Set background color
// 添加按钮点击事件监听器
button.addActionListener(new AbstractAction() { button.addActionListener(new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
//弹出输入对话框获取用户输入的特殊需求并赋值给主框架的req变量
Main_Frame.req =JOptionPane.showInputDialog(null,"Please enter your special requirements"); Main_Frame.req =JOptionPane.showInputDialog(null,"Please enter your special requirements");
} }
}); });
// ==================== 设置提示文本标签位置 ====================
button.setBounds(950,50,170,80); button.setBounds(950,50,170,80);
//将按钮添加到主面板
panel.add(button); panel.add(button);
//设置各提示标签的位置和大小并添加到主面板
label1.setBounds(150,450,480,100); label1.setBounds(150,450,480,100);
panel.add(label1); panel.add(label1);
label2.setBounds(420,450,200,100); label2.setBounds(420,450,200,100);
@ -213,9 +150,7 @@ public class Confirm_Panel extends JPanel {
label9.setBounds(610,550,1000,100); label9.setBounds(610,550,1000,100);
panel.add(label9); panel.add(label9);
// ==================== 设置信息面板内部布局 ====================
panel1.setLayout(null); panel1.setLayout(null);
//设置各信息标签在展示面板中的位置和大小并添加
label11.setBounds(400,-20,1000,100); label11.setBounds(400,-20,1000,100);
panel1.add(label11); panel1.add(label11);
label12.setBounds(800,-20,1000,100); label12.setBounds(800,-20,1000,100);
@ -237,60 +172,8 @@ public class Confirm_Panel extends JPanel {
label20.setBounds(180,-20,1000,100); label20.setBounds(180,-20,1000,100);
panel1.add(label20); panel1.add(label20);
}
/**
* -
* @param args
*/
public static void main(String[] args) {
// 设置Swing外观为系统默认外观
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
// 创建主框架
JFrame frame = new JFrame("确认面板测试 - Confirm Panel Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1200, 700);
frame.setLocationRelativeTo(null); // 窗口居中显示
// 模拟必要的静态数据(在实际应用中这些数据会从其他面板获取)
//setupTestData();
// 创建确认面板并添加到框架
Confirm_Panel confirmPanel = new Confirm_Panel();
frame.add(confirmPanel);
// 显示窗口
frame.setVisible(true);
System.out.println("确认面板测试程序已启动");
}
/**
* -
*/
private static void setupTestData() {
// 模拟航班号
Main_Frame.flightNum = "CA1234";
// 模拟座位选择
Seats_Panel.number = "15";
Seats_Panel.letter = "A";
// 模拟食物选择
Foods_Panel.food = "Vegetarian Meal";
Main_Frame.foodType = Foods_Panel.food;
// 模拟特殊需求
Main_Frame.req = "No special requirements";
System.out.println("测试数据已设置完成");
System.out.println("航班号: " + Main_Frame.flightNum);
System.out.println("座位: " + Seats_Panel.number + " " + Seats_Panel.letter);
System.out.println("食物: " + Main_Frame.foodType);
} }
} }

File diff suppressed because it is too large Load Diff

@ -1,15 +1,12 @@
package frame.UserPanel; package frame.UserPanel;
import frame.Main_Frame; import frame.Main_Frame;
import model_new.Flight; import model.eachFlight;
import service.FlightService;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
/** /**
* Title : Foods_Panel.java * Title : Foods_Panel.java
@ -18,31 +15,24 @@ import java.util.Optional;
public class Foods_Panel extends JPanel { public class Foods_Panel extends JPanel {
// 静态变量,用于跨模块间传递用户选择的食品类型
public static String food = ""; public static String food = "";
public Foods_Panel(){ public Foods_Panel(){
FlightService flightService = new FlightService();
//set background //set background
food = ""; food = "";
// 设置面板整体背景色为深紫色主题
setBackground(new Color(72, 46, 115)); setBackground(new Color(72, 46, 115));
// 创建内部主面板用于统一管理组件 //set initial panel
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setBackground(new Color(72, 46, 115)); panel.setBackground(new Color(72, 46, 115));
panel.setPreferredSize(new Dimension(1200, 680)); panel.setPreferredSize(new Dimension(1200, 680));
add(panel); add(panel);
// 使用绝对布局精确控制组件位置
panel.setLayout(null); panel.setLayout(null);
// 顶部信息面板:展示航班基础信息
JPanel panelTOP = new JPanel(); JPanel panelTOP = new JPanel();
panelTOP.setLayout(null); panelTOP.setLayout(null);
panelTOP.setBounds(0,0,1200,85); panelTOP.setBounds(0,0,1200,85);
panelTOP.setBackground(new Color(72,46,115)); panelTOP.setBackground(new Color(72,46,115));
// 定义顶部信息标签:航班号、航空公司、登机时间标题、时间值、登机口标题、登机口值
JLabel labelFlight = new JLabel(); JLabel labelFlight = new JLabel();
JLabel labelCompany = new JLabel(); JLabel labelCompany = new JLabel();
JLabel labelBoarding = new JLabel(); JLabel labelBoarding = new JLabel();
@ -50,62 +40,54 @@ public class Foods_Panel extends JPanel {
JLabel labelGate = new JLabel(); JLabel labelGate = new JLabel();
JLabel labelGateNum = new JLabel(); JLabel labelGateNum = new JLabel();
// 配置航班号标签:显示主框架中选中的航班号,样式为加粗白色字体 labelFlight.setFont(new Font(Font.DIALOG,Font.BOLD,25));//set font
labelFlight.setFont(new Font(Font.DIALOG,Font.BOLD,25)); labelFlight.setForeground(Color.white);//set text color
labelFlight.setForeground(Color.white);
labelFlight.setText(Main_Frame.flightNum); labelFlight.setText(Main_Frame.flightNum);
labelFlight.setBounds(60,17,100,40); labelFlight.setBounds(60,17,100,40);
labelCompany.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//set font labelCompany.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//set font
labelCompany.setForeground(Color.white);//set text color labelCompany.setForeground(Color.white);//set text color
labelCompany.setText(eachFlight.COMPANY(Main_Frame.flightNum));
// 创建航班对象
Optional<Flight> optionalFlight = flightService.findFlightById(Main_Frame.flightNum);
Flight flight = optionalFlight.orElse(new Flight());
labelCompany.setText(flight.getAirline_company());
labelCompany.setBounds(170,17,300,40); labelCompany.setBounds(170,17,300,40);
// 配置"登机时间"标题标签:静态文本,加粗样式 labelBoarding.setFont(new Font(Font.DIALOG,Font.BOLD,25));//set font
labelBoarding.setFont(new Font(Font.DIALOG,Font.BOLD,25)); labelBoarding.setForeground(Color.white);//set text color
labelBoarding.setForeground(Color.white);
labelBoarding.setText("BOARDING TIME"); labelBoarding.setText("BOARDING TIME");
labelBoarding.setBounds(480,17,300,40); labelBoarding.setBounds(480,17,300,40);
labelTime.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//set font labelTime.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//set font
labelTime.setForeground(Color.white);//set text color labelTime.setForeground(Color.white);//set text color
labelTime.setText(flight.getBoarding_time().toLocalDateTime().format(DateTimeFormatter.ofPattern("HH:mm"))); labelTime.setText(eachFlight.boardingTime(Main_Frame.flightNum));
labelTime.setBounds(710,17,100,40); labelTime.setBounds(710,17,100,40);
// 配置"登机口"标题标签:静态文本,加粗样式 labelGate.setFont(new Font(Font.DIALOG,Font.BOLD,25));//set font
labelGate.setFont(new Font(Font.DIALOG,Font.BOLD,25)); labelGate.setForeground(Color.white);//set text color
labelGate.setForeground(Color.white);
labelGate.setText("GATE"); labelGate.setText("GATE");
labelGate.setBounds(1000,17,100,40); labelGate.setBounds(1000,17,100,40);
labelGateNum.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//set font labelGateNum.setFont(new Font(Font.DIALOG,Font.PLAIN,25));//set font
labelGateNum.setForeground(Color.white);//set text color labelGateNum.setForeground(Color.white);//set text color
labelGateNum.setText(flight.getGate()); labelGateNum.setText(eachFlight.GATE(Main_Frame.flightNum));
labelGateNum.setBounds(1085,17,50,40); labelGateNum.setBounds(1085,17,50,40);
// 将顶部面板添加到主面板,并加载所有信息标签
panel.add(panelTOP); panel.add(panelTOP);
panelTOP.add(labelBoarding); panelTOP.add(labelBoarding);
panelTOP.add(labelCompany); panelTOP.add(labelCompany);
panelTOP.add(labelFlight); panelTOP.add(labelFlight);
panelTOP.add(labelTime); panelTOP.add(labelTime);
panelTOP.add(labelGate); panelTOP.add(labelGate);
panelTOP.add(labelGateNum); panelTOP.add(labelGateNum);//Set the layout of the top panel
// 创建6个BorderLayout布局管理器用于规范每个餐食选项的内部布局标题-图片-按钮)
BorderLayout b11 = new BorderLayout(); BorderLayout b11 = new BorderLayout();
BorderLayout b12 = new BorderLayout(); BorderLayout b12 = new BorderLayout();
BorderLayout b13 = new BorderLayout(); BorderLayout b13 = new BorderLayout();
BorderLayout b21 = new BorderLayout(); BorderLayout b21 = new BorderLayout();
BorderLayout b22 = new BorderLayout(); BorderLayout b22 = new BorderLayout();
BorderLayout b23 = new BorderLayout(); BorderLayout b23 = new BorderLayout();//set the layout of food panels
// 初始化6个餐食选择面板设置位置、大小和背景色与整体风格统一
JPanel panel_choose_standard = new JPanel(b11); JPanel panel_choose_standard = new JPanel(b11);
panel_choose_standard.setBackground(new Color(72,46,115)); panel_choose_standard.setBackground(new Color(72,46,115));
panel_choose_standard.setBounds(150,85,200,250); panel_choose_standard.setBounds(150,85,200,250);
@ -135,43 +117,48 @@ public class Foods_Panel extends JPanel {
JPanel panel_choose_sushi = new JPanel(b23); JPanel panel_choose_sushi = new JPanel(b23);
panel_choose_sushi.setBackground(new Color(72,46,115)); panel_choose_sushi.setBackground(new Color(72,46,115));
panel_choose_sushi.setBounds(850,350,200,250); panel_choose_sushi.setBounds(850,350,200,250);
panel.add(panel_choose_sushi); panel.add(panel_choose_sushi);
/*
set the size and style of food-choose panels.
*/
// 海鲜餐面板配置:标题、图片、价格按钮
JLabel seafood_text = new JLabel("Seafood",SwingConstants.CENTER); JLabel seafood_text = new JLabel("Seafood",SwingConstants.CENTER);
seafood_text.setPreferredSize(new Dimension(200,40)); seafood_text.setPreferredSize(new Dimension(200,40));
seafood_text.setFont(new Font(Font.DIALOG,Font.BOLD,20)); seafood_text.setFont(new Font(Font.DIALOG,Font.BOLD,20));//set font
seafood_text.setForeground(Color.white); seafood_text.setForeground(Color.white);//set text color
panel_choose_seafood.add(seafood_text,BorderLayout.NORTH); // 标题放北部 panel_choose_seafood.add(seafood_text,BorderLayout.NORTH);
JLabel seafood_img = new JLabel(); JLabel seafood_img = new JLabel();
seafood_img.setPreferredSize(new Dimension(200,160)); seafood_img.setPreferredSize(new Dimension(200,160));
ImageIcon image_seafood = new ImageIcon("resource/seafood.jpg"); ImageIcon image_seafood = new ImageIcon("resource/seafood.jpg");
image_seafood.setImage(image_seafood.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT)); // 图片缩放适配 image_seafood.setImage(image_seafood.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT));
seafood_img.setIcon(image_seafood); seafood_img.setIcon(image_seafood);
panel_choose_seafood.add(seafood_img,BorderLayout.CENTER); // 图片放中部 seafood_img.setSize(200,160);
panel_choose_seafood.add(seafood_img,BorderLayout.CENTER);//import images
JLabel seafood_choose = new JLabel(); JLabel seafood_choose = new JLabel();
seafood_choose.setPreferredSize(new Dimension(200,50)); seafood_choose.setPreferredSize(new Dimension(200,50));
JButton button_seafood = new JButton("£39.90"); // 显示价格
JButton button_seafood = new JButton("£39.90");
button_seafood.setSize(200,50); button_seafood.setSize(200,50);
button_seafood.setBackground(new Color(250, 250, 250)); button_seafood.setBackground(new Color(250, 250, 250));
seafood_choose.add(button_seafood); seafood_choose.add(button_seafood);
panel_choose_seafood.add(seafood_choose,BorderLayout.SOUTH); // 按钮放南部 button_seafood.setVisible(true);
panel_choose_seafood.add(seafood_choose,BorderLayout.SOUTH);
// 牛排餐面板配置:同上结构,显示牛排餐信息
JLabel steak_text = new JLabel("steak",SwingConstants.CENTER); JLabel steak_text = new JLabel("steak",SwingConstants.CENTER);
steak_text.setPreferredSize(new Dimension(200,40)); steak_text.setPreferredSize(new Dimension(200,40));
steak_text.setFont(new Font(Font.DIALOG,Font.BOLD,20)); steak_text.setFont(new Font(Font.DIALOG,Font.BOLD,20));//set font
steak_text.setForeground(Color.white); steak_text.setForeground(Color.white);//set text color
panel_choose_steak.add(steak_text,BorderLayout.NORTH); panel_choose_steak.add(steak_text,BorderLayout.NORTH);
JLabel steak_img = new JLabel(); JLabel steak_img = new JLabel();
steak_img.setPreferredSize(new Dimension(200,160)); steak_img.setPreferredSize(new Dimension(200,160));
ImageIcon image_steak= new ImageIcon("resource/steak.jpg"); ImageIcon image_steak= new ImageIcon("resource/steak.jpg");
image_steak.setImage(image_steak.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT)); image_steak.setImage(image_steak.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT));//import images
steak_img.setIcon(image_steak); steak_img.setIcon(image_steak);
steak_img.setSize(200,160); steak_img.setSize(200,160);
panel_choose_steak.add(steak_img,BorderLayout.CENTER); panel_choose_steak.add(steak_img,BorderLayout.CENTER);
@ -187,17 +174,16 @@ public class Foods_Panel extends JPanel {
panel_choose_steak.add(steak_choose,BorderLayout.SOUTH); panel_choose_steak.add(steak_choose,BorderLayout.SOUTH);
// 寿司餐面板配置:同上结构,显示寿司餐信息
JLabel sushi_text = new JLabel("sushi",SwingConstants.CENTER); JLabel sushi_text = new JLabel("sushi",SwingConstants.CENTER);
sushi_text.setPreferredSize(new Dimension(200,40)); sushi_text.setPreferredSize(new Dimension(200,40));
sushi_text.setFont(new Font(Font.DIALOG,Font.BOLD,20)); sushi_text.setFont(new Font(Font.DIALOG,Font.BOLD,20));//set font
sushi_text.setForeground(Color.white); sushi_text.setForeground(Color.white);//set text color
panel_choose_sushi.add(sushi_text,BorderLayout.NORTH); panel_choose_sushi.add(sushi_text,BorderLayout.NORTH);
JLabel sushi_img = new JLabel(); JLabel sushi_img = new JLabel();
sushi_img.setPreferredSize(new Dimension(200,160)); sushi_img.setPreferredSize(new Dimension(200,160));
ImageIcon image_sushi= new ImageIcon("resource/sushi.jpg"); ImageIcon image_sushi= new ImageIcon("resource/sushi.jpg");
image_sushi.setImage(image_sushi.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT)); image_sushi.setImage(image_sushi.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT));//import images
sushi_img.setIcon(image_sushi); sushi_img.setIcon(image_sushi);
sushi_img.setSize(180,200); sushi_img.setSize(180,200);
panel_choose_sushi.add(sushi_img,BorderLayout.CENTER); panel_choose_sushi.add(sushi_img,BorderLayout.CENTER);
@ -213,24 +199,25 @@ public class Foods_Panel extends JPanel {
panel_choose_sushi.add(sushi_choose,BorderLayout.SOUTH); panel_choose_sushi.add(sushi_choose,BorderLayout.SOUTH);
// 标准餐面板配置:同上结构,显示免费标准餐信息
JLabel standard_text = new JLabel("Standard",SwingConstants.CENTER); JLabel standard_text = new JLabel("Standard",SwingConstants.CENTER);
standard_text.setPreferredSize(new Dimension(200,40)); standard_text.setPreferredSize(new Dimension(200,40));
standard_text.setFont(new Font(Font.DIALOG,Font.BOLD,20)); standard_text.setFont(new Font(Font.DIALOG,Font.BOLD,20));//set font
standard_text.setForeground(Color.white); standard_text.setForeground(Color.white);//set text color
panel_choose_standard.add(standard_text,BorderLayout.NORTH); panel_choose_standard.add(standard_text,BorderLayout.NORTH);
JLabel standard_img = new JLabel(); JLabel standard_img = new JLabel();
standard_img.setPreferredSize(new Dimension(200,160)); standard_img.setPreferredSize(new Dimension(200,160));
ImageIcon image_standard = new ImageIcon("resource/standard_food.jpeg"); ImageIcon image_standard = new ImageIcon("resource/standard_food.jpeg");
image_standard.setImage(image_standard.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT)); image_standard.setImage(image_standard.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT));//import images
standard_img.setIcon(image_standard); standard_img.setIcon(image_standard);
standard_img.setSize(200,160); standard_img.setSize(200,160);
panel_choose_standard.add(standard_img,BorderLayout.CENTER); panel_choose_standard.add(standard_img,BorderLayout.CENTER);
JLabel standard_choose = new JLabel(); JLabel standard_choose = new JLabel();
standard_choose.setPreferredSize(new Dimension(200,50)); standard_choose.setPreferredSize(new Dimension(200,50));//set selection button
JButton button_standard = new JButton("FREE"); // 免费标识
JButton button_standard = new JButton("FREE");
button_standard.setSize(200,50); button_standard.setSize(200,50);
button_standard.setBackground(new Color(250, 250, 250)); button_standard.setBackground(new Color(250, 250, 250));
standard_choose.add(button_standard); standard_choose.add(button_standard);
@ -238,17 +225,16 @@ public class Foods_Panel extends JPanel {
panel_choose_standard.add(standard_choose,BorderLayout.SOUTH); panel_choose_standard.add(standard_choose,BorderLayout.SOUTH);
// 素食餐面板配置:同上结构,显示免费素食餐信息
JLabel vegetarian_text = new JLabel("Vegetarian",SwingConstants.CENTER); JLabel vegetarian_text = new JLabel("Vegetarian",SwingConstants.CENTER);
vegetarian_text.setPreferredSize(new Dimension(200,40)); vegetarian_text.setPreferredSize(new Dimension(200,40));
vegetarian_text.setFont(new Font(Font.DIALOG,Font.BOLD,20)); vegetarian_text.setFont(new Font(Font.DIALOG,Font.BOLD,20));//set font
vegetarian_text.setForeground(Color.white); vegetarian_text.setForeground(Color.white);//set text color
panel_choose_vegetarian.add(vegetarian_text,BorderLayout.NORTH); panel_choose_vegetarian.add(vegetarian_text,BorderLayout.NORTH);
JLabel vegetarian_img = new JLabel(); JLabel vegetarian_img = new JLabel();
vegetarian_img.setPreferredSize(new Dimension(200,160)); vegetarian_img.setPreferredSize(new Dimension(200,160));
ImageIcon image_vegetarian= new ImageIcon("resource/vegetarian_food.jpg"); ImageIcon image_vegetarian= new ImageIcon("resource/vegetarian_food.jpg");
image_vegetarian.setImage(image_vegetarian.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT)); image_vegetarian.setImage(image_vegetarian.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT));//import images
vegetarian_img.setIcon(image_vegetarian); vegetarian_img.setIcon(image_vegetarian);
vegetarian_img.setSize(200,160); vegetarian_img.setSize(200,160);
panel_choose_vegetarian.add(vegetarian_img,BorderLayout.CENTER); panel_choose_vegetarian.add(vegetarian_img,BorderLayout.CENTER);
@ -264,49 +250,54 @@ public class Foods_Panel extends JPanel {
panel_choose_vegetarian.add(vegetarian_choose,BorderLayout.SOUTH); panel_choose_vegetarian.add(vegetarian_choose,BorderLayout.SOUTH);
// 清真餐面板配置:同上结构,显示免费清真餐信息
JLabel halal_text = new JLabel("Halal",SwingConstants.CENTER); JLabel halal_text = new JLabel("Halal",SwingConstants.CENTER);
halal_text.setPreferredSize(new Dimension(200,40)); halal_text.setPreferredSize(new Dimension(200,40));
halal_text.setFont(new Font(Font.DIALOG,Font.BOLD,20)); halal_text.setFont(new Font(Font.DIALOG,Font.BOLD,20));//set font
halal_text.setForeground(Color.white); halal_text.setForeground(Color.white);//set text color
panel_choose_halal.add(halal_text,BorderLayout.NORTH); panel_choose_halal.add(halal_text,BorderLayout.NORTH);
JLabel halal_img = new JLabel(); JLabel halal_img = new JLabel();
halal_img.setPreferredSize(new Dimension(200,160)); halal_img.setPreferredSize(new Dimension(200,160));
ImageIcon image_halal= new ImageIcon("resource/halal_food.jpg"); ImageIcon image_halal= new ImageIcon("resource/halal_food.jpg");
image_halal.setImage(image_halal.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT)); image_halal.setImage(image_halal.getImage().getScaledInstance(200,160,Image.SCALE_DEFAULT));//import images
halal_img.setIcon(image_halal); halal_img.setIcon(image_halal);
panel_choose_halal.add(halal_img,BorderLayout.CENTER); halal_img.setSize(180,200);
panel_choose_halal.add(halal_img,BorderLayout.CENTER);//import images
JLabel halal_choose = new JLabel(); JLabel halal_choose = new JLabel();
halal_choose.setPreferredSize(new Dimension(200,50)); halal_choose.setPreferredSize(new Dimension(200,50));//set selection button
JButton button_halal = new JButton("FREE");
JButton button_halal = new JButton("FREE");
button_halal.setBackground(new Color(250, 250, 250)); button_halal.setBackground(new Color(250, 250, 250));
button_halal.setSize(200,50); button_halal.setSize(200,50);
button_halal.setVisible(true); button_halal.setVisible(true);
halal_choose.add(button_halal); halal_choose.add(button_halal);
panel_choose_halal.add(halal_choose,BorderLayout.SOUTH); panel_choose_halal.add(halal_choose,BorderLayout.SOUTH);
/*
// 标准餐按钮点击事件:处理选中状态 Write logical statements for the function of selecting food. The customer clicks the button to select the food category. The system records the data in the background and the corresponding button is changed in color.
*/
button_standard.addActionListener(new ActionListener() { button_standard.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 选中按钮置为绿色,其他按钮重置为白色(实现单选效果)
button_standard.setBackground(new Color(114, 236, 114)); button_standard.setBackground(new Color(114, 236, 114));
button_vegetarian.setBackground(new Color(250, 250, 250)); button_vegetarian.setBackground(new Color(250, 250, 250));
button_halal.setBackground(new Color(250, 250, 250)); button_halal.setBackground(new Color(250, 250, 250));
button_seafood.setBackground(new Color(250, 250, 250)); button_seafood.setBackground(new Color(250, 250, 250));
button_sushi.setBackground(new Color(250, 250, 250)); button_sushi.setBackground(new Color(250, 250, 250));
button_steak.setBackground(new Color(250, 250, 250)); button_steak.setBackground(new Color(250, 250, 250));
// 记录用户选择的餐食类型 /*
When the customer clicks the button, the button changes color, and the other buttons change back to the original color. In this way, if the customer chooses one and changes his mind, the system can display it intuitively.
*/
food="standard"; food="standard";
} }
});
// 素食餐按钮点击事件:同上逻辑,记录素食餐选择
});
button_vegetarian.addActionListener(new ActionListener() { button_vegetarian.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
button_vegetarian.setBackground(new Color(114, 236, 114)); button_vegetarian.setBackground(new Color(114, 236, 114));
@ -322,7 +313,6 @@ public class Foods_Panel extends JPanel {
}); });
// 清真餐按钮点击事件:同上逻辑,记录清真餐选择
button_halal.addActionListener(new ActionListener() { button_halal.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -337,12 +327,13 @@ public class Foods_Panel extends JPanel {
food="halal"; food="halal";
} }
});
// 海鲜餐按钮点击事件:同上逻辑,记录海鲜餐选择
});
button_seafood.addActionListener(new ActionListener() { button_seafood.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
button_seafood.setBackground(new Color(114, 236, 114)); button_seafood.setBackground(new Color(114, 236, 114));
button_standard.setBackground(new Color(250, 250, 250)); button_standard.setBackground(new Color(250, 250, 250));
button_halal.setBackground(new Color(250, 250, 250)); button_halal.setBackground(new Color(250, 250, 250));
@ -352,34 +343,40 @@ public class Foods_Panel extends JPanel {
food="seafood"; food="seafood";
} }
});
// 牛排餐按钮点击事件:同上逻辑,记录牛排餐选择
});
button_steak.addActionListener(new ActionListener() { button_steak.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
button_steak.setBackground(new Color(114, 236, 114)); button_steak.setBackground(new Color(114, 236, 114));
button_standard.setBackground(new Color(250, 250, 250)); button_standard.setBackground(new Color(250, 250, 250));
button_halal.setBackground(new Color(250, 250, 250)); button_halal.setBackground(new Color(250, 250, 250));
button_seafood.setBackground(new Color(250, 250, 250)); button_seafood.setBackground(new Color(250, 250, 250));
button_sushi.setBackground(new Color(250, 250, 250)); button_sushi.setBackground(new Color(250, 250, 250));
button_vegetarian.setBackground(new Color(250, 250, 250)); button_vegetarian.setBackground(new Color(250, 250, 250));
food="steak"; food="steak";
} }
});
// 寿司餐按钮点击事件:同上逻辑,记录寿司餐选择
});
button_sushi.addActionListener(new ActionListener() { button_sushi.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
button_sushi.setBackground(new Color(114, 236, 114)); button_sushi.setBackground(new Color(114, 236, 114));
button_standard.setBackground(new Color(250, 250, 250)); button_standard.setBackground(new Color(250, 250, 250));
button_halal.setBackground(new Color(250, 250, 250)); button_halal.setBackground(new Color(250, 250, 250));
button_seafood.setBackground(new Color(250, 250, 250)); button_seafood.setBackground(new Color(250, 250, 250));
button_vegetarian.setBackground(new Color(250, 250, 250)); button_vegetarian.setBackground(new Color(250, 250, 250));
button_steak.setBackground(new Color(250, 250, 250)); button_steak.setBackground(new Color(250, 250, 250));
food="sushi"; food="sushi";
} }
}); });
} }

File diff suppressed because it is too large Load Diff

@ -3,15 +3,12 @@ package frame.UserPanel;
//import com.sun.tools.javac.Main; //import com.sun.tools.javac.Main;
import constant.Constant; import constant.Constant;
import frame.Main_Frame; import frame.Main_Frame;
import model_new.Flight; import model.eachFlight;
import service.FlightService; import model.passenger_order;
import service.PassengerService;
import utils.BackGroundImagePanle; import utils.BackGroundImagePanle;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
/** /**
* <p>This page is mainly for users to print boarding passes.</p> * <p>This page is mainly for users to print boarding passes.</p>
@ -21,51 +18,41 @@ import java.util.Optional;
*/ */
public class Print_Panel extends JPanel { public class Print_Panel extends JPanel {
public Print_Panel(){ public Print_Panel(){
FlightService flightService = new FlightService();
PassengerService passengerService = new PassengerService();
//Set background color //Set background color
setBackground(new Color(72,46,115)); setBackground(new Color(72,46,115));
// 创建内部主面板 //Set initial panel
JPanel panel = new JPanel(); JPanel panel = new JPanel();
// 设置主面板背景颜色与外层一致
panel.setBackground(new Color(72,46,115)); panel.setBackground(new Color(72,46,115));
// 设置主面板首选尺寸为1200x680像素
panel.setPreferredSize(new Dimension(1200,680)); panel.setPreferredSize(new Dimension(1200,680));
// 将主面板添加到当前面板
add(panel); add(panel);
// 设置主面板为绝对布局(手动指定组件位置和大小)
panel.setLayout(null);//Set empty layout panel.setLayout(null);//Set empty layout
// 创建4个内部子面板用于承载登机牌展示内容 //Add sub panel
JPanel panel1 = new JPanel(); JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel(); JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel(); JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel(); JPanel panel4 = new JPanel();
// -------------------------- 子面板1配置左侧外层面板 -------------------------- //Set panel size, color and layout
// 设置位置(100,150)、大小(600,360)、背景色浅紫色(96,62,151)
panel1.setBounds(100,150,600,360); panel1.setBounds(100,150,600,360);
panel1.setBackground(new Color(96,62,151)); panel1.setBackground(new Color(96,62,151));
panel1.setLayout(null);//Set empty layout panel1.setLayout(null);//Set empty layout
panel.add(panel1); panel.add(panel1);
// -------------------------- 子面板2配置右侧外层面板 -------------------------- //Set panel size, color and layout
// 设置位置(710,150)、大小(350,360)、背景色浅紫色(96,62,151)
panel2.setBounds(710,150,350,360); panel2.setBounds(710,150,350,360);
panel2.setBackground(new Color(96,62,151)); panel2.setBackground(new Color(96,62,151));
panel2.setLayout(null);//Set empty layout panel2.setLayout(null);//Set empty layout
panel.add(panel2); panel.add(panel2);
// -------------------------- 子面板3配置左侧内层面板模拟登机牌正面 -------------------------- //Set panel size, color and layout
// 设置位置(0,50)、大小(600,280)、背景色白色(模拟纸质登机牌)
panel3.setBounds(0,50,600,280); panel3.setBounds(0,50,600,280);
panel3.setBackground(new Color(255,255,255)); panel3.setBackground(new Color(255,255,255));
panel3.setLayout(null);//Set empty layout panel3.setLayout(null);//Set empty layout
panel1.add(panel3); panel1.add(panel3);
// -------------------------- 子面板4配置右侧内层面板模拟登机牌背面/副券) -------------------------- //Set panel size, color and layout
// 设置位置(0,50)、大小(350,280)、背景色白色(模拟纸质登机牌)
panel4.setBounds(0,50,350,280); panel4.setBounds(0,50,350,280);
panel4.setBackground(new Color(255,255,255)); panel4.setBackground(new Color(255,255,255));
panel4.setLayout(null);//Set empty layout panel4.setLayout(null);//Set empty layout
@ -73,76 +60,47 @@ public class Print_Panel extends JPanel {
// -------------------------- 创建所有文本标签(操作提示、登机牌信息) --------------------------
// 操作提示1引导用户点击继续打印登机牌
JLabel label1 = new JLabel("PLEASE CLICK CONTINUE TO PRINT YOUR BOARDING PASS "); JLabel label1 = new JLabel("PLEASE CLICK CONTINUE TO PRINT YOUR BOARDING PASS ");
// 操作提示2引导用户参考下方示例
JLabel label2 = new JLabel("ACCORDING TO THE FIGURE BELOW "); JLabel label2 = new JLabel("ACCORDING TO THE FIGURE BELOW ");
// 左侧登机牌标题
JLabel label3 = new JLabel("BOARDING PASS"); JLabel label3 = new JLabel("BOARDING PASS");
// 右侧登机牌标题
JLabel label4 = new JLabel("BOARDING PASS "); JLabel label4 = new JLabel("BOARDING PASS ");
// 祝福语标签
JLabel label5 = new JLabel("HAVE A NICE TRIP"); JLabel label5 = new JLabel("HAVE A NICE TRIP");
// 乘客信息标题:乘客姓名
JLabel label11 = new JLabel("NAME OF PASSENGER"); JLabel label11 = new JLabel("NAME OF PASSENGER");
// 乘客信息标题:出发地
JLabel label12 = new JLabel("FROM"); JLabel label12 = new JLabel("FROM");
// 乘客信息标题:目的地
JLabel label13 = new JLabel("TO"); JLabel label13 = new JLabel("TO");
// 乘客信息标题:座位
JLabel label14 = new JLabel("SEAT"); JLabel label14 = new JLabel("SEAT");
// 乘客信息标题:登机口
JLabel label15 = new JLabel("GATE"); JLabel label15 = new JLabel("GATE");
// 乘客信息标题:登机时间
JLabel label16 = new JLabel("BOARDING TIME"); JLabel label16 = new JLabel("BOARDING TIME");
JLabel label17 = new JLabel(passengerService.getPassengerById(Main_Frame.IDNum).get().getName()); JLabel label17 = new JLabel(passenger_order.findName(Main_Frame.IDNum));
JLabel label18 = new JLabel(eachFlight.DEPARTURE(Main_Frame.flightNum));
Optional<Flight> optionalFlight = flightService.findFlightById(Main_Frame.flightNum); JLabel label19 = new JLabel(eachFlight.DESTINATION(Main_Frame.flightNum));
Flight flight = optionalFlight.orElse(new Flight()); // 获取航班对象
JLabel label18 = new JLabel(flight.getDeparture_location());
JLabel label19 = new JLabel(flight.getDestination_location());
JLabel label110 = new JLabel(Seats_Panel.number+" "+Seats_Panel.letter); JLabel label110 = new JLabel(Seats_Panel.number+" "+Seats_Panel.letter);
JLabel label111 = new JLabel(flight.getGate()); JLabel label111 = new JLabel(eachFlight.GATE(Main_Frame.flightNum));
JLabel label112 = new JLabel(flight.getBoarding_time().toLocalDateTime().format(DateTimeFormatter.ofPattern("HH:mm"))); JLabel label112 = new JLabel(eachFlight.boardingTime(Main_Frame.flightNum));
// 右侧登机牌信息标题:座位
JLabel label21 = new JLabel("SEAT"); JLabel label21 = new JLabel("SEAT");
// 右侧登机牌信息标题:登机口
JLabel label22 = new JLabel("GATE"); JLabel label22 = new JLabel("GATE");
// 右侧登机牌信息标题:登机时间
JLabel label23 = new JLabel("BOARDING TIME"); JLabel label23 = new JLabel("BOARDING TIME");
// 右侧登机牌信息内容:座位号(与左侧一致)
JLabel label24 = new JLabel(Seats_Panel.number+" "+Seats_Panel.letter); JLabel label24 = new JLabel(Seats_Panel.number+" "+Seats_Panel.letter);
JLabel label25 = new JLabel(flight.getGate()); JLabel label25 = new JLabel(eachFlight.GATE(Main_Frame.flightNum));
JLabel label26 = new JLabel(flight.getBoarding_time().toLocalDateTime().format(DateTimeFormatter.ofPattern("HH:mm"))); JLabel label26 = new JLabel(eachFlight.boardingTime(Main_Frame.flightNum));
// -------------------------- 创建条形码图标标签(左侧登机牌) --------------------------
JLabel icon1 = new JLabel(); JLabel icon1 = new JLabel();
// 加载左侧登机牌的条形码图片resource/barcode1-.png
ImageIcon image1 = new ImageIcon("resource/barcode1-.png");//Instantiate imageicon object ImageIcon image1 = new ImageIcon("resource/barcode1-.png");//Instantiate imageicon object
// 缩放图片至120x260像素
image1.setImage(image1.getImage().getScaledInstance(120, 260,Image.SCALE_DEFAULT )); image1.setImage(image1.getImage().getScaledInstance(120, 260,Image.SCALE_DEFAULT ));
icon1.setIcon(image1); icon1.setIcon(image1);
// 设置位置负值y坐标使条形码向上偏移适配登机牌布局
icon1.setBounds(0,-350,1000,1000); icon1.setBounds(0,-350,1000,1000);
panel3.add(icon1); panel3.add(icon1);
// -------------------------- 创建条形码图标标签(右侧登机牌) --------------------------
JLabel icon2 = new JLabel(); JLabel icon2 = new JLabel();
// 从常量类获取资源路径加载右侧登机牌的条形码图片barcode2.png
ImageIcon image2 = new ImageIcon(Constant.RESOURCE_PATH + "barcode2.png");//Instantiate imageicon object ImageIcon image2 = new ImageIcon(Constant.RESOURCE_PATH + "barcode2.png");//Instantiate imageicon object
// 缩放图片至180x40像素
image2.setImage(image2.getImage().getScaledInstance(180, 40,Image.SCALE_DEFAULT )); image2.setImage(image2.getImage().getScaledInstance(180, 40,Image.SCALE_DEFAULT ));
icon2.setIcon(image2); icon2.setIcon(image2);
icon2.setIcon(image2); icon2.setIcon(image2);
// 设置位置负值y坐标使条形码向上偏移适配登机牌布局
icon2.setBounds(80,-250,1000,1000); icon2.setBounds(80,-250,1000,1000);
panel4.add(icon2); panel4.add(icon2);
// -------------------------- 设置标签字体和颜色(操作提示类) --------------------------
label1.setFont(new Font(Font.DIALOG,Font.PLAIN,33));//Set text font label1.setFont(new Font(Font.DIALOG,Font.PLAIN,33));//Set text font
label1.setForeground(Color.white);//Set text color label1.setForeground(Color.white);//Set text color
label2.setFont(new Font(Font.DIALOG,Font.PLAIN,33));//Set text font label2.setFont(new Font(Font.DIALOG,Font.PLAIN,33));//Set text font
@ -154,7 +112,6 @@ public class Print_Panel extends JPanel {
label5.setFont(new Font(Font.DIALOG,Font.BOLD,16));//Set text font label5.setFont(new Font(Font.DIALOG,Font.BOLD,16));//Set text font
label5.setForeground(Color.white);//Set text color label5.setForeground(Color.white);//Set text color
// -------------------------- 设置标签字体和颜色(左侧登机牌标题类) --------------------------
label11.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font label11.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font
label11.setForeground(Color.black);//Set text color label11.setForeground(Color.black);//Set text color
label12.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font label12.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font
@ -169,7 +126,6 @@ public class Print_Panel extends JPanel {
label16.setForeground(Color.black);//Set text color label16.setForeground(Color.black);//Set text color
// -------------------------- 设置标签字体和颜色(左侧登机牌内容类) --------------------------
label17.setFont(new Font(Font.DIALOG,Font.BOLD,30));//Set text font label17.setFont(new Font(Font.DIALOG,Font.BOLD,30));//Set text font
label17.setForeground(Color.black);//Set text color label17.setForeground(Color.black);//Set text color
label18.setFont(new Font(Font.DIALOG,Font.BOLD,30));//Set text font label18.setFont(new Font(Font.DIALOG,Font.BOLD,30));//Set text font
@ -184,7 +140,6 @@ public class Print_Panel extends JPanel {
label112.setForeground(Color.black);//Set text color label112.setForeground(Color.black);//Set text color
// -------------------------- 设置标签字体和颜色(右侧登机牌信息类) --------------------------
label21.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font label21.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font
label21.setForeground(Color.black);//Set text color label21.setForeground(Color.black);//Set text color
label22.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font label22.setFont(new Font(Font.DIALOG,Font.BOLD,17));//Set text font
@ -199,24 +154,18 @@ public class Print_Panel extends JPanel {
label26.setForeground(Color.black);//Set text color label26.setForeground(Color.black);//Set text color
// -------------------------- 配置标签位置并添加到对应面板 -------------------------- //Set label size position and add labels
// 操作提示1添加到主面板位置(80,0)
label1.setBounds(80,0,1000,100); label1.setBounds(80,0,1000,100);
panel.add(label1); panel.add(label1);
// 操作提示2添加到主面板位置(80,50)
label2.setBounds(80,50,1000,100); label2.setBounds(80,50,1000,100);
panel.add(label2); panel.add(label2);
// 左侧登机牌标题添加到子面板1位置(30,-20)
label3.setBounds(30,-20,1000,100); label3.setBounds(30,-20,1000,100);
panel1.add(label3); panel1.add(label3);
// 右侧登机牌标题添加到子面板2位置(70,-20)
label4.setBounds(70,-20,1000,100); label4.setBounds(70,-20,1000,100);
panel2.add(label4); panel2.add(label4);
// 祝福语添加到子面板2位置(100,295)
label5.setBounds(100,295,1000,100); label5.setBounds(100,295,1000,100);
panel2.add(label5); panel2.add(label5);
// 左侧登机牌标题类标签添加到子面板3
label11.setBounds(130,-20,1000,100); label11.setBounds(130,-20,1000,100);
panel3.add(label11); panel3.add(label11);
label12.setBounds(130,60,1000,100); label12.setBounds(130,60,1000,100);
@ -230,7 +179,6 @@ public class Print_Panel extends JPanel {
label16.setBounds(400,140,1000,100); label16.setBounds(400,140,1000,100);
panel3.add(label16); panel3.add(label16);
// 左侧登机牌内容类标签添加到子面板3
label17.setBounds(140,20,1000,100); label17.setBounds(140,20,1000,100);
panel3.add(label17); panel3.add(label17);
label18.setBounds(140,100,1000,100); label18.setBounds(140,100,1000,100);
@ -244,7 +192,7 @@ public class Print_Panel extends JPanel {
label112.setBounds(410,180,1000,100); label112.setBounds(410,180,1000,100);
panel3.add(label112); panel3.add(label112);
// 右侧登机牌信息标签添加到子面板4
label21.setBounds(20,-30,1000,100); label21.setBounds(20,-30,1000,100);
panel4.add(label21); panel4.add(label21);
label22.setBounds(20,40,1000,100); label22.setBounds(20,40,1000,100);

File diff suppressed because it is too large Load Diff

@ -1,103 +1,58 @@
package frame.UserPanel; package frame.UserPanel;
import utils.BackGroundImagePanle; import utils.BackGroundImagePanle;
import utils.GBC;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
/** /**
* * <p>This page is mainly for reminding the passengers and show them the right way to paste baggage tags.</p>
*<p>
* </p>
* *
* * @author Jiayi Yu
* 1. * @version 3.1
* 2.
* 3.
*
* @author Jinfeng Tao
* @version 1.0
* @since 2025
*/ */
public class Video_Panel extends JPanel { public class Video_Panel extends JPanel {
/*
使gif使
*/
int index = 1; int index = 1;
/*
1.
2.
3.
1.
2.
*/
public Video_Panel() { public Video_Panel() {
// 设置主面板背景颜色 - 深紫色主题 // Set background color
setBackground(new Color(72, 46, 115)); setBackground(new Color(72, 46, 115));
// 初始化主容器面板 // Set initial panel
// 这个面板作为所有其他组建的容器
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setBackground(new Color(72, 46, 115)); // 保持与主面板一直的背景色 panel.setBackground(new Color(72, 46, 115));
panel.setPreferredSize(new Dimension(1200, 680)); // 设置面板的推荐尺寸 panel.setPreferredSize(new Dimension(1200, 680));
add(panel); // 将容器面板添加到主面板中 add(panel);
// ==================== 标题面板设置 ==================== // Create a new panel and then set size and color of it
// 创建标题面板,用于显示操作指引标题
JPanel Tips = new JPanel(); JPanel Tips = new JPanel();
BorderLayout f1 = new BorderLayout(); // 使用边布局管理器 BorderLayout f1 = new BorderLayout();
Tips.setLayout(f1); // 为标题面板设置布局 Tips.setLayout(f1);
Tips.setBounds(0, 0, 1200, 100); // 设置面板位置和大小 Tips.setBounds(0, 0, 1200, 100);
Tips.setBackground(new Color(72, 46, 115)); // 设置背景色与主面板一致 Tips.setBackground(new Color(72, 46, 115));
panel.add(Tips); // 将标题面板添加到主容器面板中 panel.add(Tips);
// 创建并设置标题标签 // Create a new text label and then set the label
JLabel title = new JLabel("PLEASE PASTE BAGGAGE TAGS IN THE FOLLOWING WAY", SwingConstants.CENTER); JLabel title = new JLabel("PLEASE PASTE BAGGAGE TAGS IN THE FOLLOWING WAY", SwingConstants.CENTER);
title.setFont(new Font(Font.DIALOG, Font.BOLD, 27));//设置文字:对话框字体 title.setFont(new Font(Font.DIALOG, Font.BOLD, 27));//设置文字字体
title.setForeground(Color.white);//设置文字颜色为白色,提高对比度 title.setForeground(Color.white);//设置文字的颜色
title.setOpaque(true); //设置为不透明。以便背景色生效 title.setOpaque(true);
title.setBackground(new Color(72, 46, 115)); // 设置标签背景色 title.setBackground(new Color(72, 46, 115));
title.setPreferredSize(new Dimension(800, 80)); // 设置标签的推荐尺寸 title.setPreferredSize(new Dimension(800, 80));
Tips.add(title, BorderLayout.CENTER); // 将标题添加到面板的中间位置 Tips.add(title, BorderLayout.CENTER);
// ==================== 演示内容面板设置 ==================== // Create a panel to contain the image and then set it
// 创建演示内容面板,用于显示动画或视频内容
JPanel Rims = new JPanel(); JPanel Rims = new JPanel();
BorderLayout f2 = new BorderLayout(); // 使用边界布局管理器 BorderLayout f2 = new BorderLayout();
Rims.setLayout(f2); // 为演示面板设置布局 Rims.setLayout(f2);
Rims.setBounds(0, 0, 900, 600); // 设置面板位置和大小 Rims.setBounds(0, 0, 900, 600);
Rims.setBackground(new Color(46, 115, 105)); // 设置演示区域背景色 - 蓝绿色 Rims.setBackground(new Color(46, 115, 105));
panel.add(Rims); // 将演示面板添加到主容器面板 panel.add(Rims);
// 创建背景图片面板,加载演示动画
// 使用自定义的BackGroundImagePanle类来显示GIF动画
BackGroundImagePanle R_pic1 = new BackGroundImagePanle("Video_ro.gif"); BackGroundImagePanle R_pic1 = new BackGroundImagePanle("Video_ro.gif");
R_pic1.setPreferredSize(new Dimension(850, 530)); // 设置动画显示区域的尺寸 R_pic1.setPreferredSize(new Dimension(850, 530));
Rims.add(R_pic1); // 将动画面板添加到演示面板中 Rims.add(R_pic1);
}
/**
* @author Jinfeng Tao
* 便
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("行李标签粘贴演示");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1200, 680);
frame.setLocationRelativeTo(null); // 居中
frame.setContentPane(new Video_Panel());
frame.setVisible(true);
});
} }
} }

@ -1,421 +1,220 @@
package model; package model;
import tools.*; import tools.*;
import java.io.*; import java.io.*;
//We use the file name of "flight number. TXT" to create a TXT file for storing flight information, such as "ba0570. TXT".
// 我们使用"航班号.TXT"作为文件名来创建存储航班信息的TXT文件例如"ba0570.TXT" //eachFlight class enables us to view the information in the flight file and change the remaining number of seats on the flight
// eachFlight类使我们能够查看航班文件中的信息并更改航班的剩余座位数
// 后续我们需要改成数据库来存储
/** /**
* eachFlight.java * Title : eachFlight.java
* * Description : This class is all methods for reading and modifying the information of each flight,
* * such as boardingTime,COMPANY,GATE,seat and so on.
*/ */
public class eachFlight { public class eachFlight {
/** /**
* * This method is used to read the boarding time of flight.
* * @param content This is the flight number of the flight chosen to read information
* @param content
* @return null
*/ */
public static String boardingTime(String content) {//Add the "flight number" to be queried in parentheses, and this function returns the boarding time of the flight public static String boardingTime(String content){//Add the "flight number" to be queried in parentheses, and this function returns the boarding time of the flight
String boarding_time = null; String boarding_time=null;
lineReader lr = new lineReader(); lineReader lr = new lineReader();
// 创建航班文件对象路径为resource/航班号.txt File file = new File("resource/"+content+".txt");
File file = new File("resource/" + content + ".txt"); if(file.exists()) {
String boardingTime_line = lr.readLine("resource/" + content + ".txt", "BOARDINGTIME");
// 检查我呢见是否存在 String[] sp = boardingTime_line.split("\\s+");
if (file.exists()) { boarding_time=sp[1];
}else{
// 读取包含"BOARDINGTIME"关键词的行 System.out.println("There is no flight called "+content);
String boardingTime_line = lr.readLine("resource/" + content + ".txt", "BOARDINGTIME");
// 使用空格分割字符串
String[] sp = boardingTime_line.split("\\s+");
// 获取第二个元素作为登机时间
boarding_time = sp[1];
} else {
// 文件不存在则打印错误信息
System.out.println("There is no flight called " + content);
} }
// 存在文件则返回航班登机时间
return boarding_time; return boarding_time;
} }
/** /**
* * This method is used to know the name of company of the flight.
* * @param content This is the flight number of the flight chosen to read information
* @param content
* @return
*/ */
public static String COMPANY(String content) { public static String COMPANY(String content){//Add the "flight number" to be queried in parentheses, and the function returns the airline to which the flight belongs
String COMPANY="";
String COMPANY = "";
lineReader lr = new lineReader(); lineReader lr = new lineReader();
// 创建航班文件对象 File file = new File("resource/"+content+".txt");
File file = new File("resource/" + content + ".txt"); if(file.exists()) {
// 判断该文件是否存在
if (file.exists()) {
// 读取包含"COMPANY"关键词的行
String COMPANY_line = lr.readLine("resource/" + content + ".txt", "COMPANY"); String COMPANY_line = lr.readLine("resource/" + content + ".txt", "COMPANY");
// 使用空格作为分隔符
String[] sp = COMPANY_line.split("\\s+"); String[] sp = COMPANY_line.split("\\s+");
COMPANY=sp[1];
// 获取第二个元素
COMPANY = sp[1];
int i = 2; int i = 2;
while (i < sp.length) { while(i<sp.length) {
COMPANY = COMPANY + " "+sp[i];
// 循环加入数组的每个元素,用空格分隔
COMPANY = COMPANY + " " + sp[i];
i = i + 1; i = i + 1;
} }
} else { }else{
System.out.println("There is no flight called "+content);
// 文件不存在则打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回航班公司名称
return COMPANY; return COMPANY;
} }
/** /**
* * This method is used to know the gate number of the flight.
* * @param content This is the flight number of the flight chosen to read information
* @param content
* @return null
*/ */
public static String GATE(String content) { public static String GATE(String content){//Add the "flight number" to be queried in parentheses, and this function returns the boarding slogan of the flight
String GATE_number=null;
// 初始化登机口号字符串
String GATE_number = null;
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
// 创建航班文件对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断文件是否存在
if (file.exists()) {
// 读取包含"GATE"关键词的行
String GATE_line = lr.readLine("resource/" + content + ".txt", "GATE"); String GATE_line = lr.readLine("resource/" + content + ".txt", "GATE");
// 使用空格分割字符串
String[] sp = GATE_line.split("\\s+"); String[] sp = GATE_line.split("\\s+");
GATE_number = sp[1]; GATE_number=sp[1];
} else { }else{
System.out.println("There is no flight called "+content);
// 没有该文件打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回结果
return GATE_number; return GATE_number;
} }
/** /**
* * This method is used to know the name of the image of the flight's destination.
* * @param content This is the flight number of the flight chosen to read information
* @param content
* @return
*/ */
public static String IMG(String content) { public static String IMG(String content){//Add the "flight number" to be queried in parentheses, and this function returns the "picture name" of the arrival destination of the flight.
// 初始化文件名字符串
String img = "";
// 创建工具类,用于读取读取文本行信息 String img="";
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
// 创建文件对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断是否存在该文件
if (file.exists()) {
// 按照关键字IMG查找行信息
String img_line = lr.readLine("resource/" + content + ".txt", "IMG"); String img_line = lr.readLine("resource/" + content + ".txt", "IMG");
// 按空格分割字符串
String[] sp = img_line.split("\\s+"); String[] sp = img_line.split("\\s+");
img=sp[1];
// 处理可能包含空格的图片名称
img = sp[1];
int i = 2; int i = 2;
while (i < sp.length) { while(i<sp.length) {
// 循环拼接字符串 img = img + " "+sp[i];
img = img + " " + sp[i];
i = i + 1; i = i + 1;
} }
} else { }else{
System.out.println("There is no flight called "+content);
// 如果不存在该文件,打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回图片名称
return img; return img;
} }
/** /**
* * This method is used to know the departure of the flight.
* * @param content This is the departure of the flight chosen to read information
* @param content
* @return null
*/ */
public static String DEPARTURE(String content) { public static String DEPARTURE(String content){//Add the "flight number" to be queried in parentheses, and this function returns the origin of the flight
String DEPARTURE=null;
// 初始化航班出发地字符串
String DEPARTURE = null;
// 创建文本处理工具类对象
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
// 创建文件对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断文件是否存在
if (file.exists()) {
// 按照DEPARTURE关键字查找对应的行信息
String DEPARTURE_line = lr.readLine("resource/" + content + ".txt", "DEPARTURE"); String DEPARTURE_line = lr.readLine("resource/" + content + ".txt", "DEPARTURE");
// 按行分割处理字符串
String[] sp = DEPARTURE_line.split("\\s+"); String[] sp = DEPARTURE_line.split("\\s+");
DEPARTURE = sp[1]; DEPARTURE=sp[1];
} else { }else{
System.out.println("There is no flight called "+content);
// 如果不存在该航班则打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回航班出发地
return DEPARTURE; return DEPARTURE;
} }
/** /**
* * This method is used to know the destination of the flight.
* * @param content This is the destination of the flight chosen to read information
* @param content
* @return null
*/ */
public static String DESTINATION(String content) { public static String DESTINATION(String content){//Add the "flight number" to be queried in parentheses, and this function returns the destination of the flight
String DESTINATION=null;
// 初始化航班目的地字符串
String DESTINATION = null;
// 创建文本处理工具类对象
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
//创建文本对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断文件是否存在
if (file.exists()) {
// 按照DESTINATION关键字查找对应的行信息
String DESTINATION_line = lr.readLine("resource/" + content + ".txt", "DESTINATION"); String DESTINATION_line = lr.readLine("resource/" + content + ".txt", "DESTINATION");
String[] sp = DESTINATION_line.split("\\s+"); String[] sp = DESTINATION_line.split("\\s+");
DESTINATION = sp[1]; DESTINATION=sp[1];
} else { }else{
System.out.println("There is no flight called "+content);
// 如果没有该文件,打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回航班目的地字符串
return DESTINATION; return DESTINATION;
} }
/** /**
* * This method is used to know the departs time of the flight.
* * @param content This is the departs time of the flight chosen to read information
* @param content
* @return null
*/ */
public static String DEPARTS(String content) { public static String DEPARTS(String content){//Add the "flight number" to be queried in parentheses, and this function returns the departure time of the flight
String DEPARTS=null;
// 初始化起飞时间字符串
String DEPARTS = null;
// 创建文本处理工具类对象
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
// 创建文件对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断文件是否存在
if (file.exists()) {
// 按DEPARTS关键字查找匹配行信息
String DEPARTS_line = lr.readLine("resource/" + content + ".txt", "DEPARTS"); String DEPARTS_line = lr.readLine("resource/" + content + ".txt", "DEPARTS");
// 按空格分割字符串
String[] sp = DEPARTS_line.split("\\s+"); String[] sp = DEPARTS_line.split("\\s+");
DEPARTS=sp[1];
// 获取字符串数组的第二个元素 }else{
DEPARTS = sp[1]; System.out.println("There is no flight called "+content);
} else {
// 如果没有该文件则打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回航班起飞时间
return DEPARTS; return DEPARTS;
} }
/** /**
* * This method is used to know the arrives time of the flight.
* * @param content This is the arrives time of the flight chosen to read information
* @param content
* @return null
*/ */
public static String ARRIVES(String content) { public static String ARRIVES(String content){//Add the "flight number" to be queried in parentheses, and this function returns the arrival time of the flight
String ARRIVES=null;
// 初始化到达时间字符串
String ARRIVES = null;
// 创建文本处理工具类对象
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
// 创建文件对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断文件是否存在
if (file.exists()) {
// 按关键字ARRIVES查找对应行信息
String ARRIVES_line = lr.readLine("resource/" + content + ".txt", "ARRIVES"); String ARRIVES_line = lr.readLine("resource/" + content + ".txt", "ARRIVES");
// 使用空格分割字符串
String[] sp = ARRIVES_line.split("\\s+"); String[] sp = ARRIVES_line.split("\\s+");
ARRIVES=sp[1];
// 获取字符串数组第二个元素 }else{
ARRIVES = sp[1]; System.out.println("There is no flight called "+content);
} else {
// 如果没有该文件则打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回航班到达时间
return ARRIVES; return ARRIVES;
} }
/** /**
* * This method is used to know the delay state of the flight.
* * @param content This is the delay state of the flight chosen to read information
* @param content
* @return 01null
*/ */
public static String DELAY(String content) { public static String DELAY(String content){//Add the "flight number" to be queried in parentheses, and the function returns a value. If it is 0, it means the flight takes off late; if it is 1, it means the flight takes off normally
String DELAY=null;
// 初始化延误状态字符串
String DELAY = null;
// 创建文本处理工具类对象
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
// 创建文件对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断文件是否存在
if (file.exists()) {
// 按照关键字DELAY查找对应行信息
String DELAY_line = lr.readLine("resource/" + content + ".txt", "DELAY"); String DELAY_line = lr.readLine("resource/" + content + ".txt", "DELAY");
// 按照空格分割字符串
String[] sp = DELAY_line.split("\\s+"); String[] sp = DELAY_line.split("\\s+");
DELAY=sp[1];
// 获取字符串数组的第二个元素 }else{
DELAY = sp[1]; System.out.println("There is no flight called "+content);
} else {
// 如果没有该航班则打印错误信息
System.out.println("There is no flight called " + content);
} }
// 返回延误信息
return DELAY; return DELAY;
} }
/** /**
* * This function can check whether the selected seat has been selected, and add the number of seat columns (numbers 01-20) of "flight number", "seat rows (letters seata-seatf)" to be queried in brackets
* * If the returned value is 1, it means that the seat is empty and can be selected. If the returned value is 0, it means that the action has been selected and can no longer be selected.
* @param content * @param content This is the flight number of the flight chosen to read information
* @param letter * @param letter This is the seat letter
* @param number * @param number This is the seat number
* @return 10
*/ */
public static int seat(String content, String letter, String number) { public static int seat(String content,String letter,String number){
// 默认值为0表示作为已被选择
int judgement = 0; int judgement = 0;
// 创建文本处理工具类对象
lineReader lr = new lineReader(); lineReader lr = new lineReader();
File file = new File("resource/"+content+".txt");
// 创建文件对象 if(file.exists()) {
File file = new File("resource/" + content + ".txt");
// 判断文件是否存在
if (file.exists()) {
// 按照关键字查找对应行信息
String seat_line = lr.readLine("resource/" + content + ".txt", letter); String seat_line = lr.readLine("resource/" + content + ".txt", letter);
// 按空格分割字符串
String[] sp = seat_line.split("\\s+"); String[] sp = seat_line.split("\\s+");
int i=0;
// 遍历该行的所有座位号,检查目标座位是否可用 while(i<sp.length){
int i = 0; if(sp[i].equals(number)){
while (i < sp.length) {
if (sp[i].equals(number)) {
judgement = 1; judgement = 1;
break; break;
} }
i++; i=i+1;
} }
} else { }else{
System.out.println("There is no flight called "+content);
// 如果没有该航班则返回错误信息
System.out.println("There is no flight called " + content);
} }
// 返回标志信息
return judgement; return judgement;
} }
/** /**
* "01-20""chosen" * This function can be used to select seats. Add the number of seat columns (numbers 01-20) of the selected "flight number" and "seat rows (letters seata-seatf)" to the variables in brackets * If the returned value is 1, it means that the seat is empty and can be selected. If the returned value is 0, it means that the action has been selected and can no longer be selected.
* * After the seat is selected, the data "01-20" in the text will be replaced with "chosen"
* @param content * @param content This is the flight number of the flight chosen to read information
* @param letter * @param letter This is the seat letter
* @param number * @param number This is the seat number
*/ */
public static void seat_choose(String content, String letter, String number) { public static void seat_choose(String content,String letter,String number){
// 创建文本处理工具类对象
lineReader lr = new lineReader(); lineReader lr = new lineReader();
lineWriter lw = new lineWriter(); lineWriter lw = new lineWriter();
int lineNum=lr.findLine("resource/"+content+".txt",letter);
// 读取文件对应的行信息 String reLine = lw.lineRewrite("resource/"+content+".txt",lineNum,number,"chosen");
int lineNum = lr.findLine("resource/" + content + ".txt", letter); lw.writeLine("resource/"+content+".txt",lineNum,reLine);
// 重新写入对应的行信息,标记位座位已被选择
String reLine = lw.lineRewrite("resource/" + content + ".txt", lineNum, number, "chosen");
lw.writeLine("resource/" + content + ".txt", lineNum, reLine);
} }
} }

@ -2,150 +2,98 @@ package model;
import tools.*; import tools.*;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
/** /**
* : flight.java * Title : flight.java
* : flight.txt"航班号""订单号""具体事项(选择的食物、座位等)" * Description :flight. Txt file stores "flight number" corresponding to "order number" and "specific matters (selected food)" (each line represents an order, for example: 1326854870744 ba0570 foodchannel)
* : 1326854870744 ba0570 foodchannel LETTERUNCHOSEN NUMBERUNCHOSEN NOTE UNBOARDING * flight.java can read and edit flight.txt.
* flight.javaflight.txt
*/ */
public class flight { public class flight {
/**
*
* @param content
* @return
*/
public static String findFlight_line(String content){ public static String findFlight_line(String content){
lineReader lr = new lineReader(); lineReader lr = new lineReader();
// 在flight.txt文件中查找包含指定内容的行
String flight_number_line = lr.readLine("resource/flight.txt",content); String flight_number_line = lr.readLine("resource/flight.txt",content);
return flight_number_line; return flight_number_line;
} }
/** /**
* * The findflight function can find the corresponding flight number according to the order number. The parameter (content) in parentheses should be the order number, and the return value (flight_number) is the flight number corresponding to the order number
* @param content * @param content This is a order number
* @return
*/ */
public static String findFlight(String content){ public static String findFlight(String content){
// 先找到包含订单号的完整行
String temp = findFlight_line(content); String temp = findFlight_line(content);
// 按空格分割行内容
String[] sp = temp.split("\\s+"); String[] sp = temp.split("\\s+");
// 航班号通常在第二个位置索引1
String flight_number = sp[1]; String flight_number = sp[1];
// 返回
return flight_number; return flight_number;
} }
/** /**
* * The findflight function can find the corresponding flight number according to the order number. The parameter (content) in parentheses should be the order number, and the return value (flight_number) is the flight number corresponding to the order number
* "FOODUNCHOSEN" * After adding successfully, the unselected "fooddishosen" at the end of the order number of each line will be replaced with the added (string food)
* @param order_number * @param order_number This is a order number
* @param food * @param food This is the chosen food
*/ */
public static void add_food(String order_number,String food){ public static void add_food(String order_number,String food){
lineReader lr = new lineReader(); lineReader lr = new lineReader();
lineWriter lw = new lineWriter(); lineWriter lw = new lineWriter();
// 找到订单号所在的行号
int lineNum=lr.findLine("resource/flight.txt",order_number); int lineNum=lr.findLine("resource/flight.txt",order_number);
// 重写该行,将"FOODUNCHOSEN"替换为具体食物
String reLine = lw.lineRewrite("resource/flight.txt",lineNum,"FOODUNCHOSEN",food); String reLine = lw.lineRewrite("resource/flight.txt",lineNum,"FOODUNCHOSEN",food);
// 将重写后的行写回文件
lw.writeLine("resource/flight.txt",lineNum,reLine); lw.writeLine("resource/flight.txt",lineNum,reLine);
} }
/** /**
* * add_ Seat function, add the "order_number" of the item being selected and the "letter" and "number of seat columns" selected in the parameters in brackets * After adding successfully, the unselected "fooddishosen" at the end of the order number of each line will be replaced with the added (string food)
* "LETTERUNCHOSEN""NUMBERUNCHOSEN" * After adding successfully, the unselected "letterunchosen" and "numberunchosen" at the end of each line of order number will be replaced with the added (string letter, string number)
* @param order_number * @param order_number This is a order number
* @param letter ABC * @param letter This is the letter of chosen seat
* @param number 123 * @param number This is the number of chosen seat
*/ */
public static void add_seat(String order_number,String letter,String number){ public static void add_seat(String order_number,String letter,String number){
lineReader lr = new lineReader(); lineReader lr = new lineReader();
lineWriter lw = new lineWriter(); lineWriter lw = new lineWriter();
// 找到订单号所在的行号
int lineNum=lr.findLine("resource/flight.txt",order_number); int lineNum=lr.findLine("resource/flight.txt",order_number);
// 先替换座位字母
String reLine1 = lw.lineRewrite("resource/flight.txt",lineNum,"LETTERUNCHOSEN",letter); String reLine1 = lw.lineRewrite("resource/flight.txt",lineNum,"LETTERUNCHOSEN",letter);
lw.writeLine("resource/flight.txt",lineNum,reLine1); lw.writeLine("resource/flight.txt",lineNum,reLine1);
// 再替换座位数字
String reLine2 = lw.lineRewrite("resource/flight.txt",lineNum,"NUMBERUNCHOSEN",number); String reLine2 = lw.lineRewrite("resource/flight.txt",lineNum,"NUMBERUNCHOSEN",number);
lw.writeLine("resource/flight.txt",lineNum,reLine2); lw.writeLine("resource/flight.txt",lineNum,reLine2);
} }
/** /**
* * add_ note function, it can add note
* @param order_number * @param order_number This is a order number
* @param note * @param note This is the note
*/ */
public static void add_note(String order_number,String note){ public static void add_note(String order_number,String note){
lineReader lr = new lineReader(); lineReader lr = new lineReader();
lineWriter lw = new lineWriter(); lineWriter lw = new lineWriter();
// 找到订单号所在的行号
int lineNum=lr.findLine("resource/flight.txt",order_number); int lineNum=lr.findLine("resource/flight.txt",order_number);
// 将"NOTE"替换为具体的备注信息
String reLine = lw.lineRewrite("resource/flight.txt",lineNum,"NOTE",note); String reLine = lw.lineRewrite("resource/flight.txt",lineNum,"NOTE",note);
lw.writeLine("resource/flight.txt",lineNum,reLine); lw.writeLine("resource/flight.txt",lineNum,reLine);
} }
/** /**
* * The "order_number" of the item being selected is added to the parameter in parentheses in the boarding function
* "UNBOARDING""ISBOARDING" * After adding successfully, the unselected "unboarding" at the end of the order number of each line will be replaced with the added "isboarding"
* @param order_number * @param order_number This is a order number
*/ */
public static void boarding(String order_number){ public static void boarding(String order_number){
lineReader lr = new lineReader(); lineReader lr = new lineReader();
lineWriter lw = new lineWriter(); lineWriter lw = new lineWriter();
// 找到订单号所在的行号
int lineNum=lr.findLine("resource/flight.txt",order_number); int lineNum=lr.findLine("resource/flight.txt",order_number);
// 将"UNBOARDING"替换为"ISBOARDING"
String reLine = lw.lineRewrite("resource/flight.txt",lineNum,"UNBOARDING","ISBOARDING"); String reLine = lw.lineRewrite("resource/flight.txt",lineNum,"UNBOARDING","ISBOARDING");
lw.writeLine("resource/flight.txt",lineNum,reLine); lw.writeLine("resource/flight.txt",lineNum,reLine);
} }
/** /**
* * isBoarding function is used to know if the passenger has been boarding
* @param flight_number * @param flight_number This is a flight number
* @param id_number * @param id_number This is an id number
* @return truefalse
*/ */
public static boolean isBoarding(String flight_number,String id_number){ public static boolean isBoarding(String flight_number,String id_number){
lineReader lr = new lineReader(); lineReader lr = new lineReader();
lineWriter lw = new lineWriter(); lineWriter lw = new lineWriter();
String judgement=null; String judgement=null;
try{ try{
// 读取flight.txt文件
FileReader fr =new FileReader(new File("resource/flight.txt")); FileReader fr =new FileReader(new File("resource/flight.txt"));
BufferedReader br = new BufferedReader(fr); BufferedReader br = new BufferedReader(fr);
String line = br.readLine(); String line = br.readLine();
// 逐行查找匹配航班号和身份证号的行
while(line!=null){ while(line!=null){
if(line.contains(flight_number)){ if(line.contains(flight_number)){
if(line.contains(id_number)){ if(line.contains(id_number)){
@ -158,38 +106,26 @@ public class flight {
} }
} }
judgement = line; judgement = line;
// 关闭文件
br.close();
fr.close();
}catch (FileNotFoundException e){ }catch (FileNotFoundException e){
e.printStackTrace(); e.printStackTrace();
}catch (IOException e){ }catch (IOException e){
e.printStackTrace(); e.printStackTrace();
} }
// 检查该行是否包含"ISBOARDING"字符串
String str="ISBOARDING"; String str="ISBOARDING";
return judgement.contains(str); return judgement.contains(str);
} }
/** /**
* * find_all_flights function is used to find all lights in box
* @return
*/ */
public static String find_all_flights(){ public static String find_all_flights(){
String result=null; String result=null;
try{ try{
FileReader fr =new FileReader(new File("resource/flight.txt")); FileReader fr =new FileReader(new File("resource/flight.txt"));
BufferedReader br = new BufferedReader(fr); BufferedReader br = new BufferedReader(fr);
String line = br.readLine(); String line = br.readLine();
// 读取第一行并提取航班号
String[] sp = line.split("\\s+"); String[] sp = line.split("\\s+");
result=sp[1]; result=sp[1];
// 继续读取后续行并提取航班号
while(line!=null){ while(line!=null){
sp=line.split("\\s+"); sp=line.split("\\s+");
result=result+" "+sp[1]; result=result+" "+sp[1];
@ -205,19 +141,13 @@ public class flight {
} }
/** /**
* * The isflight method can judge whether the entered number is an existing flight number. The parameters in parentheses are the string you want to judge. If there is a flight number, it returns a value of int type 1, otherwise it returns 0
* @param content * @param content This is what user has entered
* @return 10
*/ */
public static int isFlight(String content){ public static int isFlight(String content){
int judgement=0; int judgement=0;
// 获取所有航班号
String[] sp = find_all_flights().split("\\s+"); String[] sp = find_all_flights().split("\\s+");
int i=0; int i=0;
// 遍历所有航班号进行匹配
while(i<sp.length){ while(i<sp.length){
if(sp[i].equals(content)){ if(sp[i].equals(content)){
judgement=1; judgement=1;
@ -229,9 +159,8 @@ public class flight {
} }
/** /**
* * administer_findEachFlight_Information function is used to find the information of flight according to the flight number
* @param flight_num * @param flight_num This is a flight number
* @return
*/ */
public static ArrayList<String> administer_findEachFlight_Information(String flight_num){ public static ArrayList<String> administer_findEachFlight_Information(String flight_num){
ArrayList<String> result=new ArrayList<>(); ArrayList<String> result=new ArrayList<>();
@ -239,18 +168,14 @@ public class flight {
FileReader fr =new FileReader(new File("resource/flight.txt")); FileReader fr =new FileReader(new File("resource/flight.txt"));
BufferedReader br = new BufferedReader(fr); BufferedReader br = new BufferedReader(fr);
String line = br.readLine(); String line = br.readLine();
// 查找包含指定航班号的所有行
while(line!=null){ while(line!=null){
if(line.contains(flight_num)){ if(line.contains(flight_num)){
result.add(line); // 添加到结果列表 result.add(line);
line= br.readLine(); line= br.readLine();
}else{ }else{
line=br.readLine(); line=br.readLine();
} }
} }
br.close();
fr.close();
}catch (FileNotFoundException e){ }catch (FileNotFoundException e){
e.printStackTrace(); e.printStackTrace();
}catch (IOException e){ }catch (IOException e){
@ -258,11 +183,9 @@ public class flight {
} }
return result; return result;
} }
/** /**
* * administer_findEachFlight_Num function is used to find the flight according to the flight number
* @param flight_num * @param flight_num This is a flight number
* @return
*/ */
public static int administer_findEachFlight_Num(String flight_num){ public static int administer_findEachFlight_Num(String flight_num){
int result=0; int result=0;
@ -270,19 +193,14 @@ public class flight {
FileReader fr =new FileReader(new File("resource/flight.txt")); FileReader fr =new FileReader(new File("resource/flight.txt"));
BufferedReader br = new BufferedReader(fr); BufferedReader br = new BufferedReader(fr);
String line = br.readLine(); String line = br.readLine();
// 统计包含指定航班号的行数
while(line!=null){ while(line!=null){
if(line.contains(flight_num)){ if(line.contains(flight_num)){
line= br.readLine(); line= br.readLine();
result++; // 计数器加1 result++;
}else{ }else{
line=br.readLine(); line=br.readLine();
} }
} }
br.close();
fr.close();
}catch (FileNotFoundException e){ }catch (FileNotFoundException e){
e.printStackTrace(); e.printStackTrace();
}catch (IOException e){ }catch (IOException e){
@ -290,26 +208,19 @@ public class flight {
} }
return result; return result;
} }
/** /**
* VIP * IS_VIP function is used to know if the passenger is VIP
* @param order_num * @param order_num This is a order number
* @return VIP10
*/ */
public static int IS_VIP(String order_num){ public static int IS_VIP(String order_num){
int result=0; int result=0;
try{ try{
FileReader fr =new FileReader(new File("resource/flight.txt")); FileReader fr =new FileReader(new File("resource/flight.txt"));
BufferedReader br = new BufferedReader(fr); BufferedReader br = new BufferedReader(fr);
String line = br.readLine(); String line = br.readLine();
String[] temp =null; String[] temp =null;
// 查找包含订单号的行
while(line!=null){ while(line!=null){
if(line.contains(order_num)){ if(line.contains(order_num)){
// 检查该行是否包含"VIP"标识
if(line.contains("VIP")){ if(line.contains("VIP")){
result=1; result=1;
} }
@ -318,9 +229,6 @@ public class flight {
line = br.readLine(); line = br.readLine();
} }
} }
br.close();
fr.close();
}catch (FileNotFoundException e){ }catch (FileNotFoundException e){
e.printStackTrace(); e.printStackTrace();
}catch (IOException e){ }catch (IOException e){

@ -2,75 +2,39 @@ package model;
import tools.*; import tools.*;
/** /**
* Title: order.java * Title : order.java
* Description: Txt * Description :order. Txt file stores the order numbers of all scheduled flights, each order number is separated by a space
* flight.javaorder.txt * flight.java can read and edit order.txt.
*
*/ */
public class order { public class order {//Read all flight order numbers of the scheduled users
// 读取所有预定用户的航班订单号
/** /**
* readOrder * readOrder function is used to read all the order numbers
* @return String
* order.txt
*/ */
public static String readOrder(){ public static String readOrder(){
// 创建文件读取器对象
fileReader fr = new fileReader(); fileReader fr = new fileReader();
// 读取resource目录下的order.txt文件获取所有订单号
String order_number=fr.readFile("resource/order.txt"); String order_number=fr.readFile("resource/order.txt");
// 在控制台打印读取到的订单号(用于调试)
System.out.println(order_number); System.out.println(order_number);
return order_number;//Return all flight order numbers
// 返回所有航班订单号
return order_number;
} }
/** /**
* isOrder * isOrder function is used to know if the order number is correct
* * The isorder method can judge whether there is an entered order number in the file. The parameter in brackets is the "order number" you want to judge. If there is an order number, it returns a value of int type 1, otherwise it returns 0
* @param order_number
* @return int 10
*/ */
public static int isOrder(String order_number){ public static int isOrder(String order_number){
// 初始化判断结果0表示订单号不存在
int judgement = 0; int judgement = 0;
// 调用readOrder方法获取所有订单号
String allOrder=readOrder(); String allOrder=readOrder();
allOrder = "1326854870744 1327854870744 1326854870743 1326854870745 1326854870746 1326854870747 1326854870748 1326854870749 1316854870545 1316854870544";
// 这是测试语句,移出
//allOrder = "1326854870744 1327854870744 1326854870743 1326854870745 1326854870746 1326854870747 1326854870748 1326854870749 1316854870545 1316854870544";
// 正则表达式提取word
String[] sp = allOrder.split("\\s+"); String[] sp = allOrder.split("\\s+");
// 初始化循环计数器
int i=0; int i=0;
// 遍历所有订单号数组
while(i<sp.length){ while(i<sp.length){
// 检查当前订单号是否与输入的订单号匹配
if(sp[i].equals(order_number)){ if(sp[i].equals(order_number)){
judgement=1; judgement=1;
// 找到后立即退出循环,提高效率
break; break;
} }
// 计数器递增,继续检查下一个订单号
i=i+1; i=i+1;
} }
// 返回验证结果1表示存在0表示不存在
return judgement; return judgement;
} }
} }

@ -2,56 +2,41 @@ package model;
import tools.*; import tools.*;
/** /**
* Title: passenger.java * Title : passenger.java
* Description: passenger.txt * Description :passenger. Txt file stores the ID numbers of all scheduled flights, each ID number is separated by a space
* passenger.javapassenger.txt * passenger.java can read and edit passenger.txt.
*
*/ */
public class passenger { public class passenger {//Read the ID number of the saved user
// 读取已保存用户的身份证号码
/** /**
* readPassenger * readPassenger function is used to read all the id numbers
* @return String
* passenger.txt
*/ */
public static String readPassenger(){ public static String readPassenger(){
fileReader fr = new fileReader(); fileReader fr = new fileReader();
String passenger_id=fr.readFile("resource/passenger.txt"); String passenger_id=fr.readFile("resource/passenger.txt");
// 返回所有身份证号码,这里返回字符串,并没有返回字符数组 //System.out.println(passenger_id);
//System.out.println(passenger_id.equals("360124200102040017 360124200102040016 430102197606046442 510801197609022309 632722197112040806 522323198705037737"));
return passenger_id; return passenger_id;
} }
//The ispassenger method can determine whether there is an entered ID number in the file. The parameter in brackets is the ID number you want to determine. If the ID number exists, a value of 1 of type int will be returned. Otherwise, 0 will be returned
// ispassenger方法可以判断文件中是否存在输入的身份证号码。
// 括号中的参数是您要判断的身份证号码。如果身份证号码存在将返回int类型的值1否则返回0
/** /**
* isPassenger * isPassenger function is used to know if the id number is correct
* @param idNum * @param idNum This is the id number
* @return int 10
*
*/ */
public static int isPassenger(String idNum){ public static int isPassenger(String idNum){
int judgement = 0; int judgement = 0;
String passenger_id=readPassenger(); String passenger_id=readPassenger();
// passenger_id = "360124200102040017 360124200102040016 430102197606046442 510801197609022309 632722197112040806 522323198705037737"; passenger_id = "360124200102040017 360124200102040016 430102197606046442 510801197609022309 632722197112040806 522323198705037737";
String[] sp = passenger_id.split("\\s+"); String[] sp = passenger_id.split("\\s+");
int i=0; int i=0;
while(i<sp.length){ while(i<sp.length){
if(sp[i].equals(idNum)){ if(sp[i].equals(idNum)){
// 如果找到匹配的身份证号码设置判断结果为1
judgement=1; judgement=1;
// 找到后立即退出循环,提高效率
break; break;
} }
i=i+1; i=i+1;
} }
// 返回验证结果1表示存在0表示不存在
return judgement; return judgement;
} }
} }

@ -2,151 +2,102 @@ package model;
import tools.*; import tools.*;
/** /**
* Title: passenger_order.java * Title : passenger_order.java
* Description: passenger_order.txt * Description :passenger_ order. Txt file stores the name and order number corresponding to each ID number, and each line represents a unique ID number
* passenger_order.javapassenger_order.txt * passenger_order.java can read and edit passenger_order.txt.
*
* 1 2 ... N
*/ */
public class passenger_order { public class passenger_order {
/** /**
* findOrder_line * findOrder_line function is used to find the line has the order number you want to read
* @param content * @param content this is a order number
* @return String
* passenger_order.txt
*/ */
public static String findOrder_line(String content){ public static String findOrder_line(String content){
lineReader lr = new lineReader(); lineReader lr = new lineReader();
// 在passenger_order.txt文件中查找包含指定内容的行
String order_line=lr.readLine("resource/passenger_order.txt",content); String order_line=lr.readLine("resource/passenger_order.txt",content);
return order_line; return order_line;
} }
/** /**
* findSurname * The findsurname function can view the last name of the owner of the ID number. Adding "ID number" to the parameter in brackets will return "last name"
* @param content * @param content this is an id number
* @return String
*
* 1 2 ...
*/ */
public static String findSurname(String content) { public static String findSurname(String content) {
// 首先查找包含该身份证号的行 String temp=findOrder_line(content);
String temp = findOrder_line(content); String[] sp =temp.split("\\s+");
// 使用空格分割行内容 String surname = sp[2];
String[] sp = temp.split("\\s+");
// 数组索引说明:
// sp[0] = 身份证号
// sp[1] = 姓氏
// sp[2] = 名字
// sp[3]及以后 = 订单号
String surname = sp[1]; // 获取姓氏(数组第二个元素)
return surname; return surname;
} }
/** /**
* findName * The findname function can view the name of the owner of the ID card number. Add "order number" to the parameter in brackets, and "name" will be returned
* @param content * @param content this is a order number
* @return String + +
*
*
*/ */
public static String findName(String content) { public static String findName(String content) {
// 查找包含该订单号的行 String temp=findOrder_line(content);
String temp = findOrder_line(content); String[] sp =temp.split("\\s+");
// 使用空格分割行内容 String name = sp[1]+" "+sp[2];
String[] sp = temp.split("\\s+");
// 组合姓氏和名字形成全名
String name = sp[1] + " " + sp[2];
return name; return name;
} }
/** /**
* isSurname * The issername method can determine whether the entered last name belongs to the ID number. The parameters in parentheses are the ID number and last name you want to determine. If the ID card matches the last name, an int value of 1 is returned. Otherwise, 0 is returned
* @param idNum * @param idNum this is a id number
* @param name * @param name this is surname
* @return int 10
*
*/ */
public static int isSurname(String idNum, String name){ public static int isSurname(String idNum,String name){
// 初始化判断结果0表示不匹配
int judgement = 0; int judgement = 0;
// 根据身份证号获取对应的姓氏 String surname=findSurname(idNum);
String surname = findSurname(idNum);
// 将姓氏分割(这里可能有问题,因为姓氏通常是单个词)
String[] sp = surname.split("\\s+"); String[] sp = surname.split("\\s+");
int i=0;
// 遍历分割后的数组(实际上姓氏应该只有一个元素) while(i<sp.length){
int i = 0;
while(i < sp.length){
// 检查是否与输入的姓氏匹配
if(sp[i].equals(name)){ if(sp[i].equals(name)){
// 匹配成功设置结果为1 judgement=1;
judgement = 1;
break; break;
} }
i = i + 1; i=i+1;
} }
return judgement; return judgement;
} }
/** /**
* orderNum * Since there may be multiple flight orders under an ID card, you can use the ordernum function to view the total number of order numbers under the ID card. Add "ID card number" to the parameter in brackets, and an int type number (order quantity) will be returned
* @param content * @param content this is an id number
* @return int
*
* - 3
*/ */
public static int orderNum(String content){ public static int orderNum(String content){
// 查找包含该身份证号的行 String temp=findOrder_line(content);
String temp = findOrder_line(content);
// 使用空格分割行内容
String[] sp = temp.split("\\s+"); String[] sp = temp.split("\\s+");
// 计算订单数量总字段数减去前3个字段身份证号、姓氏、名字 int num = sp.length-3;
int num = sp.length - 3;
return num; return num;
} }
/** /**
* findOrder * The findorder function can find all the "order numbers" under the ID card according to the "ID card number". Add "ID card number" and "order serial number (1 represents the first order, 2 represents the second order, and so on)" to the parameters in brackets
* @param content * This function will return the order number you selected (type: String)
* @param num 12 * @param content this is an id number
* @return String
*
* 13
*/ */
public static String findOrder(String content, int num) { public static String findOrder(String content,int num) {
// 查找包含该身份证号的行 String temp=findOrder_line(content);
String temp = findOrder_line(content); String[] sp =temp.split("\\s+");
// 使用空格分割行内容 String order_number = sp[num+2];
String[] sp = temp.split("\\s+");
// 根据订单序号获取对应的订单号
// num+2 是因为数组索引从0开始前三个元素是身份证号(0)、姓氏(1)、名字(2)
// 第一个订单在索引3的位置所以需要num+2
String order_number = sp[num + 2];
return order_number; return order_number;
} }
/** /**
* find_id_num * find_ id_ The num function can find the ID card number to which the order number belongs according to the order number, and add the order number to the parameter in brackets
* @param content * This function will return the order number you selected (type: String)
* @return String * @param content this is a order number
*
*/ */
public static String find_id_num(String content) { public static String find_id_num(String content) {
// 查找包含该订单号的行 String temp=findOrder_line(content);
String temp = findOrder_line(content); String[] sp =temp.split("\\s+");
// 使用空格分割行内容
String[] sp = temp.split("\\s+");
// 获取身份证号码(行的第一个字段)
String id_number = sp[0]; String id_number = sp[0];
return id_number; return id_number;
} }
} }

@ -1,68 +0,0 @@
package model_new;
import java.sql.Timestamp;
/**
* @author
* @version 1.0
*/
public class Admin {
private String admin_id; // 管理员身份号
private String username; // 账号
private String password;
private Timestamp created_at;
public Admin(String admin_id, String username, String password, Timestamp created_at) {
this.admin_id = admin_id;
this.username = username;
this.password = password;
this.created_at = created_at;
}
public Admin() {
}
public String getAdmin_id() {
return admin_id;
}
public void setAdmin_id(String admin_id) {
this.admin_id = admin_id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Timestamp getCreated_at() {
return created_at;
}
public void setCreated_at(Timestamp created_at) {
this.created_at = created_at;
}
@Override
public String toString() {
return "Admin{" +
"admin_id='" + admin_id + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", created_at=" + created_at +
'}';
}
}

@ -1,153 +0,0 @@
package model_new;
import java.sql.Timestamp;
// 用于格式化Timestamp类型
//import java.text.SimpleDateFormat;
/**
* @author
* @version 1.0
*/
public class Flight {
private String flight_id; // 航班号
private String airline_company; // 航空公司
private String departure_location; // 出发地点
private String destination_location; // 目的地位置
private Timestamp departure_time; // 出发时间
private Timestamp arrival_time; // 到达时间
private Timestamp boarding_time; // 登机时间
private String gate; // 登机口
private String delay_status; // 延误状态
private String destination_image; // 目的地照片
private Timestamp created_at; // 创建时间
// 构造函数
public Flight(Timestamp created_at, String destination_image,
String delay_status, String gate, Timestamp boarding_time,
Timestamp arrival_time, Timestamp departure_time,
String destination_location, String departure_location,
String airline_company, String flight_id) {
this.created_at = created_at;
this.destination_image = destination_image;
this.delay_status = delay_status;
this.gate = gate;
this.boarding_time = boarding_time;
this.arrival_time = arrival_time;
this.departure_time = departure_time;
this.destination_location = destination_location;
this.departure_location = departure_location;
this.airline_company = airline_company;
this.flight_id = flight_id;
}
public Flight() {
}
public String getFlight_id() {
return flight_id;
}
public void setFlight_id(String flight_id) {
this.flight_id = flight_id;
}
public String getAirline_company() {
return airline_company;
}
public void setAirline_company(String airline_company) {
this.airline_company = airline_company;
}
public String getDeparture_location() {
return departure_location;
}
public void setDeparture_location(String departure_location) {
this.departure_location = departure_location;
}
public String getDestination_location() {
return destination_location;
}
public void setDestination_location(String destination_location) {
this.destination_location = destination_location;
}
public Timestamp getDeparture_time() {
return departure_time;
}
public void setDeparture_time(Timestamp departure_time) {
this.departure_time = departure_time;
}
public Timestamp getArrival_time() {
return arrival_time;
}
public void setArrival_time(Timestamp arrival_time) {
this.arrival_time = arrival_time;
}
public Timestamp getBoarding_time() {
return boarding_time;
}
public void setBoarding_time(Timestamp boarding_time) {
this.boarding_time = boarding_time;
}
public String getDelay_status() {
return delay_status;
}
public void setDelay_status(String delay_status) {
this.delay_status = delay_status;
}
public String getGate() {
return gate;
}
public void setGate(String gate) {
this.gate = gate;
}
public String getDestination_image() {
return destination_image;
}
public void setDestination_image(String destination_image) {
this.destination_image = destination_image;
}
public Timestamp getCreated_at() {
return created_at;
}
public void setCreated_at(Timestamp created_at) {
this.created_at = created_at;
}
@Override
public String toString() {
return "Flight{" +
"flight_id='" + flight_id + '\'' +
", airline_company='" + airline_company + '\'' +
", departure_location='" + departure_location + '\'' +
", destination_location='" + destination_location + '\'' +
", departure_time=" + departure_time +
", arrival_time=" + arrival_time +
", boarding_time=" + boarding_time +
", gate='" + gate + '\'' +
", delay_status='" + delay_status + '\'' +
", destination_image='" + destination_image + '\'' +
", created_at='" + created_at + '\'' +
'}';
}
}

@ -1,110 +0,0 @@
package model_new;
/**
* @author
* @version 1.0
*/
public class FlightSeat {
private int seat_id; // 座位号
private String flight_id; // 航班号
private String seat_number; // 座位编号
private int seat_row; // 行
private char seat_column; // 列
private String seat_class; // 座位类型
private boolean is_available; // 座位是否可用
public FlightSeat(int seat_id, String flight_id, String seat_number, int seat_row,
char seat_column, String seat_class, boolean is_available) {
this.seat_id = seat_id;
this.flight_id = flight_id;
this.seat_number = seat_number;
this.seat_row = seat_row;
this.seat_column = seat_column;
this.seat_class = seat_class;
this.is_available = is_available;
}
public FlightSeat() {
}
public FlightSeat(String flightId, String seatNumber, int row, String columnLetter, String seatClass, boolean b) {
this.flight_id = flightId;
this.seat_number = seatNumber;
this.seat_row = row;
this.seat_column = columnLetter.charAt(0);
this.seat_class = seatClass;
this.is_available = b;
}
public int getSeat_id() {
return seat_id;
}
public void setSeat_id(int seat_id) {
this.seat_id = seat_id;
}
public String getFlight_id() {
return flight_id;
}
public void setFlight_id(String flight_id) {
this.flight_id = flight_id;
}
public String getSeat_number() {
return seat_number;
}
public void setSeat_number(String seat_number) {
this.seat_number = seat_number;
}
public int getSeat_row() {
return seat_row;
}
public void setSeat_row(int seat_row) {
this.seat_row = seat_row;
}
public char getSeat_column() {
return seat_column;
}
public void setSeat_column(char seat_column) {
this.seat_column = seat_column;
}
public String getSeat_class() {
return seat_class;
}
public void setSeat_class(String seat_class) {
this.seat_class = seat_class;
}
public boolean isIs_available() {
return is_available;
}
public void setIs_available(boolean is_available) {
this.is_available = is_available;
}
@Override
public String toString() {
return "FlightSeat{" +
"seat_id=" + seat_id +
", flight_id='" + flight_id + '\'' +
", seat_number='" + seat_number + '\'' +
", seat_row=" + seat_row +
", seat_column=" + seat_column +
", seat_class='" + seat_class + '\'' +
", is_available=" + is_available +
'}';
}
}

@ -1,114 +0,0 @@
package model_new;
import java.sql.Timestamp;
/**
* @author
* @version 1.0
*/
public class Order {
private String order_id; // 订单号
private String passenger_id; // 用户ID
private String flight_id; // 飞机ID
private int seat_id; // 关联座位表
private String food_name; // 食物名称
private String notes;
private boolean boarding_status; // 登机状态
private Timestamp created_at;
public Order(String order_id, String passenger_id, String flight_id, int seat_id,
String food_name, String notes, boolean boarding_status, Timestamp created_at) {
this.order_id = order_id;
this.passenger_id = passenger_id;
this.flight_id = flight_id;
this.seat_id = seat_id;
this.food_name = food_name;
this.notes = notes;
this.boarding_status = boarding_status;
this.created_at = created_at;
}
public Order() {
}
public String getOrder_id() {
return order_id;
}
public void setOrder_id(String order_id) {
this.order_id = order_id;
}
public String getPassenger_id() {
return passenger_id;
}
public void setPassenger_id(String passenger_id) {
this.passenger_id = passenger_id;
}
public String getFlight_id() {
return flight_id;
}
public void setFlight_id(String flight_id) {
this.flight_id = flight_id;
}
public int getSeat_id() {
return seat_id;
}
public void setSeat_id(int seat_id) {
this.seat_id = seat_id;
}
public String getFood_name() {
return food_name;
}
public void setFood_name(String food_name) {
this.food_name = food_name;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public boolean isBoarding_status() {
return boarding_status;
}
public void setBoarding_status(boolean boarding_status) {
this.boarding_status = boarding_status;
}
public Timestamp getCreated_at() {
return created_at;
}
public void setCreated_at(Timestamp created_at) {
this.created_at = created_at;
}
@Override
public String toString() {
return "Order{" +
"order_id='" + order_id + '\'' +
", passenger_id='" + passenger_id + '\'' +
", flight_id='" + flight_id + '\'' +
", seat_id=" + seat_id +
", food_name='" + food_name + '\'' +
", notes='" + notes + '\'' +
", boarding_status=" + boarding_status +
", created_at=" + created_at +
'}';
}
}

@ -1,68 +0,0 @@
package model_new;
import java.sql.Timestamp;
/**
* @author
* @version 1.0
*/
public class Passenger {
private String id_card;
private String name;
private boolean is_vip;
private Timestamp created_at;
public Passenger(String id_card, String name, boolean is_vip, Timestamp created_at) {
this.id_card = id_card;
this.name = name;
this.is_vip = is_vip;
this.created_at = created_at;
}
public Passenger() {
}
public String getId_card() {
return id_card;
}
public void setId_card(String id_card) {
this.id_card = id_card;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean Get_is_vip() {
return is_vip;
}
public void setIs_vip(boolean is_vip) {
this.is_vip = is_vip;
}
public Timestamp getCreated_at() {
return created_at;
}
public void setCreated_at(Timestamp created_at) {
this.created_at = created_at;
}
@Override
public String toString() {
return "Passenger{" +
"id_card='" + id_card + '\'' +
", name='" + name + '\'' +
", is_vip=" + is_vip +
", created_at=" + created_at +
'}';
}
}

@ -1,55 +0,0 @@
package model_new;
import java.util.Date;
/**
* @author
* @version 1.0
*/
public class User {
private Integer id;
private String username;
private String password;
private String email;
private String phone;
private Date createTime;
private Date updateTime;
// 构造方法
public User() {}
public User(String username, String password, String email) {
this.username = username;
this.password = password;
this.email = email;
}
// getters and setters
public Integer getId() { return id; }
public void setId(Integer id) { this.id = id; }
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
public String getPassword() { return password; }
public void setPassword(String password) { this.password = password; }
public String getEmail() { return email; }
public void setEmail(String email) { this.email = email; }
public String getPhone() { return phone; }
public void setPhone(String phone) { this.phone = phone; }
public Date getCreateTime() { return createTime; }
public void setCreateTime(Date createTime) { this.createTime = createTime; }
public Date getUpdateTime() { return updateTime; }
public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
@Override
public String toString() {
return username + " (" + email + ")";
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save