Initial commit

This commit is contained in:
2026-09-03 11:24:19 +02:00
commit 6ed3153f36
1897 changed files with 538007 additions and 0 deletions
+109
View File
@@ -0,0 +1,109 @@
<?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"START: ".date('Y-m-d H:i:m')."<br/>";
function getPolyHp($dataArray,$inParam)
{
unset($resVal);unset($tbArray);
for($i=0; $i<count($dataArray); $i++)
$tbArray[] = array($dataArray[$i]['q'],$dataArray[$i]['h']);
if (count($tbArray)>1)
{
$polynomial = new zc_math_polynomial($tbArray);
$polynomial->calculate_coefficients();
$resVal = $polynomial->get_y($inParam);
}
else
$resVal=0;
return round($resVal,2);
}
function getPolyPe($dataArray,$inParam)
{
unset($resVal);unset($tbArray);
for($i=0; $i<count($dataArray); $i++)
$tbArray[] = array($dataArray[$i]['q'],$dataArray[$i]['p']);
if (count($tbArray)>1)
{
$polynomial = new zc_math_polynomial($tbArray);
$polynomial->calculate_coefficients();
$resVal = $polynomial->get_y($inParam);
}
else
$resVal=0;
return round($resVal,2);
}
unset($wellArray);
//$wellArray = sqlGetResAsArray("select * from seg_wells,seg_dev_resources left join rep_his_data_everyday on RHD_DRS_ID=DRS_ID where DRS_DEV_TYPE=12 and DRS_DEV_ID=WLL_ID and WLL_CAT_DIC_ID=20 and RHD_DRS_ID>0 and RHD_Q_VAL>0 and (RHD_PE_VAL<=0 or RHD_PE_VAL is null) and RHD_DATE>ADDDATE(now(), INTERVAL -180 DAY) order by RHD_DATE desc limit 500");
$wellArray = sqlGetResAsArray("select * from seg_wells,seg_dev_resources left join rep_his_data_everyday on RHD_DRS_ID=DRS_ID where DRS_DEV_TYPE=12 and DRS_DEV_ID=WLL_ID and WLL_CAT_DIC_ID=20 and RHD_DRS_ID>0 and RHD_Q_VAL>0 and (RHD_PE_VAL<=0 or RHD_PE_VAL is null) order by RHD_DATE desc limit 500");
for ($i=0; $i<count($wellArray); $i++)
{
unset($aggArray);
$aggArray = sqlGetResAsArray("select * from seg_wells_exchanged where WLE_WLL_ID=".$wellArray[$i]['WLL_ID']." and WLE_DATE_FROM<='".$wellArray[$i]['RHD_DATE']."' and (WLE_DATE_TO is null or WLE_DATE_TO>='".$wellArray[$i]['RHD_DATE']."')");
//echo("select * from seg_wells_exchanged where WLE_WLL_ID=".$wellArray[$i]['WLL_ID']." and WLE_DATE_FROM<='".$wellArray[$i]['RHD_DATE']."' and (WLE_DATE_TO is null or WLE_DATE_TO>='".$wellArray[$i]['RHD_DATE']."')");
//echo'<br>';
unset($testIDArray);
if (strlen($aggArray[0]['WLE_PUMP_NO'])>0 && strlen($aggArray[0]['WLE_ENG_NO'])>0)
{
$testIDArray = sqlGetResAsArray("select max(TST_ID) TST_ID from tst_tests where TST_PUP_SN_NO='".$aggArray[0]['WLE_PUMP_NO']."' and TST_ENG_SN_NO='".$aggArray[0]['WLE_ENG_NO']."'");
//echo("select max(TST_ID) TST_ID from tst_tests where TST_PUP_SN_NO='".$aggArray[0]['WLE_PUMP_NO']."' and TST_ENG_SN_NO='".$aggArray[0]['WLE_ENG_NO']."'");
//echo'<br>';
}
else
{
mysql_query("delete from rep_his_data_everyday WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
//echo("delete from rep_his_data_everyday WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
//echo'<br>';
}
unset($probaArray);
unset($mocSP);
if ($testIDArray[0]['TST_ID']>0)
{
$wynik = mysql_query("select TSD_VAL_04,TSD_VAL_08,TSD_VAL_14 from tst_tests left join tst_test_details on TSD_TST_ID=TST_ID where TST_ID=".$testIDArray[0]['TST_ID']." order by TSD_MSR_STEP");
if($wynik)while ($r = mysql_fetch_array($wynik))
{
$probaArray[] = array(
'q' => (float) $r["TSD_VAL_04"],
'h' => (float) $r["TSD_VAL_08"],
'p' => (float) $r["TSD_VAL_14"]
);
}
$mocSP = (float) getPolyPe($probaArray,$wellArray[$i]['RHD_Q_VAL']);
//
if ($wellArray[$i]['RHD_ID']>0)
{
mysql_query("UPDATE rep_his_data_everyday SET RHD_PE_VAL='".$mocSP."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
echo("UPDATE rep_his_data_everyday SET RHD_PE_VAL='".$mocSP."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
echo'<br>';
}
}
}
echo"STOP: ".date('Y-m-d H:i:m')."<br/>";
mysql_close($polacz);
?>