From 1602a68049c81e1f60ae75031a465a2e981dcaec Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Mon, 23 Mar 2026 09:45:39 +0300 Subject: [PATCH] =?utf8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BD=D0=B8=D0=BA=D0=BE?= =?utf8?q?=D0=B2=20=D0=BD=D0=B0=20=D1=81=D0=BC=D0=B5=D0=BD=D0=B5=20-=20?= =?utf8?q?=D0=B3=D1=80=D0=B5=D0=B9=D0=B4=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataTestController.php | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/erp24/api2/controllers/DataTestController.php b/erp24/api2/controllers/DataTestController.php index b4f4ff90..9d6f8267 100644 --- a/erp24/api2/controllers/DataTestController.php +++ b/erp24/api2/controllers/DataTestController.php @@ -7,6 +7,7 @@ use Exception; use Yii; use yii\helpers\Json; use yii_app\records\ApiCronTest; +use yii_app\records\AdminGradeHistory; use yii_app\records\ExportImportTable; use yii_app\records\TimetableFact; @@ -401,14 +402,38 @@ class DataTestController extends BaseController { $adminIds = array_unique(array_column($rows, 'admin_id')); - // Получаем имена сотрудников + // Получаем данные сотрудников (имя, должность) $admins = \yii_app\records\Admin::find() - ->select(['id', 'name_full']) + ->select(['id', 'name_full', 'employee_position_id']) ->where(['id' => $adminIds]) ->indexBy('id') ->asArray() ->all(); + // Получаем названия должностей + $positionIds = array_filter(array_column($admins, 'employee_position_id')); + $positions = []; + if (!empty($positionIds)) { + $positions = \yii_app\records\EmployeePosition::find() + ->select(['id', 'name']) + ->where(['id' => $positionIds]) + ->indexBy('id') + ->asArray() + ->all(); + } + + // Получаем текущий грейд (активная запись: closed_at = '2100-01-01 00:00:00') + $gradeRows = AdminGradeHistory::find() + ->alias('agh') + ->select(['agh.admin_id', 'g.id AS grade_id', 'g.name AS grade_name']) + ->innerJoin('grade g', 'g.id = agh.grade_id') + ->where(['agh.admin_id' => $adminIds]) + ->andWhere(['agh.closed_at' => '2100-01-01 00:00:00']) + ->asArray() + ->all(); + + $grades = array_column($gradeRows, null, 'admin_id'); + // Получаем seller_id (GUID из 1С) для каждого сотрудника $exportRows = ExportImportTable::find() ->select(['entity_id', 'export_val']) @@ -424,10 +449,18 @@ class DataTestController extends BaseController { $result = []; foreach ($adminIds as $adminId) { + $admin = $admins[$adminId] ?? []; + $positionId = $admin['employee_position_id'] ?? null; + $grade = $grades[$adminId] ?? null; + $result[] = [ - 'admin_id' => $adminId, - 'name' => $admins[$adminId]['name_full'] ?? null, - 'seller_id' => $sellerIds[$adminId] ?? null, + 'admin_id' => $adminId, + 'name' => $admin['name_full'] ?? null, + 'seller_id' => $sellerIds[$adminId] ?? null, + 'employee_position_id' => $positionId, + 'position_name' => $positionId ? ($positions[$positionId]['name'] ?? null) : null, + 'grade_id' => $grade['grade_id'] ?? null, + 'grade_name' => $grade['grade_name'] ?? null, ]; } -- 2.39.5