feat: 일일순회점검 시스템 구축 및 관리 기능 개선

- 일일순회점검 시스템 신규 구현
  - DB 테이블: patrol_checklist_items, daily_patrol_sessions, patrol_check_records, workplace_items, item_types
  - API: /api/patrol/* 엔드포인트
  - 프론트엔드: 지도 기반 작업장 점검 UI

- 설비 관리 기능 개선
  - 구매 관련 필드 추가 (구매일, 가격, 공급업체 등)
  - 설비 코드 자동 생성 (TKP-XXX 형식)

- 작업장 관리 개선
  - 레이아웃 이미지 업로드 기능
  - 마커 위치 저장 기능

- 부서 관리 기능 추가
- 사이드바 네비게이션 카테고리 재구성
- 이미지 401 오류 수정 (정적 파일 경로 처리)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-02-04 11:41:41 +09:00
parent 2e9d24faf2
commit 90d3e32992
101 changed files with 17421 additions and 7047 deletions

View File

@@ -9,10 +9,10 @@ const EquipmentModel = {
const query = `
INSERT INTO equipments (
equipment_code, equipment_name, equipment_type, model_name,
manufacturer, installation_date, serial_number, specifications,
manufacturer, supplier, purchase_price, installation_date, serial_number, specifications,
status, notes, workplace_id, map_x_percent, map_y_percent,
map_width_percent, map_height_percent
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`;
const values = [
@@ -21,6 +21,8 @@ const EquipmentModel = {
equipmentData.equipment_type || null,
equipmentData.model_name || null,
equipmentData.manufacturer || null,
equipmentData.supplier || null,
equipmentData.purchase_price || null,
equipmentData.installation_date || null,
equipmentData.serial_number || null,
equipmentData.specifications || null,
@@ -168,6 +170,8 @@ const EquipmentModel = {
equipment_type = ?,
model_name = ?,
manufacturer = ?,
supplier = ?,
purchase_price = ?,
installation_date = ?,
serial_number = ?,
specifications = ?,
@@ -188,6 +192,8 @@ const EquipmentModel = {
equipmentData.equipment_type || null,
equipmentData.model_name || null,
equipmentData.manufacturer || null,
equipmentData.supplier || null,
equipmentData.purchase_price || null,
equipmentData.installation_date || null,
equipmentData.serial_number || null,
equipmentData.specifications || null,
@@ -211,11 +217,24 @@ const EquipmentModel = {
}
},
// UPDATE MAP POSITION - 지도상 위치 업데이트
// UPDATE MAP POSITION - 지도상 위치 업데이트 (선택적으로 workplace_id도 업데이트)
updateMapPosition: async (equipmentId, positionData, callback) => {
try {
const db = await getDb();
const query = `
// workplace_id가 포함된 경우 함께 업데이트
const hasWorkplaceId = positionData.workplace_id !== undefined;
const query = hasWorkplaceId ? `
UPDATE equipments SET
workplace_id = ?,
map_x_percent = ?,
map_y_percent = ?,
map_width_percent = ?,
map_height_percent = ?,
updated_at = NOW()
WHERE equipment_id = ?
` : `
UPDATE equipments SET
map_x_percent = ?,
map_y_percent = ?,
@@ -225,7 +244,14 @@ const EquipmentModel = {
WHERE equipment_id = ?
`;
const values = [
const values = hasWorkplaceId ? [
positionData.workplace_id,
positionData.map_x_percent,
positionData.map_y_percent,
positionData.map_width_percent,
positionData.map_height_percent,
equipmentId
] : [
positionData.map_x_percent,
positionData.map_y_percent,
positionData.map_width_percent,
@@ -294,6 +320,39 @@ const EquipmentModel = {
} catch (error) {
callback(error);
}
},
// GET NEXT EQUIPMENT CODE - 다음 관리번호 자동 생성 (TKP-001 형식)
getNextEquipmentCode: async (prefix = 'TKP', callback) => {
try {
const db = await getDb();
// 해당 접두사로 시작하는 가장 큰 번호 찾기
const query = `
SELECT equipment_code
FROM equipments
WHERE equipment_code LIKE ?
ORDER BY equipment_code DESC
LIMIT 1
`;
const [rows] = await db.query(query, [`${prefix}-%`]);
let nextNumber = 1;
if (rows.length > 0) {
// TKP-001 형식에서 숫자 부분 추출
const lastCode = rows[0].equipment_code;
const match = lastCode.match(new RegExp(`^${prefix}-(\\d+)$`));
if (match) {
nextNumber = parseInt(match[1], 10) + 1;
}
}
// 3자리로 패딩 (001, 002, ...)
const nextCode = `${prefix}-${String(nextNumber).padStart(3, '0')}`;
callback(null, nextCode);
} catch (error) {
callback(error);
}
}
};