measurements.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. require_once "curlexec.php";
  3. require_once "auth.php";
  4. $params = [];
  5. //$params['user_id'] = "023169da-e473-11e2-aaad-ac162db0b20c";
  6. $params['user_id'] = "0231698c-e473-11e2-aaad-ac162db0b20c";
  7. //$params['work_id'] = "735f7f76-5982-4b82-a60c-3b4a88d0d7eb";
  8. $params['work_id'] = "9957c42a-234f-4f8e-99e7-1b4f6165a422";
  9. $url = "http://devplatform.digitaldepot.ru:8085/Thingworx/Things/2050UserLibraryExp/Services/work_measurements";
  10. $response = CURLrequestPOST($url, '', $params);
  11. var_dump($response);
  12. //try {
  13. // ResponseToMeasurement($response);
  14. // } catch (\Throwable $e) {
  15. // echo $e->getMessage();
  16. // }
  17. function ResponseToMeasurement($response)
  18. {
  19. global $link;
  20. $json = json_decode($response);
  21. foreach ($json->data as $item) {
  22. $comment = json_encode($item->measurement_comment);
  23. $worker = json_encode($item->worker);
  24. $compliance = intval($item->value_compliance);
  25. $is_hw = intval($item->is_hw_measurement);
  26. $value = floatval($item->measurement_value);
  27. $complete = intval($item->measurement_complete);
  28. $qstr = "insert into asusg_measurements
  29. (
  30. measurement_id,
  31. measurement_name,
  32. characteristic_id,
  33. characteristic_name,
  34. measurement_stage,
  35. measurement_complete,
  36. measurement_norm,
  37. measurement_value,
  38. value_type,
  39. value_compliance,
  40. worker,
  41. measurement_date,
  42. measurement_comment,
  43. work_id,
  44. is_hw_measurement,
  45. smopp_date_requested
  46. )
  47. values
  48. (
  49. '$item->measurement_id',
  50. '$item->measurement_name',
  51. '$item->characteristic_id',
  52. '$item->characteristic_name',
  53. $item->measurement_stage,
  54. $complete,
  55. '$item->measurement_norm',
  56. $value,
  57. '$item->value_type',
  58. $compliance,
  59. '$worker',
  60. $item->measurement_date,
  61. '$comment',
  62. '$item->work_id',
  63. $is_hw,
  64. now()
  65. )";
  66. mysqli_query($link, $qstr);
  67. }
  68. }