backend working

This commit is contained in:
2025-10-19 00:15:17 +02:00
parent 372b9b2f20
commit 970651c021
11 changed files with 1060 additions and 162 deletions

View File

@@ -1,4 +1,3 @@
// routes/scheduling.ts
import express from 'express';
import { SchedulingService } from '../services/SchedulingService.js';
@@ -8,18 +7,56 @@ router.post('/generate-schedule', async (req, res) => {
try {
const { shiftPlan, employees, availabilities, constraints } = req.body;
console.log('Received scheduling request:', {
shiftPlan: shiftPlan?.name,
employeeCount: employees?.length,
availabilityCount: availabilities?.length,
constraintCount: constraints?.length
});
// Validate required data
if (!shiftPlan || !employees || !availabilities) {
return res.status(400).json({
error: 'Missing required data',
details: {
shiftPlan: !!shiftPlan,
employees: !!employees,
availabilities: !!availabilities
}
});
}
const scheduler = new SchedulingService();
const result = await scheduler.generateOptimalSchedule({
shiftPlan,
employees,
availabilities,
constraints
constraints: constraints || []
});
console.log('Scheduling completed:', {
success: result.success,
assignments: Object.keys(result.assignments).length,
violations: result.violations.length
});
res.json(result);
} catch (error) {
res.status(500).json({ error: 'Scheduling failed', details: error });
console.error('Scheduling failed:', error);
res.status(500).json({
error: 'Scheduling failed',
details: error instanceof Error ? error.message : 'Unknown error'
});
}
});
// Health check for scheduling service
router.get('/health', (req, res) => {
res.json({
status: 'ok',
service: 'scheduling',
timestamp: new Date().toISOString()
});
});
export default router;