Files
kopalnia_2014/soap_q_manual_while.php
T
2026-09-03 11:24:19 +02:00

57 lines
2.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once('./func.php');
require_once('./dbaccess.php');
require_once('./polynomial/math.php');
$polacz = mysql_connect($db_host, $db_user, $db_user_pass) or die ('cannot connect to db');
mysql_select_db($db_name);
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER_SET utf8_general_ci");
echo"Kopiowanie danych dla studni pracujacych – SPM inne<br/>";
echo"START: ".date('Y-m-d H:i:m')."<br/>";
//sprawdza w danym momencie zabudowane agregaty
unset($wellManualArray);
$wellManualArray = sqlGetResAsArray("select * from seg_dev_resources,seg_wells left join seg_wells_exchanged on WLL_ID=WLE_WLL_ID where DRS_DEV_TYPE=12 and DRS_DEV_ID=WLL_ID and WLL_CAT_DIC_ID=20 and WLE_DATE_FROM<=now() and (WLE_DATE_TO>=now() or WLE_DATE_TO is null) group by WLL_ID");
for ($i=0; $i<count($wellManualArray); $i++)
{
// sprawdza, czy pompa obecnie pracuje
unset($wellOnOffStatus);
$wellOnOffStatus = sqlGetResAsArray("select * from softspm_rep.rep_002_avg_pump_working where WST_ID=(select max(WST_ID) from softspm_rep.rep_002_avg_pump_working where WST_DRS_ID=".$wellManualArray[$i]['DRS_ID']." and WST_DATE<=now())");
if ($wellOnOffStatus[0]['WST_STATUS_VAL']=='ON')
{
//sprawdza, czy dla zabudowanego agregatu jest jakiś pomiar Q
unset($lastMeasurment);
$lastMeasurment = sqlGetResAsArray("select * from rep_his_data_everyday where RHD_ID=(select max(RHD_ID) from rep_his_data_everyday where RHD_DRS_ID=".$wellManualArray[$i]['DRS_ID']." and RHD_Q_VAL>0 and RHD_DATE>='".$wellManualArray[$i]['WLE_DATE_FROM']."')");
if ($lastMeasurment[0]['RHD_Q_VAL']>0)
{
// sprawdza, czy w danym dniu była już kopiowana wartość z poprzedniego pomiaru - jeśli nie to wstawia
unset($checkTodayInput);
$checkTodayInput = sqlGetResAsArray("select count(*) ILE from rep_his_data_everyday where RHD_DRS_ID=".$wellManualArray[$i]['DRS_ID']." and RHD_Q_VAL>0 and RHD_DATE>='".date('Y-m-d')." 00:00:00'");
if($checkTodayInput[0]['ILE']==0)
{
// wstawia poprzednią wartość
unset($query);
$query = "INSERT INTO rep_his_data_everyday SET RHD_DRS_ID=".$wellManualArray[$i]['DRS_ID'].",RHD_DATE=now()";
if ($lastMeasurment[0]['RHD_HD_VAL']>0) $query .= ",RHD_HD_VAL=".$lastMeasurment[0]['RHD_HD_VAL'];
if ($lastMeasurment[0]['RHD_Q_VAL']>0) $query .= ",RHD_Q_VAL=".$lastMeasurment[0]['RHD_Q_VAL'];
if ($lastMeasurment[0]['RHD_P1_VAL']>0) $query .= ",RHD_P1_VAL=".$lastMeasurment[0]['RHD_P1_VAL'];
if ($lastMeasurment[0]['RHD_P2_VAL']>0) $query .= ",RHD_P2_VAL=".$lastMeasurment[0]['RHD_P2_VAL'];
if ($lastMeasurment[0]['RHD_I_VAL']>0) $query .= ",RHD_I_VAL=".$lastMeasurment[0]['RHD_I_VAL'];
if ($lastMeasurment[0]['RHD_U_VAL']>0) $query .= ",RHD_U_VAL=".$lastMeasurment[0]['RHD_U_VAL'];
if ($lastMeasurment[0]['RHD_COS_VAL']>0) $query .= ",RHD_COS_VAL=".$lastMeasurment[0]['RHD_COS_VAL'];
$query .= ",RHD_AUDIT_CD=now();";
mysql_query($query);
}
}
}
}
echo"STOP: ".date('Y-m-d H:i:m')."<br/>";
mysql_close($polacz);
?>