fix aud search on center
This commit is contained in:
11
backend/.claude/settings.local.json
Normal file
11
backend/.claude/settings.local.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(.venvScriptsactivate)",
|
||||
"Bash(python:*)",
|
||||
"Bash(venv/Scripts/python.exe:*)",
|
||||
"Bash(timeout 5 tail:*)",
|
||||
"Bash(curl:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ from backend.routers.rashodniki import consumables
|
||||
from backend.routers.zametki import zametki
|
||||
from backend.routers.auth import auth
|
||||
from backend.routers.owners import owners
|
||||
from backend.routers.inspections import inspections
|
||||
|
||||
|
||||
|
||||
@@ -32,8 +33,7 @@ def ping():
|
||||
return {"message": "pong"}
|
||||
|
||||
|
||||
# Serve static assets and frontend
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
# Serve frontend
|
||||
app.mount("/app", StaticFiles(directory="frontend", html=True), name="frontend")
|
||||
|
||||
@app.get("/")
|
||||
@@ -46,11 +46,12 @@ def login_page():
|
||||
|
||||
|
||||
# Подключение роутов
|
||||
app.include_router(equipment_types)
|
||||
app.include_router(auditories)
|
||||
app.include_router(oboruds)
|
||||
app.include_router(equipment_types)
|
||||
app.include_router(auditories)
|
||||
app.include_router(oboruds)
|
||||
app.include_router(components)
|
||||
app.include_router(consumables)
|
||||
app.include_router(zametki)
|
||||
app.include_router(auth)
|
||||
app.include_router(owners)
|
||||
app.include_router(inspections)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# backend/models.py
|
||||
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, UniqueConstraint
|
||||
from sqlalchemy.orm import relationship, declarative_base
|
||||
import datetime
|
||||
|
||||
@@ -98,3 +98,47 @@ class Zametki(Base):
|
||||
txtzam = Column(String(10000))
|
||||
created_date = Column(DateTime, default=datetime.datetime.utcnow)
|
||||
rmdt = Column(DateTime)
|
||||
|
||||
|
||||
class InspectionSession(Base):
|
||||
__tablename__ = 'inspection_sessions'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
started_at = Column(DateTime, nullable=False)
|
||||
completed_at = Column(DateTime, nullable=True)
|
||||
aud_id = Column(Integer, ForeignKey("auditories.id"), nullable=True) # null = всё подряд
|
||||
|
||||
# Relationships
|
||||
user = relationship("User")
|
||||
auditory = relationship("Auditory")
|
||||
records = relationship("InspectionRecord", back_populates="session")
|
||||
unknown_barcodes = relationship("UnknownBarcode", back_populates="session")
|
||||
|
||||
|
||||
class InspectionRecord(Base):
|
||||
__tablename__ = 'inspection_records'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
session_id = Column(Integer, ForeignKey("inspection_sessions.id"), nullable=False)
|
||||
oborud_id = Column(Integer, ForeignKey("oboruds.id"), nullable=False)
|
||||
checked_at = Column(DateTime, nullable=False) # обновляется при повторном сканировании
|
||||
|
||||
# Relationships
|
||||
session = relationship("InspectionSession", back_populates="records")
|
||||
oborud = relationship("Oboruds")
|
||||
|
||||
# Уникальное ограничение: одна запись на оборудование в рамках сессии
|
||||
__table_args__ = (UniqueConstraint('session_id', 'oborud_id', name='_session_oborud_uc'),)
|
||||
|
||||
|
||||
class UnknownBarcode(Base):
|
||||
__tablename__ = 'unknown_barcodes'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
session_id = Column(Integer, ForeignKey("inspection_sessions.id"), nullable=False)
|
||||
barcode = Column(String(100), nullable=False)
|
||||
scanned_at = Column(DateTime, nullable=False)
|
||||
|
||||
# Relationships
|
||||
session = relationship("InspectionSession", back_populates="unknown_barcodes")
|
||||
|
||||
@@ -16,7 +16,7 @@ class EquipmentTypeRead(EquipmentTypeBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# === Component ===
|
||||
@@ -31,7 +31,7 @@ class ComponentRead(ComponentBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# === Consumable ===
|
||||
@@ -46,7 +46,7 @@ class ConsumableRead(ConsumableBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# === Owner ===
|
||||
@@ -60,7 +60,7 @@ class OwnerRead(OwnerBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# === Oborud ===
|
||||
@@ -95,7 +95,7 @@ class OborudRead(OborudBase):
|
||||
consumables: List[ConsumableRead] = []
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# === Auditory ===
|
||||
@@ -109,7 +109,7 @@ class AuditoryRead(AuditoryBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# === Zametka ===
|
||||
@@ -125,7 +125,7 @@ class ZametkaRead(ZametkaBase):
|
||||
created_date: Optional[datetime] = None
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# === Auth/User ===
|
||||
@@ -151,8 +151,67 @@ class UserRead(UserBase):
|
||||
id: int
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class UserRoleUpdate(BaseModel):
|
||||
role: Role
|
||||
|
||||
|
||||
# === Inspection System ===
|
||||
|
||||
# InspectionSession
|
||||
class InspectionSessionBase(BaseModel):
|
||||
aud_id: Optional[int] = None
|
||||
|
||||
class InspectionSessionCreate(InspectionSessionBase):
|
||||
pass
|
||||
|
||||
class InspectionSessionRead(InspectionSessionBase):
|
||||
id: int
|
||||
user_id: int
|
||||
started_at: datetime
|
||||
completed_at: Optional[datetime] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
# InspectionRecord
|
||||
class InspectionRecordRead(BaseModel):
|
||||
id: int
|
||||
session_id: int
|
||||
oborud_id: int
|
||||
checked_at: datetime
|
||||
oborud: Optional[OborudRead] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
# UnknownBarcode
|
||||
class UnknownBarcodeRead(BaseModel):
|
||||
id: int
|
||||
session_id: int
|
||||
barcode: str
|
||||
scanned_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
# Ответ на сканирование
|
||||
class CheckBarcodeResponse(BaseModel):
|
||||
status: Literal["found", "not_found"]
|
||||
equipment: Optional[OborudRead] = None
|
||||
message: str
|
||||
|
||||
# Статистика сессии
|
||||
class InspectionSessionStats(BaseModel):
|
||||
session: InspectionSessionRead
|
||||
total_expected: int # всего оборудования (в аудитории или всего)
|
||||
total_checked: int # проверено уникальных позиций
|
||||
total_unknown: int # неизвестных штрихкодов
|
||||
progress_percent: float
|
||||
|
||||
# Детальный отчёт
|
||||
class InspectionDetailReport(BaseModel):
|
||||
records: List[InspectionRecordRead]
|
||||
unknown_barcodes: List[UnknownBarcodeRead]
|
||||
|
||||
Reference in New Issue
Block a user