fix: 审计日志跳过向量字段,修复 numpy 数组比较异常;补全三大入库单更新向量提取,统一删除确认弹窗
This commit is contained in:
@ -142,6 +142,7 @@ def before_update_listener(mapper, connection, target):
|
||||
changes = {}
|
||||
for attr in state.attrs:
|
||||
if attr.key in IGNORE_FIELDS: continue
|
||||
if 'embedding' in attr.key: continue
|
||||
if attr.history.has_changes():
|
||||
old_val = attr.history.deleted[0] if attr.history.deleted else None
|
||||
new_val = attr.history.added[0] if attr.history.added else None
|
||||
@ -164,6 +165,8 @@ def before_delete_listener(mapper, connection, target):
|
||||
state = inspect(target)
|
||||
snap = {}
|
||||
for attr in state.attrs:
|
||||
if attr.key in IGNORE_FIELDS: continue
|
||||
if 'embedding' in attr.key: continue
|
||||
val = getattr(target, attr.key, None)
|
||||
snap[attr.key] = _serialize_value(val)
|
||||
_create_audit_log(connection, mapper, target, 'delete', {'deleted_snapshot': snap})
|
||||
@ -180,6 +183,8 @@ def after_insert_listener(mapper, connection, target):
|
||||
state = inspect(target)
|
||||
snap = {}
|
||||
for attr in state.attrs:
|
||||
if attr.key in IGNORE_FIELDS: continue
|
||||
if 'embedding' in attr.key: continue
|
||||
val = getattr(target, attr.key, None)
|
||||
snap[attr.key] = _serialize_value(val)
|
||||
_create_audit_log(connection, mapper, target, 'insert', {'created': snap})
|
||||
|
||||
@ -245,6 +245,8 @@ class BuyInboundService:
|
||||
if k in data: setattr(stock, v, data[k])
|
||||
|
||||
if 'arrival_photo' in data: stock.arrival_photo = json.dumps(data['arrival_photo'])
|
||||
if 'arrival_photo' in data and stock.arrival_photo:
|
||||
stock.arrival_image_embedding = extract_and_embed(stock.arrival_photo)
|
||||
if 'inspection_report' in data: stock.inspection_report = json.dumps(data['inspection_report'])
|
||||
|
||||
# 更新税率
|
||||
|
||||
@ -219,6 +219,8 @@ class ProductInboundService:
|
||||
if 'product_photo' in data:
|
||||
imgs = data['product_photo']
|
||||
if isinstance(imgs, list): stock.product_photo = json.dumps(imgs)
|
||||
if stock.product_photo:
|
||||
stock.arrival_image_embedding = extract_and_embed(stock.product_photo)
|
||||
if 'quality_report_link' in data:
|
||||
imgs = data['quality_report_link']
|
||||
if isinstance(imgs, list): stock.quality_report_link = json.dumps(imgs)
|
||||
|
||||
@ -275,6 +275,8 @@ class SemiInboundService:
|
||||
imgs = data['arrival_photo']
|
||||
if isinstance(imgs, list):
|
||||
stock.arrival_photo = json.dumps(imgs)
|
||||
if stock.arrival_photo:
|
||||
stock.arrival_image_embedding = extract_and_embed(stock.arrival_photo)
|
||||
if 'quality_report_link' in data:
|
||||
imgs = data['quality_report_link']
|
||||
if isinstance(imgs, list):
|
||||
|
||||
Reference in New Issue
Block a user