Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wang
/
go_upload_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
14ecfe48
authored
Mar 23, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
忽略文件
parent
b325966d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
8 deletions
.gitignore
app/dao/supplier_sync.go
app/queue/supplier.go
config/dev/db.toml
.gitignore
View file @
14ecfe48
/logs
/logs
/.idea
/config/*.toml
app/dao/supplier_sync.go
View file @
14ecfe48
...
@@ -13,32 +13,46 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err
...
@@ -13,32 +13,46 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err
supplierMapping
:=
new
(
model
.
SupplierMergeMapping
)
supplierMapping
:=
new
(
model
.
SupplierMergeMapping
)
//先去根据供应商内部编码找出对应的supplierId
//先去根据供应商内部编码找出对应的supplierId
_
,
err
=
Dao
.
GetDb
(
"supplier"
)
.
Table
(
"lie_supplier_channel"
)
.
Where
(
"supplier_code = ?"
,
supplierCode
)
.
Get
(
supplier
)
_
,
err
=
Dao
.
GetDb
(
"supplier"
)
.
Table
(
"lie_supplier_channel"
)
.
Where
(
"supplier_code = ?"
,
supplierCode
)
.
Get
(
supplier
)
//不存在
直接跳过
//不存在
插入一条数据
if
supplier
.
SupplierId
==
0
{
if
supplier
.
SupplierId
==
0
{
return
err
return
err
}
}
//再去同步表操作对应的数据
//再去同步表操作对应的数据
supplierId
:=
supplier
.
SupplierId
supplierId
:=
supplier
.
SupplierId
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_sync"
)
.
Where
(
"supplier_id = ?"
,
supplierId
)
.
Where
(
"erp_sync_status = ?"
,
0
)
.
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_sync"
)
.
Where
(
"supplier_id = ?"
,
supplierId
)
.
Get
(
supplierSync
)
Get
(
supplierSync
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
//还要去写映射表lie_supplier_merger_mapping
//还要去写映射表lie_supplier_merger_mapping
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_merger_mapping"
)
.
Where
(
"old_supplier_code = ?"
,
supplierCode
)
.
Get
(
supplierMapping
)
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_merger_mapping"
)
.
Where
(
"old_supplier_code = ?"
,
erpSupplierCode
)
.
Where
(
"source = ?"
,
2
)
.
Get
(
supplierMapping
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
//存在更新,不存在就插入
if
supplierSync
.
SupplierId
==
0
{
supplierSync
.
ErpSyncStatus
=
1
supplierSync
.
SupplierId
=
supplierId
supplierSync
.
ErpSupplierCode
=
erpSupplierCode
supplierSync
.
ErpSupplierName
=
erpSupplierName
supplierSync
.
AddTime
=
int
(
time
.
Now
()
.
Unix
())
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_sync"
)
.
Insert
(
supplierSync
)
if
err
!=
nil
{
return
err
}
}
else
{
supplierSync
.
ErpSyncStatus
=
1
supplierSync
.
ErpSyncStatus
=
1
supplierSync
.
SupplierId
=
supplierId
supplierSync
.
SupplierId
=
supplierId
supplierSync
.
ErpSupplierCode
=
erpSupplierCode
supplierSync
.
ErpSupplierCode
=
erpSupplierCode
supplierSync
.
ErpSupplierName
=
erpSupplierName
supplierSync
.
ErpSupplierName
=
erpSupplierName
//存在更新,不存在就插入
supplierSync
.
UpdateTime
=
int
(
time
.
Now
()
.
Unix
())
supplierSync
.
UpdateTime
=
int
(
time
.
Now
()
.
Unix
())
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_sync"
)
.
Where
(
"supplier_id = ?"
,
supplierId
)
.
Update
(
supplierSync
)
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_sync"
)
.
Where
(
"supplier_id = ?"
,
supplierId
)
.
Update
(
supplierSync
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
if
supplierMapping
.
SupplierId
==
0
{
if
supplierMapping
.
SupplierId
==
0
{
supplierMapping
.
OldSupplierCode
=
erpSupplierCode
supplierMapping
.
OldSupplierCode
=
erpSupplierCode
...
@@ -46,7 +60,7 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err
...
@@ -46,7 +60,7 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err
supplierMapping
.
SupplierId
=
supplier
.
SupplierId
supplierMapping
.
SupplierId
=
supplier
.
SupplierId
supplierMapping
.
SupplierCode
=
supplier
.
SupplierCode
supplierMapping
.
SupplierCode
=
supplier
.
SupplierCode
supplierMapping
.
SupplierName
=
supplier
.
SupplierName
supplierMapping
.
SupplierName
=
supplier
.
SupplierName
supplierMapping
.
Source
=
1
supplierMapping
.
Source
=
2
supplierMapping
.
CreateTime
=
int
(
time
.
Now
()
.
Unix
())
supplierMapping
.
CreateTime
=
int
(
time
.
Now
()
.
Unix
())
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_merger_mapping"
)
.
Insert
(
supplierMapping
)
_
,
err
=
supplierDao
.
Table
(
"lie_supplier_merger_mapping"
)
.
Insert
(
supplierMapping
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
app/queue/supplier.go
View file @
14ecfe48
...
@@ -11,6 +11,8 @@ import (
...
@@ -11,6 +11,8 @@ import (
type
RecvPro
struct
{
type
RecvPro
struct
{
}
}
var
number
int
func
init
()
{
func
init
()
{
//queueExchange := rabbitmq.QueueExchange{
//queueExchange := rabbitmq.QueueExchange{
// "supplier_erp",
// "supplier_erp",
...
@@ -21,17 +23,20 @@ func init() {
...
@@ -21,17 +23,20 @@ func init() {
//}
//}
//
//
//str := `{"supplierNumber":"C0000102","PTID":"L0000002","supplierID":"LxYAAAG0CQA3xn38","supplierName":"TestName"}`
//str := `{"supplierNumber":"C0000102","PTID":"L0000002","supplierID":"LxYAAAG0CQA3xn38","supplierName":"TestName"}`
//str := `{"supplierNumber":"C0000102","PTID":"12324","supplierID":"LxYAAAG0CQA3xn38"}`
//
//
str := `{"supplierNumber":"C0000102","PTID":"12324","supplierID":"LxYAAAG0CQA3xn38"}`
//rabbitmq.Send(queueExchange, str)
//rabbitmq.Send(queueExchange, str)
}
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
number
++
message
:=
string
(
dataByte
)
message
:=
string
(
dataByte
)
supplierCode
:=
gjson
.
Get
(
message
,
"PTID"
)
.
String
()
supplierCode
:=
gjson
.
Get
(
message
,
"PTID"
)
.
String
()
erpSupplierCode
:=
gjson
.
Get
(
message
,
"supplierNumber"
)
.
String
()
erpSupplierCode
:=
gjson
.
Get
(
message
,
"supplierNumber"
)
.
String
()
erpSupplierName
:=
gjson
.
Get
(
message
,
"supplierName"
)
.
String
()
erpSupplierName
:=
gjson
.
Get
(
message
,
"supplierName"
)
.
String
()
fmt
.
Println
(
supplierCode
,
erpSupplierCode
)
err
=
service
.
AddSupplierSync
(
supplierCode
,
erpSupplierCode
,
erpSupplierName
)
err
=
service
.
AddSupplierSync
(
supplierCode
,
erpSupplierCode
,
erpSupplierName
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
return
nil
return
nil
}
}
...
...
config/dev/db.toml
View file @
14ecfe48
[xorm]
[xorm]
ShowSQL
=
tru
e
ShowSQL
=
fals
e
[micro]
[micro]
data_source_name
=
"micro_service:lie_micro_service#zsyM@tcp(192.168.2.232:3306)/lie_micro_service?charset=utf8&parseTime=true&loc=Asia%2FChongqing"
data_source_name
=
"micro_service:lie_micro_service#zsyM@tcp(192.168.2.232:3306)/lie_micro_service?charset=utf8&parseTime=true&loc=Asia%2FChongqing"
...
...
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