54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
sys.path.insert(0, 'c:\\Users\\청춘약국\\source\\pharmacy-pos-qr-system\\backend')
|
|
|
|
from db.dbsetup import get_db_session
|
|
from sqlalchemy import text
|
|
|
|
session = get_db_session('PM_DRUG')
|
|
|
|
# 동물약(POS_BOON='010103')을 CD_BARCODE와 JOIN해서 BASECODE 찾기
|
|
print('=== 동물약 BASECODE 조회 (CD_GOODS + CD_BARCODE JOIN) ===\n')
|
|
|
|
result = session.execute(text("""
|
|
SELECT
|
|
g.DrugCode,
|
|
g.GoodsName,
|
|
g.BARCODE as goods_barcode,
|
|
b.BARCODE as std_barcode,
|
|
b.BASECODE,
|
|
b.SUNG_CODE,
|
|
b.DIK_CODE,
|
|
b.ETCNAME
|
|
FROM CD_GOODS g
|
|
LEFT JOIN CD_BARCODE b ON g.DrugCode = b.DRUGCODE
|
|
WHERE g.POS_BOON = '010103' AND g.GoodsSelCode = 'B'
|
|
ORDER BY g.GoodsName
|
|
"""))
|
|
|
|
found = 0
|
|
not_found = 0
|
|
|
|
for row in result:
|
|
if row.BASECODE:
|
|
found += 1
|
|
mark = '[O]'
|
|
else:
|
|
not_found += 1
|
|
mark = '[X]'
|
|
|
|
print(f'{mark} {row.GoodsName}')
|
|
print(f' DrugCode: {row.DrugCode}')
|
|
print(f' CD_GOODS.BARCODE: {row.goods_barcode or "(없음)"}')
|
|
if row.BASECODE:
|
|
print(f' CD_BARCODE.BARCODE: {row.std_barcode}')
|
|
print(f' BASECODE: {row.BASECODE}')
|
|
print(f' SUNG_CODE: {row.SUNG_CODE}')
|
|
print()
|
|
|
|
print('---')
|
|
print(f'CD_BARCODE에서 찾음: {found}개')
|
|
print(f'CD_BARCODE에 없음: {not_found}개')
|
|
|
|
session.close()
|