merge sanjiangyuan-sub r5224 - r5246 into sjy-meteorology
This commit is contained in:
parent
457e61051d
commit
0defbad3d6
|
@ -2856,14 +2856,14 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
//文件列表
|
||||
if($ac == "files"){
|
||||
elseif($ac == "files"){
|
||||
$file = new Westdc\Dataimport\File;
|
||||
$this->_helper->json($file->getUploadFiles());
|
||||
return true;
|
||||
}
|
||||
|
||||
//刪除上传的文件
|
||||
if($ac == "delete"){
|
||||
elseif($ac == "delete"){
|
||||
$file = $this->_getParam('file');
|
||||
$fileHandle = new Westdc\Dataimport\File;
|
||||
$this->_helper->json(['success'=>$fileHandle->deleteFile($file)]);
|
||||
|
@ -2872,7 +2872,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
|
||||
//预处理
|
||||
//判断文件类型,初步识别文件內容
|
||||
if($ac == "prepare"){
|
||||
elseif($ac == "prepare"){
|
||||
$this->_helper->viewRenderer('dataimport-preprocess');
|
||||
|
||||
$file = $this->_getParam('file');
|
||||
|
@ -2911,7 +2911,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
//檢查文件是否規則
|
||||
if($ac == "check"){
|
||||
elseif($ac == "check"){
|
||||
$file = $this->_getParam('file');
|
||||
if(empty($file)){
|
||||
$this->_helper->json(['error'=>'参数错误']);
|
||||
|
@ -2931,7 +2931,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
//選擇導入目標
|
||||
if($ac == "target")
|
||||
elseif($ac == "target")
|
||||
{
|
||||
$this->_helper->viewRenderer('dataimport-target');
|
||||
|
||||
|
@ -2947,7 +2947,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
//获得数据表
|
||||
if($ac == "gettables")
|
||||
elseif($ac == "gettables")
|
||||
{
|
||||
$schema = $this->_getParam('schema');
|
||||
if(empty($schema)){
|
||||
|
@ -2959,8 +2959,24 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
return true;
|
||||
}
|
||||
|
||||
//获取表格字段名称和类型
|
||||
elseif($ac=="getfields")
|
||||
{
|
||||
$schema = $this->_getParam('schema');
|
||||
$table = $this->_getParam('table');
|
||||
if(empty($schema) || empty($table)){
|
||||
$this->_helper->json(['error'=>'参数错误']);
|
||||
return true;
|
||||
}
|
||||
$tableControl = new Westdc\Visual\DataTableControl;
|
||||
$fields = $tableControl->readFields($schema . "." .$table);
|
||||
if ($fields[0]['column_name']=='id') unset($fields[0]);
|
||||
$this->_helper->json($fields);
|
||||
return true;
|
||||
}
|
||||
|
||||
//检查能否写入数据表 和 导入数据
|
||||
if($ac == "checktables" || $ac == "import"){
|
||||
elseif($ac == "checktables" || $ac == "import"){
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
|
@ -2983,6 +2999,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
$tableControl = new Westdc\Visual\DataTableControl;
|
||||
$fields = $tableControl->readFields($schema . "." .$table);
|
||||
if ($fields[0]['column_name']=='id') unset($fields[0]);
|
||||
|
||||
$status = $processing->checkTableField($fields);
|
||||
$this->_helper->json($status);
|
||||
|
@ -2990,7 +3007,13 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
elseif($ac == "import"){
|
||||
$status = $processing->import($schema . "." .$table);
|
||||
$tableControl = new Westdc\Visual\DataTableControl;
|
||||
$fields = $tableControl->readFields($schema . "." .$table);
|
||||
$status = $processing->import($schema . "." .$table,$fields[0]['column_name']=='id');
|
||||
if($status===true)
|
||||
{
|
||||
$fileHandle->deleteFile($file);
|
||||
}
|
||||
$this->_helper->json($status);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ $this->headTitle()->setSeparator(' - ');
|
|||
</label>
|
||||
</div>
|
||||
<div class="span3" id="table-list">
|
||||
|
||||
</div>
|
||||
<div class="span4" id="field-list">
|
||||
</div>
|
||||
</div>
|
||||
<hr class="clear" />
|
||||
|
@ -39,7 +40,6 @@ $this->headTitle()->setSeparator(' - ');
|
|||
<input type="hidden" name="schema" value="">
|
||||
<input type="hidden" name="table" value="" id="input-table">
|
||||
<button type="button" id="ctl-next" class="btn btn-success disabled" disabled>下一步</button>
|
||||
<button type="button" id="ctl-show-table" class="btn btn-info hidden" disabled>查看数据表结构</button>
|
||||
<button type="button" id="ctl-import" class="btn btn-info" disabled="disabled" style="display: none;">导入数据表</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -51,10 +51,6 @@ $this->headTitle()->setSeparator(' - ');
|
|||
ctl.checkTable();
|
||||
});
|
||||
|
||||
$("#ctl-show-table").click(function(){
|
||||
|
||||
});
|
||||
|
||||
$("#ctl-import").click(function(){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
|
@ -122,6 +118,7 @@ $this->headTitle()->setSeparator(' - ');
|
|||
{
|
||||
ctl.enableNext();
|
||||
}
|
||||
ctl.getFields();
|
||||
});
|
||||
|
||||
$('#clt-next').removeClass('disabled');
|
||||
|
@ -163,6 +160,7 @@ $this->headTitle()->setSeparator(' - ');
|
|||
'url':'/admin/data/dataimport/ac/checktables',
|
||||
'data':$('#schema-form').serialize(),
|
||||
'success':function(data){
|
||||
|
||||
if (data!=true)
|
||||
{
|
||||
if(!$.isEmptyObject(data))
|
||||
|
@ -187,6 +185,49 @@ $this->headTitle()->setSeparator(' - ');
|
|||
$('#error-loading').html("正在校验数据是否可以导入......");
|
||||
$('#error-loading').show();
|
||||
},
|
||||
'complete' : function(){
|
||||
$('#error-loading').hide();
|
||||
},
|
||||
'error' : function(){
|
||||
$(".error-alerts").show();
|
||||
$("#errors").html("数据表字段检测失败,请检查导入得文件是否于数据表中得字段对应");
|
||||
}
|
||||
});
|
||||
},
|
||||
getFields : function (){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/admin/data/dataimport/ac/getfields',
|
||||
'data':$('#schema-form').serialize(),
|
||||
'success':function(data){
|
||||
|
||||
if($.isEmptyObject(data))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$(".error-alerts").show();
|
||||
|
||||
var html = new Array();
|
||||
|
||||
html.push('<span>数据表字段信息</span>');
|
||||
html.push('<table class="table table-striped table-bordered" style="width:300px;">');
|
||||
html.push('<thead><th>排序</th><th>列名</th><th>数据类型</th></thead>');
|
||||
|
||||
$.each(data,function(index,value){
|
||||
html.push("<tr><td>"+value.dtd_identifier+"</td><td>" + value.column_name + "</td><td>" + value.data_type + "</td></tr>");
|
||||
});
|
||||
|
||||
html.push('</table>');
|
||||
|
||||
$('#errors').html(html.join(""));
|
||||
|
||||
},
|
||||
'timeout': 30000,
|
||||
'beforeSend' : function(){
|
||||
$('#error-loading').html("正在获取数据表信息......");
|
||||
$('#error-loading').show();
|
||||
},
|
||||
'complete' : function(){
|
||||
$('#error-loading').hide();
|
||||
}
|
||||
|
|
|
@ -60,12 +60,12 @@
|
|||
<label class="control-label">绘图插件</label>
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<input type="radio" name="chartjs" id="optionsRadios1" value="highcharts" <?= (isset($this->info['chartjs']) && $this->info['chartjs']=='highcharts') || empty($this->info['chartjs']) ? "checked":"" ?>>
|
||||
<input type="radio" name="chartjs" id="optionsRadios1" value="highcharts" <?= (isset($this->info['chartjs']) && $this->info['chartjs']=='highcharts') ? "checked":"" ?>>
|
||||
Highcharts(适合分类数据展示和三维展示)
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<input type="radio" name="chartjs" id="optionsRadios2" value="highstock"
|
||||
<?= isset($this->info['chartjs']) && $this->info['chartjs'] == 'highstock' ? 'checked="checked"':"" ?>>
|
||||
<?= (isset($this->info['chartjs']) && $this->info['chartjs'] == 'highstock') || empty($this->info['chartjs']) ? 'checked="checked"':"" ?>>
|
||||
Highstock(适合时间序列数据可视化)
|
||||
</label>
|
||||
</div>
|
||||
|
@ -124,7 +124,7 @@
|
|||
<label class="control-label">X轴取值</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="xaxis" placeholder="时间字段读取SQL" class="input-block-level" value="<?= isset($this->info['xaxis']) ? $this->info['xaxis']:'' ?>" />
|
||||
<p class="help-block">例如: utctime, times , (year||'-'||month||'-1')::timestamp without time zone ,不需要在最外层加括号或者双引号</p>
|
||||
<p class="help-block">例如: utctime, times , (year||'-'||month||'-1')::timestamp without time zone ,不需要在最外层加括号或者双引号。如果是制作分类图,则X轴必须是category,请在数据读取SQL中用将所需字段命名为category。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1977,23 +1977,23 @@ class DataController extends Zend_Controller_Action
|
|||
$ac = $this->_request->getParam('ac');
|
||||
if ($ac=='unready') {
|
||||
//列出没有DOI的数据
|
||||
$sql="select m.* from {$this->submd} m where length(m.doi)<3 and m.uuid not in (select uuid from datadoi) order by m.ts_created desc";
|
||||
$sql="select m.* from {$this->submd} m where m.uuid not in (select uuid from datadoi) order by m.ts_created desc";
|
||||
$this->view->pageID='doi-unready';
|
||||
} else if ($ac=='prepare') {
|
||||
//列出有DOI但还未进行提交申请的数据
|
||||
$sql="select m.* from {$this->submd} m where length(m.doi)>3 and m.uuid not in (select uuid from datadoi) order by m.ts_created desc";
|
||||
$sql="select m.* from {$this->submd} m where m.uuid not in (select uuid from datadoi) order by m.ts_created desc";
|
||||
$this->view->pageID='doi-prepare';
|
||||
} else if ($ac=='unsubmit') {
|
||||
//列出有DOI并计划提交申请的数据
|
||||
$sql="select m.*,d.doi as datadoi,date(d.ts_created) as ts_created from {$this->submd} m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_created is not null and d.ts_submitted is null order by d.ts_created desc";
|
||||
$sql="select m.*,d.doi as datadoi,date(d.ts_created) as ts_created from {$this->submd} m left join datadoi d on m.uuid=d.uuid where d.ts_created is not null and d.ts_submitted is null order by d.ts_created desc";
|
||||
$this->view->pageID='doi-unsubmit';
|
||||
} else if ($ac=='submit') {
|
||||
//列出有DOI并计划提交申请的数据
|
||||
$sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted from {$this->submd} m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_submitted is not null and d.ts_published is null order by d.ts_submitted desc,d.ts_created desc";
|
||||
$sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted from {$this->submd} m left join datadoi d on m.uuid=d.uuid where d.ts_submitted is not null and d.ts_published is null order by d.ts_submitted desc,d.ts_created desc";
|
||||
$this->view->pageID='doi-submit';
|
||||
} else if ($ac=='publish' || empty($ac)) {
|
||||
//默认:列出最新发布的DOI数据
|
||||
$sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted,date(d.ts_published) as ts_published from {$this->submd} m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_published is not null order by d.ts_published desc,d.ts_submitted desc,d.ts_created desc";
|
||||
$sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted,date(d.ts_published) as ts_published from {$this->submd} m left join datadoi d on m.uuid=d.uuid where d.ts_published is not null order by d.ts_published desc,d.ts_submitted desc,d.ts_created desc";
|
||||
$this->view->pageID='doi-publish';
|
||||
}
|
||||
$sth = $this->db->prepare($sql);
|
||||
|
@ -2079,28 +2079,12 @@ class DataController extends Zend_Controller_Action
|
|||
|
||||
function listAction()
|
||||
{
|
||||
$sql="select m.uuid,m.title,m.citation,m.doi,d.doi as datadoi,d.ts_published,d.authors,d.publisher,date_part('year',d.ts_published) as publish_year from normalmetadata m
|
||||
left join mdstatus s on m.uuid=s.uuid
|
||||
left join datadoi d on d.uuid=m.uuid
|
||||
where s.status>4
|
||||
and m.uuid not in
|
||||
(select d.uuid from datasource d left join source s on d.sourceid=s.id
|
||||
where s.code in ('heihe','water','hiwater','westee'))
|
||||
order by m.title";
|
||||
$sql="select m.uuid,m.title,m.citation,m.doi,d.doi as datadoi,d.ts_published,d.authors,d.publisher,date_part('year',d.ts_published) as publish_year from {$this->submd} m
|
||||
left join mdstatus s on m.uuid=s.uuid
|
||||
left join datadoi d on d.uuid=m.uuid
|
||||
where s.status>4
|
||||
order by m.title";
|
||||
$this->view->metadata=$this->db->fetchAll($sql);
|
||||
$sql="select m.uuid,m.title,m.citation,m.doi,d.doi as datadoi,d.ts_published,d.authors,d.publisher,date_part('year',d.ts_published) as publish_year
|
||||
from normalmetadata m left join datadoi d on d.uuid=m.uuid left join mdstatus s on m.uuid=s.uuid where s.status>4 and m.title like '黑河综合遥感联合试验%' order by title";
|
||||
$this->view->water=$this->db->fetchAll($sql);
|
||||
$sql="select m.uuid,m.title,m.citation ,m.doi,d.doi as datadoi,d.ts_published,d.authors,d.publisher,date_part('year',d.ts_published) as publish_year
|
||||
from normalmetadata m left join datadoi d on d.uuid=m.uuid left join mdstatus s on m.uuid=s.uuid where s.status>0 and m.title like '黑河生态水文遥感试验%' order by title";
|
||||
$this->view->hiwater=$this->db->fetchAll($sql);
|
||||
$sql="select m.uuid,m.title,m.citation ,m.doi,d.doi as datadoi,d.ts_published,d.authors,d.publisher,date_part('year',d.ts_published) as publish_year
|
||||
from normalmetadata m left join datadoi d on d.uuid=m.uuid left join mdstatus s on m.uuid=s.uuid left join datasource ds on ds.uuid=m.uuid left join source sr on ds.sourceid=sr.id where sr.code='heihe' and s.status>0 and m.title not like '黑河生态水文遥感试验%' order by title";
|
||||
$this->view->heihe=$this->db->fetchAll($sql);
|
||||
$sql="select m.uuid,m.title,m.citation ,m.doi,d.doi as datadoi,d.ts_published,d.authors,d.publisher,date_part('year',d.ts_published) as publish_year
|
||||
from normalmetadata m left join datadoi d on d.uuid=m.uuid left join mdstatus s on m.uuid=s.uuid left join datasource ds on ds.uuid=m.uuid left join source sr on ds.sourceid=sr.id where sr.code='westee' and s.status>4 order by title";
|
||||
$this->view->westee=$this->db->fetchAll($sql);
|
||||
|
||||
}
|
||||
|
||||
//可视化数据
|
||||
|
|
|
@ -7,7 +7,6 @@ $this->nav[] = array('link'=>"/data/doi",'title'=>'DOI浏览');
|
|||
$this->theme->AppendPlus($this,'colorbox');
|
||||
?>
|
||||
<div class='row-fluid'>
|
||||
<?= $this->render('breadcrumbs.phtml') ?>
|
||||
<?= $this->partial('data/tools.phtml'); ?>
|
||||
<ul class="nav nav-tabs">
|
||||
<li id="Nav-doi-publish"><a href="/data/doi">已发布DOI的数据</a></li>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<ul class="nav nav-pills">
|
||||
<li class="nav-header">特色导航方式</li>
|
||||
<li><a href="/data/tag"><i class="icon-tags"></i>关键词浏览</a></li>
|
||||
<li><a href="/data/series"><i class="icon-th-list"></i>序列浏览</a></li>
|
||||
<li><a href="/data/category"><i class="icon-th"></i>分类浏览</a></li>
|
||||
<li><a href="/data/timeline"><i class="icon-tasks"></i>时间轴浏览</a></li>
|
||||
<li><a href="/data/map"><i class="icon-globe"></i>空间浏览</a></li>
|
||||
|
|
|
@ -20,6 +20,7 @@ $this->theme->AppendPlus($this,'colorbox');
|
|||
</div>
|
||||
<h2><a href="/data/<?php echo $md['uuid']; ?>"><?php echo $this->escape($md['title']);?></a></h2>
|
||||
<span><?php echo mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?></span>
|
||||
<p class="text-right"><a href="/visual/view/uuid/<?= $md['uuid'] ?>" class="btn btn-info pull-right" style=" text-indent:0"><i class="icon-signal"></i>可视化查看</a></p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php echo $this->paginator; ?>
|
||||
|
|
|
@ -6,7 +6,6 @@ $theme = new Theme;
|
|||
$theme->appendPlus($this,'highcharts');
|
||||
$this->nav[] = array('link'=>"/data/visual",'title'=>'数据可视化');
|
||||
?>
|
||||
<?= $this->render('breadcrumbs.phtml'); ?>
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h3><?= $this->info['title'] ?> <small><a href="/data/<?= $this->info['uuid'] ?>">查看元数据</a></small></h3>
|
||||
|
|
|
@ -22,13 +22,14 @@ abstract class AbstractProcessing {
|
|||
switch ($pgsql_data_type){
|
||||
case "integer":
|
||||
case "bigint":
|
||||
case "int2vector":
|
||||
case "real":
|
||||
case "double precision":
|
||||
return is_int($data) || is_float($data);
|
||||
case "date":
|
||||
case "timestamp without time zone":
|
||||
case "char":
|
||||
case "character varying":
|
||||
case "text":
|
||||
return is_string($data);
|
||||
|
||||
default:
|
||||
|
|
|
@ -18,8 +18,8 @@ class Csv extends AbstractProcessing implements ProcessingInterface{
|
|||
private $csv_object;
|
||||
private $csv_line_data;
|
||||
|
||||
const ERROR_INDEX_NOT_MATCHED = "值的个数于其它行不匹配";
|
||||
const ERROR_INDEX_TYPE_DIFFERENT = "值的类型于上一行不同";
|
||||
const ERROR_INDEX_NOT_MATCHED = "值的个数与其它行不匹配";
|
||||
const ERROR_INDEX_TYPE_DIFFERENT = "值的类型与上一行不同";
|
||||
const ERROR_EMPTY_FILE = "文件是空的";
|
||||
const ERROR_LINE_TITLE = "行:";
|
||||
const ERROR_COLUMN_TITLE = "列:";
|
||||
|
@ -108,6 +108,19 @@ class Csv extends AbstractProcessing implements ProcessingInterface{
|
|||
return $this->csv_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 面向数据库字段的类型判断
|
||||
* @return bool
|
||||
*/
|
||||
private function typeCompare($var1,$var2)
|
||||
{
|
||||
$t1=gettype($var1);
|
||||
$t2=gettype($var2);
|
||||
if ($t1==$t2) return true;
|
||||
if (($t1=='integer' || $t1=='double') && ($t2=='integer' || $t2=='double'))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 檢查文件內容是否規則
|
||||
* @return array|bool
|
||||
|
@ -132,7 +145,7 @@ class Csv extends AbstractProcessing implements ProcessingInterface{
|
|||
}
|
||||
|
||||
foreach($v as $vIndex => $item){
|
||||
if(gettype($item) != gettype($lines[$k-1][$vIndex]))
|
||||
if(!$this->typeCompare($item,$lines[$k-1][$vIndex]))
|
||||
{
|
||||
$error_stack[] = self::ERROR_LINE_TITLE . ($k + 1) .":".self::ERROR_INDEX_TYPE_DIFFERENT;
|
||||
}
|
||||
|
@ -158,14 +171,14 @@ class Csv extends AbstractProcessing implements ProcessingInterface{
|
|||
|
||||
$first_line = $this->getLines()[0];
|
||||
|
||||
foreach($fields as $index => $field)
|
||||
$index=0;
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$func = $this->checkFieldsDataType($field['data_type'],$first_line[$index]);
|
||||
|
||||
if($func)
|
||||
continue;
|
||||
else
|
||||
if (!$this->checkFieldsDataType($field['data_type'],$first_line[$index]))
|
||||
{
|
||||
$error_stack[] = self::ERROR_COLUMN_TITLE . $index .":" . self::ERROR_DATA_TYPE_NOT_MATCHED;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
|
||||
if(count($error_stack) < 1)
|
||||
|
@ -176,7 +189,7 @@ class Csv extends AbstractProcessing implements ProcessingInterface{
|
|||
}
|
||||
|
||||
|
||||
public function import($table)
|
||||
public function import($table,$withid=fasle)
|
||||
{
|
||||
$config = \Zend_Registry::get('config');
|
||||
$db = new PDO([
|
||||
|
@ -200,7 +213,10 @@ class Csv extends AbstractProcessing implements ProcessingInterface{
|
|||
$place_holder[] = "?";
|
||||
}
|
||||
|
||||
$sth = $db->prepare("INSERT INTO $table VALUES (".join(",",$place_holder).")");
|
||||
if ($withid)
|
||||
$sth = $db->prepare("INSERT INTO $table VALUES (default,".join(",",$place_holder).")");
|
||||
else
|
||||
$sth = $db->prepare("INSERT INTO $table VALUES (".join(",",$place_holder).")");
|
||||
|
||||
foreach($this->getLines() as $line)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue