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
48f0d1f4
authored
Apr 30, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
加上同步状态判断
parent
a6aa2bb2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
9 deletions
cmd/queue/sync_goods/main.go
cmd/queue/sync_status/main.go
cmd/queue/sync_supplier/main.go
internal/logic/goods.go
internal/logic/supplier.go
internal/service/dingding.go
cmd/queue/sync_goods/main.go
View file @
48f0d1f4
...
...
@@ -54,8 +54,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
//判断操作类型
switch
message
.
Type
{
case
"save"
:
//先去查询是否存在
,不存在才去插入,已经存在即是修改
if
logic
.
CheckGoods
Exist
(
goods
.
ErpId
)
{
//先去查询是否存在
已经同步完成的记录
if
logic
.
CheckGoods
SyncStatus
(
goods
.
ErpId
)
{
operateType
=
"update"
if
err
=
logic
.
UpdateGoods
(
goods
);
err
!=
nil
{
goto
ERR
...
...
cmd/queue/sync_status/main.go
View file @
48f0d1f4
...
...
@@ -194,7 +194,6 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
for
key
,
value
:=
range
responseData
{
//金蝶判断成功的标志
if
key
==
"0000"
{
fmt
.
Println
(
"OK"
)
return
}
//金额判断失败的标志
...
...
cmd/queue/sync_supplier/main.go
View file @
48f0d1f4
...
...
@@ -52,8 +52,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
//判断操作类型
switch
message
.
Type
{
case
"save"
:
//先去查询是否存在
,不存在才去插入,已经存在即是修改
if
logic
.
CheckSupplier
Exist
(
supplier
.
ErpId
)
{
//先去查询是否存在
已经同步完成的记录
if
logic
.
CheckSupplier
SyncStatus
(
supplier
.
ErpId
)
{
operateType
=
"update"
if
err
=
logic
.
UpdateSupplier
(
supplier
);
err
!=
nil
{
goto
ERR
...
...
internal/logic/goods.go
View file @
48f0d1f4
...
...
@@ -6,7 +6,9 @@ import (
"time"
)
const
CheckGoodsExistSql
=
"SELECT goods_id FROM lie_goods WHERE erp_id = ? AND sync_status = 1"
const
CheckGoodsExistSql
=
"SELECT goods_id FROM lie_goods WHERE erp_id = ?"
const
CheckGoodsSyncStatusSql
=
"SELECT sync_status FROM lie_goods WHERE erp_id = ?"
const
InsertGoodsSql
=
"INSERT INTO `lie_goods` (`goods_name`,`goods_cn_name`,`brand_name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?,?)"
...
...
@@ -25,10 +27,19 @@ func CheckGoodsExist(erpId string) (exist bool) {
return
goodsId
>
0
}
//获取后端同步状态
func
CheckGoodsSyncStatus
(
erpId
string
)
(
status
bool
)
{
var
statusInt
int
dao
.
GetDb
()
.
QueryRowx
(
CheckGoodsSyncStatusSql
,
erpId
)
.
Scan
(
&
statusInt
)
return
statusInt
>
0
}
//插入物料
func
InsertGoods
(
goods
model
.
Goods
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertGoodsSql
,
goods
.
GoodsName
,
goods
.
GoodsCnName
,
goods
.
BrandName
,
goods
.
ErpId
,
time
.
Now
()
.
Unix
(),
0
)
if
!
CheckGoodsExist
(
goods
.
ErpId
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertGoodsSql
,
goods
.
GoodsName
,
goods
.
GoodsCnName
,
goods
.
BrandName
,
goods
.
ErpId
,
time
.
Now
()
.
Unix
(),
0
)
}
return
}
...
...
internal/logic/supplier.go
View file @
48f0d1f4
...
...
@@ -8,6 +8,8 @@ import (
const
CheckSupplierExistSql
=
"SELECT supplier_id FROM lie_supplier WHERE erp_id = ?"
const
CheckSupplierSyncStatusSql
=
"SELECT sync_status FROM lie_supplier WHERE erp_id = ?"
const
InsertSupplierSql
=
"Insert INTO `lie_supplier` (`erp_supplier_code`,`name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?)"
const
UpdateSupplierSql
=
"UPDATE `lie_supplier` SET `erp_supplier_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?"
...
...
@@ -25,9 +27,18 @@ func CheckSupplierExist(erpId string) (exist bool) {
return
supplierId
>
0
}
//获取后端同步状态
func
CheckSupplierSyncStatus
(
erpId
string
)
(
status
bool
)
{
var
statusInt
int
dao
.
GetDb
()
.
QueryRowx
(
CheckSupplierSyncStatusSql
,
erpId
)
.
Scan
(
&
statusInt
)
return
statusInt
>
0
}
//插入供应商
func
InsertSupplier
(
supplier
model
.
Supplier
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertSupplierSql
,
supplier
.
ErpSupplierCode
,
supplier
.
Name
,
supplier
.
ErpId
,
time
.
Now
()
.
Unix
(),
0
)
if
!
CheckSupplierExist
(
supplier
.
ErpId
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertSupplierSql
,
supplier
.
ErpSupplierCode
,
supplier
.
Name
,
supplier
.
ErpId
,
time
.
Now
()
.
Unix
(),
0
)
}
return
}
...
...
internal/service/dingding.go
View file @
48f0d1f4
...
...
@@ -52,6 +52,10 @@ type DingDingRequest struct {
}
func
SendDingTalkRobotToApi
(
content
string
)
{
fmt
.
Println
(
content
)
}
func
SendDingTalkRobotToApi1
(
content
string
)
{
var
(
requestData
DingDingRequest
apiUrl
,
token
string
...
...
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