1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
tracker.php
См. документацию.
1<?php
2namespace Bitrix\Bizproc\Automation;
3
4use Bitrix\Bizproc\WorkflowInstanceTable;
5use Bitrix\Bizproc\WorkflowTemplateTable;
6use Bitrix\Bizproc\Automation\Target\BaseTarget;
7use Bitrix\Bizproc\Workflow\Entity\WorkflowStateTable;
8
9class Tracker
10{
11 const STATUS_WAITING = 0;
12 const STATUS_RUNNING = 1;
15
17 protected $target;
18
20 {
21 $this->target = $target;
22 }
23
24 public function getLog(array $statuses)
25 {
26 return $this->getBizprocTrackingEntries($statuses);
27 }
28
29 private function getBizprocTrackingEntries($statuses)
30 {
31 $entries = [];
32
33 $states = $this->getStatusesStates($statuses);
34
35 if ($states)
36 {
37 $trackIterator = \CBPTrackingService::GetList(
38 ['ID' => 'ASC'],
39 ['@WORKFLOW_ID' => array_keys($states)]
40 );
41
42 $workflowStatuses = [];
43
44 while ($row = $trackIterator->fetch())
45 {
46 if (!array_key_exists($row['WORKFLOW_ID'], $workflowStatuses))
47 {
48 $hasInstance = $row['WORKFLOW_ID'] && WorkflowInstanceTable::exists($row['WORKFLOW_ID']);
49 $workflowStatus = $hasInstance ? \CBPWorkflowStatus::Running : \CBPWorkflowStatus::Completed;
50
51 $workflowStatuses[$row['WORKFLOW_ID']] = $workflowStatus;
52 }
53
54 $status = $states[$row['WORKFLOW_ID']];
55 $row['WORKFLOW_STATUS'] = $workflowStatuses[$row['WORKFLOW_ID']];
56 $entries[$status][] = $row;
57 }
58 }
59
60 return $entries;
61 }
62
63 private function getStatusesStates($statuses)
64 {
65 $states = array();
66 $templateIds = $this->getBizprocTemplateIds($statuses);
67
68 if (!$templateIds)
69 return $states;
70
71 $stateIterator = WorkflowStateTable::getList(array(
72 'select' => array('ID', 'WORKFLOW_TEMPLATE_ID'),
73 'filter' => array(
74 '=DOCUMENT_ID' => $this->target->getDocumentId(),
75 '@WORKFLOW_TEMPLATE_ID' => array_keys($templateIds)
76 ),
77 'order' => array('STARTED' => 'DESC')
78 ));
79
80 while ($row = $stateIterator->fetch())
81 {
82 $status = $templateIds[$row['WORKFLOW_TEMPLATE_ID']];
83 if (!in_array($status, $states))
84 $states[$row['ID']] = $status;
85 }
86
87 return $states;
88 }
89
90 private function getBizprocTemplateIds($statuses)
91 {
92 $documentType = $this->target->getDocumentType();
93 $ids = array();
94
95 $iterator = WorkflowTemplateTable::getList(array(
96 'select' => array('ID', 'DOCUMENT_STATUS'),
97 'filter' => array(
98 '=MODULE_ID' => $documentType[0],
99 '=ENTITY' => $documentType[1],
100 '=DOCUMENT_TYPE' => $documentType[2],
101 //'=AUTO_EXECUTE' => \CBPDocumentEventType::Automation,
102 '@DOCUMENT_STATUS' => $statuses
103 )
104 ));
105
106 while ($row = $iterator->fetch())
107 {
108 $ids[$row['ID']] = $row['DOCUMENT_STATUS'];
109 }
110
111 return $ids;
112 }
113}
const STATUS_RUNNING
Определения tracker.php:12
const STATUS_COMPLETED
Определения tracker.php:13
getLog(array $statuses)
Определения tracker.php:24
const STATUS_WAITING
Определения tracker.php:11
__construct(BaseTarget $target)
Определения tracker.php:19
const STATUS_AUTOCOMPLETED
Определения tracker.php:14
static GetList($arOrder=array("ID"=> "DESC"), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения trackingservice.php:35
const Running
Определения constants.php:82
const Completed
Определения constants.php:83
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$status
Определения session.php:10
$iterator
Определения yandex_run.php:610