123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744 |
- <?php
- namespace app\controllers;
- use Yii;
- 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\entity\Tasktypes;
- 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\MainMappingModel;
- use app\models\procedure\StartProjectForLocoModel;
- class MappinghandlertestController extends Controller
- {
- private $logger;
- private $company;
- private $entityManager;
-
- public function beforeAction($action)
- {
- parent::beforeAction($action);
- $log = new LoggerFile();
-
- $this->logger = new MappingHandlerModel($log);
- return true;
- }
-
- // запускается периодически через крон
-
- public function actionGetworks($company)
- {
- $mainMappingModel = new MainMappingModel($company);
- $GWparams = ['url' => 'http://devplatform.digitaldepot.ru:8085/Thingworx/Things/SMoPPIntegrationLibrary/Services/getUserWorks',
- 'param' => '',
- 'login' => 'ПройдаковИА',
- 'pass' => 'Ip15351112'
- ];
-
- // список сотрудников онлайн
- $onlineUser = $mainMappingModel->getOnlineMobileUser($company);
- if( 0 == count($onlineUser)) {
- return 'Нет сотрудников онлайн';
- }
-
- // ПОЛУЧАЮ СПИСОК ПОЛЬЗОВАТЕЛЕЙ ОНЛАЙН + НАПАРНИКИ ПО РАБОТАМ
- $onlineUserPlus = $mainMappingModel->onlineUserPlus($onlineUser);
-
- $mainMappingModel->MappingStart($onlineUserPlus);
- }
-
-
-
-
- public function addWorksInJobPlan($listWorks) {
-
- $result = [];
- if (empty($listWorks)){
- return $result;
- }
- $arrayIdWorks = [];
- foreach( $listWorks->data as $work ) {
- $arrayIdWorks[] = $work;
- }
-
- foreach ($arrayIdWorks as $work){
- $asusgJobPlanEntity = new AsusgJobPlan();
- $asusgJobPlanEntity->name = $work->work_name;
- $asusgJobPlanEntity->sections = 'АБВ';
- if (!$asusgJobPlanEntity->save()) {
- $result[] = $asusgJobPlanEntity->errors;
- }
- }
- return $result;
-
- }
-
- // Добавление не существующих работ в Tasktype ( сверхцикловые )
-
- public function addWorksInTaskType($listWorks, $listIsabsentWorks ) {
-
- $result = $listIsabsentWorks;
- if (empty($listWorks)){
- return $result;
- }
- $arrayIdWorks = [];
- foreach( $listWorks->data as $work ) {
- $arrayIdWorks[] = $work;
- }
-
- foreach ($arrayIdWorks as $work){
- $tasktypesEntity = new Tasktypes();
- $tasktypesEntity->creator_id = 49 ;
- $tasktypesEntity->name = $work->work_name ;
- $tasktypesEntity->description = 'По запросу АСУ СГ: сверхцикловая работа' ;
- $tasktypesEntity->company = \Yii::$app->request->get('company');
- $tasktypesEntity->main_task = 0 ;
- $tasktypesEntity->confirmtype = 0 ;
- $tasktypesEntity->time_to_complete_minutes = 61 ;
- $tasktypesEntity->subtasks = '' ;
- $tasktypesEntity->letter = 'АБВ' ;
- if ($tasktypesEntity->save()) {
- $flag = 0;
- foreach($result as $task) {
- if ( $task->work_name == $tasktypesEntity->name ){
- $flag = 1;
- }
- }
- if ( 0 == $flag ) {
- $result[] = $work;//$tasktypesEntity->errors;
- }
- }
- }
- return $result;
-
- }
-
-
- // // новая версия GetworksOnLoco
-
- public function GetworksOnLoco($listWorks)
- {
- $result = [];
- if (empty($listWorks)){
- return $result;
- }
- $arrayResult = [];
- foreach ($listWorks as $work){
-
- $sectionsEntity = new Sections();
- $sectionsEntity->section_number = $work->eq_number;
- $sectionsEntity->locomotive_series = $work->eq_serie;
- $sectionsEntity->section_subnumber = $work->section_num;
- $sectionsEntity->uuid = $work->section_id;
- $sectionsEntity->diagnostic_map = $work->section_DK;
- $sectionsEntity->letter = mb_substr($work->section_lit, -1);
- if (! $sectionsEntity->save()) {
- continue;
- }
- }
-
- foreach ($listWorks as $work){
- $arrayResult[] = $work->section_id;
- }
-
- $sectionsEntity = Sections::find()->where(['in','uuid',$arrayResult])->asArray()->all();
-
- $arrayResult = [];
- $arrayResultTemp = [];
- $arrayIdSerieTemp = [];
- foreach($sectionsEntity as $sec){
- $arrayResult[] = $sec['uuid'];
- $arrayResultTemp[$sec['uuid']] = $sec;
-
- $LocomotiveSeriesEntity = LocomotiveSeries::findOne(['name' => $sec['locomotive_series']]);
- $arrayIdSerieTemp[$sec['uuid']] = $LocomotiveSeriesEntity->id;
- }
- $tempArray = [];
-
- foreach($listWorks as $w) {
- //var_dump(( in_array($w->section_id,$arrayResult)), $w->section_id .' ==', );
- if ( in_array($w->section_id,$arrayResult)) {
- $tempArray[] = $w;
- $result[$w->section_id] = [ 'info_obj' => $tempArray ,'info'=> $arrayResultTemp[$w->section_id],'id_serie' => $arrayIdSerieTemp[$w->section_id]];
- }
- }
- return $result;
- }
-
-
- public function checkMapping($arrProj)
- {
- $tempResult = [];
- $result = [];
-
- foreach ( $arrProj as &$proj) {
- foreach ( $proj['info_obj'] as $work) {
- $tempResult[] = $work->work_name;
- }
- $res = AsusgJobPlan::find()->where(['in', 'name',$tempResult])->all();
- $proj['jobplan'] = $res;
- }
- return $arrProj;
- }
-
- public function addJobproject($minRes)
- {
- $projectTypes = [];
- foreach ( $minRes as &$proj) {
-
- foreach($proj['info_obj'] as $obj){
- $repairtypesEntity = Repairtypes::find()->select('id')->where(['name'=> $obj->repair_name])->one();
- $projectTypes[] = $repairtypesEntity->id;
- }
- $projectTypes = array_unique($projectTypes);
-
- foreach ( $projectTypes as $type) {
-
- $field = Yii::$app->params['sections_letter'][$proj['info']["letter"]];
- $asusgProjectEntity = new AsusgProject();
- $asusgProjectEntity->loco_serie_id = $proj['id_serie']; //locomotive_series
- $asusgProjectEntity->repair_type = $type; // repairtypes name из асусг
- $asusgProjectEntity->loco_number = $proj['info']["section_number"];
- $asusgProjectEntity->$field = $proj['info']["section_subnumber"];
- $asusgProjectTypeEntity = AsusgProjectType::findOne(['loco_serie_id' => $proj['id_serie'], 'repair_type' => $type]);
- $asusgProjectEntity->asusg_projecttype_id = $asusgProjectTypeEntity->id;
- $asusgProjectEntity->save();
-
- echo "<pre>";
- var_dump($asusgProjectEntity->errors);
-
- //var_dump("Выполнение процедуры => " . $res);
- echo "</pre>";
-
- $proj['asusgProject_id'] = $asusgProjectEntity->id;
- $proj['repair_type'] = $type;
- }
- }
- return $minRes;
- }
-
- public function addJob2launch($minRes)
- {
-
- foreach ( $minRes as $proj) {
- $resultArr = [];
- $order = 1;
- foreach ( $proj['jobplan'] as $work) {
- $sectionTemp = '';
- $id_workTemp = '';
- foreach($proj['info_obj'] as $obj){
- //var_dump(( $obj->work_name == $work->name), $obj->work_name.' =='. $work->name);
- if( $obj->work_name == $work->name){
- $sectionTemp = $obj->section_id;
- $id_workTemp = $obj->id_work;
- break;
- }
- }
-
- $asusgJob2LaunchEntity = new AsusgJob2Launch();
- $asusgJob2LaunchEntity->asusg_jobplan_id = $work->id;
- $asusgJob2LaunchEntity->asusg_employee_id1 = $proj['userInfo']->id;
- $asusgJob2LaunchEntity->asusg_job_uuid = $id_workTemp;
- $asusgJob2LaunchEntity->section_uuid = $sectionTemp;
- $asusgJob2LaunchEntity->asusg_project_id = $proj['asusgProject_id'];
- $asusgJob2LaunchEntity->job_order = $order;
- $asusgProjectTypeEntity = AsusgProjectType::findOne(['loco_serie_id' => $proj['id_serie'], 'repair_type' => $proj['repair_type']]);
- //var_dump($id_workTemp);
- //var_dump($proj['id_serie'],$proj['repair_type']);
- //var_dump($asusgProjectTypeEntity->id);
- $asusgJob2LaunchEntity->asusg_projecttype_id = $asusgProjectTypeEntity->id;
- $asusgJob2LaunchEntity->save();
-
-
-
- echo "<pre>";
- var_dump($asusgJob2LaunchEntity->id);
- var_dump($asusgJob2LaunchEntity->errors);
- //var_dump($sectionsEntity);
- echo "</pre>";
- $order++;
- }
-
- }
-
-
- }
-
- 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)
- {
- require_once $_SERVER["DOCUMENT_ROOT"].'/functions.php';
-
- //var_dump(gettype($this->entityManager));
-
- foreach ( $listWorks as $work) {
-
-
- $projtype = $this->getProjectType($work["repair_name"],$work["eq_serie"]);
- $let = mb_substr($work["section_lit"], -1);
- $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->id;
- $asusgJob2LaunchEntity->section_uuid = $work["section_id"];
- $asusgJob2LaunchEntity->asusg_project_id = 0;
- $asusgJob2LaunchEntity->job_order = 0;
- //$asusgJob2LaunchEntity->asusg_projecttype_id = 0;
- $asusgJob2LaunchEntity->asusg_projecttype_id = $projtype;
- if (!$asusgJob2LaunchEntity->save()) {
- $this->logger->setLog('в Job2launch не добавилась работа => "'. $work['work_name']. '" Добавление работ будет пропущено так как такая запись уже есть.');
- continue;
- }
- $this->logger->setLog('в Job2launch была добавлена работа => "'. $work['work_name'].'"');
-
-
- $tasktypesEntity = Tasktypes::find()->where(['name' => 'Секция '.$let.', задача','company' => $this->company])->one();
-
-
- $tasksEntity = new Tasks();
- $tasksEntity->parent_id = 0;
- $tasksEntity->status = 2;
- $tasksEntity->type = $tasktypesEntity->id;
- $tasksEntity->assignees_arr = $user->id;
- $tasksEntity->created = date("Y-m-d H:i;s");
- $tasksEntity->asusg_job_mapped_id = $asusgJob2LaunchEntity->id;
- if($tasksEntity->save()) {
- $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;
- ///////////////// ДОБАВЛЕНИЕ ТМЦ
-
- $mappingapiModel = new \app\models\MappingapiModel();
- var_dump($user->id-uuid,$work['id_work']);
- $tmcString = $mappingapiModel->workDetail($user->uuid,$work['id_work']);
-
- if ( '' != $tmcString) {
- $tasksEntity3 = new Tasks();
- $tasksEntity3->parent_id = $tasksEntity->id; // +
- $tasksEntity3->status = 2; // +
- $tasksEntity3->priority = $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->asusg_job_mapped_id = $asusgJob2LaunchEntity->id; // +
- $tasksEntity3->text = $tmcString; // +
- $tasksEntity3->mapping_comment = $tmcString; // +
- if ( $tasksEntity3->save()) {
- $this->logger->setLog('в Tasks была добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity3->id);
- } else {
- $this->logger->setLog('в Tasks была НЕ добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity3->id);
- }
- $countPriority++;
- }
-
- ///////////////////
-
-
- $tasksEntity2 = new Tasks();
- $tasksEntity2->parent_id = $tasksEntity->id;
- $tasksEntity2->status = 2;
- $tasksEntity2->priority = $countPriority;
- $tasksEntity2->created = date("Y-m-d H:i;s");
- $tasksEntity2->type = Yii::$app->params['supercycletype'];
- $tasksEntity2->assignees_arr = $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 . "')";
- 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);
- }
-
-
-
- $projId = $this->generateProject($work);
-
- $tasksEntity->input_id = $projId;
- if ($tasksEntity->save()) {
- $this->logger->setLog('привязка ЗАДАЧИ ( id = '.$tasksEntity->id.') прошла успешно');
- }
-
-
- $tasksEntity2->input_id = $projId;
- $this->logger->setLog('2 =>' .$asusgJob2LaunchEntity->id);
- if($tasksEntity2->save()){
- $this->logger->setLog('привязка КОМАНДЫ ( id = '.$tasksEntity2->id.') прошла успешно');
- }
-
- $tasksEntity3->input_id = $projId;
-
- if($tasksEntity3->save()){
- $this->logger->setLog('привязка КОМАНДЫ ( id = '.$tasksEntity2->id.') прошла успешно');
- }
- //echo "<pre>";
- //var_dump($tasksEntity2->errors,$tasksEntity->errors);
- //echo "</pre>";
-
- }
-
- }
-
- // Цикловые
-
- public function addJob2launch3($listWorks,$user)
- {
-
- require_once $_SERVER["DOCUMENT_ROOT"].'/functions.php';
-
- foreach ( $listWorks as $work) {
-
- $projtype = $this->getProjectType($work["repair_name"],$work["eq_serie"]);
- $JobPlanEntitty = AsusgJobplan::find()->where(['name' => $work["work_name"]])->one(); // 1204 1567
- $jsusgJob2CommandEntity = AsusgJob2Command::find()->where(['asusg_job_id' => $JobPlanEntitty->id, 'asusg_projecttype_id' => $projtype ])->all();
- /*
- //echo "<pre>";
- //var_dump($JobPlanEntitty->id,$projtype);
- //var_dump($JobPlanEntitty->id,$jsusgJob2CommandEntity);
- //echo "</pre>";
- //continue;
- $let = mb_substr($work["section_lit"], -1);
- $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->id;
- $asusgJob2LaunchEntity->section_uuid = $work["section_id"];
- $asusgJob2LaunchEntity->asusg_project_id = 0;
- $asusgJob2LaunchEntity->job_order = 0;
- $asusgJob2LaunchEntity->asusg_projecttype_id = $projtype;
- if (!$asusgJob2LaunchEntity->save()) {
- $this->logger->setLog('в Job2launch не добавилась работа => "'. $work['work_name']. '" Добавление работ будет пропущено так как такая запись уже есть.');
- continue;
- }
- $this->logger->setLog('в Job2launch была добавлена работа => "'. $work['work_name'].'"');
-
-
- $tasktypesEntity = Tasktypes::find()->where(['name' => 'Секция '.$let.', задача','company' => $this->company])->one();
- $tasksEntity = new Tasks();
- $tasksEntity->parent_id = 0;
- $tasksEntity->status = 2;
- $tasksEntity->type = $tasktypesEntity->id;
- $tasksEntity->assignees_arr = $user->id;
- $tasksEntity->created = date("Y-m-d H:i;s");
- $tasksEntity->asusg_job_mapped_id = $asusgJob2LaunchEntity->id;
-
-
- if($tasksEntity->save()) {
- $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));
- $this->logger->setLog($JobPlanEntitty->id . ' - ' . $projtype );
-
- $arrJ = [];
- $countPriority = 1;
-
- ///////////////// ДОБАВЛЕНИЕ ТМЦ
- $mappingapiModel = new \app\models\MappingapiModel();
- var_dump($user->id-uuid,$work['id_work']);
- $tmcString = $mappingapiModel->workDetail($user->uuid,$work['id_work']);
-
- if ( '' != $tmcString) {
- $tasksEntity2 = new Tasks();
- $tasksEntity2->parent_id = $tasksEntity->id; // +
- $tasksEntity2->status = 2; // +
- $tasksEntity2->priority = $countPriority; // +
- // $tasksEntity2->input_id = $job->asusgJob2Launch->asusg_project_id;
- $tasksEntity2->created = date("Y-m-d H:i;s"); // +
- $tasksEntity2->type = 2159; // +
- $tasksEntity2->assignees_arr = $user->id; // +
- $tasksEntity2->asusg_job_mapped_id = $asusgJob2LaunchEntity->id;
- $tasksEntity2->text = $tmcString; // +
- $tasksEntity2->mapping_comment = $tmcString; // +
- if ( $tasksEntity2->save()) {
- $arrJ[] = $tasksEntity2->id;
- $this->logger->setLog('в Tasks была добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity2->id);
- } else {
- $this->logger->setLog('в Tasks была НЕ добавлена КОМАНДА => "'. $work['work_name'] . '" id => '.$tasksEntity2->id);
- }
- $countPriority++;
- }
-
- ///////////////////
- */
- $arr = [];
-
- foreach($jsusgJob2CommandEntity as $job) {
- $this->logger->setLog('3 =>'. $job->jobplantie->id);
- $tasksEntity2 = new Tasks();
- $tasksEntity2->parent_id = $tasksEntity->id;
- $tasksEntity2->status = 2;
- $tasksEntity2->priority = $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->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'];
-
- $arr[] = $job->smopp_cmd_id;
- continue;
- if ( $tasksEntity2->save()) {
- $arrJ[] = $tasksEntity2->id;
- ///////////////////
- $query3 = "call asusg_add_checkpoints_to_task(" . $user->id . ",'" . $tasksEntity2->id . "')";
- 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);
- }
- $countPriority++;
- }
-
-
- $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();
- $project_id = $projectsLocotech->id;
-
- $tasktypesarr = Tasktypes::find()->where(['in','id',$arr])->all();
-
- CreateTasks($tasktypesarr, $project_id);
-
- echo "<pre>";
-
- var_dump($user->id);
- var_dump($tasktypesEntity);
- foreach($tasktypesEntity as $task) {
- var_dump($task->creator_id);
-
- }
- echo "</pre>";
- //
-
-
- /*
- $projId = $this->generateProject3($work);
- $tasksEntity->input_id = $projId;
- if ($tasksEntity->save()) {
- $this->logger->setLog('привязка ЗАДАЧИ ( id = '.$tasksEntity->id.') прошла успешно');
- }
-
-
- foreach($arrJ as $job_id) {
- $tasksEnt = Tasks::findOne($job_id);
- $tasksEnt->input_id = $projId;
-
- if($tasksEnt->save()){
- $this->logger->setLog('привязка КОМАНДЫ ( id = '.$tasksEntity2->id.') прошла успешно');
- }
- }
- //$tasksEntity2->input_id = $projId;
- //if($tasksEntity2->save()){
- // $this->logger->setLog('привязка КОМАНДЫ ( id = '.$tasksEntity2->id.') прошла успешно');
- //}
-
- echo "<pre>";
- //var_dump($job->asusgJob2Launch->asusg_project_id);
- var_dump($tasksEntity2->errors,$tasksEntity->errors);
- echo "</pre>";
- */
- }
- }
-
-
-
- public function pushProject($minRes)
- {
- var_dump(count($minRes));
- //var_dump($minRes);
- foreach ( $minRes as $proj) {
- $arr = ['initiator' => (int)$proj['userInfo']->id, 'project_id' => (int)$proj['asusgProject_id']];
-
- //$res = \Yii::$app->db->createCommand('call asusg_build_and_start_project('.$arr["initiator"].','.$arr["project_id"].')')->execute();
- $res = \Yii::$app->db->createCommand('call asusg_build_and_start_project_auto('.$arr["initiator"].','.$arr["project_id"].')')->execute();
- echo "<pre>";
- var_dump($arr);
-
- var_dump("Выполнение процедуры => " . $res);
- echo "</pre>";
- }
- }
-
-
- public function prepareParams($listWorks)
- {
- $result = [];
- foreach ( $listWorks as $work) {
- $work['user_id'] = '0f9ed850-e473-11e2-aaad-ac162db0b20c';
- $result[] = $work;
- $result = json_encode($result);
- return $result;//json_decode($result,false);
- }
- //$result = count();
-
- }
-
- public function generateProject($work){
-
- $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])
- ->one();
- $diagnostic_map = $sectionsEntity->diagnostic_map;
- if ( null == $sectionsEntity->id) {
- $sectionsEntity = new Sections();
- $sectionsEntity->locomotive_series = $work["eq_serie"];
- $sectionsEntity->section_number = mb_substr($work['section_lit'],0,-1);
- $sectionsEntity->section_subnumber = $work["section_num"];
- $sectionsEntity->diagnostic_map = $work["section_DK"];
- $sectionsEntity->uuid = $work["section_id"];
- $sectionsEntity->letter = $let;
- if ( $sectionsEntity->save()) {
- $this->logger->setLog('в Sections была добавлена новая секция => '. $work["section_num"] . ' id => '.$sectionsEntity->id);
- } else {
- $this->logger->setLog('в Sections при добавлении секции произошли ошибки => '. count($sectionsEntity->errors) . ' шт.');
- }
- $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;
- }
- }
|