Commit bf776bd0 authored by hangjun83's avatar hangjun83

队列更新

parent a8dc8b0a
......@@ -80,6 +80,15 @@ class WuxiLabJobCommand extends Command
case 'test' :
$service->test($params);
break;
case 'test1' :
$service->test1();
break;
case 'batchUploadNewProducts' :
$service->batchUploadNewProducts();
break;
case 'batchUploadPackages' :
$service->batchUploadPackages();
break;
default:
}
......
......@@ -117,6 +117,31 @@ class WuxiLabService
}
}
public function batchUploadNewProducts()
{
$storeEntries = $this->apiService->getPlatformDataEntries('wuxiLab_not_exist_products','data_values');
if(isset($storeEntries['products']) && !empty($storeEntries['products'])){
$countNum = 0;
$products = [];
foreach($storeEntries['products'] as $product){
if(!in_array($product,$products) || empty($products)){
array_push($products,$product);
$countNum ++;
}
if($countNum == $this->apiService->getPlatformInfo('platform_params')['excelCreateLimit']){
$this->apiService->pushQueue([
'params' => ['products' => $products,'type' => 'product'],
'consumer' => __CLASS__,
'method' => 'processProductsUpdateThroughtExcel'
],'wuxilab_product');
$countNum = 0;
$products = [];
sleep(5);
}
}
}
}
/**
* @批量后台请求更新规格
* @param null $params
......@@ -182,11 +207,10 @@ class WuxiLabService
if(!isset($params['products']) || empty($params['products'])){
return false;
}
try{
$rawsList = $this->rhawnChemicalsService->getChemicalRawThroughtCode($params['products']);
if($rawsList){
foreach ($rawsList as $raw) {
foreach ($rawsList as $raw){
$rawIdList[] = $raw['r_id'];
}
$packages = $this->rhawnChemicalsService->getChemicalPackage($rawIdList);
......@@ -196,6 +220,7 @@ class WuxiLabService
$newPackages[$pack['r_code']] = $pack;
}
}
ini_set('memory_limit','4068M');
$path = app(WuxiLabExport::class)->saveExcel(
['rawList' => $rawsList,'packageList' => $newPackages],
$params['type']
......@@ -207,12 +232,12 @@ class WuxiLabService
trim(shell_exec("$cmd 2>&1"));
$filePathList = explode('/',$file);
$fileName = $filePathList[count($filePathList) - 1];
/*$result = $this->apiService->pushBatchUploadFile($params['type'],$fileName, $this->apiService->backgroundLogin());
$result = $this->apiService->pushBatchUploadFile($params['type'],$fileName, $this->apiService->backgroundLogin());
if($result){
$cmd = 'rm -rf '.storage_path('app/'.$newPath);
//trim(shell_exec("$cmd 2>&1"));
SimpleLogs::writeLog('文件名为:'.$fileName.'路径:'.$newPath.'药明康德后台上传完成', __CLASS__.':processNotExistProductsUpdate');
}*/
}
}
}
}catch(\Throwable $exception){
......@@ -220,12 +245,29 @@ class WuxiLabService
}
}
public function test1()
public function batchUploadPackages()
{
$storeEntries = $this->apiService->getPlatformDataEntries('wuxiLab_do_not_update_products','data_values');
var_dump($storeEntries['products']);
var_dump(count($storeEntries['products']));
exit;
if(isset($storeEntries['products']) && !empty($storeEntries['products'])){
$countNum = 0;
$products = [];
foreach($storeEntries['products'] as $product){
if(!in_array($product,$products) || empty($products)){
array_push($products,$product);
$countNum ++;
}
if($countNum == 100){
$this->apiService->pushQueue([
'params' => ['products' => $products,'type' => 'package'],
'consumer' => __CLASS__,
'method' => 'processProductsUpdateThroughtExcel'
],'wuxilab_package');
$countNum = 0;
$products = [];
sleep(5);
}
}
}
}
......
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