Skip to content

Commit

Permalink
feat(ZMS-1498): merge into main
Browse files Browse the repository at this point in the history
  • Loading branch information
manjencic committed Dec 18, 2023
2 parents 3e69d31 + affa54f commit 0b2889c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions zmsadmin/src/Zmsadmin/WorkstationProcessNext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,37 @@ public function readResponse(
$validator = $request->getAttribute('validator');
$excludedIds = $validator->getParameter('exclude')->isString()->getValue();
$excludedIds = ($excludedIds) ? $excludedIds : '';

$selectedDateTime = \App::$now;
$selectedDateTime = ($selectedDateTime < \App::$now) ? \App::$now : $selectedDateTime;

$workstationRequest = new \BO\Zmsclient\WorkstationRequests(\App::$http, $workstation);

$processList = $workstationRequest->readProcessListByDate(
$selectedDateTime,
Helper\GraphDefaults::getProcess()
);

$filteredProcessList = new ProcessList;

foreach ($processList as $process) {
if ($process->status === "queued" || $process->status === "confirmed") {
$timeoutTimeUnix = isset($process->timeoutTime) ? $this->timeToUnix($process->timeoutTime) : null;
$currentTimeUnix = time();

if(!isset($process->timeoutTime)){
$filteredProcessList->addEntity(clone $process);
} else if (isset($timeoutTimeUnix) && !($process->queue->callCount > 0 && ($currentTimeUnix - $timeoutTimeUnix) < 300)) {
$filteredProcessList->addEntity(clone $process);
} else {
if (!empty($excludedIds)) {
$excludedIds .= ",";
}
$excludedIds .= $process->queue->number;
}
}
}

$process = (new Helper\ClusterHelper($workstation))->getNextProcess($excludedIds);

if (! $process->hasId() || $process->getFirstAppointment()->date > \App::$now->getTimestamp()) {
Expand Down

0 comments on commit 0b2889c

Please sign in to comment.