|
- <?php
- require_once __DIR__.'/../st-xm/Common/Mysql.php';
- header("Access-Control-Allow-Origin:*");
- $pdo=conn();
-
- $linux_time = time();
- $current_day = date( "Y-m-d", $linux_time );
- $current_min = date( "H:i", $linux_time );
- $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";
- $result=$pdo->query($sql_search);
- if( $result == false ) {
- echo "refresh success";exit();
- }
- $list = $result->fetchAll();
- $run_start_array = array();
- $run_stop_array = array();
- foreach( $list as $run_info ) {
- if( $run_info["saled_count"] > 0 ) {
- $run_start_array[] = $run_info["run_id"];
- } else {
- $run_stop_array[] = $run_info["run_id"];
- }
- }
- $update_sql = " UPDATE run_main SET run_status=139 WHERE run_id IN (".implode(",", $run_start_array).") AND run_status=138 ";
- $pdo->exec($update_sql);
-
- $update_sql2 = " UPDATE run_bus SET run_bus_status=139 WHERE run_id IN (".implode(",", $run_start_array).") AND run_bus_status=138 ";
- $pdo->exec($update_sql2);
-
- /*
- $update_sql3 = " UPDATE run_main SET run_status=142 WHERE run_id IN (".implode(",", $run_stop_array).") AND run_status=138 ";
- $pdo->exec($update_sql3);
- $update_sql4 = " UPDATE run_bus SET run_bus_status=142 WHERE run_id IN (".implode(",", $run_stop_array).") AND run_bus_status=138 ";
- $pdo->exec($update_sql4);
- */
-
- /*
- //取得所有有效车信息
- $sql1=" CALL SP_REFRESH_RUN_BUS_STATUS()";
- $result=$pdo->query($sql1);
- if( $result == false ) {
- echo "refresh failed";
- } else {
- echo "refresh success";
- }
- $result->closeCursor();
- */
- /*
- $pdo3=conn3();
-
- //取得所有有效车信息
- $sql1=" CALL SP_REFRESH_RUN_BUS_STATUS()";
- $result=$pdo3->query($sql1);
- if( $result == false ) {
- echo "refresh failed";
- } else {
- echo "refresh success";
- }
- $result->closeCursor();
- */
- echo "refresh success";
- exit();
-
-
-
-
-
|