新增方法
This commit is contained in:
@@ -30,7 +30,8 @@ class Preaccept extends Base
|
||||
if (!$rule->check($data)) {
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$production_info = $this->production_article_obj->where('article_id', $data['article_id'])->find();
|
||||
$aWhere = ['article_id' => $data['article_id'],'state' => 0];
|
||||
$production_info = $this->production_article_obj->where($aWhere)->find();
|
||||
if ($production_info == null) {
|
||||
return jsonError("Object is null");
|
||||
}
|
||||
@@ -1603,5 +1604,164 @@ return null;
|
||||
$re['list'] = $mains;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
//作者上传参考文献 - 新
|
||||
public function addRefersByExcelNew(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id" => "require",
|
||||
"referFile" => "require"
|
||||
]);
|
||||
if (!$rule->check($data)) {
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
//判断数据是否存在 不存在直接入库数据 chengxiaoling 20251119 start
|
||||
$aWhere = ['article_id' => $data['article_id'],'state' => 0];
|
||||
$production_info = $this->production_article_obj->where($aWhere)->find();
|
||||
if (!$production_info) {
|
||||
$aResult = $this->addProductionEx($data['article_id']);
|
||||
$aResult = empty($aResult->getData()) ? [] : $aResult->getData();
|
||||
$iCode = isset($aResult['code']) ? $aResult['code'] : -1;
|
||||
$sMsg = empty($aResult['msg']) ? 'Data processing failed' : $aResult['msg'];
|
||||
if($iCode != 0){
|
||||
return jsonError($sMsg);
|
||||
}
|
||||
}
|
||||
$production_info = $this->production_article_obj->where($aWhere)->find();
|
||||
if(!$production_info){
|
||||
return jsonError("Object is null");
|
||||
}
|
||||
//判断数据是否存在 不存在直接入库数据 chengxiaoling 20251119 end
|
||||
$file = ROOT_PATH . 'public' . DS . "referFile" . DS . $data['referFile'];
|
||||
$list = $this->readRefersExcelNew($file,$production_info['p_article_id'],$data['article_id']);
|
||||
if(!empty($list)){
|
||||
$result = $this->production_article_refer_obj->insertAll($list);
|
||||
}
|
||||
//写入获取参考文献详情队列
|
||||
\think\Queue::push('app\api\job\ArticleReferQueue@fire',['article_id' => $data['article_id'],'p_article_id' => $production_info['p_article_id']], 'ArticleReferQueue');
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
public function readRefersExcelNew($afile,$p_article_id = 0,$article_id = 0){
|
||||
if(empty($p_article_id)){
|
||||
return [];
|
||||
}
|
||||
// //查询参考文献
|
||||
// $aWhere = ['p_article_id' => $p_article_id,'article_id' => $article_id,'state' => 0,'refer_doi' => ['<>','']];
|
||||
// $aRefer = Db::name('production_article_refer')->where($aWhere)->column('refer_doi');
|
||||
$extension = substr($afile, strrpos($afile, '.') + 1);
|
||||
vendor("PHPExcel.PHPExcel");
|
||||
if ($extension == 'xlsx') {
|
||||
$objReader = new \PHPExcel_Reader_Excel2007();
|
||||
$objPHPExcel = $objReader->load($afile);
|
||||
} else if ($extension == 'xls') {
|
||||
$objReader = new \PHPExcel_Reader_Excel5();
|
||||
$objPHPExcel = $objReader->load($afile);
|
||||
}
|
||||
$sheet = $objPHPExcel->getSheet(0);
|
||||
$highestRow = $sheet->getHighestRow();
|
||||
$frag = [];
|
||||
$k = 0;
|
||||
for ($i = 2; $i <= $highestRow; $i++) {
|
||||
if ($objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue() == '') {
|
||||
continue;
|
||||
}
|
||||
$aa['refer_content'] = $objPHPExcel->getActiveSheet()->getCell("A" . $i)->getValue();
|
||||
$aa['refer_doi'] = $objPHPExcel->getActiveSheet()->getCell("B" . $i)->getValue();
|
||||
if(empty($aa['refer_doi'])){
|
||||
continue;
|
||||
}
|
||||
$aa['refer_doi'] = trim($aa['refer_doi']);
|
||||
$aa['refer_content'] = trim($aa['refer_content']);
|
||||
// //判断是否添加过
|
||||
// $doiLinkPattern = '/^(https?:\/\/)?([a-zA-Z0-9_-]+\.)*[a-zA-Z0-9_-]+\.[a-zA-Z]{2,}(\/.*)?$/i';
|
||||
// if(preg_match($doiLinkPattern, $aa['refer_doi'], $matches)){
|
||||
// if(in_array($aa['refer_doi'], $aRefer)){
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
$aa['p_article_id'] = $p_article_id;
|
||||
$aa['article_id'] = $article_id;
|
||||
$aa['index'] = $k;
|
||||
$aa['ctime'] = time();
|
||||
$aa['index'] = $k;
|
||||
$aa['refer_frag'] = $aa['refer_content'];
|
||||
$aa['refer_type'] = 'other';
|
||||
$aa['is_deal'] = 2;
|
||||
$k++;
|
||||
$frag[] = $aa;
|
||||
}
|
||||
return $frag;
|
||||
}
|
||||
//获取参考文献的状态
|
||||
public function getReferState(){
|
||||
//获取参数
|
||||
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||
//获取文章ID
|
||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
if(empty($iArticleId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select the article']);
|
||||
}
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aProductionArticle = $this->production_article_obj->field('p_article_id')->where($aWhere)->find();
|
||||
$iPArticleId = empty($aProductionArticle['p_article_id']) ? 0 : $aProductionArticle['p_article_id'];
|
||||
if(empty($iPArticleId)) {
|
||||
return json_encode(array('status' => 2,'msg' => 'No articles found'));
|
||||
}
|
||||
//查询参考文献数据
|
||||
$aWhere = ['p_article_id' => $iPArticleId,'article_id' => $iArticleId,'state' => 0];
|
||||
$iCount = Db::name('production_article_refer')->where($aWhere)->count();
|
||||
if(empty($iCount)){
|
||||
return json_encode(array('status' => 3,'msg' => 'Reference is empty','data' => ['total' => 0,'unprocessed_total' => 0,'processed_total' => 0]));
|
||||
}
|
||||
//获取未处理的数据
|
||||
$aWhere['is_deal'] = 2;
|
||||
$aUnprocessed = Db::name('production_article_refer')->where($aWhere)->select();
|
||||
//获取已处理的数据
|
||||
$aWhere['is_deal'] = 1;
|
||||
$aProcessed = Db::name('production_article_refer')->where($aWhere)->select();
|
||||
//未处理的数量
|
||||
$iUnprocessed = empty($aUnprocessed) ? 0 : count($aUnprocessed);
|
||||
//已处理的数量
|
||||
$iProcessed = empty($aProcessed) ? 0 : count($aProcessed);
|
||||
|
||||
//数据组合
|
||||
$aRefer = array_merge($aUnprocessed,$aProcessed);
|
||||
$aRefer = ['total' => $iCount,'unprocessed_total' => $iUnprocessed,'processed_total' => $iProcessed,'refer' => $aRefer];
|
||||
return json_encode(['status' => 1,'msg' => 'success','data' => $aRefer]);
|
||||
}
|
||||
|
||||
//使文章进入生产状态
|
||||
public function beginProduce(){
|
||||
//获取参数
|
||||
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||
//获取文章ID
|
||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
if(empty($iArticleId)){
|
||||
return jsonError('Please select the article');
|
||||
}
|
||||
//查询是否缴费
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => ['in',[5,6]]];
|
||||
$aArticle = $this->article_obj->field('is_buy')->where($aWhere)->find();
|
||||
if(empty($aArticle)){
|
||||
return jsonError('No article information found');
|
||||
}
|
||||
$iIsBuy = empty($aArticle['is_buy']) ? 0 : $aArticle['is_buy'];
|
||||
if($iIsBuy != 1){
|
||||
return jsonError('Article unpaid');
|
||||
}
|
||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||
$aProductionArticle = $this->production_article_obj->field('p_article_id')->where($aWhere)->find();
|
||||
if(!empty($aProductionArticle)) {
|
||||
return jsonError('The article has entered production');
|
||||
}
|
||||
$aResult = $this->addProductionEx($iArticleId);
|
||||
$aResult = empty($aResult->getData()) ? [] : $aResult->getData();
|
||||
$iCode = isset($aResult['code']) ? $aResult['code'] : -1;
|
||||
$sMsg = empty($aResult['msg']) ? 'Data processing failed' : $aResult['msg'];
|
||||
if($iCode != 0){
|
||||
return jsonError($sMsg);
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user