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
bb758afb
Commit
bb758afb
authored
Aug 12, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openapi
parent
f5ad2f39
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
19 deletions
+98
-19
server/app/Jobs/WuxiLabJob.php
server/app/Jobs/WuxiLabJob.php
+6
-0
server/app/Repositories/Eloquent/RhawnRawRepositoryEloquent.php
.../app/Repositories/Eloquent/RhawnRawRepositoryEloquent.php
+10
-0
server/app/Services/RhawnChemicalsService.php
server/app/Services/RhawnChemicalsService.php
+5
-0
server/app/Services/ThirdPlatform/Api/WuxiApiService.php
server/app/Services/ThirdPlatform/Api/WuxiApiService.php
+42
-4
server/app/Services/WuxiLabService.php
server/app/Services/WuxiLabService.php
+28
-9
server/app/Support/Traits/HttpClientHelpers.php
server/app/Support/Traits/HttpClientHelpers.php
+7
-6
No files found.
server/app/Jobs/WuxiLabJob.php
View file @
bb758afb
...
...
@@ -35,6 +35,12 @@ class WuxiLabJob extends Job
}
$service
->
initCreateProductsToExcel
(
$params
[
'limit'
]);
break
;
case
'batchUpdatePackages'
:
if
(
!
isset
(
$params
)
||
$params
==
0
){
$params
[
'limit'
]
=
1000
;
}
$service
->
batchUpdatePackagesInfo
();
break
;
case
'batchUpdateProduct'
:
$service
->
batchUpdateProducts
();
break
;
...
...
server/app/Repositories/Eloquent/RhawnRawRepositoryEloquent.php
View file @
bb758afb
...
...
@@ -69,4 +69,14 @@ class RhawnRawRepositoryEloquent extends BaseRepository implements RhawnRawRepos
return
$packagesList
->
toArray
();
}
public
function
getProductPackagesThroughGroupByPackUnit
()
{
$packages
=
RhawnProducts
::
query
()
->
select
(
'p_pack'
,
'p_pack_unit'
)
->
groupBy
(
'p_pack'
,
'p_pack_unit'
)
->
get
();
return
$packages
->
toArray
();
}
}
server/app/Services/RhawnChemicalsService.php
View file @
bb758afb
...
...
@@ -39,4 +39,9 @@ class RhawnChemicalsService
$packageList
=
$this
->
rhawnRawRepository
->
getProductPackage
(
$rawIds
);
return
$packageList
;
}
public
function
getProductPackagesThroughGroupByPackUnit
()
{
return
$this
->
rhawnRawRepository
->
getProductPackagesThroughGroupByPackUnit
();
}
}
server/app/Services/ThirdPlatform/Api/WuxiApiService.php
View file @
bb758afb
...
...
@@ -32,19 +32,57 @@ class WuxiApiService
* @param $product
* @return bool
*/
public
function
pushBatchUpdateProduct
(
$product
){
public
function
pushBatchUpdateProduct
(
$product
)
{
$this
->
__checkPlatform
();
try
{
$params
=
[];
$params
[
'chemicalProducts'
]
=
$this
->
mergeApiMetaData
(
$product
);
$response
=
$this
->
getPostClient
(
'https://api.uploadcatalog.com/api/v1/update'
,
$params
,
[
$this
->
platformInfo
[
'platform_params'
][
'username'
],
$this
->
platformInfo
[
'platform_params'
][
'password'
]
]);
return
$this
->
apiResponse
(
$response
);
}
catch
(
\Exception
$e
){
return
$this
->
requestError
(
$e
);
}
}
public
function
backgroundLogin
()
{
$this
->
__checkPlatform
();
$response
=
$this
->
getPostClient
(
'https://www.uploadcatalog.com/json_login'
,[
'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'
]);
return
json_decode
(
$response
,
true
)[
'token'
];
}
private
function
__checkPlatform
(){
if
(
!
$this
->
platformInfo
){
throw
new
\LogicException
(
'第三方平台信息无法获取!'
,
500
);
}
}
public
function
pushBatchUpdatePackages
(
$packages
,
$token
)
{
$this
->
__checkPlatform
();
try
{
$params
=
[];
$params
[
'chemicalProducts'
]
=
$this
->
mergeApiMetaData
(
$product
);
$params
[
'company_id'
]
=
'6789'
;
$params
[
'product_type'
]
=
'CHAMICAL'
;
$response
=
$this
->
getPostClient
(
'https://api.uploadcatalog.com/api/v1/update'
,
$params
,
[
$this
->
platformInfo
[
'platform_params'
][
'username'
],
$this
->
platformInfo
[
'platform_params'
][
'password'
]
$params
=
array_merge
(
$params
,
$packages
);
$cookie
=
'org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE=zh_CN;Auth-Token='
.
$token
.
';'
;
$response
=
$this
->
getPostClient
(
'https://www.uploadcatalog.com/package/specification/save'
,
$params
,
null
,
[
'cookie'
=>
$cookie
]);
return
$this
->
apiResponse
(
$response
);
...
...
server/app/Services/WuxiLabService.php
View file @
bb758afb
...
...
@@ -14,6 +14,7 @@ namespace App\Services;
use
App\Export\BaseExport
;
use
App\Export\WuxiLab\WuxiLabExport
;
use
App\Repositories\Contracts\ThirdApiPlatformRepository
;
use
App\Repositories\Models\RhawnProducts
;
use
App\Services\Kafka\KafkaService
;
use
App\Services\ThirdPlatform\Api\WuxiApiService
;
use
App\Services\ThirdPlatform\PlatformAbstractService
;
...
...
@@ -58,15 +59,6 @@ class WuxiLabService extends PlatformAbstractService
}
}
if
(
!
empty
(
$rawList
)){
/*if(
$this->batchUpdateApi(
['rawList' => $rawList,'packageList' => $newPackages]
)
){
//$page = intval($count / $limit) * $limit;
$page ++;
usleep(3000);
}*/
app
(
KafkaService
::
class
)
->
produerSend
(
[
'params'
=>
[
'rawList'
=>
$rawList
,
'packageList'
=>
$newPackages
],
...
...
@@ -81,6 +73,33 @@ class WuxiLabService extends PlatformAbstractService
}
}
public
function
batchUpdatePackagesInfo
()
{
$service
=
app
(
WuxiApiService
::
class
);
$token
=
$service
->
backgroundLogin
();
$wuxiLabPackage
=
[
'bottle'
,
'box'
,
'bp'
,
'case'
,
'ea'
,
'g'
,
'gal'
,
'hole'
,
'kg'
,
'kit'
,
'l'
,
'm'
,
'm2'
,
'mg'
,
'ml'
,
'mm'
,
'mmol'
,
'mu'
,
'ng'
,
'nmole'
,
'od'
,
'package'
,
'pair'
,
'piece'
,
'pmole'
,
'RL'
,
'sets'
,
'test'
,
'unit'
,
'vial'
,
'xa'
,
'µci'
,
'µg'
,
'µl'
,
'µmol'
];
$rhawnChemicalsService
=
app
(
RhawnChemicalsService
::
class
);
$packagesUnit
=
$rhawnChemicalsService
->
getProductPackagesThroughGroupByPackUnit
();
foreach
(
$packagesUnit
as
$unit
){
if
(
in_array
(
$unit
[
'p_pack_unit'
],
$wuxiLabPackage
)){
$service
->
pushBatchUpdatePackages
([
'unit_quantity'
=>
$unit
[
'p_pack'
],
'unit_type'
=>
$unit
[
'p_pack_unit'
],
'unit_description'
=>
$unit
[
'p_pack'
]
.
$unit
[
'p_pack_unit'
]
],
$token
);
}
}
$token
=
$service
->
pushBatchUpdatePackages
([
'unit_quantity'
=>
'10'
,
'unit_type'
=>
'g'
,
'unit_description'
=>
'g'
],
$token
);
}
public
function
batchUpdateApi
(
$updateData
)
{
$result
=
app
(
WuxiApiService
::
class
)
->
pushBatchUpdateProduct
(
$updateData
);
...
...
server/app/Support/Traits/HttpClientHelpers.php
View file @
bb758afb
...
...
@@ -13,14 +13,9 @@ trait HttpClientHelpers
$client
=
app
(
\GuzzleHttp\Client
::
class
);
$options
=
[];
if
(
!
is_null
(
$header
)){
$options
[
'headers'
]
=
$header
;
}
if
(
$json
)
{
$options
[
'headers'
]
=
[
'Content-type'
=>
'application/json'
,
"Accept"
=>
"application/json"
'Content-Type'
=>
'application/json;charset=UTF-8'
,
];
$options
[
'json'
]
=
$paramsBody
;
...
...
@@ -33,6 +28,12 @@ trait HttpClientHelpers
$options
[
'auth'
]
=
$auth
;
}
$options
[
'headers'
][
'User-Agent'
]
=
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36'
;
if
(
!
is_null
(
$header
)){
$options
[
'headers'
]
=
array_merge
(
$options
[
'headers'
],
$header
);
}
$options
[
'debug'
]
=
env
(
'API_DEBUG'
);
$response
=
$client
->
request
(
'post'
,
$uri
,
$options
);
...
...
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