Commit b8888b6d by mushishixian

修复bug

parent 2e4514cf
......@@ -50,7 +50,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
goto ERR
}
if message.SyncName == "in_store" || message.SyncName == "out_store"{
if message.SyncName == "in_store" || message.SyncName == "out_store" {
//得到入库数据以后,去组装金蝶需要的数据
storeErpData = map[string]interface{}{
"FSourceBillID": message.Data.ErpStoreId,
......@@ -67,9 +67,12 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
})
}
storeErpData["FEntrys"] = inStoreErpGoods
fmt.Println(storeErpData)
jsonByte, _ = json.Marshal(storeErpData)
}
//出入库金蝶那边可能会延迟,所以要进行延迟推送
if message.SyncName == "in_store" || message.SyncName == "out_store" {
time.Sleep(5 * time.Second)
}
//得到message以后,去请求金蝶的接口
if err = SyncErpAuditStatus(message.SyncName, message.Data.ErpStoreId, string(jsonByte)); err != nil {
goto ERR
......@@ -161,7 +164,7 @@ func CheckBillDataRequest(syncName, billId string, res *gosoap.Response) (err er
}
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
service.SendDingTalkRobotToApi(fmt.Sprintf("存在尝试3次都同步失败的审核队列,队列信息为:%s", string(dataByte)))
return nil
}
......
......@@ -9,6 +9,10 @@ import (
func main() () {
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"}}`
message = `{"SyncName":"out_store","Data":{"erp_store_id":"Ncx3gMUSSEml7z2jL1\/p\/u+cpps=","box_number":1,"pallet_number":0,"detail":[{"erp_entry_sn":"123131","number":"25.0000","box_id":"39","pallet_id":0}]}}`
message = `{"SyncName":"in_store","Data":{"erp_store_id":"ibn\/BoPESE+jP5olU7sjl8BZJbY=","detail":[{"number":"100.0000","erp_entry_sn":"Nn9vCo1nRNip2jzdHLDN0e0oFFw=","country":"127"}],"pallet_number":1,"pallet_weight":"0.0000","box_number":1,"box_weight":"0.0000"}}`
message = `{"SyncName":"in_store","Data":{"erp_store_id":"MYDb7OZMQeS6cSN7TO8r+sBZJbY=","detail":[{"number":"200.0000","erp_entry_sn":"RbAldie8SiGLuPFp5WvY9e0oFFw=","country":"107"}],"pallet_number":0,"pallet_weight":"0","box_number":1,"box_weight":"0.0000"}}`
message = `{"SyncName":"in_store","Data":{"erp_store_id":"aou1scjXStuIAw4aB7m1rMBZJbY=","detail":[{"number":"200.0000","erp_entry_sn":"qpnQLQvyRyKQBttqm9YmAO0oFFw=","country":"112"}],"pallet_number":0,"pallet_weight":"0","box_number":1,"box_weight":"0.0000"}}`
message = `{"SyncName":"in_store","Data":{"erp_store_id":"aou1scjXStuIAw4aB7m1rMBZJbY=","detail":[{"number":"200.0000","erp_entry_sn":"qpnQLQvyRyKQBttqm9YmAO0oFFw=","country":"112"}],"pallet_number":0,"pallet_weight":"0","box_number":1,"box_weight":"0.0000"}}`
fmt.Println(message)
queueExchange := rabbitmq.QueueExchange{
"store_audit_status",
......
......@@ -58,6 +58,7 @@ func main() {
}
body := string(data)
body = `{"type":"save","data":{"FEntrustBillNo":"B05438","FWarehouseNo":"002","FDeliveryTypeNo":"deliveryTerms0003","FPrincipalNo":"WT00683","FSourceBillID":"7aJKpxihRW+LqF7MXDosLO+cpps=","FEntrys":[{"FQty":20,"FSourceBillEntryID":"EYTqfK7nT46e1Ek63QR6dcLaWpc=","FMaterialID":"Hcew0urxRmKVS4bYh6rDQ0QJ5/A=","FUnit":"\u4E2A","FBrand":"BRAND","FOriginCountry":"115","CFIsInsp":false,"FPrice":3.0045,"FGoods":"\u7535\u78C1\u5E72\u6270\u6EE4\u6CE2\u5668","FModel":"sfg"}],"FIsCustoms":true,"FErpPostRequistionBillNo":"FKFH202005147729"}}`
body = `{"Type":"save","Data":{"FWarehouseNo":"002","FErpPostRequistionBillNo":"FKFH202005147730","FIsCustoms":true,"FSourceBillID":"eRoPxET5QsGpiG/+k153z++cpps=","FRecPerson":"","FPrincipalNo":"WT00655","FDeliveryTypeNo":"deliveryTerms0001","FRecPersonContact":"","FRecPersonAddress":"","Remark":"","FEntrustBillNo":"B05448","FEntrys":[{"FQty":60,"FMaterialID":"LBQDhMUhQF2WFB20c54Qu0QJ5/A=","FBrand":"JST","FPrice":5.0077,"FSourceBillEntryID":"AJ6EYRbSSICvCxd/CZeciMLaWpc=","FModel":"04CPT-B1-2A","FGoods":"二极管","FUnit":"个","CFIsInsp":false,"Fremark":"","FOriginCountry":"137"}]}}`
queueExchange := rabbitmq.QueueExchange{
"store_out",
"store_out",
......
......@@ -33,6 +33,11 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
if err = json.Unmarshal(dataByte, &message); err != nil {
goto ERR
}
//出入库金蝶那边可能会延迟,所以要进行延迟推送
if message.SyncName == "inStore" || message.SyncName == "outStore" {
time.Sleep(5 * time.Second)
}
fmt.Println(message.SyncName)
//得到message以后,去请求金蝶的接口
if err = SyncErpDataStatus(message.SyncName, message.ErpId); err != nil {
goto ERR
......@@ -50,6 +55,10 @@ ERR:
}
logic.LogError(syncStatusLog.SyncError)
service.SendDingTalkRobotToApi(syncStatusLog.SyncError)
//出入库金蝶那边可能会延迟,所以要进行重试
if message.SyncName == "inStore" || message.SyncName == "outStore" {
return errors.New("重试错误")
}
return nil
}
......@@ -183,7 +192,7 @@ func CheckBillDataRequest(syncName, uniqueId string, res *gosoap.Response) (err
}
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
service.SendDingTalkRobotToApi(fmt.Sprintf("存在尝试3次都同步失败的审核队列,队列信息为:%s", string(dataByte)))
return nil
}
......
......@@ -11,7 +11,7 @@ import (
)
func init() {
logs.SetLogger(logs.AdapterFile,`{"filename":"logs/error.log","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":10,"color":true}`)
logs.SetLogger(logs.AdapterFile, `{"filename":"logs/error.log","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":10,"color":true}`)
logs.Async()
}
......@@ -29,6 +29,7 @@ func LogError(msg string) {
}
func DealSyncError(dataByte []byte, uniqueId, syncName string, err error) error {
go func() {
//还要存到一个统一错误表
syncLog := model.SyncLog{
AddTime: time.Now().Unix(),
......@@ -48,5 +49,6 @@ func DealSyncError(dataByte []byte, uniqueId, syncName string, err error) error
//保存日志
logs.Error(fmt.Sprintf("%s", string(msg)))
}()
return nil
}
......@@ -56,7 +56,6 @@ func SendDingTalkRobotToApi(content string) {
}
func SendDingTalkRobotToApi1(content string) {
go func() {
var (
requestData DingDingRequest
apiUrl, token string
......@@ -77,5 +76,4 @@ func SendDingTalkRobotToApi1(content string) {
if err != nil {
fmt.Println(err)
}
}()
}
......@@ -20,7 +20,7 @@ type PayloadItem struct {
Timestamp int64 `json:"timestamp"`
Step int `json:"step"`
Value float64 `json:"value"`
CounterType string `json:"counter_type"`
CounterType string `json:"counterType"`
Tags string `json:"tags"`
}
......@@ -34,16 +34,18 @@ func pushAlive() {
err error
)
item = PayloadItem{
Endpoint: "store_sync",
Metric: "alive_check",
Endpoint: "wms-server",
Metric: "scm_wms_server",
Timestamp: time.Now().Unix(),
Step: 60,
CounterType: "GAUGE",
Value: float64(time.Now().Unix()),
Tags: "service=store_sync",
Value: 1,
Tags: "type=check_alive/sync",
}
payload = append(payload, item)
param := req.BodyJSON(&payload)
//temp,_:=json.Marshal(payload)
//fmt.Println(string(temp))
req.Debug = false
url = configs.OpenFalconPushUrl
_, err = req.Post(url, param)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment