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
ba0c881f
authored
May 13, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix bug
parent
293610f4
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
71 additions
and
59 deletions
cmd/queue/sync_audit_status/main.go
cmd/queue/sync_audit_status/product/product_status_queue.go
cmd/queue/sync_out_store/main.go
cmd/queue/sync_out_store/product/product.go
cmd/queue/sync_status/main.go
cmd/queue/sync_supplier/main.go
conf/config.ini
internal/logic/audit_status_log.go
internal/logic/in_store.go
internal/logic/out_store.go
internal/logic/sync_log.go
internal/model/audit_status_log.go
main.go
scm_server
cmd/queue/sync_audit_status/main.go
View file @
ba0c881f
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/beevik/etree"
"github.com/beevik/etree"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/mushishixian/gosoap"
"github.com/mushishixian/gosoap"
"github.com/pkg/errors"
"github.com/pkg/errors"
...
@@ -26,22 +25,18 @@ type QueueAuditData struct {
...
@@ -26,22 +25,18 @@ type QueueAuditData struct {
type
StoreData
struct
{
type
StoreData
struct
{
ErpStoreId
string
`json:"erp_store_id"`
ErpStoreId
string
`json:"erp_store_id"`
BoxNumber
int
`json:"box_number"`
BoxNumber
int
`json:"box_number"`
BoxWeight
float64
`json:"box_weight"`
BoxWeight
string
`json:"box_weight"`
PalletNumber
int
`json:"pallet_number"`
PalletNumber
int
`json:"pallet_number"`
PalletWeight
int
`json:"pallet_weight"`
PalletWeight
string
`json:"pallet_weight"`
Detail
[]
StoreGoods
`json:"detail"`
Detail
[]
StoreGoods
`json:"detail"`
}
}
type
StoreGoods
struct
{
type
StoreGoods
struct
{
ErpEntrySn
string
`json:"erp_entry_sn"`
ErpEntrySn
string
`json:"erp_entry_sn"`
Number
int
`json:"number"`
Number
string
`json:"number"`
CountryCode
string
`json:"country_code"`
CountryCode
string
`json:"country_code"`
}
}
func
init
()
{
log
.
Init
(
nil
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
var
(
var
(
message
QueueAuditData
message
QueueAuditData
...
@@ -64,7 +59,8 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -64,7 +59,8 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
"FCardBoardQty"
:
message
.
Data
.
PalletNumber
,
"FCardBoardQty"
:
message
.
Data
.
PalletNumber
,
"FCardBoardWeight"
:
message
.
Data
.
PalletWeight
,
"FCardBoardWeight"
:
message
.
Data
.
PalletWeight
,
}
}
for
_
,
value
:=
range
message
.
Data
.
Detail
{
inStoreErpGoods
=
append
(
inStoreErpGoods
,
map
[
string
]
interface
{}{
for
_
,
value
:=
range
message
.
Data
.
Detail
{
inStoreErpGoods
=
append
(
inStoreErpGoods
,
map
[
string
]
interface
{}{
"FSourceBillEntryID"
:
value
.
ErpEntrySn
,
"FSourceBillEntryID"
:
value
.
ErpEntrySn
,
"FQty"
:
value
.
Number
,
"FQty"
:
value
.
Number
,
"FOriginCountry"
:
value
.
CountryCode
,
"FOriginCountry"
:
value
.
CountryCode
,
...
@@ -74,25 +70,26 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
...
@@ -74,25 +70,26 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
jsonByte
,
_
=
json
.
Marshal
(
storeErpData
)
jsonByte
,
_
=
json
.
Marshal
(
storeErpData
)
}
}
//得到message以后,去请求金蝶的接口
//得到message以后,去请求金蝶的接口
if
err
=
SyncErpAuditStatus
(
message
.
SyncName
,
string
(
jsonByte
));
err
!=
nil
{
if
err
=
SyncErpAuditStatus
(
message
.
SyncName
,
message
.
Data
.
ErpStoreId
,
string
(
jsonByte
));
err
!=
nil
{
goto
ERR
goto
ERR
}
}
return
nil
return
nil
ERR
:
ERR
:
auditStatusLog
.
SyncName
=
message
.
SyncName
auditStatusLog
.
SyncName
=
message
.
SyncName
//auditStatusLog.UniqueId = message.ErpId
auditStatusLog
.
UniqueId
=
message
.
Data
.
ErpStoreId
auditStatusLog
.
QueueMessage
=
string
(
dataByte
)
auditStatusLog
.
SyncError
=
err
.
Error
()
auditStatusLog
.
SyncError
=
err
.
Error
()
auditStatusLog
.
AddTime
=
time
.
Now
()
.
Unix
()
auditStatusLog
.
AddTime
=
time
.
Now
()
.
Unix
()
//如果失败了,记录到表,并且发送钉钉消息
//如果失败了,记录到表,并且发送钉钉消息
if
err
=
logic
.
InsertAuditStatusLog
(
auditStatusLog
);
err
!=
nil
{
if
err
=
logic
.
InsertAuditStatusLog
(
auditStatusLog
);
err
!=
nil
{
log
.
Error
(
err
.
Error
())
log
ic
.
Log
Error
(
err
.
Error
())
service
.
SendDingTalkRobotToApi
(
err
.
Error
())
service
.
SendDingTalkRobotToApi
(
err
.
Error
())
}
}
service
.
SendDingTalkRobotToApi
(
auditStatusLog
.
SyncError
)
service
.
SendDingTalkRobotToApi
(
auditStatusLog
.
SyncError
)
return
nil
return
nil
}
}
func
SyncErpAuditStatus
(
syncName
,
json
string
)
(
err
error
)
{
func
SyncErpAuditStatus
(
syncName
,
billId
,
json
string
)
(
err
error
)
{
if
err
=
service
.
LoginErp
();
err
!=
nil
{
if
err
=
service
.
LoginErp
();
err
!=
nil
{
return
return
}
}
...
@@ -122,16 +119,15 @@ func SyncErpAuditStatus(syncName, json string) (err error) {
...
@@ -122,16 +119,15 @@ func SyncErpAuditStatus(syncName, json string) (err error) {
params
=
gosoap
.
ArrayParams
{
params
=
gosoap
.
ArrayParams
{
{
"json"
,
json
},
{
"json"
,
json
},
}
}
fmt
.
Println
(
json
)
res
,
err
=
soap
.
Call
(
apiMethod
,
params
)
res
,
err
=
soap
.
Call
(
apiMethod
,
params
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
return
CheckBillDataRequest
(
res
)
return
CheckBillDataRequest
(
syncName
,
billId
,
res
)
}
}
//检查出入库单申请同步请求的情况
//检查出入库单申请同步请求的情况
func
CheckBillDataRequest
(
res
*
gosoap
.
Response
)
(
err
error
)
{
func
CheckBillDataRequest
(
syncName
,
billId
string
,
res
*
gosoap
.
Response
)
(
err
error
)
{
doc
:=
etree
.
NewDocument
()
doc
:=
etree
.
NewDocument
()
if
err
=
doc
.
ReadFromBytes
(
res
.
Body
);
err
!=
nil
{
if
err
=
doc
.
ReadFromBytes
(
res
.
Body
);
err
!=
nil
{
return
return
...
@@ -148,8 +144,11 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
...
@@ -148,8 +144,11 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
for
key
,
value
:=
range
responseData
{
for
key
,
value
:=
range
responseData
{
//金蝶判断成功的标志
//金蝶判断成功的标志
if
key
==
"0000"
{
if
key
==
"0000"
{
fmt
.
Println
(
"ok"
)
if
syncName
==
"in_store"
{
return
return
logic
.
SyncInStoreErpAuditSuccess
(
billId
)
}
else
{
return
logic
.
SyncOutStoreErpAuditSuccess
(
billId
)
}
}
}
//金额判断失败的标志
//金额判断失败的标志
if
key
==
"4444"
{
if
key
==
"4444"
{
...
...
cmd/queue/sync_audit_status/product/product_status_queue.go
View file @
ba0c881f
...
@@ -7,22 +7,7 @@ import (
...
@@ -7,22 +7,7 @@ import (
)
)
func
main
()
()
{
func
main
()
()
{
message
:=
`{"SyncName": "in_store",
message
:=
`{"SyncName":"in_store","Data":{"erp_store_id":"FGipxV9OSXGWVCgqefjkesBZJbY=","detail":[{"number":"10.0000","erp_entry_sn":"mJ4W+QdYQoWe0WCnzEOJou0oFFw=","country":""},{"number":"900.0000","erp_entry_sn":"z0ULke\/wRhC5cQFzZZT4WO0oFFw=","country":""}],"pallet_number":1,"pallet_weight":"0.0000","box_number":1,"box_weight":"0.0000"}}`
"Data": {
"erp_store_id": "9wtJ0cxwTcOCbMSGuBbhfcBZJbY=",
"box_number": 2,
"box_weight": 400,
"pallet_number": 1,
"pallet_weight": 600,
"detail": [
{
"erp_entry_sn": "RsgAliA2QPGXgJHwk6ntk+0oFFw=",
"number": 55,
"country_code": "502"
}
]
}
}`
fmt
.
Println
(
message
)
fmt
.
Println
(
message
)
queueExchange
:=
rabbitmq
.
QueueExchange
{
queueExchange
:=
rabbitmq
.
QueueExchange
{
"store_audit_status"
,
"store_audit_status"
,
...
...
cmd/queue/sync_out_store/main.go
View file @
ba0c881f
...
@@ -166,14 +166,14 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
...
@@ -166,14 +166,14 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
"deliveryTerms0007"
:
7
,
"deliveryTerms0007"
:
7
,
"deliveryTerms0008"
:
8
,
"deliveryTerms0008"
:
8
,
}
}
var
isInsp
int
if
entry
.
CFIsInsp
{
isInsp
=
1
}
else
{
isInsp
=
0
}
params
=
make
(
map
[
string
]
interface
{})
params
=
make
(
map
[
string
]
interface
{})
for
_
,
entry
=
range
message
.
Data
.
FEntrys
{
for
_
,
entry
=
range
message
.
Data
.
FEntrys
{
var
isInsp
int
if
entry
.
CFIsInsp
{
isInsp
=
1
}
else
{
isInsp
=
0
}
outStoreDetail
=
append
(
outStoreDetail
,
map
[
string
]
interface
{}{
outStoreDetail
=
append
(
outStoreDetail
,
map
[
string
]
interface
{}{
"erp_goods_id"
:
entry
.
FMaterialID
,
"erp_goods_id"
:
entry
.
FMaterialID
,
"goods_name"
:
entry
.
FModel
,
"goods_name"
:
entry
.
FModel
,
...
...
cmd/queue/sync_out_store/product/product.go
View file @
ba0c881f
...
@@ -36,6 +36,19 @@ func main() {
...
@@ -36,6 +36,19 @@ func main() {
"FGoods"
:
"集成电路"
,
"FGoods"
:
"集成电路"
,
"FUnit"
:
"个"
,
"FUnit"
:
"个"
,
},
},
{
"FQty"
:
9
,
"FIsRecordLotAndDC"
:
false
,
"FOriginCountry"
:
"502"
,
"FIsPrint"
:
false
,
"CFIsInsp"
:
true
,
"FMaterialID"
:
"YscJMHmgT1+Yh6EWN343yEQJ5/A="
,
"FBrand"
:
"ON"
,
"FSourceBillEntryID"
:
"gHw/y6EQRBmCpLGDFkdJCO0oFFw="
,
"FModel"
:
"1abaaba"
,
"FGoods"
:
"集成电路"
,
"FUnit"
:
"个"
,
},
},
},
},
},
}
}
...
...
cmd/queue/sync_status/main.go
View file @
ba0c881f
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/beevik/etree"
"github.com/beevik/etree"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/mushishixian/gosoap"
"github.com/mushishixian/gosoap"
"github.com/pkg/errors"
"github.com/pkg/errors"
...
@@ -24,12 +23,9 @@ type QueueStatus struct {
...
@@ -24,12 +23,9 @@ type QueueStatus struct {
ErpId
string
ErpId
string
}
}
func
init
()
{
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
log
.
Init
(
nil
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
(
err
error
)
{
var
(
var
(
err
error
message
QueueStatus
message
QueueStatus
syncStatusLog
model
.
SyncStatusLog
syncStatusLog
model
.
SyncStatusLog
)
)
...
@@ -50,7 +46,9 @@ ERR:
...
@@ -50,7 +46,9 @@ ERR:
//如果失败了,记录到表,并且发送钉钉消息
//如果失败了,记录到表,并且发送钉钉消息
if
err
=
logic
.
InsertSyncStatusLog
(
syncStatusLog
);
err
!=
nil
{
if
err
=
logic
.
InsertSyncStatusLog
(
syncStatusLog
);
err
!=
nil
{
service
.
SendDingTalkRobotToApi
(
err
.
Error
())
service
.
SendDingTalkRobotToApi
(
err
.
Error
())
logic
.
LogError
(
err
.
Error
())
}
}
logic
.
LogError
(
syncStatusLog
.
SyncError
)
service
.
SendDingTalkRobotToApi
(
syncStatusLog
.
SyncError
)
service
.
SendDingTalkRobotToApi
(
syncStatusLog
.
SyncError
)
return
nil
return
nil
}
}
...
...
cmd/queue/sync_supplier/main.go
View file @
ba0c881f
...
@@ -77,7 +77,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -77,7 +77,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
if
err
=
SyncSupplierData
(
operateType
,
supplier
);
err
!=
nil
{
if
err
=
SyncSupplierData
(
operateType
,
supplier
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
fmt
.
Println
(
"同步成功,开始发送金蝶状态同步"
)
if
err
=
product
.
SyncErpStatus
(
"supplier"
,
supplier
.
ErpId
);
err
!=
nil
{
if
err
=
product
.
SyncErpStatus
(
"supplier"
,
supplier
.
ErpId
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
...
@@ -143,7 +142,7 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
...
@@ -143,7 +142,7 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
}
}
}
}
//都没问题,代表后端那边已经成功修改,修改同步表的状态
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if
err
=
logic
.
Sync
Custom
erSuccess
(
supplier
.
ErpId
);
err
!=
nil
{
if
err
=
logic
.
Sync
Suppli
erSuccess
(
supplier
.
ErpId
);
err
!=
nil
{
return
return
}
}
return
return
...
...
conf/config.ini
View file @
ba0c881f
...
@@ -8,9 +8,9 @@ database = lie_scm_sync
...
@@ -8,9 +8,9 @@ database = lie_scm_sync
url
=
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
url
=
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
[api]
[api]
base
=
http://192.168.2.
113
:40001
base
=
http://192.168.2.
232
:40001
out_store
=
http://192.168.2.179:40003
out_store
=
http://192.168.2.179:40003
in_store
=
http://192.168.2.23
9
:40004
in_store
=
http://192.168.2.23
2
:40004
erp_sync_base_data_status
=
http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl
erp_sync_base_data_status
=
http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl
erp_sync_bill_status
=
http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl
erp_sync_bill_status
=
http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl
erp_login_status
=
http://192.168.2.253:6888/ormrpc/services/EASLogin?wsdl
erp_login_status
=
http://192.168.2.253:6888/ormrpc/services/EASLogin?wsdl
...
...
internal/logic/audit_status_log.go
View file @
ba0c881f
...
@@ -6,9 +6,9 @@ import (
...
@@ -6,9 +6,9 @@ import (
)
)
//插入金蝶同步状态错误信息
//插入金蝶同步状态错误信息
const
InsertAuditStatusLogSql
=
"INSERT INTO `lie_audit_status_log` ( `sync_name` , `
unique_id` , `sync_error` , `add_time` ) VALUE (
?,?,?,?)"
const
InsertAuditStatusLogSql
=
"INSERT INTO `lie_audit_status_log` ( `sync_name` , `
queue_message` , `unique_id` , `sync_error` , `add_time` ) VALUE (?,
?,?,?,?)"
func
InsertAuditStatusLog
(
auditStatusLog
model
.
AuditStatusLog
)
(
err
error
)
{
func
InsertAuditStatusLog
(
auditStatusLog
model
.
AuditStatusLog
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertAuditStatusLogSql
,
auditStatusLog
.
SyncName
,
auditStatusLog
.
UniqueId
,
auditStatusLog
.
SyncError
,
auditStatusLog
.
AddTime
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
InsertAuditStatusLogSql
,
auditStatusLog
.
SyncName
,
auditStatusLog
.
QueueMessage
,
auditStatusLog
.
UniqueId
,
auditStatusLog
.
SyncError
,
auditStatusLog
.
AddTime
)
return
return
}
}
internal/logic/in_store.go
View file @
ba0c881f
...
@@ -20,12 +20,21 @@ const SyncInStoreSuccessSqlWithStatus = "UPDATE `lie_in_store` SET sync_status =
...
@@ -20,12 +20,21 @@ const SyncInStoreSuccessSqlWithStatus = "UPDATE `lie_in_store` SET sync_status =
const
SyncInStoreErpSuccessSql
=
"UPDATE `lie_in_store` SET sync_erp_status = 1 , sync_time = ? WHERE bill_id = ?"
const
SyncInStoreErpSuccessSql
=
"UPDATE `lie_in_store` SET sync_erp_status = 1 , sync_time = ? WHERE bill_id = ?"
const
SyncInStoreErpAuditSuccessSql
=
"UPDATE `lie_in_store` SET sync_erp_audit_status = 1 , sync_time = ? WHERE bill_id = ?"
//修改同步到erp成功的状态
//修改同步到erp成功的状态
func
SyncInStoreErpSuccess
(
billId
string
)
(
err
error
)
{
func
SyncInStoreErpSuccess
(
billId
string
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
SyncInStoreErpSuccessSql
,
time
.
Now
()
.
Unix
(),
billId
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
SyncInStoreErpSuccessSql
,
time
.
Now
()
.
Unix
(),
billId
)
return
return
}
}
//修改审核状态同步到erp成功的状态
func
SyncInStoreErpAuditSuccess
(
billId
string
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
SyncInStoreErpAuditSuccessSql
,
time
.
Now
()
.
Unix
(),
billId
)
return
}
//检查出库是否存在
//检查出库是否存在
func
CheckInStoreExist
(
billId
string
)
(
exist
bool
)
{
func
CheckInStoreExist
(
billId
string
)
(
exist
bool
)
{
var
inStoreId
int
var
inStoreId
int
...
...
internal/logic/out_store.go
View file @
ba0c881f
...
@@ -22,6 +22,8 @@ const SyncOutStoreSuccessSqlWithStatus = "UPDATE `lie_out_store` SET sync_status
...
@@ -22,6 +22,8 @@ const SyncOutStoreSuccessSqlWithStatus = "UPDATE `lie_out_store` SET sync_status
const
SyncOutStoreErpSuccessSql
=
"UPDATE `lie_out_store` SET sync_erp_status = 1 , sync_time = ? WHERE bill_id = ?"
const
SyncOutStoreErpSuccessSql
=
"UPDATE `lie_out_store` SET sync_erp_status = 1 , sync_time = ? WHERE bill_id = ?"
const
SyncOutStoreErpAuditSuccessSql
=
"UPDATE `lie_out_store` SET sync_erp_audit_status = 1 , sync_time = ? WHERE bill_id = ?"
//修改同步到erp成功的状态
//修改同步到erp成功的状态
func
SyncOutStoreErpSuccess
(
billId
string
)
(
err
error
)
{
func
SyncOutStoreErpSuccess
(
billId
string
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
SyncOutStoreErpSuccessSql
,
time
.
Now
()
.
Unix
(),
billId
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
SyncOutStoreErpSuccessSql
,
time
.
Now
()
.
Unix
(),
billId
)
...
@@ -55,9 +57,9 @@ func DeleteOutStore(outStore model.OutStore) (err error) {
...
@@ -55,9 +57,9 @@ func DeleteOutStore(outStore model.OutStore) (err error) {
return
return
}
}
//
写入同步失败的原因
//
修改审核状态同步到erp成功的状态
func
WriteOutStoreSyncError
(
erpId
string
,
syncError
string
)
(
err
error
)
{
func
SyncOutStoreErpAuditSuccess
(
billId
string
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
WriteOutStoreSyncErrorSql
,
syncError
,
erp
Id
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
SyncOutStoreErpAuditSuccessSql
,
time
.
Now
()
.
Unix
(),
bill
Id
)
return
return
}
}
...
...
internal/logic/sync_log.go
View file @
ba0c881f
...
@@ -23,6 +23,11 @@ func InsertSyncLog(syncLog model.SyncLog) (err error) {
...
@@ -23,6 +23,11 @@ func InsertSyncLog(syncLog model.SyncLog) (err error) {
return
err
return
err
}
}
func
LogError
(
msg
string
)
{
//保存日志
logs
.
Error
(
fmt
.
Sprintf
(
"%s"
,
msg
))
}
func
DealSyncError
(
dataByte
[]
byte
,
uniqueId
,
syncName
string
,
err
error
)
error
{
func
DealSyncError
(
dataByte
[]
byte
,
uniqueId
,
syncName
string
,
err
error
)
error
{
//还要存到一个统一错误表
//还要存到一个统一错误表
syncLog
:=
model
.
SyncLog
{
syncLog
:=
model
.
SyncLog
{
...
...
internal/model/audit_status_log.go
View file @
ba0c881f
...
@@ -3,6 +3,7 @@ package model
...
@@ -3,6 +3,7 @@ package model
type
AuditStatusLog
struct
{
type
AuditStatusLog
struct
{
SyncName
string
SyncName
string
SyncError
string
SyncError
string
QueueMessage
string
UniqueId
string
UniqueId
string
AddTime
int64
AddTime
int64
}
}
main.go
View file @
ba0c881f
package
main
package
main
import
(
import
(
"github.com/imroc/req"
"scm_server/cmd/queue/sync_customer"
"scm_server/cmd/queue/sync_customer"
"scm_server/cmd/queue/sync_goods"
"scm_server/cmd/queue/sync_goods"
"scm_server/cmd/queue/sync_in_store"
"scm_server/cmd/queue/sync_in_store"
...
@@ -10,6 +9,8 @@ import (
...
@@ -10,6 +9,8 @@ import (
"scm_server/cmd/queue/sync_supplier"
"scm_server/cmd/queue/sync_supplier"
"scm_server/configs"
"scm_server/configs"
"time"
"time"
"github.com/imroc/req"
)
)
type
PayloadItem
struct
{
type
PayloadItem
struct
{
...
@@ -38,7 +39,7 @@ func pushAlive() {
...
@@ -38,7 +39,7 @@ func pushAlive() {
Step
:
60
,
Step
:
60
,
CounterType
:
"GAUGE"
,
CounterType
:
"GAUGE"
,
Value
:
float64
(
time
.
Now
()
.
Unix
()),
Value
:
float64
(
time
.
Now
()
.
Unix
()),
Tags
:
"store_sync"
,
Tags
:
"s
ervice=s
tore_sync"
,
}
}
payload
=
append
(
payload
,
item
)
payload
=
append
(
payload
,
item
)
param
:=
req
.
BodyJSON
(
&
payload
)
param
:=
req
.
BodyJSON
(
&
payload
)
...
@@ -57,10 +58,10 @@ func main() {
...
@@ -57,10 +58,10 @@ func main() {
go
sync_in_store
.
Sync
()
go
sync_in_store
.
Sync
()
go
sync_out_store
.
Sync
()
go
sync_out_store
.
Sync
()
go
sync_status
.
Sync
()
go
sync_status
.
Sync
()
//go sync_audit_status.Sync()
//
go sync_audit_status.Sync()
//定时请求open falcon证明自己没挂
//定时请求open falcon证明自己没挂
for
{
for
{
//
pushAlive()
pushAlive
()
time
.
Sleep
(
5
*
time
.
Second
)
time
.
Sleep
(
5
*
time
.
Second
)
}
}
}
}
scm_server
View file @
ba0c881f
The file could not be displayed because it is too large.
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