|
|
@@ -6,6 +6,7 @@ use Illuminate\Console\Command;
|
|
|
use App\Models\BookTitle;
|
|
|
use App\Models\FtsText;
|
|
|
use App\Models\WbwTemplate;
|
|
|
+use App\Tools\PaliSearch;
|
|
|
|
|
|
class UpgradeFts extends Command
|
|
|
{
|
|
|
@@ -14,9 +15,9 @@ class UpgradeFts extends Command
|
|
|
*
|
|
|
* @var string
|
|
|
*/
|
|
|
- protected $signature = 'upgrade:fts {--content : upgrade col content}
|
|
|
+ protected $signature = 'upgrade:fts {--content : upgrade col content only}
|
|
|
{para?}
|
|
|
- {--test : output log}';
|
|
|
+ {--test : output log only}';
|
|
|
|
|
|
/**
|
|
|
* The console command description.
|
|
|
@@ -45,36 +46,80 @@ class UpgradeFts extends Command
|
|
|
if(\App\Tools\Tools::isStop()){
|
|
|
return 0;
|
|
|
}
|
|
|
- if($this->option('content')){
|
|
|
- if(!empty($this->argument('para'))){
|
|
|
- $para = explode('-',$this->argument('para'));
|
|
|
+
|
|
|
+ if(!empty($this->argument('para'))){
|
|
|
+ $para = explode('-',$this->argument('para'));
|
|
|
+ }
|
|
|
+ for ($iBook=1; $iBook <= 217; $iBook++) {
|
|
|
+ if(isset($para[0]) && $para[0] != $iBook){
|
|
|
+ continue;
|
|
|
}
|
|
|
- for ($iBook=1; $iBook <= 217; $iBook++) {
|
|
|
- if(isset($para[0]) && $para[0] != $iBook){
|
|
|
+ # code...
|
|
|
+ $this->info('book:'.$iBook);
|
|
|
+ $maxParagraph = WbwTemplate::where('book',$iBook)->max('paragraph');
|
|
|
+ $bar = $this->output->createProgressBar($maxParagraph-1);
|
|
|
+ for($iPara=1; $iPara <= $maxParagraph; $iPara++){
|
|
|
+ if(isset($para[1]) && $para[1] != $iPara){
|
|
|
+ $bar->advance();
|
|
|
continue;
|
|
|
}
|
|
|
- # code...
|
|
|
- $this->info('book:'.$iBook);
|
|
|
- $maxParagraph = WbwTemplate::where('book',$iBook)->max('paragraph');
|
|
|
- $bar = $this->output->createProgressBar($maxParagraph-1);
|
|
|
- for($iPara=1; $iPara <= $maxParagraph; $iPara++){
|
|
|
- if(isset($para[1]) && $para[1] != $iPara){
|
|
|
- $bar->advance();
|
|
|
- continue;
|
|
|
- }
|
|
|
- $content = $this->getContent($iBook,$iPara);
|
|
|
- if($this->option('test')){
|
|
|
- $this->info($content);
|
|
|
+ $content = $this->getContent($iBook,$iPara);
|
|
|
+ //查找黑体字
|
|
|
+ $words = WbwTemplate::where('book',$iBook)
|
|
|
+ ->where('paragraph',$iPara)
|
|
|
+ ->orderBy('wid')->get();
|
|
|
+ $bold1 = array();
|
|
|
+ $bold2 = array();
|
|
|
+ $bold3 = array();
|
|
|
+ $currBold = array();
|
|
|
+ foreach ($words as $word) {
|
|
|
+ if($word->style==='bld'){
|
|
|
+ $currBold[] = $word->real;
|
|
|
}else{
|
|
|
- //TODO update bold
|
|
|
- FtsText::where('book',$iBook)->where('paragraph',$iPara)->update(['content'=>$content]);
|
|
|
+ $countBold = count($currBold);
|
|
|
+ if($countBold === 1){
|
|
|
+ $bold1[] = $currBold[0];
|
|
|
+ }else if($countBold === 2){
|
|
|
+ $bold2 = array_merge($bold2,$currBold);
|
|
|
+ }else if($countBold > 0){
|
|
|
+ $bold3 = array_merge($bold3,$currBold);
|
|
|
+ }
|
|
|
+ $currBold = [];
|
|
|
}
|
|
|
- $bar->advance();
|
|
|
}
|
|
|
- $bar->finish();
|
|
|
- $this->info('done');
|
|
|
+ $pcd_book = BookTitle::where('book',$iBook)
|
|
|
+ ->where('paragraph','<=',$iPara)
|
|
|
+ ->orderBy('paragraph','desc')
|
|
|
+ ->first();
|
|
|
+ if($pcd_book){
|
|
|
+ $pcd_book_id = $pcd_book->sn;
|
|
|
+ }else{
|
|
|
+ $pcd_book_id = BookTitle::where('book',$iBook)
|
|
|
+ ->orderBy('paragraph')
|
|
|
+ ->value('sn');
|
|
|
+ }
|
|
|
+ if($this->option('test')){
|
|
|
+ $this->info($content.
|
|
|
+ ' pcd_book='.$pcd_book_id.
|
|
|
+ ' bold1='.implode(' ',$bold1).
|
|
|
+ ' bold2='.implode(' ',$bold2).
|
|
|
+ ' bold3='.implode(' ',$bold3).PHP_EOL
|
|
|
+ );
|
|
|
+ }else{
|
|
|
+ $update = PaliSearch::update($iBook,
|
|
|
+ $iPara,
|
|
|
+ implode(' ',$bold1),
|
|
|
+ implode(' ',$bold2),
|
|
|
+ implode(' ',$bold3),
|
|
|
+ $content,
|
|
|
+ $pcd_book_id);
|
|
|
+ }
|
|
|
+ $bar->advance();
|
|
|
}
|
|
|
+ $bar->finish();
|
|
|
+ $this->info('done');
|
|
|
}
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|