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
d62fbed9
authored
Apr 23, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善普通的增删改
parent
c034f2e2
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
86 additions
and
47 deletions
cmd/main.go
cmd/queue/sync_goods/main.go
cmd/queue/sync_goods/product.go
cmd/queue/sync_status/main.go
cmd/queue/sync_status/product.go → cmd/queue/sync_status/product/product_status_queue.go
cmd/queue/sync_supplier/main.go
cmd/queue/sync_supplier/product.go
cmd/source/main.go
internal/logic/goods.go
internal/logic/supplier.go
internal/logic/sync_status_log.go
internal/model/goods.go
internal/model/supplier.go
cmd/main.go
View file @
d62fbed9
...
@@ -8,28 +8,29 @@ import (
...
@@ -8,28 +8,29 @@ import (
func
main
()
{
func
main
()
{
//
soap, err := gosoap.SoapClient("http://192.168.2.253:6888/ormrpc/services/EASLogin?wsdl")
soap
,
err
:=
gosoap
.
SoapClient
(
"http://192.168.2.253:6888/ormrpc/services/EASLogin?wsdl"
)
soap
,
err
:=
gosoap
.
SoapClient
(
"http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl"
)
//
soap, err := gosoap.SoapClient("http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl")
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"SoapClient error: %s"
,
err
)
log
.
Fatalf
(
"SoapClient error: %s"
,
err
)
}
}
//(userName, password, slnName, dcName, language, dbType, authPattern)
//(userName, password, slnName, dcName, language, dbType, authPattern)
//("WBYH", "123456", "eas", "demo", "L2", 1, "BaseDB")
//("WBYH", "123456", "eas", "demo", "L2", 1, "BaseDB")
//params := gosoap.Params{
params
:=
gosoap
.
Params
{
// "userName": "WBYH",
"userName"
:
"WBYH"
,
// "password": "123456",
"password"
:
"123456"
,
// "slnName": "eas",
"slnName"
:
"eas"
,
// "dcName": "demo",
"dcName"
:
"demo"
,
// "language": "L2",
"language"
:
"L2"
,
// "dbType": 1,
"dbType"
:
1
,
// "authPattern": "BaseDB",
"authPattern"
:
"BaseDB"
,
//}
params
:=
gosoap
.
Params
{
"json"
:
`{"FType":"material", "FID":"ET9WHFzYagYZf0="}`
,
}
}
//params:=gosoap.Params{
// "json":`{"FType":"material", "FID":"ET9WHFzYagYZf0="}`,
//}
err
=
soap
.
Call
(
"synRewriteErpBaseDataStatus"
,
params
)
//err = soap.Call("synRewriteErpBaseDataStatus", params)
err
=
soap
.
Call
(
"login"
,
params
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"Call error: %s"
,
err
)
log
.
Fatalf
(
"Call error: %s"
,
err
)
}
}
...
...
cmd/queue/sync_goods/main.go
View file @
d62fbed9
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/go-kratos/kratos/pkg/log"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product"
"scm_server/configs"
"scm_server/configs"
"scm_server/internal/common"
"scm_server/internal/common"
"scm_server/internal/logic"
"scm_server/internal/logic"
...
@@ -68,9 +69,10 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -68,9 +69,10 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
}
}
case
"delete"
:
case
"delete"
:
operateType
=
"delete"
operateType
=
"delete"
goods
.
Status
=
0
if
logic
.
CheckGoodsExist
(
goods
.
ErpId
)
{
if
logic
.
CheckGoodsExist
(
goods
.
ErpId
)
{
//如果存在,才进行删除
//如果存在,才进行删除
if
err
=
logic
.
DeleteGoods
(
goods
.
ErpId
);
err
!=
nil
{
if
err
=
logic
.
DeleteGoods
(
goods
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
}
else
{
}
else
{
...
@@ -85,7 +87,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -85,7 +87,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
if
err
=
SyncGoodsData
(
operateType
,
goods
);
err
!=
nil
{
if
err
=
SyncGoodsData
(
operateType
,
goods
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
fmt
.
Println
(
"同步成功"
)
fmt
.
Println
(
"同步成功,开始发送金蝶状态同步"
)
product
.
SyncErpStatus
(
"goods"
,
goods
.
ErpId
)
return
nil
return
nil
ERR
:
ERR
:
//不存在的erp_id不去操作对应的数据库
//不存在的erp_id不去操作对应的数据库
...
@@ -140,7 +143,7 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) {
...
@@ -140,7 +143,7 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) {
}
else
if
operate
==
"insert"
{
}
else
if
operate
==
"insert"
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiInsertGoodsInfo"
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiInsertGoodsInfo"
}
else
{
}
else
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
DeleteGoodsInfo
"
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
UpdateGoodsStatus
"
}
}
req
.
Debug
=
false
req
.
Debug
=
false
if
operate
==
"update"
||
operate
==
"insert"
{
if
operate
==
"update"
||
operate
==
"insert"
{
...
@@ -159,7 +162,6 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) {
...
@@ -159,7 +162,6 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) {
return
return
}
}
}
else
{
}
else
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiUpdateGoodsStatus"
//删除,软删除
//删除,软删除
param
:=
req
.
Param
{
param
:=
req
.
Param
{
"status"
:
0
,
"status"
:
0
,
...
...
cmd/queue/sync_goods/product.go
View file @
d62fbed9
...
@@ -9,12 +9,12 @@ import (
...
@@ -9,12 +9,12 @@ import (
func
main
()
{
func
main
()
{
message
:=
make
(
map
[
string
]
interface
{})
message
:=
make
(
map
[
string
]
interface
{})
message
=
map
[
string
]
interface
{}{
message
=
map
[
string
]
interface
{}{
"type"
:
"
sav
e"
,
"type"
:
"
delet
e"
,
"data"
:
map
[
string
]
string
{
"data"
:
map
[
string
]
string
{
"FID"
:
"Z8eVSzSLRXKa7ET9WHFzYagYZf0171="
,
"FID"
:
"Z8eVSzSLRXKa7ET9WHFzYagYZf017
2
1="
,
"FGoods"
:
"WT0050333"
,
"FGoods"
:
"WT0050333"
,
"FBrand"
:
"深圳市鼎驰达电子有限公司"
,
"FBrand"
:
"深圳市鼎驰达电子有限公司"
,
"FModel"
:
""
,
"FModel"
:
"
XXX
"
,
},
},
}
}
data
,
err
:=
json
.
Marshal
(
message
)
data
,
err
:=
json
.
Marshal
(
message
)
...
...
cmd/queue/sync_status/main.go
View file @
d62fbed9
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"fmt"
"fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"scm_server/internal/logic"
)
)
type
RecvPro
struct
{
type
RecvPro
struct
{
...
@@ -21,6 +22,7 @@ func init() {
...
@@ -21,6 +22,7 @@ func init() {
}
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
fmt
.
Println
(
string
(
dataByte
))
var
(
var
(
err
error
err
error
message
QueueStatus
message
QueueStatus
...
@@ -30,10 +32,14 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -30,10 +32,14 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
goto
ERR
goto
ERR
}
}
//得到message以后,去请求金蝶的接口
//得到message以后,去请求金蝶的接口
fmt
.
Println
(
"请求金蝶接口"
)
return
nil
//如果失败了,记录到表,并且发送钉钉消息
//如果失败了,记录到表,并且发送钉钉消息
ERR
:
ERR
:
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
if
err
=
logic
.
InsertSyncStatusLog
(
message
.
SyncName
,
message
.
ErpId
,
"err.Error()"
);
err
!=
nil
{
fmt
.
Println
(
err
)
}
return
nil
return
nil
}
}
...
...
cmd/queue/sync_status/product.go
→
cmd/queue/sync_status/product
/product_status_queue
.go
View file @
d62fbed9
package
main
package
product
import
(
import
(
"encoding/json"
"encoding/json"
...
@@ -6,15 +6,15 @@ import (
...
@@ -6,15 +6,15 @@ import (
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
)
)
func
main
(
)
{
func
SyncErpStatus
(
syncName
string
,
ErpId
string
)
{
message
:=
make
(
map
[
string
]
interface
{})
message
:=
make
(
map
[
string
]
interface
{})
message
=
map
[
string
]
interface
{}{
message
=
map
[
string
]
interface
{}{
"SyncName"
:
"supplier"
,
"SyncName"
:
syncName
,
"Status"
:
1
,
"Status"
:
1
,
"ErpId"
:
"test123456"
,
"ErpId"
:
ErpId
,
}
}
data
,
err
:=
json
.
Marshal
(
message
)
data
,
err
:=
json
.
Marshal
(
message
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
}
}
body
:=
string
(
data
)
body
:=
string
(
data
)
...
...
cmd/queue/sync_supplier/main.go
View file @
d62fbed9
...
@@ -65,9 +65,10 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -65,9 +65,10 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
}
}
case
"delete"
:
case
"delete"
:
operateType
=
"delete"
operateType
=
"delete"
supplier
.
Status
=
0
if
logic
.
CheckSupplierExist
(
supplier
.
ErpId
)
{
if
logic
.
CheckSupplierExist
(
supplier
.
ErpId
)
{
//如果存在,才进行删除
//如果存在,才进行删除
if
err
=
logic
.
DeleteSupplier
(
supplier
.
ErpId
);
err
!=
nil
{
if
err
=
logic
.
DeleteSupplier
(
supplier
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
}
else
{
}
else
{
...
@@ -135,7 +136,7 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
...
@@ -135,7 +136,7 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
}
else
if
operate
==
"insert"
{
}
else
if
operate
==
"insert"
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiInsertSupplierInfo"
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiInsertSupplierInfo"
}
else
{
}
else
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
DeleteSupplierInfo
"
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
UpdateSupplierStatus
"
}
}
req
.
Debug
=
false
req
.
Debug
=
false
if
operate
==
"update"
||
operate
==
"insert"
{
if
operate
==
"update"
||
operate
==
"insert"
{
...
@@ -154,9 +155,28 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
...
@@ -154,9 +155,28 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
return
return
}
}
}
else
{
}
else
{
param
=
req
.
Param
{
"erp_supplier_id"
:
supplier
.
ErpId
,
"admin_name"
:
"系统"
,
"admin_id"
:
1
,
"status"
:
0
,
}
//删除
//删除
resp
,
err
=
req
.
Post
(
url
,
param
)
if
err
!=
nil
{
return
}
if
err
=
resp
.
ToJSON
(
&
respData
);
err
!=
nil
{
return
}
if
respData
.
Errcode
!=
101100
{
return
errors
.
New
(
respData
.
Errmsg
)
}
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if
err
=
logic
.
SyncCustomerSuccess
(
supplier
.
ErpId
);
err
!=
nil
{
return
}
}
}
return
return
}
}
...
...
cmd/queue/sync_supplier/product.go
View file @
d62fbed9
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
func
main
()
{
func
main
()
{
message
:=
make
(
map
[
string
]
interface
{})
message
:=
make
(
map
[
string
]
interface
{})
message
=
map
[
string
]
interface
{}{
message
=
map
[
string
]
interface
{}{
"type"
:
"
sav
e"
,
"type"
:
"
delet
e"
,
"data"
:
map
[
string
]
string
{
"data"
:
map
[
string
]
string
{
"FID"
:
"Z8eVSzSLRXKa7ET9WHFzYagYZf017ff="
,
"FID"
:
"Z8eVSzSLRXKa7ET9WHFzYagYZf017ff="
,
"FNUMBER"
:
"WT0050333"
,
"FNUMBER"
:
"WT0050333"
,
...
...
cmd/source/main.go
View file @
d62fbed9
package
main
package
main
import
"scm_server/cmd/source/
supplier
"
import
"scm_server/cmd/source/
goods
"
func
main
()
{
func
main
()
{
//forever := make(chan bool)
//forever := make(chan bool)
//go supplier.Import()
//go supplier.Import()
supplier
.
Import
()
//
supplier.Import()
//<-forever
//<-forever
//customer.Import()
//customer.Import()
//
goods.Import()
goods
.
Import
()
}
}
internal/logic/goods.go
View file @
d62fbed9
...
@@ -12,7 +12,7 @@ const InsertGoodsSql = "INSERT INTO `lie_goods` (`goods_name`,`goods_cn_name`,`b
...
@@ -12,7 +12,7 @@ const InsertGoodsSql = "INSERT INTO `lie_goods` (`goods_name`,`goods_cn_name`,`b
const
UpdateGoodsSql
=
"UPDATE `lie_goods` SET `goods_name` = ? , `goods_cn_name` = ? , `brand_name` = ? , `update_time` = ? WHERE `erp_id` = ?"
const
UpdateGoodsSql
=
"UPDATE `lie_goods` SET `goods_name` = ? , `goods_cn_name` = ? , `brand_name` = ? , `update_time` = ? WHERE `erp_id` = ?"
const
DeleteGoodsSql
=
"
DELETE FROM `lie_goods`
WHERE `erp_id` = ?"
const
DeleteGoodsSql
=
"
UPDATE `lie_goods` SET `status` = ? , `update_time` = ?
WHERE `erp_id` = ?"
const
WriteGoodsSyncErrorSql
=
"UPDATE `lie_goods` SET sync_error = ? WHERE goods_id = ?"
const
WriteGoodsSyncErrorSql
=
"UPDATE `lie_goods` SET sync_error = ? WHERE goods_id = ?"
...
@@ -44,8 +44,8 @@ func UpdateGoods(goods model.Goods) (err error) {
...
@@ -44,8 +44,8 @@ func UpdateGoods(goods model.Goods) (err error) {
}
}
//删除供应商
//删除供应商
func
DeleteGoods
(
erpId
string
)
(
err
error
)
{
func
DeleteGoods
(
goods
model
.
Goods
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteGoodsSql
,
e
rpId
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteGoodsSql
,
goods
.
Status
,
time
.
Now
()
.
Unix
(),
goods
.
E
rpId
)
return
return
}
}
...
...
internal/logic/supplier.go
View file @
d62fbed9
...
@@ -12,7 +12,7 @@ const InsertSupplierSql = "Insert INTO `lie_supplier` (`erp_supplier_code`,`name
...
@@ -12,7 +12,7 @@ const InsertSupplierSql = "Insert INTO `lie_supplier` (`erp_supplier_code`,`name
const
UpdateSupplierSql
=
"UPDATE `lie_supplier` SET `erp_supplier_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?"
const
UpdateSupplierSql
=
"UPDATE `lie_supplier` SET `erp_supplier_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?"
const
DeleteSupplierSql
=
"
DELETE FROM `lie_supplier`
WHERE `erp_id` = ?"
const
DeleteSupplierSql
=
"
UPDATE `lie_supplier` SET `status` = ? , `update_time` = ?
WHERE `erp_id` = ?"
const
WriteSupplierSyncErrorSql
=
"UPDATE `lie_supplier` SET sync_time = ? , sync_status = ? , sync_error = ? WHERE erp_id = ?"
const
WriteSupplierSyncErrorSql
=
"UPDATE `lie_supplier` SET sync_time = ? , sync_status = ? , sync_error = ? WHERE erp_id = ?"
...
@@ -28,24 +28,18 @@ func CheckSupplierExist(erpId string) (exist bool) {
...
@@ -28,24 +28,18 @@ func CheckSupplierExist(erpId string) (exist bool) {
//插入供应商
//插入供应商
func
InsertSupplier
(
supplier
model
.
Supplier
)
(
err
error
)
{
func
InsertSupplier
(
supplier
model
.
Supplier
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertSupplierSql
,
supplier
.
ErpSupplierCode
,
supplier
.
Name
,
supplier
.
ErpId
,
time
.
Now
()
.
Unix
(),
0
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertSupplierSql
,
supplier
.
ErpSupplierCode
,
supplier
.
Name
,
supplier
.
ErpId
,
time
.
Now
()
.
Unix
(),
0
)
if
err
!=
nil
{
return
return
}
return
nil
}
}
//更新供应商
//更新供应商
func
UpdateSupplier
(
supplier
model
.
Supplier
)
(
err
error
)
{
func
UpdateSupplier
(
supplier
model
.
Supplier
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
UpdateSupplierSql
,
supplier
.
ErpSupplierCode
,
supplier
.
Name
,
time
.
Now
()
.
Unix
(),
supplier
.
ErpId
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
UpdateSupplierSql
,
supplier
.
ErpSupplierCode
,
supplier
.
Name
,
time
.
Now
()
.
Unix
(),
supplier
.
ErpId
)
if
err
!=
nil
{
return
return
}
return
nil
}
}
//删除供应商
//删除供应商
func
DeleteSupplier
(
erpId
string
)
(
err
error
)
{
func
DeleteSupplier
(
supplier
model
.
Supplier
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteSupplierSql
,
e
rpId
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteSupplierSql
,
supplier
.
Status
,
time
.
Now
()
.
Unix
(),
supplier
.
E
rpId
)
return
return
}
}
...
...
internal/logic/sync_status_log.go
0 → 100644
View file @
d62fbed9
package
logic
import
(
"scm_server/internal/dao"
"time"
)
//插入金蝶同步状态错误信息
const
InsertSyncStatusLogSql
=
"Insert Into `lie_sync_status_log` ( `sync_name` , `unique_id` , `error_msg` , `add_time` ) Value (?,?,?,?)"
func
InsertSyncStatusLog
(
syncName
,
uniqueId
,
errMsg
string
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertSyncStatusLogSql
,
syncName
,
uniqueId
,
errMsg
,
time
.
Now
()
.
Unix
())
return
}
internal/model/goods.go
View file @
d62fbed9
...
@@ -9,4 +9,5 @@ type Goods struct {
...
@@ -9,4 +9,5 @@ type Goods struct {
SyncTime
int
SyncTime
int
SyncStatus
int
SyncStatus
int
SyncError
string
SyncError
string
Status
int
}
}
internal/model/supplier.go
View file @
d62fbed9
...
@@ -8,4 +8,5 @@ type Supplier struct {
...
@@ -8,4 +8,5 @@ type Supplier struct {
SyncTime
int
SyncTime
int
SyncStatus
int
SyncStatus
int
SyncError
string
SyncError
string
Status
int
}
}
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