在数据可视化中添加了环境监测数据的显示
This commit is contained in:
parent
c2f9bf43a2
commit
5bec6c3aab
|
@ -343,6 +343,149 @@ class VisualController extends Zend_Controller_Action
|
|||
//getHydrologyDataByStationId() 获得水文数据变量值
|
||||
|
||||
|
||||
/****************************
|
||||
|
||||
环境监测数据
|
||||
|
||||
*****************************/
|
||||
|
||||
/*
|
||||
* createAmbientDataSet 创建环境监测数据
|
||||
*
|
||||
* param int $sid 站点编号、名称
|
||||
* param string $valuetype 变量类型
|
||||
* param string $label 单位
|
||||
* param int $round 数值精确度,小数点后位数
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
function createAmbientDataSet($sid,$valuetype,$label,$round=4){
|
||||
|
||||
if(empty($label))
|
||||
{
|
||||
$label='';
|
||||
}
|
||||
|
||||
$data = array(
|
||||
"name"=>"站点:$sid",
|
||||
"data"=>$this->getAmbientValueByStation($sid,$valuetype),
|
||||
"tooltip"=>array(
|
||||
"valueDecimals"=> $round,
|
||||
"valueSuffix"=> $label
|
||||
)
|
||||
);
|
||||
|
||||
return $data;
|
||||
|
||||
}//createAmbientDataSet 创建环境监测数据的数据
|
||||
|
||||
/*
|
||||
* getAmbientValueByStation 按站点查询变量
|
||||
*
|
||||
* param int $sid 站点编号
|
||||
* param string $table 变量类型
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
function getAmbientValueByStation($sid,$t)
|
||||
{
|
||||
|
||||
$field = array(); //查询字段
|
||||
|
||||
$field[] = 'id';
|
||||
$field[] = '"position"';
|
||||
$field[] = 'dt';
|
||||
$field[] = $t.' as v';
|
||||
|
||||
$field = join(",",$field); //拼接
|
||||
|
||||
|
||||
$sql = "select $field from ambient_air where \"position\"='$sid' ORDER BY dt ASC";
|
||||
|
||||
$sth = $this->dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$temp = $sth->fetchAll();
|
||||
|
||||
$dataSet = array();
|
||||
|
||||
foreach ($temp as $k=>$v)
|
||||
{
|
||||
$time = 0;
|
||||
if(!empty($v['dt']))
|
||||
{
|
||||
$time = strtotime($v['dt']);
|
||||
}
|
||||
if(!empty($v['yr']) && !empty($v['mth']))
|
||||
{
|
||||
$time = strtotime($v['yr'].'-'.$v['mth'].'-'.'01 00:00:00');
|
||||
}
|
||||
if(!empty($v['yr']) && empty($v['mth']))
|
||||
{
|
||||
$time = strtotime($v['yr'].'-01-01 00:00:00');
|
||||
}
|
||||
$dataSet[] = array($time*1000,$v['v']);
|
||||
}
|
||||
unset($temp);
|
||||
|
||||
return $dataSet;
|
||||
|
||||
}// getAmbientValueByStation 按站点查询变量
|
||||
|
||||
/*
|
||||
* getAmbientDataByStationId 获得环境监测数据变量
|
||||
*
|
||||
* param string $valuetype 变量类型
|
||||
* param string $label 单位
|
||||
* param int $sid 站点编号,默认为空,空值将列出所有站点变量值
|
||||
* param int $round 数值精确度,小数点后位数
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
function getAmbientDataByStationId($valuetype,$label,$sid=0,$round=4){
|
||||
|
||||
if(empty($sid))
|
||||
{
|
||||
//降水
|
||||
$p = array('tsp','pm10','so2','no2');
|
||||
|
||||
if(in_array($valuetype,$p))
|
||||
{
|
||||
$sql = "select \"position\" from ambient_air group by \"position\"";
|
||||
}
|
||||
|
||||
$sth = $this->dbh->prepare($sql);
|
||||
$sth->execute();
|
||||
$stations = $sth->fetchAll();
|
||||
|
||||
$data = array();
|
||||
|
||||
foreach ($stations as $v)
|
||||
{
|
||||
$data[] = $this->createAmbientDataSet($v['position'],$valuetype,$label,$round);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}//所有站点
|
||||
|
||||
|
||||
if(is_array($sid))
|
||||
{
|
||||
|
||||
}//多个指定站点
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
}//单个站点
|
||||
|
||||
}
|
||||
//getAmbientDataByStationId() 获得环境监测数据变量的值
|
||||
|
||||
|
||||
|
||||
|
||||
//********************************************************
|
||||
|
||||
/*
|
||||
|
@ -362,7 +505,7 @@ class VisualController extends Zend_Controller_Action
|
|||
$ac = $this->_request->getParam('ac');
|
||||
$base = $this->_request->getParam('dt');
|
||||
|
||||
if(!in_array($base,array('meteorology','hydrology')))
|
||||
if(!in_array($base,array('meteorology','hydrology','ambient')))
|
||||
{
|
||||
$data = array(
|
||||
"error"=>"参数错误"
|
||||
|
@ -477,6 +620,38 @@ class VisualController extends Zend_Controller_Action
|
|||
}//水文数据
|
||||
|
||||
|
||||
if($base=="ambient")
|
||||
{
|
||||
if($ac=='tsp')
|
||||
{
|
||||
$title = "总悬浮颗粒物";
|
||||
$label="";
|
||||
$datas = $this->getAmbientDataByStationId($ac,$label);
|
||||
}
|
||||
|
||||
if($ac=='pm10')
|
||||
{
|
||||
$title = "可吸入颗粒物";
|
||||
$label="";
|
||||
$datas = $this->getAmbientDataByStationId($ac,$label);
|
||||
}
|
||||
|
||||
if($ac=='so2')
|
||||
{
|
||||
$title = "二氧化硫";
|
||||
$label="";
|
||||
$datas = $this->getAmbientDataByStationId($ac,$label);
|
||||
}
|
||||
|
||||
if($ac=='no2')
|
||||
{
|
||||
$title = "二氧化氮";
|
||||
$label="";
|
||||
$datas = $this->getAmbientDataByStationId($ac,$label);
|
||||
}
|
||||
}//环境监测数据
|
||||
|
||||
|
||||
|
||||
$data = array(
|
||||
"label"=>$label,
|
||||
|
@ -491,6 +666,8 @@ class VisualController extends Zend_Controller_Action
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
function utcMsTime($time=''){
|
||||
if(empty($time))
|
||||
return (time()+8*3600)*1000;
|
||||
|
|
|
@ -9,7 +9,7 @@ $this->headScript()->appendFile('/static/js/highstock/modules/exporting.js');
|
|||
//$this->headScript()->appendFile('/static/js/highcharts/highcharts.js');
|
||||
//$this->headScript()->appendFile('/static/js/highcharts/modules/exporting.js');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/data">数据与服务</a>');
|
||||
$this->breadcrumb('<a href="/data">数据与服务</a>');
|
||||
$this->breadcrumb('数据可视化');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
|
@ -40,10 +40,13 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
</div>
|
||||
</div>
|
||||
<div class="tbox mt12">
|
||||
<div class="title corners-top">环境检测</div>
|
||||
<div class="title corners-top">环境监测</div>
|
||||
<div class="content">
|
||||
<ul>
|
||||
<li><button value="0" class="fetchSeries btn">流动检测</button></li>
|
||||
<li><button value="tsp" class="fetchSeries btn ambient">总悬浮颗粒物</button></li>
|
||||
<li><button value="pm10" class="fetchSeries btn ambient">可吸入颗粒物</button></li>
|
||||
<li><button value="so2" class="fetchSeries btn ambient">二氧化硫</button></li>
|
||||
<li><button value="no2" class="fetchSeries btn ambient">二氧化氮</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -104,6 +107,11 @@ $(".fetchSeries").click(function () {
|
|||
dt = 'hydrology';
|
||||
}
|
||||
|
||||
if(button.hasClass('ambient'))
|
||||
{
|
||||
dt = 'ambient';
|
||||
}
|
||||
|
||||
$('#datachart').html('');
|
||||
|
||||
function onDataReceived(series) {
|
||||
|
|
Loading…
Reference in New Issue