Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0d23241f
authored
Mar 14, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
队列性能问题
parent
df1f8139
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
app/Console/Commands/SyncAllSupplierToErp.php
app/Http/Services/SyncSupplierService.php
app/Console/Commands/SyncAllSupplierToErp.php
View file @
0d23241f
...
...
@@ -9,6 +9,7 @@ use App\Http\Services\SyncSupplierService;
use
App\Model\SupplierChannelModel
;
use
Illuminate\Console\Command
;
use
Illuminate\Foundation\Inspiring
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
//设置供应商是否需要跟进
class
SyncAllSupplierToErp
extends
Command
...
...
@@ -35,10 +36,14 @@ class SyncAllSupplierToErp extends Command
public
function
handle
()
{
$supplierIds
=
SupplierChannelModel
::
where
(
'is_type'
,
0
)
->
pluck
(
'supplier_id'
)
->
toArray
();
$conn
=
new
AMQPStreamConnection
(
config
(
'database.connections.rabbitmq.host'
),
config
(
'database.connections.rabbitmq.port'
),
config
(
'database.connections.rabbitmq.login'
),
config
(
'database.connections.rabbitmq.password'
));
foreach
(
$supplierIds
as
$supplierId
)
{
usleep
(
100000
);
dump
(
$supplierId
);
(
new
SyncSupplierService
())
->
syncSupplierToErp
(
$supplierId
);
(
new
SyncSupplierService
())
->
syncSupplierToErp
(
$supplierId
,
$conn
);
}
}
}
app/Http/Services/SyncSupplierService.php
View file @
0d23241f
...
...
@@ -22,7 +22,7 @@ use PhpAmqpLib\Message\AMQPMessage;
class
SyncSupplierService
{
//同步供应商到erp
public
function
syncSupplierToErp
(
$supplierId
)
public
function
syncSupplierToErp
(
$supplierId
,
$conn
=
null
)
{
//先去获取供应商的信息
$supplierModel
=
new
SupplierChannelModel
();
...
...
@@ -98,10 +98,15 @@ class SyncSupplierService
}
//dd($message);
$conn
=
new
AMQPStreamConnection
(
config
(
'database.connections.rabbitmq.host'
),
config
(
'database.connections.rabbitmq.port'
),
config
(
'database.connections.rabbitmq.login'
),
config
(
'database.connections.rabbitmq.password'
));
if
(
$conn
)
{
}
else
{
$conn
=
new
AMQPStreamConnection
(
config
(
'database.connections.rabbitmq.host'
),
config
(
'database.connections.rabbitmq.port'
),
config
(
'database.connections.rabbitmq.login'
),
config
(
'database.connections.rabbitmq.password'
));
}
$channel
=
$conn
->
channel
();
$channel
->
queue_declare
(
'supplier_sync'
,
false
,
true
,
false
,
false
);
...
...
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