数据库统计增加当月每艘船的作业量

This commit is contained in:
2025-12-29 02:50:25 +08:00
parent 833db895b0
commit 4d2f9302ff
2 changed files with 39 additions and 5 deletions

View File

@@ -86,7 +86,7 @@ class OrbitInGUI:
btn_report_today = ttk.Button(
left_frame,
text="日日报",
text="日日报",
command=self.generate_today_report,
width=20
)
@@ -422,17 +422,27 @@ class OrbitInGUI:
try:
db = DailyLogsDatabase()
stats = db.get_stats()
# 获取当月船次统计
current_month = datetime.now().strftime('%Y-%m')
ships_monthly = db.get_ships_with_monthly_teu(current_month)
db.close()
self.log_message(f"总记录数: {stats['total']}")
self.log_message(f"船次数量: {len(stats['ships'])}")
self.log_message(f"日期范围: {stats['date_range']['start']} ~ {stats['date_range']['end']}")
if stats['ships']:
if ships_monthly:
self.log_message("")
self.log_message("船次列表:")
for ship in sorted(stats['ships']):
self.log_message(f" - {ship}")
self.log_message(f"{current_month}月船次统计:")
total_monthly_teu = 0
for ship in ships_monthly:
monthly_teu = ship['monthly_teu'] or 0
total_monthly_teu += monthly_teu
self.log_message(f" {ship['ship_name']}: {monthly_teu}TEU")
self.log_message(f" ---")
self.log_message(f" 本月合计: {total_monthly_teu}TEU")
self.set_status("完成")