Commit bf776bd0 authored by hangjun83's avatar hangjun83

队列更新

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