1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
createuserfilterstepper.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Worker\Workflow;
4
5use Bitrix\Main;
6use Bitrix\Main\Application;
7
9{
10 protected static $moduleId = 'bizproc';
11
12 private const STEP_ROWS_LIMIT = 100;
13
14 public function execute(array &$option)
15 {
16 $connection = Application::getConnection();
17 if ($connection->getType() !== 'mysql')
18 {
19 return self::FINISH_EXECUTION;
20 }
21
22 $userId = (int)$this->getOuterParams()[0];
23 $lastTs = (int)($this->getOuterParams()[1] ?? 0);
24 $limit = self::STEP_ROWS_LIMIT;
25
26 $oldSql = ' AND wu.MODIFIED > ' . $connection->getSqlHelper()->addDaysToDateTime(-180);
27 $modCondition = '';
28 if ($lastTs > 0)
29 {
30 $modCondition = ' AND wu.MODIFIED <= ' . "'" . date('Y-m-d H:i:s', $lastTs) . "'";
31 }
32 $queryRows = $connection->query(
33 <<<SQL
34 select wu.WORKFLOW_ID, wu.MODIFIED from b_bp_workflow_user wu
35 where wu.USER_ID = {$userId} {$modCondition} {$oldSql} order by wu.MODIFIED DESC LIMIT {$limit}
36 SQL
37 )->fetchAll();
38
39 $ids = array_column($queryRows, 'WORKFLOW_ID');
40
41 if (empty($ids))
42 {
43 return self::FINISH_EXECUTION;
44 }
45
47 $lastModified = end($queryRows)['MODIFIED'];
48 $newLastTs = ($lastModified?->getTimestamp()) ?? $lastTs;
49 if ($newLastTs === $lastTs)
50 {
51 --$newLastTs;
52 }
53
54 $this->setOuterParams([$userId, $newLastTs]);
55
56 $idsSql = "'" . implode("','", $ids) . "'";
57
58 $connection->query(
59 <<<SQL
60 INSERT IGNORE INTO b_bp_workflow_filter
61 (WORKFLOW_ID, MODULE_ID, ENTITY, DOCUMENT_ID, TEMPLATE_ID, STARTED)
62 (
63 select ws.ID,
64 case when ws.MODULE_ID is null then '' else ws.MODULE_ID end,
65 ws.ENTITY,
66 ws.DOCUMENT_ID,
67 ws.WORKFLOW_TEMPLATE_ID,
68 case when ws.STARTED is null then now() else ws.STARTED end
69 from b_bp_workflow_state ws
70 where ws.ID IN ({$idsSql})
71 )
72 SQL
73 );
74
75 if (count($ids) < $limit)
76 {
77 return self::FINISH_EXECUTION;
78 }
79
80 return self::CONTINUE_EXECUTION;
81 }
82
83 public static function bindUser(int $userId): void
84 {
85 static::bind(0, [$userId]);
86 }
87}
return select
Определения access_edit.php:440
$connection
Определения actionsdefinitions.php:38
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
getOuterParams()
Определения stepper.php:212
setOuterParams(array $outerParams)
Определения stepper.php:207
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$option
Определения options.php:1711