Commit 3f41fe6b authored by hangjun83's avatar hangjun83

更新

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