checkLogin(); $user = $this->getCurrentUser(); $workstation = new Workstation(); $stations = $workstation->getAll(); // 统计各工位今日数据(使用 StationDefinition 统一模型) $stats = []; $today = date('Y-m-d'); $stationDef = new StationDefinition(); // 内置工位列表(station_definitions 中配置的) $builtinTypes = ['inbound', 'pcb_test', 'battery', 'assembly', 'finished_test', 'warehouse', 'delivery']; foreach ($stations as $station) { $type = $station['station_type']; $count = 0; if (in_array($type, $builtinTypes)) { $count = $stationDef->countTodayByOperator($type, $user['emp_name']); } $stats[$type] = [ 'name' => $station['station_name'], 'code' => $station['station_code'], 'count' => $count, 'status' => $station['status'], ]; } // 总计 $totalRecords = array_sum(array_column($stats, 'count')); $this->assign('title', '前台工位看板'); $this->assign('user', $user); $this->assign('stations', $stations); $this->assign('stats', $stats); $this->assign('totalRecords', $totalRecords); $this->assign('today', $today); $this->render(); } }