198 lines
5.6 KiB
Markdown
198 lines
5.6 KiB
Markdown
Here is the content for the `documentation.md` file that explains the functionality of the application:
|
|
|
|
---
|
|
|
|
### Documentation for Quality Recticel Application
|
|
|
|
---
|
|
|
|
#### **Overview**
|
|
The Quality Recticel application is a web-based system designed to manage and monitor quality control processes, user roles, and database interactions. It includes modules for scanning, quality assurance, warehouse management, and administrative settings.
|
|
|
|
---
|
|
|
|
### **Features**
|
|
|
|
#### 1. **User Management**
|
|
- **Roles**:
|
|
- `superadmin`: Full access to all features and settings.
|
|
- `administrator`: Limited administrative access.
|
|
- `quality`: Access to quality assurance features.
|
|
- `warehouse`: Access to warehouse management features.
|
|
- `scan`: Access to scanning features.
|
|
- **Functionalities**:
|
|
- Create, edit, and delete users.
|
|
- Assign roles to users.
|
|
- Manage user credentials.
|
|
|
|
#### 2. **Scan Module**
|
|
- **Input Form**:
|
|
- Allows users to input scan data, including:
|
|
- Operator Code
|
|
- CP Code
|
|
- OC1 Code
|
|
- OC2 Code
|
|
- Defect Code
|
|
- Date and Time
|
|
- **Latest Scans Table**:
|
|
- Displays the last 15 scans with details such as:
|
|
- Approved Quantity
|
|
- Rejected Quantity
|
|
- Data is dynamically fetched from the database.
|
|
|
|
#### 3. **Quality Module**
|
|
- Provides tools for quality assurance personnel to monitor and manage quality-related data.
|
|
|
|
#### 4. **Warehouse Module**
|
|
- Enables warehouse personnel to manage inventory and related processes.
|
|
|
|
#### 5. **Settings Module**
|
|
- **External Database Configuration**:
|
|
- Allows the `superadmin` to configure external database settings, including:
|
|
- Server Domain/IP
|
|
- Port
|
|
- Database Name
|
|
- Username and Password
|
|
- **User Management**:
|
|
- Provides an interface to manage users and their roles.
|
|
|
|
---
|
|
|
|
### **Database Structure**
|
|
|
|
#### **Table: `scan1_orders`**
|
|
- **Columns**:
|
|
- `Id`: Auto-incremented primary key.
|
|
- `operator_code`: Operator code (4 characters).
|
|
- `CP_full_code`: Full CP code (15 characters, unique).
|
|
- `OC1_code`: OC1 code (4 characters).
|
|
- `OC2_code`: OC2 code (4 characters).
|
|
- `CP_base_code`: Auto-generated base code (first 10 characters of `CP_full_code`).
|
|
- `quality_code`: Quality code (3 digits).
|
|
- `date`: Date in `yyyy-mm-dd` format.
|
|
- `time`: Time in `hh:mm:ss` format.
|
|
- `approved_quantity`: Number of approved items (calculated dynamically).
|
|
- `rejected_quantity`: Number of rejected items (calculated dynamically).
|
|
|
|
#### **Triggers**
|
|
- **`increment_approved_quantity`**:
|
|
- Updates `approved_quantity` based on the number of rows with the same `CP_base_code` and `quality_code = 000`.
|
|
- **`increment_rejected_quantity`**:
|
|
- Updates `rejected_quantity` based on the number of rows with the same `CP_base_code` and `quality_code != 000`.
|
|
|
|
---
|
|
|
|
### **Key Files**
|
|
|
|
#### 1. **`run.py`**
|
|
- Entry point for the application.
|
|
- Starts the Flask server.
|
|
|
|
#### 2. **`routes.py`**
|
|
- Defines the routes and logic for the application.
|
|
- Handles user authentication, form submissions, and database interactions.
|
|
|
|
#### 3. **`models.py`**
|
|
- Defines the `User` model for managing user data.
|
|
|
|
#### 4. **`create_scan_1db.py`**
|
|
- Script to create the `scan1_orders` table in the database.
|
|
|
|
#### 5. **`create_triggers.py`**
|
|
- Script to create database triggers for dynamically updating `approved_quantity` and `rejected_quantity`.
|
|
|
|
#### 6. **`seed.py`**
|
|
- Seeds the database with default users.
|
|
|
|
#### 7. **Templates**
|
|
- **`scan.html`**:
|
|
- Interface for the Scan Module.
|
|
- **`settings.html`**:
|
|
- Interface for managing users and external database settings.
|
|
|
|
---
|
|
|
|
### **How to Run the Application**
|
|
|
|
1. **Set Up the Environment**:
|
|
- Install dependencies:
|
|
```bash
|
|
pip install flask mariadb
|
|
```
|
|
|
|
2. **Configure the Database**:
|
|
- Update the `external_server.conf` file with the correct database credentials.
|
|
|
|
3. **Create the Database and Triggers**:
|
|
- Run the create_scan_1db.py script:
|
|
```bash
|
|
python py_app/app/db_create_scripts/create_scan_1db.py
|
|
```
|
|
- Run the create_triggers.py script:
|
|
```bash
|
|
python py_app/app/db_create_scripts/create_triggers.py
|
|
```
|
|
|
|
4. **Seed the Database**:
|
|
- Run the seed.py script:
|
|
```bash
|
|
python py_app/seed.py
|
|
```
|
|
|
|
5. **Start the Application**:
|
|
- Run the run.py file:
|
|
```bash
|
|
python py_app/run.py
|
|
```
|
|
|
|
6. **Access the Application**:
|
|
- Open a browser and navigate to:
|
|
```
|
|
http://127.0.0.1:5000
|
|
```
|
|
|
|
---
|
|
|
|
### **Troubleshooting**
|
|
|
|
1. **Database Connection Issues**:
|
|
- Ensure the `external_server.conf` file is correctly configured.
|
|
- Verify that the database server is running.
|
|
|
|
2. **Trigger Errors**:
|
|
- Check the trigger definitions in the database using:
|
|
```sql
|
|
SHOW TRIGGERS;
|
|
```
|
|
|
|
3. **Form Submission Errors**:
|
|
- Verify that all required fields in the form are filled out.
|
|
|
|
4. **Permission Issues**:
|
|
- Ensure the user has the correct role for accessing specific modules.
|
|
|
|
---
|
|
|
|
### **Future Enhancements**
|
|
- Add detailed logging for debugging.
|
|
- Implement role-based access control for more granular permissions.
|
|
- Add support for exporting scan data to CSV or Excel.
|
|
|
|
---
|
|
|
|
Save this content as `documentation.md` in the root directory of your project.3. **Form Submission Errors**:
|
|
- Verify that all required fields in the form are filled out.
|
|
|
|
4. **Permission Issues**:
|
|
- Ensure the user has the correct role for accessing specific modules.
|
|
|
|
---
|
|
|
|
### **Future Enhancements**
|
|
- Add detailed logging for debugging.
|
|
- Implement role-based access control for more granular permissions.
|
|
- Add support for exporting scan data to CSV or Excel.
|
|
|
|
---
|
|
|
|
Save this content as `documentation.md` in the root directory of your project. |