Commit 886dcaed authored by hangjun83's avatar hangjun83

队列更新

parent 7d905db5
......@@ -2,6 +2,7 @@
namespace App\Console\Commands;
use App\Jobs\WuxiLabJob;
use App\Services\WuxiLabService;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
......@@ -56,8 +57,34 @@ class WuxiLabJobCommand extends Command
exit;
}
$productUpdateJob = (new WuxiLabJob($action_type,$params))->delay(100)->onQueue('slow');
app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($productUpdateJob);
$service = app(WuxiLabService::class);
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;
use App\Support\Traits\Helpers;
use Illuminate\Filesystem\Filesystem;
use longlang\phpkafka\Protocol\ApiVersions\ApiVersionsResponse;
use function Symfony\Component\String\u;
class WuxiLabService
{
......@@ -60,15 +61,12 @@ class WuxiLabService
}
}
if(!empty($rawList)){
SimpleKafka::produerSend(
[
$this->apiService->pushQueue([
'params' => ['rawList' => $rawList,'packageList' => $newPackages],
'consumer' => __CLASS__,
'method' => 'batchUpdateToWuxiLab'
],
'wuxilab'
);
],'wuxilab');
}
break;
}
......@@ -162,9 +160,13 @@ class WuxiLabService
if(!in_array($package['p_pack_unit'],$wuxiLabPackage)){
continue;
}
try{
$this->apiService->pushBatchUpdatePackages([
'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
//更新成功,批量更新包装规格
$storeEntries = $this->apiService->getPlatformDataEntries('wuxiLab_do_not_update_products','data_values');
if(!is_null($storeEntries) && count($storeEntries['products']) >= $this->apiService->getPlatformInfo('platform_params')['excelCreateLimit']){
SimpleKafka::produerSend(
[
$this->apiService->pushQueue([
'params' => ['products' => $storeEntries['products'],'type' => 'package'],
'consumer' => __CLASS__,
'method' => 'processProductsUpdateThroughtExcel'
]
);
],'wuxilab');
$this->apiService->removePlatformDataEntries('wuxiLab_do_not_update_products');
}
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