|
|
@@ -39,8 +39,11 @@ def import_flight_range_status(atlas_db, mongo_db, city_pair, create_at_begin_st
|
|
|
},
|
|
|
{
|
|
|
"$addFields": {
|
|
|
- "create_at_readable": {
|
|
|
- "$toDate": {"$multiply": ["$create_at", 1000]}
|
|
|
+ "create_at_beijing": {
|
|
|
+ "$add": [
|
|
|
+ {"$toDate": {"$multiply": ["$create_at", 1000]}},
|
|
|
+ 8 * 60 * 60 * 1000 # 加8小时,保持Date类型
|
|
|
+ ]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -111,8 +114,8 @@ def import_flight_range_status(atlas_db, mongo_db, city_pair, create_at_begin_st
|
|
|
price_tax = doc.get('tax')
|
|
|
price_total = doc.get('total')
|
|
|
create_at = doc.get('create_at')
|
|
|
- create_at_readable = doc.get('create_at_readable')
|
|
|
- create_time = create_at_readable.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
+ create_at_beijing = doc.get('create_at_beijing')
|
|
|
+ create_time = create_at_beijing.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
|
|
new_doc = {
|
|
|
"citypair": citypair_new,
|
|
|
@@ -210,8 +213,13 @@ def mongo_con_parse(config=None):
|
|
|
return client, db
|
|
|
|
|
|
def main_import_process(create_at_begin, create_at_end):
|
|
|
- create_at_begin_stamp = int(datetime.strptime(create_at_begin, "%Y-%m-%d %H:%M:%S").timestamp())
|
|
|
- create_at_end_stamp = int(datetime.strptime(create_at_end, "%Y-%m-%d %H:%M:%S").timestamp())
|
|
|
+ # 先转 datetime,再减去 0 小时得到 UTC 时间戳
|
|
|
+ begin_dt = datetime.strptime(create_at_begin, "%Y-%m-%d %H:%M:%S") - timedelta(hours=0)
|
|
|
+ end_dt = datetime.strptime(create_at_end, "%Y-%m-%d %H:%M:%S") - timedelta(hours=0)
|
|
|
+
|
|
|
+ create_at_begin_stamp = int(begin_dt.timestamp())
|
|
|
+ create_at_end_stamp = int(end_dt.timestamp())
|
|
|
+
|
|
|
print(f"create_at_begin: {create_at_begin}, timestamp: {create_at_begin_stamp}")
|
|
|
print(f"create_at_end: {create_at_end}, timestamp: {create_at_end_stamp}")
|
|
|
|
|
|
@@ -241,10 +249,10 @@ if __name__ == "__main__":
|
|
|
create_at_end = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
create_at_begin = (current_time - timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
- # create_at_begin = "2026-04-08 00:00:00"
|
|
|
- # create_at_end = "2026-04-09 15:59:59"
|
|
|
+ # create_at_begin = "2026-04-21 00:00:00"
|
|
|
+ # create_at_end = "2026-04-22 23:59:59"
|
|
|
|
|
|
main_import_process(create_at_begin, create_at_end)
|
|
|
|
|
|
print(f"本次导入结束时间: {datetime.now()}")
|
|
|
- print()
|
|
|
+ print()
|