You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.3 KiB

1 year ago
from Util.PgUtil import *
# 系统用户ID
SYSTEM_USER_ID = '16380C30-B1EA-4BFF-B5E6-4F3928CE36F3'
# 普通用户ID
NORMAL_USER_ID = 'ca3e280e-12f0-33ff-c92e-4d56724b0fa1'
USERS = [SYSTEM_USER_ID, NORMAL_USER_ID]
for USER in USERS:
# 当前处理哪个用户的文件
user_id = USER
# 获取所有生成的文件获取到task_id然后修改task_id
sql = "select t1.id,t1.task_id,t2.model_id from t_hy_task_files as t1 inner join t_hy_task as t2 on t1.task_id=t2.task_id where t2.user_id='%s'" % (
user_id)
results = execute_query(sql)
for row in results:
# 获取这个model_id+这个用户最小的任务编号是多少,然后把当前的数据修改为那个任务编号
sql = "select task_id from t_hy_task where model_id=%s and user_id='%s' limit 1" % (row[2], user_id)
res = execute_query(sql)
if res:
task_id = res[0][0]
sql = "update t_hy_task_files set task_id=%s where id=%s" % (task_id, row[0])
execute_modify(sql)
print("成功修改了一个数据")
# 删除表中没有生成过文件的任务
sql = "delete from t_hy_task where task_id not in (select task_id from t_hy_task_files)"
execute_modify(sql)
# 清理完毕
print("清理完毕")