Spaces:
Running
Running
Update app3.py
Browse files
app3.py
CHANGED
@@ -7,280 +7,259 @@ import base64
|
|
7 |
import matplotlib.gridspec as gridspec
|
8 |
import math
|
9 |
from matplotlib.backends.backend_pdf import PdfPages
|
10 |
-
from matplotlib.patches import
|
11 |
|
|
|
12 |
SPLIT_TIME = "17:30"
|
13 |
BUSINESS_START = "09:30"
|
14 |
BUSINESS_END = "01:30"
|
15 |
BORDER_COLOR = '#A9A9A9'
|
16 |
DATE_COLOR = '#A9A9A9'
|
|
|
17 |
|
18 |
def process_schedule(file):
|
19 |
"""处理上传的 Excel 文件,生成排序和分组后的打印内容"""
|
20 |
try:
|
21 |
# 读取 Excel,跳过前 8 行
|
22 |
df = pd.read_excel(file, skiprows=8)
|
23 |
-
|
24 |
# 提取所需列 (G9, H9, J9)
|
25 |
df = df.iloc[:, [6, 7, 9]] # G, H, J 列
|
26 |
df.columns = ['Hall', 'StartTime', 'EndTime']
|
27 |
-
|
28 |
# 清理数据
|
29 |
df = df.dropna(subset=['Hall', 'StartTime', 'EndTime'])
|
30 |
-
|
31 |
# 转换影厅格式为 "#号" 格式
|
32 |
df['Hall'] = df['Hall'].str.extract(r'(\d+)号').astype(str) + ' '
|
33 |
-
|
34 |
# 保存原始时间字符串用于诊断
|
35 |
df['original_end'] = df['EndTime']
|
36 |
-
|
37 |
# 转换时间为 datetime 对象
|
38 |
base_date = datetime.today().date()
|
39 |
-
|
40 |
-
df['
|
41 |
-
|
|
|
|
|
42 |
# 设置基准时间
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
#
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
for idx, row in df.iterrows():
|
52 |
-
end_time = row['EndTime']
|
53 |
-
if end_time.hour < 9:
|
54 |
-
df.at[idx, 'EndTime'] = end_time + timedelta(days=1)
|
55 |
-
|
56 |
-
if row['StartTime'].hour >= 21 and end_time.hour < 9:
|
57 |
-
df.at[idx, 'EndTime'] = end_time + timedelta(days=1)
|
58 |
-
|
59 |
-
# 筛选营业时间内的场次
|
60 |
-
df['time_for_comparison'] = df['EndTime'].apply(
|
61 |
-
lambda x: datetime.combine(base_date, x.time())
|
62 |
-
)
|
63 |
-
|
64 |
-
df.loc[df['time_for_comparison'].dt.hour < 9, 'time_for_comparison'] += timedelta(days=1)
|
65 |
-
|
66 |
-
valid_times = (
|
67 |
-
((df['time_for_comparison'] >= datetime.combine(base_date, business_start.time())) &
|
68 |
-
(df['time_for_comparison'] <= datetime.combine(base_date + timedelta(days=1), business_end.time())))
|
69 |
)
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
df = df.sort_values('EndTime')
|
75 |
-
|
76 |
# 分割数据
|
77 |
-
|
78 |
-
split_time_for_comparison = df['time_for_comparison'].apply(
|
79 |
-
lambda x: datetime.combine(base_date, split_time.time())
|
80 |
-
)
|
81 |
-
|
82 |
-
part1 = df[df['time_for_comparison'] <= split_time_for_comparison].copy()
|
83 |
-
part2 = df[df['time_for_comparison'] > split_time_for_comparison].copy()
|
84 |
|
85 |
-
|
|
|
|
|
|
|
86 |
for part in [part1, part2]:
|
87 |
-
part['
|
88 |
-
|
89 |
-
#
|
90 |
-
date_df = pd.read_excel(
|
91 |
-
file,
|
92 |
-
skiprows=5, # 跳过前5行(0-4)
|
93 |
-
nrows=1, # 只读1行
|
94 |
-
usecols=[2], # 第三列(C列)
|
95 |
-
header=None # 无表头
|
96 |
-
)
|
97 |
date_cell = date_df.iloc[0, 0]
|
98 |
-
|
99 |
try:
|
100 |
-
# 处理不同日期格式
|
101 |
if isinstance(date_cell, str):
|
|
|
102 |
date_str = datetime.strptime(date_cell, '%Y-%m-%d').strftime('%Y-%m-%d')
|
103 |
else:
|
|
|
104 |
date_str = pd.to_datetime(date_cell).strftime('%Y-%m-%d')
|
105 |
except:
|
106 |
date_str = datetime.today().strftime('%Y-%m-%d')
|
107 |
-
|
108 |
-
return part1[['Hall', '
|
109 |
-
|
110 |
except Exception as e:
|
111 |
st.error(f"处理文件时出错: {str(e)}")
|
112 |
return None, None, None
|
113 |
|
|
|
114 |
def create_print_layout(data, title, date_str):
|
115 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
if data.empty:
|
117 |
return None
|
118 |
|
119 |
-
# ---
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
# ---
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
#
|
150 |
-
|
151 |
-
|
152 |
-
#
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
# --- 保存 PNG ---
|
239 |
png_buffer = io.BytesIO()
|
240 |
-
|
241 |
-
png_fig.savefig(png_buffer, format='png', bbox_inches='tight', pad_inches=0.02)
|
242 |
png_buffer.seek(0)
|
243 |
png_base64 = base64.b64encode(png_buffer.getvalue()).decode()
|
244 |
-
plt.close(png_fig)
|
245 |
|
246 |
-
#
|
247 |
pdf_buffer = io.BytesIO()
|
248 |
-
|
249 |
-
# 可以尝试减小 pad_inches, even set to 0
|
250 |
-
pdf.savefig(pdf_fig, bbox_inches='tight', pad_inches=0.02)
|
251 |
pdf_buffer.seek(0)
|
252 |
pdf_base64 = base64.b64encode(pdf_buffer.getvalue()).decode()
|
253 |
-
|
|
|
254 |
|
255 |
return {
|
256 |
'png': f'data:image/png;base64,{png_base64}',
|
257 |
'pdf': f'data:application/pdf;base64,{pdf_base64}'
|
258 |
}
|
259 |
|
260 |
-
# --- 新增 PDF 显示函数 ---
|
261 |
def display_pdf(base64_pdf):
|
262 |
"""在Streamlit中嵌入显示PDF"""
|
263 |
pdf_display = f'<iframe src="{base64_pdf}" width="100%" height="800" type="application/pdf"></iframe>'
|
264 |
return pdf_display
|
265 |
|
266 |
-
# Streamlit
|
267 |
st.set_page_config(page_title="散厅时间快捷打印", layout="wide")
|
268 |
st.title("散厅时间快捷打印")
|
269 |
|
270 |
-
uploaded_file = st.file_uploader("上传【放映场次核对表.xls】文件", type=["xls"])
|
271 |
|
272 |
if uploaded_file:
|
|
|
273 |
part1, part2, date_str = process_schedule(uploaded_file)
|
274 |
-
|
275 |
if part1 is not None and part2 is not None:
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
|
|
279 |
|
280 |
col1, col2 = st.columns(2)
|
281 |
|
282 |
with col1:
|
283 |
-
st.subheader("
|
284 |
if part1_output:
|
285 |
tab1_1, tab1_2 = st.tabs(["PDF 预览", "PNG 预览"])
|
286 |
with tab1_1:
|
@@ -291,7 +270,7 @@ if uploaded_file:
|
|
291 |
st.info("白班部分没有数据")
|
292 |
|
293 |
with col2:
|
294 |
-
st.subheader("
|
295 |
if part2_output:
|
296 |
tab2_1, tab2_2 = st.tabs(["PDF 预览", "PNG 预览"])
|
297 |
with tab2_1:
|
@@ -299,6 +278,4 @@ if uploaded_file:
|
|
299 |
with tab2_2:
|
300 |
st.image(part2_output['png'])
|
301 |
else:
|
302 |
-
st.info("夜班部分没有数据")
|
303 |
-
|
304 |
-
|
|
|
7 |
import matplotlib.gridspec as gridspec
|
8 |
import math
|
9 |
from matplotlib.backends.backend_pdf import PdfPages
|
10 |
+
from matplotlib.patches import Rectangle # Replaced FancyBboxPatch
|
11 |
|
12 |
+
# --- Constants ---
|
13 |
SPLIT_TIME = "17:30"
|
14 |
BUSINESS_START = "09:30"
|
15 |
BUSINESS_END = "01:30"
|
16 |
BORDER_COLOR = '#A9A9A9'
|
17 |
DATE_COLOR = '#A9A9A9'
|
18 |
+
SEQ_COLOR = '#A9A9A9' # Color for the new serial number
|
19 |
|
20 |
def process_schedule(file):
|
21 |
"""处理上传的 Excel 文件,生成排序和分组后的打印内容"""
|
22 |
try:
|
23 |
# 读取 Excel,跳过前 8 行
|
24 |
df = pd.read_excel(file, skiprows=8)
|
25 |
+
|
26 |
# 提取所需列 (G9, H9, J9)
|
27 |
df = df.iloc[:, [6, 7, 9]] # G, H, J 列
|
28 |
df.columns = ['Hall', 'StartTime', 'EndTime']
|
29 |
+
|
30 |
# 清理数据
|
31 |
df = df.dropna(subset=['Hall', 'StartTime', 'EndTime'])
|
32 |
+
|
33 |
# 转换影厅格式为 "#号" 格式
|
34 |
df['Hall'] = df['Hall'].str.extract(r'(\d+)号').astype(str) + ' '
|
35 |
+
|
36 |
# 保存原始时间字符串用于诊断
|
37 |
df['original_end'] = df['EndTime']
|
38 |
+
|
39 |
# 转换时间为 datetime 对象
|
40 |
base_date = datetime.today().date()
|
41 |
+
# Using errors='coerce' will turn unparseable times into NaT (Not a Time)
|
42 |
+
df['StartTime'] = pd.to_datetime(df['StartTime'], errors='coerce')
|
43 |
+
df['EndTime'] = pd.to_datetime(df['EndTime'], errors='coerce')
|
44 |
+
df = df.dropna(subset=['StartTime', 'EndTime']) # Drop rows where time conversion failed
|
45 |
+
|
46 |
# 设置基准时间
|
47 |
+
business_start_time = datetime.strptime(BUSINESS_START, "%H:%M").time()
|
48 |
+
business_end_time = datetime.strptime(BUSINESS_END, "%H:%M").time()
|
49 |
+
|
50 |
+
# 处理跨天情况:结束时间小于开始时间,则结束时间加一天
|
51 |
+
# This logic handles cases like 9:30 AM to 1:30 AM (next day)
|
52 |
+
df['EndTime_adjusted'] = df.apply(
|
53 |
+
lambda row: row['EndTime'] + timedelta(days=1) if row['EndTime'].time() < row['StartTime'].time() else row['EndTime'],
|
54 |
+
axis=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
)
|
56 |
|
57 |
+
# 按散场时间排序 (using the adjusted time)
|
58 |
+
df = df.sort_values('EndTime_adjusted')
|
59 |
+
|
|
|
|
|
60 |
# 分割数据
|
61 |
+
split_dt = datetime.strptime(SPLIT_TIME, "%H:%M").time()
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
part1 = df[df['EndTime_adjusted'].dt.time <= split_dt].copy()
|
64 |
+
part2 = df[df['EndTime_adjusted'].dt.time > split_dt].copy()
|
65 |
+
|
66 |
+
# 格式化时间显示 (use original EndTime for display)
|
67 |
for part in [part1, part2]:
|
68 |
+
part['EndTime_formatted'] = part['EndTime'].dt.strftime('%-I:%M')
|
69 |
+
|
70 |
+
# 读取日期单元格 C6
|
71 |
+
date_df = pd.read_excel(file, skiprows=5, nrows=1, usecols=[2], header=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
date_cell = date_df.iloc[0, 0]
|
73 |
+
|
74 |
try:
|
|
|
75 |
if isinstance(date_cell, str):
|
76 |
+
# Assuming format like '2023-10-27'
|
77 |
date_str = datetime.strptime(date_cell, '%Y-%m-%d').strftime('%Y-%m-%d')
|
78 |
else:
|
79 |
+
# Assuming it's a datetime object
|
80 |
date_str = pd.to_datetime(date_cell).strftime('%Y-%m-%d')
|
81 |
except:
|
82 |
date_str = datetime.today().strftime('%Y-%m-%d')
|
83 |
+
|
84 |
+
return part1[['Hall', 'EndTime_formatted']], part2[['Hall', 'EndTime_formatted']], date_str
|
85 |
+
|
86 |
except Exception as e:
|
87 |
st.error(f"处理文件时出错: {str(e)}")
|
88 |
return None, None, None
|
89 |
|
90 |
+
|
91 |
def create_print_layout(data, title, date_str):
|
92 |
+
"""
|
93 |
+
创建符合新要求的打印布局 (PNG 和 PDF)。
|
94 |
+
1. 动态计算边距。
|
95 |
+
2. 使用灰色虚线圆点作为单元格边框。
|
96 |
+
3. 单元格内容区域为单元格的90%。
|
97 |
+
4. 在左上角添加灰色序号。
|
98 |
+
"""
|
99 |
if data.empty:
|
100 |
return None
|
101 |
|
102 |
+
# --- Constants ---
|
103 |
+
A5_WIDTH_IN = 5.83
|
104 |
+
A5_HEIGHT_IN = 8.27
|
105 |
+
DPI = 300
|
106 |
+
NUM_COLS = 3
|
107 |
+
|
108 |
+
# --- Setup Figure ---
|
109 |
+
fig = plt.figure(figsize=(A5_WIDTH_IN, A5_HEIGHT_IN), dpi=DPI)
|
110 |
+
|
111 |
+
# --- Font Setup ---
|
112 |
+
plt.rcParams['font.family'] = 'sans-serif'
|
113 |
+
plt.rcParams['font.sans-serif'] = ['Arial Unicode MS', 'Heiti TC', 'sans-serif']
|
114 |
+
|
115 |
+
|
116 |
+
# --- Data Preparation ---
|
117 |
+
total_items = len(data)
|
118 |
+
# Augment data with an original index for numbering
|
119 |
+
data_values_with_index = [(i, row) for i, row in enumerate(data.values.tolist())]
|
120 |
+
|
121 |
+
# Pad data to be a multiple of NUM_COLS
|
122 |
+
padded_total = math.ceil(total_items / NUM_COLS) * NUM_COLS
|
123 |
+
while len(data_values_with_index) < padded_total:
|
124 |
+
data_values_with_index.append((None, ['', '']))
|
125 |
+
|
126 |
+
num_rows = padded_total // NUM_COLS
|
127 |
+
|
128 |
+
# --- Layout Calculation (Request 1) ---
|
129 |
+
if num_rows > 0:
|
130 |
+
# "A5 paper height / num_rows / 4 is the padding for all sides"
|
131 |
+
padding_in = (A5_HEIGHT_IN / num_rows / 4)
|
132 |
+
# Cap padding to prevent it from being excessively large
|
133 |
+
padding_in = min(padding_in, 0.5)
|
134 |
+
else:
|
135 |
+
padding_in = 0.25 # Default padding if no rows
|
136 |
+
|
137 |
+
# Convert padding to relative figure coordinates for subplots_adjust
|
138 |
+
left_margin = padding_in / A5_WIDTH_IN
|
139 |
+
right_margin = 1 - left_margin
|
140 |
+
bottom_margin = padding_in / A5_HEIGHT_IN
|
141 |
+
top_margin = 1 - bottom_margin
|
142 |
+
|
143 |
+
# Adjust overall figure margins
|
144 |
+
fig.subplots_adjust(left=left_margin, right=right_margin, top=top_margin, bottom=bottom_margin, hspace=0.4, wspace=0.4)
|
145 |
+
|
146 |
+
# --- Grid & Font Size ---
|
147 |
+
gs = gridspec.GridSpec(num_rows + 1, NUM_COLS, height_ratios=[0.2] + [1] * num_rows, figure=fig)
|
148 |
+
|
149 |
+
if num_rows > 0:
|
150 |
+
content_area_height_in = A5_HEIGHT_IN * (top_margin - bottom_margin)
|
151 |
+
cell_height_in = content_area_height_in / num_rows * (1 - fig.subplotpars.hspace)
|
152 |
+
base_fontsize = min(40, max(10, cell_height_in * 72 * 0.4)) # 72 pt/inch, 40% of cell height
|
153 |
+
else:
|
154 |
+
base_fontsize = 20
|
155 |
+
|
156 |
+
# --- Z-Sort (Column-major) Data for Layout ---
|
157 |
+
rows_per_col_layout = num_rows
|
158 |
+
sorted_data = [(None, ['',''])] * padded_total
|
159 |
+
for i, item_tuple in enumerate(data_values_with_index):
|
160 |
+
if item_tuple[0] is not None:
|
161 |
+
original_data_index = i # Index from the time-sorted list
|
162 |
+
row_in_col = original_data_index % rows_per_col_layout
|
163 |
+
col_idx = original_data_index // rows_per_col_layout
|
164 |
+
new_grid_index = row_in_col * NUM_COLS + col_idx
|
165 |
+
if new_grid_index < len(sorted_data):
|
166 |
+
sorted_data[new_grid_index] = item_tuple
|
167 |
+
|
168 |
+
# --- Drawing Logic ---
|
169 |
+
for grid_idx, item_tuple in enumerate(sorted_data):
|
170 |
+
original_index, (hall, end_time) = item_tuple
|
171 |
+
|
172 |
+
if original_index is not None:
|
173 |
+
row_grid = grid_idx // NUM_COLS + 1 # +1 because date is in row 0
|
174 |
+
col_grid = grid_idx % NUM_COLS
|
175 |
+
|
176 |
+
ax = fig.add_subplot(gs[row_grid, col_grid])
|
177 |
+
ax.set_axis_off()
|
178 |
+
|
179 |
+
# --- Cell Border (Request 2) & Content Area (Request 3) ---
|
180 |
+
# Draw a dotted rectangle. Content will be placed inside this.
|
181 |
+
# Making the rect slightly smaller creates a visual 90% area.
|
182 |
+
cell_border = Rectangle((0.05, 0.05), 0.9, 0.9,
|
183 |
+
edgecolor=BORDER_COLOR,
|
184 |
+
facecolor='none',
|
185 |
+
linestyle=(0, (1, 1.5)), # Dotted line with round caps
|
186 |
+
linewidth=1,
|
187 |
+
transform=ax.transAxes,
|
188 |
+
clip_on=False)
|
189 |
+
ax.add_patch(cell_border)
|
190 |
+
|
191 |
+
# --- Cell Content ---
|
192 |
+
display_text = f"{hall}{end_time}"
|
193 |
+
ax.text(0.5, 0.5, display_text,
|
194 |
+
fontsize=base_fontsize,
|
195 |
+
fontweight='bold',
|
196 |
+
ha='center', va='center',
|
197 |
+
transform=ax.transAxes)
|
198 |
+
|
199 |
+
# --- Cell Numbering (Request 4) ---
|
200 |
+
# Serial number is original_index + 1
|
201 |
+
ax.text(0.12, 0.82, str(original_index + 1),
|
202 |
+
fontsize=base_fontsize * 0.5,
|
203 |
+
color=SEQ_COLOR,
|
204 |
+
fontweight='normal',
|
205 |
+
ha='center', va='center',
|
206 |
+
transform=ax.transAxes)
|
207 |
+
|
208 |
+
# --- Date Header ---
|
209 |
+
ax_date = fig.add_subplot(gs[0, :])
|
210 |
+
ax_date.set_axis_off()
|
211 |
+
ax_date.text(0, 0.5, f"{date_str} {title}",
|
212 |
+
fontsize=base_fontsize * 0.6,
|
213 |
+
color=DATE_COLOR,
|
214 |
+
fontweight='bold',
|
215 |
+
ha='left', va='center',
|
216 |
+
transform=ax_date.transAxes)
|
217 |
+
|
218 |
+
# --- Save to Buffers ---
|
219 |
+
# Save PNG
|
|
|
|
|
220 |
png_buffer = io.BytesIO()
|
221 |
+
fig.savefig(png_buffer, format='png', bbox_inches='tight', pad_inches=0.02)
|
|
|
222 |
png_buffer.seek(0)
|
223 |
png_base64 = base64.b64encode(png_buffer.getvalue()).decode()
|
|
|
224 |
|
225 |
+
# Save PDF
|
226 |
pdf_buffer = io.BytesIO()
|
227 |
+
fig.savefig(pdf_buffer, format='pdf', bbox_inches='tight', pad_inches=0.02)
|
|
|
|
|
228 |
pdf_buffer.seek(0)
|
229 |
pdf_base64 = base64.b64encode(pdf_buffer.getvalue()).decode()
|
230 |
+
|
231 |
+
plt.close(fig)
|
232 |
|
233 |
return {
|
234 |
'png': f'data:image/png;base64,{png_base64}',
|
235 |
'pdf': f'data:application/pdf;base64,{pdf_base64}'
|
236 |
}
|
237 |
|
|
|
238 |
def display_pdf(base64_pdf):
|
239 |
"""在Streamlit中嵌入显示PDF"""
|
240 |
pdf_display = f'<iframe src="{base64_pdf}" width="100%" height="800" type="application/pdf"></iframe>'
|
241 |
return pdf_display
|
242 |
|
243 |
+
# --- Streamlit UI ---
|
244 |
st.set_page_config(page_title="散厅时间快捷打印", layout="wide")
|
245 |
st.title("散厅时间快捷打印")
|
246 |
|
247 |
+
uploaded_file = st.file_uploader("上传【放映场次核对表.xls】文件", type=["xls", "xlsx"])
|
248 |
|
249 |
if uploaded_file:
|
250 |
+
# Use new column name 'EndTime_formatted' for display
|
251 |
part1, part2, date_str = process_schedule(uploaded_file)
|
|
|
252 |
if part1 is not None and part2 is not None:
|
253 |
+
part1_data_for_layout = part1[['Hall', 'EndTime_formatted']]
|
254 |
+
part2_data_for_layout = part2[['Hall', 'EndTime_formatted']]
|
255 |
+
|
256 |
+
part1_output = create_print_layout(part1_data_for_layout, "A", date_str)
|
257 |
+
part2_output = create_print_layout(part2_data_for_layout, "C", date_str)
|
258 |
|
259 |
col1, col2 = st.columns(2)
|
260 |
|
261 |
with col1:
|
262 |
+
st.subheader("白班散场预览(散场时间 ≤ 17:30)")
|
263 |
if part1_output:
|
264 |
tab1_1, tab1_2 = st.tabs(["PDF 预览", "PNG 预览"])
|
265 |
with tab1_1:
|
|
|
270 |
st.info("白班部分没有数据")
|
271 |
|
272 |
with col2:
|
273 |
+
st.subheader("夜班散场预览(散场时间 > 17:30)")
|
274 |
if part2_output:
|
275 |
tab2_1, tab2_2 = st.tabs(["PDF 预览", "PNG 预览"])
|
276 |
with tab2_1:
|
|
|
278 |
with tab2_2:
|
279 |
st.image(part2_output['png'])
|
280 |
else:
|
281 |
+
st.info("夜班部分没有数据")
|
|
|
|