_peekdatasafe.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <?
  2. /*echo 'Logging in...'; exit;
  3. if (!$logged_me_in_successfully234)
  4. return;
  5. echo 'Logged in';
  6. /**/
  7. defined('YII_DEBUG') or define('YII_DEBUG', true);
  8. defined('YII_ENV') or define('YII_ENV', 'dev');
  9. require __DIR__ . '/api/vendor/autoload.php';
  10. require __DIR__ . '/api/vendor/yiisoft/yii2/Yii.php';
  11. $config = require __DIR__ . '/api/config/web.php';
  12. (new yii\web\Application($config));
  13. /**/
  14. use Yii;
  15. use yii\base\Model;
  16. use app\models\entity\ProjectsLocotech;
  17. use app\models\entity\Tasks;
  18. use app\models\entity\Tasknotes;
  19. use app\models\LocomotiveModel;
  20. use app\models\EmployeesModel;/**/
  21. //include 'api/models/LocomotiveModel.php';
  22. //$locomotive = new LocomotiveModel();
  23. //$employee = new EmployeesModel();
  24. $methods = array(
  25. 1 => 'add_completed_work()',
  26. 2 => 'add_remark()',
  27. 3 => 'get_employee_status()',
  28. 4 => 'get_position_list()',
  29. 5 => 'get_workers()',
  30. 6 => 'get_worker_timetable()',
  31. 7 => 'get_repair_sites()',
  32. 8 => 'get_section_list()',
  33. 9 => 'get_section_remarks()',
  34. 10 => 'get_sld_list()',
  35. 11 => 'get_source_of_comments()'
  36. );
  37. echo '<html><head><title>';
  38. echo 'Тестирование интеграции SMoPP - АСУ СГ';
  39. echo '</title>';
  40. echo '</head>
  41. <body>
  42. <h2>Методы API</h2><br/>';
  43. echo '<table>
  44. <tr><th>№</th><th>Метод</th></tr>
  45. ';
  46. $action = filter_input(INPUT_GET, 'action');
  47. for ($i = 1; $i <= 11; $i++)
  48. {
  49. //$hmacstring = 'action='.$i;
  50. //$hmacstring = hash_hmac('SHA512', $hmacstring, $secret);
  51. if ($action == $i)
  52. echo '<tr bgcolor="lightgray">';
  53. else
  54. echo '<tr>';
  55. echo '<td>' . $i . '</td><td><a href="_peekdatasafe.php?action=' . $i . '">' . $methods[$i] . '</a></td>'
  56. . '</tr>
  57. ';
  58. }
  59. echo '</table><br/><br/>';
  60. /*
  61. * Параметры для тестирования запросов.
  62. */
  63. $number = //'0277Б'; // номер секции
  64. //'0130А';
  65. '0275А';
  66. $subnumber = //'12025490';
  67. '11374006';
  68. $sectionId = //'ac8959ee-f049-11e1-8e8b-001517e6ca10';
  69. '3c0afed3-5c25-11e3-9702-ac162db0b20c';
  70. $diagnosticCard = '004d9e52-9848-11e9-80d5-005056011052';
  71. $inspectionId = '910'; // ид проекта
  72. $isSCWorksNeeded = 'true';
  73. $day = new DateTime();
  74. $startTime = $day->getTimestamp();
  75. $endTime = $startTime + 2000;
  76. $workerASU = '9c15af86-e114-11e5-b9ab-00155d6cab04';
  77. $worker = 'bbd19a7f-bf7d-11e7-80cd-0050560110fa';
  78. //$workerASU; //$worker0['ID'];
  79. $engineer = '27';
  80. $otcEmployee = '3';
  81. $source = '9d028e6b-ce35-11e7-80cc-005056011052';
  82. $description = 'Тест API ' . $day->format('Y-m-d H:i:s');
  83. $placeOfRepair = 'a84d0a15-08ec-11e5-829d-00155d6cab05'; // Братское.
  84. //'65c03976-1fd1-11e1-8b55-ee71e73de6e5'; // Мариинск (Братский) (до01.06.2015)
  85. //'6b593ee5-7cb6-11e1-930e-001517e6ca10'; // х Вихоревка (см. Братское)
  86. //'de11fb47-4b02-11e1-b72e-001517e6ca10'; // Братское (до01.06.2015)
  87. //'5f2e4eca-4b02-11e1-b72e-001517e6ca10'; // Москва-Сортировочная.
  88. $sld = '95d764c1-e7ee-11e4-829d-00155d6cab05';
  89. switch ($action)
  90. {
  91. case 1:
  92. $result = CheckAddCompletedWork();
  93. break;
  94. case 2:
  95. $result = CheckAddRemark();
  96. break;
  97. case 3:
  98. $result = CheckGetEmployeeStatus();
  99. break;
  100. case 4:
  101. $result = CheckGetPositionList();
  102. break;
  103. case 5:
  104. $result = CheckGetWorkers();
  105. break;
  106. case 6:
  107. $result = CheckGetWorkerTimetable();
  108. break;
  109. case 7:
  110. $result = CheckGetRepairSites();
  111. break;
  112. case 8:
  113. $result = CheckGetSectionList();
  114. PrintSectionListAsTable($result);
  115. break;
  116. case 9:
  117. $result = CheckGetSectionRemarks();
  118. break;
  119. case 10:
  120. $result = CheckGetSldList();
  121. break;
  122. case 11:
  123. $result = CheckGetSourcesOfComments();
  124. break;
  125. case 12:
  126. $pwd0 = '1234';
  127. $pwd1 = '12345';
  128. $result = $pwd0 . ' ' . md5($pwd0) . '<br>' . $pwd1 . ' ' . md5($pwd1);
  129. break;
  130. default:
  131. http_response_code(404);
  132. die;
  133. }
  134. echo '<h2>Результаты последнего вызванного метода.</h2>';
  135. echo '<div id="apiresult">';
  136. echo '<b>' . $methods[$action] . '</b><br/><br/>';
  137. try
  138. {
  139. if (empty($result))
  140. echo '(НЕТ ДАННЫХ)';
  141. else
  142. echo $result;
  143. }
  144. catch (Exception $exc)
  145. {
  146. var_dump($result);
  147. }
  148. echo '</div>';
  149. echo '</body></html>';
  150. function CheckGetRepairSites()
  151. {
  152. $result = app\models\api::getrepairsites(); // $locomotive->getRepairSites();
  153. return $result;
  154. }
  155. function CheckGetSectionList()
  156. {
  157. global $placeOfRepair, $day;
  158. $params['place'] = $placeOfRepair;
  159. //'5f2e4eca-4b02-11e1-b72e-001517e6ca10';
  160. $params['date'] = $day->getTimestamp();
  161. var_dump($params);
  162. $result = app\models\api::getsectionlist($params); // $locomotive->getSectionList();
  163. return $result;
  164. }
  165. function CheckGetWorkers()
  166. {
  167. global $placeOfRepair, $sld;
  168. //$params['placeOfRepair'] = $placeOfRepair; // из списка get_sld_list
  169. //$params['SLD'] = $sld; //'95d764c1-e7ee-11e4-829d-00155d6cab05';
  170. //$params['sld'] = $sld; //'95d764c1-e7ee-11e4-829d-00155d6cab05';
  171. //$params = array();
  172. var_dump($params);
  173. $result = app\models\api::getworkers($params);
  174. return $result;
  175. }
  176. function CheckGetWorkerTimetable()
  177. {
  178. global $worker;
  179. global $day;
  180. $params['sId'] = $worker;
  181. $params['date'] = $day->getTimestamp();
  182. var_dump($params);
  183. $result = app\models\api::getworkertimetable($params);
  184. return $result;
  185. }
  186. function CheckGetSectionRemarks()
  187. {
  188. global $sectionId;
  189. $params['section_id'] = $sectionId;
  190. //'3c0afed3-5c25-11e3-9702-ac162db0b20c';
  191. //'34d11b7c-f04a-11e1-8e8b-001517e6ca10';
  192. var_dump($params);
  193. $result = app\models\api::getsectionremarks($params); // $locomotive->getSectionRemarks();
  194. return $result;
  195. }
  196. function CheckAddWork()
  197. {
  198. return null;
  199. }
  200. function CheckAddWorkRFID()
  201. {
  202. return null;
  203. }
  204. function CheckGetEmployeeStatus()
  205. {
  206. global $worker;
  207. //global $number, $subnumber, $diagnosticCard, $isSCWorksNeeded;
  208. global $day;
  209. $params['worker'] = $worker;
  210. $params['date'] = $day->getTimestamp();
  211. var_dump($params);
  212. $result = app\models\api::getemployeestatus($params);
  213. return $result;
  214. }
  215. function CheckAddCompletedWork()
  216. {
  217. global $worker, $engineer, $otcEmployee;
  218. global $number, $subnumber, $diagnosticCard, $inspectionId, $isSCWorksNeeded;
  219. global $startTime, $endTime;
  220. $params['number'] = $number; // номер секции
  221. $params['subnumber'] = $subnumber;
  222. $params['diagnosticCard'] = $diagnosticCard;
  223. $params['inspectionId'] = $inspectionId; // ид проекта
  224. $params['isSCWorksNeeded'] = $isSCWorksNeeded;
  225. $params['startTime'] = $startTime; //начало выполнения первого таска
  226. $params['endTime'] = $endTime; // завершение последнего
  227. $params['worker'] = $worker; // Сотрудник?
  228. $params['engineer'] = $engineer; // Инженер? Мастер?
  229. $params['otcEmployee'] = $otcEmployee; // Сотрудник ОТК?
  230. var_dump($params);
  231. $result = app\models\api::addcompletedwork($params);
  232. return $result;
  233. }
  234. function CheckAddRemark()
  235. {
  236. global $worker;
  237. global $number, $subnumber, $sectionId, $diagnosticCard, $isSCWorksNeeded;
  238. global $day;
  239. global $source, $description;
  240. /*$params['number'] = $number;
  241. $params['subnumber'] = $subnumber;
  242. $params['diagnosticMap'] = $diagnosticCard;
  243. $params['date'] = $day->getTimestamp();
  244. $params['worker'] = $worker;
  245. $params['source'] = $source;
  246. $params['description'] = $description;
  247. $params['isSCWorksNeeded'] = $isSCWorksNeeded;
  248. //$params['plant'] = $description;
  249. $params['sectionId'] = $sectionId;/**/
  250. // Минутка хардкода.
  251. $params['number'] = '0130А';
  252. $params['subnumber'] = '11374006';
  253. $params['sectionId'] = 'ac8959ee-f049-11e1-8e8b-001517e6ca10';
  254. //$params['number'] = '0275А';
  255. //$params['subnumber'] = '12025490';
  256. $params['diagnosticMap'] = '004d9e52-9848-11e9-80d5-005056011052';
  257. $params['date'] = $day->getTimestamp();
  258. $params['worker'] = '9c15af86-e114-11e5-b9ab-00155d6cab04';
  259. $params['source'] = '9d028e6b-ce35-11e7-80cc-005056011052';
  260. $params['description'] = 'Проверка добавления замечания по параметрам из примера запроса. Параметр plant отсутствует.';
  261. $params['isSCWorksNeeded'] = '';
  262. // $params['plant'] = 'd8910d3c-c5f5-11e7-80cc-005056011052';
  263. //$params['sectionId'] = 'ac8959ee-f049-11e1-8e8b-001517e6ca10';
  264. var_dump($params);
  265. $result = app\models\api::addremark($params);
  266. return $result;
  267. }
  268. function CheckGetSldList()
  269. {
  270. $result = app\models\api::getsldlist(); // $locomotive->getSldList();
  271. return $result;
  272. }
  273. function CheckGetPositionList()
  274. {
  275. global $source;
  276. $params = array();
  277. //$params['uId'] = $source; // Должен быть ИД должности.
  278. var_dump($params);
  279. $result = app\models\api::getpositionlist();
  280. return $result;
  281. }
  282. function CheckGetSourcesOfComments()
  283. {
  284. global $source;
  285. $params = array();
  286. //$params['uId'] = $source; // Должен быть ИД должности.
  287. var_dump($params);
  288. $result = app\models\api::getsourcesofcoments(); // $locomotive->getSourcesOfComents();
  289. return $result;
  290. }
  291. function PrintSectionListAsTable($result)
  292. {
  293. if (!empty($result))
  294. {
  295. $data = json_decode($result);
  296. if (count($data->array))
  297. {
  298. echo "<table align=\"center\" border=\"1\">";
  299. echo "<tr>";
  300. echo "<th>TypeOfRepair</th>";
  301. echo "<th>SectionNumber</th>";
  302. echo "<th>LocomotiveNumber</th>";
  303. echo "<th>SectionSubnumber</th>";
  304. echo "<th>Section</th>";
  305. echo "<th>RepairStartDatePlan</th>";
  306. echo "<th>RepairStartDateFact</th>";
  307. echo "<th>DiagnosticMapslocomotive</th>";
  308. echo "</tr>";
  309. foreach ($data->array as $idx => $array)
  310. {
  311. echo "<tr>";
  312. echo "<td>$array->TypeOfRepair</td>";
  313. echo "<td>$array->SectionNumber</td>";
  314. echo "<td>$array->LocomotiveNumber</td>";
  315. echo "<td>$array->SectionSubnumber</td>";
  316. echo "<td>$array->Section</td>";
  317. echo "<td>$array->RepairStartDatePlan</td>";
  318. echo "<td>$array->RepairStartDateFact</td>";
  319. echo "<td>$array->DiagnosticMapslocomotive</td>";
  320. echo "</tr>";
  321. }
  322. echo "</table>";
  323. }
  324. }
  325. }