diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index 77446449..bb0a3969 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -3983,6 +3983,9 @@ class Admin_DataController extends Zend_Controller_Action $data = $visual->getVisualVars($uuid); + if(isset($data['visual_datatable'])) + $this->view->visualField = $visualTable->readFields($data['visual_datatable']); + if(!empty($data)) { $this->view->info = $data; @@ -4003,6 +4006,7 @@ class Admin_DataController extends Zend_Controller_Action 'visual_timefield_year' => $this->_getParam('visual_timefield_year'), 'visual_timefield_month' => $this->_getParam('visual_timefield_month'), 'visual_timefield_day' => $this->_getParam('visual_timefield_day'), + 'visual_timefield_custom' => $this->_getParam('visual_timefield_custom'), 'visual_type' => $this->_getParam('visual_type'), ); diff --git a/application/admin/views/scripts/data/visual-add.phtml b/application/admin/views/scripts/data/visual-add.phtml index 3c85fde6..2bf8150c 100644 --- a/application/admin/views/scripts/data/visual-add.phtml +++ b/application/admin/views/scripts/data/visual-add.phtml @@ -8,12 +8,12 @@ $this->breadcrumb('同步GEONETWORK元数据'); $this->breadcrumb()->setSeparator(' > '); ?> -
-
+
+
partial('data/left.phtml'); ?>
-
+

添加可视化要素


error)) {?> @@ -147,8 +147,14 @@
+ 字段 字段 显示名 + 过滤条件">
diff --git a/application/module/Westdc/Visual/Handle/VisualHandle.php b/application/module/Westdc/Visual/Handle/VisualHandle.php index 24850071..c9b829d4 100644 --- a/application/module/Westdc/Visual/Handle/VisualHandle.php +++ b/application/module/Westdc/Visual/Handle/VisualHandle.php @@ -39,6 +39,12 @@ class VisualHandle extends \Westdc\Visual\VariableEncoder public function processData(\Zend_EventManager_Event $e) { $data = $e->getParam('data'); + + foreach($data['vars'] as $k=>$v) + { + if(preg_match("/;/",$v['filter'])) + $data['vars'][$k]['filter'] = explode(";",$v['filter']); + } $data['vars'] = $this->encode($data['vars']); diff --git a/application/module/Westdc/Visual/Record.php b/application/module/Westdc/Visual/Record.php index b18d9294..9bf665d5 100644 --- a/application/module/Westdc/Visual/Record.php +++ b/application/module/Westdc/Visual/Record.php @@ -4,7 +4,7 @@ namespace Westdc\Visual; class Record extends Database { - public $subdataset,$valueFilter; + public $subdataset,$valueFilter,$vars; public $timeFiled = "utctime"; @@ -35,6 +35,7 @@ class Record extends Database $visual = new Visual; $var_data = $visual->getVisualVars($uuid); + $this->vars = $var_data['vars']; if(!empty($var_data['visual_valuefilter'])) $this->valueFilter = (float)$var_data['visual_valuefilter']; @@ -74,7 +75,7 @@ class Record extends Database $this->timeFiled = $timefield_temp; }//multiple elseif($var_data['visual_timefield_model'] == 'custom'){ - $this->timeFiled = $var_data['visual_timefield_model']; + $this->timeFiled = $var_data['visual_timefield_custom']; }//custom //时间字段为空的bug @@ -91,9 +92,9 @@ class Record extends Database } if(isset($var_data['data']) && !empty($var_data['data'])) - $this->sql = $this->makeSql($var_data['data'],$this->subdataset); + $this->sql = $this->makeSql($var_data['data']); else - $this->sql = $this->makeSql($var_data['visual_datatable'],$this->subdataset); + $this->sql = $this->makeSql($var_data['visual_datatable']); //echo $this->sql;exit(); } @@ -122,16 +123,37 @@ class Record extends Database return $data; } - public function makeSql($table,$fieldValue) + public function makeSql($table) { $wheresql = ""; + if(!empty($this->valueFilter)) { - $wheresql = " WHERE \"$fieldValue\"<>".$this->valueFilter .' '; + $wheresql = " WHERE \"$this->subdataset\"<>".$this->valueFilter .' '; + } + + $filter = $this->getFilter($this->subdataset); + if(!empty($filter)) + { + if(is_string($filter)) + $wheresql = ' WHERE "'.$this->subdataset.'"'. $filter .' '; + + elseif(is_array($filter)) + { + $wheresql = []; + foreach($filter as $v) + { + if(preg_match("/^[<|>|=|!](.*)/",$v)) + $wheresql[] = '"'.$this->subdataset.'"'.$v; + else + $wheresql[] = $v; + } + $wheresql = ' WHERE '.join(" AND ",$wheresql); + } } $sql = "SELECT - {$this->timeFiled} as utctime , \"$fieldValue\" as value + {$this->timeFiled} as utctime , \"{$this->subdataset}\" as value FROM $table as tbl $wheresql ORDER BY @@ -152,4 +174,26 @@ class Record extends Database else return ($time)*1000; } + + public function getFilter($subdataset) + { + $vars = json_decode($this->vars,TRUE); + + if(!is_array($vars) || count($vars)<1) + return null; + + foreach($vars as $v) + { + if($v['field'] == $subdataset) + { + if(isset($v['filter']) && !empty($v['filter'])) + { + return $v['filter']; + }else{ + return null; + } + } + } + return null; + } } \ No newline at end of file