diff --git a/back_ground_module/logs/error_task.log b/back_ground_module/logs/error_task.log index b3deaa8..5c32a0c 100644 --- a/back_ground_module/logs/error_task.log +++ b/back_ground_module/logs/error_task.log @@ -7,3 +7,4 @@ 2025-08-21 09:37:49,150 - data_Support_Commission.py - error_task_logger - ERROR - 小六提成数据支撑任务执行出错:cannot access local variable 'data_commission' where it is not associated with a value 2025-08-21 09:38:43,196 - data_Support_Commission.py - error_task_logger - ERROR - 小六提成数据支撑任务执行出错:'Logger' object has no attribute 'warrning' 2025-08-21 09:38:43,333 - data_Support_Commission.py - error_task_logger - ERROR - 小六提成数据支撑任务执行出错:cannot access local variable 'data_commission' where it is not associated with a value +2025-08-21 09:54:25,836 - update_denominator_reporting_adjustment_to_bi.py - error_task_logger - ERROR - 写入数据时发生错误: 1054 (42S22): Unknown column 'nan' in 'field list' diff --git a/back_ground_module/logs/task.log b/back_ground_module/logs/task.log index 7317006..9076720 100644 --- a/back_ground_module/logs/task.log +++ b/back_ground_module/logs/task.log @@ -13806,3 +13806,22 @@ 2025-08-21 09:42:56,325 - api.py - task_logger - INFO - 46页 返回结果: {'status': 'success', 'success_count': 24} 2025-08-21 09:42:56,700 - api.py - task_logger - INFO - 多数据写入行数: 5594 2025-08-21 09:43:11,161 - common_module.py - task_logger - INFO - 任务状态发送成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-08-21T01:43:12.493Z', 'updateTime': '2025-08-21T01:43:12.493Z', 'deleteTime': None, '_widget_1744873387500': '2025-08-21T00:00:00.000Z', '_widget_1743644977694': '小六提成数据支撑', '_widget_1744873387501': '2025-08-21T01:42:27.000Z', '_widget_1744873387502': '2025-08-21T01:43:10.000Z', '_widget_1744873387504': '43', '_id': '68a679b0148af9d8cfa5f5ea', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}} +2025-08-21 09:48:38,988 - update_molecule_reporting_adjustment_to_bi.py - task_logger - INFO - 开始执行任务 +2025-08-21 09:48:39,871 - update_molecule_reporting_adjustment_to_bi.py - task_logger - INFO - 获取宜搭数据成功 +2025-08-21 09:48:40,149 - update_molecule_reporting_adjustment_to_bi.py - task_logger - INFO - 成功清空表数据 +2025-08-21 09:48:40,149 - update_molecule_reporting_adjustment_to_bi.py - task_logger - INFO - 清空表成功 +2025-08-21 09:48:41,420 - update_molecule_reporting_adjustment_to_bi.py - task_logger - INFO - 成功写入 70 条记录到 f6_molecule_adjustment 表中。 +2025-08-21 09:48:41,420 - update_molecule_reporting_adjustment_to_bi.py - task_logger - INFO - 写入BI数据库成功 +2025-08-21 09:48:41,583 - common_module.py - task_logger - INFO - 任务状态发送成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-08-21T01:48:42.936Z', 'updateTime': '2025-08-21T01:48:42.936Z', 'deleteTime': None, '_widget_1744873387500': '2025-08-21T00:00:00.000Z', '_widget_1743644977694': '分子报备调整', '_widget_1744873387501': '2025-08-21T01:48:38.000Z', '_widget_1744873387502': '2025-08-21T01:48:41.000Z', '_widget_1744873387504': '3', '_id': '68a67afae111bf65eae586ff', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}} +2025-08-21 09:54:25,441 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 获取宜搭数据成功 +2025-08-21 09:54:25,685 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 清空表数据成功 +2025-08-21 09:54:25,686 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 清空表数据成功 +2025-08-21 09:54:25,984 - common_module.py - task_logger - INFO - 任务错误发生成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-08-21T01:54:27.324Z', 'updateTime': '2025-08-21T01:54:27.324Z', 'deleteTime': None, '_widget_1744873387500': '2025-08-21T00:00:00.000Z', '_widget_1743644977694': '分母报备调整', '_widget_1744873387501': '2025-08-21T01:54:25.000Z', '_widget_1744873387502': '2025-08-21T01:54:25.000Z', '_widget_1744873387504': '0', '_widget_1754981992215': "1054 (42S22): Unknown column 'nan' in 'field list'", '_id': '68a67c538fc253d96bfb3410', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '689ae65da00c17578e27cd74'}} +2025-08-21 09:54:25,998 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 写入BI数据库成功 +2025-08-21 09:54:26,146 - common_module.py - task_logger - INFO - 任务状态发送成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-08-21T01:54:27.497Z', 'updateTime': '2025-08-21T01:54:27.497Z', 'deleteTime': None, '_widget_1744873387500': '2025-08-21T00:00:00.000Z', '_widget_1743644977694': '分母报备调整', '_widget_1744873387501': '2025-08-21T01:54:23.000Z', '_widget_1744873387502': '2025-08-21T01:54:25.000Z', '_widget_1744873387504': '2', '_id': '68a67c53f279a27cf8281c30', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}} +2025-08-21 09:54:52,857 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 获取宜搭数据成功 +2025-08-21 09:54:53,056 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 清空表数据成功 +2025-08-21 09:54:53,057 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 清空表数据成功 +2025-08-21 09:54:59,971 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - 成功写入 398 条记录到 f6_denominator_adjustment 表中。 +2025-08-21 09:54:59,972 - update_denominator_reporting_adjustment_to_bi.py - task_logger - INFO - ✅ 写入BI数据库成功 +2025-08-21 09:55:00,102 - common_module.py - task_logger - INFO - 任务状态发送成功: {'data': {'creator': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'updater': {'name': 'F6汽车科技', 'username': '#admin', 'status': 1, 'type': 0}, 'deleter': None, 'createTime': '2025-08-21T01:55:01.452Z', 'updateTime': '2025-08-21T01:55:01.452Z', 'deleteTime': None, '_widget_1744873387500': '2025-08-21T00:00:00.000Z', '_widget_1743644977694': '分母报备调整', '_widget_1744873387501': '2025-08-21T01:54:50.000Z', '_widget_1744873387502': '2025-08-21T01:54:59.000Z', '_widget_1744873387504': '9', '_id': '68a67c759597e45c1b2c0617', 'appId': '6694d3c4fcb69ca9a111a6c4', 'entryId': '67ede908eb9c22261016466e'}} diff --git a/back_ground_module/update_denominator_reporting_adjustment_to_bi.py b/back_ground_module/update_denominator_reporting_adjustment_to_bi.py index 3806a9c..871fbf8 100644 --- a/back_ground_module/update_denominator_reporting_adjustment_to_bi.py +++ b/back_ground_module/update_denominator_reporting_adjustment_to_bi.py @@ -142,7 +142,21 @@ class DenominatorReportingAdjustment: cursor.execute(f"SHOW COLUMNS FROM {table_name}") columns_info = cursor.fetchall() db_columns = [col[0] for col in columns_info] # 提取列名 + + + # 处理日期字段 - 新增部分 + date_fields = ['开户日期', '开始时间', '结束时间'] + for field in date_fields: + if field in df.columns: + # 转换为整数类型 + df[field] = pd.to_numeric(df[field], errors='coerce').astype('Int64') + # 转换为datetime对象 + df[field] = pd.to_datetime(df[field], unit='ms') + # 转换为MySQL兼容的字符串格式 + df[field] = df[field].dt.strftime('%Y-%m-%d %H:%M:%S') + df = df.replace([None, np.nan, pd.NA, 'nan', 'NaN', 'NAN', ''], None) + # 保留 DataFrame 中与数据库列名匹配的列 filtered_df = df[df.columns.intersection(db_columns)] @@ -195,14 +209,6 @@ class DenominatorReportingAdjustment: logger.info("✅ 获取宜搭数据成功") df = pd.DataFrame(self.denominator_data_list) - df['开户日期'] = df['开户日期'].astype('Int64') - df['开户日期'] = pd.to_datetime(df['开户日期'], unit='ms') - - df['结束时间'] = df['结束时间'].astype('Int64') - df['结束时间'] = pd.to_datetime(df['结束时间'], unit='ms') - - df['开始时间'] = df['开始时间'].astype('Int64') - df['开始时间'] = pd.to_datetime(df['开始时间'], unit='ms') # step2:清空BI数据表 self.clear_table() diff --git a/back_ground_module/update_molecule_reporting_adjustment_to_bi.py b/back_ground_module/update_molecule_reporting_adjustment_to_bi.py index 0edd919..8894a92 100644 --- a/back_ground_module/update_molecule_reporting_adjustment_to_bi.py +++ b/back_ground_module/update_molecule_reporting_adjustment_to_bi.py @@ -188,8 +188,13 @@ class MoleculeReportingAdjustment: logger.info(f"获取宜搭数据成功") df = pd.DataFrame(self.molecule_data_list) - df['归属月份'] = df['归属月份'].astype('Int64') - df['归属月份'] = pd.to_datetime(df['归属月份'], unit='ms') + if '归属月份' in df.columns: + # 确保是整数类型 + df['归属月份'] = df['归属月份'].astype('Int64') + # 转换为datetime对象 + df['归属月份'] = pd.to_datetime(df['归属月份'], unit='ms') + # 转换为MySQL兼容的字符串格式 + df['归属月份'] = df['归属月份'].dt.strftime('%Y-%m-%d %H:%M:%S') # step2:清空BI数据表 self.clear_table()