参考文献bug

This commit is contained in:
wangjinlei
2026-06-10 15:31:10 +08:00
parent 0a2b053718
commit 249a04c109
5 changed files with 109 additions and 5 deletions

View File

@@ -782,7 +782,8 @@ class Preaccept extends Base
$title = trim((string)($summary['title'] ?? '')); $title = trim((string)($summary['title'] ?? ''));
$jouraRaw = trim((string)($summary['joura'] ?? '')); $jouraRaw = trim((string)($summary['joura'] ?? ''));
$authorStr = trim((string)($summary['author_str'] ?? '')); // 姓全写 + 名首字母,超过 3 个作者取前 3 个 + et al
$authorCitation = $svc->getAuthorsCitation($summary['raw'] ?? [], 3);
$dateno = trim((string)($summary['dateno'] ?? '')); $dateno = trim((string)($summary['dateno'] ?? ''));
$doilink = trim((string)($summary['doilink'] ?? '')); $doilink = trim((string)($summary['doilink'] ?? ''));
if ($doilink === '') { if ($doilink === '') {
@@ -790,7 +791,7 @@ class Preaccept extends Base
} }
$f = [ $f = [
'author' => $authorStr !== '' ? prgeAuthor($authorStr) : '', 'author' => $authorCitation !== '' ? $authorCitation . '.' : '',
'title' => $title, 'title' => $title,
'joura' => $jouraRaw !== '' ? formateJournal($jouraRaw) : '', 'joura' => $jouraRaw !== '' ? formateJournal($jouraRaw) : '',
'dateno' => str_replace(' ', '', str_replace('-', '', $dateno)), 'dateno' => str_replace(' ', '', str_replace('-', '', $dateno)),

View File

@@ -3208,7 +3208,7 @@ class Production extends Base
$z = count($list); $z = count($list);
$m = 0; $m = 0;
foreach ($list as $v) { foreach ($list as $v) {
if ($v['refer_frag'] != '' || $v['author'] != '') { if ($v['refer_frag'] != '' || $v['author'] != ''|| $v['title'] != '') {
$m++; $m++;
} }
} }
@@ -3361,7 +3361,7 @@ class Production extends Base
$tt .= "Please carefully check the proof, including the text, figures, tables, references, author information, affiliations, spelling, and formatting. If any corrections are needed, please mark them clearly on the proof or submit comments through the system.<br/>"; $tt .= "Please carefully check the proof, including the text, figures, tables, references, author information, affiliations, spelling, and formatting. If any corrections are needed, please mark them clearly on the proof or submit comments through the system.<br/>";
$tt .= "If we do not receive your confirmation by ".date("Y-m-d", strtotime("+3 days")).", the proof will be considered approved in its current form. Please note that no further revisions will be accepted after online confirmation.<br/><br/>"; $tt .= "If we do not receive your confirmation by ".date("Y-m-d", strtotime("+3 days")).", the proof will be considered approved in its current form. Please note that no further revisions will be accepted after online confirmation.<br/><br/>";
$tt .= "Thank you for your time and cooperation. Should you have any questions, please feel free to contact us.<br/><br/>"; $tt .= "Thank you for your time and cooperation. Should you have any questions, please feel free to contact us.<br/><br/>";
$tt .= "Best regards,<br/>Biomedical Engineering Communications<br/>Email: bmec@tmrjournals.com<br/>Website: https://www.tmrjournals.com/bmec/"; $tt .= "Best regards,<br/>".$journal_info['title']."<br/>Email: ".$journal_info['email']."<br/>Website: ".$journal_info['website'];
// $maidata['email'] = '751475802@qq.com'; // $maidata['email'] = '751475802@qq.com';
$maidata['email'] = $user_info['email']; $maidata['email'] = $user_info['email'];

View File

@@ -300,6 +300,73 @@ class CrossrefService
return $authors; return $authors;
} }
/**
* 引用格式作者串:姓全写 + 名首字母,超过 $maxAuthors 个取前 N 个 + et al
* 例Smith JA, Jones B, Lee C, et al
*
* @param array $aDoiInfo Crossref message
* @param int $maxAuthors 最多展示作者数,超过则截断加 et al
* @return string
*/
public function getAuthorsCitation($aDoiInfo = [], $maxAuthors = 3)
{
$list = [];
if (!empty($aDoiInfo['author'])) {
foreach ($aDoiInfo['author'] as $author) {
$family = trim((string)($author['family'] ?? ''));
$given = trim((string)($author['given'] ?? ''));
if ($family === '' && $given === '') {
// 机构作者等无姓名结构的情况
$orgName = trim((string)($author['name'] ?? ''));
if ($orgName !== '') {
$list[] = $orgName;
}
continue;
}
$initials = $this->givenToInitials($given);
$name = $initials !== '' ? trim($family . ' ' . $initials) : $family;
if ($name !== '') {
$list[] = $name;
}
}
}
if (empty($list)) {
return '';
}
$maxAuthors = max(1, (int)$maxAuthors);
if (count($list) > $maxAuthors) {
$list = array_slice($list, 0, $maxAuthors);
return implode(', ', $list) . ', et al';
}
return implode(', ', $list);
}
/**
* 名转首字母:取每个组成部分(空格/连字符/点分隔)首字母大写并拼接。
* 例:"John A." -> "JA""Mary-Jane" -> "MJ"
*/
private function givenToInitials($given)
{
$given = trim((string)$given);
if ($given === '') {
return '';
}
$parts = preg_split('/[\s\-\.]+/u', $given, -1, PREG_SPLIT_NO_EMPTY);
$initials = '';
foreach ($parts as $p) {
$first = mb_substr($p, 0, 1);
if ($first !== '') {
$initials .= mb_strtoupper($first);
}
}
return $initials;
}
/** /**
* 提取发表年份 * 提取发表年份
*/ */

