feat: APC 없을 때 바코드로 PostgreSQL RAG 조회
This commit is contained in:
parent
8b58ab0d3a
commit
b1d5bcfc98
@ -2737,10 +2737,15 @@ def _get_animal_drug_rag(apc_codes):
|
|||||||
|
|
||||||
|
|
||||||
def _get_animal_drugs():
|
def _get_animal_drugs():
|
||||||
"""보유 중인 동물약 목록 조회 (APC 이미지 포함)"""
|
"""보유 중인 동물약 목록 조회 (APC 이미지 포함)
|
||||||
|
|
||||||
|
APC 우선순위:
|
||||||
|
1. CD_ITEM_UNIT_MEMBER에서 023%로 시작하는 APC 코드
|
||||||
|
2. 없으면 기존 BARCODE를 PostgreSQL에서 조회 (바코드=APC인 경우)
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
drug_session = db_manager.get_session('PM_DRUG')
|
drug_session = db_manager.get_session('PM_DRUG')
|
||||||
# CD_ITEM_UNIT_MEMBER에서 APC 바코드 조회 (0230237로 시작하는 것)
|
# CD_ITEM_UNIT_MEMBER에서 APC 바코드 조회 (023%로 시작하는 것)
|
||||||
query = text("""
|
query = text("""
|
||||||
SELECT
|
SELECT
|
||||||
G.DrugCode,
|
G.DrugCode,
|
||||||
@ -2764,16 +2769,22 @@ def _get_animal_drugs():
|
|||||||
result = []
|
result = []
|
||||||
for r in rows:
|
for r in rows:
|
||||||
apc = r.APC_CODE if hasattr(r, 'APC_CODE') else None
|
apc = r.APC_CODE if hasattr(r, 'APC_CODE') else None
|
||||||
|
barcode = r.BARCODE or ''
|
||||||
image_url = None
|
image_url = None
|
||||||
if apc:
|
|
||||||
# APC가 있으면 이미지 URL 생성
|
# APC가 없으면 바코드를 APC로 사용 (PostgreSQL에서 바코드=APC인 경우)
|
||||||
|
if not apc and barcode:
|
||||||
|
apc = barcode
|
||||||
|
|
||||||
|
if apc and apc.startswith('023'):
|
||||||
|
# 023으로 시작하는 APC만 이미지 URL 생성
|
||||||
image_url = f"https://ani.0bin.in/img/{apc}_F.jpg"
|
image_url = f"https://ani.0bin.in/img/{apc}_F.jpg"
|
||||||
|
|
||||||
result.append({
|
result.append({
|
||||||
'code': r.DrugCode,
|
'code': r.DrugCode,
|
||||||
'name': r.GoodsName,
|
'name': r.GoodsName,
|
||||||
'price': float(r.Saleprice) if r.Saleprice else 0,
|
'price': float(r.Saleprice) if r.Saleprice else 0,
|
||||||
'barcode': r.BARCODE or '',
|
'barcode': barcode,
|
||||||
'apc': apc,
|
'apc': apc,
|
||||||
'image_url': image_url
|
'image_url': image_url
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user