You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""
|
|
Quick script to see distinct FMEA equipment names and equipment_tags
|
|
so we can plan the matching strategy against PFI equipment names.
|
|
"""
|
|
import asyncio
|
|
import os, sys
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from sqlalchemy import text
|
|
from src.database.core import async_session
|
|
|
|
async def main():
|
|
session = async_session()
|
|
try:
|
|
# Get distinct equipment names
|
|
result = await session.execute(text(
|
|
"SELECT DISTINCT equipment FROM fmea_record ORDER BY equipment"
|
|
))
|
|
equipments = [r[0] for r in result.all()]
|
|
|
|
# Get distinct equipment tags
|
|
result2 = await session.execute(text(
|
|
"SELECT DISTINCT equipment_tag FROM fmea_record WHERE equipment_tag IS NOT NULL AND equipment_tag != '' ORDER BY equipment_tag"
|
|
))
|
|
tags = [r[0] for r in result2.all()]
|
|
|
|
print("=" * 60)
|
|
print(f"FMEA Equipment Names ({len(equipments)} distinct):")
|
|
print("=" * 60)
|
|
for eq in equipments:
|
|
print(f" - {eq}")
|
|
|
|
print()
|
|
print("=" * 60)
|
|
print(f"FMEA Equipment Tags ({len(tags)} distinct):")
|
|
print("=" * 60)
|
|
for t in tags[:30]:
|
|
print(f" - {t}")
|
|
if len(tags) > 30:
|
|
print(f" ... and {len(tags) - 30} more")
|
|
|
|
# Check equipment + tag mapping
|
|
result3 = await session.execute(text(
|
|
"SELECT DISTINCT equipment, equipment_tag FROM fmea_record WHERE equipment_tag IS NOT NULL AND equipment_tag != '' ORDER BY equipment, equipment_tag LIMIT 40"
|
|
))
|
|
mappings = result3.all()
|
|
print()
|
|
print("=" * 60)
|
|
print(f"FMEA Equipment -> Tag Mapping (sample):")
|
|
print("=" * 60)
|
|
for eq, tag in mappings:
|
|
print(f" {eq:40s} | {tag}")
|
|
|
|
finally:
|
|
await session.close()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|