56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* 前台工位看板 - 独立单页(不嵌入 AdminLTE 框架)
|
|
* 显示所有工位的实时生产状态
|
|
*/
|
|
namespace app\controllers;
|
|
|
|
use core\base\Controller;
|
|
use app\models\Workstation;
|
|
use app\models\StationDefinition;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$this->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();
|
|
}
|
|
}
|