You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

69 lines
2.1 KiB

  1. <?php
  2. require_once __DIR__.'/../st-xm/Common/Mysql.php';
  3. header("Access-Control-Allow-Origin:*");
  4. $pdo=conn();
  5. $linux_time = time();
  6. $current_day = date( "Y-m-d", $linux_time );
  7. $current_min = date( "H:i", $linux_time );
  8. $sql_search = "SELECT run_bus.run_id, sum(run_bus.SALED_COUNT) as saled_count FROM run_bus WHERE run_bus.run_id IN (SELECT run_id FROM run_main left join opera_line on opera_line.line_id = run_main.prod_id where run_main.run_date = '{$current_day}' AND run_main.run_time <= '{$current_min}' AND run_main.run_status = 138 AND opera_line.line_type = 255) AND run_bus.cancel_flag = 0 group by run_bus.run_id";
  9. $result=$pdo->query($sql_search);
  10. if( $result == false ) {
  11. echo "refresh success";exit();
  12. }
  13. $list = $result->fetchAll();
  14. $run_start_array = array();
  15. $run_stop_array = array();
  16. foreach( $list as $run_info ) {
  17. if( $run_info["saled_count"] > 0 ) {
  18. $run_start_array[] = $run_info["run_id"];
  19. } else {
  20. $run_stop_array[] = $run_info["run_id"];
  21. }
  22. }
  23. $update_sql = " UPDATE run_main SET run_status=139 WHERE run_id IN (".implode(",", $run_start_array).") AND run_status=138 ";
  24. $pdo->exec($update_sql);
  25. $update_sql2 = " UPDATE run_bus SET run_bus_status=139 WHERE run_id IN (".implode(",", $run_start_array).") AND run_bus_status=138 ";
  26. $pdo->exec($update_sql2);
  27. /*
  28. $update_sql3 = " UPDATE run_main SET run_status=142 WHERE run_id IN (".implode(",", $run_stop_array).") AND run_status=138 ";
  29. $pdo->exec($update_sql3);
  30. $update_sql4 = " UPDATE run_bus SET run_bus_status=142 WHERE run_id IN (".implode(",", $run_stop_array).") AND run_bus_status=138 ";
  31. $pdo->exec($update_sql4);
  32. */
  33. /*
  34. //取得所有有效车信息
  35. $sql1=" CALL SP_REFRESH_RUN_BUS_STATUS()";
  36. $result=$pdo->query($sql1);
  37. if( $result == false ) {
  38. echo "refresh failed";
  39. } else {
  40. echo "refresh success";
  41. }
  42. $result->closeCursor();
  43. */
  44. /*
  45. $pdo3=conn3();
  46. //取得所有有效车信息
  47. $sql1=" CALL SP_REFRESH_RUN_BUS_STATUS()";
  48. $result=$pdo3->query($sql1);
  49. if( $result == false ) {
  50. echo "refresh failed";
  51. } else {
  52. echo "refresh success";
  53. }
  54. $result->closeCursor();
  55. */
  56. echo "refresh success";
  57. exit();