feat: Enhance smart factory schedule management

- Added dailyCount parameter to the upsertSchedule function, allowing for the configuration of daily access limits for users.
- Updated the smartFactoryLog interface to include daily_count, ensuring proper data handling for schedule management.
- Removed the runScheduleNowHandler function from the smartFactoryLogController and adminRoutes, streamlining the API for schedule management.
- Modified the frontend SmartFactoryLogPage to support dailyCount selection, improving user experience in managing schedules.

These changes aim to enhance the flexibility and usability of the smart factory schedule management system, allowing for better control over user access and scheduling operations.
This commit is contained in:
kjs
2026-04-07 17:29:03 +09:00
parent 1b7842c305
commit fc61a66287
6 changed files with 108 additions and 138 deletions

View File

@@ -8,7 +8,6 @@ import { logger } from "../utils/logger";
import { encryptionService } from "../services/encryptionService";
import {
sendSmartFactoryLog,
runScheduleNow,
getTodayPlanStatus,
planDailySends,
} from "../utils/smartFactoryLog";
@@ -255,7 +254,7 @@ export const upsertSchedule = async (
res: Response
): Promise<void> => {
try {
const { companyCode, isActive, timeStart, timeEnd, excludeWeekend, excludeHolidays } = req.body;
const { companyCode, isActive, timeStart, timeEnd, excludeWeekend, excludeHolidays, dailyCount } = req.body;
if (!companyCode) {
res.status(400).json({ success: false, message: "회사코드는 필수입니다." });
@@ -263,11 +262,11 @@ export const upsertSchedule = async (
}
await query(
`INSERT INTO smart_factory_schedule (company_code, is_active, time_start, time_end, exclude_weekend, exclude_holidays, updated_at)
VALUES ($1, $2, $3, $4, $5, $6, NOW())
`INSERT INTO smart_factory_schedule (company_code, is_active, time_start, time_end, exclude_weekend, exclude_holidays, daily_count, updated_at)
VALUES ($1, $2, $3, $4, $5, $6, $7, NOW())
ON CONFLICT (company_code) DO UPDATE SET
is_active = $2, time_start = $3, time_end = $4,
exclude_weekend = $5, exclude_holidays = $6, updated_at = NOW()`,
exclude_weekend = $5, exclude_holidays = $6, daily_count = $7, updated_at = NOW()`,
[
companyCode,
isActive ?? false,
@@ -275,6 +274,7 @@ export const upsertSchedule = async (
timeEnd || "17:30",
excludeWeekend ?? true,
excludeHolidays ?? true,
Math.max(1, Math.min(3, dailyCount || 1)),
]
);
@@ -308,23 +308,6 @@ export const deleteSchedule = async (
/**
* POST /api/admin/smart-factory-log/schedules/:companyCode/run-now
*/
export const runScheduleNowHandler = async (
req: AuthenticatedRequest,
res: Response
): Promise<void> => {
try {
const { companyCode } = req.params;
const result = await runScheduleNow(companyCode);
res.json({ success: true, data: result });
} catch (error) {
logger.error("즉시 실행 실패:", error);
res.status(500).json({
success: false,
message: error instanceof Error ? error.message : "즉시 실행 실패",
});
}
};
/**
* GET /api/admin/smart-factory-log/schedules/today-plan
*/