日期:2014-05-16 浏览次数:20978 次
insert into RMINTDATMST9 (RMINTTAG_ID, RMINTDAT_DAT, RMINTDAT_VAL)
values ('1DCS.XNFX:X10114', to_date('2014-01-19 08:20:00','yyyy-mm-dd hh24:mi:ss'), '349.637390');
insert into RMINTDATMST9 (RMINTTAG_ID, RMINTDAT_DAT, RMINTDAT_VAL)
values ('DCS1.1CP20AI:AI241302.PNT', to_date('2014-01-19 08:20:00','yyyy-mm-dd hh24:mi:ss'), '349.086945');
insert into RMINTDATMST9 (RMINTTAG_ID, RMINTDAT_DAT, RMINTDAT_VAL)
values ('1DCS.CALC:CYQSW', to_date('2014-01-19 08:15:00','yyyy-mm-dd hh24:mi:ss'), '2181.503906');
insert into RMINTDATMST9 (RMINTTAG_ID, RMINTDAT_DAT, RMINTDAT_VAL)
values ('DCS1.0CP01DI:DI012105.CIN', to_date('2014-01-19 08:15:00','yyyy-mm-dd hh24:mi:ss'), '0.200555');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-type: text/html; charset=utf-8");
header('Content-type: text/json');
$msSQL="SET TRANSACTION ISOLATION LEVEL READ COMMITTED;";
$stmt = oci_parse($conn,$msSQL);
oci_execute($stmt,OCI_COMMIT_ON_SUCCESS);
$msSQL="select/*+no_result_cache*/ rminttag_id,to_char(rmintdat_dat,'YYYY-MM-DD HH24:MI:SS') as rmintdat_dat,rmintdat_val from RMINTDATMST9 t where rownum<=40 order by rmintdat_dat desc";
$stmt = oci_parse($conn,$msSQL);
oci_execute($stmt,OCI_COMMIT_ON_SUCCESS);
$iRows = oci_fetch_all($stmt,$result, null, null, OCI_FETCHSTATEMENT_BY_ROW);
foreach($result as $idx=>$v)
{
$index = str_replace(":","_",str_replace(".","_",str_replace(".CALC:","_",rtrim($v['RMINTTAG_ID']))));
if(strlen($index)==25)
{
$index=substr($index,0,13).substr($index,-3);
}
$mfCurVal = sprintf("%01.2f",rtrim($v['RMINTDAT_VAL']));
//去掉重复采样值,取最大值
$msData[$index]= (abs($mfCurVal)>=abs($msData[$index]))? $mfCurVal : $msData[$index];
if($idx==0)
{
//取样时间
$msData['RMINTDAT_DAT']=rtrim($v['RMINTDAT_DAT']);
}
}
oci_free_statement($stmt);
oci_close($conn);
echo json_encode($msData);