Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
f477dea9
Commit
f477dea9
authored
Sep 09, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
药明康德
parent
28426dfe
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
479 additions
and
152 deletions
+479
-152
server/app/ImportExport/BaseExport.php
server/app/ImportExport/BaseExport.php
+19
-9
server/app/ImportExport/WuxiLab/Models/WuxiLabPackagesExportModel.php
...mportExport/WuxiLab/Models/WuxiLabPackagesExportModel.php
+2
-2
server/app/ImportExport/WuxiLab/Models/WuxiLabProductsExportModel.php
...mportExport/WuxiLab/Models/WuxiLabProductsExportModel.php
+1
-1
server/app/ImportExport/WuxiLab/Models/WuxiLabStocksExportModel.php
.../ImportExport/WuxiLab/Models/WuxiLabStocksExportModel.php
+1
-1
server/app/ImportExport/WuxiLab/WuxiLabExport.php
server/app/ImportExport/WuxiLab/WuxiLabExport.php
+26
-28
server/app/Jobs/WuxiLabJob.php
server/app/Jobs/WuxiLabJob.php
+3
-0
server/app/Repositories/Eloquent/RhawnRawRepositoryEloquent.php
.../app/Repositories/Eloquent/RhawnRawRepositoryEloquent.php
+13
-0
server/app/Repositories/Eloquent/ThirdApiPlatformRepositoryEloquent.php
...ositories/Eloquent/ThirdApiPlatformRepositoryEloquent.php
+0
-25
server/app/Services/ThirdPlatform/Api/WuxiApiService.php
server/app/Services/ThirdPlatform/Api/WuxiApiService.php
+136
-32
server/app/Services/ThirdPlatform/Api/ZhenkhApiService.php
server/app/Services/ThirdPlatform/Api/ZhenkhApiService.php
+1
-1
server/app/Services/ThirdPlatform/PlatformAbstractService.php
...er/app/Services/ThirdPlatform/PlatformAbstractService.php
+1
-1
server/app/Services/WuxiLabService.php
server/app/Services/WuxiLabService.php
+231
-42
server/app/Support/Traits/HttpClientHelpers.php
server/app/Support/Traits/HttpClientHelpers.php
+34
-1
server/database/seeds/local/ThridApiPlatformSeeder.php
server/database/seeds/local/ThridApiPlatformSeeder.php
+11
-9
No files found.
server/app/ImportExport/BaseExport.php
View file @
f477dea9
<?php
<?php
namespace
App\Export
;
namespace
App\
Import
Export
;
use
App\Services\SysLogService
;
use
App\Services\SysLogService
;
use
App\Support\Facades\SimpleLogs
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Maatwebsite\Excel\Excel
as
BaseExcel
;
use
Maatwebsite\Excel\Excel
as
BaseExcel
;
...
@@ -26,14 +27,23 @@ class BaseExport
...
@@ -26,14 +27,23 @@ class BaseExport
public
function
storeExcel
(
$excelContent
,
$filePath
,
$diskType
=
null
){
public
function
storeExcel
(
$excelContent
,
$filePath
,
$diskType
=
null
){
if
(
$diskType
==
null
){
if
(
$diskType
==
null
){
$diskType
=
config
(
'filesystem.default'
);
$diskType
=
config
(
'filesystem
s
.default'
);
}
}
$result
=
Excel
::
store
(
$excelContent
,
$filePath
,
$diskType
,
$this
->
expand
);
try
{
if
(
Excel
::
store
(
$excelContent
,
$filePath
,
$diskType
,
$this
->
expand
)){
$logContent
=
[
$logContent
=
[
'filePath'
=>
$filePath
,
'filePath'
=>
$filePath
,
'diskType'
=>
$diskType
,
'diskType'
=>
$diskType
,
'datetime'
=>
time
()
'datetime'
=>
time
()
];
];
app
(
SysLogService
::
class
)
->
addOperationLogs
(
$logContent
);
SimpleLogs
::
writeLog
(
$logContent
,
__CLASS__
.
':storeExcel'
);
return
true
;
}
return
false
;
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':storeExcel'
,
'error'
);
throw
$exception
;
}
}
}
}
}
server/app/ImportExport/WuxiLab/Models/WuxiLabPackagesExportModel.php
View file @
f477dea9
<?php
<?php
namespace
App\Export\WuxiLab\Models
;
namespace
App\
Import
Export\WuxiLab\Models
;
use
Maatwebsite\Excel\Concerns\FromArray
;
use
Maatwebsite\Excel\Concerns\FromArray
;
use
Maatwebsite\Excel\Concerns\ShouldAutoSize
;
use
Maatwebsite\Excel\Concerns\ShouldAutoSize
;
...
@@ -32,7 +32,7 @@ class WuxiLabPackagesExportModel implements FromArray,WithHeadings, ShouldAutoSi
...
@@ -32,7 +32,7 @@ class WuxiLabPackagesExportModel implements FromArray,WithHeadings, ShouldAutoSi
array_push
(
$exportRows
,[
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
]);
array_push
(
$exportRows
,[
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
]);
foreach
(
$rows
as
$key
=>
$row
){
foreach
(
$rows
as
$key
=>
$row
){
array_push
(
$exportRows
,[
array_push
(
$exportRows
,[
$row
[
'r_code'
],
''
,
$row
[
'p_pack'
]
.
'
/
'
.
$row
[
'p_pack_unit'
],
$row
[
'p_stock'
]
==
0
?
'0'
:
$row
[
'p_stock'
],
'CN-SH'
,
$row
[
'p_price'
],
'0.5'
,
$row
[
'r_code'
],
''
,
$row
[
'p_pack'
]
.
''
.
$row
[
'p_pack_unit'
],
$row
[
'p_stock'
]
==
0
?
'0'
:
$row
[
'p_stock'
],
'CN-SH'
,
$row
[
'p_price'
],
'0.5'
,
'RMB'
,
'CN'
,
$row
[
'p_price'
]
*
0.5
'RMB'
,
'CN'
,
$row
[
'p_price'
]
*
0.5
]);
]);
}
}
...
...
server/app/ImportExport/WuxiLab/Models/WuxiLabProductsExportModel.php
View file @
f477dea9
<?php
<?php
namespace
App\Export\WuxiLab\Models
;
namespace
App\
Import
Export\WuxiLab\Models
;
use
Maatwebsite\Excel\Concerns\FromArray
;
use
Maatwebsite\Excel\Concerns\FromArray
;
use
Maatwebsite\Excel\Concerns\ShouldAutoSize
;
use
Maatwebsite\Excel\Concerns\ShouldAutoSize
;
...
...
server/app/ImportExport/WuxiLab/Models/WuxiLabStocksExportModel.php
View file @
f477dea9
<?php
<?php
namespace
App\Export\WuxiLab\Models
;
namespace
App\
Import
Export\WuxiLab\Models
;
use
Maatwebsite\Excel\Concerns\FromArray
;
use
Maatwebsite\Excel\Concerns\FromArray
;
use
Maatwebsite\Excel\Concerns\ShouldAutoSize
;
use
Maatwebsite\Excel\Concerns\ShouldAutoSize
;
...
...
server/app/ImportExport/WuxiLab/WuxiLabExport.php
View file @
f477dea9
<?php
<?php
namespace
App\Export\WuxiLab
;
namespace
App\
Import
Export\WuxiLab
;
use
App\Export\BaseExport
;
use
App\
Import
Export\BaseExport
;
use
App\Export\WuxiLab\Models\WuxiLabPackagesExportModel
;
use
App\
Import
Export\WuxiLab\Models\WuxiLabPackagesExportModel
;
use
App\Export\WuxiLab\Models\WuxiLabProductsExportModel
;
use
App\
Import
Export\WuxiLab\Models\WuxiLabProductsExportModel
;
use
App\Export\WuxiLab\Models\WuxiLabStocksExportModel
;
use
App\
Import
Export\WuxiLab\Models\WuxiLabStocksExportModel
;
class
WuxiLabExport
extends
BaseExport
class
WuxiLabExport
extends
BaseExport
{
{
...
@@ -21,7 +21,7 @@ class WuxiLabExport extends BaseExport
...
@@ -21,7 +21,7 @@ class WuxiLabExport extends BaseExport
public
function
getSavePath
(
$fileName
)
public
function
getSavePath
(
$fileName
)
{
{
if
(
$this
->
filePath
==
''
){
if
(
$this
->
filePath
==
''
){
$this
->
filePath
=
config
(
'filesystem
.default'
)
.
'/
public/Excel/'
;
$this
->
filePath
=
config
(
'filesystem
s.default.root'
)
.
'
public/Excel/'
;
}
}
return
$this
->
filePath
.
date
(
'Ymd'
,
time
())
.
'/'
.
$fileName
;
return
$this
->
filePath
.
date
(
'Ymd'
,
time
())
.
'/'
.
$fileName
;
}
}
...
@@ -36,18 +36,14 @@ class WuxiLabExport extends BaseExport
...
@@ -36,18 +36,14 @@ class WuxiLabExport extends BaseExport
* @param $saveContent
* @param $saveContent
* @param null $model
* @param null $model
*/
*/
public
function
saveExcel
(
$saveContent
,
$model
=
null
)
public
function
saveExcel
(
$saveContent
,
$model
=
'product'
)
{
{
if
(
$model
==
null
){
if
(
!
is_array
(
$model
)
&&
$model
==
null
){
$model
=
$this
->
defaultExportModel
;
throw
new
\Exception
(
'excel 文档生成错误,无法找到对应生成类型!'
)
;
}
}
if
(
!
is_array
(
$model
)
&&
$model
!=
null
){
$export
=
null
;
$model
=
explode
(
','
,
$model
);
switch
(
$model
){
}
foreach
(
$model
as
$m
){
switch
(
$m
){
case
'product'
:
case
'product'
:
$export
=
new
WuxiLabProductsExportModel
(
$saveContent
[
'rawList'
]);
$export
=
new
WuxiLabProductsExportModel
(
$saveContent
[
'rawList'
]);
break
;
break
;
...
@@ -59,9 +55,11 @@ class WuxiLabExport extends BaseExport
...
@@ -59,9 +55,11 @@ class WuxiLabExport extends BaseExport
break
;
break
;
}
}
$savePath
=
$this
->
getSavePath
(
$savePath
=
$this
->
getSavePath
(
$this
->
getFileName
(
$m
)
$this
->
getFileName
(
$model
)
);
);
$this
->
storeExcel
(
$export
,
$savePath
);
$result
=
$this
->
storeExcel
(
$export
,
$savePath
);
if
(
$result
){
return
$savePath
;
}
}
}
}
}
}
server/app/Jobs/WuxiLabJob.php
View file @
f477dea9
...
@@ -47,6 +47,9 @@ class WuxiLabJob extends Job
...
@@ -47,6 +47,9 @@ class WuxiLabJob extends Job
case
'batchUpdateProduct'
:
case
'batchUpdateProduct'
:
$service
->
batchUpdateProducts
();
$service
->
batchUpdateProducts
();
break
;
break
;
case
'test'
:
$service
->
test
(
$this
->
params
);
break
;
default
:
default
:
}
}
}
}
...
...
server/app/Repositories/Eloquent/RhawnRawRepositoryEloquent.php
View file @
f477dea9
...
@@ -54,6 +54,19 @@ class RhawnRawRepositoryEloquent extends BaseRepository implements RhawnRawRepos
...
@@ -54,6 +54,19 @@ class RhawnRawRepositoryEloquent extends BaseRepository implements RhawnRawRepos
return
$rawList
->
toArray
();
return
$rawList
->
toArray
();
}
}
public
function
getRawProductsThroughtCode
(
$rawCode
)
{
$raw
=
RhawnRaw
::
query
()
->
join
(
'chemicals'
,
'chemicals.c_id'
,
'raw.c_id'
);
if
(
!
is_array
(
$rawCode
)){
$raw
->
where
(
'r_code'
,
$rawCode
);
}
else
{
$raw
->
whereIn
(
'r_code'
,
!
is_array
(
$rawCode
));
}
$rawList
=
$raw
->
get
();
return
$rawList
->
toArray
();
}
public
function
getProductPackage
(
$rawProductIds
)
public
function
getProductPackage
(
$rawProductIds
)
{
{
$packagesList
=
RhawnProducts
::
query
()
$packagesList
=
RhawnProducts
::
query
()
...
...
server/app/Repositories/Eloquent/ThirdApiPlatformRepositoryEloquent.php
View file @
f477dea9
...
@@ -15,31 +15,6 @@ use Prettus\Validator\Contracts\ValidatorInterface;
...
@@ -15,31 +15,6 @@ use Prettus\Validator\Contracts\ValidatorInterface;
*/
*/
class
ThirdApiPlatformRepositoryEloquent
extends
BaseRepository
implements
ThirdApiPlatformRepository
class
ThirdApiPlatformRepositoryEloquent
extends
BaseRepository
implements
ThirdApiPlatformRepository
{
{
protected
$fieldSearchable
=
[
'platform_name'
,
'platform_title'
,
];
/**
* 定义validator的检索规则
* @var \string[][]
*/
public
$rules
=
[
ValidatorInterface
::
RULE_CREATE
=>
[
'platform_name'
=>
'required'
,
'platform_title'
=>
'required'
,
'platform_type'
=>
'required'
,
'platform_token'
=>
'required'
,
'platform_status'
=>
'required'
,
],
ValidatorInterface
::
RULE_UPDATE
=>
[
'platform_name'
=>
'required'
,
'platform_title'
=>
'required'
,
'platform_type'
=>
'required'
,
'platform_token'
=>
'required'
,
'platform_status'
=>
'required'
,
]
];
/**
/**
* Specify Model class name.
* Specify Model class name.
*
*
...
...
server/app/Services/ThirdPlatform/Api/WuxiApiService.php
View file @
f477dea9
This diff is collapsed.
Click to expand it.
server/app/Services/ThirdPlatform/Api/ZhenkhApiService.php
View file @
f477dea9
...
@@ -362,7 +362,7 @@ class ZhenkhApiService extends PlatformAbstractService
...
@@ -362,7 +362,7 @@ class ZhenkhApiService extends PlatformAbstractService
protected
function
requestError
(
$response
)
protected
function
requestError
(
$response
)
{
{
SimpleLogs
::
writeLog
(
$response
->
getMessage
(),
'api error'
,
'error'
);
SimpleLogs
::
writeLog
(
$response
->
getMessage
(),
'
Zhenkh
api error'
,
'error'
);
throw
$response
;
throw
$response
;
}
}
...
...
server/app/Services/ThirdPlatform/PlatformAbstractService.php
View file @
f477dea9
...
@@ -112,6 +112,6 @@ abstract class PlatformAbstractService
...
@@ -112,6 +112,6 @@ abstract class PlatformAbstractService
public
function
removePlatformDataEntries
(
$dataKey
)
public
function
removePlatformDataEntries
(
$dataKey
)
{
{
return
$this
->
dataEntriesService
->
removeEntriesValues
(
$dataKey
);
return
$this
->
dataEntriesService
->
removeEntriesValues
(
$
this
->
getPlatformInfo
(
'id'
),
$
dataKey
);
}
}
}
}
server/app/Services/WuxiLabService.php
View file @
f477dea9
This diff is collapsed.
Click to expand it.
server/app/Support/Traits/HttpClientHelpers.php
View file @
f477dea9
...
@@ -12,7 +12,7 @@ trait HttpClientHelpers
...
@@ -12,7 +12,7 @@ trait HttpClientHelpers
{
{
$options
=
[];
$options
=
[];
$options
[
'headers'
][
'User-Agent'
]
=
$this
->
randomUserAgent
()
;
$options
[
'headers'
][
'User-Agent'
]
=
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.71 Safari/537.1 LBBROWSER'
;
$options
[
'debug'
]
=
env
(
'API_DEBUG'
);
$options
[
'debug'
]
=
env
(
'API_DEBUG'
);
return
$options
;
return
$options
;
...
@@ -44,6 +44,39 @@ trait HttpClientHelpers
...
@@ -44,6 +44,39 @@ trait HttpClientHelpers
return
$this
->
clientRequest
(
'post'
,
$uri
,
$options
);
return
$this
->
clientRequest
(
'post'
,
$uri
,
$options
);
}
}
public
function
getMultipartPostClient
(
$uri
,
$paramsBody
=
[],
$auth
=
null
,
$header
=
null
)
{
$options
=
[
'headers'
=>
[]
];
$paramsOptions
=
[];
foreach
(
$paramsBody
as
$key
=>
$params
){
if
(
$key
!=
'file'
){
array_push
(
$paramsOptions
,[
'name'
=>
$key
,
'contents'
=>
$params
]);
}
else
{
array_push
(
$paramsOptions
,[
'name'
=>
'file'
,
'filename'
=>
$params
[
'name'
],
'contents'
=>
$params
[
'contents'
]
]);
}
}
$options
[
'multipart'
]
=
$paramsOptions
;
if
(
$auth
&&
is_array
(
$auth
)){
$options
[
'auth'
]
=
$auth
;
}
if
(
!
is_null
(
$header
)){
$options
[
'headers'
]
=
array_merge
(
$options
[
'headers'
],
$header
);
}
return
$this
->
clientRequest
(
'post'
,
$uri
,
$options
);
}
protected
function
clientRequest
(
$requestType
,
$uri
,
$options
)
protected
function
clientRequest
(
$requestType
,
$uri
,
$options
)
{
{
$requestOptions
=
$this
->
getDefaultOptions
();
$requestOptions
=
$this
->
getDefaultOptions
();
...
...
server/database/seeds/local/ThridApiPlatformSeeder.php
View file @
f477dea9
...
@@ -3,14 +3,13 @@
...
@@ -3,14 +3,13 @@
use
Illuminate\Database\Seeder
;
use
Illuminate\Database\Seeder
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Spatie\Permission\Models\Role
;
class
ThridApiPlatformSeeder
extends
Seeder
class
ThridApiPlatformSeeder
extends
Seeder
{
{
use
\App\Support\Traits\Helpers
;
use
\App\Support\Traits\Helpers
;
protected
$thirdapiplatform
=
[
protected
$thirdapiplatform
=
[
/*
[
[
'platform_name'
=>
'integle'
,
'platform_name'
=>
'integle'
,
'platform_title'
=>
'integle'
,
'platform_title'
=>
'integle'
,
'platform_url'
=>
'http://suppliers.integle.com'
,
'platform_url'
=>
'http://suppliers.integle.com'
,
...
@@ -31,8 +30,8 @@ class ThridApiPlatformSeeder extends Seeder
...
@@ -31,8 +30,8 @@ class ThridApiPlatformSeeder extends Seeder
'platform_type'
=>
'third'
,
'platform_type'
=>
'third'
,
'platform_status'
=>
'1'
,
'platform_status'
=>
'1'
,
'platform_token'
=>
''
,
'platform_token'
=>
''
,
],
*/
],
/*
[
[
'platform_name'
=>
'bide'
,
'platform_name'
=>
'bide'
,
'platform_title'
=>
'bide'
,
'platform_title'
=>
'bide'
,
'platform_url'
=>
'http://220.248.71.110:9000'
,
'platform_url'
=>
'http://220.248.71.110:9000'
,
...
@@ -42,8 +41,8 @@ class ThridApiPlatformSeeder extends Seeder
...
@@ -42,8 +41,8 @@ class ThridApiPlatformSeeder extends Seeder
'platform_type'
=>
'third'
,
'platform_type'
=>
'third'
,
'platform_status'
=>
'1'
,
'platform_status'
=>
'1'
,
'platform_token'
=>
''
,
'platform_token'
=>
''
,
],
*/
],
/*
[
[
'platform_name'
=>
'bjs'
,
'platform_name'
=>
'bjs'
,
'platform_title'
=>
'bjs'
,
'platform_title'
=>
'bjs'
,
'platform_url'
=>
'http://220.248.71.110:9000'
,
'platform_url'
=>
'http://220.248.71.110:9000'
,
...
@@ -53,7 +52,7 @@ class ThridApiPlatformSeeder extends Seeder
...
@@ -53,7 +52,7 @@ class ThridApiPlatformSeeder extends Seeder
'platform_type'
=>
'third'
,
'platform_type'
=>
'third'
,
'platform_status'
=>
'1'
,
'platform_status'
=>
'1'
,
'platform_token'
=>
''
,
'platform_token'
=>
''
,
],
*/
],
[
[
'platform_name'
=>
'zkh'
,
'platform_name'
=>
'zkh'
,
'platform_title'
=>
'震坤行'
,
'platform_title'
=>
'震坤行'
,
...
@@ -89,7 +88,10 @@ class ThridApiPlatformSeeder extends Seeder
...
@@ -89,7 +88,10 @@ class ThridApiPlatformSeeder extends Seeder
'username'
=>
'790087059@qq.com'
,
'username'
=>
'790087059@qq.com'
,
'password'
=>
'YXH1992xb'
,
'password'
=>
'YXH1992xb'
,
'auth'
=>
'dGVzdDEyMzpwYXNzNDU2'
,
'auth'
=>
'dGVzdDEyMzpwYXNzNDU2'
,
'batchNums'
=>
'500'
'batchNums'
=>
'500'
,
'companyId'
=>
'6789'
,
'adminUrl'
=>
'https://www.uploadcatalog.com'
,
'excelCreateLimit'
=>
100
]);
]);
break
;
break
;
case
"bide"
:
case
"bide"
:
...
@@ -121,7 +123,7 @@ class ThridApiPlatformSeeder extends Seeder
...
@@ -121,7 +123,7 @@ class ThridApiPlatformSeeder extends Seeder
$platform
[
'created_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$platform
[
'created_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$platform
[
'updated_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$platform
[
'updated_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$thirdApiPlatformRepo
->
updateOrCreate
(
$platform
);
$thirdApiPlatformRepo
->
updateOrCreate
(
[
'platform_name'
=>
$platform
[
'platform_name'
]],
$platform
);
}
}
DB
::
commit
();
DB
::
commit
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment