phosphat-report-app/STOPPAGES_ANALYSIS_FEATURE.md
2025-08-07 01:37:30 +03:00

244 lines
10 KiB
Markdown

# Stoppages Analysis Feature
## Overview
Created a comprehensive stoppages analysis page that aggregates and displays all operational stoppages from report sheets. This provides valuable insights into operational efficiency, downtime patterns, and areas for improvement.
## Features
### ✅ **Comprehensive Data Analysis**
1. **All Stoppages**: Shows stoppages from both day and night shifts across all report sheets
2. **Detailed Information**: Displays time, reason, responsible party, and notes for each stoppage
3. **Summary Statistics**: Provides overall metrics and averages
4. **Filtering**: Multiple filter options for focused analysis
5. **Time Calculations**: Automatic time aggregation and formatting
### ✅ **Summary Statistics Dashboard**
- **Total Stoppages**: Count of all stoppage incidents
- **Total Time**: Sum of all stoppage durations
- **Sheets with Stoppages**: Number of sheets that have recorded stoppages
- **Average Stoppages per Sheet**: Mean number of stoppages per sheet
- **Average Time per Sheet**: Mean stoppage duration per sheet
### ✅ **Filter Options**
1. **Date Range**: From/To date filtering
2. **Area**: Filter by operational area
3. **Employee**: Filter by specific employee
4. **Dredger Location**: Filter by dredger location
5. **Real-time Filtering**: Immediate results update
## User Interface
### ✅ **Statistics Dashboard**
```
┌─────────────────────────────────────────────────────────────┐
│ Stoppages Summary - Overall statistics for selected period │
├─────────────────────────────────────────────────────────────┤
│ [45] [12:30] [15] [3.0] [00:50] │
│ Total Total Sheets Avg/Sheet Avg Time │
│ Stoppages Time w/Stops /Sheet │
└─────────────────────────────────────────────────────────────┘
```
### ✅ **Detailed Stoppages Table**
- **Date & Shift**: When the stoppages occurred
- **Location**: Area, dredger, and reclamation locations
- **Employee**: Who reported the stoppages
- **Stoppages**: Detailed breakdown of each stoppage
- **Total Time**: Aggregated time for all stoppages in that shift
### ✅ **Mobile-Responsive Design**
- **Desktop**: Full table with detailed columns
- **Mobile**: Card-based layout with collapsible details
- **Responsive Filters**: Adapts to screen size
## Technical Implementation
### ✅ **Data Processing**
```typescript
// Process stoppages from both day and night shifts
sheets.forEach(sheet => {
// Day shift stoppages
if (sheet.dayShift && Array.isArray(sheet.dayShift.stoppages)) {
const stoppages = sheet.dayShift.stoppages as StoppageEntry[];
const totalTime = stoppages.reduce((sum, stoppage) =>
sum + timeToMinutes(stoppage.total), 0);
// Add to stoppagesData array
}
// Night shift stoppages (similar processing)
});
```
### ✅ **Time Calculations**
```typescript
// Convert time string to minutes for calculations
const timeToMinutes = (timeStr: string): number => {
if (!timeStr || timeStr === '00:00') return 0;
const [hours, minutes] = timeStr.split(':').map(Number);
return (hours * 60) + minutes;
};
// Format minutes back to HH:MM display
const formatMinutesToTime = (minutes: number): string => {
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
return `${hours.toString().padStart(2, '0')}:${mins.toString().padStart(2, '0')}`;
};
```
### ✅ **Filtering Logic**
- **Server-side**: Initial filtering by date, area, and location
- **Post-processing**: Employee filtering after data aggregation
- **URL Persistence**: Filters maintained in URL parameters
- **Real-time Updates**: Immediate filter application
## Data Structure
### ✅ **Stoppage Entry**
```typescript
interface StoppageEntry {
id: string;
from: string; // Start time
to: string; // End time
total: string; // Duration (HH:MM)
reason: string; // Reason for stoppage
responsible: string; // Who/what was responsible
note: string; // Additional notes
}
```
### ✅ **Processed Data**
```typescript
interface StoppageData {
sheetId: number;
date: string;
area: string;
dredgerLocation: string;
reclamationLocation: string;
shift: string; // 'Day' or 'Night'
employee: string;
stoppages: StoppageEntry[];
totalStoppageTime: number; // Total minutes
}
```
## Business Value
### ✅ **Operational Insights**
1. **Downtime Analysis**: Identify patterns in operational stoppages
2. **Efficiency Metrics**: Track overall operational efficiency
3. **Problem Areas**: Identify locations or shifts with frequent stoppages
4. **Responsibility Tracking**: See who/what causes most stoppages
5. **Trend Analysis**: Monitor improvements over time
### ✅ **Management Benefits**
1. **Performance Monitoring**: Track operational performance metrics
2. **Resource Planning**: Identify areas needing attention or resources
3. **Cost Analysis**: Understand the impact of downtime
4. **Process Improvement**: Data-driven decisions for optimization
5. **Reporting**: Comprehensive stoppage reports for stakeholders
## Use Cases
### **Operational Analysis**
1. **Daily Review**: Check yesterday's stoppages and their causes
2. **Weekly Trends**: Analyze patterns over the past week
3. **Area Comparison**: Compare stoppage rates between different areas
4. **Shift Analysis**: Compare day vs night shift performance
5. **Employee Performance**: Track individual performance metrics
### **Management Reporting**
1. **Monthly Reports**: Generate monthly stoppage summaries
2. **Efficiency Metrics**: Calculate operational efficiency percentages
3. **Cost Impact**: Estimate financial impact of stoppages
4. **Improvement Tracking**: Monitor the effectiveness of improvements
5. **Benchmarking**: Compare performance across different periods
### **Process Improvement**
1. **Root Cause Analysis**: Identify most common stoppage reasons
2. **Prevention Planning**: Plan preventive measures based on data
3. **Resource Allocation**: Allocate resources to problem areas
4. **Training Needs**: Identify training needs based on stoppage patterns
5. **Equipment Maintenance**: Schedule maintenance based on stoppage data
## Statistics Calculations
### ✅ **Summary Metrics**
- **Total Stoppages**: Sum of all individual stoppage incidents
- **Total Time**: Sum of all stoppage durations (converted to HH:MM)
- **Sheets with Stoppages**: Count of unique sheets that have stoppages
- **Average Stoppages per Sheet**: Total stoppages ÷ sheets with stoppages
- **Average Time per Sheet**: Total time ÷ sheets with stoppages
### ✅ **Time Aggregation**
- Individual stoppage times are converted to minutes for calculation
- Totals are calculated in minutes for accuracy
- Results are converted back to HH:MM format for display
- Proper handling of time across midnight boundaries
## Performance Considerations
### ✅ **Efficient Data Processing**
- Single database query to fetch all relevant sheets
- In-memory processing of JSON stoppage data
- Efficient filtering and aggregation algorithms
- Minimal data transfer with focused queries
### ✅ **Scalability**
- Indexed date fields for fast date range queries
- Efficient JSON processing for stoppage data
- Pagination could be added for very large datasets
- Caching opportunities for frequently accessed data
## Future Enhancements
### **Advanced Analytics**
1. **Charts and Graphs**: Visual representation of stoppage trends
2. **Comparative Analysis**: Compare periods, areas, or employees
3. **Predictive Analytics**: Predict potential stoppage patterns
4. **Export Functionality**: Export data to Excel or PDF
5. **Automated Alerts**: Notify when stoppages exceed thresholds
### **Enhanced Filtering**
1. **Stoppage Reason**: Filter by specific stoppage reasons
2. **Time Range**: Filter by time of day when stoppages occurred
3. **Duration Range**: Filter by stoppage duration (short vs long)
4. **Responsible Party**: Filter by who was responsible
5. **Multiple Selection**: Select multiple areas, employees, etc.
### **Integration Features**
1. **Dashboard Integration**: Add stoppage widgets to main dashboard
2. **Report Integration**: Link to related reports and sheets
3. **Notification System**: Alert management about critical stoppages
4. **API Endpoints**: Provide data for external systems
5. **Mobile App**: Dedicated mobile interface for field use
## Counted vs Uncounted Stoppages
### ✅ **Classification Logic**
- **Counted Stoppages**: Unplanned operational stoppages that impact productivity
- **Uncounted Stoppages**: Planned operational activities that don't count as downtime
- Entries containing "Brine" in reason or notes (planned brine operations)
- Entries containing "Change Shift" in reason or notes (planned shift changes)
### ✅ **Visual Indicators**
- **Red Background**: Counted stoppages (impact productivity)
- **Green Background**: Uncounted stoppages (planned activities)
- **Color-coded Badges**: "Counted" (red) vs "Uncounted" (green)
- **Legend**: Clear explanation of the classification system
### ✅ **Enhanced Statistics**
- **Total vs Counted**: Shows both total and counted stoppage counts
- **Time Breakdown**: Separate time calculations for counted vs uncounted
- **Percentage Analysis**: Shows what percentage of stoppages are counted
- **Averages**: Separate averages for total and counted stoppages per sheet
## Menu Integration
### ✅ **Dashboard Navigation**
- Added "Stoppages" menu item to the main navigation
- Accessible to users with auth level 2+ (management and admin)
- Clock icon for easy identification
- Consistent with other navigation items
The stoppages analysis feature provides comprehensive insights into operational efficiency and helps identify areas for improvement, making it a valuable tool for operational management and continuous improvement initiatives. The counted vs uncounted classification ensures that only genuine operational stoppages are considered in productivity metrics."