This commit is contained in:
wangjinlei
2022-09-12 17:42:14 +08:00
parent ea2355c4d8
commit 8490380169
4 changed files with 389 additions and 61 deletions

View File

@@ -39,6 +39,7 @@ class Typeset extends Controller
protected $ts_obj = '';
protected $ts_refer_obj = '';
protected $ts_frag_obj = '';
protected $online_obj = '';
public function __construct(\think\Request $request = null)
{
@@ -69,6 +70,7 @@ class Typeset extends Controller
$this->ts_obj = Db::name('ts');
$this->ts_refer_obj = Db::name('ts_refer');
$this->ts_frag_obj = Db::name('ts_frag');
$this->online_obj = Db::name('online');
}
public function getTypeSet()
@@ -92,6 +94,154 @@ class Typeset extends Controller
return jsonSuccess($re);
}
/**
* 添加online
*/
public function createOnline(){
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$check = $this->online_obj->where('article_id',$data['article_id'])->where('on_state',0)->find();
if($check){
return jsonError('不能重复生成');
}
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$ts_info = $this->ts_obj->where('article_id',$data['article_id'])->where('ts_state',0)->find();
$insert['article_id'] = $data['article_id'];
$insert['journal_id'] = $journal_info['journal_id'];
$insert['on_title'] = $article_info['title'];
$insert['on_doi'] = $ts_info['ts_doi'];
$insert['abstract'] = $ts_info['ts_abstract'];
$insert['keywords'] = $ts_info['keywords'];
$insert['on_ctime'] = time();
$this->online_obj->insert($insert);
return jsonSuccess([]);
}
/**
* 编辑online信息
*/
public function editOnline(){
$data = $this->request->post();
$rule = new Validate([
'on_id'=>'require',
'journal_stage_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$update['journal_stage_id'] = $data['journal_stage_id'];
if(isset($data['abstract'])){
$update['abstract'] =trim($data['abstract']);
}
if(isset($data['npp'])&&$data['npp']!=''){
$update['npp'] = $data['npp'];
}
$this->online_obj->where('on_id',$data['on_id'])->update($update);
return jsonSuccess([]);
}
/**
* 获取online列表
*/
public function getOnlineList(){
$data = $this->request->post();
$rule = new Validate([
'journal_id'=>'require',
'editor_id'=>'require',
'pageIndex'=>'require',
'pageSize'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$journalids = [];
if($data['journal_id']==0){
$journalids = $this->journal_obj->where('editor_id',$data['editor_id'])->column('journal_id');
}else{
$journalids[] = $data['journal_id'];
}
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
$list = $this->online_obj->where('journal_id','in',$journalids)->where('on_state',0)->limit($limit_start,$data['pageSize'])->select();
$count = $this->online_obj->where('journal_id','in',$journalids)->where('on_state',0)->count();
$re['onlines'] = $list;
$re['count'] = $count;
return jsonSuccess($re);
}
/**
* 推送文章到官网系统
*/
public function pushArticleToSystem(){
$data = $this->request->post();
$rule = new Validate([
'on_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$on_info = $this->online_obj->where('on_id',$data['on_id'])->find();
$ts_info = $this->ts_obj->where('article_id',$on_info['article_id'])->where('ts_state',0)->find();
$article_info = $this->article_obj->where('article_id',$on_info['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$authors = $this->article_author_obj->where('article_id',$article_info['article_id'])->where('state',0)->select();
//check信息是否完整
if($on_info['journal_stage_id']==''||$on_info['on_doi']==''||$on_info['abstract']==''||$on_info['npp']==''){
return jsonError('信息不全!');
}
//发送推送请求
// $url = "http://www.journal.com/master/Article/addArticleForSubmission";
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/addArticleForSubmission';
$pra = [];
$pra['title'] = $article_info['title'];
$pra['journal_stage_id'] = $on_info['journal_stage_id'];
$pra['issn'] = $journal_info['issn'];
$pra['type'] = translateType($article_info['type']);
$pra['doi'] = $on_info['on_doi'];
$pra['abstract'] = $on_info['abstract'];
$pra['pub_date'] = $ts_info['online_date'];
$pra['file_pdf'] = $article_info['pdf_url'];
$pra['keywords'] = $article_info['keywords'];
$pra['npp'] = $on_info['npp'];
$pra['authors'] = json_encode($authors);
$res = object_to_array(json_decode(myPost($url, $pra)));
if($res['code']==0){
$this->online_obj->where('on_id',$data['on_id'])->update(['has_push'=>1]);
return jsonSuccess([]);
}else{
return jsonError('system error!');
}
}
/**
* 编辑online信息
*/
// public function editOnline(){
// $data = $this->request->post();
// // 验证规则
// $rule = new Validate([
// 'on_id' => 'require|number',
// 'abstract' => 'require'
// ]);
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
// }
/**
* 获取排版实例列表
*/
@@ -121,8 +271,8 @@ class Typeset extends Controller
->limit($limit_start, $data['pageSize'])
->select();
$count = $this->ts_obj->join('t_article', 't_article.article_id = t_ts.article_id', 'left')->where('t_ts.ts_state', 0)->where('t_article.journal_id', 'in', $journals)->count();
foreach($ts_list as $k => $v){
$cache = $this->ts_frag_obj->where('ts_id',$v['ts_id'])->where('tf_state',0)->order('ts_id desc')->limit(1)->find();
foreach ($ts_list as $k => $v) {
$cache = $this->ts_frag_obj->where('ts_id', $v['ts_id'])->where('tf_state', 0)->order('ts_id desc')->limit(1)->find();
$ts_list[$k]['frag_url'] = $cache['url'];
}
$re['ts_list'] = $ts_list;
@@ -133,15 +283,16 @@ class Typeset extends Controller
/**
* 获取排版实例最终文件列表
*/
public function getFragList(){
public function getFragList()
{
$data = $this->request->post();
$rule = new Validate([
'ts_id'=>'require'
'ts_id' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->ts_frag_obj->where('ts_id',$data['ts_id'])->where('tf_state',0)->select();
$list = $this->ts_frag_obj->where('ts_id', $data['ts_id'])->where('tf_state', 0)->select();
$re['frags'] = $list;
return jsonSuccess($re);
@@ -175,31 +326,33 @@ class Typeset extends Controller
/**
* 修改参考文献的最终结果
*/
public function editReferFrag(){
public function editReferFrag()
{
$data = $this->request->post();
$rule = new Validate([
'ts_refer_id'=>'require',
'refer_frag'=>'require'
'ts_refer_id' => 'require',
'refer_frag' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->ts_refer_obj->where('ts_refer_id',$data['ts_refer_id'])->update(['refer_frag'=>$data['refer_frag'],'cs'=>1]);
$this->ts_refer_obj->where('ts_refer_id', $data['ts_refer_id'])->update(['refer_frag' => $data['refer_frag'], 'cs' => 1]);
return jsonSuccess([]);
}
/**
* 改成可修改状态
*/
public function beginEdit(){
public function beginEdit()
{
$data = $this->request->post();
$rule = new Validate([
'ts_refer_id'=>'require'
'ts_refer_id' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->ts_refer_obj->where('ts_refer_id',$data['ts_refer_id'])->update(['cs'=>0]);
$this->ts_refer_obj->where('ts_refer_id', $data['ts_refer_id'])->update(['cs' => 0]);
return jsonSuccess([]);
}
@@ -234,7 +387,7 @@ class Typeset extends Controller
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
$ts_info = $this->ts_obj->where('article_id', $article_id)->where('ts_state',0)->find();
$ts_info = $this->ts_obj->where('article_id', $article_id)->where('ts_state', 0)->find();
$refers = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_state', 0)->select();
foreach ($refers as $v) { //处理doi
if (strripos($v['refer_content'], 'doi:') == false && strripos($v['refer_content'], 'doi.org/') == false) {
@@ -261,6 +414,30 @@ class Typeset extends Controller
return jsonSuccess([]);
}
/**
* 获取online信息
*/
public function getOnlineDetail(){
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'on_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$online_info = $this->online_obj->where('on_id',$data['on_id'])->find();
$article_info = $this->article_obj->where('article_id',$online_info['article_id'])->find();
$ts_info = $this->ts_obj->where('article_id',$article_info['article_id'])->where('ts_state',0)->find();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$online_info['article_type'] = translateType($article_info['type']);
$re['journal'] = $journal_info;
$re['online'] = $online_info;
return jsonSuccess($re);
}
/**
* doi获取格式化的参考文献信息
*/
@@ -274,22 +451,120 @@ class Typeset extends Controller
// if (!$rule->check($data)) {
// return jsonError($rule->getError());
// }
$ts_info = $this->ts_obj->where('article_id', $article_id)->where('ts_state',0)->find();
$ts_info = $this->ts_obj->where('article_id', $article_id)->where('ts_state', 0)->find();
$refers = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_state', 0)->select();
//清空frag百分比用重新生成
// $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_doi', '<>', '')->update(['refer_frag' => '']);
foreach ($refers as $v) {
if($v['refer_doi']==''){
$this->ts_refer_obj->where('ts_refer_id',$v['ts_refer_id'])->update(['refer_frag'=>$v['refer_content']]);
}else{
if ($v['refer_doi'] == '') {
$this->ts_refer_obj->where('ts_refer_id', $v['ts_refer_id'])->update(['refer_frag' => $v['refer_content']]);
} else {
Queue::push('app\api\job\ts@fire', $v, 'ts');
}
}
return jsonSuccess([]);
}
/**
* pdf文件加水印
*/
public function pdfAddPfroof()
{
vendor('fpdf.fpdf');
vendor('fpdi/fpdi');
$pdf = new \FPDI();
$pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS.'pdf'.DS.'test.pdf');
public function up_pdf_file(){
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h']));
else $pdf->AddPage('P', array($size['w'], $size['h']));
// use the imported page
// $pdf->useTemplate($templateId);
$pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 25, 80);
$pdf->image(ROOT_PATH . 'public' . DS.'pdf'.DS.'bg2.png',55, 155, 80);
$pdf->useTemplate($templateId);
// $pdf->SetFont('Arial', 'B', '12');
// // sign with current date
// $pdf->SetXY(0, 0); // you should keep testing untill you find out correct x,y values
// $pdf->Write(7, date('Y-m-d'));
}
$pdf->Output(ROOT_PATH . 'public' . DS.'pdf'.DS.'word.pdf');
}
/**
* 获取online的分期
*/
public function getStagesOnline(){
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'journal_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
$cs['issn'] = $journal_info['issn'];
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Journal/getStageByISSN';
// $url = 'http://www.journal.com/master/Journal/getStageByISSN';
$list = object_to_array(json_decode(myPost($url, $cs)));
$re['stages'] = $list['data']['stages'];
return jsonSuccess($re);
}
/**
* 添加online分期
*/
public function addStage(){
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'journal_id' => 'require|number',
'stage_year'=>'require',
'stage_vol'=>'require',
'stage_no'=>'require',
'stage_pagename'=>'require',
'stage_page'=>'require',
'issue_date'=>'require',
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$journal_info = $this->journal_obj->where('journal_id',$data['journal_id'])->find();
$insert_data['issn'] = $journal_info['issn'];
$insert_data['stage_year'] = $data['stage_year'];
$insert_data['stage_vol'] = $data['stage_vol'];
$insert_data['stage_no'] = $data['stage_no'];
$insert_data['stage_pagename'] = $data['stage_pagename'];
$insert_data['stage_page'] = $data['stage_page'];
$insert_data['issue_date'] = $data['issue_date'];
if (isset($data['stage_icon']) && !empty($data['stage_icon'])) {
$insert_data['stage_icon'] = $data['stage_icon'];
}
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Journal/addStageForTG';
// $url = 'http://www.journal.com/master/Journal/addStageForTG';
$list = object_to_array(json_decode(myPost($url, $insert_data)));
return jsonSuccess([]);
}
/**
* 上传pdf文件
*/
public function up_pdf_file()
{
$file = request()->file('pdf');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'pdf');
@@ -305,16 +580,17 @@ class Typeset extends Controller
/**
* 更新pdf文件
*/
public function updateArticlePdfFile(){
public function updateArticlePdfFile()
{
$data = $this->request->post();
$rule = new Validate([
'article_id'=>'require',
'pdf'=>'require'
'article_id' => 'require',
'pdf' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->article_obj->where('article_id',$data['article_id'])->update(['pdf_url'=>$data['pdf']]);
$this->article_obj->where('article_id', $data['article_id'])->update(['pdf_url' => $data['pdf']]);
return jsonSuccess([]);
}
@@ -322,28 +598,29 @@ class Typeset extends Controller
/**
* 验证参考文献是否全部通过
*/
public function checkRefer(){
public function checkRefer()
{
$data = $this->request->post();
$rule = new Validate([
'ts_id'=>'require'
'ts_id' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$list = $this->ts_refer_obj->where('ts_id',$data['ts_id'])->where('refer_state',0)->select();
if(!$list){
$list = $this->ts_refer_obj->where('ts_id', $data['ts_id'])->where('refer_state', 0)->select();
if (!$list) {
return jsonError('references error');
}
$frag = 1;
foreach($list as $v){
if($v['cs']==0){
foreach ($list as $v) {
if ($v['cs'] == 0) {
$frag = 0;
break;
}
}
if($frag==0){
if ($frag == 0) {
return jsonError('references check error');
}else{
} else {
return jsonSuccess([]);
}
}
@@ -359,7 +636,7 @@ class Typeset extends Controller
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->where('ts_state',0)->find();
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->where('ts_state', 0)->find();
$list = $this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->where('refer_state', 0)->select();
$z = count($list);
$m = 0;
@@ -393,6 +670,24 @@ class Typeset extends Controller
// echo $frag;
}
/**
* 获取作者详情为了online
*/
public function getAuthorForOnline(){
$data = $this->request->post();
// 验证规则
$rule = new Validate([
'article_id' => 'require|number'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$authors = $this->article_author_obj->where('article_id',$data['article_id'])->where('state',0)->select();
$re['authors'] = $authors;
return jsonSuccess($re);
}
/**
* 排版主方法入口
@@ -410,7 +705,7 @@ class Typeset extends Controller
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id', $article_info['journal_id'])->find();
$editor_info = $this->user_obj->where('user_id', $journal_info['editor_id'])->find();
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->where('ts_state',0)->find();
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->where('ts_state', 0)->find();
$typesetInfo = [];
$typesetInfo['info_title'] = $ts_info['ts_title'];
@@ -465,7 +760,7 @@ class Typeset extends Controller
$res = object_to_array(json_decode(myPost1($url, $typesetInfo)));
// return jsonSuccess($res);
if(!isset($res['data']['file'])||$res['data']['file']==''){
if (!isset($res['data']['file']) || $res['data']['file'] == '') {
return jsonError('create error');
}
$file_res = $res['data']['file'];
@@ -504,13 +799,17 @@ class Typeset extends Controller
'ts_abstract' => 'require',
'acknowledgment' => 'require',
'abbreviation' => 'require',
'ts_doi' => 'require',
'ts_topic' => 'require',
'ts_main' => 'require'
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
$journal_info = $this->journal_obj->where('journal_id',$article_info['journal_id'])->find();
$old_ts_info = $this->ts_obj->where('article_id',$data['article_id'])->where('ts_state',0)->find();
$insert_ts['ts_title'] = $data['ts_title'];
$insert_ts['ts_type'] = $data['ts_type'];
$insert_ts['author'] = $data['author'];
@@ -528,14 +827,34 @@ class Typeset extends Controller
$insert_ts['ts_abstract'] = $data['ts_abstract'];
$insert_ts['acknowledgment'] = $data['acknowledgment'];
$insert_ts['abbreviation'] = $data['abbreviation'];
$insert_ts['ts_doi'] = $data['ts_doi'];
//如果doi还没有需要生成
if($old_ts_info['ts_doi']==''){
$c1 = explode(';',$data['stage']);
$year = $c1[0];
$c2 = explode('(',$c1[1]);
$vol = $c2[0];
$insert_ts['ts_doi'] =$this->createdoi($year,$vol,$journal_info['abbr']);
}
// $insert_ts['ts_doi'] = $data['ts_doi'];
$insert_ts['trdition'] = $data['trdition'];
$insert_ts['ts_topic'] = $data['ts_topic'];
$insert_ts['ts_main'] = $data['ts_main'];
$this->ts_obj->where('article_id', $data['article_id'])->where('ts_state',0)->update($insert_ts);
$this->ts_obj->where('article_id', $data['article_id'])->where('ts_state', 0)->update($insert_ts);
return jsonSuccess([]);
}
private function createdoi($year,$vol,$abbr){
$frag = '';
$doi = $abbr.$year.$vol.rand(1000,9999);
$frag = $doi;
$check = $this->ts_obj->where('ts_doi',$doi)->find();
if($check){
$frag = $this->createdoi($year,$vol,$abbr);
}
return $frag;
}
/**
* 创建排版实例
*/
@@ -552,7 +871,7 @@ class Typeset extends Controller
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
//存在实例不可重复创建
$check_ts = $this->ts_obj->where('article_id', $data['article_id'])->where('ts_state',0)->find();
$check_ts = $this->ts_obj->where('article_id', $data['article_id'])->where('ts_state', 0)->find();
if ($check_ts) {
return jsonError("has created");
}
@@ -616,7 +935,10 @@ class Typeset extends Controller
}
$frag['main'][] = $v;
}
// var_dump($frag);
//创建doi
//组合,存储获取到的信息
$insert_ts = [];
$insert_ts['article_id'] = $article_info['article_id'];
@@ -671,7 +993,7 @@ class Typeset extends Controller
return jsonError($rule->getError());
}
$article_info = $this->article_obj->where('article_id',$data['article_id'])->find();
$article_info = $this->article_obj->where('article_id', $data['article_id'])->find();
$files = $this->article_file_obj
->where('article_id', $article_info['article_id'])
->where('type_name', 'manuscirpt')
@@ -693,36 +1015,38 @@ class Typeset extends Controller
/**
* 删除排版实例
*/
public function delTypeSet(){
public function delTypeSet()
{
$data = $this->request->post();
$rule = new Validate([
'ts_id'=>'require'
'ts_id' => 'require'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$this->ts_obj->where('ts_id',$data['ts_id'])->update(['ts_state'=>1]);
$this->ts_obj->where('ts_id', $data['ts_id'])->update(['ts_state' => 1]);
return jsonSuccess([]);
}
/**
* 更新引用条目
*/
public function freshRefers(){
public function freshRefers()
{
$data = $this->request->post();
$rule = new Validate([
'article_id'=>'require',
'refers'=>'require|array'
'article_id' => 'require',
'refers' => 'require|array'
]);
if(!$rule->check($data)){
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$ts_info = $this->ts_obj->where('article_id',$data['article_id'])->where('ts_state',0)->find();
$ts_info = $this->ts_obj->where('article_id', $data['article_id'])->where('ts_state', 0)->find();
//清空之前的引用条目
$this->ts_refer_obj->where('ts_id',$ts_info['ts_id'])->update(['refer_state'=>1]);
$this->ts_refer_obj->where('ts_id', $ts_info['ts_id'])->update(['refer_state' => 1]);
foreach($data['refers'] as $k => $v){
foreach ($data['refers'] as $k => $v) {
$cache_insert['ts_id'] = $ts_info['ts_id'];
$cache_insert['refer_content'] = $v;
$cache_insert['refer_ctime'] = time();

BIN
vendor/fpdf/bg.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

View File

@@ -73,7 +73,7 @@ var $PDFVersion; // PDF version number
* Public methods *
* *
*******************************************************************************/
function FPDF($orientation='P', $unit='mm', $size='A4')
function __construct($orientation='P', $unit='mm', $size='A4')
{
// Some checks
$this->_dochecks();

View File

@@ -560,10 +560,14 @@ class FPDI extends FPDF_TPL
reset ($value[1]);
while (list($k, $v) = each($value[1])) {
foreach ($value[1] as $k => $v){
$this->_straightOut($k . ' ');
$this->_writeValue($v);
}
// while (list($k, $v) = each($value[1])) {
// $this->_straightOut($k . ' ');
// $this->_writeValue($v);
// }
$this->_straightOut('>>');
break;