Api.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. /*
  3. для получения нужно объявить namespace
  4. use app\models\Api;
  5. вызов:
  6. например Api::getsldlist()
  7. Доступные статические методы
  8. параметры:
  9. $params - array входные параметры см. спецификацию [не обязательный]
  10. return - результат выполнения метода TWX
  11. getsectionremarks($params = [])
  12. getsectionlist($params = [])
  13. addcomplitedwork($params = [])
  14. addremark($params = [])
  15. getsourcesofcoments()
  16. getrepairsites()
  17. getsldlist()
  18. getworkers($params = [])
  19. getemployeestatus($params = [])
  20. getworkertimetable($params = [])
  21. getpositionlist()
  22. */
  23. namespace app\models;
  24. use Yii;
  25. use yii\base\Model;
  26. use app\models\entity\Accounts;
  27. use app\models\entity\Sections;
  28. use app\models\LocomotiveModel;
  29. use app\models\EmployeesModel;
  30. use app\models\UserModel;
  31. use app\models\TasksModel;
  32. use app\models\AccountModel;
  33. use app\models\ProjectsModel;
  34. use app\models\ServiceModel;
  35. class Api extends MainModel
  36. {
  37. public $errors = [];
  38. public static function getsectionremarks($params = [])
  39. {
  40. if ( [] == $params ) {
  41. $params['number'] = '0469В';
  42. $params['subnumber'] = '11385168';
  43. }
  44. $url = Yii::$app->params['api']['domain'] . Yii::$app->params['api']['pathListCurrentComments'];
  45. $locomotiveModel = new LocomotiveModel();
  46. $result = $locomotiveModel->getSectionRemarks($params,false);
  47. return json_decode($result);
  48. }
  49. public static function getsectionlist($params = [])
  50. {
  51. if ( [] == $params ) {
  52. $params['place'] = 'a84d0a15-08ec-11e5-829d-00155d6cab05';
  53. //$params['place'] = '5fb47130-580c-11e7-aefa-00155d6cab05';
  54. $params['date'] = '1562077752';//$this->milliseconds();
  55. }
  56. $locomotiveModel = new LocomotiveModel();
  57. $result = $locomotiveModel->getSectionList($params);
  58. return $result;
  59. }
  60. public static function addcompletedwork($params = [])
  61. {
  62. if ( [] == $params ) {
  63. $params['number'] = '345'; // номер секции
  64. $params['subnumber'] = '123';
  65. $params['diagnosticCard'] = '123e4567-e89b-12d3-a456-426655440000';
  66. $params['inspectionId'] = '910'; // ид проекта
  67. $params['isSCWorksNeeded'] = 'true';
  68. $params['startTime'] = $this->milliseconds(); //начало выполнения первого таска
  69. $params['endTime'] = $this->milliseconds()+2000; // завершение последнего
  70. $params['worker'] = '2';
  71. $params['engineer'] = '27';
  72. $params['otcEmployee'] = '3';
  73. }
  74. $locomotiveModel = new LocomotiveModel();
  75. $result = $locomotiveModel->addCompletedWork($params);
  76. return $result;
  77. //$result = $this->curlRequest($url,$params);
  78. }
  79. public static function addremark($params = [])
  80. {
  81. $locomotiveModel = new LocomotiveModel();
  82. if ( [] == $params ) {
  83. $locomotiveModel->project_id = '1332';
  84. $params['number'] = '234234';
  85. $params['subnumber'] = '35468795';
  86. $params['diagnosticCard'] = '004d9e52-9848-11e9-80d5-005056011052';//'123e4567-e89b-12d3-a456-426655440000';
  87. $params['date'] = $locomotiveModel->milliseconds();
  88. $params['worker'] = '023169da-e473-11e2-aaad-ac162db0b20c'; //Котов
  89. $params['source'] = '';
  90. $params['description'] = '';
  91. $params['isSCWorksNeeded'] = '';
  92. }
  93. $url = Yii::$app->params['api']['domain'] . Yii::$app->params['api']['pathCommentSection'];
  94. $result = $locomotiveModel->addRemark($params);
  95. return $result;
  96. }
  97. public static function getsourcesofcoments()
  98. {
  99. $locomotiveModel = new LocomotiveModel();
  100. $result = $locomotiveModel->getSourcesOfComents();
  101. return json_decode($result);
  102. }
  103. public static function getrepairsites()
  104. {
  105. $locomotiveModel = new LocomotiveModel();
  106. $result = $locomotiveModel->getRepairSites();
  107. return json_decode($result);
  108. }
  109. public static function getsldlist()
  110. {
  111. $locomotiveModel = new LocomotiveModel();
  112. $result = $locomotiveModel->getSldList();
  113. return json_decode($result);
  114. }
  115. public static function getworkers($params = [])
  116. {
  117. if ( [] == $params ) {
  118. $params['sld'] = '95d764c1-e7ee-11e4-829d-00155d6cab05';
  119. $params['placeOfRepair'] = 'a84d0a15-08ec-11e5-829d-00155d6cab05'; // из списка get_sld_list
  120. }
  121. $employeesModel = new EmployeesModel();
  122. $result = $employeesModel->getWorkers($params);
  123. return $result;
  124. }
  125. public static function getemployeestatus($params = [])
  126. {
  127. if ( [] == $params ) {
  128. $params['worker'] = '25b3793b-ce67-11e6-aab3-00155d6cab04';
  129. $params['date'] = '1562072228';//$this->milliseconds();
  130. }
  131. $employeesModel = new EmployeesModel();
  132. $result = $employeesModel->getEmployeeStatus($params);
  133. return $result;
  134. }
  135. public static function getworkertimetable($params = [])
  136. {
  137. if ( [] == $params ) {
  138. $params['name'] = 'Ивлева Светлана Николаевна';
  139. $params['date'] = $this->milliseconds();
  140. }
  141. $employeesModel = new EmployeesModel();
  142. $result = $employeesModel->getWorkerTimetable($params);
  143. return $result;
  144. }
  145. public static function getpositionlist()
  146. {
  147. $employeesModel = new EmployeesModel();
  148. $result = $employeesModel->getPositionList($params);
  149. return $result;
  150. }
  151. }
  152. ?>