作者 lyh

gxAiblog自动发布

... ... @@ -30,6 +30,7 @@ use App\Models\Workchat\MessagePush;
use App\Services\AiBlogService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
... ... @@ -50,6 +51,8 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
$this->_actions();
dd(111);
$projectModel = new Project();
$lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
foreach ($lists as $val) {
... ... @@ -125,4 +128,28 @@ class lyhDemo extends Command
return $aiSettingInfo;
}
public function _actions(){
echo '565'.PHP_EOL;
ProjectServer::useProject(565);
$table = 'gl_route_map';
$filed = 'route';
$str = 'Trimos,insize,Fowler,Mahr,Starrett,Tesa,Mitutoyo,Wixey,Shars,Fisso,Spi,Grizzly,Accumaster,Accuremote,Baker,Sharpe,Compac,Earth,Etalon,Federal,Fell,Fisso,Fowler,Gem,Grizzly,Husky,iGaging,Insize,Kanetec,Magnetics,Mighty,Mitutoyo,Noga,Pittsburgh,Procheck,Saker,Scherr Tumico,Shars,Shinwa,SPI,Starrett,Tesa,Technidea,Trimos,Verdict,Wyler,Wixey';
$arr = explode(',', $str);
foreach ($arr as $val) {
$val = strtolower(trim($val)); // 去除空白并转小写
$str_s = $val.'-';
DB::connection('custom_mysql')->table($table)
->whereRaw("LOWER($filed) LIKE ?", ["%{$str_s}%"]) // 不区分大小写匹配包含
->update([
$filed => DB::raw("REPLACE(LOWER($filed), '$str_s', '')") // 只替换对应字符串,且都转小写替换
]);
DB::connection('custom_mysql')->table($table)
->whereRaw("LOWER($filed) LIKE ?", ["%{$val}%"]) // 不区分大小写匹配包含
->update([
$filed => DB::raw("REPLACE(LOWER($filed), '$val', '')") // 只替换对应字符串,且都转小写替换
]);
}
DB::disconnect('custom_mysql');
}
}
... ...