优化及bug修改
This commit is contained in:
1 parent
5467bbc232
commit
f4254f0051
9 files changed
+265
-38
No files matched your search
+29
-3
@@ -39,9 +39,6 @@ def add_task(data):
|
||||
#判断是否是昆山教学的,是的话优先级设置为默认
|
||||
if data["psid"] == '85':
|
||||
sql = f'insert into tasks (task_type, task_key,studio_id) values ("{data["task_type"]}", "{data["task_key"]}","{data["psid"]}")'
|
||||
elif data["psid"] == '1':
|
||||
#实验室的订单走分布式处理
|
||||
sql = f'insert into task_distributed (task_type, task_key, priority,created_at,studio_id) values ("{data["task_type"]}", "{data["task_key"]}", 1,"{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}","{data["psid"]}")'
|
||||
else:
|
||||
sql = f'insert into tasks (task_type, task_key, priority,studio_id) values ("{data["task_type"]}", "{data["task_key"]}", 1,"{data["psid"]}")'
|
||||
# print(f'sql: {sql}')
|
||||
@@ -50,6 +47,18 @@ def add_task(data):
|
||||
except Exception as e:
|
||||
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行add_task({data})异常: {str(e)}")
|
||||
|
||||
#新增任务到分布式处理任务表中 {"task_type":key,"task_key":pid,"psid":psid}
|
||||
def add_task_distributed(data):
|
||||
try:
|
||||
with pymysqlAlias() as conn:
|
||||
cursor = conn.cursor()
|
||||
sql = f'insert into task_distributed (task_type, task_key, priority,created_at,studio_id) values ("{data["task_type"]}", "{data["task_key"]}", "{data["priority"]}","{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}","{data["psid"]}")'
|
||||
cursor.execute(sql)
|
||||
conn.commit()
|
||||
except Exception as e:
|
||||
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行add_task_distributed({data})异常: {str(e)}")
|
||||
|
||||
|
||||
# 开始任务
|
||||
def start_task(data):
|
||||
try:
|
||||
@@ -130,6 +139,23 @@ def change_to_new_make_psid(psid):
|
||||
cursor.execute(sql)
|
||||
conn.commit()
|
||||
print(f'修改影棚{psid}为走新的建模系统')
|
||||
except Exception as e:
|
||||
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行change_to_new_make_psid()异常: {str(e)}")
|
||||
return "error"
|
||||
|
||||
|
||||
#判断影棚走分布式的建模系统 还是走原来的建模系统
|
||||
def isStudioConfigDistribute(psid):
|
||||
try:
|
||||
with pymysqlAlias() as conn:
|
||||
cursor = conn.cursor()
|
||||
sql = f'select count(*) from studio_config_distribute where studio_id = {psid}'
|
||||
cursor.execute(sql)
|
||||
result = cursor.fetchone()
|
||||
if result[0] == 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行change_to_new_make_psid()异常: {str(e)}")
|
||||
return "error"
|
||||
Reference in new issue
Block a user