updated files
This commit is contained in:
146
old code/EXCEL_UPLOAD_MAPPING.md
Normal file
146
old code/EXCEL_UPLOAD_MAPPING.md
Normal file
@@ -0,0 +1,146 @@
|
||||
# Excel File Upload Mapping
|
||||
|
||||
## File Information
|
||||
- **File**: `1cc01b8Comenzi Productie (19).xlsx`
|
||||
- **Sheets**: DataSheet (corrupted), Sheet1 (249 rows × 29 columns)
|
||||
- **Purpose**: Production orders for label generation
|
||||
|
||||
## Excel Columns (29 total)
|
||||
|
||||
### Core Order Fields (✅ Stored in Database)
|
||||
1. **Comanda Productie** → `comanda_productie` ✅
|
||||
2. **Cod Articol** → `cod_articol` ✅
|
||||
3. **Descriere** → `descr_com_prod` ✅
|
||||
4. **Cantitate ceruta** → `cantitate` ✅
|
||||
5. **Delivery date** → `data_livrare` ✅
|
||||
6. **Customer** → `customer_name` ✅
|
||||
7. **Comanda client** → `com_achiz_client` ✅
|
||||
|
||||
### Additional Fields (📊 Read but not stored in order_for_labels table)
|
||||
8. **Status** → `status` 📊
|
||||
9. **End of Quilting** → `end_of_quilting` 📊
|
||||
10. **End of sewing** → `end_of_sewing` 📊
|
||||
11. **T1** → `t1` 📊 (Quality control stage 1)
|
||||
12. **Data inregistrare T1** → `data_inregistrare_t1` 📊
|
||||
13. **Numele Complet T1** → `numele_complet_t1` 📊
|
||||
14. **T2** → `t2` 📊 (Quality control stage 2)
|
||||
15. **Data inregistrare T2** → `data_inregistrare_t2` 📊
|
||||
16. **Numele Complet T2** → `numele_complet_t2` 📊
|
||||
17. **T3** → `t3` 📊 (Quality control stage 3)
|
||||
18. **Data inregistrare T3** → `data_inregistrare_t3` 📊
|
||||
19. **Numele Complet T3** → `numele_complet_t3` 📊
|
||||
20. **Clasificare** → `clasificare` 📊
|
||||
21. **Masina Cusut** → `masina_cusut` 📊
|
||||
22. **Tip Masina** → `tip_masina` 📊
|
||||
23. **Timp normat total** → `timp_normat_total` 📊
|
||||
24. **Data Deschiderii** → `data_deschiderii` 📊
|
||||
25. **Model Lb2** → `model_lb2` 📊
|
||||
26. **Data Planific.** → `data_planific` 📊
|
||||
27. **Numar masina** → `numar_masina` 📊
|
||||
28. **Design nr** → `design_nr` 📊
|
||||
29. **Needle position** → `needle_position` 📊
|
||||
|
||||
## Database Schema (order_for_labels)
|
||||
|
||||
```sql
|
||||
CREATE TABLE order_for_labels (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
comanda_productie VARCHAR(25) NOT NULL,
|
||||
cod_articol VARCHAR(25) NOT NULL,
|
||||
descr_com_prod VARCHAR(100),
|
||||
cantitate INT,
|
||||
data_livrare DATE,
|
||||
dimensiune VARCHAR(25),
|
||||
com_achiz_client VARCHAR(25),
|
||||
nr_linie_com_client INT,
|
||||
customer_name VARCHAR(50),
|
||||
customer_article_number VARCHAR(25),
|
||||
open_for_order VARCHAR(25),
|
||||
line_number INT,
|
||||
printed_labels INT DEFAULT 0
|
||||
);
|
||||
```
|
||||
|
||||
## Validation Rules
|
||||
|
||||
### Required Fields
|
||||
- ✅ `comanda_productie` (Production Order #)
|
||||
- ✅ `cod_articol` (Article Code)
|
||||
- ✅ `descr_com_prod` (Description)
|
||||
- ✅ `cantitate` (Quantity)
|
||||
|
||||
### Optional Fields
|
||||
- `data_livrare` (Delivery Date)
|
||||
- `dimensiune` (Dimension)
|
||||
- `com_achiz_client` (Customer Order #)
|
||||
- `nr_linie_com_client` (Customer Order Line)
|
||||
- `customer_name` (Customer Name)
|
||||
- `customer_article_number` (Customer Article #)
|
||||
- `open_for_order` (Open for Order)
|
||||
- `line_number` (Line Number)
|
||||
|
||||
## Processing Logic
|
||||
|
||||
1. **Sheet Selection**: Tries Sheet1 → sheet 0 → DataSheet
|
||||
2. **Column Normalization**: Converts to lowercase, strips whitespace
|
||||
3. **Column Mapping**: Maps Excel columns to database fields
|
||||
4. **Row Processing**:
|
||||
- Skips empty rows
|
||||
- Handles NaN values (converts to empty string)
|
||||
- Validates required fields
|
||||
- Returns validation errors and warnings
|
||||
5. **Data Storage**: Only valid rows with required fields are stored
|
||||
|
||||
## Sample Data (Row 1)
|
||||
|
||||
```
|
||||
comanda_productie : CP00267043
|
||||
cod_articol : PF010147
|
||||
descr_com_prod : HUSA STARLINE NEXT X7 90X210
|
||||
cantitate : 1
|
||||
data_livrare : 2024-03-12
|
||||
customer_name : 411_01RECT BED
|
||||
com_achiz_client : 379579-1
|
||||
status : Inchis
|
||||
classificare : HP3D
|
||||
masina_cusut : SPECIALA
|
||||
```
|
||||
|
||||
## Upload Functionality
|
||||
|
||||
**URL**: `/upload_data` (Labels module)
|
||||
|
||||
**Supported Formats**:
|
||||
- CSV (.csv)
|
||||
- Excel (.xlsx, .xls)
|
||||
|
||||
**Process**:
|
||||
1. User uploads file
|
||||
2. System validates file type
|
||||
3. Processes file (CSV or Excel)
|
||||
4. Shows preview with validation
|
||||
5. User confirms upload
|
||||
6. Data inserted into database
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
# Test Excel reading
|
||||
cd /srv/quality_app
|
||||
python3 << 'EOF'
|
||||
import pandas as pd
|
||||
df = pd.read_excel("1cc01b8Comenzi Productie (19).xlsx", sheet_name='Sheet1')
|
||||
print(f"✅ Read {len(df)} rows × {len(df.columns)} columns")
|
||||
print(f"Required fields present: {all(col in df.columns for col in ['Comanda Productie', 'Cod Articol', 'Descriere', 'Cantitate ceruta'])}")
|
||||
EOF
|
||||
```
|
||||
|
||||
## Implementation Files
|
||||
|
||||
- `/srv/quality_app/py_app/app/order_labels.py` - Processing functions
|
||||
- `/srv/quality_app/py_app/app/routes.py` - Upload route handler
|
||||
- `/srv/quality_app/py_app/app/templates/upload_orders.html` - Upload UI
|
||||
|
||||
---
|
||||
**Status**: ✅ All 29 columns readable and mapped correctly
|
||||
**Date**: 2024-11-26
|
||||
Reference in New Issue
Block a user