/*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 '
';
echo 'Тестирование интеграции SMoPP - АСУ СГ';
echo '';
echo '
Методы API
';
echo '
№ | Метод |
';
$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 '';
else
echo '
';
echo '' . $i . ' | ' . $methods[$i] . ' | '
. '
';
}
echo '
';
/*
* Параметры для тестирования запросов.
*/
$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) . '
' . $pwd1 . ' ' . md5($pwd1);
break;
default:
http_response_code(404);
die;
}
echo 'Результаты последнего вызванного метода.
';
echo '';
echo '' . $methods[$action] . '
';
try
{
if (empty($result))
echo '(НЕТ ДАННЫХ)';
else
echo $result;
}
catch (Exception $exc)
{
var_dump($result);
}
echo '
';
echo '';
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 "";
echo "";
echo "TypeOfRepair | ";
echo "SectionNumber | ";
echo "LocomotiveNumber | ";
echo "SectionSubnumber | ";
echo "Section | ";
echo "RepairStartDatePlan | ";
echo "RepairStartDateFact | ";
echo "DiagnosticMapslocomotive | ";
echo "
";
foreach ($data->array as $idx => $array)
{
echo "";
echo "$array->TypeOfRepair | ";
echo "$array->SectionNumber | ";
echo "$array->LocomotiveNumber | ";
echo "$array->SectionSubnumber | ";
echo "$array->Section | ";
echo "$array->RepairStartDatePlan | ";
echo "$array->RepairStartDateFact | ";
echo "$array->DiagnosticMapslocomotive | ";
echo "
";
}
echo "
";
}
}
}