123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161 |
- <?php
- namespace app\controllers;
- use app\models\ElasticLog;
- use Yii;
- use app\models\Logs;
- use yii\web\Controller;
- use app\models\MainModel;
- use app\models\ProcedureModel;
- use app\models\entity\Tasks;
- use app\models\ProjectsModel;
- use app\models\entity\Accounts;
- use app\models\entity\Sections;
- use app\models\LocomotiveModel;
- use app\models\MappingapiModel;
- use app\models\entity\Tasktypes;
- use \app\models\LogEippResponse;
- use app\models\logger\LoggerFile;
- use app\models\entity\Repairtypes;
- use app\models\entity\Projecttypes;
- use app\models\entity\AsusgProject;
- use app\models\entity\AsusgJobPlan;
- use app\models\MappingHandlerModel;
- use app\models\entity\AsusgJob2Launch;
- use app\models\entity\AsusgProjectType;
- use app\models\entity\LocomotiveSeries;
- use app\models\entity\ProjectsLocotech;
- use app\models\entity\AsusgJob2Command;
- use app\models\procedure\StartProjectForLocoModel;
- class MappinghandlermwController extends Controller
- {
- private $logger;
- private $company;
- private $sectionList;
- private $testIdpl2;
- private $testIdpl3;
- private $datailWorkArray = [];
- private $locoGetInfoArray = [];
- private $logEtn;
- private $prepareLogString = '';
- private $issetLaunch = false;
-
- public function beforeAction($action)
- {
- parent::beforeAction($action);
- $logEtn = new Logs();
- $logEtn->index_t = strtotime(date("Y-m-d H:i:s"));
- $logEtn->section = 3;
- $this->logEtn = $logEtn;
- $log = new LoggerFile();
-
- $this->logger = new MappingHandlerModel($log);
- return true;
- }
-
- // запускается периодически через крон
-
- public function actionGetworks($company)
- {
- //$this->sectionList();
- //exit;
-
- $this->company = $company;
- $GWparams = [
- 'url' => 'http://' . Yii::$app->params['api']['domain'].'/Thingworx/Things/2050UserLibraryExp/Services/my_works',
- //'url' => 'http://devplatform.digitaldepot.ru:8085/Thingworx/Things/SMoPPIntegrationLibrary/Services/getUserWorks',
- 'param' => '',
- 'login' => 'ПройдаковИА',
- 'pass' => 'Ip15351112'
- ];
- // список сотрудников онлайн
- $onlineUser = $this->getOnlineMobileUser($company);
- if( 0 == count($onlineUser)) {
- return 'Нет сотрудников онлайн';
- }
- //$this->logger->setLog('ID пользователя => ' . (int)$_SESSION["id"]);
-
- $this->prepareLogString .= "\n=================== СТАРТ МЕППИНГА ==================================\n";
-
- $this->prepareLogString .= date("Y-m-d H:i:s") . "\n";
-
-
-
- $mainModel = new MainModel();
- // для каждого сотрудника онлайн запускаем проекты если они еще не запущены
- $setOnlineWorkers = [];
- $this->prepareLogString .= "Колличество cотрудников онлайн :" . count($onlineUser) ."\n";
-
- foreach($onlineUser as $user) {
- $buisy = $this->buisyEmployee($user);
- if( $buisy || ('' == $user->uuid and null == $user->uuid )) {
- continue;
- }
- $GWparams['param'] = $user->uuid;
- $listWorks2 = json_decode($mainModel->curlRequest2($GWparams),true);
- $listWorks2 = $this->prepareListWorks($listWorks2);
-
- //foreach ( $listIssetWorks3 as $work) { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- //echo '<pre>';
- //var_dump($user->id);
- //var_dump($listWorks2);
- //echo '</pre>';
- foreach ( $listWorks2['data'] as $work) {
-
- $mappingapiModel = new \app\models\MappingapiModel();
-
- $this->datailWorkArray[$work['id_work']] = $mappingapiModel->workDetail($user->uuid,$work['id_work']);
- foreach( $this->datailWorkArray[$work['id_work']]['workers_uuid'] as $uuid) {
- $setOnlineWorkers[] = $uuid;
- }
- }
- $this->prepareLogString .= $mappingapiModel->prepareLogString."\n";
- $this->prepareLogString .= "Вот это сейчас должен получить работу :" . $user->id . "( ".$user->name." )\n";
- }
-
- $setOnlineWorkers = array_unique($setOnlineWorkers);
- $onlineUserModificate = \app\models\entity\Accounts::find()->where(['in','uuid',$setOnlineWorkers])->andWhere(['company' =>$company])->all();
- $this->prepareLogString .= "Колличество cотрудников онлайн для них есть работа ( с напарниками ):" . count($setOnlineWorkers)."\n";
- foreach($onlineUserModificate as $user) {
- //var_dump($user->id);continue;
- if( '' == $user->uuid and null == $user->uuid || 349 == $user->id) {
- continue;
- }
- $this->issetLaunch = false;
- $GWparams['param'] = $user->uuid;
- ElasticLog::eipp($GWparams, 'my_works', 0);
- $listWorks2 = $mainModel->curlRequest2($GWparams);
- $unixTime = time();
- LogEippResponse::addLog($unixTime.'gw'. $user->id ,$listWorks2,'Получение работ от ЕИПП');
- ElasticLog::eipp($listWorks2, 'my_works', 0, false);
- $this->prepareLogString .= "\nMY_WORK =====>\n";
- $this->prepareLogString .= "Параметры: \n user_id =>". $GWparams['param'] .".\n";
- $this->prepareLogString .= "Строка запроса : \n " . $GWparams['url'] .".\n";
- $this->prepareLogString .= "Вот тут можно посмотреть что ЕИПП прислал по запросу http://dev.prmsys.net/api/mappinghandler/eippresponse?indx=".$unixTime."\n";
- $this->prepareLogString .= "MY_WORK ======>\n\n";
- $listWorks2 = json_decode($listWorks2,true);
- $listWorks2 = $this->prepareListWorks($listWorks2);
- /// НЕТ ДВУХ ПОЛЕЙ ["section_num"] ["section_DK"]
- //echo '<pre>';
- //var_dump($user->id);
- //var_dump('Привет', $user->id , "\n");
-
- //echo '</pre>';
- //continue;
- //$this->logEtn->addlogText('','sdfsdfsdf');
-
- $this->prepareLogString .= "Колличество работ из еипп: ". count($listWorks2['data'])." \n Cотрудник:" . $user->id . "( ". $user->name ." )\n";
- $listIsabsentWorks2 = $this->Getisabsentworksjp($listWorks2); // вновь утвержденный план 1 | вернет список работ кот нет ( в JobPlan )
- $listIssetWorks3 = $this->Getissetworksjp($listWorks2);
- $this->prepareLogString .= 'Колличество работ из еипп ( сверхциклвая ): '. count($listIsabsentWorks2)."\n";
- $this->prepareLogString .= 'Колличество работ из еипп ( цикловая ): '. count($listIssetWorks3)."\n";
- $this->prepareLogString .= "\n СВЕРХЦИКЛОВЫЕ \n\n";
- //$addJob2launch2 = $this->addJob2launch2($listIsabsentWorks2,$user);
- $this->prepareLogString .= "\n ЦИКЛОВЫЕ \n\n";
- //$addJob2launch3 = $this->addJob2launch3($listIssetWorks3,$user);
-
-
- if (!$this->issetLaunch) {
- continue;
- }
-
- $this->logger->setLog("Интеграция сверхцикловых работ прошла без падений!");
- $this->logger->setLog("=====================================================\n\n");
-
-
-
- }
- return true;//$listWorks;
-
- }
-
- public function actionDojob()
- {
- Yii::$app->db->createCommand('update `accounts_internal` set `last_seen_mobile` = NOW() where id in (351,349,350)')->execute();
- }
-
- public function actionDopro()
- {
-
- $JobPlanEntitty = AsusgJobplan::find()->where(['name' => 'Тормозное и пневматическое оборудование после ремонта испытать , отрегулировать согласно инструкции'])->one(); // 1204 1567
- $jsusgJob2CommandEntity = AsusgJob2Command::find()->where(['asusg_job_id' => $JobPlanEntitty->id])->all();
- foreach($jsusgJob2CommandEntity as $job) {
- echo '<pre>';
- var_dump('3 =>'. $job->id, $job->asusg_job_id);
- var_dump('3 =>'. $job->jobplantie->id);
- echo '</pre>';
- }
- exit;
- }
-
- public function actionProctest()
- {
- $procedureModel = new ProcedureModel();
- $procedureModel->asusg_build_and_start_project_auto(27,210);
- }
-
- public function Getisabsentworksjp( $listWorks = null){
-
- $result = [];
- if ( null == $listWorks) {
- return false;
- }
- foreach( $listWorks['data'] as $work) {
- $asusgJobPlan = AsusgJobPlan::find()->where(['name' => $work['work_name']])->one();
- if ( null == $asusgJobPlan ){
- $result[] = $work;
- }
- }
- return $result;
- }
-
- public function Getissetworksjp( $listWorks = null){
-
- $result = [];
- if ( null == $listWorks) {
- return false;
- }
- foreach( $listWorks['data'] as $work) {
- $asusgJobPlan = AsusgJobPlan::find()->where(['name' => $work['work_name']])->one();
- if ( null != $asusgJobPlan ){
- $result[] = $work;
- }
- }
- return $result;
- }
-
- public function getOnlineMobileUser($company){
-
- $result = [];
- $accountsEntity = \app\models\entity\Accounts::find()->where(['company' => $company])->all();
- foreach ($accountsEntity as $account) {
- //var_dump($account->id,'<br>');
- $last_seen_mobile = ( null != $account->last_seen_mobile )? new \DateTime($account->last_seen_mobile): $account->last_seen_mobile ;
- $online_mobile = $this->OnlineAccountCheck($this->TimeString($last_seen_mobile));
- //var_dump(( !$online_mobile ),'<br>');
- if ( !$online_mobile ){
- continue;
- }
- $result[] = $account;//['id' => $account->id, 'uuid' => $account->uuid];
- }
- return $result;
- }
-
- public function OnlineAccountCheck($last_seen)
- {
- $last_seen = date($last_seen);
- $time = (time()-strtotime($last_seen));
- if ($time <= Yii::$app->params['onlineMobileTimeoutSeconds'])
- return true;
- return false;
- }
-
- public function TimeString($timeobj)
- {
- if ($timeobj != null)
- return $timeobj->format('d.m.Y H:i');
- //return date('d.m.Y H:i', $timeobj);
- }
-
- public function getProjectType($repairName,$serieName)
- {
- $result = null;
- $repairtypesEntity = Repairtypes::findOne(['name' => $repairName]);
- $locomotiveSeriesEntity = LocomotiveSeries::findOne(['name' => $serieName]);
- $asusgProjectTypeEntity = AsusgProjectType::findOne(['repair_type' => $repairtypesEntity->id , 'loco_serie_id' => $locomotiveSeriesEntity->id]);
- if ( null != $asusgProjectTypeEntity->id ) {
- $result = $asusgProjectTypeEntity->id;
- }
- return $result;
- }
-
- public function addJob2launch2($listWorks,$user)
- {
-
-
- foreach ( $listWorks as $work) {
- $dwResult = $this->datailWorkArray[$work['id_work']];
- $this->prepareLogString .= "Название работы:". $work['work_name']. ".\n UUID работы: " . $work['id_work'] . "\n\n";
-
-
- $this->prepareLogString .= "\n 1. ДОБАВЛЕНИЕ В LAUNCH \n\n";
- $asusgJob2LaunchEntity = AsusgJob2Launch::findOne(['asusg_job_uuid' => $work['id_work']]);
- $let = mb_substr($work["section_lit"], -1);
- // ВАЖНО ПОНИМАТЬ !!!!
- // если проект для такой работы уже есть, его создавать нельзя
- // но можно прикреплять к нему задачи. Сотрудник который зашел первый получает и замеры и тмц и работы
- // тот кто зашел вторым получает только работы.
- //$mappingapiModel = new \app\models\MappingapiModel();
- //$dwResult = $mappingapiModel->workDetail($user->uuid,$work['id_work']);
-
-
- //echo "<pre>";
- //var_dump($user->id);
- //var_dump($work['work_name']);
- //var_dump($dwResult["hw_measurements_status"]);
- //var_dump($asusgJob2LaunchEntity->id);
- //echo "</pre>";
- //continue;
-
-
- $projtype = $this->getProjectType($work["repair_name"],$work["eq_serie"]);
-
- $switcher = $asusgJob2LaunchEntity;
-
- if ( null == $switcher) {
- $resultArr = [];
- $asusgJob2LaunchEntity = new AsusgJob2Launch();
- $asusgJob2LaunchEntity->asusg_jobplan_id = Yii::$app->params['supercycleplan'];
- $asusgJob2LaunchEntity->asusg_employee_id1 = $user->id;
- $asusgJob2LaunchEntity->asusg_job_uuid = $work['id_work'];
- $asusgJob2LaunchEntity->employees_uuid = $user->uuid;
- $asusgJob2LaunchEntity->section_uuid = $work["section_id"];
- $asusgJob2LaunchEntity->asusg_project_id = 0;
- $asusgJob2LaunchEntity->job_order = 0;
- $asusgJob2LaunchEntity->time_limit = $dwResult['time_limit'];
- $asusgJob2LaunchEntity->outfit = $dwResult['outfit'];
- $asusgJob2LaunchEntity->name = $work['work_name'];
- $asusgJob2LaunchEntity->section_name = $work["section_lit"];
- //$asusgJob2LaunchEntity->asusg_projecttype_id = 0;
- $asusgJob2LaunchEntity->asusg_projecttype_id = $projtype;
- if (!$asusgJob2LaunchEntity->save()) {
- $this->logger->setLog('в Job2launch не добавилась работа => "'. $work['work_name']. '" Добавление работ будет пропущено так как такая запись уже есть.');
- continue;
- }
- $this->issetLaunch = true;
- $this->logger->setLog($this->prepareLogString);
- $this->prepareLogString = '';
- $this->logger->setLog('в Job2launch была добавлена работа => "'. $work['work_name'].'"');
- /// сначала генерю проект
- $projId = $this->generateProject($work);
- /// сначала генерю проетк
- } else {
- $userUuidArr = explode(',', $asusgJob2LaunchEntity->employees_uuid);
- if ( in_array( $user->uuid , $userUuidArr)) { // если сотрудник уже привязан к лаунчу
- $this->logger->setLog('сотрудник '.$user->name .' ('.$user->id.') уже привязан к лаунчу'. $asusgJob2LaunchEntity->id);
- continue;
- } else {
- $asusgJob2LaunchEntity->employees_uuid .= ','. $user->uuid;
- $asusgJob2LaunchEntity->save();
- $this->logger->setLog('сотрудники ('.$asusgJob2LaunchEntity->employees_uuid.') привязаны к лаунчу'. $asusgJob2LaunchEntity->id);
- }
- //continue;
- $this->prepareLogString .= "ВОТ ТУТ Я ХОТЕЛ ПОЛУЧИТЬ ИД ПРОЕКТА ЧЕРЕЗ ЗАДАЧУ( launch_id = ".$asusgJob2LaunchEntity->id.") => " . $asusgJob2LaunchEntity->tasks->id .", ВОТ ЧТО ПОЛУЧИЛ => " . $asusgJob2LaunchEntity->tasks->input_id ."!\n";
- $projId = $asusgJob2LaunchEntity->tasks->input_id;
- }
- /////////////// ДОБАВЛЕНИЕ ЗАДАЧИ
- $this->prepareLogString .= "\n 3. ДОБАВЛЕНИЕ ЗАДАЧИ \n\n";
- $tasktypesEntity = Tasktypes::find()->where(['name' => 'Секция '.$let.', задача','company' => $this->company])->one();
-
- $tasksEnt = Tasks::find()->where(['parent_id' => 0,'asusg_job_mapped_id' => $asusgJob2LaunchEntity->id,'assignees_arr' => $user->id])->one();
- if ( null != $tasksEnt) {
- continue;
- }
- $this->logger->setLog($this->prepareLogString);
- $this->prepareLogString = '';
- $tasksEntity = new Tasks();
- $tasksEntity->parent_id = 0;
- $tasksEntity->status = 2;
- $tasksEntity->type = $tasktypesEntity->id;
- $tasksEntity->assignees_arr = $user->id;
- $tasksEntity->preferred_assignee = $user->id;
- $tasksEntity->created = date("Y-m-d H:i;s");
- $tasksEntity->asusg_job_mapped_id = $asusgJob2LaunchEntity->id;
- $tasksEntity->mapping_comment = $work["outfit"] . ': ' . $work['work_name'];
- $tasksEntity->text = $work["section_lit"] . "\n" . $work["outfit"] . ': ' . $work['work_name'] . "\n" . $dwResult['workers'];
-
-
- if($tasksEntity->save()) {
- $this->testIdpl2 = $tasksEntity->id;
- $this->logger->setLog('в Tasks была добавлена ЗАДАЧА => "'. $work['work_name'] . '" id => '.$tasksEntity->id);
- } else {
- $this->logger->setLog('в Tasks была НЕ добавлена ЗАДАЧА => "'. $work['work_name'] . '" id => '.$tasksEntity->id);
- }
- //var_dump($tasksEntity->errors,$user->id); echo '<br>';
-
- //$countPriority = 1;
- if ( null == $switcher) {
- ///////////////// ДОБАВЛЕНИЕ ТМЦ
-
- //$mappingapiModel = new \app\models\MappingapiModel();
- //var_dump($user->id-uuid,$work['id_work']);
- //$tmcString = $mappingapiModel->workDetail($user->uuid,$work['id_work']);
- $this->logger->setLog("\n ДОБАВЛЕНИЕ ТМЦ " . strlen($dwResult['tmcString']) . "\n");
- if ( '' != $dwResult['tmcString']) {
- $tasksEntity3 = new Tasks();
- $tasksEntity3->parent_id = $tasksEntity->id; // +
- $tasksEntity3->status = 2; // +
- $tasksEntity3->priority = Yii::$app->params['countPriority']; // +
- // $tasksEntity2->input_id = $job->asusgJob2Launch->asusg_project_id;
- $tasksEntity3->created = date("Y-m-d H:i;s"); // +
- $tasksEntity3->type = 2159; // +
- $tasksEntity3->assignees_arr = $user->id; // +
- $tasksEntity3->preferred_assignee = $user->id; // +
- $tasksEntity3->asusg_job_mapped_id = $asusgJob2LaunchEntity->id; // +
- $tasksEntity3->text = $dwResult['tmcString']; // +
- $tasksEntity3->mapping_comment = $dwResult['tmcString']; // +
- $tasksEntity3->input_id = $projId;
- if ( $tasksEntity3->save()) {
- $query3 = "call asusg_add_checkpoints_to_task(" . $user->id . ",'" . $tasksEntity3->id . "')";
- $resProc = Yii::$app->db->createCommand($query3)->query();
- $logResProc = 'false';
- if ($resProc){
- $logResProc = 'true';
- }
- $this->logger->setLog('в Tasks была добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity3->id. ' процедура => ' . $logResProc . ' приоритет =>' . Yii::$app->params['countPriority']);
- } else {
- $this->logger->setLog('в Tasks была НЕ добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity3->id );
- }
- Yii::$app->params['countPriority']++;
- }
- ///////////////////
- ///////////////// ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 0
- $this->logger->setLog( "\n 4. ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 0 \n");
- //if ( Yii::$app->params['api']['hw_msrmnt_stat'][ $dwResult["hw_measurements_status"] ]) { // выполнение hw_measurements_status = waiting
- $paramsMeaserm = ['input_id' => $projId, 'assignees_arr' => $user->id, 'work' => $work,'stage' => 0, 'parent_id' => $tasksEntity->id , 'stage_type' => 'доремонтный','asusg_job_mapped_id' => $asusgJob2LaunchEntity->id ];
- Yii::$app->params['api']['mesrmntParam'] = $paramsMeaserm;
- MappingapiModel::workMeasurements($work['id_work'],$user->uuid);
- //}
- ///////////////////
- }
- /////////////// НА РЕМОНТ
- $this->logger->setLog("\n 5. ДОБАВЛЕНИЕ НА РЕМОНТ \n");
- $tasksEntity2 = new Tasks();
- $tasksEntity2->parent_id = $tasksEntity->id;
- $tasksEntity2->status = 2;
- $tasksEntity2->priority = Yii::$app->params['countPriority'];
- $tasksEntity2->created = date("Y-m-d H:i;s");
- $tasksEntity2->type = Yii::$app->params['supercycletype'];
- $tasksEntity2->assignees_arr = $user->id;
- $tasksEntity2->preferred_assignee = $user->id;
- $tasksEntity2->asusg_job_mapped_id = $asusgJob2LaunchEntity->id;
- $tasksEntity2->text = $work["eq_serie"] . ' '.$work["section_lit"] . ', '. $work["outfit"] . ': ' . $work['work_name'];
- $tasksEntity2->mapping_comment = $work["outfit"] . ': ' . $work['work_name'];
- if ( $tasksEntity2->save()) {
- ///////////////////
- //$query3 = "call asusg_add_checkpoints_to_task(" . $user->id . ",'" . $tasksEntity2->id . "')";
- //$resProc = Yii::$app->db->createCommand($query3)->query();
- ///////////////////
- $this->logger->setLog('в Tasks была добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity2->id . ' приоритет =>' . Yii::$app->params['countPriority']. ', cтатус => ' . $tasksEntity2->status);
- } else {
- $this->logger->setLog('в Tasks была НЕ добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity2->id);
- }
-
-
-
- // $projId = $this->generateProject($work);
-
- $tasksEntity->input_id = $projId;
- if ($tasksEntity->save()) {
- $this->logger->setLog('привязка ЗАДАЧИ ( id = '.$tasksEntity->id.') прошла успешно ( "assignees_arr" => ' . $tasksEntity->assignees_arr . ')');
- }
-
-
- $tasksEntity2->input_id = $projId;
-
- if($tasksEntity2->save()){
- $this->logger->setLog('привязка КОМАНДЫ ( id = '.$tasksEntity2->id.') прошла успешно ( "assignees_arr" => ' . $tasksEntity2->assignees_arr . ')');
- }
- //if ( null != $tasksEntity3) {
- // $tasksEntity3->input_id = $projId;
- //
- // if($tasksEntity3->save()){
- // $this->logger->setLog('привязка КОМАНДЫ ТМЦ ( id = '.$tasksEntity3->id.') прошла успешно');
- // }
- //}
-
- if ( null == $switcher) {
-
- ///////////////// ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 1
- $this->logger->setLog("\n 6. ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 1 \n");
-
- //if ( Yii::$app->params['api']['hw_msrmnt_stat'][ $dwResult["hw_measurements_status"] ]) { // выполнение hw_measurements_status = waiting
- $paramsMeaserm['stage'] = 1;
- $paramsMeaserm['stage_type'] = 'контрольный';
- $paramsMeaserm['asusg_job_mapped_id'] = $asusgJob2LaunchEntity->id;
- Yii::$app->params['api']['mesrmntParam'] = $paramsMeaserm;
- MappingapiModel::workMeasurements($work['id_work'],$user->uuid);
- //}
- ///////////////////
-
- ///////////////// ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 2
-
- $this->logger->setLog("\n 7. ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 2 \n");
- //if ( Yii::$app->params['api']['hw_msrmnt_stat'][ $dwResult["hw_measurements_status"] ]) { // выполнение hw_measurements_status = waiting
- $paramsMeaserm['stage'] = 2;
- $paramsMeaserm['stage_type'] = 'послеремонтный';
- $paramsMeaserm['asusg_job_mapped_id'] = $asusgJob2LaunchEntity->id;
- Yii::$app->params['api']['mesrmntParam'] = $paramsMeaserm;
- MappingapiModel::workMeasurements($work['id_work'],$user->uuid);
- //}
- ///////////////////
- }
-
- //( все правильно сначала 2 потом 1)
-
- //echo "<pre>";
- //var_dump($tasksEntity2->errors,$tasksEntity->errors);
- //echo "</pre>";
-
- }
- Yii::$app->params['countPriority'] = 1;
- }
-
-
-
- public function addJob2launch3($listWorks,$user)
- {
-
- foreach ( $listWorks as $work) {
-
- $this->prepareLogString .= "\n 1. ДОБАВЛЕНИЕ В LAUNCH \n\n";
- $asusgJob2LaunchEntity = AsusgJob2Launch::findOne(['asusg_job_uuid' => $work['id_work']]);
- $let = mb_substr($work["section_lit"], -1);
-
- // ВАЖНО ПОНИМАТЬ !!!!
- // если проект для такой работы уже есть, его создавать нельзя
- // но можно прикреплять к нему задачи. Сотрудник который зашел первый получает и замеры и тмц и работы
- // тот кто зашел вторым получает только работы.
-
-
- //$mappingapiModel = new \app\models\MappingapiModel();
- //$dwResult = $mappingapiModel->workDetail($user->uuid,$work['id_work']);
- $dwResult = $this->datailWorkArray[$work['id_work']];
-
- //echo "<pre>";
- //var_dump($user->id);
- //var_dump($work['work_name']);
- //var_dump($dwResult["hw_measurements_status"]);
- //var_dump($dwResult);
- //var_dump($user->uuid);
- //echo "</pre>";
- //continue;
-
- $projtype = $this->getProjectType($work["repair_name"],$work["eq_serie"]);
- $JobPlanEntitty = AsusgJobplan::find()->where(['name' => $work["work_name"]])->one(); // 1204 1567
- if ( null == $JobPlanEntitty->id ) {
- $this->prepareLogString .= " ВНИМАНИЕ не нашел работу в AsusgJobplan ('name' => ".$work['work_name'].")\n\n";
- }
- $jsusgJob2CommandEntity = AsusgJob2Command::find()->where(['asusg_job_id' => $JobPlanEntitty->id, 'asusg_projecttype_id' => $projtype ])->all();
- $switcher = $asusgJob2LaunchEntity;
-
- if ( null == $switcher) {
- $resultArr = [];
-
- $asusgJob2LaunchEntity = new AsusgJob2Launch();
- $asusgJob2LaunchEntity->asusg_jobplan_id = $JobPlanEntitty->id;
- $asusgJob2LaunchEntity->asusg_employee_id1 = $user->id;
- $asusgJob2LaunchEntity->asusg_job_uuid = $work['id_work'];
- $asusgJob2LaunchEntity->employees_uuid = $user->uuid;
- $asusgJob2LaunchEntity->section_uuid = $work["section_id"];
- $asusgJob2LaunchEntity->asusg_project_id = 0;
- $asusgJob2LaunchEntity->job_order = 0;
- $asusgJob2LaunchEntity->asusg_projecttype_id = $projtype;
- $asusgJob2LaunchEntity->time_limit = $dwResult['time_limit'];
- $asusgJob2LaunchEntity->outfit = $dwResult['outfit'];
- $asusgJob2LaunchEntity->name = $work['work_name'];
- $asusgJob2LaunchEntity->section_name = $work["section_lit"];
- if (!$asusgJob2LaunchEntity->save()) {
- $this->logger->setLog('в Job2launch не добавилась работа => "'. $work['work_name']. '" Добавление работ будет пропущено так как такая запись уже есть.');
- continue;
- }
- $this->issetLaunch = true;
- $this->logger->setLog($this->prepareLogString);
- $this->prepareLogString = '';
- $this->logger->setLog('в Job2launch была добавлена работа => "'. $work['work_name'].'"');
- /// сначала генерю проект
-
- $projId = $this->generateProject($work);
- /// сначала генерю проект
- } else {
- $userUuidArr = explode(',', $asusgJob2LaunchEntity->employees_uuid);
- if ( in_array( $user->uuid , $userUuidArr)) { // если сотрудник уже привязан к лаунчу
- $this->logger->setLog('сотрудник '.$user->name .' ('.$user->id.') уже привязан к лаунчу'. $asusgJob2LaunchEntity->id);
- continue;
- } else {
- $asusgJob2LaunchEntity->employees_uuid .= ','. $user->uuid;
- $asusgJob2LaunchEntity->save();
- $this->logger->setLog('сотрудники ('.$asusgJob2LaunchEntity->employees_uuid.') привязаны к лаунчу'. $asusgJob2LaunchEntity->id);
- }
-
- //continue;
- $this->prepareLogString .= "ВОТ ТУТ Я ХОТЕЛ ПОЛУЧИТЬ ИД ПРОЕКТА ЧЕРЕЗ ЗАДАЧУ => " . $asusgJob2LaunchEntity->tasks->id .", ВОТ ЧТО ПОЛУЧИЛ => " . $asusgJob2LaunchEntity->tasks->input_id ."!\n";
-
- $projId = $asusgJob2LaunchEntity->tasks->input_id;
- }
- /////////////// ДОБАВЛЕНИЕ ЗАДАЧИ
- $this->prepareLogString .= "\n 3. ДОБАВЛЕНИЕ ЗАДАЧИ \n\n";
- $tasktypesEntity = Tasktypes::find()->where(['name' => 'Секция '.$let.', задача','company' => $this->company])->one();
- $tasksEnt = Tasks::find()->where(['parent_id' => 0,'asusg_job_mapped_id' => $asusgJob2LaunchEntity->id,'assignees_arr' => $user->id])->one();
- if ( null != $tasksEnt) {
- continue;
- }
- $this->logger->setLog($this->prepareLogString);
- $this->prepareLogString = '';
- $tasksEntity = new Tasks();
- $tasksEntity->parent_id = 0;
- $tasksEntity->status = 2;
- $tasksEntity->type = $tasktypesEntity->id;
- $tasksEntity->assignees_arr = $user->id;
- $tasksEntity->preferred_assignee = $user->id;
- $tasksEntity->created = date("Y-m-d H:i;s");
- $tasksEntity->asusg_job_mapped_id = $asusgJob2LaunchEntity->id;
- $tasksEntity->mapping_comment = $work["outfit"] . ': ' . $work['work_name'];
- $tasksEntity->text = $work["section_lit"] . "\n" . $work["outfit"] . ': ' . $work['work_name'] . "\n" . $dwResult['workers'];
-
- if($tasksEntity->save()) {
- //$this->testIdpl3 = $tasksEntity->id;
- $this->logger->setLog('в Tasks была добавлена ЗАДАЧА => "'. $work['work_name'] . '" id => '.$tasksEntity->id);
- } else {
- $this->logger->setLog('в Tasks была НЕ добавлена ЗАДАЧА => "'. $work['work_name'] . '" id => '.$tasksEntity->id);
- }
- //var_dump($tasksEntity->errors,$user->id); echo '<br>';
- $this->logger->setLog(' колво записей => ' . count($jsusgJob2CommandEntity) . 'type => '. gettype($jsusgJob2CommandEntity));
-
-
- $arrJ = [];
- //$countPriority = 1;
- /////////////////
- if ( null == $switcher) {
- $this->logger->setLog("switcher = null");
- ///////////////// ДОБАВЛЕНИЕ ТМЦ
- $mappingapiModel = new \app\models\MappingapiModel();
- //var_dump($user->id-uuid,$work['id_work']);
- $this->logger->setLog("сотрудник => " . $user->uuid . ", работа => " . $work['id_work']);
-
- $tmcString = $mappingapiModel->workDetail($user->uuid,$work['id_work']);
- $this->logger->setLog("\n ДОБАВЛЕНИЕ ТМЦ " . strlen($dwResult['tmcString']) . "\n");
- if ( '' != $dwResult['tmcString']) {
- $tasksEntity3 = new Tasks();
- $tasksEntity3->parent_id = $tasksEntity->id; // +
- $tasksEntity3->status = 2; // +
- $tasksEntity3->priority = Yii::$app->params['countPriority']; // +
- // $tasksEntity2->input_id = $job->asusgJob2Launch->asusg_project_id;
- $tasksEntity3->created = date("Y-m-d H:i;s"); // +
- $tasksEntity3->type = 2159; // +
- $tasksEntity3->assignees_arr = $user->id; // +
- $tasksEntity3->preferred_assignee = $user->id; // +
- $tasksEntity3->asusg_job_mapped_id = $asusgJob2LaunchEntity->id;
- $tasksEntity3->text = $dwResult['tmcString']; // +
- $tasksEntity3->mapping_comment = $dwResult['tmcString']; // +
- $tasksEntity3->input_id = $projId;
- if ( $tasksEntity3->save()) {
- var_dump('создана ТМЦ, задача =>' . $tasksEntity3->id);
- $arrJ[] = $tasksEntity3->id;
- $query3 = "call asusg_add_checkpoints_to_task(" . $user->id . ",'" . $tasksEntity3->id . "')";
- $resProc = Yii::$app->db->createCommand($query3)->query();
- $logResProc = 'false';
- if ($resProc){
- $logResProc = 'true';
- }
- $this->logger->setLog('в Tasks была добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity3->id. ' процедура => ' . $logResProc);
- } else {
- var_dump('не создана ТМЦ');
- $this->logger->setLog('в Tasks была НЕ добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity3->id);
- }
- Yii::$app->params['countPriority']++;
- }
-
- ///////////////////
-
- ///////////////// ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 0
- $this->logger->setLog("\n 4. ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 0 \n");
- //var_dump(Yii::$app->params['api']['hw_msrmnt_stat'][ $dwResult["hw_measurements_status"] ],$dwResult["hw_measurements_status"]); echo "\n";
- //if ( Yii::$app->params['api']['hw_msrmnt_stat'][ $dwResult["hw_measurements_status"] ]) { // выполнение hw_measurements_status = waiting
- $paramsMeaserm = ['input_id' => $projId, 'assignees_arr' => $user->id, 'work' => $work,'stage' =>0, 'parent_id' => $tasksEntity->id ,'stage_type' => 'доремонтный','asusg_job_mapped_id' => $asusgJob2LaunchEntity->id];
- Yii::$app->params['api']['mesrmntParam'] = $paramsMeaserm;
- MappingapiModel::workMeasurements($work['id_work'],$user->uuid);
- //}
- ///////////////////
- }
-
- /////////////// НА РЕМОНТ
- $this->logger->setLog("\n 5. ДОБАВЛЕНИЕ НА РЕМОНТ \n");
- foreach($jsusgJob2CommandEntity as $job) {
-
- $tasksEntity2 = new Tasks();
- $tasksEntity2->parent_id = $tasksEntity->id;
- $tasksEntity2->status = 2;
- $tasksEntity2->priority = Yii::$app->params['countPriority'];
- // $tasksEntity2->input_id = $job->asusgJob2Launch->asusg_project_id;
- $tasksEntity2->created = date("Y-m-d H:i;s");
- $tasksEntity2->type = $job->smopp_cmd_id;//Yii::$app->params['supercycletype'];
- $tasksEntity2->assignees_arr = $user->id;
- $tasksEntity2->preferred_assignee = $user->id;
- $tasksEntity2->asusg_job_mapped_id = $job->jobplantie->id;
- $tasksEntity2->text = $work["eq_serie"] . ' '.$work["section_lit"] . ', '. $work["outfit"] . ':' . $work['work_name'];
- $tasksEntity2->mapping_comment = $work["outfit"] . ': ' . $work['work_name'];
- if ( $tasksEntity2->save()) {
- $arrJ[] = $tasksEntity2->id;
- ///////////////////
- //$query3 = "call asusg_add_checkpoints_to_task(" . $user->id . ",'" . $tasksEntity2->id . "')";
- //$resProc = Yii::$app->db->createCommand($query3)->query();
- ///////////////////
- $this->logger->setLog('в Tasks была добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity2->id);
- } else {
- $this->logger->setLog('в Tasks была НЕ добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity2->id);
- }
- Yii::$app->params['countPriority']++;
- }
-
- /////////////////////////////////////
-
-
- // $projId = $this->generateProject3($work);
- $tasksEntity->input_id = $tasksEntity->input_id ?? $projId;
- if ($tasksEntity->save()) {
- $this->logger->setLog('привязка ЗАДАЧИ ( id = '.$tasksEntity->id.') прошла успешно');
- }
- $tasksEntity = null;
-
- foreach($arrJ as $job_id) {
- $tasksEnt = Tasks::findOne($job_id);
- $tasksEnt->input_id = $tasksEnt->input_id ?? $projId;
-
- if($tasksEnt->save()){
- $this->logger->setLog('привязка КОМАНДЫ ( id = '.$tasksEntity2->id.') прошла успешно');
- } else {
- $this->logger->setLog('привязка КОМАНДЫ ( id = '.$tasksEntity2->id.') прошла не успешно');
- }
- }
- if ( null != $tasksEntity3) {
- $tasksEntity3->input_id = $projId;
- //if($tasksEntity3->save()){
- // $this->logger->setLog('привязка КОМАНДЫ ТМЦ ( id = '.$tasksEntity3->id.') прошла успешно');
- //}
- }
-
- if ( null == $switcher) {
-
- ///////////////// ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 1
- $this->logger->setLog("\n 6. ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 1 \n");
- //if ( Yii::$app->params['api']['hw_msrmnt_stat'][ $dwResult["hw_measurements_status"] ]) { // выполнение hw_measurements_status = waiting
- $paramsMeaserm['stage'] = 1;
- $paramsMeaserm['stage_type'] = 'контрольный';
- $paramsMeaserm['asusg_job_mapped_id'] = $asusgJob2LaunchEntity->id;
- Yii::$app->params['api']['mesrmntParam'] = $paramsMeaserm;
- MappingapiModel::workMeasurements($work['id_work'],$user->uuid);
- //}
- ///////////////////
-
- ///////////////// ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 2
- $this->logger->setLog("\n 7. ДОБАВЛЕНИЕ ЗАМЕРОВ ЭТАП 2 \n");
- //if ( Yii::$app->params['api']['hw_msrmnt_stat'][ $dwResult["hw_measurements_status"] ]) { // выполнение hw_measurements_status = waiting
- $paramsMeaserm['stage'] = 2;
- $paramsMeaserm['stage_type'] = 'послеремонтный';
- $paramsMeaserm['asusg_job_mapped_id'] = $asusgJob2LaunchEntity->id;
- Yii::$app->params['api']['mesrmntParam'] = $paramsMeaserm;
- MappingapiModel::workMeasurements($work['id_work'],$user->uuid);
- //}
- ///////////////////
- //
- }
- Yii::$app->params['countPriority']= 1;
- //echo "<pre>";
- //var_dump($job->asusgJob2Launch->asusg_project_id);
- //var_dump($tasksEntity2->errors,$tasksEntity->errors);
- //echo "</pre>";
-
- }
- }
-
-
- public function generateProject($work){
-
- $this->logger->setLog("\n 2. ГЕНЕРАЦИЯ ПРОЕКТА \n");
-
-
- $result = '';
- $let = mb_substr($work["section_lit"], -1);
-
- $sectionsEntity = Sections::find()->select(['id', 'diagnostic_map'])
- //->where(['locomotive_series' => $work["eq_serie"],'section_number' => mb_substr($work['section_lit'],0,-1),'letter' => $let])
- ->where(['locomotive_series' => $work["eq_serie"],'section_number' => mb_substr($work['section_lit'],0,-1),'section_subnumber' => $work["section_num"]])
- ->one();
- $this->logger->setLog("Параметры локомотива locomotive_series => " . $work["eq_serie"]. ", section_number => " . $work['section_lit'] . " ,letter => " .$let. " \n");
- $diagnostic_map = $sectionsEntity->diagnostic_map;
-
- if ( null == $sectionsEntity->id) {
- $sectionsEntity2 = new Sections();
- $sectionsEntity2->locomotive_series = $work["eq_serie"];
- $sectionsEntity2->section_number = mb_substr($work['section_lit'],0,-1);
- $sectionsEntity2->section_subnumber = $work["section_num"];
- $sectionsEntity2->diagnostic_map = $work["section_DK"];
- $sectionsEntity2->uuid = $work["section_id"];
- $sectionsEntity2->letter = $let;
- if ( $sectionsEntity2->save()) {
- $this->logger->setLog('в Sections была добавлена новая секция => '. $work["section_num"] . ' id => '.$sectionsEntity2->id);
- } else {
- //var_dump($sectionsEntity2->errors);
- $this->logger->setLog('в Sections при добавлении секции произошли ошибки => '. count($sectionsEntity2->errors) . ' шт.');
- $sectionsEntity->diagnostic_map = $work['section_DK'];
- $sectionsEntity->save();
- $this->logger->setLog('Пришлось просто обновить диагностическую карту секция=> '. $sectionsEntity . ', номер карты =>' . $work['section_DK']);
- }
- $diagnostic_map = $sectionsEntity->diagnostic_map;
- }
- else if( null == $sectionsEntity->diagnostic_map ) {
- $sectionsEntity->diagnostic_map = $work['section_DK'];
- $sectionsEntity->save();
- }
-
-
-
-
- if ($sectionsEntity->diagnostic_map == $work['section_DK'] ) {
-
- $query = "select pl.id from projects_locotech pl
- inner join tasks t on pl.id = t.input_id
- left join tasktypes tt on t.type = tt.id
- where pl.company = " . $this->company . "
- and pl.loco_type = '" . $work["eq_serie"] . "'
- and pl.loco_number = " . $work["eq_number"] . "
- and t.parent_id = 0
- and tt.letter like '%" . $let . "%'
- and pl.uuid like '%" . $work['repair_name']. ",%'
- order by pl.id desc
- limit 1";
- $projectId = Yii::$app->db->createCommand($query)->queryOne();
-
- $result = $projectId['id'];
- $this->logger->setLog('в Sections секция с такой диагностической картой => '. $work['section_DK'] . ' существует. Ид проекта '. $result);
- }
-
- if (!$result) {
- $projectsLocotech = new ProjectsLocotech();
- $projectsLocotech->action = 197 ;
- $projectsLocotech->company = $this->company;
- $projectsLocotech->status = 2;
- $projectsLocotech->loco_type = $work["eq_serie"];
- $projectsLocotech->loco_number = $work["eq_number"];
- $projectsLocotech->depo ='' ;
- $projectsLocotech->depo_service = '';
- $projectsLocotech->created = date('Y-m-d H:i:s');
- $projectsLocotech->urgent = 0;
- $projectsLocotech->uuid = $work['work_name'].":".$work['repair_name'].",".$work["eq_serie"];
- $projectsLocotech->save();
- $result = $projectsLocotech->id;
- $this->logger->setLog('Такого проекта еще не было пришлось создать. Ид проекта => '. $result);
- }
- //var_dump($result);
- return $result;
- }
-
- public function generateProject3($work){
-
- $result = '';
- $projectsLocotech = new ProjectsLocotech();
- $projectsLocotech->action = 197 ;
- $projectsLocotech->company = $this->company;
- $projectsLocotech->status = 2;
- $projectsLocotech->loco_type = $work["eq_serie"];
- $projectsLocotech->loco_number = $work["eq_number"];
- $projectsLocotech->depo ='' ;
- $projectsLocotech->depo_service = '';
- $projectsLocotech->created = date('Y-m-d H:i:s');
- $projectsLocotech->urgent = 0;
- $projectsLocotech->uuid = $work['work_name'].":".$work['repair_name'].",".$work["eq_serie"];
- $projectsLocotech->save();
- $result = $projectsLocotech->id;
- $this->logger->setLog('Такого проекта еще не было пришлось создать. Ид проекта => '. $result);
-
- //var_dump($result);
- return $result;
- }
-
- private function prepareListWorks($listWorks) {
-
- $result = [];
- $dataArr = [];
- if ( null == $listWorks || empty($listWorks)) {
- return [];
- }
-
-
- foreach ( $listWorks["rows"] as $rows) {
-
- $rows["result"] = json_decode($rows["result"],true);
-
- foreach ( $rows["result"]['data'] as $key => $data) {
-
- //echo '<pre>';
- // var_dump($data);
- // echo '</pre>';
- $tempArray = [];
- $tempArray["eq_serie"] = explode(" ",$data["equip_sect_name"])[0];
- $eq = explode(" ",$data["equip_sect_name"])[1];
- $tempArray["eq_number"] = explode("/",$eq)[0];
- //echo '<pre>';
- //var_dump($tempArray["eq_number"]);
- //echo '</pre>';
- foreach ( $data["sections"] as $sections) {
- $tempArray["section_id"] = $sections["id_section"];
- $tempArray["section_lit"] = $sections["section_name"];
- //$this->getLocoInfoMore($sections["section_subnumber"]);
- $tempArray["section_num"] = $sections["section_subnumber"];
- $tempArray["section_DK"] = $sections["section_dk"];
- // echo '<pre>';
- // var_dump($sections);
- // echo '</pre>';
-
- foreach ( $sections['works'] as $work) {
-
-
- $tempArray["id_work"] = $work["id_work"];
- $tempArray["outfit"] = $work["outfit"];
- $tempArray["work_name"] = $work["work_name"];
- $tempArray["repair_name"] = $work["repair_type"];
- $tempArray["work_status"] = $work["work_status"];
- $tempArray["repeats"] = $work["repeats"];
-
- //$extraSection = $this->getSectionInfo( $tempArray["section_id"], $tempArray["repair_name"]);
-
- //$tempArray["section_num"] = $extraSection['section_num'];
- //$tempArray['section_DK'] = $extraSection['section_DK'];
-
- $dataArr[] = $tempArray;
-
- foreach ( $works['workers'] as $worker) {
- //echo '<pre>';
- //var_dump($worker);
- //echo '</pre>';
- }
- }
- }
- }
- $result['result'] = 'true';
- $result['data'] = $dataArr;
- break;
- }
- return $result;
- }
-
- private function sectionList() {
-
- $result = [];
- //$params['place'] = 'a84d0a15-08ec-11e5-829d-00155d6cab05';
- //$params['place'] = '95d7646d-e7ee-11e4-829d-00155d6cab05';
- $params['place'] = 'a84d0a15-08ec-11e5-829d-00155d6cab05';
- $params['date'] = '1581324560';
- $locomotiveModel = new LocomotiveModel();
- $result = $locomotiveModel->getSectionList($params);
- //$result = json_decode($result,true);
- //$this->sectionList = $result['array'];
- $this->sectionList = json_decode($result,true);
- return $result;
- }
-
- private function getSectionInfo( $id,$repair) {
-
- $result = [];
- if (empty($this->sectionList)) {
- $this->sectionList();
- }
-
- foreach ($this->sectionList as $items) {
- //var_dump($section["Section"] .' == '. $id , $section['TypeOfRepair'] .' == '. $repair); echo '<br>';
-
- foreach ( $items as $section) {
- if ( $section["Section"] == $id and $section['TypeOfRepair'] == $repair ) {
-
- $result['section_num'] = $section["NumberSection"];
- $result['section_DK'] = $section['DiagnosticMapslocomotive'];
- return $result;
- }
- }
- }
- return $result;
- }
-
- private function buisyEmployee($user){
- $tasksEntity = Tasks::find()->where(['assignees_arr' => $user->id])->andWhere(['<>','status',5])->all();
-
- if ( null != $tasksEntity){
- var_dump('Return =>true');
- return true;
- }
- var_dump('Return =>false');
- return false;
- }
-
- }
- /*
- int(349)
- array(2) {
- ["dataShape"]=>
- array(1) {
- ["fieldDefinitions"]=>
- array(1) {
- ["result"]=>
- array(5) {
- ["name"]=>
- string(6) "result"
- ["description"]=>
- string(0) ""
- ["baseType"]=>
- string(4) "TEXT"
- ["ordinal"]=>
- int(0)
- ["aspects"]=>
- array(0) {
- }
- }
- }
- }
- ["rows"]=>
- array(1) {
- [0]=>
- array(1) {
- ["result"]=>
- string(1290) "{"result":"true",
- "data":
- [{"id_equipment":"95078df8-4487-46b9-9771-5c6b6e1f6b81",
- "equip_sect_name":"3ЭС5К 0362/3ЭС5К", // ["eq_serie"]/ ["eq_number"]
- "sections":
- [{"works":
- [{"id_work":"a7869ca0-0153-41f5-93c4-51393ccc574a",
- "repeats":1,
- "work_name":"Тормозное и пневматическое оборудование после ремонта испытать, // ["work_name"]
- отрегулировать согласно инструкции",
- "work_status":4,
- "workers":
- [{"id":"0f9ed850-e473-11e2-aaad-ac162db0b20c","fio":"Новосад Я. И."},
- {"id":"0f9ed854-e473-11e2-aaad-ac162db0b20c","fio":"Ознобихин О. А."}],
- "measurements":"--/--/--"}],
- "section_name":"0362А", // ["section_lit"]
- "id_section":"6ddd13a5-986b-11e2-99b5-ac162db0b20c"}, // ["section_id"]
-
- {"works":
- [{"id_work":"a0a572e0-4d70-45d7-ac4a-9483933c70b9",
- "repeats":1,
- "work_name":"Тормозное и пневматическое оборудование после ремонта испытать,
- отрегулировать согласно инструкции",
- "work_status":4,
- "workers":
- [{"id":"0f9ed850-e473-11e2-aaad-ac162db0b20c","fio":"Новосад Я. И."},
- {"id":"0f9ed854-e473-11e2-aaad-ac162db0b20c","fio":"Ознобихин О.А."}],
- "measurements":"--/--/--"}],
- "section_name":"0362В",
- "id_section":"6ddd13a6-986b-11e2-99b5-ac162db0b20c"}],
- "equip_percent":10730}]}"
- }
- }
- }
- repair_name - ?
- section_num - ? +
- outfit - ?
- section_DK - ?
- int(349)
- array(2) {
- ["result"]=>
- string(4) "true"
- ["data"]=>
- array(2) {
- [0]=>
- array(10) {
- ["id_work"]=>
- string(36) "a7869ca0-0153-41f5-93c4-51393ccc574a" +
- ["section_DK"]=>
- string(36) "6d4acb88-685e-11ea-80d6-005056011052" +
- ["eq_number"]=>
- string(4) "0362" +
- ["outfit"]=>
- float(1460789) +
- ["work_name"]=>
- string(187) "Тормозное и пневматическое оборудование после ремонта испытать , отрегулировать согласно инструкции" +
- ["section_id"]=>
- string(36) "6ddd13a5-986b-11e2-99b5-ac162db0b20c" +
- ["section_num"]=>
- string(8) "11381969" +
- ["section_lit"]=>
- string(6) "0362А" +
- ["repair_name"]=>
- string(6) "ТР-1" +
- ["eq_serie"]=>
- string(8) "3ЭС5К" +
- }
- [1]=>
- array(10) {
- ["id_work"]=>
- string(36) "a0a572e0-4d70-45d7-ac4a-9483933c70b9"
- ["section_DK"]=>
- string(36) "6d4acb89-685e-11ea-80d6-005056011052"
- ["eq_number"]=>
- string(4) "0362"
- ["outfit"]=>
- float(1460871)
- ["work_name"]=>
- string(187) "Тормозное и пневматическое оборудование после ремонта испытать , отрегулировать согласно инструкции"
- ["section_id"]=>
- string(36) "6ddd13a6-986b-11e2-99b5-ac162db0b20c"
- ["section_num"]=>
- string(8) "11381985"
- ["section_lit"]=>
- string(6) "0362В"
- ["repair_name"]=>
- string(6) "ТР-1"
- ["eq_serie"]=>
- string(8) "3ЭС5К"
- }
- }
- }
- */
|