Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
scm_server
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
fdaedb67
authored
May 15, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复
parent
fe3a7b9d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
25 deletions
cmd/queue/sync_audit_status/main.go
cmd/queue/sync_audit_status/product/product_status_queue.go
configs/config.go
configs/env.go
configs/erp.go
configs/rabbitmq.go
main.go
cmd/queue/sync_audit_status/main.go
View file @
fdaedb67
...
...
@@ -128,7 +128,11 @@ func SyncErpAuditStatus(syncName, billId, json string) (err error) {
if
err
!=
nil
{
return
}
return
CheckBillDataRequest
(
syncName
,
billId
,
res
)
if
syncName
==
"in_store"
{
return
CheckBillDataRequest
(
syncName
,
billId
,
res
)
}
else
{
return
CheckOutStoreBillDataRequest
(
syncName
,
billId
,
res
)
}
}
//检查出入库单申请同步请求的情况
...
...
@@ -164,6 +168,39 @@ func CheckBillDataRequest(syncName, billId string, res *gosoap.Response) (err er
return
errors
.
New
(
"金蝶返回响应格式无法识别"
)
}
//检查出入库单申请同步请求的情况
func
CheckOutStoreBillDataRequest
(
syncName
,
billId
string
,
res
*
gosoap
.
Response
)
(
err
error
)
{
doc
:=
etree
.
NewDocument
()
if
err
=
doc
.
ReadFromBytes
(
res
.
Body
);
err
!=
nil
{
return
}
//没有这个xml节点代表金蝶报错了
root
:=
doc
.
SelectElement
(
"ns1:synOutWarehousAuditResponse"
)
if
root
==
nil
{
return
errors
.
New
(
string
(
res
.
Body
))
}
result
:=
root
.
SelectElement
(
"synOutWarehousAuditReturn"
)
if
result
!=
nil
{
var
responseData
map
[
string
]
string
json
.
Unmarshal
([]
byte
(
result
.
Text
()),
&
responseData
)
for
key
,
value
:=
range
responseData
{
//金蝶判断成功的标志
if
key
==
"0000"
{
if
syncName
==
"in_store"
{
return
logic
.
SyncInStoreErpAuditSuccess
(
billId
)
}
else
{
return
logic
.
SyncOutStoreErpAuditSuccess
(
billId
)
}
}
//金额判断失败的标志
if
key
==
"4444"
{
return
errors
.
New
(
"金蝶返回失败,失败信息为:"
+
value
)
}
}
}
return
errors
.
New
(
"金蝶返回响应格式无法识别"
)
}
func
(
t
*
RecvPro
)
FailAction
(
dataByte
[]
byte
)
error
{
service
.
SendDingTalkRobotToApi
(
fmt
.
Sprintf
(
"存在尝试3次都同步失败的审核队列,队列信息为:%s"
,
string
(
dataByte
)))
return
nil
...
...
cmd/queue/sync_audit_status/product/product_status_queue.go
View file @
fdaedb67
...
...
@@ -7,7 +7,7 @@ import (
)
func
main
()
()
{
message
:=
`{"SyncName":"out_store","Data":{"erp_store_id":"
eRoPxET5QsGpiG\/+k153z++cpps=","box_number":1,"pallet_number":1,"detail":[{"erp_entry_sn":"AJ6EYRbSSICvCxd\/CZeciMLaWpc=","number":"60.0000","box_id":"117","pallet_id":44
}]}}`
message
:=
`{"SyncName":"out_store","Data":{"erp_store_id":"
HZz+KziKSha3qvk\/h22l9e+cpps=","box_number":1,"pallet_number":1,"detail":[{"erp_entry_sn":"6SaHDGNFTWKuhg9sRtzKi8LaWpc=","number":"10.0000","box_id":"126","pallet_id":35
}]}}`
fmt
.
Println
(
message
)
queueExchange
:=
rabbitmq
.
QueueExchange
{
"scm_store_audit_status"
,
...
...
configs/config.go
View file @
fdaedb67
package
configs
import
(
"flag"
"fmt"
"gopkg.in/ini.v1"
"os"
)
var
Cfg
*
ini
.
File
//func init() {
// var err error
// Cfg, err = ini.Load("conf/config.ini")
// if err != nil {
// fmt.Printf("Fail to read file: %v", err)
// os.Exit(1)
// }
//}
func
Setup
(
path
string
){
func
Setup
(
path
string
)
{
var
err
error
//Cfg, err = ini.Load("conf/config.ini")
Cfg
,
err
=
ini
.
Load
(
path
)
if
err
!=
nil
{
fmt
.
Printf
(
"Fail to read file: %v"
,
err
)
os
.
Exit
(
1
)
}
SetUpOne
()
SetUpTwo
()
SetUpThree
()
}
func
GetConfig
(
section
,
name
string
)
string
{
return
Cfg
.
Section
(
section
)
.
Key
(
name
)
.
String
()
}
func
GetPath
(){
var
path
string
flag
.
StringVar
(
&
path
,
"config"
,
"./conf/config.ini"
,
"./conf/config.ini"
)
flag
.
Parse
()
}
configs/env.go
View file @
fdaedb67
...
...
@@ -18,7 +18,7 @@ var ErpLoginStatusApi string
var
OpenFalconPushUrl
string
func
init
()
{
func
SetUpOne
()
{
BasicApiUrl
=
GetConfig
(
"api"
,
"base"
)
OutStoreApiUrl
=
GetConfig
(
"api"
,
"out_store"
)
InStoreApiUrl
=
GetConfig
(
"api"
,
"in_store"
)
...
...
configs/erp.go
View file @
fdaedb67
...
...
@@ -8,7 +8,7 @@ var ErpLanguage string
var
ErpDbType
string
var
ErpAuthPattern
string
func
init
()
{
func
SetUpTwo
()
{
ErpUserName
=
GetConfig
(
"erp"
,
"userName"
)
ErpPassword
=
GetConfig
(
"erp"
,
"password"
)
ErpSlnName
=
GetConfig
(
"erp"
,
"slnName"
)
...
...
configs/rabbitmq.go
View file @
fdaedb67
...
...
@@ -3,6 +3,6 @@ package configs
//const RABBITMQDSN = "amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
var
RABBITMQDSN
string
func
init
()
{
func
SetUpThree
()
{
RABBITMQDSN
=
GetConfig
(
"rabbitmq"
,
"url"
)
}
main.go
View file @
fdaedb67
package
main
import
(
"flag"
"github.com/imroc/req"
"scm_server/cmd/queue/sync_audit_status"
"scm_server/cmd/queue/sync_customer"
"scm_server/cmd/queue/sync_goods"
...
...
@@ -10,8 +12,6 @@ import (
"scm_server/cmd/queue/sync_supplier"
"scm_server/configs"
"time"
"github.com/imroc/req"
)
type
PayloadItem
struct
{
...
...
@@ -52,17 +52,16 @@ func pushAlive() {
}
}
//var (
// ConfFile string // 配置文件路径
//)
func
init
()
{
// main.go -config ./conf/config.ini
//func init() {
// // master -config ./conf/config.ini
// flag.StringVar(&ConfFile, "config", "./conf/config.ini", "./conf/config.ini")
// flag.Parse()
//}
}
func
main
()
{
var
path
string
flag
.
StringVar
(
&
path
,
"config"
,
"./conf/config.ini"
,
"./conf/config.ini"
)
flag
.
Parse
()
configs
.
Setup
(
path
)
go
sync_customer
.
Sync
()
go
sync_supplier
.
Sync
()
go
sync_goods
.
Sync
()
...
...
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