api_getworkers.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. defined('YII_DEBUG') or define('YII_DEBUG', true);
  3. defined('YII_ENV') or define('YII_ENV', 'dev');
  4. require 'api/vendor/autoload.php';
  5. require 'api/vendor/yiisoft/yii2/Yii.php';
  6. $config = require 'api/config/web.php';
  7. (new yii\web\Application($config));
  8. $res = new app\models\LocomotiveModel();
  9. $locomotiveModel = new app\models\LocomotiveModel();
  10. $locomotiveModel->project_id = '1151';
  11. $time = $locomotiveModel->milliseconds();
  12. $time = explode(' ', microtime())[1];
  13. //$time = microtime();
  14. //echo $time."<br>";
  15. //$params['number'] = '0130А';
  16. //$params['subnumber'] = '11374006';
  17. //$params['diagnosticMap'] = '25c46291-9eb1-11e8-80cf-005056011052';
  18. //$params['date'] = $time;//'1562877877';$locomotiveModel->milliseconds();
  19. //$params['worker'] = 'bbd19a7f-bf7d-11e7-80cd-0050560110fa';
  20. //$params['source'] = 'c92e78e9-e104-11e7-80cc-005056011052';
  21. //$params['description'] = 'new21';
  22. //$params['isSCWorksNeeded'] = '';
  23. //$params['plant'] = '';
  24. //$params['sectionId'] = 'ac8959ee-f049-11e1-8e8b-001517e6ca10';
  25. //$result = $locomotiveModel->addRemark($params);
  26. //$params = array();
  27. //$params['placeOfRepair'] = '95d764c1-e7ee-11e4-829d-00155d6cab05'; //Братск
  28. //$params['placeOfRepair'] = '5f2e4eca-4b02-11e1-b72e-001517e6ca10'; //Москва
  29. //$params['sectionId'] = 'ac8959f0-f049-11e1-8e8b-001517e6ca10';
  30. //echo '123';
  31. //var_dump( $result);
  32. $params =array();
  33. $params['sld'] = '95d7646d-e7ee-11e4-829d-00155d6cab05';
  34. $start = $_REQUEST['start'];
  35. $end = $_REQUEST['end'];
  36. if (!$start)
  37. $start = '1';
  38. if (!$end)
  39. $end = '100';
  40. $params['start'] = $start;
  41. $params['end'] = $end;
  42. //{"start":1,"end":50,"SLD":"95d7646d-e7ee-11e4-829d-00155d6cab05"}
  43. TWXrequest($params);
  44. function TWXrequest($params)
  45. {
  46. //app key 6a7bdbaa-6bc1-4159-a2f4-07a13c8907d1
  47. // $url = "http://62.141.88.61:8085/Thingworx/Things/connSmoppLibrary/Services/get_section_remarks";
  48. //$url = "http://62.141.88.61:8085/Thingworx/Things/connSmoppLibrary/Services/add_remark";
  49. $url = "http://qaplatform.digitaldepot.ru:8085/Thingworx/Things/connSmoppLibrary/Services/get_workers";
  50. $jsonEncoded = json_encode($params);
  51. $curl = curl_init();
  52. curl_setopt($curl, CURLOPT_URL, $url);
  53. curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "AppKey: 33cd23bb-3b03-4638-afef-7104a13e9211", "Accept:application/json"));
  54. // curl_setopt($curl, CURLOPT_USERPWD, sprintf('%s:%s', "Smopp", "2050.Digital"));
  55. curl_setopt($curl, CURLOPT_TIMEOUT, 600);
  56. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  57. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  58. curl_setopt($curl, CURLOPT_POST, 1);
  59. curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonEncoded);
  60. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  61. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  62. // var_dump($jsonEncoded);
  63. $result = curl_exec($curl);
  64. // $uuid = json_decode($result)->RemarkId;
  65. // echo "uuid ".$uuid;
  66. // curl_close($curl);
  67. var_dump($result);
  68. // var_dump($result);
  69. }