- 목록 관리 페이지에 고급 필터링 시스템 추가 - 프로젝트별, 검토상태별, 날짜별 필터링 - 검토 완료/필요 항목 시각적 구분 및 정렬 - 해결 시간 입력 + 확인 버튼으로 검토 완료 처리 - 부적합 조회 페이지에 동일한 필터링 기능 적용 - 검토 상태에 따른 카드 스타일링 (음영 처리) - JavaScript 템플릿 리터럴 오류 수정 - 보고서 페이지 프로젝트별 분석 기능 추가 - 프로젝트 선택 드롭다운 추가 - 총 작업 공수를 프로젝트별 일일공수 데이터로 계산 - 부적합 처리 시간, 카테고리 분석, 상세 목록 모두 프로젝트별 필터링 - localStorage 키 이름 통일 (daily-work-data)
96 lines
3.5 KiB
Python
96 lines
3.5 KiB
Python
from sqlalchemy import Column, Integer, BigInteger, String, DateTime, Float, Boolean, Text, ForeignKey, Enum
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime, timezone, timedelta
|
|
import enum
|
|
|
|
# 한국 시간대 설정
|
|
KST = timezone(timedelta(hours=9))
|
|
|
|
def get_kst_now():
|
|
"""현재 한국 시간 반환"""
|
|
return datetime.now(KST)
|
|
|
|
Base = declarative_base()
|
|
|
|
class UserRole(str, enum.Enum):
|
|
admin = "admin"
|
|
user = "user"
|
|
|
|
class IssueStatus(str, enum.Enum):
|
|
new = "new"
|
|
progress = "progress"
|
|
complete = "complete"
|
|
|
|
class IssueCategory(str, enum.Enum):
|
|
material_missing = "material_missing"
|
|
design_error = "design_error" # 설계미스 (기존 dimension_defect 대체)
|
|
incoming_defect = "incoming_defect"
|
|
inspection_miss = "inspection_miss" # 검사미스 (신규 추가)
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
username = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
full_name = Column(String)
|
|
role = Column(Enum(UserRole), default=UserRole.user)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, default=get_kst_now)
|
|
|
|
# Relationships
|
|
issues = relationship("Issue", back_populates="reporter")
|
|
daily_works = relationship("DailyWork", back_populates="created_by")
|
|
projects = relationship("Project", back_populates="created_by")
|
|
|
|
class Issue(Base):
|
|
__tablename__ = "issues"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
photo_path = Column(String)
|
|
photo_path2 = Column(String) # 두 번째 사진 경로
|
|
category = Column(Enum(IssueCategory), nullable=False)
|
|
description = Column(Text, nullable=False)
|
|
status = Column(Enum(IssueStatus), default=IssueStatus.new)
|
|
reporter_id = Column(Integer, ForeignKey("users.id"))
|
|
project_id = Column(BigInteger, ForeignKey("projects.id"))
|
|
report_date = Column(DateTime, default=get_kst_now)
|
|
work_hours = Column(Float, default=0)
|
|
detail_notes = Column(Text)
|
|
|
|
# Relationships
|
|
reporter = relationship("User", back_populates="issues")
|
|
project = relationship("Project", back_populates="issues")
|
|
|
|
class Project(Base):
|
|
__tablename__ = "projects"
|
|
|
|
id = Column(BigInteger, primary_key=True, index=True)
|
|
job_no = Column(String, unique=True, nullable=False, index=True)
|
|
project_name = Column(String, nullable=False)
|
|
created_by_id = Column(Integer, ForeignKey("users.id"))
|
|
created_at = Column(DateTime, default=get_kst_now)
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
# Relationships
|
|
created_by = relationship("User", back_populates="projects")
|
|
issues = relationship("Issue", back_populates="project")
|
|
|
|
class DailyWork(Base):
|
|
__tablename__ = "daily_works"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
date = Column(DateTime, nullable=False, index=True)
|
|
worker_count = Column(Integer, nullable=False)
|
|
regular_hours = Column(Float, nullable=False)
|
|
overtime_workers = Column(Integer, default=0)
|
|
overtime_hours = Column(Float, default=0)
|
|
overtime_total = Column(Float, default=0)
|
|
total_hours = Column(Float, nullable=False)
|
|
created_by_id = Column(Integer, ForeignKey("users.id"))
|
|
created_at = Column(DateTime, default=get_kst_now)
|
|
|
|
# Relationships
|
|
created_by = relationship("User", back_populates="daily_works")
|