完善生产查询与登录权限配置
This commit is contained in:
@@ -91,14 +91,20 @@ class WorkStatisticsService
|
||||
$connection = $model->getConnection();
|
||||
$table = $model->getTable();
|
||||
$exceptionTable = $exceptionModel->getTable();
|
||||
$flow = $this->getRepairFlow();
|
||||
$query = $connection->table($table)
|
||||
->leftJoin($exceptionTable, $exceptionTable . '.id', '=', $table . '.exception_id')
|
||||
->whereBetween($table . '.repaired_at', [$start, $end])
|
||||
->whereNull($table . '.deleted_at');
|
||||
|
||||
if (!$this->matchesRepairFlow($params, $flow)) {
|
||||
$query->whereRaw('1 = 0');
|
||||
foreach (['process_id', 'step_id'] as $field) {
|
||||
if (($params[$field] ?? '') !== '') {
|
||||
$query->where($table . '.' . $field, $params[$field]);
|
||||
}
|
||||
}
|
||||
foreach (['process_name', 'step_name'] as $field) {
|
||||
if (($params[$field] ?? '') !== '') {
|
||||
$query->where($table . '.' . $field, 'like', '%' . $params[$field] . '%');
|
||||
}
|
||||
}
|
||||
if (($params['user_code'] ?? '') !== '') {
|
||||
$query->where($exceptionTable . '.user_code', 'like', '%' . $params['user_code'] . '%');
|
||||
@@ -109,8 +115,8 @@ class WorkStatisticsService
|
||||
|
||||
return $query->select([$exceptionTable . '.user_code', $table . '.operator'])
|
||||
->selectRaw($periodExpression($connection->getTablePrefix() . $table . '.repaired_at') . ' as period')
|
||||
->selectRaw('? as process_name', [$flow['process_name']])
|
||||
->selectRaw('? as step_name', [$flow['step_name']])
|
||||
->selectRaw("COALESCE(NULLIF({$connection->getTablePrefix()}{$table}.process_name, ''), '历史数据未记录') as process_name")
|
||||
->selectRaw("COALESCE(NULLIF({$connection->getTablePrefix()}{$table}.step_name, ''), '历史数据未记录') as step_name")
|
||||
->selectRaw('COUNT(*) as amount')
|
||||
->groupBy('user_code', 'operator', 'process_name', 'step_name', 'period');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user