123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <?
- /*echo 'Logging in...'; exit;
- if (!$logged_me_in_successfully234)
- return;
- echo 'Logged in';
- /**/
- defined('YII_DEBUG') or define('YII_DEBUG', true);
- defined('YII_ENV') or define('YII_ENV', 'dev');
- require __DIR__ . '/api/vendor/autoload.php';
- require __DIR__ . '/api/vendor/yiisoft/yii2/Yii.php';
- $config = require __DIR__ . '/api/config/web.php';
- (new yii\web\Application($config));
- /**/
- use Yii;
- use yii\base\Model;
- use app\models\entity\ProjectsLocotech;
- use app\models\entity\Tasks;
- use app\models\entity\Tasknotes;
- use app\models\LocomotiveModel;
- use app\models\EmployeesModel;/**/
- //include 'api/models/LocomotiveModel.php';
- //$locomotive = new LocomotiveModel();
- //$employee = new EmployeesModel();
- $methods = array(
- 1 => 'add_completed_work()',
- 2 => 'add_remark()',
- 3 => 'get_employee_status()',
- 4 => 'get_position_list()',
- 5 => 'get_workers()',
- 6 => 'get_worker_timetable()',
- 7 => 'get_repair_sites()',
- 8 => 'get_section_list()',
- 9 => 'get_section_remarks()',
- 10 => 'get_sld_list()',
- 11 => 'get_source_of_comments()'
- );
- echo '<html><head><title>';
- echo 'Тестирование интеграции SMoPP - АСУ СГ';
- echo '</title>';
- echo '</head>
- <body>
- <h2>Методы API</h2><br/>';
- echo '<table>
- <tr><th>№</th><th>Метод</th></tr>
- ';
- $action = filter_input(INPUT_GET, 'action');
- for ($i = 1; $i <= 11; $i++)
- {
- //$hmacstring = 'action='.$i;
- //$hmacstring = hash_hmac('SHA512', $hmacstring, $secret);
- if ($action == $i)
- echo '<tr bgcolor="lightgray">';
- else
- echo '<tr>';
- echo '<td>' . $i . '</td><td><a href="_peekdatasafe.php?action=' . $i . '">' . $methods[$i] . '</a></td>'
- . '</tr>
- ';
- }
- echo '</table><br/><br/>';
- /*
- * Параметры для тестирования запросов.
- */
- $number = //'0277Б'; // номер секции
- //'0130А';
- '0275А';
- $subnumber = //'12025490';
- '11374006';
- $sectionId = //'ac8959ee-f049-11e1-8e8b-001517e6ca10';
- '3c0afed3-5c25-11e3-9702-ac162db0b20c';
- $diagnosticCard = '004d9e52-9848-11e9-80d5-005056011052';
- $inspectionId = '910'; // ид проекта
- $isSCWorksNeeded = 'true';
- $day = new DateTime();
- $startTime = $day->getTimestamp();
- $endTime = $startTime + 2000;
- $workerASU = '9c15af86-e114-11e5-b9ab-00155d6cab04';
- $worker = 'bbd19a7f-bf7d-11e7-80cd-0050560110fa';
- //$workerASU; //$worker0['ID'];
- $engineer = '27';
- $otcEmployee = '3';
- $source = '9d028e6b-ce35-11e7-80cc-005056011052';
- $description = 'Тест API ' . $day->format('Y-m-d H:i:s');
- $placeOfRepair = 'a84d0a15-08ec-11e5-829d-00155d6cab05'; // Братское.
- //'65c03976-1fd1-11e1-8b55-ee71e73de6e5'; // Мариинск (Братский) (до01.06.2015)
- //'6b593ee5-7cb6-11e1-930e-001517e6ca10'; // х Вихоревка (см. Братское)
- //'de11fb47-4b02-11e1-b72e-001517e6ca10'; // Братское (до01.06.2015)
- //'5f2e4eca-4b02-11e1-b72e-001517e6ca10'; // Москва-Сортировочная.
- $sld = '95d764c1-e7ee-11e4-829d-00155d6cab05';
- switch ($action)
- {
- case 1:
- $result = CheckAddCompletedWork();
- break;
- case 2:
- $result = CheckAddRemark();
- break;
- case 3:
- $result = CheckGetEmployeeStatus();
- break;
- case 4:
- $result = CheckGetPositionList();
- break;
- case 5:
- $result = CheckGetWorkers();
- break;
- case 6:
- $result = CheckGetWorkerTimetable();
- break;
- case 7:
- $result = CheckGetRepairSites();
- break;
- case 8:
- $result = CheckGetSectionList();
- PrintSectionListAsTable($result);
- break;
- case 9:
- $result = CheckGetSectionRemarks();
- break;
- case 10:
- $result = CheckGetSldList();
- break;
- case 11:
- $result = CheckGetSourcesOfComments();
- break;
- case 12:
- $pwd0 = '1234';
- $pwd1 = '12345';
- $result = $pwd0 . ' ' . md5($pwd0) . '<br>' . $pwd1 . ' ' . md5($pwd1);
- break;
- default:
- http_response_code(404);
- die;
- }
- echo '<h2>Результаты последнего вызванного метода.</h2>';
- echo '<div id="apiresult">';
- echo '<b>' . $methods[$action] . '</b><br/><br/>';
- try
- {
- if (empty($result))
- echo '(НЕТ ДАННЫХ)';
- else
- echo $result;
- }
- catch (Exception $exc)
- {
- var_dump($result);
- }
- echo '</div>';
- echo '</body></html>';
- function CheckGetRepairSites()
- {
- $result = app\models\api::getrepairsites(); // $locomotive->getRepairSites();
- return $result;
- }
- function CheckGetSectionList()
- {
- global $placeOfRepair, $day;
-
- $params['place'] = $placeOfRepair;
- //'5f2e4eca-4b02-11e1-b72e-001517e6ca10';
- $params['date'] = $day->getTimestamp();
- var_dump($params);
- $result = app\models\api::getsectionlist($params); // $locomotive->getSectionList();
- return $result;
- }
- function CheckGetWorkers()
- {
- global $placeOfRepair, $sld;
-
- //$params['placeOfRepair'] = $placeOfRepair; // из списка get_sld_list
- //$params['SLD'] = $sld; //'95d764c1-e7ee-11e4-829d-00155d6cab05';
- //$params['sld'] = $sld; //'95d764c1-e7ee-11e4-829d-00155d6cab05';
- //$params = array();
- var_dump($params);
- $result = app\models\api::getworkers($params);
- return $result;
- }
- function CheckGetWorkerTimetable()
- {
- global $worker;
- global $day;
-
- $params['sId'] = $worker;
- $params['date'] = $day->getTimestamp();
- var_dump($params);
- $result = app\models\api::getworkertimetable($params);
- return $result;
- }
- function CheckGetSectionRemarks()
- {
- global $sectionId;
- $params['section_id'] = $sectionId;
- //'3c0afed3-5c25-11e3-9702-ac162db0b20c';
- //'34d11b7c-f04a-11e1-8e8b-001517e6ca10';
- var_dump($params);
- $result = app\models\api::getsectionremarks($params); // $locomotive->getSectionRemarks();
- return $result;
- }
- function CheckAddWork()
- {
- return null;
- }
- function CheckAddWorkRFID()
- {
- return null;
- }
- function CheckGetEmployeeStatus()
- {
- global $worker;
- //global $number, $subnumber, $diagnosticCard, $isSCWorksNeeded;
- global $day;
- $params['worker'] = $worker;
- $params['date'] = $day->getTimestamp();
- var_dump($params);
- $result = app\models\api::getemployeestatus($params);
- return $result;
- }
- function CheckAddCompletedWork()
- {
- global $worker, $engineer, $otcEmployee;
- global $number, $subnumber, $diagnosticCard, $inspectionId, $isSCWorksNeeded;
- global $startTime, $endTime;
- $params['number'] = $number; // номер секции
- $params['subnumber'] = $subnumber;
- $params['diagnosticCard'] = $diagnosticCard;
- $params['inspectionId'] = $inspectionId; // ид проекта
- $params['isSCWorksNeeded'] = $isSCWorksNeeded;
- $params['startTime'] = $startTime; //начало выполнения первого таска
- $params['endTime'] = $endTime; // завершение последнего
- $params['worker'] = $worker; // Сотрудник?
- $params['engineer'] = $engineer; // Инженер? Мастер?
- $params['otcEmployee'] = $otcEmployee; // Сотрудник ОТК?
-
- var_dump($params);
- $result = app\models\api::addcompletedwork($params);
- return $result;
- }
- function CheckAddRemark()
- {
- global $worker;
- global $number, $subnumber, $sectionId, $diagnosticCard, $isSCWorksNeeded;
- global $day;
- global $source, $description;
- /*$params['number'] = $number;
- $params['subnumber'] = $subnumber;
- $params['diagnosticMap'] = $diagnosticCard;
- $params['date'] = $day->getTimestamp();
- $params['worker'] = $worker;
- $params['source'] = $source;
- $params['description'] = $description;
- $params['isSCWorksNeeded'] = $isSCWorksNeeded;
- //$params['plant'] = $description;
- $params['sectionId'] = $sectionId;/**/
- // Минутка хардкода.
- $params['number'] = '0130А';
- $params['subnumber'] = '11374006';
- $params['sectionId'] = 'ac8959ee-f049-11e1-8e8b-001517e6ca10';
- //$params['number'] = '0275А';
- //$params['subnumber'] = '12025490';
- $params['diagnosticMap'] = '004d9e52-9848-11e9-80d5-005056011052';
- $params['date'] = $day->getTimestamp();
- $params['worker'] = '9c15af86-e114-11e5-b9ab-00155d6cab04';
- $params['source'] = '9d028e6b-ce35-11e7-80cc-005056011052';
- $params['description'] = 'Проверка добавления замечания по параметрам из примера запроса. Параметр plant отсутствует.';
- $params['isSCWorksNeeded'] = '';
- // $params['plant'] = 'd8910d3c-c5f5-11e7-80cc-005056011052';
- //$params['sectionId'] = 'ac8959ee-f049-11e1-8e8b-001517e6ca10';
- var_dump($params);
- $result = app\models\api::addremark($params);
- return $result;
- }
- function CheckGetSldList()
- {
- $result = app\models\api::getsldlist(); // $locomotive->getSldList();
- return $result;
- }
- function CheckGetPositionList()
- {
- global $source;
-
- $params = array();
- //$params['uId'] = $source; // Должен быть ИД должности.
-
- var_dump($params);
- $result = app\models\api::getpositionlist();
- return $result;
- }
- function CheckGetSourcesOfComments()
- {
- global $source;
-
- $params = array();
- //$params['uId'] = $source; // Должен быть ИД должности.
-
- var_dump($params);
- $result = app\models\api::getsourcesofcoments(); // $locomotive->getSourcesOfComents();
- return $result;
- }
- function PrintSectionListAsTable($result)
- {
- if (!empty($result))
- {
- $data = json_decode($result);
- if (count($data->array))
- {
- echo "<table align=\"center\" border=\"1\">";
- echo "<tr>";
- echo "<th>TypeOfRepair</th>";
- echo "<th>SectionNumber</th>";
- echo "<th>LocomotiveNumber</th>";
- echo "<th>SectionSubnumber</th>";
- echo "<th>Section</th>";
- echo "<th>RepairStartDatePlan</th>";
- echo "<th>RepairStartDateFact</th>";
- echo "<th>DiagnosticMapslocomotive</th>";
- echo "</tr>";
-
- foreach ($data->array as $idx => $array)
- {
- echo "<tr>";
- echo "<td>$array->TypeOfRepair</td>";
- echo "<td>$array->SectionNumber</td>";
- echo "<td>$array->LocomotiveNumber</td>";
- echo "<td>$array->SectionSubnumber</td>";
- echo "<td>$array->Section</td>";
- echo "<td>$array->RepairStartDatePlan</td>";
- echo "<td>$array->RepairStartDateFact</td>";
- echo "<td>$array->DiagnosticMapslocomotive</td>";
- echo "</tr>";
- }
-
- echo "</table>";
- }
- }
- }
|