View File

@@ -2,6 +2,7 @@
namespace app\common; namespace app\common;
use think\Db; use think\Db;
use think\Env; use think\Env;
use app\common\CrossrefService;
class ProductionArticleRefer class ProductionArticleRefer
{ {
@@ -78,6 +79,41 @@ class ProductionArticleRefer
return json_encode(['status' => 4,'msg' => 'Reference DOI is empty'.json_encode($aParam)]); return json_encode(['status' => 4,'msg' => 'Reference DOI is empty'.json_encode($aParam)]);
} }
//开始用crossref接口的方式处理数据
$doiNorm = preg_replace('#^https?://(dx\.)?doi\.org/#i', '', $aRefer['refer_doi']);
$doiNorm = trim($doiNorm, " \t\n\r\0\x0B/");
$svc = new CrossrefService([
'mailto' => trim((string)Env::get('crossref_mailto', '')),
]);
$summary = $svc->fetchWorkSummary($doiNorm);
if ($summary !== null && !empty($summary['doi'])) {
$update_a = [];
$title = trim((string)($summary['title'] ?? ''));
$jouraRaw = trim((string)($summary['joura'] ?? ''));
// 姓全写 + 名首字母,超过 3 个作者取前 3 个 + et al
$authorCitation = $svc->getAuthorsCitation($summary['raw'] ?? [], 3);
$dateno = trim((string)($summary['dateno'] ?? ''));
$doilink = trim((string)($summary['doilink'] ?? ''));
$update_a['title'] = $title;
$update_a['author'] = $authorCitation !== '' ? $authorCitation . '.' : '';
$update_a['joura'] = $jouraRaw;
$update_a['dateno'] = $dateno;
$update_a['refer_type'] = "journal";
$update_a['is_ja'] = 1;
$update_a['doilink'] = $doilink;
$update_a['cs'] = 1;
$update_a['update_time'] = time();
$update_a['is_deal'] = 1;
Db::name('production_article_refer')->where(['p_refer_id' => $iPReferId])->limit(1)->update($update_a);
return json_encode(['status' => 1,'msg' => 'Update successful']);
}
//结束---用crossref接口的方式处理数据
//数据处理 //数据处理
$doi = str_replace('/', '%2F', $aRefer['refer_doi']); $doi = str_replace('/', '%2F', $aRefer['refer_doi']);
$url = "https://citation.doi.org/format?doi=$doi&style=cancer-translational-medicine&lang=en-US"; $url = "https://citation.doi.org/format?doi=$doi&style=cancer-translational-medicine&lang=en-US";

View File

@@ -27,7 +27,7 @@ use think\Env;
class LocalModelService class LocalModelService
{ {
/** 上下文长度阈值(字符数):<= 用小模型,> 用大模型 */ /** 上下文长度阈值(字符数):<= 用小模型,> 用大模型 */
const CONTEXT_THRESHOLD = 3000; const CONTEXT_THRESHOLD = 1000;
/** 请求超时(秒) */ /** 请求超时(秒) */
const TIMEOUT = 120; const TIMEOUT = 120;