校验唯一任务添加时间
优化续约代办请求次数
This commit is contained in:
+35
-7
@@ -572,10 +572,35 @@ class YDToJDYRenewalToDo(object):
|
||||
print(f"获取流程实例数据时出错: {e}")
|
||||
continue
|
||||
|
||||
df = pd.DataFrame(all_process_list)
|
||||
df.to_csv(f"{output_dir}/{start_time}_{end_time}_all_process_list.csv", index=False)
|
||||
df_current = pd.DataFrame(all_process_list)
|
||||
current_file = f"{output_dir}/{start_time}_{end_time}_all_process_list.csv"
|
||||
|
||||
return all_process_list
|
||||
# === 新增:读取上次文件并计算差值 ===
|
||||
if os.path.exists(current_file):
|
||||
try:
|
||||
df_last = pd.read_csv(current_file)
|
||||
except Exception as e:
|
||||
print(f"读取历史文件失败: {e}")
|
||||
df_last = pd.DataFrame()
|
||||
else:
|
||||
df_last = pd.DataFrame()
|
||||
|
||||
# 假设唯一标识字段为 'instanceId',请根据实际字段名调整
|
||||
id_col = 'processInstanceId'
|
||||
if not df_last.empty and not df_current.empty and id_col in df_current.columns and id_col in df_last.columns:
|
||||
# 转为字符串确保可比
|
||||
last_ids = set(df_last[id_col].astype(str))
|
||||
current_ids = set(df_current[id_col].astype(str))
|
||||
new_ids = current_ids - last_ids
|
||||
diff_records = df_current[df_current[id_col].astype(str).isin(new_ids)].to_dict('records')
|
||||
else:
|
||||
# 没有历史文件 或 无唯一ID → 返回空 list(按你要求)
|
||||
diff_records = []
|
||||
|
||||
# 保存当前全量数据(覆盖)
|
||||
df_current.to_csv(current_file, index=False)
|
||||
|
||||
return diff_records
|
||||
|
||||
def filter_renewal_data(self, all_process_list):
|
||||
update_data_list = []
|
||||
@@ -680,10 +705,13 @@ class YDToJDYRenewalToDo(object):
|
||||
try:
|
||||
# step1 获取简道云与宜搭数据
|
||||
jd_ydy_data = self.load_all_data()
|
||||
# step2 过滤已经续约的单子
|
||||
update_data_list = self.filter_renewal_data(jd_ydy_data)
|
||||
# step3 校验简道云是否有进行中的单子并关闭
|
||||
self.check_jd_ydy_data(update_data_list)
|
||||
if jd_ydy_data:
|
||||
# step2 过滤已经续约的单子
|
||||
update_data_list = self.filter_renewal_data(jd_ydy_data)
|
||||
# step3 校验简道云是否有进行中的单子并关闭
|
||||
self.check_jd_ydy_data(update_data_list)
|
||||
else:
|
||||
print("本次执行无处理数据")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user