作者 刘锟

采集数据按6.0展示后,再次采集不覆盖

@@ -312,7 +312,7 @@ class ProjectUpdate extends Command @@ -312,7 +312,7 @@ class ProjectUpdate extends Command
312 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 312 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
313 313
314 try { 314 try {
315 - $product = $model->read(['route' => $route], 'id'); 315 + $product = $model->read(['route' => $route], ['id', 'six_read']);
316 if (!$product) { 316 if (!$product) {
317 $id = $model->insertGetId([ 317 $id = $model->insertGetId([
318 'project_id' => $project_id, 318 'project_id' => $project_id,
@@ -338,8 +338,12 @@ class ProjectUpdate extends Command @@ -338,8 +338,12 @@ class ProjectUpdate extends Command
338 ]); 338 ]);
339 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id); 339 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
340 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $domain_arr['host'], $link_type, $language_list, $page_list); 340 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
  341 + $six_read = 1;
341 } else { 342 } else {
342 $id = $product['id']; 343 $id = $product['id'];
  344 + $six_read = $product['six_read'];
  345 + if ($six_read) {
  346 + //按5.0展示才需要更新数据
343 $model->edit([ 347 $model->edit([
344 'title' => $item['ttile'], 348 'title' => $item['ttile'],
345 'intro' => $item['short_description'] ?? '', 349 'intro' => $item['short_description'] ?? '',
@@ -356,9 +360,11 @@ class ProjectUpdate extends Command @@ -356,9 +360,11 @@ class ProjectUpdate extends Command
356 'sort' => $item['sort'] ?? 0, 360 'sort' => $item['sort'] ?? 0,
357 ], ['id' => $id]); 361 ], ['id' => $id]);
358 } 362 }
  363 + }
359 364
  365 + if ($six_read) {
360 //关联分类 366 //关联分类
361 - if ($category_arr) { 367 + if ($$category_arr) {
362 CategoryRelated::saveRelated($id, array_column($category_arr, 'id')); 368 CategoryRelated::saveRelated($id, array_column($category_arr, 'id'));
363 } 369 }
364 370
@@ -395,6 +401,7 @@ class ProjectUpdate extends Command @@ -395,6 +401,7 @@ class ProjectUpdate extends Command
395 } 401 }
396 } 402 }
397 } 403 }
  404 + }
