diff --git a/backend/routers/__pycache__/issues.cpython-311.pyc b/backend/routers/__pycache__/issues.cpython-311.pyc index 0973e38..067221c 100644 Binary files a/backend/routers/__pycache__/issues.cpython-311.pyc and b/backend/routers/__pycache__/issues.cpython-311.pyc differ diff --git a/backend/routers/issues.py b/backend/routers/issues.py index 317d787..7b3b571 100644 --- a/backend/routers/issues.py +++ b/backend/routers/issues.py @@ -313,12 +313,20 @@ async def request_completion( raise HTTPException(status_code=400, detail="이미 완료 신청된 부적합입니다.") try: + print(f"DEBUG: 완료 신청 시작 - Issue ID: {issue_id}, User: {current_user.username}") + # 완료 사진 저장 completion_photo_path = None if request.completion_photo: + print(f"DEBUG: 완료 사진 저장 시작") completion_photo_path = save_base64_image(request.completion_photo, "completion") + print(f"DEBUG: 완료 사진 저장 완료 - Path: {completion_photo_path}") + + if not completion_photo_path: + raise Exception("완료 사진 저장에 실패했습니다.") # 완료 신청 정보 업데이트 + print(f"DEBUG: DB 업데이트 시작") issue.completion_requested_at = datetime.now() issue.completion_requested_by_id = current_user.id issue.completion_photo_path = completion_photo_path @@ -326,6 +334,7 @@ async def request_completion( db.commit() db.refresh(issue) + print(f"DEBUG: DB 업데이트 완료") return { "message": "완료 신청이 성공적으로 제출되었습니다.", @@ -335,9 +344,10 @@ async def request_completion( } except Exception as e: + print(f"ERROR: 완료 신청 처리 오류 - {str(e)}") db.rollback() # 업로드된 파일이 있다면 삭제 - if completion_photo_path: + if 'completion_photo_path' in locals() and completion_photo_path: try: delete_file(completion_photo_path) except: diff --git a/backend/services/__pycache__/file_service.cpython-311.pyc b/backend/services/__pycache__/file_service.cpython-311.pyc index e9ed27c..45d44ec 100644 Binary files a/backend/services/__pycache__/file_service.cpython-311.pyc and b/backend/services/__pycache__/file_service.cpython-311.pyc differ diff --git a/backend/services/file_service.py b/backend/services/file_service.py index 487adf9..46fed89 100644 --- a/backend/services/file_service.py +++ b/backend/services/file_service.py @@ -13,7 +13,7 @@ def ensure_upload_dir(): if not os.path.exists(UPLOAD_DIR): os.makedirs(UPLOAD_DIR) -def save_base64_image(base64_string: str) -> Optional[str]: +def save_base64_image(base64_string: str, prefix: str = "image") -> Optional[str]: """Base64 이미지를 파일로 저장하고 경로 반환""" try: ensure_upload_dir() @@ -40,8 +40,8 @@ def save_base64_image(base64_string: str) -> Optional[str]: elif image.mode != 'RGB': image = image.convert('RGB') - # 파일명 생성 (강제로 .jpg) - filename = f"{datetime.now().strftime('%Y%m%d%H%M%S')}_{uuid.uuid4().hex[:8]}.jpg" + # 파일명 생성 (prefix 포함) + filename = f"{prefix}_{datetime.now().strftime('%Y%m%d%H%M%S')}_{uuid.uuid4().hex[:8]}.jpg" filepath = os.path.join(UPLOAD_DIR, filename) # 이미지 저장 (최대 크기 제한) diff --git a/frontend/issues-dashboard.html b/frontend/issues-dashboard.html index d7feb4d..0483cbd 100644 --- a/frontend/issues-dashboard.html +++ b/frontend/issues-dashboard.html @@ -181,29 +181,29 @@ -
-
-
-

- 지연 위험 -

-

-

0

-
- -
-
-

- 활성 프로젝트 + 완료 대기

-

0

+

0

- + +
+
+ +
+
+
+

+ 지연 중 +

+

+

0

+
+
@@ -385,26 +385,29 @@ // 통계 업데이트 function updateStatistics() { const today = new Date().toDateString(); + + // 오늘 신규 (오늘 수신함에서 진행중으로 넘어온 것들) const todayIssues = allIssues.filter(issue => - new Date(issue.report_date).toDateString() === today + issue.reviewed_at && new Date(issue.reviewed_at).toDateString() === today ); - // 지연 위험 계산 (예상일이 지났거나 3일 이내) - const delayRiskIssues = allIssues.filter(issue => { + // 완료 대기 (완료 신청이 된 것들) + const pendingCompletionIssues = allIssues.filter(issue => + issue.completion_requested_at && issue.review_status === 'in_progress' + ); + + // 지연 중 (마감일이 지난 것들) + const overdueIssues = allIssues.filter(issue => { if (!issue.expected_completion_date) return false; const expectedDate = new Date(issue.expected_completion_date); const now = new Date(); - const diffDays = (expectedDate - now) / (1000 * 60 * 60 * 24); - return diffDays <= 3; // 3일 이내 또는 지연 + return expectedDate < now; // 마감일 지남 }); - // 활성 프로젝트 (진행 중인 부적합이 있는 프로젝트) - const activeProjectIds = new Set(allIssues.map(issue => issue.project_id)); - document.getElementById('totalInProgress').textContent = allIssues.length; document.getElementById('todayNew').textContent = todayIssues.length; - document.getElementById('delayRisk').textContent = delayRiskIssues.length; - document.getElementById('activeProjects').textContent = activeProjectIds.size; + document.getElementById('pendingCompletion').textContent = pendingCompletionIssues.length; + document.getElementById('overdue').textContent = overdueIssues.length; } // 이슈 카드 업데이트 (관리함 스타일 - 날짜별 그룹화)