feat: 新增物料/入库单实时 CLIP 向量提取(新建+更新),修复 I/O 延迟和路径解析静默失败
This commit is contained in:
@ -12,6 +12,7 @@ import traceback
|
||||
import json
|
||||
import io
|
||||
import datetime
|
||||
from app.utils.ai_vision import extract_and_embed
|
||||
# 需要 pip install openpyxl
|
||||
from openpyxl import Workbook
|
||||
from openpyxl.styles import Font, Alignment, Border, Side, PatternFill
|
||||
@ -555,7 +556,9 @@ class MaterialBaseService:
|
||||
product_image=json.dumps(data.get('generalImage', [])),
|
||||
is_enabled=is_enabled_val
|
||||
)
|
||||
|
||||
# 实时提取产品图向量(失败不影响业务)
|
||||
if new_material.product_image:
|
||||
new_material.img_embedding = extract_and_embed(new_material.product_image)
|
||||
db.session.add(new_material)
|
||||
db.session.commit()
|
||||
return new_material
|
||||
@ -587,6 +590,10 @@ class MaterialBaseService:
|
||||
if 'generalImage' in data:
|
||||
material.product_image = json.dumps(data['generalImage'])
|
||||
|
||||
# 补上这两行:提取新上传图片的向量!
|
||||
if material.product_image:
|
||||
material.img_embedding = extract_and_embed(material.product_image)
|
||||
|
||||
# 【核心修改】:兼容前端传来的布尔值
|
||||
if 'isEnabled' in data:
|
||||
raw_enabled = data['isEnabled']
|
||||
|
||||
@ -9,6 +9,7 @@ from sqlalchemy import or_, func, text, and_
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
import traceback
|
||||
import json
|
||||
from app.utils.ai_vision import extract_and_embed
|
||||
|
||||
|
||||
class BuyInboundService:
|
||||
@ -177,6 +178,9 @@ class BuyInboundService:
|
||||
arrival_photo=json.dumps(data.get('arrival_photo', [])),
|
||||
inspection_report=json.dumps(data.get('inspection_report', []))
|
||||
)
|
||||
# 实时提取到货图片向量(失败不影响业务)
|
||||
if new_stock.arrival_photo:
|
||||
new_stock.arrival_image_embedding = extract_and_embed(new_stock.arrival_photo)
|
||||
db.session.add(new_stock)
|
||||
db.session.commit()
|
||||
return new_stock
|
||||
|
||||
@ -9,6 +9,7 @@ from sqlalchemy import or_, func, text, and_
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
import traceback
|
||||
import json
|
||||
from app.utils.ai_vision import extract_and_embed
|
||||
|
||||
|
||||
class ProductInboundService:
|
||||
@ -183,6 +184,9 @@ class ProductInboundService:
|
||||
sale_price=float(data.get('sale_price') or 0),
|
||||
order_id=data.get('order_id')
|
||||
)
|
||||
# 实时提取成品实拍图向量(失败不影响业务)
|
||||
if new_stock.product_photo:
|
||||
new_stock.arrival_image_embedding = extract_and_embed(new_stock.product_photo)
|
||||
db.session.add(new_stock)
|
||||
db.session.commit()
|
||||
return new_stock
|
||||
|
||||
@ -9,6 +9,7 @@ from sqlalchemy import or_, func, text, and_
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
import traceback
|
||||
import json
|
||||
from app.utils.ai_vision import extract_and_embed
|
||||
|
||||
|
||||
class SemiInboundService:
|
||||
@ -220,6 +221,9 @@ class SemiInboundService:
|
||||
detail_link=data.get('detail_link'),
|
||||
remark=data.get('remark')
|
||||
)
|
||||
# 实时提取到货图片向量(失败不影响业务)
|
||||
if new_stock.arrival_photo:
|
||||
new_stock.arrival_image_embedding = extract_and_embed(new_stock.arrival_photo)
|
||||
db.session.add(new_stock)
|
||||
db.session.commit()
|
||||
return new_stock
|
||||
|
||||
Reference in New Issue
Block a user