fix: D(도즈) 단위는 boxes=units로 처리 (나잘스프레이 등)

This commit is contained in:
thug0bin 2026-03-07 17:49:03 +09:00
parent dc2a992c12
commit 0f69b50c49
3 changed files with 65 additions and 6 deletions

31
backend/check_raninex.py Normal file
View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
import requests
# 지오영 확인
geo = requests.get('http://localhost:7001/api/geoyoung/orders/summary-by-kd?start_date=2026-03-07&end_date=2026-03-07', timeout=120).json()
print("=== 지오영 ===")
for kd, info in geo.get('by_kd_code', {}).items():
if '라니넥스' in info['product_name'] or '나잘' in info['product_name']:
print(f" KD: {kd}")
print(f" product_name: {info['product_name']}")
print(f" spec: {info['spec']}")
print(f" boxes: {info['boxes']}")
print(f" units: {info['units']}")
print()
# 수인 확인
sooin = requests.get('http://localhost:7001/api/sooin/orders/summary-by-kd?start_date=2026-03-07&end_date=2026-03-07', timeout=120).json()
print("=== 수인약품 ===")
found = False
for kd, info in sooin.get('by_kd_code', {}).items():
if '라니넥스' in info['product_name'] or '나잘' in info['product_name']:
print(f" KD: {kd}")
print(f" product_name: {info['product_name']}")
print(f" spec: {info['spec']}")
print(f" boxes: {info['boxes']}")
print(f" units: {info['units']}")
found = True
print()
if not found:
print(" (없음)")

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
import requests
# 스틸녹스 검색해서 spec 필드 확인
res = requests.get('http://localhost:7001/api/geoyoung/stock?keyword=스틸녹스', timeout=30)
data = res.json()
print("=== 지오영 제품 검색 결과 ===")
for item in data.get('items', [])[:3]:
print(f" product_name: {item.get('product_name')}")
print(f" specification: {item.get('specification')}")
print(f" stock: {item.get('stock')}")
print()
# 수인도 확인
res2 = requests.get('http://localhost:7001/api/sooin/stock?keyword=스틸녹스', timeout=30)
data2 = res2.json()
print("=== 수인 제품 검색 결과 ===")
for item in data2.get('items', [])[:3]:
print(f" name: {item.get('name')}")
print(f" spec: {item.get('spec')}")
print(f" stock: {item.get('stock')}")
print()

View File

@ -600,15 +600,19 @@ def api_geoyoung_orders_by_kd():
"""
규격에서 수량 추출 (30T 30, 100C 100)
우선순위:
1. spec에서 T/C/P/D 단위 숫자 (: 14T 14)
2. product_name에서 T/C/P/D 단위 숫자
3. spec의 번째 숫자 (fallback)
단위 처리:
- T/C/P: /캡슐/ 숫자 그대로 (30T 30)
- D: 도즈/분사 1 처리 (140D 1, 박스 단위)
- mg/ml/g: 용량 1 처리
"""
combined = f"{spec} {product_name}"
# T/C/P/D 단위가 붙은 숫자 우선 추출 (예: 14T, 100C, 30P, 140D)
qty_match = re.search(r'(\d+)\s*[TCPD]\b', combined, re.IGNORECASE)
# D(도즈) 단위는 박스 단위로 계산 (140D → 1)
if re.search(r'\d+\s*D\b', combined, re.IGNORECASE):
return 1
# T/C/P 단위가 붙은 숫자 추출 (예: 14T, 100C, 30P)
qty_match = re.search(r'(\d+)\s*[TCP]\b', combined, re.IGNORECASE)
if qty_match:
return int(qty_match.group(1))