feat: AI 기반 제품 카테고리 자동 태깅 및 UI 표시
- OpenAI GPT-4o-mini로 31개 제품 자동 분류 (100% 커버리지) - 관리자 페이지 사용자 상세 모달에 카테고리 뱃지 추가 - BARCODE 기반 제품-카테고리 매핑 (many-to-many) - 카테고리별 색상 구분 (10가지 그라디언트 디자인) - 제품 수동 분류 도구 추가 (update_product_category.py) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -818,9 +818,10 @@ def admin_user_detail(user_id):
|
||||
else:
|
||||
transaction_date = '-'
|
||||
|
||||
# SALE_SUB + CD_GOODS JOIN
|
||||
# SALE_SUB + CD_GOODS JOIN (BARCODE 추가)
|
||||
sale_items_query = text("""
|
||||
SELECT
|
||||
S.BARCODE,
|
||||
S.DrugCode,
|
||||
ISNULL(G.GoodsName, '(약품명 없음)') AS goods_name,
|
||||
S.SL_NM_item AS quantity,
|
||||
@@ -837,17 +838,36 @@ def admin_user_detail(user_id):
|
||||
{'transaction_id': transaction_id}
|
||||
).fetchall()
|
||||
|
||||
# 상품 리스트 변환
|
||||
items = [
|
||||
{
|
||||
# 상품 리스트 변환 (카테고리 포함)
|
||||
items = []
|
||||
for item in items_raw:
|
||||
barcode = item.BARCODE
|
||||
|
||||
# SQLite에서 제품 카테고리 조회
|
||||
categories = []
|
||||
if barcode:
|
||||
cursor.execute("""
|
||||
SELECT category_name, relevance_score
|
||||
FROM product_category_mapping
|
||||
WHERE barcode = ?
|
||||
ORDER BY relevance_score DESC
|
||||
""", (barcode,))
|
||||
|
||||
for cat_row in cursor.fetchall():
|
||||
categories.append({
|
||||
'name': cat_row[0],
|
||||
'score': cat_row[1]
|
||||
})
|
||||
|
||||
items.append({
|
||||
'code': item.DrugCode,
|
||||
'barcode': barcode,
|
||||
'name': item.goods_name,
|
||||
'qty': int(item.quantity or 0),
|
||||
'price': int(item.price or 0),
|
||||
'total': int(item.total or 0)
|
||||
}
|
||||
for item in items_raw
|
||||
]
|
||||
'total': int(item.total or 0),
|
||||
'categories': categories
|
||||
})
|
||||
|
||||
# 상품 요약 생성 ("첫번째상품명 외 N개")
|
||||
if items:
|
||||
|
||||
Reference in New Issue
Block a user