diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index 8c9fe1d5..0e6efa9d 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -43,6 +43,11 @@ class Admin_DataController extends Zend_Controller_Action } $this->view->msg='成功同步元数据!'; } elseif ($source=="watergn" && empty($uuid) ) { + //首先删除所有的黑河试验数据 + $sql="delete from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d'"; + $this->db->query($sql); + $sql="delete from responsible where id not in (select distinct(resid) from role)"; + $this->db->query($sql); //同步黑河遥感实验的元数据 $sql="select uuid,data,source from watergn where schemaid='iso19115'"; $rs=$this->db->fetchAll($sql); @@ -700,6 +705,9 @@ class Admin_DataController extends Zend_Controller_Action //先删除已有元数据,然后再插入新数据 $sql="delete from metadata where uuid=?"; $this->db->query($sql,array($iso->uuid)); + //删除所有未用到的responsible数据 + $sql="delete from responsible where id not in (select distinct(resid) from role)"; + $this->db->query($sql); $row=$md->createRow(); $trow=$thumb->createRow(); $row->uuid=$iso->uuid; @@ -827,25 +835,25 @@ class Admin_DataController extends Zend_Controller_Action foreach($inds as $ind) { $sql="select id from responsible where individual=? and organisation=?"; - $row=$this->db->fetchRow($sql,array($ind,$au['organisation'])); + $row=$this->db->fetchRow($sql,array(trim($ind),trim($au['organisation']))); if (!$row) { $sql="insert into responsible (individual,organisation,position,delivery,phone,email,city,country,administrative,postal) values(?,?,?,?,?,?,?,?,?,?)"; - $this->db->query($sql,array($ind,$au['organisation'],$au['position'],$au['delivery'],$au['phone'],$au['email'],$au['city'],$au['country'],$au['administrative'],$au['postal'])); - } else { + $this->db->query($sql,array(trim($ind),trim($au['organisation']),trim($au['position']),trim($au['delivery']),trim($au['phone']),trim($au['email']),trim($au['city']),trim($au['country']),trim($au['administrative']),trim($au['postal']))); + } elseif (count($inds)==1) { //deal email address if (($au['email']) && empty($row->email)) { $sql="update responsible set email=? where id=?"; - $this->db->query($sql,array($au['email'],$row->id)); + $this->db->query($sql,array(trim($au['email']),$row->id)); } } $sql="select id from responsible where individual=? and organisation=?"; - $row=$this->db->fetchRow($sql,array($ind,$au['organisation'])); + $row=$this->db->fetchRow($sql,array(trim($ind),trim($au['organisation']))); if ($row->id>0) { $sql="insert into role (resid,uuid,role) values(?,?,?)"; - $this->db->query($sql,array($row->id,$iso->uuid,$au['role'])); + $this->db->query($sql,array($row->id,$iso->uuid,trim($au['role']))); } } } diff --git a/application/admin/views/scripts/index/index.phtml b/application/admin/views/scripts/index/index.phtml index fef718e5..08c83777 100755 --- a/application/admin/views/scripts/index/index.phtml +++ b/application/admin/views/scripts/index/index.phtml @@ -19,6 +19,7 @@
  • 数据管理
  • WATER元数据处理工具
  • 数据测试管理
  • +
  • 数据库工具