Commit eb7ac8ab authored by hangjun83's avatar hangjun83

药明康德更新

parent c2077287
......@@ -92,6 +92,9 @@ class WuxiLabJobCommand extends Command
case 'batchUpdateProductPackages' :
$service->batchUploadPackages();
break;
case 'batchUpdateProductsShelves' :
$service->batchUpdateProductsShelves();
break;
case 'initToken' :
$service->initToken();
break;
......
<?php
namespace App\ImportExport\WuxiLab\Models;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
class WuxiLabProductsShelvesExportModel implements FromArray,WithHeadings, ShouldAutoSize
{
private $exportContent = [];
public function __construct($exportContent)
{
$this->setExportContent($exportContent);
}
public function setExportContent($content)
{
$this->exportContent = $this->toMap($content);
}
public function array(): array
{
return $this->exportContent;
}
public function toMap($rows): array
{
$exportRows = [];
foreach($rows as $key => $row){
array_push($exportRows,[
$row
]);
}
return $exportRows;
}
public function headings(): array
{
return $this->getHeaderTitle();
}
private function getHeaderTitle()
{
return [
'supplierProductId'
];
}
}
......@@ -6,6 +6,7 @@ namespace App\ImportExport\WuxiLab;
use App\ImportExport\BaseExport;
use App\ImportExport\WuxiLab\Models\WuxiLabPackagesExportModel;
use App\ImportExport\WuxiLab\Models\WuxiLabProductsExportModel;
use App\ImportExport\WuxiLab\Models\WuxiLabProductsShelvesExportModel;
use App\ImportExport\WuxiLab\Models\WuxiLabStocksExportModel;
class WuxiLabExport extends BaseExport
......@@ -53,6 +54,9 @@ class WuxiLabExport extends BaseExport
case 'stock' :
$export = new WuxiLabStocksExportModel($saveContent['packageList']);
break;
case 'product_shelves' :
$export = new WuxiLabProductsShelvesExportModel($saveContent['rawCode']);
break;
}
$savePath = $this->getSavePath(
$this->getFileName($model)
......
......@@ -61,7 +61,7 @@ class WuxiApiService extends PlatformAbstractService
'username' => $this->platformInfo['platform_params']['username'],
'password' => $this->platformInfo['platform_params']['password']
],null,[
'cookie' => 'org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE=zh_CN; JSESSIONID=B2A024B5414E017F114AE4BCD29A6055'
'cookie' => 'org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE=zh_CN; JSESSIONID=805B829F0A377E7777326FBBA5F859E8'
]);
return json_decode($response,true)['token'];
......
......@@ -72,6 +72,52 @@ class WuxiLabService
}
}
/**
* 商品批量下架
* @param null $params
* @throws \Exception
*/
public function batchUpdateProductsShelves($params = null)
{
$status = $this->apiService->checkPlatformStatus();
if($status){
$limit = $this->apiService->getPlatformInfo('platform_params')['batchNums'];
$page = 0;
ini_set('memory_limit','3072M');
$rawCodeList = [];
while(true) {
$rawList = $this->rhawnChemicalsService->getRawsList($page * $limit, $limit);
if (!$rawList) {
break;
}
foreach ($rawList as $raw) {
if(!in_array($rawCodeList,$raw['r_code'])){
array_push($rawCodeList,$raw['r_code']);
}
}
$page ++;
}
$path = app(WuxiLabExport::class)->saveExcel(
['rawCode' => $rawCodeList], 'product_shelves'
);
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"));
SimpleLogs::writeLog('文件名为:'.$fileName.'路径:'.$newPath.'药明康德后台上传完成', __CLASS__.':processNotExistProductsUpdate');
}*/
}
}
}
public function test($rawCode)
{
try{
......
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