修复因无新增客户导致NGV数据新增异常
This commit is contained in:
@@ -10,6 +10,8 @@ from decimal import Decimal
|
||||
import time
|
||||
import numpy as np
|
||||
import json
|
||||
import os
|
||||
os.chdir(Path(__file__).parent)
|
||||
|
||||
|
||||
def replace_decimals(obj):
|
||||
|
||||
@@ -54,8 +54,8 @@ class UpdateNGVData:
|
||||
timestamp = time.time()
|
||||
|
||||
|
||||
# data_NGV_j.to_csv(os.path.join(output_dir, f"{timestamp}up_NGV_j.csv"))
|
||||
# data_NGV_j1.to_csv(os.path.join(output_dir, f"{timestamp}up_NGV_j1.csv"))
|
||||
data_NGV_j.to_csv(os.path.join(output_dir, f"up_NGV_j.csv"))
|
||||
data_NGV_j1.to_csv(os.path.join(output_dir, f"up_NGV_j1.csv"))
|
||||
|
||||
# 找出在 data_NGV_j 中存在但在 data_NGV_j1 中不存在的 data_id
|
||||
unique_data_ids = data_NGV_j[~data_NGV_j['org_code'].isin(data_NGV_j1['org_code'])]
|
||||
@@ -111,9 +111,11 @@ class UpdateNGVData:
|
||||
logger.info(f"人员转换完成")
|
||||
|
||||
# 数字保留3位小数
|
||||
filtered_df['g_month_percentage'] = (pd.to_numeric(data_NGV_j['g_month_percentage'], errors='coerce')
|
||||
.round(3)
|
||||
.apply(lambda x: f"{x:.3f}" if pd.notna(x) else ''))
|
||||
filtered_df['g_month_percentage'] = (
|
||||
pd.to_numeric(filtered_df['g_month_percentage'], errors='coerce')
|
||||
.round(3)
|
||||
.apply(lambda x: f"{x:.3f}" if pd.notna(x) else '')
|
||||
)
|
||||
|
||||
# filtered_df.to_csv(r"D:\Idea Project\SaaS_V1.3\back_ground_module\output\NGV.csv")
|
||||
|
||||
@@ -138,17 +140,18 @@ class UpdateNGVData:
|
||||
# print(result_str[:500])
|
||||
|
||||
# 保存到Excel文件
|
||||
# output_path = r'D:\Idea Project\F6+宜搭+其它(1)\new\文件输出\ngv明细1.xlsx'
|
||||
# output_path = r'D:\Idea Project\SaaS_V1.7\back_ground_module\output\ngv明细1.xlsx'
|
||||
# filtered_df.to_excel(output_path, index=False)
|
||||
# data_NGV_j1.to_excel( r'D:\Idea Project\F6+宜搭+其它(1)\new\文件输出\ngv明细j1.xlsx', index=False)
|
||||
# data_NGV_j.to_excel( r'D:\Idea Project\F6+宜搭+其它(1)\new\文件输出\ngv明细j.xlsx', index=False)
|
||||
# new_df.to_excel(r'D:\Idea Project\F6+宜搭+其它(1)\new\文件输出\ngv明细ndf.xlsx', index=False)
|
||||
# data_NGV_j1.to_excel( r'D:\Idea Project\SaaS_V1.7\back_ground_module\output\ngv明细j1.xlsx', index=False)
|
||||
# data_NGV_j.to_excel( r'D:\Idea Project\SaaS_V1.7\back_ground_module\output\ngv明细j.xlsx', index=False)
|
||||
# new_df.to_excel(r'D:\Idea Project\SaaS_V1.7\back_ground_module\output\ngv明细ndf.xlsx', index=False)
|
||||
|
||||
common_module.send_task_status(task_start_time, "NGV新增数据")
|
||||
logger.info(f"任务完成。")
|
||||
except Exception as e:
|
||||
error_task_logger.error(f"任务执行时发生异常: {e}")
|
||||
common_module.send_task_error(task_start_time, "NGV新增数据", str(e))
|
||||
# pass
|
||||
|
||||
@staticmethod
|
||||
def row_to_dict(row, field_mapping):
|
||||
|
||||
@@ -88,10 +88,6 @@ class MoleculeReportingAdjustment:
|
||||
if id_in_map == field_id:
|
||||
transformed_data[display_name] = value
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
# BI上已经实现
|
||||
# if transformed_data.get("是否上传衡石") == "否" or transformed_data.get("是否上传衡石") is None:
|
||||
# continue
|
||||
|
||||
Reference in New Issue
Block a user