Initial commit
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
<head>
|
||||
<meta http-equiv="Refresh" content="1" />
|
||||
</head>
|
||||
|
||||
<?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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$tableName = 'softspm_his.rep_his_data_everyday_2014_q1';
|
||||
|
||||
|
||||
unset($wellArray);
|
||||
$wellArray = sqlGetResAsArray("select * from ".$tableName." where RHD_Q_VAL>0 and (RHD_PE_VAL<0 or RHD_PE_VAL is null) limit 200");
|
||||
|
||||
for ($i=0; $i<count($wellArray); $i++)
|
||||
{
|
||||
unset($wellInfoDet);
|
||||
$wellInfoDet = sqlGetResAsArray("select * from seg_dev_resources,seg_wells where DRS_DEV_TYPE=12 and DRS_DEV_ID=WLL_ID and DRS_ID=".$wellArray[$i]['RHD_DRS_ID']);
|
||||
|
||||
|
||||
echo'Studnia: '.$wellInfoDet[0]['WLL_NAME'].', id='.$wellInfoDet[0]['WLL_ID'].'<br/>';
|
||||
|
||||
|
||||
unset($wellExch);
|
||||
$wellExch = sqlGetResAsArray("select * from seg_wells_exchanged where WLE_WLL_ID=".$wellInfoDet[0]['WLL_ID']." and WLE_NR_EXCHANGE=(select max(WLE_NR_EXCHANGE) from seg_wells_exchanged where WLE_WLL_ID=".$wellInfoDet[0]['WLL_ID']." and WLE_DATE_FROM<='".$wellArray[$i]['RHD_DATE']."')");
|
||||
|
||||
unset($testIDArray);
|
||||
if (strlen($wellExch[0]['WLE_PUMP_NO'])>0 && strlen($wellExch[0]['WLE_ENG_NO'])>0)
|
||||
{
|
||||
$testIDArray = sqlGetResAsArray("select max(TST_ID) TST_ID from tst_tests where TST_PUP_SN_NO='".$wellExch[0]['WLE_PUMP_NO']."' and TST_ENG_SN_NO='".$wellExch[0]['WLE_ENG_NO']."' and TST_AUDIT_CD<='".$wellExch[0]['WLE_DATE_FROM']."'");
|
||||
}
|
||||
|
||||
|
||||
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 ($mocSP>0)
|
||||
{
|
||||
mysql_query("UPDATE ".$tableName." SET RHD_PE_VAL='".$mocSP."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
|
||||
echo("UPDATE ".$tableName." SET RHD_PE_VAL='".$mocSP."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
|
||||
echo'<br>';
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
unset($engArray);
|
||||
$engArray = sqlGetResAsArray("select * from seg_engines where ENG_NAME='".$wellExch[0]['WLE_ENG_NAME']."'");
|
||||
|
||||
if ($engArray[0]['ENG_POWER']>0)
|
||||
{
|
||||
mysql_query("UPDATE ".$tableName." SET RHD_PE_VAL='".$engArray[0]['ENG_POWER']."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
|
||||
echo("UPDATE ".$tableName." SET RHD_PE_VAL='".$engArray[0]['ENG_POWER']."' WHERE RHD_ID=".$wellArray[$i]['RHD_ID']);
|
||||
echo'<br>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo"STOP: ".date('Y-m-d H:i:m')."<br/>";
|
||||
|
||||
mysql_close($polacz);
|
||||
Reference in New Issue
Block a user