398 } catch (\Exception $e) { 405 } catch (\Exception $e) {
399 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 406 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
400 continue; 407 continue;
@@ -448,7 +455,7 @@ class ProjectUpdate extends Command @@ -448,7 +455,7 @@ class ProjectUpdate extends Command
448 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 455 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
449 456
450 try { 457 try {
451 - $news = $model->read(['url' => $route], 'id'); 458 + $news = $model->read(['url' => $route], ['id', 'six_read']);
452 if (!$news) { 459 if (!$news) {
453 $id = $model->insertGetId([ 460 $id = $model->insertGetId([
454 'project_id' => $project_id, 461 'project_id' => $project_id,
@@ -472,6 +479,9 @@ class ProjectUpdate extends Command @@ -472,6 +479,9 @@ class ProjectUpdate extends Command
472 CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $domain_arr['host'], $link_type, $language_list, $page_list); 479 CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
473 } else { 480 } else {
474 $id = $news['id']; 481 $id = $news['id'];
  482 + $six_read = $news['six_read'];
  483 + if ($six_read) {
  484 + //按5.0展示才需要更新数据
475 $model->edit([ 485 $model->edit([
476 'name' => $item['ttile'], 486 'name' => $item['ttile'],
477 'category_id' => $category_id, 487 'category_id' => $category_id,
@@ -483,6 +493,7 @@ class ProjectUpdate extends Command @@ -483,6 +493,7 @@ class ProjectUpdate extends Command
483 'sort' => $item['sort'] ?? 0, 493 'sort' => $item['sort'] ?? 0,
484 ], ['id' => $id]); 494 ], ['id' => $id]);
485 } 495 }
  496 + }
486 } catch (\Exception $e) { 497 } catch (\Exception $e) {
487 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 498 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
488 continue; 499 continue;
@@ -516,7 +527,7 @@ class ProjectUpdate extends Command @@ -516,7 +527,7 @@ class ProjectUpdate extends Command
516 //名称去掉特殊符号 527 //名称去掉特殊符号
517 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 528 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
518 try { 529 try {
519 - $custom = $model->read(['url' => $route], 'id'); 530 + $custom = $model->read(['url' => $route], ['id', 'six_read']);
520 if (!$custom) { 531 if (!$custom) {
521 $id = $model->insertGetId([ 532 $id = $model->insertGetId([
522 'project_id' => $project_id, 533 'project_id' => $project_id,
@@ -537,6 +548,9 @@ class ProjectUpdate extends Command @@ -537,6 +548,9 @@ class ProjectUpdate extends Command
537 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $domain_arr['host'], $link_type, $language_list, $page_list); 548 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
538 } else { 549 } else {
539 $id = $custom['id']; 550 $id = $custom['id'];
  551 + $six_read = $custom['six_read'];
  552 + if ($six_read) {
  553 + //按5.0展示才需要更新数据
540 $model->edit([ 554 $model->edit([
541 'name' => $item['ttile'], 555 'name' => $item['ttile'],
542 'title' => $item['ttile'], 556 'title' => $item['ttile'],
@@ -545,6 +559,7 @@ class ProjectUpdate extends Command @@ -545,6 +559,7 @@ class ProjectUpdate extends Command
545 'html' => $item['content'] ?? '', 559 'html' => $item['content'] ?? '',
546 ], ['id' => $id]); 560 ], ['id' => $id]);
547 } 561 }
  562 + }
548 } catch (\Exception $e) { 563 } catch (\Exception $e) {
549 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 564 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
550 continue; 565 continue;
@@ -632,7 +647,7 @@ class ProjectUpdate extends Command @@ -632,7 +647,7 @@ class ProjectUpdate extends Command
632 $item['title'] = $this->special2str($item['title'] ?? ''); 647 $item['title'] = $this->special2str($item['title'] ?? '');
633 648
634 try { 649 try {
635 - $custom_content = $model->read(['route' => $route], 'id'); 650 + $custom_content = $model->read(['route' => $route], ['id','six_read']);
636 if (!$custom_content) { 651 if (!$custom_content) {
637 $id = $model->insertGetId([ 652 $id = $model->insertGetId([
638 'project_id' => $project_id, 653 'project_id' => $project_id,
@@ -651,8 +666,11 @@ class ProjectUpdate extends Command @@ -651,8 +666,11 @@ class ProjectUpdate extends Command
651 $this->set_map($route, RouteMap::SOURCE_MODULE, $id, $project_id); 666 $this->set_map($route, RouteMap::SOURCE_MODULE, $id, $project_id);
652 667
653 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_MODULE, $id, $domain_arr['host'], $link_type, $language_list, $page_list); 668 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_MODULE, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
  669 + $six_read = 1;
654 } else { 670 } else {
655 $id = $custom_content['id']; 671 $id = $custom_content['id'];
  672 + $six_read = $custom_content['six_read'];
  673 + if($six_read){
656 $model->edit([ 674 $model->edit([
657 'name' => $item['title'], 675 'name' => $item['title'],
658 'category_id' => $category_id, 676 'category_id' => $category_id,
@@ -661,8 +679,10 @@ class ProjectUpdate extends Command @@ -661,8 +679,10 @@ class ProjectUpdate extends Command
661 'image' => $new_img 679 'image' => $new_img
662 ], ['id' => $id]); 680 ], ['id' => $id]);
663 } 681 }
  682 + }
664 683
665 //扩展字段 684 //扩展字段
  685 + if($six_read){
666 if ($item['extend'] ?? []) { 686 if ($item['extend'] ?? []) {
667 foreach ($item['extend'] as $ke => $ve) { 687 foreach ($item['extend'] as $ke => $ve) {
668 $extend = $extend_model->read(['title' => $ke]); 688 $extend = $extend_model->read(['title' => $ke]);
@@ -699,6 +719,7 @@ class ProjectUpdate extends Command @@ -699,6 +719,7 @@ class ProjectUpdate extends Command
699 } 719 }
700 } 720 }
701 } 721 }
  722 + }
702 } catch (\Exception $e) { 723 } catch (\Exception $e) {
703 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 724 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
704 continue; 725 continue;