- 순찰/점검 기능 개선 (zone-detail 페이지 추가) - 출근/근태 시스템 개선 (연차 조회, 근무현황) - 작업분석 대분류 그룹화 및 마이그레이션 스크립트 - 모바일 네비게이션 UI 추가 - NAS 배포 도구 및 문서 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
127 lines
4.6 KiB
JavaScript
127 lines
4.6 KiB
JavaScript
// patrolRoutes.js
|
|
// 일일순회점검 시스템 라우트
|
|
|
|
const express = require('express');
|
|
const router = express.Router();
|
|
const multer = require('multer');
|
|
const path = require('path');
|
|
const patrolController = require('../controllers/patrolController');
|
|
|
|
// Multer 설정 - 구역 현황 사진 업로드
|
|
const storage = multer.diskStorage({
|
|
destination: (req, file, cb) => {
|
|
cb(null, path.join(__dirname, '../uploads'));
|
|
},
|
|
filename: (req, file, cb) => {
|
|
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
|
|
const ext = path.extname(file.originalname).toLowerCase();
|
|
cb(null, `zone-item-${uniqueSuffix}${ext}`);
|
|
}
|
|
});
|
|
|
|
const upload = multer({
|
|
storage,
|
|
limits: { fileSize: 10 * 1024 * 1024 }, // 10MB
|
|
fileFilter: (req, file, cb) => {
|
|
const allowedTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'];
|
|
if (allowedTypes.includes(file.mimetype)) {
|
|
cb(null, true);
|
|
} else {
|
|
cb(new Error('이미지 파일만 업로드 가능합니다.'), false);
|
|
}
|
|
}
|
|
});
|
|
|
|
// ==================== 순회점검 세션 ====================
|
|
|
|
// 세션 목록 조회
|
|
// GET /patrol/sessions?patrol_date=2026-02-04&patrol_time=morning&category_id=1
|
|
router.get('/sessions', patrolController.getSessions);
|
|
|
|
// 세션 시작/조회 (POST로 생성하거나 기존 세션 반환)
|
|
// POST /patrol/sessions { patrol_date, patrol_time, category_id }
|
|
router.post('/sessions', patrolController.getOrCreateSession);
|
|
|
|
// 세션 상세 조회
|
|
router.get('/sessions/:sessionId', patrolController.getSession);
|
|
|
|
// 세션 완료
|
|
router.patch('/sessions/:sessionId/complete', patrolController.completeSession);
|
|
|
|
// 세션 메모 업데이트
|
|
router.patch('/sessions/:sessionId/notes', patrolController.updateSessionNotes);
|
|
|
|
// 세션별 작업장 점검 현황
|
|
router.get('/sessions/:sessionId/workplace-status', patrolController.getWorkplaceCheckStatus);
|
|
|
|
// ==================== 체크리스트 항목 ====================
|
|
|
|
// 체크리스트 항목 조회 (필터링 가능)
|
|
// GET /patrol/checklist?category_id=1&workplace_id=2
|
|
router.get('/checklist', patrolController.getChecklistItems);
|
|
|
|
// 체크리스트 항목 CRUD
|
|
router.post('/checklist', patrolController.createChecklistItem);
|
|
router.put('/checklist/:itemId', patrolController.updateChecklistItem);
|
|
router.delete('/checklist/:itemId', patrolController.deleteChecklistItem);
|
|
|
|
// ==================== 체크 기록 ====================
|
|
|
|
// 세션별 체크 기록 조회
|
|
// GET /patrol/sessions/:sessionId/records?workplace_id=1
|
|
router.get('/sessions/:sessionId/records', patrolController.getCheckRecords);
|
|
|
|
// 체크 기록 저장 (단건)
|
|
router.post('/sessions/:sessionId/records', patrolController.saveCheckRecord);
|
|
|
|
// 체크 기록 일괄 저장
|
|
router.post('/sessions/:sessionId/records/batch', patrolController.saveCheckRecords);
|
|
|
|
// ==================== 작업장 물품 현황 ====================
|
|
|
|
// 작업장별 물품 조회
|
|
router.get('/workplaces/:workplaceId/items', patrolController.getWorkplaceItems);
|
|
|
|
// 물품 CRUD
|
|
router.post('/workplaces/:workplaceId/items', patrolController.createWorkplaceItem);
|
|
router.put('/items/:itemId', patrolController.updateWorkplaceItem);
|
|
router.delete('/items/:itemId', patrolController.deleteWorkplaceItem);
|
|
|
|
// ==================== 물품 유형 ====================
|
|
|
|
// 물품 유형 목록
|
|
router.get('/item-types', patrolController.getItemTypes);
|
|
|
|
// ==================== 대시보드/통계 ====================
|
|
|
|
// 오늘 순회점검 현황
|
|
router.get('/today-status', patrolController.getTodayStatus);
|
|
|
|
// ==================== 작업장 상세 정보 ====================
|
|
|
|
// 작업장 상세 정보 조회 (시설물, 안전신고, 부적합, 출입, TBM 통합)
|
|
// GET /patrol/workplaces/:workplaceId/detail?date=2026-02-05
|
|
router.get('/workplaces/:workplaceId/detail', patrolController.getWorkplaceDetail);
|
|
|
|
// ==================== 구역 내 등록 물품/시설물 ====================
|
|
|
|
// 구역 내 등록된 물품/시설물 목록 조회
|
|
router.get('/workplaces/:workplaceId/zone-items', patrolController.getZoneItems);
|
|
|
|
// 구역 내 물품/시설물 등록
|
|
router.post('/workplaces/:workplaceId/zone-items', patrolController.createZoneItem);
|
|
|
|
// 구역 내 물품/시설물 수정
|
|
router.put('/zone-items/:itemId', patrolController.updateZoneItem);
|
|
|
|
// 구역 내 물품/시설물 삭제
|
|
router.delete('/zone-items/:itemId', patrolController.deleteZoneItem);
|
|
|
|
// 구역 현황 사진 업로드
|
|
router.post('/zone-items/photos', upload.single('photo'), patrolController.uploadZoneItemPhoto);
|
|
|
|
// 구역 현황 이력 조회
|
|
router.get('/zone-items/:itemId/history', patrolController.getZoneItemHistory);
|
|
|
|
module.exports = router;
|