1
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use think\Db;
|
||||
use think\Env;
|
||||
use phpseclib3\Net\SFTP;
|
||||
|
||||
//use TCPDF;
|
||||
|
||||
@@ -249,6 +250,40 @@ function getAuthor($article) {
|
||||
return $frag;
|
||||
}
|
||||
|
||||
|
||||
function pushSFTPForScopus($file)
|
||||
{
|
||||
$host = 'sftp-opsbank2.elsevier.com';
|
||||
$port = 22; // SFTP 默认端口号
|
||||
$username = 'pdf-e';
|
||||
$password = '?b#W5=T4';
|
||||
|
||||
// 创建 SFTP 连接
|
||||
$sftp = new SFTP($host, $port);
|
||||
|
||||
if (!$sftp->login($username, $password)) {
|
||||
exit('SFTP 登录失败');
|
||||
}
|
||||
|
||||
// 列出远程服务器的文件
|
||||
// $fileList = $sftp->nlist();
|
||||
// print_r($fileList);
|
||||
|
||||
// 上传文件到 SFTP 服务器
|
||||
$localFile = ROOT_PATH."public/articleXML/".$file;
|
||||
$remoteFile = '/data/incoming/tmr/'.$file;
|
||||
|
||||
$res = $sftp->put($remoteFile, $localFile, SFTP::SOURCE_LOCAL_FILE);
|
||||
|
||||
if ($res) {
|
||||
echo "文件上传成功!";
|
||||
} else {
|
||||
var_dump($sftp);
|
||||
// return $sftp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function strongArticleList($list){
|
||||
$journal_stage_obj = Db::name("journal_stage");
|
||||
$journal_obj = Db::name("journal");
|
||||
|
||||
@@ -226,18 +226,19 @@ class Datebase extends Controller
|
||||
// }
|
||||
// }
|
||||
|
||||
public function getaaa(){
|
||||
$num = $this->request->post('num');
|
||||
$list = $this->article_obj->where('j_article.state',0)->join("j_journal_stage","j_journal_stage.journal_stage_id = j_article.journal_stage_id",'left')
|
||||
->page($num,1000)->field("j_article.article_id,j_journal_stage.stage_year")->select();
|
||||
$re['list'] = $list;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
// public function getaaa(){
|
||||
// $num = $this->request->post('num');
|
||||
// $list = $this->article_obj->where('j_article.state',0)->join("j_journal_stage","j_journal_stage.journal_stage_id = j_article.journal_stage_id",'left')
|
||||
// ->page($num,1000)->field("j_article.article_id,j_journal_stage.stage_year")->select();
|
||||
// $re['list'] = $list;
|
||||
// return jsonSuccess($re);
|
||||
// }
|
||||
|
||||
|
||||
public function xmlCreateForArticle(){
|
||||
|
||||
$article_id = 3034;
|
||||
private function xmlCreateForArticle($article_id){
|
||||
|
||||
// $article_id = 3035;
|
||||
|
||||
$article_info = $this->article_obj->where("article_id",$article_id)->find();
|
||||
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
||||
@@ -335,10 +336,10 @@ class Datebase extends Controller
|
||||
$issue->addAttribute("content-type","No.");
|
||||
|
||||
//abstract
|
||||
// $abstract = $articleMeta->addChild("abstract ");
|
||||
// $abstract->addAttribute("xml:lang","en");
|
||||
// $abs_p = $abstract->addChild("p",$article_info['abstract']);
|
||||
// $abs_p->addAttribute("indent","0mm");
|
||||
$abstract = $articleMeta->addChild("abstract");
|
||||
$abstract->addAttribute("xml:lang","en");
|
||||
$abs_p = $abstract->addChild("p",htmlspecialchars($article_info['abstract'], ENT_QUOTES | ENT_XML1, 'UTF-8'));
|
||||
$abs_p->addAttribute("indent","0mm");
|
||||
|
||||
//keywords
|
||||
$kwd = $articleMeta->addChild("kwd-group");
|
||||
@@ -378,7 +379,10 @@ class Datebase extends Controller
|
||||
|
||||
// 将生成的 XML 输出或保存
|
||||
// echo $xml->asXML(); // 或者保存到文件,例如 $xml->asXML('output.xml');
|
||||
$xml->asXML('d:/output.xml');
|
||||
$x = $xml->asXML();
|
||||
|
||||
$file = ROOT_PATH."public/articleXML/".substr($article_info['doi'],strpos($article_info['doi'],"/")+1).".xml";
|
||||
file_put_contents($file, $x);
|
||||
|
||||
}
|
||||
|
||||
@@ -415,6 +419,30 @@ class Datebase extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function testAcopus(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"stage_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$this->scopusPushXML($data['stage_id']);
|
||||
}
|
||||
|
||||
|
||||
public function scopusPushXML($stage_id){
|
||||
$list = $this->article_obj->where("journal_stage_id",$stage_id)->where("state",0)->select();
|
||||
foreach ($list as $v){
|
||||
$this->xmlCreateForArticle($v['article_id']);
|
||||
$file = substr($v['doi'],strpos($v['doi'],"/")+1).".xml";
|
||||
pushSFTPForScopus($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送邮件至青年科学家
|
||||
*/
|
||||
@@ -695,6 +723,8 @@ class Datebase extends Controller
|
||||
// 发送ftp
|
||||
$this->createFtpFileInfo($data["journal_stage_id"]);
|
||||
|
||||
$this->scopusPushXML($data["journal_stage_id"]);
|
||||
|
||||
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user