fix #230, 实现文献数据同步

This commit is contained in:
wlx 2011-10-29 07:12:47 +00:00
parent ae5c70c4a6
commit d9a155f878
3 changed files with 78 additions and 2 deletions

View File

@ -164,6 +164,45 @@ class Admin_SysController extends Zend_Controller_Action
}//emailtextAction 邮件模板管理 }//emailtextAction 邮件模板管理
function seekspaceAction()
{
set_time_limit(0);
$submit = $this->_request->getParam('submit');
if (!empty($submit))
{
$sql="select item_id from knl_article order by id desc";
$row=$this->db->fetchRow($sql);
try {
$this->db->beginTransaction();
$sql="insert into knl_article (item_id) select item_id from knl_dcvalue where dc_type_id=66 and text_value='Article' and item_id>".$row['item_id'];
$this->db->query($sql);
$sql="update knl_article k set title=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=64) as t where k.item_id=t.item_id and k.item_id>".$row['item_id'];
$this->db->query($sql);
$sql="update knl_article k set url=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=25) as t where k.item_id=t.item_id and k.item_id>".$row['item_id'];
$this->db->query($sql);
$sql="update knl_article k set publisher=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=39) as t where k.item_id=t.item_id and k.item_id>".$row['item_id'];
$this->db->query($sql);
$sql="update knl_article k set ts_issued=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=15) as t where k.item_id=t.item_id and k.item_id>".$row['item_id'];
$this->db->query($sql);
$sql="update knl_article k set ts_created=cast(t.text_value as timestamp without time zone) from (select text_value,item_id from knl_dcvalue where dc_type_id=12) as t where k.item_id=t.item_id and k.item_id>".$row['item_id'];
$this->db->query($sql);
$sql="update knl_article k set keywords[t.place]=t.text_value from (select text_value,item_id,place from knl_dcvalue where dc_type_id=57) as t where k.item_id=t.item_id and k.item_id>".$row['item_id'];
$this->db->query($sql);
$sql="insert into knl_keyword (keyword,item_id,place) select text_value,item_id,place from knl_dcvalue where dc_type_id=57 and item_id>".$row['item_id'];
$this->db->query($sql);
$sql="insert into knl_author (author,item_id,place) select text_value,item_id,place from knl_dcvalue where dc_type_id=3 and item_id>".$row['item_id'];
$this->db->query($sql);
$this->db->query("delete from knl_keyword where item_id not in (select item_id from knl_article)");
$this->db->query("delete from knl_author where item_id not in (select item_id from knl_article)");
$this->db->commit();
} catch(Exception $e) {
$this->db->rollBack();
$this->view->msg=$e->getMessage();
}
$this->view->msg='与文献平台同步成功!';
}
$sql="select (select count(*) from knl_article) as westdccount,(select count(*) from knl_dcvalue where dc_type_id=66 and text_value='Article') as seekcount";
$this->view->count=$this->db->fetchRow($sql);
}
} }

View File

@ -1,4 +1,5 @@
<ul> <ul>
<li class="title">系统管理</li> <li class="title">系统管理</li>
<li><a href="/admin/sys/emailtext">邮件模板管理</a></li> <li><a href="/admin/sys/emailtext">邮件模板管理</a></li>
<li><a href="/admin/sys/seekspace">文献平台同步</a></li>
</ul> </ul>

View File

@ -0,0 +1,36 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/sys">系统管理</a>');
$this->breadcrumb('文献平台同步');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/jquery-1.6.4.min.js');
?>
<div id="leftPanel">
<?= $this->partial('sys/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div class="box box-info">
<?php if ($this->msg) : ?>
<?php echo $this->msg; ?>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<?php echo $msg; ?>
<?php endforeach;endif; ?>
<script language="javascript">
setTimeout('$(".box-info").remove()',5000);
</script>
</div>
<?php endif; ?>
<form method="post">
<p>WestDC共有文献<?php echo $this->count['westdccount']; ?>条数Seekspace上共有文献<?php echo $this->count['seekcount']; ?>条。</p>
<p>此同步比较慢,请耐心等候!</p>
<input type="hidden" name="submit" value="1" />
<p><input type="submit" class="btn" value="确认同步?" /></p>
</form>
</div>