VPN IP로 약국 검색 API 추가 + Phase 3 기존 약국 감지 수정
- farmq-admin: GET /api/pharmacy/search?vpn_ip= 엔드포인트 추가 - pharmacy_devices + pharmacies 테이블 모두 검색 - 스크립트: 기존 복잡한 Python 파싱 → 단순 API 호출로 변경 - PVE IP, CT IP 둘 다 검색 가능 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -299,32 +299,15 @@ phase3_collect_info() {
|
|||||||
local EXISTING_PHARMACY=""
|
local EXISTING_PHARMACY=""
|
||||||
if [ -n "$PVE_VPN_IP" ]; then
|
if [ -n "$PVE_VPN_IP" ]; then
|
||||||
print_step "등록된 약국 조회 중... (VPN IP: $PVE_VPN_IP)"
|
print_step "등록된 약국 조회 중... (VPN IP: $PVE_VPN_IP)"
|
||||||
EXISTING_PHARMACY=$(curl -s --connect-timeout 5 "${FARMQ_API}/api/pharmacies" 2>/dev/null | \
|
EXISTING_PHARMACY=$(curl -s --connect-timeout 5 "${FARMQ_API}/api/pharmacy/search?vpn_ip=${PVE_VPN_IP}" 2>/dev/null || true)
|
||||||
python3 -c "
|
|
||||||
import json, sys
|
|
||||||
try:
|
|
||||||
data = json.load(sys.stdin)
|
|
||||||
pharmacies = data.get('pharmacies', data) if isinstance(data, dict) else data
|
|
||||||
if isinstance(pharmacies, list):
|
|
||||||
for p in pharmacies:
|
|
||||||
devices = p.get('devices', [])
|
|
||||||
for d in devices:
|
|
||||||
if d.get('tailscale_ip') == '$PVE_VPN_IP':
|
|
||||||
print(json.dumps(p, ensure_ascii=False))
|
|
||||||
sys.exit(0)
|
|
||||||
if p.get('tailscale_ip') == '$PVE_VPN_IP':
|
|
||||||
print(json.dumps(p, ensure_ascii=False))
|
|
||||||
sys.exit(0)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
" 2>/dev/null || true)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$EXISTING_PHARMACY" ]; then
|
# success:true 인지 확인
|
||||||
|
if echo "$EXISTING_PHARMACY" | grep -q '"success": true\|"success":true' 2>/dev/null; then
|
||||||
# 기존 약국 정보 로드
|
# 기존 약국 정보 로드
|
||||||
local EXIST_NAME EXIST_CODE
|
local EXIST_NAME EXIST_CODE
|
||||||
EXIST_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('pharmacy_name',''))" 2>/dev/null || true)
|
EXIST_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy']['pharmacy_name'])" 2>/dev/null || true)
|
||||||
EXIST_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('pharmacy_code',''))" 2>/dev/null || true)
|
EXIST_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy']['pharmacy_code'])" 2>/dev/null || true)
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${GREEN}이 PVE에 등록된 약국을 찾았습니다:${NC}"
|
echo -e "${GREEN}이 PVE에 등록된 약국을 찾았습니다:${NC}"
|
||||||
@@ -337,10 +320,10 @@ except:
|
|||||||
if [[ -z "${USE_EXISTING:-}" ]] || [[ "${USE_EXISTING}" =~ ^[Yy]$ ]]; then
|
if [[ -z "${USE_EXISTING:-}" ]] || [[ "${USE_EXISTING}" =~ ^[Yy]$ ]]; then
|
||||||
PHARMACY_NAME="$EXIST_NAME"
|
PHARMACY_NAME="$EXIST_NAME"
|
||||||
PHARMACY_CODE="$EXIST_CODE"
|
PHARMACY_CODE="$EXIST_CODE"
|
||||||
HIRA_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('institution_code','') or '')" 2>/dev/null || true)
|
HIRA_CODE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('institution_code','') or '')" 2>/dev/null || true)
|
||||||
PHARMACY_ADDRESS=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('address','') or '')" 2>/dev/null || true)
|
PHARMACY_ADDRESS=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('address','') or '')" 2>/dev/null || true)
|
||||||
OWNER_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('owner_name','') or '')" 2>/dev/null || true)
|
OWNER_NAME=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('owner_name','') or '')" 2>/dev/null || true)
|
||||||
PHARMACY_PHONE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('phone','') or '')" 2>/dev/null || true)
|
PHARMACY_PHONE=$(echo "$EXISTING_PHARMACY" | python3 -c "import json,sys; print(json.load(sys.stdin)['pharmacy'].get('phone','') or '')" 2>/dev/null || true)
|
||||||
MSSQL_SERVER="${ARGS_MSSQL:-192.168.0.201\\PM2014}"
|
MSSQL_SERVER="${ARGS_MSSQL:-192.168.0.201\\PM2014}"
|
||||||
print_ok "기존 약국 정보 로드됨: $PHARMACY_CODE ($PHARMACY_NAME)"
|
print_ok "기존 약국 정보 로드됨: $PHARMACY_CODE ($PHARMACY_NAME)"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user