Commit 886dcaed authored by hangjun83's avatar hangjun83

队列更新

parent 7d905db5
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Jobs\WuxiLabJob; use App\Jobs\WuxiLabJob;
use App\Services\WuxiLabService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait; use Illuminate\Console\ConfirmableTrait;
...@@ -56,8 +57,34 @@ class WuxiLabJobCommand extends Command ...@@ -56,8 +57,34 @@ class WuxiLabJobCommand extends Command
exit; exit;
} }
$productUpdateJob = (new WuxiLabJob($action_type,$params))->delay(100)->onQueue('slow'); $service = app(WuxiLabService::class);
app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($productUpdateJob); switch($this->action_type){
case 'initProductToExcel' :
if(!isset($params) || $params == 0){
$params['limit'] = 1000;
}
$service->initCreateProductsToExcel($params['limit']);
break;
case 'batchUpdatePackages' :
if(!isset($params) || $params == 0){
$params['limit'] = 1000;
}
$service->batchUpdatePackagesInfo($params);
break;
case 'batchUploadProducts' :
$service->batchUploadProducts();
break;
case 'batchUpdateProduct' :
$service->batchUpdateProducts();
break;
case 'test' :
$service->test($params);
break;
default:
}
/*$productUpdateJob = (new WuxiLabJob($action_type,$params))->delay(100)->onQueue('slow');
app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($productUpdateJob);*/
} }
} }
......
...@@ -23,6 +23,7 @@ use App\Support\Facades\SimpleLogs; ...@@ -23,6 +23,7 @@ use App\Support\Facades\SimpleLogs;
use App\Support\Traits\Helpers; use App\Support\Traits\Helpers;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use longlang\phpkafka\Protocol\ApiVersions\ApiVersionsResponse; use longlang\phpkafka\Protocol\ApiVersions\ApiVersionsResponse;
use function Symfony\Component\String\u;
class WuxiLabService class WuxiLabService
{ {
...@@ -60,15 +61,12 @@ class WuxiLabService ...@@ -60,15 +61,12 @@ class WuxiLabService
} }
} }
if(!empty($rawList)){ if(!empty($rawList)){
SimpleKafka::produerSend( $this->apiService->pushQueue([
[ 'params' => ['rawList' => $rawList,'packageList' => $newPackages],
'params' => ['rawList' => $rawList,'packageList' => $newPackages], 'consumer' => __CLASS__,
'consumer' => __CLASS__, 'method' => 'batchUpdateToWuxiLab'
'method' => 'batchUpdateToWuxiLab'
], ],'wuxilab');
'wuxilab'
);
} }
break; break;
} }
...@@ -162,9 +160,13 @@ class WuxiLabService ...@@ -162,9 +160,13 @@ class WuxiLabService
if(!in_array($package['p_pack_unit'],$wuxiLabPackage)){ if(!in_array($package['p_pack_unit'],$wuxiLabPackage)){
continue; continue;
} }
$this->apiService->pushBatchUpdatePackages([ try{
'unit_quantity' => $package['p_pack'], 'unit_type' => $package['p_pack_unit'], 'unit_description' => $package['p_pack'].$package['p_pack_unit'] $this->apiService->pushBatchUpdatePackages([
],$token); 'unit_quantity' => $package['p_pack'], 'unit_type' => $package['p_pack_unit'], 'unit_description' => $package['p_pack'].$package['p_pack_unit']
],$token);
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':batchUpdatePackagesInfo', 'error');
}
} }
} }
} }
...@@ -259,13 +261,11 @@ class WuxiLabService ...@@ -259,13 +261,11 @@ class WuxiLabService
//更新成功,批量更新包装规格 //更新成功,批量更新包装规格
$storeEntries = $this->apiService->getPlatformDataEntries('wuxiLab_do_not_update_products','data_values'); $storeEntries = $this->apiService->getPlatformDataEntries('wuxiLab_do_not_update_products','data_values');
if(!is_null($storeEntries) && count($storeEntries['products']) >= $this->apiService->getPlatformInfo('platform_params')['excelCreateLimit']){ if(!is_null($storeEntries) && count($storeEntries['products']) >= $this->apiService->getPlatformInfo('platform_params')['excelCreateLimit']){
SimpleKafka::produerSend( $this->apiService->pushQueue([
[ 'params' => ['products' => $storeEntries['products'],'type' => 'package'],
'params' => ['products' => $storeEntries['products'],'type' => 'package'], 'consumer' => __CLASS__,
'consumer' => __CLASS__, 'method' => 'processProductsUpdateThroughtExcel'
'method' => 'processProductsUpdateThroughtExcel' ],'wuxilab');
]
);
$this->apiService->removePlatformDataEntries('wuxiLab_do_not_update_products'); $this->apiService->removePlatformDataEntries('wuxiLab_do_not_update_products');
} }
foreach($result['successProduct'] as $successProduct){ foreach($result['successProduct'] as $successProduct){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment