update merge both sack and box batch to 1, also make sure that detected object outside of zone is not detected
This commit is contained in:
1 parent
6bc6887969
commit
418d1779a4
12 files changed
+1496
-230
No files matched your search
@@ -218,3 +218,6 @@ __marimo__/
|
||||
|
||||
# Streamlit
|
||||
.streamlit/secrets.toml
|
||||
|
||||
# superpower
|
||||
.superpowers
|
||||
@@ -28,12 +28,17 @@ Returns the currently active batch's data or idle state with next batch number.
|
||||
"batch_mode": "manual",
|
||||
"counting_date": "2024-01-01",
|
||||
"batch_number": 12,
|
||||
"object_label": "mixed",
|
||||
"count": 342,
|
||||
"sack_count": 210,
|
||||
"box_count": 132,
|
||||
"start_time": "2024-01-01T14:30:00",
|
||||
"last_detection_time": "2024-01-01T14:35:00"
|
||||
}
|
||||
```
|
||||
|
||||
`count` is the combined total. `sack_count` and `box_count` are the separate class totals.
|
||||
|
||||
**Stopped response (no active batch, 200):**
|
||||
```json
|
||||
{
|
||||
@@ -43,6 +48,8 @@ Returns the currently active batch's data or idle state with next batch number.
|
||||
"batch_mode": "manual",
|
||||
"error": "No active batch",
|
||||
"count": 0,
|
||||
"sack_count": 0,
|
||||
"box_count": 0,
|
||||
"batch_number": null,
|
||||
"next_batch_number": 13,
|
||||
"counting_date": "2024-01-01"
|
||||
@@ -52,7 +59,7 @@ Returns the currently active batch's data or idle state with next batch number.
|
||||
---
|
||||
|
||||
### `POST /api/batch/start`
|
||||
Manually starts a new batch on the counter engine.
|
||||
Manually starts a new unified batch on the counter engine. One batch counts sacks and boxes together and reports separate class totals.
|
||||
|
||||
**Success response (200):**
|
||||
```json
|
||||
@@ -60,10 +67,16 @@ Manually starts a new batch on the counter engine.
|
||||
"success": true,
|
||||
"message": "Started Batch #13",
|
||||
"batch_number": 13,
|
||||
"object_label": "mixed",
|
||||
"count": 0,
|
||||
"sack_count": 0,
|
||||
"box_count": 0,
|
||||
"status": "running"
|
||||
}
|
||||
```
|
||||
|
||||
**Legacy aliases:** `POST /api/batch/start/sack` and `POST /api/batch/start/box` still work and start the same unified batch. The class argument is ignored.
|
||||
|
||||
**Error response (503 if engine offline):**
|
||||
```json
|
||||
{
|
||||
@@ -81,9 +94,12 @@ Manually stops the currently active batch, saves records to SQLite (`batches` an
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Batch #13 stopped (342 sacks)",
|
||||
"message": "Batch #13 stopped (342 items)",
|
||||
"batch_number": 13,
|
||||
"object_label": "mixed",
|
||||
"count": 342,
|
||||
"sack_count": 210,
|
||||
"box_count": 132,
|
||||
"persisted": true,
|
||||
"status": "stopped"
|
||||
}
|
||||
@@ -102,7 +118,10 @@ Returns real-time status of the counter engine and batch state.
|
||||
"status": "running",
|
||||
"batch_mode": "manual",
|
||||
"batch_number": 13,
|
||||
"object_label": "mixed",
|
||||
"count": 342,
|
||||
"sack_count": 210,
|
||||
"box_count": 132,
|
||||
"counting_date": "2024-01-01",
|
||||
"engine_alive": true
|
||||
}
|
||||
@@ -119,7 +138,10 @@ Returns the most recently completed batch from the `batches` database table, wit
|
||||
"success": true,
|
||||
"date": "2024-01-01",
|
||||
"batch_number": 11,
|
||||
"object_label": "mixed",
|
||||
"count": 287,
|
||||
"sack_count": 190,
|
||||
"box_count": 97,
|
||||
"start_time": "2024-01-01T14:00:00",
|
||||
"end_time": "2024-01-01T14:27:00",
|
||||
"duration_minutes": 27.0
|
||||
@@ -137,17 +159,26 @@ Returns today, yesterday, and all-time aggregate statistics plus average per day
|
||||
"today": {
|
||||
"date": "2024-01-01",
|
||||
"total_count": 1500,
|
||||
"total_batches": 8
|
||||
"total_batches": 8,
|
||||
"count": 1500,
|
||||
"sack_count": 980,
|
||||
"box_count": 520
|
||||
},
|
||||
"yesterday": {
|
||||
"date": "2023-12-31",
|
||||
"total_count": 1342,
|
||||
"total_batches": 7
|
||||
"total_batches": 7,
|
||||
"count": 1342,
|
||||
"sack_count": 860,
|
||||
"box_count": 482
|
||||
},
|
||||
"all_time": {
|
||||
"grand_total": 50000,
|
||||
"grand_batches": 260,
|
||||
"total_days": 45
|
||||
"total_days": 45,
|
||||
"count": 50000,
|
||||
"sack_count": 32000,
|
||||
"box_count": 18000
|
||||
},
|
||||
"average_per_day": 1111.1,
|
||||
"best_day": {
|
||||
@@ -195,12 +226,17 @@ Returns all batch records for a specific `counting_date` along with summary tota
|
||||
"date": "2024-01-01",
|
||||
"total_count": 1500,
|
||||
"total_batches": 8,
|
||||
"sack_count": 980,
|
||||
"box_count": 520,
|
||||
"total_duration_minutes": 216.0,
|
||||
"avg_duration_minutes": 27.0,
|
||||
"batches": [
|
||||
{
|
||||
"batch_number": 1,
|
||||
"object_label": "mixed",
|
||||
"count": 187,
|
||||
"sack_count": 120,
|
||||
"box_count": 67,
|
||||
"start_time": "2024-01-01T08:00:00",
|
||||
"end_time": "2024-01-01T08:27:00",
|
||||
"duration_minutes": 27.0
|
||||
@@ -225,7 +261,10 @@ Returns the most recent batches with computed durations.
|
||||
{
|
||||
"date": "2024-01-01",
|
||||
"batch_number": 8,
|
||||
"object_label": "mixed",
|
||||
"count": 213,
|
||||
"sack_count": 140,
|
||||
"box_count": 73,
|
||||
"start_time": "2024-01-01T16:30:00",
|
||||
"end_time": "2024-01-01T16:58:00",
|
||||
"duration_minutes": 28.0
|
||||
@@ -261,7 +300,7 @@ Exports batch detail records for the last N days as an `.xlsx` file.
|
||||
|--------|------|---------|-----------------------------|
|
||||
| `days` | int | 30 | Number of days to look back |
|
||||
|
||||
**Response:** XLSX file download with columns: Date, Batch #, Count, Start Time, End Time, Duration (min).
|
||||
**Response:** XLSX file download with columns: Date, Batch #, Type, Sack, Box, Total, Start Time, End Time, Duration (min).
|
||||
|
||||
Filename format: `{SITE_NAME}_daily_records_{timestamp}.xlsx`
|
||||
|
||||
@@ -275,7 +314,7 @@ Exports all batch records for a single date as an `.xlsx` file.
|
||||
|--------|--------|----------------------|
|
||||
| `date` | string | Date in `YYYY-MM-DD` |
|
||||
|
||||
**Response:** XLSX file download with columns: Batch Number, Count, Start Time, End Time, Duration (min).
|
||||
**Response:** XLSX file download with columns: Batch Number, Type, Sack, Box, Total, Start Time, End Time, Duration (min).
|
||||
|
||||
Filename format: `{SITE_NAME}_day_detail_{date}.xlsx`
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
# RKNN Sack Counter (Production)
|
||||
|
||||
RTSP + YOLO RKNN + ByteTrack line-crossing counter for sacks on Rockchip edge hardware.
|
||||
RTSP + YOLO RKNN + ByteTrack line-crossing counter for sacks and boxes on Rockchip edge hardware.
|
||||
|
||||
## Architecture
|
||||
|
||||
- **Input:** Direct LAN camera RTSP (low latency)
|
||||
- **Inference:** YOLO `.rknn` on RK3588 NPU
|
||||
- **Logic:** Line crossing (`sack` count) via `batch_store.py`
|
||||
- **Logic:** Line crossing (`sack` + `box` counts) via `batch_store.py`
|
||||
- **Output:** `feedmill.db` + `current_batch.json`
|
||||
- **Dashboard:** Flask on port **7000**
|
||||
|
||||
Batch lifecycle:
|
||||
- **Manual Mode (`BATCH_MODE=manual`, default):** Operator triggers **Start Batch** and **Stop Batch** manually via dashboard buttons or API. Sacks passing while stopped are ignored.
|
||||
- **Auto Mode (`BATCH_MODE=auto`):** Auto-creates batch on first sack crossing, closes batch after idle timeout (`BATCH_TIMEOUT_SECONDS=600`).
|
||||
- **Manual Mode (`BATCH_MODE=manual`, default):** Operator triggers **Start Batch** and **Stop Batch** manually via dashboard buttons or API. One batch counts sacks and boxes together while reporting separate Sack and Box totals. Objects passing while stopped are ignored.
|
||||
- **Auto Mode (`BATCH_MODE=auto`):** Auto-creates batch on first crossing, closes batch after idle timeout (`BATCH_TIMEOUT_SECONDS=600`).
|
||||
|
||||
## Deploy
|
||||
|
||||
|
||||
@@ -7971,3 +7971,596 @@ batch,frame,timestamp,object_id
|
||||
12,15975,2026-11-12T16:15:01.672759,1049
|
||||
13,267,2026-11-12T16:36:26.444367,1575
|
||||
13,1325,2026-11-12T16:37:28.843927,7304
|
||||
14,907,2026-11-12T16:49:56.981684,2
|
||||
14,993,2026-11-12T16:50:00.415299,13
|
||||
14,1186,2026-11-12T16:50:08.156610,18
|
||||
14,1386,2026-11-12T16:50:16.139288,27
|
||||
14,2767,2026-11-12T16:51:11.382556,58
|
||||
14,2797,2026-11-12T16:51:12.583705,59
|
||||
14,2877,2026-11-12T16:51:15.739368,63
|
||||
14,2973,2026-11-12T16:51:19.660236,69
|
||||
14,3100,2026-11-12T16:51:24.719791,73
|
||||
14,3101,2026-11-12T16:51:24.742555,78
|
||||
14,3269,2026-11-12T16:51:31.597306,90
|
||||
14,3302,2026-11-12T16:51:32.778609,87
|
||||
14,3367,2026-11-12T16:51:35.379487,95
|
||||
14,3386,2026-11-12T16:51:36.136680,96
|
||||
14,3491,2026-11-12T16:51:40.305491,94
|
||||
14,3515,2026-11-12T16:51:41.299515,98
|
||||
14,3572,2026-11-12T16:51:43.635701,111
|
||||
14,3676,2026-11-12T16:51:47.761822,118
|
||||
14,3717,2026-11-12T16:51:49.382997,120
|
||||
14,3800,2026-11-12T16:51:52.658251,127
|
||||
14,3842,2026-11-12T16:51:54.384625,125
|
||||
14,3904,2026-11-12T16:51:56.897536,144
|
||||
14,3952,2026-11-12T16:51:58.770016,149
|
||||
14,4035,2026-11-12T16:52:02.063374,143
|
||||
14,4052,2026-11-12T16:52:02.778848,160
|
||||
14,4161,2026-11-12T16:52:07.138072,171
|
||||
14,4183,2026-11-12T16:52:08.016014,175
|
||||
14,4264,2026-11-12T16:52:11.257879,174
|
||||
14,4311,2026-11-12T16:52:13.152621,189
|
||||
14,4386,2026-11-12T16:52:16.087783,200
|
||||
14,4425,2026-11-12T16:52:17.702531,188
|
||||
14,4502,2026-11-12T16:52:20.761836,214
|
||||
14,4637,2026-11-12T16:52:26.199539,202
|
||||
14,4846,2026-11-12T16:52:34.536789,239
|
||||
14,4897,2026-11-12T16:52:36.585967,249
|
||||
14,4961,2026-11-12T16:52:39.197414,244
|
||||
14,5037,2026-11-12T16:52:42.183298,251
|
||||
14,5148,2026-11-12T16:52:46.625095,267
|
||||
14,5256,2026-11-12T16:52:50.948191,295
|
||||
14,5406,2026-11-12T16:52:56.946180,304
|
||||
14,5559,2026-11-12T16:53:03.061223,324
|
||||
14,5708,2026-11-12T16:53:09.025519,344
|
||||
14,5744,2026-11-12T16:53:10.458659,346
|
||||
14,5862,2026-11-12T16:53:15.195817,361
|
||||
14,5874,2026-11-12T16:53:15.685253,355
|
||||
14,5960,2026-11-12T16:53:19.102298,370
|
||||
14,5981,2026-11-12T16:53:19.952426,366
|
||||
14,6131,2026-11-12T16:53:25.949397,375
|
||||
14,6176,2026-11-12T16:53:27.758829,381
|
||||
14,6278,2026-11-12T16:53:31.862735,383
|
||||
14,6299,2026-11-12T16:53:32.667038,389
|
||||
14,6434,2026-11-12T16:53:38.088768,365
|
||||
14,6575,2026-11-12T16:53:43.715036,404
|
||||
14,6897,2026-11-12T16:53:56.583261,412
|
||||
14,6898,2026-11-12T16:53:56.625394,413
|
||||
14,7051,2026-11-12T16:54:02.740178,429
|
||||
14,7138,2026-11-12T16:54:06.228727,435
|
||||
14,7193,2026-11-12T16:54:08.423885,440
|
||||
14,7388,2026-11-12T16:54:16.224315,445
|
||||
14,8441,2026-11-12T16:54:58.338844,482
|
||||
14,8603,2026-11-12T16:55:04.821186,489
|
||||
14,8714,2026-11-12T16:55:09.269437,499
|
||||
14,8803,2026-11-12T16:55:12.821078,509
|
||||
14,8884,2026-11-12T16:55:16.104903,513
|
||||
14,9054,2026-11-12T16:55:22.862288,527
|
||||
14,9198,2026-11-12T16:55:28.617718,541
|
||||
14,9308,2026-11-12T16:55:33.149275,552
|
||||
14,9449,2026-11-12T16:55:38.988825,559
|
||||
14,9470,2026-11-12T16:55:39.578296,563
|
||||
14,9551,2026-11-12T16:55:42.744620,562
|
||||
14,9595,2026-11-12T16:55:44.507539,570
|
||||
14,9694,2026-11-12T16:55:48.470073,572
|
||||
14,9732,2026-11-12T16:55:50.363594,573
|
||||
14,9812,2026-11-12T16:55:53.182429,595
|
||||
14,9857,2026-11-12T16:55:55.637423,589
|
||||
14,9888,2026-11-12T16:55:56.424625,603
|
||||
14,9969,2026-11-12T16:55:59.674634,599
|
||||
14,10038,2026-11-12T16:56:02.244137,592
|
||||
14,10103,2026-11-12T16:56:04.819057,613
|
||||
14,10203,2026-11-12T16:56:08.827726,605
|
||||
14,10235,2026-11-12T16:56:10.062664,640
|
||||
14,10326,2026-11-12T16:56:13.749894,647
|
||||
14,10343,2026-11-12T16:56:14.418680,654
|
||||
14,10448,2026-11-12T16:56:18.621472,672
|
||||
14,10575,2026-11-12T16:56:23.737623,653
|
||||
14,10606,2026-11-12T16:56:24.951090,688
|
||||
14,10710,2026-11-12T16:56:29.104224,689
|
||||
14,10717,2026-11-12T16:56:29.385199,704
|
||||
14,10846,2026-11-12T16:56:34.535042,718
|
||||
14,10854,2026-11-12T16:56:34.859838,719
|
||||
14,10954,2026-11-12T16:56:38.856765,732
|
||||
14,11003,2026-11-12T16:56:40.861748,734
|
||||
14,11057,2026-11-12T16:56:42.981968,730
|
||||
14,11118,2026-11-12T16:56:45.506376,735
|
||||
14,11177,2026-11-12T16:56:47.824456,755
|
||||
14,11226,2026-11-12T16:56:49.817183,760
|
||||
14,11292,2026-11-12T16:56:52.394681,741
|
||||
14,11334,2026-11-12T16:56:54.053039,759
|
||||
14,11350,2026-11-12T16:56:54.699530,776
|
||||
14,11377,2026-11-12T16:56:55.798437,775
|
||||
14,11418,2026-11-12T16:56:57.545807,772
|
||||
14,11466,2026-11-12T16:56:59.390906,783
|
||||
14,11541,2026-11-12T16:57:02.335220,782
|
||||
14,11555,2026-11-12T16:57:02.897175,791
|
||||
14,11617,2026-11-12T16:57:05.393770,796
|
||||
14,11641,2026-11-12T16:57:06.338528,797
|
||||
14,11663,2026-11-12T16:57:07.253818,789
|
||||
14,11737,2026-11-12T16:57:10.199710,808
|
||||
14,11973,2026-11-12T16:57:19.715670,716
|
||||
14,11980,2026-11-12T16:57:19.914739,819
|
||||
14,12081,2026-11-12T16:57:23.940045,830
|
||||
14,12193,2026-11-12T16:57:28.420370,833
|
||||
14,12318,2026-11-12T16:57:33.539042,838
|
||||
14,14093,2026-11-12T16:58:44.418869,882
|
||||
14,14175,2026-11-12T16:58:47.713923,887
|
||||
14,14285,2026-11-12T16:58:52.072595,897
|
||||
14,14295,2026-11-12T16:58:52.499989,899
|
||||
14,14444,2026-11-12T16:58:58.469912,909
|
||||
14,14454,2026-11-12T16:58:58.879783,912
|
||||
14,14530,2026-11-12T16:59:14.687476,916
|
||||
14,14539,2026-11-12T16:59:14.899150,926
|
||||
14,14634,2026-11-12T16:59:17.072366,924
|
||||
14,14641,2026-11-12T16:59:17.243355,929
|
||||
14,14741,2026-11-12T16:59:19.502616,940
|
||||
14,14783,2026-11-12T16:59:20.696607,941
|
||||
14,14935,2026-11-12T16:59:26.799155,955
|
||||
14,14997,2026-11-12T16:59:29.391713,954
|
||||
14,15061,2026-11-12T16:59:31.814475,965
|
||||
14,15103,2026-11-12T16:59:33.582810,961
|
||||
14,15106,2026-11-12T16:59:33.660034,968
|
||||
14,15181,2026-11-12T16:59:36.649338,979
|
||||
14,15261,2026-11-12T16:59:39.816547,988
|
||||
14,15303,2026-11-12T16:59:41.638613,984
|
||||
14,15383,2026-11-12T16:59:44.702339,991
|
||||
14,15469,2026-11-12T16:59:48.141469,1005
|
||||
14,15474,2026-11-12T16:59:48.341094,997
|
||||
14,15565,2026-11-12T16:59:52.026728,1003
|
||||
14,15596,2026-11-12T16:59:53.295043,1015
|
||||
14,15693,2026-11-12T16:59:57.129130,1016
|
||||
14,15760,2026-11-12T16:59:59.794753,1022
|
||||
1,2029,2026-11-13T08:42:51.729746,25
|
||||
1,2070,2026-11-13T08:42:53.272383,26
|
||||
1,2207,2026-11-13T08:42:58.825856,33
|
||||
1,2280,2026-11-13T08:43:01.778762,36
|
||||
1,2322,2026-11-13T08:43:03.349923,35
|
||||
1,2431,2026-11-13T08:43:07.807545,41
|
||||
1,2453,2026-11-13T08:43:08.676464,28
|
||||
1,2559,2026-11-13T08:43:12.842943,51
|
||||
1,2574,2026-11-13T08:43:13.430720,49
|
||||
1,2706,2026-11-13T08:43:18.742202,58
|
||||
1,2743,2026-11-13T08:43:20.240910,63
|
||||
1,2848,2026-11-13T08:43:24.336763,67
|
||||
1,2876,2026-11-13T08:43:25.521972,69
|
||||
1,2986,2026-11-13T08:43:29.959487,77
|
||||
1,3019,2026-11-13T08:43:31.239898,80
|
||||
1,3128,2026-11-13T08:43:35.637935,92
|
||||
1,3171,2026-11-13T08:43:37.332308,84
|
||||
1,3261,2026-11-13T08:43:40.921058,93
|
||||
1,3321,2026-11-13T08:43:43.321530,104
|
||||
1,3500,2026-11-13T08:43:50.411097,110
|
||||
1,3548,2026-11-13T08:43:52.388636,112
|
||||
1,3756,2026-11-13T08:44:00.724234,121
|
||||
2,108338,2026-11-13T10:28:41.030911,2357
|
||||
2,108485,2026-11-13T10:28:46.928507,2362
|
||||
2,108621,2026-11-13T10:28:52.629142,2366
|
||||
2,108761,2026-11-13T10:28:57.966788,2370
|
||||
2,109017,2026-11-13T10:29:08.164384,2372
|
||||
2,109160,2026-11-13T10:29:13.887546,2377
|
||||
2,109347,2026-11-13T10:29:21.362015,2381
|
||||
2,110046,2026-11-13T10:29:49.351750,2392
|
||||
2,110184,2026-11-13T10:29:54.868089,2388
|
||||
2,110271,2026-11-13T10:29:58.433849,2400
|
||||
2,110326,2026-11-13T10:30:00.622316,2402
|
||||
2,110465,2026-11-13T10:30:06.291438,2403
|
||||
2,110607,2026-11-13T10:30:11.794995,2415
|
||||
2,110749,2026-11-13T10:30:17.479566,2421
|
||||
2,110886,2026-11-13T10:30:22.971470,2422
|
||||
2,110981,2026-11-13T10:30:26.841625,2429
|
||||
2,111115,2026-11-13T10:30:32.281477,2441
|
||||
2,111266,2026-11-13T10:30:38.331226,2447
|
||||
2,111375,2026-11-13T10:30:42.647373,2452
|
||||
2,111592,2026-11-13T10:30:51.156895,2455
|
||||
2,111681,2026-11-13T10:30:54.728138,2463
|
||||
2,111848,2026-11-13T10:31:01.399329,2472
|
||||
2,111953,2026-11-13T10:31:05.630409,2478
|
||||
2,112130,2026-11-13T10:31:12.778478,2483
|
||||
2,112280,2026-11-13T10:31:18.705332,2489
|
||||
2,112428,2026-11-13T10:31:24.677633,2495
|
||||
2,112560,2026-11-13T10:31:29.919765,2501
|
||||
2,112711,2026-11-13T10:31:35.953586,2506
|
||||
2,112831,2026-11-13T10:31:40.852507,2509
|
||||
2,112981,2026-11-13T10:31:46.741698,2508
|
||||
2,113114,2026-11-13T10:31:52.293941,2514
|
||||
2,113222,2026-11-13T10:31:56.450143,2523
|
||||
2,113312,2026-11-13T10:31:59.977368,2528
|
||||
2,113415,2026-11-13T10:32:04.195130,2430
|
||||
2,113514,2026-11-13T10:32:08.513254,2538
|
||||
2,113624,2026-11-13T10:32:12.474669,2545
|
||||
2,113736,2026-11-13T10:32:16.991276,2549
|
||||
2,113750,2026-11-13T10:32:17.531381,2519
|
||||
2,113825,2026-11-13T10:32:20.469376,2553
|
||||
2,113917,2026-11-13T10:32:24.392585,2554
|
||||
2,114018,2026-11-13T10:32:28.376566,2556
|
||||
2,114029,2026-11-13T10:32:28.665722,2560
|
||||
2,114146,2026-11-13T10:32:33.371842,2535
|
||||
2,114222,2026-11-13T10:32:36.494205,2568
|
||||
2,114308,2026-11-13T10:32:39.797195,2572
|
||||
2,114638,2026-11-13T10:32:53.029398,2586
|
||||
2,114795,2026-11-13T10:32:59.300600,2591
|
||||
2,114903,2026-11-13T10:33:03.628708,2575
|
||||
2,115074,2026-11-13T10:33:10.532997,2603
|
||||
2,115218,2026-11-13T10:33:16.361761,2608
|
||||
2,115548,2026-11-13T10:33:29.398985,2616
|
||||
2,119154,2026-11-13T10:35:53.647508,2654
|
||||
2,119181,2026-11-13T10:35:54.908809,2646
|
||||
2,119326,2026-11-13T10:36:00.697396,2655
|
||||
2,119426,2026-11-13T10:36:04.654329,2662
|
||||
2,119565,2026-11-13T10:36:10.443139,2676
|
||||
2,119678,2026-11-13T10:36:14.590675,2685
|
||||
2,119786,2026-11-13T10:36:18.908023,2694
|
||||
2,119952,2026-11-13T10:36:26.877489,2707
|
||||
2,119974,2026-11-13T10:36:27.908484,2706
|
||||
2,120020,2026-11-13T10:36:29.292880,2708
|
||||
2,120081,2026-11-13T10:36:30.827983,2709
|
||||
2,120170,2026-11-13T10:36:34.316281,2721
|
||||
2,120290,2026-11-13T10:36:39.114905,2727
|
||||
2,120398,2026-11-13T10:36:43.395278,2732
|
||||
2,120513,2026-11-13T10:36:48.403689,2752
|
||||
2,120545,2026-11-13T10:36:49.376776,2758
|
||||
2,120608,2026-11-13T10:36:51.814232,2724
|
||||
2,120734,2026-11-13T10:36:56.868606,2765
|
||||
2,120768,2026-11-13T10:36:58.374592,2757
|
||||
2,120881,2026-11-13T10:37:02.735667,2784
|
||||
2,120992,2026-11-13T10:37:07.157402,2795
|
||||
2,121066,2026-11-13T10:37:10.214471,2802
|
||||
2,121178,2026-11-13T10:37:14.604314,2808
|
||||
2,121236,2026-11-13T10:37:16.919933,2810
|
||||
2,121344,2026-11-13T10:37:22.881536,2831
|
||||
2,121383,2026-11-13T10:37:24.685125,2821
|
||||
2,121461,2026-11-13T10:37:27.490510,2841
|
||||
2,121483,2026-11-13T10:37:28.511842,2836
|
||||
2,121597,2026-11-13T10:37:31.385401,2857
|
||||
2,121598,2026-11-13T10:37:31.428721,2861
|
||||
2,121721,2026-11-13T10:37:36.301452,2869
|
||||
2,121725,2026-11-13T10:37:36.495637,2870
|
||||
2,121812,2026-11-13T10:37:39.961285,2872
|
||||
2,121905,2026-11-13T10:37:43.725318,2893
|
||||
2,121918,2026-11-13T10:37:44.520908,2894
|
||||
2,122005,2026-11-13T10:37:47.747568,2886
|
||||
2,122011,2026-11-13T10:37:47.933495,2905
|
||||
2,122133,2026-11-13T10:37:52.900045,2885
|
||||
2,122204,2026-11-13T10:37:56.143337,2895
|
||||
2,122234,2026-11-13T10:37:56.916295,2906
|
||||
2,122334,2026-11-13T10:38:01.199058,2923
|
||||
2,122340,2026-11-13T10:38:01.386081,2936
|
||||
2,122363,2026-11-13T10:38:02.164817,2928
|
||||
2,122430,2026-11-13T10:38:04.807855,2943
|
||||
2,122469,2026-11-13T10:38:06.324784,2940
|
||||
2,122539,2026-11-13T10:38:09.115199,2947
|
||||
2,122618,2026-11-13T10:38:12.399569,2946
|
||||
2,122646,2026-11-13T10:38:13.391107,2931
|
||||
2,122969,2026-11-13T10:38:26.364456,2977
|
||||
2,123186,2026-11-13T10:38:35.284211,2984
|
||||
2,123443,2026-11-13T10:38:45.425420,2989
|
||||
2,133723,2026-11-13T10:45:36.531122,3240
|
||||
2,133819,2026-11-13T10:45:40.483750,3258
|
||||
2,133901,2026-11-13T10:45:43.614589,3262
|
||||
2,133942,2026-11-13T10:45:45.266795,3273
|
||||
2,134003,2026-11-13T10:45:47.707275,3255
|
||||
2,134069,2026-11-13T10:45:50.380033,3284
|
||||
2,134154,2026-11-13T10:45:53.724996,3292
|
||||
2,134202,2026-11-13T10:45:55.631169,3289
|
||||
2,134297,2026-11-13T10:45:59.422063,3299
|
||||
2,134324,2026-11-13T10:46:00.799196,3297
|
||||
2,134437,2026-11-13T10:46:05.151271,3260
|
||||
2,134541,2026-11-13T10:46:09.295941,3331
|
||||
2,134565,2026-11-13T10:46:10.526636,3337
|
||||
2,134644,2026-11-13T10:46:13.328670,3324
|
||||
2,134668,2026-11-13T10:46:14.355056,3343
|
||||
2,134731,2026-11-13T10:46:16.874350,3334
|
||||
2,134770,2026-11-13T10:46:18.501618,3341
|
||||
2,134878,2026-11-13T10:46:22.680287,3348
|
||||
2,134976,2026-11-13T10:46:26.596744,3360
|
||||
2,135067,2026-11-13T10:46:30.334310,3390
|
||||
2,135081,2026-11-13T10:46:30.800197,3392
|
||||
2,135096,2026-11-13T10:46:31.392677,3387
|
||||
2,135163,2026-11-13T10:46:34.321306,3393
|
||||
2,135194,2026-11-13T10:46:35.312604,3399
|
||||
2,135268,2026-11-13T10:46:38.411812,3405
|
||||
2,135271,2026-11-13T10:46:38.492057,3417
|
||||
2,135378,2026-11-13T10:46:42.676240,3420
|
||||
2,135414,2026-11-13T10:46:44.287060,3429
|
||||
2,135479,2026-11-13T10:46:46.891620,3430
|
||||
2,135518,2026-11-13T10:46:48.395467,3435
|
||||
2,135543,2026-11-13T10:46:49.292967,3419
|
||||
2,135570,2026-11-13T10:46:50.390716,3442
|
||||
2,135631,2026-11-13T10:46:52.832340,3444
|
||||
2,135660,2026-11-13T10:46:53.970520,3440
|
||||
2,135714,2026-11-13T10:46:56.258466,3448
|
||||
2,135765,2026-11-13T10:46:58.339381,3450
|
||||
2,135803,2026-11-13T10:46:59.683216,3431
|
||||
2,135830,2026-11-13T10:47:00.765931,3464
|
||||
2,135888,2026-11-13T10:47:03.091261,3452
|
||||
2,136277,2026-11-13T10:47:18.770588,3460
|
||||
3,1386,2026-11-13T11:57:42.191271,28
|
||||
3,2743,2026-11-13T11:58:36.476833,56
|
||||
3,2754,2026-11-13T11:58:36.913987,59
|
||||
3,2934,2026-11-13T11:58:44.184202,63
|
||||
3,3058,2026-11-13T11:58:49.082779,74
|
||||
3,3363,2026-11-13T11:59:01.272918,90
|
||||
3,3374,2026-11-13T11:59:01.761164,44
|
||||
3,3477,2026-11-13T11:59:05.836307,95
|
||||
3,3488,2026-11-13T11:59:06.245470,99
|
||||
3,3662,2026-11-13T11:59:13.237577,119
|
||||
3,3701,2026-11-13T11:59:14.790648,121
|
||||
3,3757,2026-11-13T11:59:17.076340,128
|
||||
3,3785,2026-11-13T11:59:18.129491,126
|
||||
3,506,2026-11-13T13:42:45.456952,1
|
||||
3,620,2026-11-13T13:42:50.032816,16
|
||||
3,638,2026-11-13T13:42:50.752003,17
|
||||
3,782,2026-11-13T13:42:56.545177,20
|
||||
3,808,2026-11-13T13:42:57.585689,24
|
||||
3,956,2026-11-13T13:43:03.533374,22
|
||||
3,968,2026-11-13T13:43:04.010488,32
|
||||
3,1088,2026-11-13T13:43:08.833290,36
|
||||
3,1132,2026-11-13T13:43:10.602440,41
|
||||
3,1149,2026-11-13T13:43:11.289316,31
|
||||
3,1228,2026-11-13T13:43:14.459428,48
|
||||
3,1257,2026-11-13T13:43:15.624456,50
|
||||
3,1351,2026-11-13T13:43:19.398321,54
|
||||
3,1401,2026-11-13T13:43:21.410063,61
|
||||
3,1506,2026-11-13T13:43:25.621867,66
|
||||
3,1522,2026-11-13T13:43:26.260110,67
|
||||
3,1588,2026-11-13T13:43:29.012077,74
|
||||
3,1627,2026-11-13T13:43:30.459219,60
|
||||
3,1633,2026-11-13T13:43:30.694524,81
|
||||
3,1706,2026-11-13T13:43:33.618218,77
|
||||
3,1789,2026-11-13T13:43:36.942066,98
|
||||
3,1873,2026-11-13T13:43:40.296606,97
|
||||
3,1910,2026-11-13T13:43:41.775049,112
|
||||
3,1933,2026-11-13T13:43:42.701338,113
|
||||
3,2028,2026-11-13T13:43:46.499817,122
|
||||
3,2030,2026-11-13T13:43:46.582526,100
|
||||
3,2127,2026-11-13T13:43:50.481585,130
|
||||
3,2233,2026-11-13T13:43:54.724814,133
|
||||
3,2252,2026-11-13T13:43:55.461781,131
|
||||
3,2359,2026-11-13T13:43:59.742663,151
|
||||
3,2388,2026-11-13T13:44:00.899266,150
|
||||
3,2476,2026-11-13T13:44:04.425692,163
|
||||
3,2508,2026-11-13T13:44:05.716831,132
|
||||
3,2612,2026-11-13T13:44:09.880188,172
|
||||
3,2658,2026-11-13T13:44:11.733715,175
|
||||
3,2718,2026-11-13T13:44:14.165068,181
|
||||
3,2724,2026-11-13T13:44:14.376129,188
|
||||
3,2818,2026-11-13T13:44:18.189003,199
|
||||
3,2835,2026-11-13T13:44:18.835254,200
|
||||
3,2849,2026-11-13T13:44:19.404350,194
|
||||
3,2914,2026-11-13T13:44:22.108762,203
|
||||
3,2949,2026-11-13T13:44:23.423912,209
|
||||
3,3053,2026-11-13T13:44:27.584142,214
|
||||
3,3085,2026-11-13T13:44:28.874055,218
|
||||
3,3166,2026-11-13T13:44:32.164450,222
|
||||
3,3190,2026-11-13T13:44:33.063054,221
|
||||
3,3252,2026-11-13T13:44:35.543726,228
|
||||
3,3371,2026-11-13T13:44:40.296846,235
|
||||
3,3405,2026-11-13T13:44:41.657574,231
|
||||
3,3504,2026-11-13T13:44:45.614243,258
|
||||
3,3525,2026-11-13T13:44:46.458252,248
|
||||
3,3652,2026-11-13T13:44:51.539266,266
|
||||
3,3793,2026-11-13T13:44:57.181316,250
|
||||
3,3896,2026-11-13T13:45:01.316043,289
|
||||
3,3948,2026-11-13T13:45:03.384365,293
|
||||
3,4054,2026-11-13T13:45:07.619075,300
|
||||
3,4080,2026-11-13T13:45:08.683050,302
|
||||
3,8316,2026-11-13T13:47:58.254421,369
|
||||
3,8411,2026-11-13T13:48:02.074081,353
|
||||
3,8524,2026-11-13T13:48:06.608278,381
|
||||
3,8658,2026-11-13T13:48:11.992520,384
|
||||
3,8703,2026-11-13T13:48:13.788060,386
|
||||
3,8759,2026-11-13T13:48:16.051045,387
|
||||
3,8860,2026-11-13T13:48:20.112839,407
|
||||
3,8888,2026-11-13T13:48:21.227224,402
|
||||
3,9014,2026-11-13T13:48:26.288404,419
|
||||
3,9033,2026-11-13T13:48:27.051230,416
|
||||
3,9106,2026-11-13T13:48:29.983218,426
|
||||
3,9169,2026-11-13T13:48:32.523986,432
|
||||
3,9222,2026-11-13T13:48:34.647276,436
|
||||
3,9325,2026-11-13T13:48:38.782611,435
|
||||
3,9434,2026-11-13T13:48:43.157047,442
|
||||
3,9440,2026-11-13T13:48:43.403399,437
|
||||
3,9537,2026-11-13T13:48:47.303317,453
|
||||
3,9569,2026-11-13T13:48:48.584523,458
|
||||
3,9709,2026-11-13T13:48:54.210135,467
|
||||
3,9742,2026-11-13T13:48:55.534962,483
|
||||
3,9844,2026-11-13T13:48:59.635610,494
|
||||
3,9932,2026-11-13T13:49:03.165984,505
|
||||
3,9957,2026-11-13T13:49:04.170494,459
|
||||
3,10083,2026-11-13T13:49:09.237342,511
|
||||
3,10093,2026-11-13T13:49:09.640140,523
|
||||
3,10161,2026-11-13T13:49:12.371490,502
|
||||
3,10217,2026-11-13T13:49:14.620655,538
|
||||
3,10266,2026-11-13T13:49:16.591273,545
|
||||
3,10299,2026-11-13T13:49:17.911503,547
|
||||
3,10317,2026-11-13T13:49:18.633999,554
|
||||
3,10339,2026-11-13T13:49:19.522012,555
|
||||
3,10376,2026-11-13T13:49:21.003840,562
|
||||
3,10416,2026-11-13T13:49:22.617489,559
|
||||
3,10477,2026-11-13T13:49:25.101923,573
|
||||
3,10493,2026-11-13T13:49:25.723476,571
|
||||
3,10554,2026-11-13T13:49:28.174215,566
|
||||
3,10654,2026-11-13T13:49:32.175214,592
|
||||
3,10733,2026-11-13T13:49:35.355081,596
|
||||
3,10746,2026-11-13T13:49:35.870485,601
|
||||
3,10827,2026-11-13T13:49:39.131821,602
|
||||
3,10929,2026-11-13T13:49:43.224878,608
|
||||
3,10941,2026-11-13T13:49:43.705945,593
|
||||
3,11018,2026-11-13T13:49:46.806025,614
|
||||
3,11057,2026-11-13T13:49:48.372135,595
|
||||
3,11162,2026-11-13T13:49:52.586229,625
|
||||
3,11264,2026-11-13T13:49:56.681082,619
|
||||
3,11272,2026-11-13T13:49:57.008681,626
|
||||
3,11629,2026-11-13T13:50:11.469568,642
|
||||
3,11653,2026-11-13T13:50:12.304726,651
|
||||
3,11756,2026-11-13T13:50:16.424928,656
|
||||
3,11758,2026-11-13T13:50:16.510260,657
|
||||
3,12824,2026-11-13T13:50:59.146308,683
|
||||
3,12844,2026-11-13T13:50:59.947040,681
|
||||
3,12945,2026-11-13T13:51:03.990033,682
|
||||
3,12978,2026-11-13T13:51:05.363254,686
|
||||
3,13182,2026-11-13T13:51:13.466180,709
|
||||
4,5990,2026-11-13T15:03:03.470102,8
|
||||
4,6164,2026-11-13T15:03:10.745462,12
|
||||
4,6310,2026-11-13T15:03:16.324071,16
|
||||
4,6446,2026-11-13T15:03:21.792540,19
|
||||
4,6604,2026-11-13T15:03:28.191007,27
|
||||
4,6716,2026-11-13T15:03:32.644472,31
|
||||
4,6839,2026-11-13T15:03:37.572678,34
|
||||
4,6850,2026-11-13T15:03:38.015527,35
|
||||
4,7000,2026-11-13T15:03:44.047907,39
|
||||
4,7129,2026-11-13T15:03:49.232215,43
|
||||
4,7269,2026-11-13T15:03:55.081061,48
|
||||
4,7395,2026-11-13T15:03:59.934020,38
|
||||
4,7429,2026-11-13T15:04:01.281089,54
|
||||
4,7523,2026-11-13T15:04:05.064436,60
|
||||
4,7551,2026-11-13T15:04:06.205757,3
|
||||
4,7662,2026-11-13T15:04:10.641132,66
|
||||
4,7909,2026-11-13T15:04:20.569074,79
|
||||
4,7987,2026-11-13T15:04:23.704675,81
|
||||
4,8062,2026-11-13T15:04:26.712987,74
|
||||
4,8121,2026-11-13T15:04:29.093874,67
|
||||
4,8205,2026-11-13T15:04:32.475329,84
|
||||
4,8345,2026-11-13T15:04:38.084643,94
|
||||
4,8365,2026-11-13T15:04:39.001222,95
|
||||
4,8478,2026-11-13T15:04:43.428067,97
|
||||
4,8511,2026-11-13T15:04:44.753199,99
|
||||
4,8603,2026-11-13T15:04:48.449551,103
|
||||
4,8632,2026-11-13T15:04:49.612848,102
|
||||
4,8741,2026-11-13T15:04:53.999059,109
|
||||
4,8745,2026-11-13T15:04:54.152857,108
|
||||
4,8876,2026-11-13T15:04:59.421188,117
|
||||
4,8901,2026-11-13T15:05:00.424948,118
|
||||
4,9036,2026-11-13T15:05:05.867198,119
|
||||
4,9096,2026-11-13T15:05:08.256911,87
|
||||
4,9152,2026-11-13T15:05:10.507076,125
|
||||
4,9225,2026-11-13T15:05:13.503133,126
|
||||
4,9248,2026-11-13T15:05:14.368029,127
|
||||
4,9327,2026-11-13T15:05:17.542329,131
|
||||
4,9343,2026-11-13T15:05:18.223436,132
|
||||
4,9421,2026-11-13T15:05:21.332180,136
|
||||
4,9460,2026-11-13T15:05:22.879600,120
|
||||
4,9643,2026-11-13T15:05:30.236582,144
|
||||
4,9748,2026-11-13T15:05:34.456485,145
|
||||
4,9772,2026-11-13T15:05:35.420861,146
|
||||
4,9872,2026-11-13T15:05:39.432994,158
|
||||
4,9883,2026-11-13T15:05:39.878636,149
|
||||
4,9980,2026-11-13T15:05:43.777643,165
|
||||
4,9996,2026-11-13T15:05:44.422820,160
|
||||
4,11277,2026-11-13T15:06:36.047895,206
|
||||
4,11309,2026-11-13T15:06:37.210791,204
|
||||
4,11378,2026-11-13T15:06:40.039805,214
|
||||
4,11442,2026-11-13T15:06:42.519772,220
|
||||
4,11494,2026-11-13T15:06:44.619699,223
|
||||
4,11530,2026-11-13T15:06:46.183908,216
|
||||
4,11602,2026-11-13T15:06:48.994795,232
|
||||
4,11633,2026-11-13T15:06:50.224124,241
|
||||
4,11703,2026-11-13T15:06:53.021554,242
|
||||
4,11752,2026-11-13T15:06:55.004524,255
|
||||
4,11807,2026-11-13T15:06:57.227954,240
|
||||
4,11867,2026-11-13T15:06:59.786850,261
|
||||
4,11921,2026-11-13T15:07:01.973766,283
|
||||
4,11978,2026-11-13T15:07:04.060217,280
|
||||
4,12031,2026-11-13T15:07:06.207208,292
|
||||
4,12097,2026-11-13T15:07:08.893481,299
|
||||
4,12144,2026-11-13T15:07:10.773614,258
|
||||
4,12202,2026-11-13T15:07:13.081070,309
|
||||
4,12290,2026-11-13T15:07:16.644678,293
|
||||
4,12315,2026-11-13T15:07:17.951423,318
|
||||
4,12431,2026-11-13T15:07:22.633284,315
|
||||
4,12559,2026-11-13T15:07:27.514727,340
|
||||
4,12632,2026-11-13T15:07:30.468314,350
|
||||
4,12738,2026-11-13T15:07:34.646434,365
|
||||
4,12803,2026-11-13T15:07:37.224697,344
|
||||
4,12839,2026-11-13T15:07:38.701123,374
|
||||
4,12960,2026-11-13T15:07:43.511739,388
|
||||
4,13041,2026-11-13T15:07:46.802015,398
|
||||
4,13081,2026-11-13T15:07:48.708933,401
|
||||
4,13184,2026-11-13T15:07:52.583948,412
|
||||
4,13305,2026-11-13T15:07:57.395902,424
|
||||
4,13406,2026-11-13T15:08:01.461119,434
|
||||
4,13487,2026-11-13T15:08:04.703370,438
|
||||
4,13597,2026-11-13T15:08:09.097149,446
|
||||
4,13620,2026-11-13T15:08:10.075115,453
|
||||
4,13702,2026-11-13T15:08:13.330941,455
|
||||
4,13711,2026-11-13T15:08:13.693559,460
|
||||
4,13825,2026-11-13T15:08:18.256854,463
|
||||
4,13853,2026-11-13T15:08:19.392723,450
|
||||
4,13949,2026-11-13T15:08:23.250492,483
|
||||
4,14009,2026-11-13T15:08:25.662607,482
|
||||
4,14118,2026-11-13T15:08:30.300477,498
|
||||
4,14159,2026-11-13T15:08:31.701883,494
|
||||
4,14319,2026-11-13T15:08:38.545837,508
|
||||
4,15275,2026-11-13T15:09:16.510481,536
|
||||
4,15442,2026-11-13T15:09:23.230044,544
|
||||
4,15544,2026-11-13T15:09:27.322547,551
|
||||
4,15660,2026-11-13T15:09:32.020910,535
|
||||
4,15729,2026-11-13T15:09:34.760895,537
|
||||
4,15761,2026-11-13T15:09:36.097610,569
|
||||
4,15803,2026-11-13T15:09:37.769081,581
|
||||
4,15848,2026-11-13T15:09:39.559996,583
|
||||
4,15886,2026-11-13T15:09:41.111822,584
|
||||
4,15925,2026-11-13T15:09:42.681555,561
|
||||
4,16000,2026-11-13T15:09:45.674449,590
|
||||
4,16095,2026-11-13T15:09:49.481640,605
|
||||
4,16111,2026-11-13T15:09:50.121834,610
|
||||
4,16186,2026-11-13T15:09:53.142584,624
|
||||
4,16192,2026-11-13T15:09:53.382343,614
|
||||
4,16290,2026-11-13T15:09:57.521354,615
|
||||
4,16295,2026-11-13T15:09:57.655954,636
|
||||
4,16318,2026-11-13T15:09:58.624172,641
|
||||
4,16456,2026-11-13T15:10:04.002107,650
|
||||
4,16562,2026-11-13T15:10:08.297745,658
|
||||
4,16569,2026-11-13T15:10:08.658004,669
|
||||
4,16660,2026-11-13T15:10:12.190570,680
|
||||
4,16673,2026-11-13T15:10:12.995180,672
|
||||
4,16781,2026-11-13T15:10:17.103086,697
|
||||
4,16795,2026-11-13T15:10:17.657244,685
|
||||
4,16909,2026-11-13T15:10:22.181185,702
|
||||
4,17043,2026-11-13T15:10:27.573782,720
|
||||
4,17169,2026-11-13T15:10:32.820999,724
|
||||
4,17335,2026-11-13T15:10:39.337597,740
|
||||
4,17490,2026-11-13T15:10:45.562230,771
|
||||
4,17532,2026-11-13T15:10:47.229795,757
|
||||
4,17582,2026-11-13T15:10:49.231049,778
|
||||
4,17691,2026-11-13T15:10:53.635944,792
|
||||
4,17760,2026-11-13T15:10:56.383905,803
|
||||
4,17772,2026-11-13T15:10:57.017009,805
|
||||
4,17845,2026-11-13T15:10:59.768273,780
|
||||
4,17861,2026-11-13T15:11:00.423209,819
|
||||
4,17930,2026-11-13T15:11:03.243661,824
|
||||
4,18055,2026-11-13T15:11:08.221878,829
|
||||
4,18198,2026-11-13T15:11:13.961358,852
|
||||
4,18376,2026-11-13T15:11:21.123257,855
|
||||
4,18376,2026-11-13T15:11:21.124416,862
|
||||
4,18505,2026-11-13T15:11:26.306015,867
|
||||
4,18515,2026-11-13T15:11:27.124136,865
|
||||
4,18613,2026-11-13T15:11:30.974343,866
|
||||
4,18639,2026-11-13T15:11:31.705847,884
|
||||
4,18794,2026-11-13T15:11:37.924793,904
|
||||
4,18796,2026-11-13T15:11:38.007443,898
|
||||
4,18914,2026-11-13T15:11:42.974793,906
|
||||
4,20401,2026-11-13T15:12:42.504860,970
|
||||
4,20426,2026-11-13T15:12:43.570618,969
|
||||
4,20524,2026-11-13T15:12:47.470126,968
|
||||
4,20552,2026-11-13T15:12:48.534173,988
|
||||
4,20564,2026-11-13T15:12:49.149641,980
|
||||
4,20593,2026-11-13T15:12:50.179426,977
|
||||
4,20779,2026-11-13T15:12:57.668135,1009
|
||||
4,20787,2026-11-13T15:12:57.982844,1011
|
||||
4,20881,2026-11-13T15:13:01.756498,1020
|
||||
4,21014,2026-11-13T15:13:07.224522,1030
|
||||
4,21015,2026-11-13T15:13:07.258608,1033
|
||||
4,21050,2026-11-13T15:13:08.565246,1035
|
||||
4,21093,2026-11-13T15:13:10.322052,1041
|
||||
4,21146,2026-11-13T15:13:12.397717,1014
|
||||
4,21207,2026-11-13T15:13:14.857657,1053
|
||||
4,21207,2026-11-13T15:13:14.858679,1052
|
||||
4,21276,2026-11-13T15:13:17.640156,1060
|
||||
4,21323,2026-11-13T15:13:19.551830,1051
|
||||
4,21382,2026-11-13T15:13:22.156427,1055
|
||||
4,21462,2026-11-13T15:13:25.109397,1079
|
||||
4,21548,2026-11-13T15:13:28.561606,1080
|
||||
4,21564,2026-11-13T15:13:29.370161,1068
|
||||
4,21771,2026-11-13T15:13:37.507197,1091
|
||||
|
+162
-56
@@ -10,6 +10,83 @@ from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def ensure_batch_schema(conn):
|
||||
"""Create batch tables and migrate legacy rows to separate class counters."""
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS batches (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
counting_date TEXT NOT NULL,
|
||||
batch_number INTEGER NOT NULL,
|
||||
camera_name TEXT NOT NULL,
|
||||
object_label TEXT NOT NULL,
|
||||
count INTEGER NOT NULL,
|
||||
sack_count INTEGER NOT NULL DEFAULT 0,
|
||||
box_count INTEGER NOT NULL DEFAULT 0,
|
||||
start_time TEXT NOT NULL,
|
||||
end_time TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(counting_date, batch_number, camera_name, object_label)
|
||||
)
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS daily_summaries (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
counting_date TEXT NOT NULL,
|
||||
camera_name TEXT NOT NULL,
|
||||
object_label TEXT NOT NULL,
|
||||
total_count INTEGER NOT NULL DEFAULT 0,
|
||||
total_batches INTEGER NOT NULL DEFAULT 0,
|
||||
sack_count INTEGER NOT NULL DEFAULT 0,
|
||||
box_count INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(counting_date, camera_name, object_label)
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
for table in ("batches", "daily_summaries"):
|
||||
columns = {row[1] for row in cur.execute(f"PRAGMA table_info({table})")}
|
||||
for column in ("sack_count", "box_count"):
|
||||
if column not in columns:
|
||||
cur.execute(
|
||||
f"ALTER TABLE {table} ADD COLUMN {column} INTEGER NOT NULL DEFAULT 0"
|
||||
)
|
||||
|
||||
cur.execute(
|
||||
"""
|
||||
UPDATE batches
|
||||
SET sack_count = count
|
||||
WHERE object_label = 'sack' AND sack_count = 0 AND count > 0
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
UPDATE batches
|
||||
SET box_count = count
|
||||
WHERE object_label = 'box' AND box_count = 0 AND count > 0
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
UPDATE daily_summaries
|
||||
SET sack_count = total_count
|
||||
WHERE object_label = 'sack' AND sack_count = 0 AND total_count > 0
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
UPDATE daily_summaries
|
||||
SET box_count = total_count
|
||||
WHERE object_label = 'box' AND box_count = 0 AND total_count > 0
|
||||
"""
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
|
||||
class BatchStore:
|
||||
def __init__(
|
||||
self,
|
||||
@@ -53,38 +130,7 @@ class BatchStore:
|
||||
self.previous_state = self.current_state
|
||||
|
||||
def _init_db(self):
|
||||
cur = self.db.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS batches (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
counting_date TEXT NOT NULL,
|
||||
batch_number INTEGER NOT NULL,
|
||||
camera_name TEXT NOT NULL,
|
||||
object_label TEXT NOT NULL,
|
||||
count INTEGER NOT NULL,
|
||||
start_time TEXT NOT NULL,
|
||||
end_time TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(counting_date, batch_number, camera_name, object_label)
|
||||
)
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS daily_summaries (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
counting_date TEXT NOT NULL,
|
||||
camera_name TEXT NOT NULL,
|
||||
object_label TEXT NOT NULL,
|
||||
total_count INTEGER NOT NULL DEFAULT 0,
|
||||
total_batches INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(counting_date, camera_name, object_label)
|
||||
)
|
||||
"""
|
||||
)
|
||||
self.db.commit()
|
||||
ensure_batch_schema(self.db)
|
||||
|
||||
def get_counting_date(self, dt=None):
|
||||
if dt is None:
|
||||
@@ -96,6 +142,8 @@ class BatchStore:
|
||||
|
||||
def _normalize_batch_label(self, label=None):
|
||||
raw = str(label or '').strip().lower()
|
||||
if raw in ('mixed', 'all', 'both'):
|
||||
return 'mixed'
|
||||
if raw in ('box', '1'):
|
||||
return 'box'
|
||||
if raw in ('sack', '0'):
|
||||
@@ -103,13 +151,36 @@ class BatchStore:
|
||||
default_raw = str(self.object_label or 'sack').split(',')[0].strip().lower()
|
||||
return 'box' if default_raw == 'box' else 'sack'
|
||||
|
||||
def _normalize_item_label(self, label=None):
|
||||
raw = str(label or 'sack').strip().lower()
|
||||
return 'box' if raw == 'box' else 'sack'
|
||||
|
||||
def _load_state(self):
|
||||
if not self.state_file.exists():
|
||||
return None
|
||||
try:
|
||||
with open(self.state_file, 'r', encoding='utf-8') as f:
|
||||
state = json.load(f)
|
||||
state['object_label'] = self._normalize_batch_label(state.get('object_label'))
|
||||
legacy_label = self._normalize_batch_label(state.get('object_label'))
|
||||
if 'sack_count' not in state:
|
||||
state['sack_count'] = (
|
||||
int(state.get('count', 0))
|
||||
if legacy_label in ('sack', 'mixed')
|
||||
else 0
|
||||
)
|
||||
if 'box_count' not in state:
|
||||
state['box_count'] = (
|
||||
int(state.get('count', 0)) if legacy_label == 'box' else 0
|
||||
)
|
||||
state['sack_count'] = int(state.get('sack_count', 0))
|
||||
state['box_count'] = int(state.get('box_count', 0))
|
||||
state['count'] = state['sack_count'] + state['box_count']
|
||||
state['object_label'] = 'mixed'
|
||||
legacy_ids = state.get('counted_event_ids', [])
|
||||
state['counted_event_ids'] = [
|
||||
f"{legacy_label}:{event_id}" if ':' not in str(event_id) else event_id
|
||||
for event_id in legacy_ids
|
||||
]
|
||||
current_date = self.get_counting_date()
|
||||
if state.get('counting_date') != current_date:
|
||||
self.log(
|
||||
@@ -122,7 +193,9 @@ class BatchStore:
|
||||
state['count'],
|
||||
state['start_time'],
|
||||
datetime.now().isoformat(),
|
||||
object_label=state.get('object_label'),
|
||||
object_label='mixed',
|
||||
sack_count=state['sack_count'],
|
||||
box_count=state['box_count'],
|
||||
)
|
||||
self.state_file.unlink(missing_ok=True)
|
||||
return None
|
||||
@@ -163,23 +236,21 @@ class BatchStore:
|
||||
return self.current_state['batch_number']
|
||||
if counting_date is None:
|
||||
counting_date = self.get_counting_date()
|
||||
batch_label = self._normalize_batch_label(object_label)
|
||||
batch_number = self.get_next_batch_number(counting_date)
|
||||
now = datetime.now().isoformat()
|
||||
counted_ids = []
|
||||
if (
|
||||
self.previous_state is not None
|
||||
and self.previous_state.get('object_label') == batch_label
|
||||
):
|
||||
if self.previous_state is not None:
|
||||
try:
|
||||
counted_ids = self.previous_state['counted_event_ids'][-self.carry_ids:]
|
||||
counted_ids = list(self.previous_state['counted_event_ids'][-self.carry_ids:])
|
||||
except (KeyError, TypeError):
|
||||
counted_ids = []
|
||||
self.current_state = {
|
||||
'counting_date': counting_date,
|
||||
'batch_number': batch_number,
|
||||
'object_label': batch_label,
|
||||
'object_label': 'mixed',
|
||||
'count': 0,
|
||||
'sack_count': 0,
|
||||
'box_count': 0,
|
||||
'start_time': now,
|
||||
'last_detection_time': now,
|
||||
'counted_event_ids': counted_ids,
|
||||
@@ -187,7 +258,7 @@ class BatchStore:
|
||||
self.save_state()
|
||||
if self.batch_mode != 'manual':
|
||||
self._reset_batch_timer()
|
||||
self.log(f'Started batch #{batch_number} for {counting_date} ({batch_label}) [mode={self.batch_mode}]')
|
||||
self.log(f'Started batch #{batch_number} for {counting_date} (mixed) [mode={self.batch_mode}]')
|
||||
return batch_number
|
||||
|
||||
def _reset_batch_timer(self):
|
||||
@@ -223,16 +294,14 @@ class BatchStore:
|
||||
self.start_new_batch(counting_date, object_label=object_label or prev_label)
|
||||
started_new = True
|
||||
|
||||
active_label = self.current_state.get('object_label', 'sack')
|
||||
if object_label is not None and self._normalize_batch_label(object_label) != active_label:
|
||||
return self.current_state['count'], False
|
||||
|
||||
event_key = str(track_id)
|
||||
item_label = self._normalize_item_label(object_label)
|
||||
event_key = f'{item_label}:{track_id}'
|
||||
if event_key not in self.current_state['counted_event_ids']:
|
||||
self.current_state['count'] += 1
|
||||
self.current_state[f'{item_label}_count'] += 1
|
||||
self.current_state['counted_event_ids'].append(event_key)
|
||||
self.log(
|
||||
f'Counted {active_label} (track {track_id}) | '
|
||||
f'Counted {item_label} (track {track_id}) | '
|
||||
f'batch #{self.current_state["batch_number"]} '
|
||||
f'total: {self.current_state["count"]}'
|
||||
)
|
||||
@@ -294,6 +363,8 @@ class BatchStore:
|
||||
state['start_time'],
|
||||
end_time,
|
||||
object_label=batch_label,
|
||||
sack_count=state.get('sack_count', 0),
|
||||
box_count=state.get('box_count', 0),
|
||||
)
|
||||
cps = state['count'] / duration_seconds if duration_seconds > 0 else 0
|
||||
self.log(
|
||||
@@ -311,29 +382,62 @@ class BatchStore:
|
||||
self.batch_timer = None
|
||||
return True
|
||||
|
||||
def _insert_batch(self, counting_date, batch_number, count, start_time, end_time, object_label=None):
|
||||
batch_label = self._normalize_batch_label(object_label) if object_label else self.object_label
|
||||
def _insert_batch(
|
||||
self,
|
||||
counting_date,
|
||||
batch_number,
|
||||
count,
|
||||
start_time,
|
||||
end_time,
|
||||
object_label=None,
|
||||
sack_count=0,
|
||||
box_count=0,
|
||||
):
|
||||
batch_label = 'mixed'
|
||||
sack_count = int(sack_count or 0)
|
||||
box_count = int(box_count or 0)
|
||||
if not sack_count and not box_count and count:
|
||||
# Legacy caller without separate counters: trust the row label.
|
||||
legacy_label = self._normalize_batch_label(object_label)
|
||||
if legacy_label == 'box':
|
||||
box_count = int(count)
|
||||
else:
|
||||
sack_count = int(count)
|
||||
cur = self.db.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO batches
|
||||
(counting_date, batch_number, camera_name, object_label, count, start_time, end_time)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
(counting_date, batch_number, camera_name, object_label, count,
|
||||
sack_count, box_count, start_time, end_time)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(counting_date, batch_number, self.camera_name, batch_label, count, start_time, end_time),
|
||||
(
|
||||
counting_date,
|
||||
batch_number,
|
||||
self.camera_name,
|
||||
batch_label,
|
||||
count,
|
||||
sack_count,
|
||||
box_count,
|
||||
start_time,
|
||||
end_time,
|
||||
),
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO daily_summaries
|
||||
(counting_date, camera_name, object_label, total_count, total_batches)
|
||||
VALUES (?, ?, ?, ?, 1)
|
||||
(counting_date, camera_name, object_label, total_count, total_batches,
|
||||
sack_count, box_count)
|
||||
VALUES (?, ?, ?, ?, 1, ?, ?)
|
||||
ON CONFLICT(counting_date, camera_name, object_label)
|
||||
DO UPDATE SET
|
||||
total_count = total_count + excluded.total_count,
|
||||
total_batches = total_batches + excluded.total_batches,
|
||||
sack_count = sack_count + excluded.sack_count,
|
||||
box_count = box_count + excluded.box_count,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
""",
|
||||
(counting_date, self.camera_name, batch_label, count),
|
||||
(counting_date, self.camera_name, batch_label, count, sack_count, box_count),
|
||||
)
|
||||
self.db.commit()
|
||||
|
||||
@@ -419,6 +523,8 @@ class BatchStore:
|
||||
"object_label": obj_label,
|
||||
"next_batch_number": self.get_next_batch_number(cdate) if not active else None,
|
||||
"count": self.current_state['count'] if active else 0,
|
||||
"sack_count": self.current_state.get('sack_count', 0) if active else 0,
|
||||
"box_count": self.current_state.get('box_count', 0) if active else 0,
|
||||
"counting_date": self.current_state['counting_date'] if active else cdate,
|
||||
"start_time": self.current_state['start_time'] if active else None,
|
||||
"last_detection_time": self.current_state['last_detection_time'] if active else None,
|
||||
|
||||
+18
-21
@@ -42,35 +42,29 @@ class ControlHandler(BaseHTTPRequestHandler):
|
||||
"/api/batch/start/sack",
|
||||
"/api/batch/start/box",
|
||||
):
|
||||
body = self._read_json_body()
|
||||
if clean_path.endswith("/box"):
|
||||
req_label = "box"
|
||||
elif clean_path.endswith("/sack"):
|
||||
req_label = "sack"
|
||||
else:
|
||||
req_label = str(
|
||||
body.get("object_label") or body.get("type") or "sack"
|
||||
).strip().lower()
|
||||
if req_label not in ("sack", "box"):
|
||||
req_label = "sack"
|
||||
|
||||
self._read_json_body()
|
||||
status = self.server.store.get_status()
|
||||
if status["active"]:
|
||||
cur_label = status.get("object_label") or "sack"
|
||||
self._send_json(200, {
|
||||
"success": True,
|
||||
"message": f"Batch #{status['batch_number']} ({cur_label.upper()}) is already running",
|
||||
"message": f"Batch #{status['batch_number']} is already running",
|
||||
"batch_number": status["batch_number"],
|
||||
"object_label": cur_label,
|
||||
"object_label": "mixed",
|
||||
"count": status.get("count", 0),
|
||||
"sack_count": status.get("sack_count", 0),
|
||||
"box_count": status.get("box_count", 0),
|
||||
"status": "running",
|
||||
})
|
||||
else:
|
||||
batch_num = self.server.store.start_new_batch(object_label=req_label)
|
||||
batch_num = self.server.store.start_new_batch()
|
||||
self._send_json(200, {
|
||||
"success": True,
|
||||
"message": f"Started Batch #{batch_num} ({req_label.upper()})",
|
||||
"message": f"Started Batch #{batch_num}",
|
||||
"batch_number": batch_num,
|
||||
"object_label": req_label,
|
||||
"object_label": "mixed",
|
||||
"count": 0,
|
||||
"sack_count": 0,
|
||||
"box_count": 0,
|
||||
"status": "running",
|
||||
})
|
||||
elif clean_path in ("/stop", "/api/stop", "/api/batch/stop"):
|
||||
@@ -85,14 +79,17 @@ class ControlHandler(BaseHTTPRequestHandler):
|
||||
else:
|
||||
cur_num = status["batch_number"]
|
||||
cur_count = status["count"]
|
||||
cur_label = status.get("object_label") or "sack"
|
||||
cur_sack = status.get("sack_count", 0)
|
||||
cur_box = status.get("box_count", 0)
|
||||
ok = self.server.store.end_batch(closed_by="manual")
|
||||
self._send_json(200, {
|
||||
"success": True,
|
||||
"message": f"Batch #{cur_num} ({cur_label.upper()}) stopped ({cur_count} {cur_label})",
|
||||
"message": f"Batch #{cur_num} stopped ({cur_count} items)",
|
||||
"batch_number": cur_num,
|
||||
"object_label": cur_label,
|
||||
"object_label": "mixed",
|
||||
"count": cur_count,
|
||||
"sack_count": cur_sack,
|
||||
"box_count": cur_box,
|
||||
"persisted": ok,
|
||||
"status": "stopped",
|
||||
})
|
||||
|
||||
+121
-68
@@ -20,6 +20,9 @@ from flask import Flask, render_template, jsonify, request, Response
|
||||
from werkzeug.serving import WSGIRequestHandler
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from batch_store import ensure_batch_schema
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@@ -90,38 +93,7 @@ def _ensure_db():
|
||||
from pathlib import Path
|
||||
Path(DB_PATH).parent.mkdir(parents=True, exist_ok=True)
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS batches (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
counting_date TEXT NOT NULL,
|
||||
batch_number INTEGER NOT NULL,
|
||||
camera_name TEXT NOT NULL,
|
||||
object_label TEXT NOT NULL,
|
||||
count INTEGER NOT NULL,
|
||||
start_time TEXT NOT NULL,
|
||||
end_time TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(counting_date, batch_number, camera_name, object_label)
|
||||
)
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS daily_summaries (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
counting_date TEXT NOT NULL,
|
||||
camera_name TEXT NOT NULL,
|
||||
object_label TEXT NOT NULL,
|
||||
total_count INTEGER NOT NULL DEFAULT 0,
|
||||
total_batches INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(counting_date, camera_name, object_label)
|
||||
)
|
||||
"""
|
||||
)
|
||||
conn.commit()
|
||||
ensure_batch_schema(conn)
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
print(f"[Warning] Could not initialize database at {DB_PATH}: {e}")
|
||||
@@ -197,15 +169,36 @@ def index():
|
||||
|
||||
def _normalize_obj_label(raw_label):
|
||||
val = str(raw_label or "").strip().lower()
|
||||
if val in ("mixed", "all", "both"):
|
||||
return "mixed"
|
||||
return "box" if val == "box" else "sack"
|
||||
|
||||
|
||||
def _separate_counts(raw_label, count, sack_count=None, box_count=None):
|
||||
"""Return separate class counts while remaining compatible with legacy rows."""
|
||||
total = int(count or 0)
|
||||
if sack_count is not None or box_count is not None:
|
||||
sacks = int(sack_count or 0)
|
||||
boxes = int(box_count or 0)
|
||||
elif _normalize_obj_label(raw_label) == "box":
|
||||
sacks, boxes = 0, total
|
||||
else:
|
||||
sacks, boxes = total, 0
|
||||
return sacks, boxes
|
||||
|
||||
|
||||
@app.route("/api/current-batch")
|
||||
def api_current_batch():
|
||||
cdate = get_counting_date()
|
||||
try:
|
||||
with open(CURRENT_BATCH_PATH, "r") as f:
|
||||
data = json.load(f)
|
||||
sack_count, box_count = _separate_counts(
|
||||
data.get("object_label"),
|
||||
data.get("count", 0),
|
||||
data.get("sack_count"),
|
||||
data.get("box_count"),
|
||||
)
|
||||
return jsonify(
|
||||
{
|
||||
"success": True,
|
||||
@@ -216,6 +209,8 @@ def api_current_batch():
|
||||
"batch_number": data.get("batch_number"),
|
||||
"object_label": _normalize_obj_label(data.get("object_label")),
|
||||
"count": data.get("count", 0),
|
||||
"sack_count": sack_count,
|
||||
"box_count": box_count,
|
||||
"start_time": data.get("start_time"),
|
||||
"last_detection_time": data.get("last_detection_time"),
|
||||
}
|
||||
@@ -230,6 +225,8 @@ def api_current_batch():
|
||||
"batch_mode": BATCH_MODE,
|
||||
"error": "No active batch",
|
||||
"count": 0,
|
||||
"sack_count": 0,
|
||||
"box_count": 0,
|
||||
"batch_number": None,
|
||||
"object_label": None,
|
||||
"next_batch_number": next_batch,
|
||||
@@ -246,6 +243,8 @@ def api_current_batch():
|
||||
"batch_mode": BATCH_MODE,
|
||||
"error": str(e),
|
||||
"count": 0,
|
||||
"sack_count": 0,
|
||||
"box_count": 0,
|
||||
"batch_number": None,
|
||||
"object_label": None,
|
||||
"next_batch_number": next_batch,
|
||||
@@ -257,11 +256,7 @@ def api_current_batch():
|
||||
@app.route("/api/batch/start", methods=["POST"])
|
||||
@app.route("/api/batch/start/<object_label>", methods=["POST"])
|
||||
def api_batch_start(object_label=None):
|
||||
if not object_label:
|
||||
body = request.get_json(silent=True) or {}
|
||||
object_label = body.get("object_label") or request.args.get("object_label") or "sack"
|
||||
obj_type = _normalize_obj_label(object_label)
|
||||
data, code = _send_counter_command(f"start/{obj_type}")
|
||||
data, code = _send_counter_command("start")
|
||||
return jsonify(data), code
|
||||
|
||||
|
||||
@@ -292,6 +287,12 @@ def api_batch_status():
|
||||
next_batch = get_next_batch_number_db(cdate)
|
||||
|
||||
if state_data:
|
||||
sack_count, box_count = _separate_counts(
|
||||
state_data.get("object_label"),
|
||||
state_data.get("count", 0),
|
||||
state_data.get("sack_count"),
|
||||
state_data.get("box_count"),
|
||||
)
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"active": True,
|
||||
@@ -300,6 +301,8 @@ def api_batch_status():
|
||||
"batch_number": state_data.get("batch_number"),
|
||||
"object_label": _normalize_obj_label(state_data.get("object_label")),
|
||||
"count": state_data.get("count", 0),
|
||||
"sack_count": sack_count,
|
||||
"box_count": box_count,
|
||||
"counting_date": state_data.get("counting_date", cdate),
|
||||
"start_time": state_data.get("start_time"),
|
||||
"last_detection_time": state_data.get("last_detection_time"),
|
||||
@@ -315,6 +318,8 @@ def api_batch_status():
|
||||
"object_label": None,
|
||||
"next_batch_number": next_batch,
|
||||
"count": 0,
|
||||
"sack_count": 0,
|
||||
"box_count": 0,
|
||||
"counting_date": cdate,
|
||||
"start_time": None,
|
||||
"last_detection_time": None,
|
||||
@@ -329,7 +334,8 @@ def api_previous_batch():
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT counting_date, batch_number, object_label, count, start_time, end_time,
|
||||
SELECT counting_date, batch_number, object_label, count, sack_count, box_count,
|
||||
start_time, end_time,
|
||||
ROUND((julianday(end_time) - julianday(start_time)) * 24 * 60, 1) as duration_minutes
|
||||
FROM batches
|
||||
ORDER BY end_time DESC
|
||||
@@ -339,6 +345,9 @@ def api_previous_batch():
|
||||
row = cur.fetchone()
|
||||
conn.close()
|
||||
if row:
|
||||
sack_count, box_count = _separate_counts(
|
||||
row["object_label"], row["count"], row["sack_count"], row["box_count"]
|
||||
)
|
||||
return jsonify(
|
||||
{
|
||||
"success": True,
|
||||
@@ -346,6 +355,8 @@ def api_previous_batch():
|
||||
"batch_number": row["batch_number"],
|
||||
"object_label": _normalize_obj_label(row["object_label"]),
|
||||
"count": row["count"],
|
||||
"sack_count": sack_count,
|
||||
"box_count": box_count,
|
||||
"start_time": row["start_time"],
|
||||
"end_time": row["end_time"],
|
||||
"duration_minutes": row["duration_minutes"],
|
||||
@@ -367,7 +378,9 @@ def api_summary():
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT COALESCE(SUM(total_count), 0) as total_count,
|
||||
COALESCE(SUM(total_batches), 0) as total_batches
|
||||
COALESCE(SUM(total_batches), 0) as total_batches,
|
||||
COALESCE(SUM(sack_count), 0) as sack_count,
|
||||
COALESCE(SUM(box_count), 0) as box_count
|
||||
FROM daily_summaries
|
||||
WHERE counting_date = ?
|
||||
""",
|
||||
@@ -378,7 +391,9 @@ def api_summary():
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT COALESCE(SUM(total_count), 0) as total_count,
|
||||
COALESCE(SUM(total_batches), 0) as total_batches
|
||||
COALESCE(SUM(total_batches), 0) as total_batches,
|
||||
COALESCE(SUM(sack_count), 0) as sack_count,
|
||||
COALESCE(SUM(box_count), 0) as box_count
|
||||
FROM daily_summaries
|
||||
WHERE counting_date = ?
|
||||
""",
|
||||
@@ -389,6 +404,8 @@ def api_summary():
|
||||
"""
|
||||
SELECT COALESCE(SUM(total_count), 0) as grand_total,
|
||||
COALESCE(SUM(total_batches), 0) as grand_batches,
|
||||
COALESCE(SUM(sack_count), 0) as sack_count,
|
||||
COALESCE(SUM(box_count), 0) as box_count,
|
||||
COUNT(DISTINCT counting_date) as total_days
|
||||
FROM daily_summaries
|
||||
"""
|
||||
@@ -422,16 +439,25 @@ def api_summary():
|
||||
"date": today,
|
||||
"total_count": today_row["total_count"] if today_row else 0,
|
||||
"total_batches": today_row["total_batches"] if today_row else 0,
|
||||
"count": today_row["total_count"] if today_row else 0,
|
||||
"sack_count": today_row["sack_count"] if today_row else 0,
|
||||
"box_count": today_row["box_count"] if today_row else 0,
|
||||
},
|
||||
"yesterday": {
|
||||
"date": yesterday,
|
||||
"total_count": yesterday_row["total_count"] if yesterday_row else 0,
|
||||
"total_batches": yesterday_row["total_batches"] if yesterday_row else 0,
|
||||
"count": yesterday_row["total_count"] if yesterday_row else 0,
|
||||
"sack_count": yesterday_row["sack_count"] if yesterday_row else 0,
|
||||
"box_count": yesterday_row["box_count"] if yesterday_row else 0,
|
||||
},
|
||||
"all_time": {
|
||||
"grand_total": all_time["grand_total"],
|
||||
"grand_batches": all_time["grand_batches"],
|
||||
"total_days": all_time["total_days"],
|
||||
"count": all_time["grand_total"],
|
||||
"sack_count": all_time["sack_count"],
|
||||
"box_count": all_time["box_count"],
|
||||
},
|
||||
"average_per_day": avg["avg_per_day"] or 0,
|
||||
"best_day": {
|
||||
@@ -490,7 +516,7 @@ def api_day_detail(date):
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT batch_number, object_label, count, start_time, end_time,
|
||||
SELECT batch_number, object_label, count, sack_count, box_count, start_time, end_time,
|
||||
ROUND((julianday(end_time) - julianday(start_time)) * 24 * 60, 1) as duration_minutes
|
||||
FROM batches
|
||||
WHERE counting_date = ?
|
||||
@@ -503,11 +529,16 @@ def api_day_detail(date):
|
||||
for row in cur.fetchall():
|
||||
duration = row["duration_minutes"] or 0
|
||||
total_duration += duration
|
||||
sack_count, box_count = _separate_counts(
|
||||
row["object_label"], row["count"], row["sack_count"], row["box_count"]
|
||||
)
|
||||
batches.append(
|
||||
{
|
||||
"batch_number": row["batch_number"],
|
||||
"object_label": _normalize_obj_label(row["object_label"]),
|
||||
"count": row["count"],
|
||||
"sack_count": sack_count,
|
||||
"box_count": box_count,
|
||||
"start_time": row["start_time"],
|
||||
"end_time": row["end_time"],
|
||||
"duration_minutes": duration,
|
||||
@@ -516,7 +547,9 @@ def api_day_detail(date):
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT COALESCE(SUM(total_count), 0) as total_count,
|
||||
COALESCE(SUM(total_batches), 0) as total_batches
|
||||
COALESCE(SUM(total_batches), 0) as total_batches,
|
||||
COALESCE(SUM(sack_count), 0) as sack_count,
|
||||
COALESCE(SUM(box_count), 0) as box_count
|
||||
FROM daily_summaries
|
||||
WHERE counting_date = ?
|
||||
""",
|
||||
@@ -529,13 +562,15 @@ def api_day_detail(date):
|
||||
"date": date,
|
||||
"total_count": summary["total_count"] if summary else 0,
|
||||
"total_batches": summary["total_batches"] if summary else 0,
|
||||
"sack_count": summary["sack_count"] if summary else 0,
|
||||
"box_count": summary["box_count"] if summary else 0,
|
||||
"total_duration_minutes": round(total_duration, 1),
|
||||
"avg_duration_minutes": round(total_duration / len(batches), 1) if batches else 0,
|
||||
"batches": batches,
|
||||
}
|
||||
)
|
||||
except sqlite3.OperationalError as e:
|
||||
return jsonify({"date": date, "total_count": 0, "total_batches": 0, "total_duration_minutes": 0, "avg_duration_minutes": 0, "batches": [], "error": f"Database unavailable: {e}"}), 200
|
||||
return jsonify({"date": date, "total_count": 0, "total_batches": 0, "sack_count": 0, "box_count": 0, "total_duration_minutes": 0, "avg_duration_minutes": 0, "batches": [], "error": f"Database unavailable: {e}"}), 200
|
||||
except Exception as e:
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@@ -548,7 +583,8 @@ def api_recent_batches():
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT counting_date, batch_number, object_label, count, start_time, end_time,
|
||||
SELECT counting_date, batch_number, object_label, count, sack_count, box_count,
|
||||
start_time, end_time,
|
||||
ROUND((julianday(end_time) - julianday(start_time)) * 24 * 60, 1) as duration_minutes
|
||||
FROM batches
|
||||
ORDER BY end_time DESC
|
||||
@@ -556,18 +592,24 @@ def api_recent_batches():
|
||||
""",
|
||||
(limit,),
|
||||
)
|
||||
batches = [
|
||||
{
|
||||
"date": row["counting_date"],
|
||||
"batch_number": row["batch_number"],
|
||||
"object_label": _normalize_obj_label(row["object_label"]),
|
||||
"count": row["count"],
|
||||
"start_time": row["start_time"],
|
||||
"end_time": row["end_time"],
|
||||
"duration_minutes": row["duration_minutes"] or 0,
|
||||
}
|
||||
for row in cur.fetchall()
|
||||
]
|
||||
batches = []
|
||||
for row in cur.fetchall():
|
||||
sack_count, box_count = _separate_counts(
|
||||
row["object_label"], row["count"], row["sack_count"], row["box_count"]
|
||||
)
|
||||
batches.append(
|
||||
{
|
||||
"date": row["counting_date"],
|
||||
"batch_number": row["batch_number"],
|
||||
"object_label": _normalize_obj_label(row["object_label"]),
|
||||
"count": row["count"],
|
||||
"sack_count": sack_count,
|
||||
"box_count": box_count,
|
||||
"start_time": row["start_time"],
|
||||
"end_time": row["end_time"],
|
||||
"duration_minutes": row["duration_minutes"] or 0,
|
||||
}
|
||||
)
|
||||
conn.close()
|
||||
return jsonify(batches)
|
||||
except sqlite3.OperationalError as e:
|
||||
@@ -653,7 +695,8 @@ def export_daily_xlsx():
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT counting_date, batch_number, object_label, count, start_time, end_time,
|
||||
SELECT counting_date, batch_number, object_label, count, sack_count, box_count,
|
||||
start_time, end_time,
|
||||
ROUND((julianday(end_time) - julianday(start_time)) * 24 * 60, 1) as duration_minutes
|
||||
FROM batches
|
||||
WHERE counting_date >= ?
|
||||
@@ -671,16 +714,21 @@ def export_daily_xlsx():
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "Batch Details"
|
||||
_style_header(ws, [("A", "Date"), ("B", "Batch #"), ("C", "Type"), ("D", "Count"), ("E", "Start Time"), ("F", "End Time"), ("G", "Duration (min)")])
|
||||
_style_header(ws, [("A", "Date"), ("B", "Batch #"), ("C", "Type"), ("D", "Sack"), ("E", "Box"), ("F", "Total"), ("G", "Start Time"), ("H", "End Time"), ("I", "Duration (min)")])
|
||||
|
||||
for r_idx, row in enumerate(rows, 2):
|
||||
sack_count, box_count = _separate_counts(
|
||||
row["object_label"], row["count"], row["sack_count"], row["box_count"]
|
||||
)
|
||||
ws.cell(row=r_idx, column=1, value=row["counting_date"])
|
||||
ws.cell(row=r_idx, column=2, value=row["batch_number"])
|
||||
ws.cell(row=r_idx, column=3, value=_normalize_obj_label(row["object_label"]).upper())
|
||||
ws.cell(row=r_idx, column=4, value=row["count"])
|
||||
ws.cell(row=r_idx, column=5, value=row["start_time"])
|
||||
ws.cell(row=r_idx, column=6, value=row["end_time"])
|
||||
ws.cell(row=r_idx, column=7, value=row["duration_minutes"] or 0)
|
||||
ws.cell(row=r_idx, column=4, value=sack_count)
|
||||
ws.cell(row=r_idx, column=5, value=box_count)
|
||||
ws.cell(row=r_idx, column=6, value=row["count"])
|
||||
ws.cell(row=r_idx, column=7, value=row["start_time"])
|
||||
ws.cell(row=r_idx, column=8, value=row["end_time"])
|
||||
ws.cell(row=r_idx, column=9, value=row["duration_minutes"] or 0)
|
||||
|
||||
_auto_width(ws)
|
||||
filename = f"{SITE_NAME}_daily_records_{datetime.now().strftime('%Y%m%d_%H%M%S')}.xlsx"
|
||||
@@ -694,7 +742,7 @@ def export_day_xlsx(date):
|
||||
cur = conn.cursor()
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT batch_number, object_label, count, start_time, end_time,
|
||||
SELECT batch_number, object_label, count, sack_count, box_count, start_time, end_time,
|
||||
ROUND((julianday(end_time) - julianday(start_time)) * 24 * 60, 1) as duration_minutes
|
||||
FROM batches
|
||||
WHERE counting_date = ?
|
||||
@@ -712,15 +760,20 @@ def export_day_xlsx(date):
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.title = f"Day {date}"
|
||||
_style_header(ws, [("A", "Batch Number"), ("B", "Type"), ("C", "Count"), ("D", "Start Time"), ("E", "End Time"), ("F", "Duration (min)")])
|
||||
_style_header(ws, [("A", "Batch Number"), ("B", "Type"), ("C", "Sack"), ("D", "Box"), ("E", "Total"), ("F", "Start Time"), ("G", "End Time"), ("H", "Duration (min)")])
|
||||
|
||||
for r_idx, row in enumerate(rows, 2):
|
||||
sack_count, box_count = _separate_counts(
|
||||
row["object_label"], row["count"], row["sack_count"], row["box_count"]
|
||||
)
|
||||
ws.cell(row=r_idx, column=1, value=row["batch_number"])
|
||||
ws.cell(row=r_idx, column=2, value=_normalize_obj_label(row["object_label"]).upper())
|
||||
ws.cell(row=r_idx, column=3, value=row["count"])
|
||||
ws.cell(row=r_idx, column=4, value=row["start_time"])
|
||||
ws.cell(row=r_idx, column=5, value=row["end_time"])
|
||||
ws.cell(row=r_idx, column=6, value=row["duration_minutes"] or 0)
|
||||
ws.cell(row=r_idx, column=3, value=sack_count)
|
||||
ws.cell(row=r_idx, column=4, value=box_count)
|
||||
ws.cell(row=r_idx, column=5, value=row["count"])
|
||||
ws.cell(row=r_idx, column=6, value=row["start_time"])
|
||||
ws.cell(row=r_idx, column=7, value=row["end_time"])
|
||||
ws.cell(row=r_idx, column=8, value=row["duration_minutes"] or 0)
|
||||
|
||||
_auto_width(ws)
|
||||
filename = f"{SITE_NAME}_day_detail_{date}.xlsx"
|
||||
|
||||
@@ -727,8 +727,6 @@ class RKNNYOLO:
|
||||
|
||||
if is_obb:
|
||||
obb_corners = _xywhr_to_corners(cx, cy, bw, bh, angles)
|
||||
obb_corners[:, :, 0] = np.clip(obb_corners[:, :, 0], 0, w0)
|
||||
obb_corners[:, :, 1] = np.clip(obb_corners[:, :, 1], 0, h0)
|
||||
bboxes = np.stack(
|
||||
[
|
||||
obb_corners[:, :, 0].min(axis=1),
|
||||
@@ -1535,12 +1533,14 @@ def run():
|
||||
d for d in detections if d["cls"] == truck_cls and d["score"] >= TRUCK_CONF
|
||||
]
|
||||
|
||||
zone_truck = None
|
||||
if ZONE_MODE in {"manual", "fixed"}:
|
||||
zone_x1, zone_x2 = manual_x1, manual_x2
|
||||
zone_source = "MANUAL"
|
||||
else:
|
||||
if truck_dets:
|
||||
best_truck = max(truck_dets, key=lambda d: d["score"])
|
||||
zone_truck = best_truck
|
||||
tb = best_truck["bbox"]
|
||||
tx1 = max(0, int(tb[0]) - TRUCK_ZONE_PAD_X)
|
||||
tx2 = min(w, int(tb[2]) + TRUCK_ZONE_PAD_X)
|
||||
@@ -1572,6 +1572,9 @@ def run():
|
||||
|
||||
for tdet in truck_dets:
|
||||
tb = tdet["bbox"]
|
||||
tcx = (tb[0] + tb[2]) / 2.0
|
||||
if tdet is not zone_truck and not (zone_x1 <= tcx <= zone_x2):
|
||||
continue
|
||||
tx1, ty1, tx2, ty2 = int(tb[0]), int(tb[1]), int(tb[2]), int(tb[3])
|
||||
t_color = (255, 200, 0)
|
||||
t_obb = tdet.get("obb")
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
# Unified Batch Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Replace separate Sack and Box batch starts with one unified batch that records separate Sack and Box totals.
|
||||
|
||||
**Architecture:** Keep one row per batch. Add `sack_count` and `box_count` to batch state, `batches`, and `daily_summaries`, while retaining `count` as the total for API compatibility. New batches use `object_label = mixed` and accept crossings from both counted classes.
|
||||
|
||||
**Tech Stack:** Python 3.12, Flask, SQLite, Jinja template, vanilla JavaScript, stdlib `unittest`, openpyxl
|
||||
|
||||
**Spec:** `docs/superpowers/specs/2026-11-13-unified-batch-design.md`
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Do not add dependencies. Use stdlib `unittest` for tests.
|
||||
- Keep `count` equal to `sack_count + box_count` in every batch and API response.
|
||||
- Persist one database row per unified batch.
|
||||
- Preserve existing Sack and Box history, totals, batch numbers, and cutoff behavior.
|
||||
- Keep legacy start URLs working as aliases for unified start.
|
||||
- Preserve current dashboard visual system and responsive behavior.
|
||||
- This directory is not a Git repository, so use test checkpoints instead of commit steps.
|
||||
|
||||
## Review Focus
|
||||
|
||||
- Legacy active state: old Sack or Box count must survive resume and the batch must accept both classes afterward.
|
||||
- Same numeric track ID for different classes: one Sack and one Box must both count.
|
||||
- Legacy database rows: total counts must remain unchanged after separate-count backfill.
|
||||
- API compatibility: existing `count` field must remain the combined total.
|
||||
- Empty manual batch: it must create no batch row and must not increment daily batch totals.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Unified batch state and persistence
|
||||
|
||||
**Files:**
|
||||
- Create: `tests/test_batch_store.py`
|
||||
- Modify: `batch_store.py`
|
||||
|
||||
**Interfaces:**
|
||||
- Produces: `ensure_batch_schema(conn: sqlite3.Connection) -> None`
|
||||
- Produces: `BatchStore.start_new_batch(counting_date: str | None = None, object_label: str | None = None) -> int`
|
||||
- Produces: `BatchStore.get_status() -> dict` with `count`, `sack_count`, and `box_count`
|
||||
- Produces: batch rows using `object_label = "mixed"` and columns `sack_count`, `box_count`
|
||||
|
||||
- [ ] **Step 1: Write failing store tests**
|
||||
|
||||
Create `tests/test_batch_store.py` with `unittest`, `tempfile.TemporaryDirectory`, and isolated SQLite paths. Add tests named:
|
||||
|
||||
```python
|
||||
def test_mixed_batch_counts_sacks_and_boxes_separately(self):
|
||||
store = self.make_store()
|
||||
store.start_new_batch()
|
||||
store.record_counted_object_crossing(1, object_label="sack")
|
||||
store.record_counted_object_crossing(2, object_label="box")
|
||||
status = store.get_status()
|
||||
self.assertEqual(status["count"], 2)
|
||||
self.assertEqual(status["sack_count"], 1)
|
||||
self.assertEqual(status["box_count"], 1)
|
||||
```
|
||||
|
||||
Also cover:
|
||||
|
||||
- Same track ID once per class counts twice.
|
||||
- Legacy JSON state with `object_label = "sack"` and `count = 4` resumes as mixed with Sack 4, Box 0, total 4.
|
||||
- Legacy SQLite rows backfill `sack_count` or `box_count` without changing `total_count`.
|
||||
- One mixed batch row persists with total 2, Sack 1, Box 1.
|
||||
- Mixed daily summary persists total 2, Sack 1, Box 1, and `total_batches = 1`.
|
||||
- Empty manual batch persists no batch row and creates no daily summary.
|
||||
|
||||
- [ ] **Step 2: Run store tests and verify failure**
|
||||
|
||||
Run: `venv/bin/python -m unittest tests/test_batch_store.py -v`
|
||||
|
||||
Expected: FAIL because `sack_count`, `box_count`, and unified state do not exist.
|
||||
|
||||
- [ ] **Step 3: Add schema creation and migration**
|
||||
|
||||
In `batch_store.py`, add `ensure_batch_schema(conn)` that:
|
||||
|
||||
1. Creates `batches` and `daily_summaries` when absent.
|
||||
2. Adds `sack_count INTEGER NOT NULL DEFAULT 0` and `box_count INTEGER NOT NULL DEFAULT 0` to both tables when absent.
|
||||
3. Backfills legacy `daily_summaries.object_label = 'sack'` rows into `sack_count`, and legacy Box rows into `box_count`.
|
||||
4. Leaves `total_count`, `total_batches`, and existing rows unchanged.
|
||||
|
||||
Use `PRAGMA table_info(table_name)` to inspect columns before each `ALTER TABLE`. Call `ensure_batch_schema(self.db)` from `BatchStore._init_db()` and commit once.
|
||||
|
||||
- [ ] **Step 4: Upgrade batch state and counting**
|
||||
|
||||
In `batch_store.py`:
|
||||
|
||||
1. Add mixed-label normalization for `mixed`, `all`, and `both`.
|
||||
2. In `_load_state()`, convert legacy active state to `object_label = 'mixed'`, preserve legacy count in the matching class counter, and derive total from both counters.
|
||||
3. In `start_new_batch()`, always create a mixed batch with `count`, `sack_count`, and `box_count` initialized to zero.
|
||||
4. In `record_counted_object_crossing()`, remove the active-label type lock, normalize detected item to Sack or Box, increment that class counter and total, and use an event key containing both class and track ID.
|
||||
5. Keep manual mode behavior unchanged: crossings while no batch is active return `(0, False)`.
|
||||
|
||||
- [ ] **Step 5: Persist separate counters**
|
||||
|
||||
Change `_insert_batch()` to accept `sack_count` and `box_count`, insert both columns, and write one mixed `daily_summaries` row. Upsert `total_count`, `total_batches`, `sack_count`, and `box_count` independently.
|
||||
|
||||
Update `_end_batch_locked()` and cutoff finalization to pass the two counters.
|
||||
|
||||
- [ ] **Step 6: Run store tests**
|
||||
|
||||
Run: `venv/bin/python -m unittest tests/test_batch_store.py -v`
|
||||
|
||||
Expected: all store tests PASS.
|
||||
|
||||
- [ ] **Step 7: Checkpoint**
|
||||
|
||||
Run: `venv/bin/python -m py_compile batch_store.py tests/test_batch_store.py`
|
||||
|
||||
Expected: exit code 0.
|
||||
|
||||
---
|
||||
|
||||
### Task 2: Unified control and dashboard APIs
|
||||
|
||||
**Files:**
|
||||
- Create: `tests/test_dashboard.py`
|
||||
- Modify: `counter_control.py`
|
||||
- Modify: `counter_dashboard.py`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `BatchStore.get_status()` fields `count`, `sack_count`, `box_count`
|
||||
- Produces: `POST /api/batch/start` calls counter command `start` without a class suffix
|
||||
- Produces: batch-related JSON responses include `sack_count` and `box_count`
|
||||
|
||||
- [ ] **Step 1: Write failing API tests**
|
||||
|
||||
Create `tests/test_dashboard.py` with Flask test client, temporary database, and `unittest.mock.patch`. Add tests named:
|
||||
|
||||
```python
|
||||
def test_start_endpoint_sends_unified_start_command(self):
|
||||
with patch("counter_dashboard._send_counter_command", return_value=({"success": True, "batch_number": 1}, 200)) as send:
|
||||
response = self.client.post("/api/batch/start")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
send.assert_called_once_with("start")
|
||||
```
|
||||
|
||||
Also cover:
|
||||
|
||||
- `/api/current-batch` returns saved mixed-state Sack and Box counts.
|
||||
- `/api/summary` returns separate today Sack and Box totals.
|
||||
- `/api/day-detail/<date>` returns separate counts for a mixed batch.
|
||||
- `/api/recent-batches` returns separate counts.
|
||||
- `/api/previous-batch` returns separate counts.
|
||||
- Legacy `POST /api/batch/start/sack` and `/api/batch/start/box` also send unified `start`.
|
||||
- Response `count` equals `sack_count + box_count`.
|
||||
|
||||
- [ ] **Step 2: Run API tests and verify failure**
|
||||
|
||||
Run: `venv/bin/python -m unittest tests/test_dashboard.py -v`
|
||||
|
||||
Expected: FAIL because start routes still use class suffixes and responses lack separate counters.
|
||||
|
||||
- [ ] **Step 3: Make control server start unified batches**
|
||||
|
||||
In `counter_control.py`, keep all existing start paths for compatibility, but call `start_new_batch()` without a class argument. Return `object_label = "mixed"` and include `sack_count`, `box_count`, and total `count` in start and stop responses.
|
||||
|
||||
- [ ] **Step 4: Update dashboard schema initialization**
|
||||
|
||||
Import and call `ensure_batch_schema(conn)` from `counter_dashboard._ensure_db()` instead of maintaining duplicate table definitions.
|
||||
|
||||
- [ ] **Step 5: Add separate counts to dashboard APIs**
|
||||
|
||||
In `counter_dashboard.py`:
|
||||
|
||||
1. Preserve `mixed` during object-label normalization.
|
||||
2. Make `/api/batch/start` and both legacy class routes call `_send_counter_command("start")`.
|
||||
3. Add `sack_count` and `box_count` to current-batch, batch-status fallback, previous-batch, day-detail, and recent-batch responses.
|
||||
4. Add `sack_count` and `box_count` to today, yesterday, and all-time summary objects.
|
||||
5. Select the new columns in every batch query.
|
||||
6. Keep `count` and existing aggregate total fields unchanged.
|
||||
|
||||
- [ ] **Step 6: Run API and store tests**
|
||||
|
||||
Run: `venv/bin/python -m unittest discover -s tests -v`
|
||||
|
||||
Expected: all current tests PASS.
|
||||
|
||||
- [ ] **Step 7: Checkpoint**
|
||||
|
||||
Run: `venv/bin/python -m py_compile counter_control.py counter_dashboard.py tests/test_dashboard.py`
|
||||
|
||||
Expected: exit code 0.
|
||||
|
||||
---
|
||||
|
||||
### Task 3: Dashboard UI and exports
|
||||
|
||||
**Files:**
|
||||
- Modify: `templates/dashboard.html`
|
||||
- Modify: `counter_dashboard.py`
|
||||
- Test: `tests/test_dashboard.py`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: API fields `count`, `sack_count`, `box_count`, and `object_label = mixed`
|
||||
- Produces: DOM IDs `btnBatchStart`, `live-sack-count`, `live-box-count`, `today-sack-count`, `today-box-count`, `modalStopBatchSackCount`, and `modalStopBatchBoxCount`
|
||||
|
||||
- [ ] **Step 1: Write failing dashboard rendering tests**
|
||||
|
||||
Add Flask client tests that render `/` and assert:
|
||||
|
||||
```python
|
||||
html = self.client.get("/").get_data(as_text=True)
|
||||
self.assertIn('id="btnBatchStart"', html)
|
||||
self.assertNotIn('id="btnBatchStartSack"', html)
|
||||
self.assertNotIn('id="btnBatchStartBox"', html)
|
||||
self.assertIn('id="live-sack-count"', html)
|
||||
self.assertIn('id="live-box-count"', html)
|
||||
```
|
||||
|
||||
Also assert exports expose separate Sack and Box columns by reading returned XLSX with `openpyxl.load_workbook`.
|
||||
|
||||
- [ ] **Step 2: Run rendering tests and verify failure**
|
||||
|
||||
Run: `venv/bin/python -m unittest tests/test_dashboard.py -v`
|
||||
|
||||
Expected: FAIL because two start buttons and separate-count export columns do not exist.
|
||||
|
||||
- [ ] **Step 3: Replace both start controls**
|
||||
|
||||
In `templates/dashboard.html`, replace both buttons with one green button:
|
||||
|
||||
```html
|
||||
<button class="btn-batch btn-batch-start" id="btnBatchStart" type="button" onclick="handleStartBatch()">
|
||||
<i class="fas fa-play"></i> START BATCH <span id="lblNextBatch">#1</span>
|
||||
</button>
|
||||
```
|
||||
|
||||
Remove `btn-batch-start-box` CSS. Keep the existing control-bar layout and touch target size.
|
||||
|
||||
- [ ] **Step 4: Show separate live and daily totals**
|
||||
|
||||
Add a secondary breakdown row under the active batch total with Sack and Box values. Keep combined total as primary metric. Add Sack and Box values under today's combined total.
|
||||
|
||||
Use existing CSS variables and muted-text treatment so hierarchy remains clear. Update JavaScript to populate new IDs from API fields and reset them to zero when idle.
|
||||
|
||||
- [ ] **Step 5: Update control-bar copy and behavior**
|
||||
|
||||
Change active and idle copy from class-specific wording to one batch counting both classes. Change `handleStartBatch()` to disable one button, call `POST /api/batch/start`, and show a combined-batch toast.
|
||||
|
||||
Update stop confirmation to display total, Sack, and Box counts separately.
|
||||
|
||||
- [ ] **Step 6: Update history and day-detail rendering**
|
||||
|
||||
Render new mixed batches with both counts. Keep legacy rows labeled Sack or Box readable. Replace type-based batch totals in the day-detail footer with counts of mixed, legacy Sack, and legacy Box rows without double counting.
|
||||
|
||||
- [ ] **Step 7: Update Excel exports**
|
||||
|
||||
In both export endpoints, select `sack_count` and `box_count`. Replace generic Type and Count columns with Sack, Box, and Total columns. Legacy rows use their stored class count for the matching column and zero for the other.
|
||||
|
||||
- [ ] **Step 8: Run dashboard and full tests**
|
||||
|
||||
Run: `venv/bin/python -m unittest discover -s tests -v`
|
||||
|
||||
Expected: all tests PASS.
|
||||
|
||||
- [ ] **Step 9: Run app smoke checks**
|
||||
|
||||
Run with temporary environment values:
|
||||
|
||||
```bash
|
||||
DB_PATH=/tmp/opencode/feedmill-test.db \
|
||||
CURRENT_BATCH_PATH=/tmp/opencode/feedmill-state.json \
|
||||
FLASK_APP=counter_dashboard.py \
|
||||
venv/bin/python -m flask --app counter_dashboard.py routes
|
||||
```
|
||||
|
||||
Expected: `/`, `/api/batch/start`, `/api/current-batch`, and `/api/summary` appear in route output.
|
||||
|
||||
Start the dashboard on an unused local port, request `/`, `/api/current-batch`, and `/api/summary`, then stop it. Expected: HTTP 200 responses and no template, JSON, or database errors.
|
||||
|
||||
---
|
||||
|
||||
### Task 4: Documentation and final verification
|
||||
|
||||
**Files:**
|
||||
- Modify: `API.md`
|
||||
- Modify: `README.md`
|
||||
- Modify: `docs/superpowers/specs/2026-11-13-unified-batch-design.md`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: final API response shapes and user-visible behavior
|
||||
- Produces: documentation matching unified start and separate totals
|
||||
|
||||
- [ ] **Step 1: Update API documentation**
|
||||
|
||||
Document unified `POST /api/batch/start`, legacy start aliases, `object_label = mixed`, `sack_count`, `box_count`, and `count` as total. Update current-batch and summary examples.
|
||||
|
||||
- [ ] **Step 2: Update operator documentation**
|
||||
|
||||
Replace references to choosing Start Sack or Start Box with one Start Batch action. Explain that each batch contains separate Sack and Box totals while the batch number and lifecycle are shared.
|
||||
|
||||
- [ ] **Step 3: Mark design implementation status**
|
||||
|
||||
Append a short implementation note to the design document naming completed files and verification commands. Do not change approved design decisions.
|
||||
|
||||
- [ ] **Step 4: Run complete verification**
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
venv/bin/python -m unittest discover -s tests -v
|
||||
venv/bin/python -m py_compile batch_store.py counter_control.py counter_dashboard.py tests/test_batch_store.py tests/test_dashboard.py
|
||||
```
|
||||
|
||||
Expected: all tests PASS and compilation exits 0.
|
||||
|
||||
Start dashboard with temporary DB and state paths. Exercise:
|
||||
|
||||
1. `GET /` renders one START BATCH button.
|
||||
2. `POST /api/batch/start` reaches the unified start command.
|
||||
3. `GET /api/current-batch` returns total, Sack, and Box fields.
|
||||
4. `GET /api/summary` returns separate totals.
|
||||
5. Day-detail and both XLSX exports include Sack and Box values.
|
||||
|
||||
Expected: no server errors, template errors, or schema errors.
|
||||
|
||||
- [ ] **Step 5: Checkpoint**
|
||||
|
||||
List changed files and summarize test output. Do not claim completion unless the recorded commands pass.
|
||||
@@ -0,0 +1,102 @@
|
||||
# Unified Batch Design
|
||||
|
||||
## Intent
|
||||
|
||||
Replace separate `START SACK` and `START BOX` actions with one `START BATCH` action. Each batch counts sacks and boxes together while preserving separate Sack and Box totals.
|
||||
|
||||
## Goals
|
||||
|
||||
- One visible Start Batch control.
|
||||
- One batch ID and one Start/Stop lifecycle for both object classes.
|
||||
- Separate live, daily, history, and export totals for Sack and Box.
|
||||
- Preserve existing batch history and totals.
|
||||
- Keep existing API consumers working where practical.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- Redesign dashboard visual style.
|
||||
- Change object detection, confidence, tracking, or line-crossing logic.
|
||||
- Change batch numbering or daily cutoff behavior.
|
||||
|
||||
## Constraints
|
||||
|
||||
- Current `batches` table stores one count and one object label per row.
|
||||
- Current `daily_summaries` table stores totals by object label.
|
||||
- Existing records use `sack` or `box` labels and must remain readable.
|
||||
- Active batch state persists as JSON and must resume safely.
|
||||
|
||||
## Approaches considered
|
||||
|
||||
### 1. One batch row with separate counters, selected
|
||||
|
||||
Add `sack_count` and `box_count` to `batches` and `daily_summaries`. Keep `count` as total count for compatibility. New batches use `object_label = mixed`. API responses add `sack_count` and `box_count` while keeping `count` as total.
|
||||
|
||||
This gives one clean batch row, correct batch totals, and separate class totals.
|
||||
|
||||
### 2. Two rows per batch
|
||||
|
||||
Insert one Sack row and one Box row for each batch. This avoids schema changes but creates duplicate history entries and incorrect batch counts.
|
||||
|
||||
Rejected.
|
||||
|
||||
### 3. UI-only button merge
|
||||
|
||||
Keep the type-locked backend and expose one button. This cannot provide separate Sack and Box totals inside one batch.
|
||||
|
||||
Rejected.
|
||||
|
||||
## Design
|
||||
|
||||
### Batch state and counting
|
||||
|
||||
- `BatchStore.start_new_batch()` creates one mixed batch.
|
||||
- State stores `sack_count`, `box_count`, and total `count`.
|
||||
- `record_counted_object_crossing()` increments the matching class counter and total.
|
||||
- Both counted class IDs remain eligible while a batch is active.
|
||||
- Legacy active state converts safely: old Sack count becomes `sack_count`, old Box count becomes `box_count`.
|
||||
- Manual start aliases (`/start/sack`, `/start/box`) map to the same unified batch start behavior.
|
||||
|
||||
### Persistence
|
||||
|
||||
- Migrate `batches` with `sack_count INTEGER NOT NULL DEFAULT 0` and `box_count INTEGER NOT NULL DEFAULT 0`.
|
||||
- Migrate `daily_summaries` with the same fields.
|
||||
- Backfill legacy summary rows from `object_label` and `total_count`.
|
||||
- New mixed batch persists one row, increments overall total once, and updates both class totals.
|
||||
- Existing rows remain unchanged except backfilled compatibility fields.
|
||||
|
||||
### Dashboard
|
||||
|
||||
- Replace two Start buttons with one `START BATCH` button.
|
||||
- Active batch card shows total count plus separate Sack and Box counts.
|
||||
- Stop confirmation shows separate Sack and Box totals.
|
||||
- Today summary shows separate Sack and Box totals below combined total.
|
||||
- Recent batch and day-detail views show separate Sack and Box counts.
|
||||
- Existing visual system stays unchanged.
|
||||
|
||||
### APIs and exports
|
||||
|
||||
- Batch status, current batch, day detail, recent batches, previous batch, and summary responses add `sack_count` and `box_count`.
|
||||
- `count` remains total count for backward compatibility.
|
||||
- Excel exports add separate Sack and Box columns.
|
||||
- API documentation updates examples and endpoint behavior.
|
||||
|
||||
## Verification
|
||||
|
||||
- Unit tests cover mixed counting, persistence, migration, and API response fields.
|
||||
- Flask test client checks unified start behavior and dashboard rendering.
|
||||
- Python compilation and test suite run after changes.
|
||||
- Dashboard starts locally without template or API errors.
|
||||
|
||||
## Implementation status
|
||||
|
||||
Implemented 2026-11-13.
|
||||
|
||||
Changed files:
|
||||
- `batch_store.py`: `ensure_batch_schema()` migration, mixed active state, unified `start_new_batch()`, separate class counters, one mixed batch row and one mixed daily summary row.
|
||||
- `counter_control.py`: unified `start` aliases, stop response with total, Sack, Box counts.
|
||||
- `counter_dashboard.py`: unified start routes, `sack_count`/`box_count` in current-batch, batch-status fallback, previous-batch, day-detail, recent-batches, summary; XLSX exports now carry Sack, Box, Total columns.
|
||||
- `templates/dashboard.html`: one `START BATCH` button, live and today Sack/Box breakdown, stop modal totals, recent and day-detail rendering with both counts.
|
||||
- `API.md`, `README.md`: updated endpoint behavior and operator instructions.
|
||||
- `tests/test_batch_store.py`, `tests/test_dashboard.py`: store, API, control, rendering, and export coverage.
|
||||
|
||||
Verification: `venv/bin/python -m unittest discover -s tests -v` (19 tests) passes, `venv/bin/python -m py_compile batch_store.py counter_control.py counter_dashboard.py tests/test_batch_store.py tests/test_dashboard.py` exits 0, and the dashboard serves `/`, `/api/current-batch`, `/api/summary`, `/api/batch/status` with HTTP 200 against a temporary database.
|
||||
BIN
Binary file not shown.
+119
-72
@@ -265,6 +265,12 @@
|
||||
.bc-sub-info {
|
||||
font-size: 12px; color: var(--text-muted);
|
||||
}
|
||||
.bc-info-row {
|
||||
display: flex; flex-direction: column; gap: 2px;
|
||||
}
|
||||
.recent-breakdown {
|
||||
font-size: 11px; color: var(--text-muted); font-family: var(--mono);
|
||||
}
|
||||
.bc-right {
|
||||
display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
|
||||
}
|
||||
@@ -287,14 +293,6 @@
|
||||
filter: brightness(1.08);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.btn-batch-start-box {
|
||||
background: var(--blue-btn);
|
||||
color: #fff;
|
||||
}
|
||||
.btn-batch-start-box:hover:not(:disabled) {
|
||||
filter: brightness(1.08);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.btn-batch-stop {
|
||||
background: #ef4444;
|
||||
color: #fff;
|
||||
@@ -316,6 +314,10 @@
|
||||
background: var(--yellow-bg); color: var(--yellow);
|
||||
border: 1px solid var(--yellow);
|
||||
}
|
||||
.type-pill.mixed {
|
||||
background: var(--blue-btn-bg, rgba(22,130,178,0.14)); color: var(--blue-btn);
|
||||
border: 1px solid var(--blue-btn);
|
||||
}
|
||||
|
||||
/* ── Summary cards ── */
|
||||
.summary-row {
|
||||
@@ -365,6 +367,7 @@
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.stat-meta-val { font-family: var(--mono); font-size: 16px; font-weight: 700; }
|
||||
.stat-breakdown { display: flex; gap: 24px; }
|
||||
|
||||
/* ── Monitor row ── */
|
||||
.monitor-wrap {
|
||||
@@ -794,7 +797,9 @@
|
||||
.modal-table th:nth-child(4), .modal-table td:nth-child(4),
|
||||
.modal-table th:nth-child(5), .modal-table td:nth-child(5) { width: 15%; }
|
||||
.modal-table th:nth-child(6), .modal-table td:nth-child(6) { width: 13%; }
|
||||
.modal-table th:nth-child(7), .modal-table td:nth-child(7) { width: 12%; }
|
||||
.modal-table th:nth-child(7), .modal-table td:nth-child(7) { width: 11%; }
|
||||
.modal-table th:nth-child(8), .modal-table td:nth-child(8) { width: 11%; }
|
||||
.modal-table th:nth-child(9), .modal-table td:nth-child(9) { width: 11%; }
|
||||
.modal-table .mono { font-family: var(--mono); font-weight: 600; }
|
||||
.modal-empty {
|
||||
color: var(--text-muted); font-size: 12px; padding: 16px; text-align: center;
|
||||
@@ -900,15 +905,12 @@
|
||||
</div>
|
||||
<div class="bc-info-row">
|
||||
<div class="bc-main-info" id="bcMainInfo">Sistem Siap Menghitung</div>
|
||||
<div class="bc-sub-info" id="bcSubInfo">Pilih "Start Sack" atau "Start Box" untuk mulai menghitung batch.</div>
|
||||
<div class="bc-sub-info" id="bcSubInfo">Sistem idle. Klik "Start Batch" untuk menghitung karung dan box sekaligus.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bc-right">
|
||||
<button class="btn-batch btn-batch-start" id="btnBatchStartSack" type="button" onclick="handleStartBatch('sack')">
|
||||
<i class="fas fa-play"></i> START SACK <span id="lblNextBatchSack">#1</span>
|
||||
</button>
|
||||
<button class="btn-batch btn-batch-start-box" id="btnBatchStartBox" type="button" onclick="handleStartBatch('box')">
|
||||
<i class="fas fa-box"></i> START BOX <span id="lblNextBatchBox">#1</span>
|
||||
<button class="btn-batch btn-batch-start" id="btnBatchStart" type="button" onclick="handleStartBatch()">
|
||||
<i class="fas fa-play"></i> START BATCH <span id="lblNextBatch">#1</span>
|
||||
</button>
|
||||
<button class="btn-batch btn-batch-stop" id="btnBatchStop" type="button" style="display:none;" onclick="handleStopBatch()">
|
||||
<i class="fas fa-stop"></i> STOP BATCH <span id="lblCurrBatch">#1</span>
|
||||
@@ -925,7 +927,18 @@
|
||||
</div>
|
||||
<div class="stat-big-row">
|
||||
<span class="stat-big" id="live-count">--</span>
|
||||
<span class="stat-unit" id="live-unit">Karung</span>
|
||||
<span class="stat-unit" id="live-unit">Total</span>
|
||||
</div>
|
||||
<hr class="stat-divider">
|
||||
<div class="stat-breakdown">
|
||||
<div class="stat-meta">
|
||||
<span class="stat-meta-label">karung</span>
|
||||
<span class="stat-meta-val" id="live-sack-count">0</span>
|
||||
</div>
|
||||
<div class="stat-meta">
|
||||
<span class="stat-meta-label">box</span>
|
||||
<span class="stat-meta-val" id="live-box-count">0</span>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="stat-divider">
|
||||
<div class="stat-meta-row">
|
||||
@@ -948,6 +961,17 @@
|
||||
<span class="stat-trend-badge" id="today-trend">--</span>
|
||||
</div>
|
||||
<hr class="stat-divider">
|
||||
<div class="stat-breakdown">
|
||||
<div class="stat-meta">
|
||||
<span class="stat-meta-label">karung</span>
|
||||
<span class="stat-meta-val" id="today-sack-count">0</span>
|
||||
</div>
|
||||
<div class="stat-meta">
|
||||
<span class="stat-meta-label">box</span>
|
||||
<span class="stat-meta-val" id="today-box-count">0</span>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="stat-divider">
|
||||
<div class="stat-meta">
|
||||
<span class="stat-meta-label">jumlah batch</span>
|
||||
<span class="stat-meta-val" id="today-batches">-- batch hari ini</span>
|
||||
@@ -993,8 +1017,8 @@
|
||||
<div class="side-stack">
|
||||
<div class="side-card">
|
||||
<div class="side-card-title">akurasi data stream</div>
|
||||
<div class="acc-bar"><div class="acc-fill" id="accuracy-fill" style="width:{{ stream_accuracy | default('98') }}%"></div></div>
|
||||
<div class="acc-hint">Konfidensi {{ stream_accuracy | default('98') }}% · Terakhir diupdate <span id="acc-updated">--</span></div>
|
||||
<div class="acc-bar"><div class="acc-fill" id="accuracy-fill" data-accuracy="{{ stream_accuracy }}"></div></div>
|
||||
<div class="acc-hint">Konfidensi {{ stream_accuracy }}% · Terakhir diupdate <span id="acc-updated">--</span></div>
|
||||
</div>
|
||||
<div class="side-card">
|
||||
<div class="side-card-title">keterangan deteksi</div>
|
||||
@@ -1157,6 +1181,8 @@
|
||||
<tr>
|
||||
<th>Batch #</th>
|
||||
<th>Tipe</th>
|
||||
<th>Sack</th>
|
||||
<th>Box</th>
|
||||
<th>Total</th>
|
||||
<th>Mulai</th>
|
||||
<th>Selesai</th>
|
||||
@@ -1188,6 +1214,14 @@
|
||||
<span id="modalStopBatchLabel" style="color:var(--text-muted); font-size:12px;">Total Terhitung:</span>
|
||||
<strong id="modalStopBatchCount" style="color:var(--green); font-size: 20px; font-family:var(--mono);">0</strong>
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom: 8px;">
|
||||
<span style="color:var(--text-muted); font-size:12px;">Karung (Sack):</span>
|
||||
<strong id="modalStopBatchSackCount" style="color:var(--text); font-size: 14px; font-family:var(--mono);">0</strong>
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom: 8px;">
|
||||
<span style="color:var(--text-muted); font-size:12px;">Box:</span>
|
||||
<strong id="modalStopBatchBoxCount" style="color:var(--text); font-size: 14px; font-family:var(--mono);">0</strong>
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
||||
<span style="color:var(--text-muted); font-size:12px;">Waktu Mulai:</span>
|
||||
<span id="modalStopBatchStart" style="font-size: 12px; font-family:var(--mono); color:var(--text);">--:--:--</span>
|
||||
@@ -1210,7 +1244,7 @@
|
||||
<div id="toastContainer" style="position:fixed; bottom:24px; right:24px; z-index:9999; display:flex; flex-direction:column; gap:10px; pointer-events:none;"></div>
|
||||
|
||||
<script>
|
||||
const LOGO_FALLBACK = {{ url_for('static', filename='img/logo-zenai-white.svg') | tojson }};
|
||||
const LOGO_FALLBACK = "{{ url_for('static', filename='img/logo-zenai-white.svg') }}";
|
||||
let mainChart = null;
|
||||
let videoActive = false;
|
||||
let videoErrorTimer = null;
|
||||
@@ -1221,7 +1255,7 @@ const DAILY_PAGE_SIZE = 10;
|
||||
let currentBatchState = {
|
||||
active: false,
|
||||
batch_number: null,
|
||||
object_label: 'sack',
|
||||
object_label: 'mixed',
|
||||
next_batch_number: 1,
|
||||
count: 0,
|
||||
start_time: null,
|
||||
@@ -1293,6 +1327,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
|
||||
const accFill = document.getElementById('accuracy-fill');
|
||||
if (accFill) accFill.style.width = `${accFill.dataset.accuracy || 98}%`;
|
||||
loadSummary();
|
||||
loadCurrentBatch();
|
||||
loadChartData(7);
|
||||
@@ -1314,19 +1350,21 @@ async function loadCurrentBatch() {
|
||||
const res = await fetch('/api/current-batch');
|
||||
const data = await res.json();
|
||||
const isActive = Boolean(data.success && data.active !== false && data.batch_number != null);
|
||||
const objType = (data.object_label || 'sack').toLowerCase() === 'box' ? 'box' : 'sack';
|
||||
const objTypeUpper = objType.toUpperCase();
|
||||
const objUnitLabel = objType === 'box' ? 'Box' : 'Karung';
|
||||
const objTypeUpper = 'MIXED';
|
||||
|
||||
currentBatchState.active = isActive;
|
||||
currentBatchState.batch_number = data.batch_number || null;
|
||||
currentBatchState.object_label = objType;
|
||||
currentBatchState.next_batch_number = data.next_batch_number || (data.batch_number ? data.batch_number + 1 : 1);
|
||||
currentBatchState.count = data.count || 0;
|
||||
currentBatchState.sack_count = data.sack_count || 0;
|
||||
currentBatchState.box_count = data.box_count || 0;
|
||||
currentBatchState.start_time = data.start_time || null;
|
||||
|
||||
const liveCountEl = document.getElementById('live-count');
|
||||
const liveUnitEl = document.getElementById('live-unit');
|
||||
const liveSackEl = document.getElementById('live-sack-count');
|
||||
const liveBoxEl = document.getElementById('live-box-count');
|
||||
const liveBatchEl = document.getElementById('live-batch-number');
|
||||
const liveLastDetEl = document.getElementById('live-last-detection');
|
||||
const batchStatusEl = document.getElementById('batch-status');
|
||||
@@ -1341,11 +1379,9 @@ async function loadCurrentBatch() {
|
||||
const bcStatusText = document.getElementById('bcStatusText');
|
||||
const bcMainInfo = document.getElementById('bcMainInfo');
|
||||
const bcSubInfo = document.getElementById('bcSubInfo');
|
||||
const btnStartSack = document.getElementById('btnBatchStartSack');
|
||||
const btnStartBox = document.getElementById('btnBatchStartBox');
|
||||
const btnStart = document.getElementById('btnBatchStart');
|
||||
const btnStop = document.getElementById('btnBatchStop');
|
||||
const lblNextBatchSack = document.getElementById('lblNextBatchSack');
|
||||
const lblNextBatchBox = document.getElementById('lblNextBatchBox');
|
||||
const lblNextBatch = document.getElementById('lblNextBatch');
|
||||
const lblCurrBatch = document.getElementById('lblCurrBatch');
|
||||
|
||||
if (svcCamEl) svcCamEl.textContent = videoActive ? 'Streaming' : 'Standby';
|
||||
@@ -1353,8 +1389,10 @@ async function loadCurrentBatch() {
|
||||
|
||||
if (isActive) {
|
||||
if (liveCountEl) liveCountEl.textContent = Number(data.count || 0).toLocaleString('id-ID');
|
||||
if (liveUnitEl) liveUnitEl.textContent = objUnitLabel;
|
||||
if (liveBatchEl) liveBatchEl.textContent = `${String(data.batch_number).padStart(4, '0')} (${objTypeUpper})`;
|
||||
if (liveUnitEl) liveUnitEl.textContent = 'Total';
|
||||
if (liveSackEl) liveSackEl.textContent = Number(data.sack_count || 0).toLocaleString('id-ID');
|
||||
if (liveBoxEl) liveBoxEl.textContent = Number(data.box_count || 0).toLocaleString('id-ID');
|
||||
if (liveBatchEl) liveBatchEl.textContent = String(data.batch_number).padStart(4, '0');
|
||||
if (batchStatusEl) {
|
||||
batchStatusEl.textContent = `RUNNING · ${objTypeUpper}`;
|
||||
batchStatusEl.className = 'badge-running';
|
||||
@@ -1372,30 +1410,31 @@ async function loadCurrentBatch() {
|
||||
const accUpd = document.getElementById('acc-updated');
|
||||
if (accUpd) accUpd.textContent = lastDet.toLocaleTimeString('id-ID', { hour12: false, hour: '2-digit', minute: '2-digit' });
|
||||
} else {
|
||||
if (liveLastDetEl) liveLastDetEl.textContent = `menunggu ${objType}...`;
|
||||
if (liveLastDetEl) liveLastDetEl.textContent = 'menunggu objek...';
|
||||
}
|
||||
|
||||
if (bcStatusBadge) {
|
||||
bcStatusBadge.className = 'bc-status-badge running';
|
||||
bcStatusText.textContent = `BATCH #${data.batch_number} (${objTypeUpper}) ACTIVE`;
|
||||
bcStatusText.textContent = `BATCH #${data.batch_number} ACTIVE`;
|
||||
}
|
||||
if (bcMainInfo) {
|
||||
bcMainInfo.textContent = `Batch #${data.batch_number} [${objTypeUpper}] Sedang Berjalan (${Number(data.count || 0).toLocaleString('id-ID')} ${objUnitLabel})`;
|
||||
bcMainInfo.textContent = `Batch #${data.batch_number} [${objTypeUpper}] Sedang Berjalan (${Number(data.count || 0).toLocaleString('id-ID')} total)`;
|
||||
}
|
||||
if (bcSubInfo) {
|
||||
const startTimeStr = data.start_time ? new Date(data.start_time).toLocaleTimeString('id-ID', { hour12: false }) : '--:--:--';
|
||||
bcSubInfo.textContent = `Mulai pukul ${startTimeStr} · Menghitung khusus ${objTypeUpper}`;
|
||||
bcSubInfo.textContent = `Mulai pukul ${startTimeStr} · Menghitung karung dan box`;
|
||||
}
|
||||
if (btnStartSack) btnStartSack.style.display = 'none';
|
||||
if (btnStartBox) btnStartBox.style.display = 'none';
|
||||
if (btnStart) btnStart.style.display = 'none';
|
||||
if (btnStop) {
|
||||
btnStop.style.display = 'inline-flex';
|
||||
if (lblCurrBatch) lblCurrBatch.textContent = `#${data.batch_number} (${objTypeUpper})`;
|
||||
if (lblCurrBatch) lblCurrBatch.textContent = `#${data.batch_number}`;
|
||||
}
|
||||
} else {
|
||||
if (liveCountEl) liveCountEl.textContent = '0';
|
||||
if (liveUnitEl) liveUnitEl.textContent = 'Karung / Box';
|
||||
if (liveBatchEl) liveBatchEl.textContent = `---- (Next: #${currentBatchState.next_batch_number})`;
|
||||
if (liveUnitEl) liveUnitEl.textContent = 'Total';
|
||||
if (liveSackEl) liveSackEl.textContent = '0';
|
||||
if (liveBoxEl) liveBoxEl.textContent = '0';
|
||||
if (liveBatchEl) liveBatchEl.textContent = '----';
|
||||
if (liveLastDetEl) liveLastDetEl.textContent = '--:--:--';
|
||||
if (batchStatusEl) {
|
||||
batchStatusEl.textContent = 'IDLE';
|
||||
@@ -1413,15 +1452,11 @@ async function loadCurrentBatch() {
|
||||
bcMainInfo.textContent = `Siap Menghitung (Batch #${currentBatchState.next_batch_number})`;
|
||||
}
|
||||
if (bcSubInfo) {
|
||||
bcSubInfo.textContent = 'Sistem idle. Klik "Start Sack" untuk menghitung karung atau "Start Box" untuk menghitung box.';
|
||||
bcSubInfo.textContent = 'Sistem idle. Klik "Start Batch" untuk menghitung karung dan box sekaligus.';
|
||||
}
|
||||
if (btnStartSack) {
|
||||
btnStartSack.style.display = 'inline-flex';
|
||||
if (lblNextBatchSack) lblNextBatchSack.textContent = `#${currentBatchState.next_batch_number}`;
|
||||
}
|
||||
if (btnStartBox) {
|
||||
btnStartBox.style.display = 'inline-flex';
|
||||
if (lblNextBatchBox) lblNextBatchBox.textContent = `#${currentBatchState.next_batch_number}`;
|
||||
if (btnStart) {
|
||||
btnStart.style.display = 'inline-flex';
|
||||
if (lblNextBatch) lblNextBatch.textContent = `#${currentBatchState.next_batch_number}`;
|
||||
}
|
||||
if (btnStop) btnStop.style.display = 'none';
|
||||
}
|
||||
@@ -1430,20 +1465,16 @@ async function loadCurrentBatch() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleStartBatch(objectType = 'sack') {
|
||||
const normType = objectType === 'box' ? 'box' : 'sack';
|
||||
const btnSack = document.getElementById('btnBatchStartSack');
|
||||
const btnBox = document.getElementById('btnBatchStartBox');
|
||||
if (btnSack) btnSack.disabled = true;
|
||||
if (btnBox) btnBox.disabled = true;
|
||||
showToast(`Memulai batch ${normType.toUpperCase()} baru...`, 'info');
|
||||
async function handleStartBatch() {
|
||||
const btnStart = document.getElementById('btnBatchStart');
|
||||
if (btnStart) btnStart.disabled = true;
|
||||
showToast('Memulai batch baru...', 'info');
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/batch/start/${normType}`, { method: 'POST' });
|
||||
const res = await fetch('/api/batch/start', { method: 'POST' });
|
||||
const data = await res.json();
|
||||
if (res.ok && data.success) {
|
||||
const startedLabel = (data.object_label || normType).toUpperCase();
|
||||
showToast(`Batch #${data.batch_number} (${startedLabel}) berhasil dimulai!`, 'success');
|
||||
showToast(`Batch #${data.batch_number} berhasil dimulai!`, 'success');
|
||||
await loadCurrentBatch();
|
||||
} else {
|
||||
showToast(data.error || 'Gagal memulai batch', 'error');
|
||||
@@ -1451,8 +1482,7 @@ async function handleStartBatch(objectType = 'sack') {
|
||||
} catch (e) {
|
||||
showToast('Koneksi gagal ke server counter', 'error');
|
||||
} finally {
|
||||
if (btnSack) btnSack.disabled = false;
|
||||
if (btnBox) btnBox.disabled = false;
|
||||
if (btnStart) btnStart.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1461,13 +1491,15 @@ function handleStopBatch() {
|
||||
const modalName = document.getElementById('modalStopBatchName');
|
||||
const modalLabel = document.getElementById('modalStopBatchLabel');
|
||||
const modalCount = document.getElementById('modalStopBatchCount');
|
||||
const modalSack = document.getElementById('modalStopBatchSackCount');
|
||||
const modalBox = document.getElementById('modalStopBatchBoxCount');
|
||||
const modalStart = document.getElementById('modalStopBatchStart');
|
||||
const objTypeUpper = (currentBatchState.object_label || 'sack').toUpperCase();
|
||||
const unitName = currentBatchState.object_label === 'box' ? 'Box' : 'Karung (Sack)';
|
||||
|
||||
if (modalName) modalName.textContent = `Batch #${currentBatchState.batch_number || '--'} (${objTypeUpper})`;
|
||||
if (modalLabel) modalLabel.textContent = `Total ${unitName} Terhitung:`;
|
||||
if (modalName) modalName.textContent = `Batch #${currentBatchState.batch_number || '--'}`;
|
||||
if (modalLabel) modalLabel.textContent = 'Total Terhitung:';
|
||||
if (modalCount) modalCount.textContent = Number(currentBatchState.count || 0).toLocaleString('id-ID');
|
||||
if (modalSack) modalSack.textContent = Number(currentBatchState.sack_count || 0).toLocaleString('id-ID');
|
||||
if (modalBox) modalBox.textContent = Number(currentBatchState.box_count || 0).toLocaleString('id-ID');
|
||||
if (modalStart) {
|
||||
modalStart.textContent = currentBatchState.start_time
|
||||
? new Date(currentBatchState.start_time).toLocaleTimeString('id-ID', { hour12: false })
|
||||
@@ -1492,8 +1524,7 @@ async function confirmStopBatch() {
|
||||
closeStopModal();
|
||||
|
||||
if (res.ok && data.success) {
|
||||
const stoppedLabel = (data.object_label || currentBatchState.object_label || 'sack').toUpperCase();
|
||||
showToast(`Batch #${data.batch_number} (${stoppedLabel}) selesai (${data.count} item)!`, 'success');
|
||||
showToast(`Batch #${data.batch_number} selesai (${data.count} item, ${data.sack_count} karung, ${data.box_count} box)!`, 'success');
|
||||
await loadCurrentBatch();
|
||||
await loadSummary();
|
||||
await loadRecentBatches();
|
||||
@@ -1537,6 +1568,8 @@ async function loadSummary() {
|
||||
|
||||
const todayCount = Number(data.today?.total_count || 0);
|
||||
const todayBatches = Number(data.today?.total_batches || 0);
|
||||
const todaySack = Number(data.today?.sack_count || 0);
|
||||
const todayBox = Number(data.today?.box_count || 0);
|
||||
const yestCount = Number(data.yesterday?.total_count || 0);
|
||||
const yestBatches = Number(data.yesterday?.total_batches || 0);
|
||||
const avgPerDay = Number(data.average_per_day || 0);
|
||||
@@ -1546,6 +1579,8 @@ async function loadSummary() {
|
||||
|
||||
document.getElementById('current-date').textContent = data.today?.date || '--';
|
||||
document.getElementById('today-count').textContent = todayCount.toLocaleString('id-ID');
|
||||
document.getElementById('today-sack-count').textContent = todaySack.toLocaleString('id-ID');
|
||||
document.getElementById('today-box-count').textContent = todayBox.toLocaleString('id-ID');
|
||||
document.getElementById('today-batches').textContent = `${todayBatches} batch hari ini`;
|
||||
|
||||
document.getElementById('yesterday-count').textContent = yestCount.toLocaleString('id-ID');
|
||||
@@ -1677,14 +1712,18 @@ async function loadRecentBatches() {
|
||||
return;
|
||||
}
|
||||
container.innerHTML = batches.map(b => {
|
||||
const bType = (b.object_label || 'sack').toLowerCase() === 'box' ? 'box' : 'sack';
|
||||
const bType = (b.object_label || 'mixed').toLowerCase() === 'box' ? 'box' : (b.object_label || 'mixed').toLowerCase() === 'sack' ? 'sack' : 'mixed';
|
||||
const typePill = bType === 'mixed'
|
||||
? '<span class="type-pill mixed">MIXED</span>'
|
||||
: `<span class="type-pill ${bType}">${bType.toUpperCase()}</span>`;
|
||||
return `
|
||||
<div class="recent-card">
|
||||
<div class="recent-head">
|
||||
<span class="recent-batch">B-${String(b.batch_number).padStart(4, '0')} <span class="type-pill ${bType}">${bType.toUpperCase()}</span></span>
|
||||
<span class="recent-batch">B-${String(b.batch_number).padStart(4, '0')} ${typePill}</span>
|
||||
<span class="recent-date">${formatDateID(b.date)}</span>
|
||||
</div>
|
||||
<div class="recent-count">${Number(b.count || 0).toLocaleString('id-ID')}</div>
|
||||
<div class="recent-breakdown">${Number(b.sack_count || 0).toLocaleString('id-ID')} karung · ${Number(b.box_count || 0).toLocaleString('id-ID')} box</div>
|
||||
<div class="recent-time">${formatTimeShort(b.start_time)} - ${formatTimeShort(b.end_time)} · <strong>${b.duration_minutes} menit</strong></div>
|
||||
</div>
|
||||
`;
|
||||
@@ -1886,18 +1925,24 @@ async function showDayDetail(date) {
|
||||
|
||||
const batches = data.batches || [];
|
||||
const totalDuration = batches.reduce((acc, b) => acc + (b.duration_minutes || 0), 0);
|
||||
const sackCount = batches.filter(b => (b.object_label || 'sack').toLowerCase() !== 'box').length;
|
||||
const boxCount = batches.filter(b => (b.object_label || 'sack').toLowerCase() === 'box').length;
|
||||
const sackTotal = Number(data.sack_count || 0);
|
||||
const boxTotal = Number(data.box_count || 0);
|
||||
|
||||
let tableHtml = '';
|
||||
if (batches.length) {
|
||||
tableHtml = batches.map(b => {
|
||||
const bType = (b.object_label || 'sack').toLowerCase() === 'box' ? 'box' : 'sack';
|
||||
const rawType = (b.object_label || 'mixed').toLowerCase();
|
||||
const bType = rawType === 'box' ? 'box' : (rawType === 'sack' ? 'sack' : 'mixed');
|
||||
const typePill = bType === 'mixed'
|
||||
? '<span class="type-pill mixed">MIXED</span>'
|
||||
: `<span class="type-pill ${bType}">${bType.toUpperCase()}</span>`;
|
||||
const pct = total > 0 ? (b.count / total) * 100 : 0;
|
||||
return `
|
||||
<tr>
|
||||
<td class="mono">#${b.batch_number}</td>
|
||||
<td><span class="type-pill ${bType}">${bType.toUpperCase()}</span></td>
|
||||
<td>${typePill}</td>
|
||||
<td class="mono">${Number(b.sack_count || 0).toLocaleString('id-ID')}</td>
|
||||
<td class="mono">${Number(b.box_count || 0).toLocaleString('id-ID')}</td>
|
||||
<td class="mono">${Number(b.count || 0).toLocaleString('id-ID')}</td>
|
||||
<td>${formatTime(b.start_time)}</td>
|
||||
<td>${formatTime(b.end_time)}</td>
|
||||
@@ -1909,7 +1954,9 @@ async function showDayDetail(date) {
|
||||
tableHtml += `
|
||||
<tr style="background: rgba(22,130,178,0.12); font-weight: 700; border-top: 2px solid var(--border-accent);">
|
||||
<td class="mono" style="font-weight:700;">TOTAL</td>
|
||||
<td><span class="status-badge info total-type-badge">${sackCount} Sack, ${boxCount} Box</span></td>
|
||||
<td><span class="status-badge info total-type-badge">${sackTotal.toLocaleString('id-ID')} Sack, ${boxTotal.toLocaleString('id-ID')} Box</span></td>
|
||||
<td class="mono" style="font-weight:700;">${sackTotal.toLocaleString('id-ID')}</td>
|
||||
<td class="mono" style="font-weight:700;">${boxTotal.toLocaleString('id-ID')}</td>
|
||||
<td class="mono" style="font-weight:700; color: #38bdf8;">${total.toLocaleString('id-ID')}</td>
|
||||
<td style="font-size:10px; color:var(--text-muted);">${batches[0] ? formatTime(batches[0].start_time) : '--'}</td>
|
||||
<td style="font-size:10px; color:var(--text-muted);">${batches[batches.length - 1] ? formatTime(batches[batches.length - 1].end_time) : '--'}</td>
|
||||
@@ -1917,7 +1964,7 @@ async function showDayDetail(date) {
|
||||
<td class="mono" style="font-weight:700;">100%</td>
|
||||
</tr>`;
|
||||
} else {
|
||||
tableHtml = `<tr><td colspan="7" class="modal-empty">Tidak ada batch pada tanggal ini</td></tr>`;
|
||||
tableHtml = `<tr><td colspan="9" class="modal-empty">Tidak ada batch pada tanggal ini</td></tr>`;
|
||||
}
|
||||
|
||||
document.getElementById('modal-table-body').innerHTML = tableHtml;
|
||||
|
||||
Reference in new issue
Block a user