Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_scm_wms_sync
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
30b2e198
authored
May 06, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
导入初始数据修改成异步
parent
82d7e9c2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
15 deletions
cmd/source/customer/customer.go
cmd/source/goods/goods.go
cmd/source/main.go
cmd/source/supplier/supplier.go
cmd/source/customer/customer.go
View file @
30b2e198
...
...
@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/model"
"sync"
)
var
Exchange
rabbitmq
.
QueueExchange
...
...
@@ -22,7 +23,8 @@ func init() {
configs
.
RABBITMQDSN
,
}
}
func
Import
()
{
func
Import
(
wg
*
sync
.
WaitGroup
)
{
defer
wg
.
Done
()
var
(
excelFileName
string
xlFile
*
xlsx
.
File
...
...
@@ -49,8 +51,6 @@ func Import() {
//去数据库检测是否已经同步过了
if
exist
:=
logic
.
CheckCustomerExist
(
customer
.
ErpId
);
exist
{
i
++
fmt
.
Println
(
"已存在,跳过"
)
fmt
.
Println
(
i
)
continue
}
message
:=
make
(
map
[
string
]
interface
{})
...
...
@@ -67,8 +67,8 @@ func Import() {
fmt
.
Println
(
err
)
}
body
:=
string
(
data
)
fmt
.
Println
(
message
)
rabbitmq
.
Send
(
Exchange
,
body
)
}
}
fmt
.
Println
(
"已完成客户导入"
)
}
cmd/source/goods/goods.go
View file @
30b2e198
...
...
@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/model"
"sync"
)
var
Exchange
rabbitmq
.
QueueExchange
...
...
@@ -24,7 +25,8 @@ func init() {
}
//导入委托方的信息(excel导入)
func
Import
()
{
func
Import
(
wg
*
sync
.
WaitGroup
)
{
defer
wg
.
Done
()
var
(
excelFileName
string
xlFile
*
xlsx
.
File
...
...
@@ -71,4 +73,5 @@ func Import() {
rabbitmq
.
Send
(
Exchange
,
body
)
}
}
fmt
.
Println
(
"已完成物料导入"
)
}
cmd/source/main.go
View file @
30b2e198
package
main
import
"scm_server/cmd/source/goods"
import
(
"scm_server/cmd/source/customer"
"scm_server/cmd/source/goods"
"scm_server/cmd/source/supplier"
"sync"
)
func
main
()
{
//forever := make(chan bool)
//go supplier.Import()
//supplier.Import()
//<-forever
//customer.Import()
goods
.
Import
()
var
wg
sync
.
WaitGroup
wg
.
Add
(
3
)
go
supplier
.
Import
(
&
wg
)
go
customer
.
Import
(
&
wg
)
go
goods
.
Import
(
&
wg
)
wg
.
Wait
()
}
cmd/source/supplier/supplier.go
View file @
30b2e198
...
...
@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/model"
"sync"
)
var
Exchange
rabbitmq
.
QueueExchange
...
...
@@ -24,7 +25,8 @@ func init() {
}
//导入委托方的信息(excel导入)
func
Import
()
{
func
Import
(
wg
*
sync
.
WaitGroup
)
{
defer
wg
.
Done
()
var
(
excelFileName
string
xlFile
*
xlsx
.
File
...
...
@@ -61,9 +63,9 @@ func Import() {
fmt
.
Println
(
err
)
}
body
:=
string
(
data
)
fmt
.
Println
(
message
)
rabbitmq
.
Send
(
Exchange
,
body
)
}
}
}
fmt
.
Println
(
"已完成供应商导入"
)
}
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