<?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();
$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(); // $json = $DB->json(); echo "{$DB->query}"; $DB->setQuery("select ID,CREATION_DT,BU,S_START_DT,S_END_DT,DEPTO,PRODUCT,PROCESS,MACHINE,SAMPLE_TIME_SPAN,\n\t\tTOTAL_PRODUCTION_TIME,BUILD_QTY,AVG_CT,AVAIL AVAILABILITY,PERF PERFORMANCE,YIELD,OEE\n\t\tfrom oee_master2 a where machine in ('DR1','DR2') and s_start_dt = (select max(s_start_dt) from oee_master2 b where b.machine = a.machine)"); $DB->exec(); file_put_contents('./cache/oee_query_uITLA_DEFLECTOR.json', $DB->json()); $DB->setQuery("select ID,CREATION_DT,BU,S_START_DT,S_END_DT,DEPTO,PRODUCT,PROCESS,MACHINE,SAMPLE_TIME_SPAN,\n\t\tTOTAL_PRODUCTION_TIME,BUILD_QTY,AVG_CT,AVAIL AVAILABILITY,PERF PERFORMANCE,YIELD,OEE\n\t\tfrom oee_master2 a where machine in ('EN2') and s_start_dt = (select max(s_start_dt) from oee_master2 b where b.machine = a.machine)"); $DB->exec(); file_put_contents('./cache/oee_query_uITLA_ETALON.json', $DB->json()); $DB->close();