<?php

// /update/:query/:inicio/:final
// $date = DateTime::createFromFormat('Y-n-j H:i',$inicio);
// $inicio = date('Y-m-d H:i',$date->format('U'));
// $date = DateTime::createFromFormat('Y-n-j H:i',$final);
// $final = date('Y-m-d H:i',$date->format('U'));
echo $inicio, PHP_EOL, $final, PHP_EOL;
// Only insert data every four hours
$files = array('oee_insert_uITLA_PRE-POST-PURGE');
// $inicio = strtotime('-4 hours');
// $final = strtotime('now');
// echo('Query for dates:' . date('Y-m-d H:i', $inicio) . "  >".  date('Y-m-d H:i', $final));
$DB = new MxApps();
foreach ($files as $index => $value) {
    $query = file_get_contents("sql/" . $value . '.sql');
    $DB->setQuery($query);
    $DB->bind_vars(':inicio', $inicio);
    $DB->bind_vars(':final', $final);
    file_put_contents("sql/preCompiled/" . $value . ".sql", $DB->query);
    echo "Active : " . $value . PHP_EOL;
    if (oci_execute($DB->statement)) {
        echo "Success : " . $value . PHP_EOL;
    } else {
        echo "Fail" . PHP_EOL;
    }
}
$DB->close();
示例#2
0
// Take a base DATE and ADD 4 hours
$final = strtotime('+4 hours', $date->format('U'));
$final = date('Y-m-d H:i', $final);
$bu_id = '3';
// bu_id [Alfredo-1,Luis-2,Gerardo-3,Tomas-4]
$depto = 'ITLA';
$product = 'all';
$process = 'Deflector';
$machine = $request['machine'];
$sample_time_span = '240';
$total_production_time = '';
$build_qty = $request['build_qty'] <= 0 ? 0 : $request['build_qty'];
$good_qty = $request['good_qty'] <= 0 ? 0 : $request['good_qty'];
$yield = $build_qty <= 0 ? 0 : "{$good_qty}/{$build_qty}";
$query = file_get_contents("./sql/oee_manual_insert_generic.sql");
$DB = new MxApps();
$DB->setQuery($query);
$DB->bind_vars(':inicio', $inicio);
$DB->bind_vars(':final', $final);
$DB->bind_vars(':bu_id', $bu_id);
$DB->bind_vars(':depto', $depto);
$DB->bind_vars(':product', $product);
$DB->bind_vars(':process', $process);
$DB->bind_vars(':machine', $machine);
$DB->bind_vars(':sample_time_span', $sample_time_span);
$DB->bind_vars(':total_production_time', $total_production_time);
$DB->bind_vars(':build_qty', $build_qty);
$DB->bind_vars(':good_qty', $request['good_qty']);
$DB->bind_vars(':avg_ct', $avg_ct);
$DB->bind_vars(':yield', $yield);
$DB->exec();
示例#3
0
<?php

// phpinfo();
// echo "product: $machine, $total_qty, $good_qty, $start" ;
/*
 * All this effort to convert a date to a string
 */
// Convert the taken date to a date object
$date = DateTime::createFromFormat('Y-n-j H:i', $start);
// Convert the date to a string
$inicio = date('Y-m-d H:i', $date->format('U'));
// echo "$inicio";
$machine = $machine;
$query = "select * from oee_master2 where s_start_dt = to_date(':s_start_dt','yyyy-mm-dd hh24:mi') and machine = ':machine'";
$DB = new MxApps();
$DB->setQuery($query);
$DB->bind_vars(':s_start_dt', $inicio);
$DB->bind_vars(':machine', $machine);
$DB->exec();
$json = $DB->json();
$ans = $DB->results[0];
// echo $DB->query;
if ($json == "[]") {
    echo '{"error":"empty"}';
} else {
    $build_qty = $ans['BUILD_QTY'];
    $good_qty = round($ans['BUILD_QTY'] * $ans['YIELD']);
    $json = '{"build_qty":' . $build_qty . ',"good_qty":' . $good_qty . '}';
    echo "{$json}";
}
$DB->close();
示例#4
0
        if ($json == '[]') {
            // throw new Exception("No arrojo datos la base de datos [".$queryName. "]", 1);
        } else {
            file_put_contents('cache/' . $queryName . '.json', $json);
            array_push($ans, array($queryName => json_decode($json)));
        }
    }
    $DB->close();
    echo json_encode($ans);
} elseif ($target == 'four_ours') {
    // Only insert data every four hours
    $files = array('oee_insert_SiLens_every_x_h', 'oee_insert_LR4-OSA_LIV', 'oee_insert_Engines_Functional', 'oee_insert_Engines_Welder', 'oee_insert_pmqpsk_dctest', 'oee_insert_pmqpsk_plctest', 'oee_insert_uITLA_LENS', 'oee_insert_LR4-pack_Screening', 'oee_insert_Engines_LIV', 'oee_query_uITLA_PRE-POST-PURGE', 'oee_insert_Engines_10Gb_25Gb');
    $inicio = strtotime('-4 hours');
    $final = strtotime('now');
    // echo('Query for dates:' . date('Y-m-d H:i', $inicio) . "  >".  date('Y-m-d H:i', $final));
    $DB = new MxApps();
    foreach ($files as $index => $value) {
        $query = file_get_contents("sql/" . $value . '.sql');
        $DB->setQuery($query);
        $DB->bind_vars(':inicio', date('Y-m-d H:i', $inicio));
        $DB->bind_vars(':final', date('Y-m-d H:i', $final));
        file_put_contents("sql/preCompiled/" . $value . ".sql", $DB->query);
        echo "Active : " . $value . PHP_EOL;
        if (oci_execute($DB->statement)) {
            echo "Success : " . $value . PHP_EOL;
        } else {
            echo "Fail" . PHP_EOL;
        }
    }
    $DB->close();
}