- 실시간 작업장 현황을 지도로 시각화 - 작업장 관리 페이지에서 정의한 구역 정보 활용 - TBM 작업자 및 방문자 현황 표시 주요 변경사항: - dashboard.html: 작업장 현황 섹션 추가 (기존 작업 현황 테이블 제거) - workplace-status.js: 지도 렌더링 및 데이터 통합 로직 구현 - modern-dashboard.js: 삭제된 DOM 요소 조건부 체크 추가 시각화 방식: - 인원 없음: 회색 테두리 + 작업장 이름 - 내부 작업자: 파란색 영역 + 인원 수 - 외부 방문자: 보라색 영역 + 인원 수 - 둘 다: 초록색 영역 + 총 인원 수 기술 구현: - Canvas API 기반 사각형 영역 렌더링 - map-regions API를 통한 데이터 일관성 보장 - 클릭 이벤트로 상세 정보 모달 표시 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
198 lines
4.7 KiB
JavaScript
198 lines
4.7 KiB
JavaScript
/**
|
|
* 근태 관리 컨트롤러
|
|
*
|
|
* 근태 기록 API 엔드포인트 핸들러
|
|
*
|
|
* @author TK-FB-Project
|
|
* @since 2025-12-11
|
|
*/
|
|
|
|
const attendanceService = require('../services/attendanceService');
|
|
const { asyncHandler } = require('../middlewares/errorHandler');
|
|
|
|
/**
|
|
* 일일 근태 현황 조회 (대시보드용)
|
|
*/
|
|
const getDailyAttendanceStatus = asyncHandler(async (req, res) => {
|
|
const { date } = req.query;
|
|
const data = await attendanceService.getDailyAttendanceStatusService(date);
|
|
|
|
res.json({
|
|
success: true,
|
|
data,
|
|
message: '근태 현황을 성공적으로 조회했습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 일일 근태 기록 조회
|
|
*/
|
|
const getDailyAttendanceRecords = asyncHandler(async (req, res) => {
|
|
const { date, worker_id } = req.query;
|
|
const data = await attendanceService.getDailyAttendanceRecordsService(date, worker_id);
|
|
|
|
res.json({
|
|
success: true,
|
|
data,
|
|
message: '근태 기록을 성공적으로 조회했습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 근태 기록 생성/업데이트
|
|
*/
|
|
const upsertAttendanceRecord = asyncHandler(async (req, res) => {
|
|
const recordData = {
|
|
...req.body,
|
|
created_by: req.user?.user_id || req.user?.id
|
|
};
|
|
|
|
const result = await attendanceService.upsertAttendanceRecordService(recordData);
|
|
|
|
res.json({
|
|
success: true,
|
|
data: result,
|
|
message: '근태 기록이 성공적으로 저장되었습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 휴가 처리
|
|
*/
|
|
const processVacation = asyncHandler(async (req, res) => {
|
|
const vacationData = {
|
|
record_date: req.body.date,
|
|
worker_id: req.body.worker_id,
|
|
vacation_type_id: req.body.vacation_type,
|
|
created_by: req.user?.user_id || req.user?.id
|
|
};
|
|
|
|
const result = await attendanceService.processVacationService(vacationData);
|
|
|
|
res.json({
|
|
success: true,
|
|
data: result,
|
|
message: '휴가 처리가 성공적으로 완료되었습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 초과근무 승인
|
|
*/
|
|
const approveOvertime = asyncHandler(async (req, res) => {
|
|
const overtimeData = {
|
|
record_date: req.body.date,
|
|
worker_id: req.body.worker_id,
|
|
overtime_approved: true,
|
|
approved_by: req.user?.user_id || req.user?.id
|
|
};
|
|
|
|
const result = await attendanceService.approveOvertimeService(overtimeData);
|
|
|
|
res.json({
|
|
success: true,
|
|
data: result,
|
|
message: '초과근무가 성공적으로 승인되었습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 근로 유형 목록 조회
|
|
*/
|
|
const getAttendanceTypes = asyncHandler(async (req, res) => {
|
|
const data = await attendanceService.getAttendanceTypesService();
|
|
|
|
res.json({
|
|
success: true,
|
|
data,
|
|
message: '근로 유형 목록을 성공적으로 조회했습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 휴가 유형 목록 조회
|
|
*/
|
|
const getVacationTypes = asyncHandler(async (req, res) => {
|
|
const data = await attendanceService.getVacationTypesService();
|
|
|
|
res.json({
|
|
success: true,
|
|
data,
|
|
message: '휴가 유형 목록을 성공적으로 조회했습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 작업자 휴가 잔여 조회
|
|
*/
|
|
const getWorkerVacationBalance = asyncHandler(async (req, res) => {
|
|
const { worker_id } = req.params;
|
|
const data = await attendanceService.getWorkerVacationBalanceService(parseInt(worker_id));
|
|
|
|
res.json({
|
|
success: true,
|
|
data,
|
|
message: '휴가 잔여 정보를 성공적으로 조회했습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 월별 근태 통계
|
|
*/
|
|
const getMonthlyAttendanceStats = asyncHandler(async (req, res) => {
|
|
const { year, month, worker_id } = req.query;
|
|
const data = await attendanceService.getMonthlyAttendanceStatsService(
|
|
parseInt(year),
|
|
parseInt(month),
|
|
worker_id ? parseInt(worker_id) : null
|
|
);
|
|
|
|
res.json({
|
|
success: true,
|
|
data,
|
|
message: '월별 근태 통계를 성공적으로 조회했습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 출근 체크 목록 조회 (아침용, 휴가 정보 포함)
|
|
*/
|
|
const getCheckinList = asyncHandler(async (req, res) => {
|
|
const { date } = req.query;
|
|
const data = await attendanceService.getCheckinListService(date);
|
|
|
|
res.json({
|
|
success: true,
|
|
data,
|
|
message: '출근 체크 목록을 성공적으로 조회했습니다'
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 출근 체크 저장 (일괄 처리)
|
|
*/
|
|
const saveCheckins = asyncHandler(async (req, res) => {
|
|
const { date, checkins } = req.body; // checkins: [{worker_id, is_present}, ...]
|
|
const result = await attendanceService.saveCheckinsService(date, checkins);
|
|
|
|
res.json({
|
|
success: true,
|
|
data: result,
|
|
message: '출근 체크가 성공적으로 저장되었습니다'
|
|
});
|
|
});
|
|
|
|
module.exports = {
|
|
getDailyAttendanceStatus,
|
|
getDailyAttendanceRecords,
|
|
upsertAttendanceRecord,
|
|
processVacation,
|
|
approveOvertime,
|
|
getAttendanceTypes,
|
|
getVacationTypes,
|
|
getWorkerVacationBalance,
|
|
getMonthlyAttendanceStats,
|
|
getCheckinList,
|
|
saveCheckins
|
|
};
|