'ПройдаковИА','pass' => 'Ip15351112']; private $responseEippMeasurement = ''; public $prepareLogString = ''; function __construct() { $log = new LoggerFile(); $this->logger = new MappingHandlerModel($log); } //public function workDetail($params) { public function workDetail($user_id, $work_id) { $this->GWparams = [ 'url' => Yii::$app->params['api']['domain'] . $this->url . 'work_detail', //'param' => ['user_id' => $params['user_id'], 'work_id' => $params['work_id']], 'param' => ['user_id' => $user_id, 'id_work' => $work_id], ]; //var_dump($this->GWparams['url'],$user_id,$work_id); ElasticLog::eipp($this->GWparams, $work_id, $user_id); $response = $this->curlRequestUni($this->GWparams,'post'); $work = json_decode($response,true); ElasticLog::eipp($response, $work_id, $user_id, false); //var_dump($work); $time = time(); LogEippResponse::addLog($time ."wd".$work_id,json_encode($work),'Детализация по работе, ответ ЕИПП'); $this->logger->setLog("\nДЕТАЛИЗАЦИЯ НАЧАЛО =====>\n"); $this->logger->setLog("Параметры: \n user_id => ".$user_id.",\n id_work => ".$work_id.".\n"); $this->logger->setLog("Строка запроса : \n ".$this->GWparams['url'] .".\n"); $this->logger->setLog("Вот тут можно посмотреть что ЕИПП прислал по запросу детализации http://dev.prmsys.net/api/mappinghandler/eippresponse?indx=".$time ."wd".$work_id."\n"); $this->logger->setLog("ДЕТАЛИЗАЦИЯ КОНЕЦ =====>\n\n"); return $this->getTmcList($work); } // для функции TasksCancel в server.php // public function setPause($accid, $maintask) { $params = []; $this->logger->setLog('setPause =>accid' . $accid . ' maintask =>' . $maintask); // завершаю задачу $taskEntity2 = Tasks::findOne($maintask); $launch = $taskEntity2->asusg_job_mapped_id; if ( null == $launch and null == $taskEntity2->accounts->uuid){ return true; } $taskEntity2->status = 5; //var_dump($maintask); try { $taskEntity2->save(); } catch (\yii\db\Exception $e) { echo 'Поймано исключение: ', $e->getMessage(), "\n"; } // $asusgJob2LaunchEntity = AsusgJob2Launch::findOne($launch); $asusgJob2LaunchEntity->asusg_job_uuid = $asusgJob2LaunchEntity->asusg_job_uuid . ' Отмена'; //var_dump($launch); try { $asusgJob2LaunchEntity->save(); } catch (\yii\db\Exception $e) { echo 'Поймано исключение: ', $e->getMessage(), "\n"; } $this->logger->setLog('setPause =>id_ launch' . $launch . ' work=>' . $asusgJob2LaunchEntity->id); // завершаю все команды Tasks::updateAll(['status' => 5],['parent_id' => $maintask]); // запрос к еипп $work_uuid = $taskEntity2->asusgjob2launch->asusg_job_uuid; $user_uuid = $taskEntity2->accounts->uuid; $params['user_id'] = $user_uuid; $params['id_work'] = $work_uuid; $params['id_reason'] = "прочее"; $params['comment'] = "прочее"; if ( null != $work_uuid) { $this->setPauseRequest($params); } return $params; } public static function workMeasurements($id_work, $id_user,$eipp_resp = ''){ //require_once $_SERVER["DOCUMENT_ROOT"].'/measurements.php'; self::$_instance = new self(); $time = time(); $params['user_id'] = $id_user; $params['work_id'] = $id_work['id_work']; self::$_instance->GWparams = ['url' => Yii::$app->params['api']['domain'] . self::$_instance->url . 'work_measurements', 'param' => $params, ]; self::$_instance->responseEippMeasurement = $eipp_resp; if ( '' == self::$_instance->responseEippMeasurement ) { ElasticLog::eipp(self::$_instance->GWparams, $params['work_id'], $params['user_id']); self::$_instance->responseEippMeasurement = self::$_instance->curlRequestUni(self::$_instance->GWparams,'post'); ElasticLog::eipp(self::$_instance->responseEippMeasurement, $params['work_id'], $params['user_id'], false); LogEippResponse::addLog($time."/".$id_work['id_work'],self::$_instance->responseEippMeasurement,'Ответ от ЕИПП по замерам, уровень: ' . Yii::$app->params['api']['mesrmntParam']['stage']); } //self::$_instance->logger->setLog('ResponseToMeasurement =>user' . $id_user . ' work=>' . $id_work); self::$_instance->logger->setLog( "\n ЗАМЕРЫ НАЧАЛО =====>"); self::$_instance->logger->setLog( "Параметры: \n user_id =>".$id_user.",\n work_id => ".$id_work['id_work']."."); self::$_instance->logger->setLog( "Строка запроса : \n ".self::$_instance->GWparams['url'] ."."); self::$_instance->logger->setLog( "Вот тут можно посмотреть что ЕИПП прислал по запросу замеров http://dev.prmsys.net/api/mappinghandler/eippresponse?indx=".$time."/".$id_work); self::$_instance->logger->setLog( " ЗАМЕРЫ КОНЕЦ =====>\n"); self::$_instance->ResponseToMeasurement(); return self::$_instance->responseEippMeasurement; } public static function workDeviceMeasurements($work, $id_user){ //require_once $_SERVER["DOCUMENT_ROOT"].'/measurements.php'; self::$_instance = new self(); $time = time(); $params['user_id'] = $id_user; $params['work_id'] = $id_work['id_work']; $params['measurement_stage'] = Yii::$app->params['api']['mesrmntParam']['stage']; $params['section_position_number'] = mb_substr($id_work['section_lit'], -1); self::$_instance->GWparams = ['url' => Yii::$app->params['api']['domain'] . self::$_instance->url . 'task_for_hw_measurements', 'param' => $params, ]; self::$_instance->responseEippMeasurement = $eipp_resp; if ( '' == self::$_instance->responseEippMeasurement ) { $reusltEipp = self::$_instance->curlRequestUni(self::$_instance->GWparams,'post'); LogEippResponse::addLog($time."/".$id_work,self::$_instance->responseEippMeasurement,'Ответ от ЕИПП по замерам, уровень: ' . Yii::$app->params['api']['mesrmntParam']['stage']); } $reusltEipp = json_decode( $reusltEipp, true ); //var_dump($reusltEipp['data']['task_id']); return $reusltEipp['data']['task_id'];; } public static function updateMeasurements($id_work){ //require_once $_SERVER["DOCUMENT_ROOT"].'/measurements.php'; //exit; self::$_instance = new self(); $time = time(); $tasksEntity = Tasks::findOne($id_work); $params['user_id'] = $tasksEntity->accounts->uuid; $params['work_id'] = $tasksEntity->asusgjob2launch->asusg_job_uuid; Yii::$app->params['api']['mesrmntParam']['stage'] = $tasksEntity->measurementone->measurement_stage; self::$_instance->GWparams = ['url' => Yii::$app->params['api']['domain'] . self::$_instance->url . 'work_measurements', 'param' => $params, ]; // self::$_instance->responseEippMeasurement = $eipp_resp; if ( '' == self::$_instance->responseEippMeasurement ) { self::$_instance->responseEippMeasurement = self::$_instance->curlRequestUni(self::$_instance->GWparams,'post'); LogEippResponse::addLog($time."/".$id_work['id_work'],self::$_instance->responseEippMeasurement,'Ответ от ЕИПП по замерам, уровень: ' . Yii::$app->params['api']['mesrmntParam']['stage']); } //self::$_instance->logger->setLog( "\n ЗАМЕРЫ НАЧАЛО =====>"); //self::$_instance->logger->setLog( "Параметры: \n user_id =>".$id_user.",\n work_id => ".$id_work['id_work']."."); //self::$_instance->logger->setLog( "Строка запроса : \n ".self::$_instance->GWparams['url'] ."."); //self::$_instance->logger->setLog( "Вот тут можно посмотреть что ЕИПП прислал по запросу замеров http://dev.prmsys.net/api/mappinghandler/eippresponse?indx=".$time."/".$id_work); //self::$_instance->logger->setLog( " ЗАМЕРЫ КОНЕЦ =====>\n"); self::$_instance->UpdateToMeasurement($id_work); //return self::$_instance->responseEippMeasurement; } private function getTmcList($work) { $result = []; $tenpArray = []; $count = 1; foreach($work['rows'] as $tmc1) { // echo "
"; //if ( $key == "cam_list") { //$tenpArray[] = $tmc4["tmc_name"]; //var_dump($tmc1); //} foreach($tmc1 as $tmc2) { $tmc2 = json_decode($tmc2,true); foreach($tmc2['data'] as $key => $tmc3) { //echo ""; $result[$key] = $tmc3; foreach($tmc3 as $tmc4) { if ( '' != $tmc4["tmc_name"]) { $tenpArray[] = $tmc4["tmc_name"]; } } if ( 'workers' == $key) { $result['workers'] = []; foreach($tmc3 as $key => $tmc5) { $result['workers'][] = $tmc5['fio']; $result['workers_uuid'][] = $tmc5['id']; } } if ( 'measurements' == $key) { $result['measurements'] = $this->CheckmeasurementField($tmc3); } } } } $result['tmcString'] = ''; if ( !empty($tenpArray) ) { $result['tmcString'] = implode("\n * ", $tenpArray); $result['tmcString'] = "* " . $result['tmcString']; } $result['workers'] = 'Назначены: ' . implode(', ',$result['workers']); //echo "
"; //var_dump($result); //echo ""; return $result; } private function setPauseRequest($params) { if ( !$params ) { return false; } $this->GWparams = ['url' => Yii::$app->params['api']['domain'] . $this->url . 'work_pause', 'param' => $params, ]; $mainModel = new MainModel(); $listWorks = json_decode($mainModel->curlRequestUni($this->GWparams,'post')); LogEippResponse::addLog($time."/".$maintask . "sp", $listWorks ,'Ответ от ЕИПП установка паузы' ); // тут ответ от еипп $listWorks параметры запроса $this->GWparams return true; } private function ResponseToMeasurement() { $json = json_decode($this->responseEippMeasurement); $counter = 0; foreach ($json->data as $item) { if ( intval($item->measurement_stage) != Yii::$app->params['api']['mesrmntParam']['stage']) { continue; } $counter++; } $this->logger->setLog('Количество замеров =>'. $counter); if ( 0 == $counter) { return true; } // 1. В первую очередь создается команда Yii::$app->params['api']['mesrmntParam']['type'] = Yii::$app->params['api']['mesrmntTaskType']; Yii::$app->params['api']['mesrmntParam']['measurement_name'] = 'Выполнить замер: ' . Yii::$app->params['api']['mesrmntParam']['stage_type']; $mappingHandlerModel = new MappingHandlerModel($this->logger); $res = $mappingHandlerModel->addNewTask(); $this->logger->setLog("в Tasks была добавлена КОМАНДА( ЗАМЕРЫ ) =>". $res['tasksEntity']->id . " \n приоритет =>" . (Yii::$app->params['countPriority']-1) ."\n статус => ". $res['tasksEntity']->status . "\n сотрудник => " . $res['tasksEntity']->assignees_arr); // 2.Далее записываю замеры foreach ($json->data as $item) { if ( intval($item->measurement_stage) != Yii::$app->params['api']['mesrmntParam']['stage']) { continue; } $AsusgMeasurementsEntity = new AsusgMeasurements(); $AsusgMeasurementsEntity->measurement_id = $item->measurement_id; $AsusgMeasurementsEntity->measurement_name = $item->measurement_name; $AsusgMeasurementsEntity->characteristic_id = $item->characteristic_id; $AsusgMeasurementsEntity->characteristic_name = $item->characteristic_name; $AsusgMeasurementsEntity->measurement_stage = intval($item->measurement_stage); $AsusgMeasurementsEntity->measurement_complete = intval($item->measurement_complete); $AsusgMeasurementsEntity->measurement_norm = $item->measurement_norm; $AsusgMeasurementsEntity->measurement_value = floatval($item->measurement_value); $AsusgMeasurementsEntity->value_type = $item->value_type; $AsusgMeasurementsEntity->value_compliance = intval($item->value_compliance); $AsusgMeasurementsEntity->worker = json_encode($item->worker); $AsusgMeasurementsEntity->measurement_date = $item->measurement_date; $AsusgMeasurementsEntity->measurement_comment = json_encode($item->measurement_comment); $AsusgMeasurementsEntity->work_id = $item->work_id; $AsusgMeasurementsEntity->is_hw_measurement = intval($item->is_hw_measurement); $AsusgMeasurementsEntity->smopp_date_requested = date('Y-m-d H:i:s'); $AsusgMeasurementsEntity->smopp_task_id = $res['tasksEntity']->id;//Yii::$app->params['api']['mesrmntParam']['parent_id']; $check = 'ручной'; if ( intval($item->is_hw_measurement)) { $check = 'аппаратный'; } //Yii::$app->params['api']['mesrmntParam']['measurement_name'] = "Замер " . $check. ' ' . Yii::$app->params['api']['mesrmntParam']['stage_type'] ." " . $item->characteristic_name ." - " . $item->measurement_name; $msrmnt_name = $item->characteristic_name ." - " . $item->measurement_name .". \n Норма: " . $item->measurement_norm; $this->logger->setLog("Сохранение в таблицу замеров. smopp_task_id =>".$AsusgMeasurementsEntity->smopp_task_id."\n"); $AsusgMeasurementsEntity->save(); try { if( is_bool($item->measurement_value) === true and 'Отметка о выполнении' == $item->measurement_name) { // Вот тут дожна вызываться процедура $query = "call asusg_add_finish_mark_to_task(" . Yii::$app->params['api']['mesrmntParam']['assignees_arr'] . ",'" . $res['tasksEntity']->id . "', " . $AsusgMeasurementsEntity->id . ", '" . $msrmnt_name . "' )"; } else { // Вот тут дожна вызываться процедура //$query = "call asusg_add_measurement_to_task(" . Yii::$app->params['api']['mesrmntParam']['assignees_arr'] . ",'" . $res['tasksEntity']->id . "', " . $AsusgMeasurementsEntity->id . ", '" . $msrmnt_name . "' )"; $AAMsrTT = new AsusgAddMeasurementToTaskModel(); $AAMsrTT->execute( $res['tasksEntity']->id,$AsusgMeasurementsEntity->id, $msrmnt_name, $item->measurement_value, false); $query = 'exec AsusgAddMeasurementToTaskModel, params (' . $res['tasksEntity']->id.','.$AsusgMeasurementsEntity->id.','. $msrmnt_name.','. $item->measurement_value .', false)'; } // Вот это вместо процедуры // 3 .Далее создание контрольных карт //$classNew = new AsusgAddMeasurementToTaskModel(); //$classNew->execute( $res['tasksEntity']->id , $AsusgMeasurementsEntity->id , $msrmnt_name , $extraCheckpoint ); $resProc = Yii::$app->db->createCommand($query)->execute(); $this->logger->setLog($query); $this->logger->setLog('ГЕНЕРАЦИЯ ЧЕКПОИТОВ =>'. $resProc); //var_dump("Создание кк =>", $resProc); //$logs->error_text = "Создание кк =>". $resProc; //$logs->section = 4; // $logs->save(); //echo "