tjx
2025-11-04 c5f81c1b1298d9c20acf5fc21d26893a341db283
CLAUDE.md
@@ -25,8 +25,8 @@
- For local debugging: Run > Run to Mobile Device
**Key Development URLs:**
- Local debug API: `http://localhost:63775/api`
- Internal network API: `http://192.168.0.94:10055/api`
- Local debug API: `http://localhost:5106/api`
- Internal network API (PRIMARY): `http://192.168.0.94:8008/api`
- Server health check: `http://192.168.11.251:10054`
**No traditional npm scripts** - this project uses Uni-app's build system through HBuilderX or uni CLI.
@@ -34,27 +34,58 @@
## Architecture Overview
### Core Application Flow
1. **Device Identification**: App auto-detects device MAC address (`store/index.js:14`)
2. **Work Order Management**: Multi-work order selection with mold consistency validation
3. **Production Operations**: Tab-based interface for different manufacturing processes
4. **Data Synchronization**: Real-time sync with backend MES system via RESTful APIs
1. **App Startup** (App.vue, pages/index.vue):
   - Clear local storage (except critical device info)
   - Detect device WiFi MAC address via Android native APIs
   - Check for APK updates and install silently if available
   - Load machine binding from `/DevMachine/GetDevMachineByPdaMac`
2. **Work Order Selection** (Tab 7):
   - Display available work orders for the bound machine
   - User selects up to 4 orders (must have same mold)
   - Save selection via `/MesOrderSelect/Add`
   - Navigate to Tab 0 (Main Interface)
3. **Production Monitoring** (Tab 0 - WorkOrder.vue):
   - Display real-time order details and production metrics
   - Show quality inspection results (首检/巡检)
   - Auto-refresh every 120 seconds
4. **Production Operations** (Tabs 2-6, 9):
   - Mold changes, machine adjustments, barcode printing
   - Quality inspections, e-SOP viewing, process parameters
   - Equipment point checks
5. **Data Synchronization**: All operations sync with backend MES system via RESTful APIs
### Key API Endpoints
- Device info: `/DevMachine/GetDevMachineByPdaMac`
- Work orders: `/Womdaa/GetWomdaasByShow`
- Order selection: `/MesOrderSelect/Add` and `/MesOrderSelect/Remove`
- Work orders: `/Womdaa/GetWomdaasByShow`, `/Womdaa/GetWomdaasByMachine`, `/Womdaa/GetWomdaaById`
- Order selection: `/MesOrderSelect/Add`, `/MesOrderSelect/Remove`
- Order status: `/MesOrderSta/FindByOrderNo`, `/MesOrderSta/init`, `/MesOrderSta/Binding`
- Quality inspection: `/MesQaItemsDetect02/FindSJByOrderNo` (首检), `/MesQaItemsDetect02/FindXJByOrderNo` (巡检)
- Stored procedures: `/b/esp` endpoint
**API Response Format:**
All API responses follow this structure:
```javascript
{
  status: 0,                    // 0 = success, non-zero = error
  message: "Operation message",
  data: {
    tbBillList: [...],          // Primary data array/object
    ...
  }
}
```
### Tab Structure (pages/index.vue)
- Tab 7: Work Order Selection - Multi-order selection with mold validation
- Tab 0: Main Interface - Work order details and production monitoring
- Tab 1: Start/Finish Work - Production time tracking
- Tab 7: Work Order Selection - Multi-order selection with mold validation (main entry point)
- Tab 0: Main Interface - Work order details and production monitoring (auto-refresh every 120 seconds)
- Tab 1: Start/Finish Work - Production time tracking (currently hidden)
- Tab 2: Mold Change - Mold management operations
- Tab 3: Machine Adjustment & Inspection - Equipment tuning and QC
- Tab 3: Machine Adjustment & Inspection - Equipment tuning and QC (调机送检)
- Tab 4: Barcode Printing & Reporting - Production quantity reporting
- Tab 5: e-SOP - Standard operating procedures (PDF viewer)
- Tab 6: Process Parameters - Production parameter management
- Tab 8: Printer Settings - Bluetooth printer configuration
- Tab 8: Printer Settings - Bluetooth printer configuration (hidden)
- Tab 9: Equipment Inspection - Equipment point checks (设备点检)
### Component Architecture
- **WorkOrder.vue**: Main production interface component
@@ -65,6 +96,7 @@
- **PDFShow.vue**: e-SOP document viewer
- **mold.vue**: Mold change operations
- **machine.vue**: Machine adjustment and inspection
- **EquipmentInspection.vue**: Equipment inspection/点检
### State Management (store/index.js)
- Server configuration with internal/external network switching
@@ -72,11 +104,18 @@
- Network status and connection management
### Utility Functions (main.js)
Global prototype methods available on all Vue instances:
- **HTTP Requests**: `$post`, `$get`, `$uni_request` methods for API communication
  - `$post(params)`: POST requests with loading spinner
  - `$get(params)`: GET requests
  - `$uni_request(params)`: Unified promise-based requests to `serverAPI`
  - `$toERP(params)`: Direct ERP endpoint calls
- **Authentication**: `$login`, `$logout`, user session management
  - `$loginInfo`: User object with account, userName, deptNo, chineseName, id
- **UI Helpers**: `$showMessage`, `$showDialog` for user notifications
- **File Operations**: `$camera`, `$fileUpload` for image handling
- **Date Utilities**: `$getDate` with multiple format support
- **File Operations**: `$camera`, `$fileUpload` for image handling (uploads to `/Base/saveImage`)
- **Date Utilities**: `$getDate` with multiple format support ('yyyy-mm-dd hh24:mi:ss')
- **Constants**: `$company` ("广深科技"), `$esp` ("/b/esp"), `$api` ("/api")
### Bluetooth Integration (utils/bluetooth.js)
- Native Android Bluetooth API integration via plus.android
@@ -86,9 +125,14 @@
### Key Development Considerations
- App targets Android industrial control machines with specific screen resolutions (1280x800, 1920x1080)
- Device MAC address is critical for machine binding and identification
- Offline capability with local data caching and sync mechanisms
- Auto-update functionality with APK download and silent installation
  - Primary method: WifiManager.getConnectionInfo().getMacAddress()
  - Fallback (Android 6.0+): NetworkInterface.getByName("wlan0").getHardwareAddress()
- Data persistence via `uni.setStorageSync()` and `uni.getStorageSync()`
  - Stores: pdaMac, machineNo, machineName, account, userName, deptNo
  - Auto-cleared on each app restart: `uni.clearStorageSync()` in App.onLaunch
- Auto-update functionality with APK download and silent installation via `plus.runtime.install()`
- Multi-work order support limited to 4 simultaneous orders with same mold requirements
- WorkOrder.vue auto-refreshes every 120 seconds to sync production data
### Environment Configuration
- Configure `serverAPI` in store for backend API endpoint