123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?php
- namespace app\controllers;
- use app\models\entity\Companies;
- use Yii;
- use app\models\entity\Accounts;
- use app\models\entity\FaceFeature;
- use app\models\entity\Objects;
- use app\models\entity\Tasks;
- use yii\web\UnauthorizedHttpException;
- class ArealitysController extends MainController
- {
- private $isAdmin = false;
- private $response = ['login' => '','response' => [],'error' => []];
- public function beforeAction($action)
- {
- parent::beforeAction($action);
- $key = Yii::$app->request->headers->get('uuid-key');
- $this->checkAuth($key);
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- return true;
- }
-
- //todo: Перенести на corp
-
- /**
- * Получение данных
- *
- * @param $login
- * @param $password
- * @return string (список объектов)
- */
-
- public function actionGetardata()
- {
- $post = Yii::$app->request->post();
- $this->response['login'] = $post['login'];
-
- $checkAdmin = $this->checkAdmin($post);
- if(!empty($checkAdmin)){
- return $this->response['error'] = $checkAdmin;
- }
- $objectsEntity = Objects::find()->all();
- $tempArray = [];
- $tempArray2 = [];
- $tempArray3 = [];
-
- //var_dump($post['login']); die();
- foreach( $objectsEntity as $object) {
- $tempArray = [];
- $tempArray['id'] = $object->id;
- $tempArray['name'] = $object->name;
- $tempArray['name_display'] = $object->name_display;
- $tempArray['x'] = $object->x;
- $tempArray['y'] = $object->y;
- $tempArray['z'] = $object->z;
- $tempArray['imageA'] = $object->imageA;
- $tempArray['imageB'] = $object->imageB;
- $tempArray['imageC'] = $object->imageC;
-
- foreach( $object->tasks as $task) {
- $tempArray2 = [];
- $tempArray2['id'] = $task->id;
- $tempArray2['name'] = $task->tasktypes->name;
-
- foreach( $task->phase as $phase) {
- $tempArray3 = [];
- $tempArray3['id'] = $phase->id;
- $tempArray3['phase_number'] = $phase->phase_number;
- $tempArray3['message'] = $phase->message;
- $tempArray3['CoordX'] = $phase->x;
- $tempArray3['CoordY'] = $phase->y;
- $tempArray3['CoordZ'] = $phase->z;
- $tempArray2['phase'][] = $tempArray3;
- }
- $tempArray['comands'][] = $tempArray2;
- }
- $this->response['response'][] = $tempArray;
- }
-
- return $this->response;
- }
-
- /**
- * Добавление объекта.
- *
- * @param $login
- * @param $password
- * @param $params
- * @return ?
- */
-
-
- public function actionAddobject()
- {
- $post = Yii::$app->request->post();
- $checkAdmin = $this->checkAdmin($post);
- if(!empty($checkAdmin)){
- return $this->response['error'] = $checkAdmin;
- }
- $post['params'] = json_decode($post['params'],true);
-
- $objectsEntity = new Objects();
- /*
- $objectsEntity->name = $post['params']['name'];
- $objectsEntity->name_display = $post['params']['name_display'];
- $objectsEntity->x = $post['params']['SizeX'];
- $objectsEntity->y = $post['params']['SizeY'];
- $objectsEntity->z = $post['params']['SizeZ'];
- $objectsEntity->imageA = $post['params']['imageA'];
- $objectsEntity->imageB = $post['params']['imageB'];
- $objectsEntity->imageC = $post['params']['imageC'];
- */
- if ( $objectsEntity->load($post['params'], '') and $objectsEntity->save() ) {
- $this->response['response'] = $objectsEntity->id;
- } else {
- $this->response['error'] = $objectsEntity->errors;
- }
- if ( isset($post['params']['command'])
- and !empty( $post['params']['command'] )
- and isset( $objectsEntity->id )
- ) {
- foreach( $post['params']['command'] as $command){
- $tasksEntity = Tasks::findOne($command['id']);
- $tasksEntity->objects_id = $objectsEntity->id;
- $tasksEntity->save();
- if ( !empty($tasksEntity->errors) ) {
- $this->response['error'] = $tasksEntity->errors;
- }
- }
- }
-
- //$this->response[''];
- //$objectsEntity->load($post['params'], '');
- return $this->response;//$return;
- }
-
- /**
- * Удаление объекта.
- *
- * @param $login
- * @param $password
- * @param $id
- * @return ?
- */
-
- public function actionRemoveobject()
- {
- $post = Yii::$app->request->post();
- $return = [];
- return $return;
- }
-
- /**
- * Добавление этапа.
- *
- * @param $login
- * @param $password
- * @param $obj_params
- * @return ?
- */
-
- public function actionAddphase()
- {
- $post = Yii::$app->request->post();
- $return = [];
- return $return;
- }
-
- /**
- * Удаление этапа.
- *
- * @param $login
- * @param $password
- * @param $obj_params
- * @return ?
- */
-
- public function actionRemovephase()
- {
- $post = Yii::$app->request->post();
- $return = [];
- return $return;
- }
-
- }
|