fix: 캘린더 모달 중복 카드 문제 및 삭제 권한 개선
- monthly_worker_status 조회 시 GROUP BY로 중복 데이터 합산 - 작업보고서 삭제 권한을 그룹장 이상으로 제한 (admin, system, group_leader) - 중복 데이터 정리를 위한 마이그레이션 SQL 추가 (009_fix_duplicate_monthly_status.sql) - synology_deployment 버전에도 동일 수정 적용
This commit is contained in:
@@ -45,14 +45,30 @@ class MonthlyStatusModel {
|
||||
const db = await getDb();
|
||||
|
||||
try {
|
||||
// 중복 방지: worker_id와 date로 그룹화하고 최신 데이터만 조회
|
||||
const [rows] = await db.execute(`
|
||||
SELECT
|
||||
mws.*,
|
||||
mws.worker_id,
|
||||
w.worker_name,
|
||||
w.job_type
|
||||
w.job_type,
|
||||
MAX(mws.year) as year,
|
||||
MAX(mws.month) as month,
|
||||
mws.date,
|
||||
SUM(mws.total_work_hours) as total_work_hours,
|
||||
SUM(mws.actual_work_hours) as actual_work_hours,
|
||||
SUM(mws.vacation_hours) as vacation_hours,
|
||||
SUM(mws.total_work_count) as total_work_count,
|
||||
SUM(mws.regular_work_count) as regular_work_count,
|
||||
SUM(mws.error_work_count) as error_work_count,
|
||||
MAX(mws.work_status) as work_status,
|
||||
MAX(mws.has_vacation) as has_vacation,
|
||||
MAX(mws.has_error) as has_error,
|
||||
MAX(mws.has_issues) as has_issues,
|
||||
MAX(mws.last_updated) as last_updated
|
||||
FROM monthly_worker_status mws
|
||||
JOIN workers w ON mws.worker_id = w.worker_id
|
||||
WHERE mws.date = ?
|
||||
GROUP BY mws.worker_id, mws.date, w.worker_name, w.job_type
|
||||
ORDER BY w.worker_name ASC
|
||||
`, [date]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user