feat: 챗봇 신고 페이지 AI 백엔드 추가 및 기타 개선

- ai-service: 챗봇 분석/요약 엔드포인트 추가 (chatbot.py, chatbot_service.py)
- tkreport: 챗봇 신고 페이지 (chat-report.html/js/css), nginx ai-api 프록시
- tkreport: 이미지 업로드 서비스 개선, M-Project 연동 신고자 정보 전달
- system1: TBM 작업보고서 UI 개선
- TKQC: 관리함/수신함 기능 개선

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-09 14:11:00 +09:00
parent 5aeda43605
commit d42380ff63
16 changed files with 1522 additions and 59 deletions

View File

@@ -199,6 +199,7 @@ exports.createReport = async (req, res) => {
// 부적합 유형이면 System 3(tkqc)으로 비동기 전달
try {
console.log(`[System3 연동] report_id=${reportId}, category_type=${categoryType}`);
if (catInfo && catInfo.category_type === 'nonconformity') {
const fs = require('fs').promises;
const path = require('path');
@@ -209,8 +210,9 @@ exports.createReport = async (req, res) => {
const filePath = path.join(__dirname, '..', p);
const buf = await fs.readFile(filePath);
photoBase64List.push(`data:image/jpeg;base64,${buf.toString('base64')}`);
console.log(`[System3 연동] 사진 읽기 성공: ${p} (${buf.length} bytes)`);
} catch (readErr) {
console.error('사진 파일 읽기 실패:', p, readErr.message);
console.error('[System3 연동] 사진 파일 읽기 실패:', p, readErr.message);
}
}
@@ -223,27 +225,32 @@ exports.createReport = async (req, res) => {
if (locationParts.workplace_name) locationInfo += ` - ${locationParts.workplace_name}`;
}
} catch (locErr) {
console.error('위치 정보 조회 실패:', locErr.message);
console.error('[System3 연동] 위치 정보 조회 실패:', locErr.message);
}
}
const originalToken = (req.headers['authorization'] || '').replace('Bearer ', '');
console.log(`[System3 연동] sendToMProject 호출: category=${catInfo.category_name}, photos=${photoBase64List.length}장, reporter=${req.user.username}`);
const result = await mProjectService.sendToMProject({
category: catInfo.category_name,
description: additional_description || catInfo.category_name,
reporter_name: req.user.name || req.user.username,
reporter_username: req.user.username || req.user.sub,
reporter_role: req.user.role || 'user',
tk_issue_id: reportId,
project_id: project_id || null,
location_info: locationInfo,
photos: photoBase64List,
ssoToken: originalToken
});
console.log(`[System3 연동] 결과: ${JSON.stringify(result)}`);
if (result.success && result.mProjectId) {
await workIssueModel.updateMProjectId(reportId, result.mProjectId);
console.log(`[System3 연동] m_project_id=${result.mProjectId} 업데이트 완료`);
}
} else {
console.log(`[System3 연동] 부적합 아님, 건너뜀`);
}
} catch (e) {
console.error('System3 연동 실패 (신고는 정상 저장됨):', e.message);
console.error('[System3 연동 실패]', e.message, e.stack);
}
} catch (error) {
console.error('신고 생성 에러:', error);