feat: db_insert_mplogx 添加限制参数
This commit is contained in:
parent
a24666b795
commit
679165cbd0
|
@ -47,7 +47,7 @@ def db_insert_mplogx_batch(rows):
|
|||
insert_mplogx_item(tag_code, tag_val, make_aware(tag_update), {})
|
||||
|
||||
@shared_task(base=CustomTask)
|
||||
def db_insert_mplogx():
|
||||
def db_insert_mplogx(limit:bool=True):
|
||||
"""
|
||||
从数据库转存到超表
|
||||
"""
|
||||
|
@ -58,7 +58,7 @@ def db_insert_mplogx():
|
|||
raise Exception("last_tag_id is None")
|
||||
cursor.execute("select count(id) from tag_value where id > %s", (last_tag_id))
|
||||
count = cursor.fetchone()[0]
|
||||
if count > 400:
|
||||
if limit and count > 400:
|
||||
raise Exception("db inset count > 400")
|
||||
cursor.execute(
|
||||
"select id, val, tag_code, update_time from tag_value where id > %s order by id, update_time", (last_tag_id, ))
|
||||
|
@ -85,12 +85,11 @@ def db_ins_mplogx():
|
|||
# raise Exception("db inset count > 400")
|
||||
# materials_name = ['水泥+P.C42.5 袋装', '水泥+P.O42.5R 袋装', '水泥+P.O42.5 散装','水泥+P.O42.5 袋装', '水泥+P.O52.5 散装', '水泥+P.C42.5 散装', '水泥+P.O42.5R 散装']
|
||||
query = """
|
||||
SELECT id, CONCAT('x', inv_name) AS inv_name, de_real_quantity, bill_date
|
||||
SELECT id, de_real_quantity, CONCAT('x', inv_name) AS inv_name, bill_date
|
||||
FROM sa_weigh_view
|
||||
WHERE bill_date > %s
|
||||
ORDER BY id, bill_date
|
||||
"""
|
||||
# date_obj = datetime.datetime.strptime(bill_date, '%Y-%m-%d %H:%M:%S')
|
||||
cursor.execute(query, (bill_date,))
|
||||
rows = cursor.fetchall() # 获取数据后保存至本地
|
||||
if rows:
|
||||
|
|
Loading…
Reference in New Issue