Commit 3f41fe6b authored by hangjun83's avatar hangjun83

更新

parent 6cfed54a
......@@ -211,52 +211,50 @@ class WuxiLabService
}
try{
$rawsList = $newPackages = [];
if(count($params['products']) > 5000){
$slice_array_length= 500;
$current_length = 0;
while(true){
$list = [];
$product = array_slice($params['products'],$current_length,$slice_array_length);
$list = $this->rhawnChemicalsService->getChemicalRawThroughtCode($product);
if($list){
$rawIdList = [];
foreach ($rawsList as $raw){
$rawIdList[] = $raw['r_id'];
}
$rawsList = array_merge($rawsList,$list);
$packages = $this->rhawnChemicalsService->getChemicalPackage($rawIdList);
if($packages){
foreach($packages as $pack){
$newPackages[$pack['r_code']] = $pack;
}
}
$slice_array_length= 500;
$current_length = 0;
while(true){
$list = [];
$product = array_slice($params['products'],$current_length,$slice_array_length);
$list = $this->rhawnChemicalsService->getChemicalRawThroughtCode($product);
if($list){
$rawIdList = [];
foreach ($rawsList as $raw){
$rawIdList[] = $raw['r_id'];
}
if($current_length >= $slice_array_length){
break;
$rawsList = array_merge($rawsList,$list);
$packages = $this->rhawnChemicalsService->getChemicalPackage($rawIdList);
if($packages){
foreach($packages as $pack){
$newPackages[$pack['r_code']] = $pack;
}
}
$current_length += $slice_array_length;
}
if($current_length >= $slice_array_length){
break;
}
$current_length += $slice_array_length;
}
$path = app(WuxiLabExport::class)->saveExcel(
['rawList' => $rawsList,'packageList' => $newPackages],
$params['type']
);
if($path){
list($file,$expend) = explode('.',$path);
$newPath = $file.'.'.strtolower($expend);
$cmd = 'mv '.storage_path('app/'.$path).' '.storage_path('app/'.$newPath);
$path = app(WuxiLabExport::class)->saveExcel(
['rawList' => $rawsList,'packageList' => $newPackages],
$params['type']
);
if($path){
list($file,$expend) = explode('.',$path);
$newPath = $file.'.'.strtolower($expend);
$cmd = 'mv '.storage_path('app/'.$path).' '.storage_path('app/'.$newPath);
trim(shell_exec("$cmd 2>&1"));
$filePathList = explode('/',$file);
$fileName = $filePathList[count($filePathList) - 1];
$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"));
$filePathList = explode('/',$file);
$fileName = $filePathList[count($filePathList) - 1];
$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');
}
SimpleLogs::writeLog('文件名为:'.$fileName.'路径:'.$newPath.'药明康德后台上传完成', __CLASS__.':processNotExistProductsUpdate');
}
usleep(rand(1000000,5000000));
}
usleep(rand(1000000,5000000));
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':processNotExistProductsUpdate', 'error');
}
......
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