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
43f08466
authored
May 07, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改优化
parent
171f4b4d
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
80 additions
and
29 deletions
cmd/queue/main.go
cmd/queue/sync_customer/main.go
cmd/queue/sync_customer/product.go
cmd/queue/sync_in_store/main.go
cmd/queue/sync_status/main.go
cmd/queue/sync_supplier/main.go
cmd/queue/sync_supplier/product.go → cmd/queue/sync_supplier/product/product.go
cmd/source/customer/customer.go
cmd/source/goods/goods.go
cmd/source/supplier/supplier.go
conf/config.ini
configs/env.go
cmd/queue/main.go
View file @
43f08466
package
main
package
main
import
(
"github.com/imroc/req"
"scm_server/cmd/queue/sync_customer"
"scm_server/cmd/queue/sync_supplier"
"scm_server/configs"
"time"
)
type
PayloadItem
struct
{
Endpoint
string
`json:"endpoint"`
Metric
string
`json:"metric"`
Timestamp
int64
`json:"timestamp"`
Step
int
`json:"step"`
Value
float64
`json:"value"`
CounterType
string
`json:"counter_type"`
Tags
string
`json:"tags"`
}
//定时请求open falcon 证明程序没有挂掉
func
pushAlive
()
{
var
(
payload
[]
PayloadItem
item
PayloadItem
url
string
//resp *req.Resp
err
error
)
item
=
PayloadItem
{
Endpoint
:
"store_sync"
,
Metric
:
"alive_check"
,
Timestamp
:
time
.
Now
()
.
Unix
(),
Step
:
60
,
CounterType
:
"GAUGE"
,
Value
:
float64
(
time
.
Now
()
.
Unix
()),
Tags
:
"store_sync"
,
}
payload
=
append
(
payload
,
item
)
param
:=
req
.
BodyJSON
(
&
payload
)
url
=
configs
.
OpenFalconPushUrl
_
,
err
=
req
.
Post
(
url
,
param
)
if
err
!=
nil
{
panic
(
"push数据到open_falcon失败,原因是:"
+
err
.
Error
())
}
}
func
main
()
{
go
sync_customer
.
Sync
()
go
sync_supplier
.
Sync
()
for
{
pushAlive
()
time
.
Sleep
(
5
*
time
.
Second
)
}
}
cmd/queue/sync_customer/main.go
View file @
43f08466
package
main
package
sync_customer
import
(
import
(
"encoding/json"
"encoding/json"
...
@@ -179,7 +179,7 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
...
@@ -179,7 +179,7 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
return
nil
return
nil
}
}
func
main
()
{
func
Sync
()
{
t
:=
&
RecvPro
{}
t
:=
&
RecvPro
{}
rabbitmq
.
Recv
(
rabbitmq
.
QueueExchange
{
rabbitmq
.
Recv
(
rabbitmq
.
QueueExchange
{
"store_customer"
,
"store_customer"
,
...
...
cmd/queue/sync_customer/product.go
View file @
43f08466
package
main
package
sync_customer
import
(
import
(
"encoding/json"
"encoding/json"
...
...
cmd/queue/sync_in_store/main.go
View file @
43f08466
...
@@ -183,7 +183,7 @@ func TransformParams(message InStoreMessage) (result req.Param) {
...
@@ -183,7 +183,7 @@ func TransformParams(message InStoreMessage) (result req.Param) {
params
=
make
(
map
[
string
]
interface
{})
params
=
make
(
map
[
string
]
interface
{})
outStoreDetail
=
make
(
map
[
string
]
interface
{})
outStoreDetail
=
make
(
map
[
string
]
interface
{})
for
key
,
entry
=
range
message
.
Data
.
FEntrys
{
for
key
,
entry
=
range
message
.
Data
.
FEntrys
{
var
isInsp
,
isPrint
int
var
isInsp
,
isPrint
,
isRecordLotAndDC
int
if
entry
.
CFIsInsp
{
if
entry
.
CFIsInsp
{
isInsp
=
1
isInsp
=
1
}
else
{
}
else
{
...
@@ -194,6 +194,11 @@ func TransformParams(message InStoreMessage) (result req.Param) {
...
@@ -194,6 +194,11 @@ func TransformParams(message InStoreMessage) (result req.Param) {
}
else
{
}
else
{
isPrint
=
0
isPrint
=
0
}
}
if
entry
.
FIsRecordLotAndDC
{
isRecordLotAndDC
=
1
}
else
{
isRecordLotAndDC
=
2
}
detailPrefix
=
fmt
.
Sprintf
(
"detail[%d]["
,
key
)
detailPrefix
=
fmt
.
Sprintf
(
"detail[%d]["
,
key
)
detailMap
=
map
[
string
]
interface
{}{
detailMap
=
map
[
string
]
interface
{}{
detailPrefix
+
"erp_entry_sn]"
:
entry
.
FSourceBillEntryID
,
detailPrefix
+
"erp_entry_sn]"
:
entry
.
FSourceBillEntryID
,
...
@@ -205,6 +210,7 @@ func TransformParams(message InStoreMessage) (result req.Param) {
...
@@ -205,6 +210,7 @@ func TransformParams(message InStoreMessage) (result req.Param) {
detailPrefix
+
"goods_unit]"
:
entry
.
FUnit
,
detailPrefix
+
"goods_unit]"
:
entry
.
FUnit
,
detailPrefix
+
"is_insp]"
:
isInsp
,
detailPrefix
+
"is_insp]"
:
isInsp
,
detailPrefix
+
"is_print]"
:
isPrint
,
detailPrefix
+
"is_print]"
:
isPrint
,
detailPrefix
+
"is_record_batch_dc]"
:
isRecordLotAndDC
,
}
}
for
k
,
v
:=
range
detailMap
{
for
k
,
v
:=
range
detailMap
{
outStoreDetail
[
k
]
=
v
outStoreDetail
[
k
]
=
v
...
...
cmd/queue/sync_status/main.go
View file @
43f08466
...
@@ -124,7 +124,6 @@ func SyncErpDataStatus(syncName, uniqueId string) (err error) {
...
@@ -124,7 +124,6 @@ func SyncErpDataStatus(syncName, uniqueId string) (err error) {
default
:
default
:
return
errors
.
New
(
"同步金蝶状态出现非法的同步类型"
+
syncName
)
return
errors
.
New
(
"同步金蝶状态出现非法的同步类型"
+
syncName
)
}
}
fmt
.
Println
(
apiMethod
)
soap
,
err
=
gosoap
.
SoapClient
(
apiUrl
)
soap
,
err
=
gosoap
.
SoapClient
(
apiUrl
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
...
...
cmd/queue/sync_supplier/main.go
View file @
43f08466
package
main
package
sync_supplier
import
(
import
(
"encoding/json"
"encoding/json"
...
@@ -179,7 +179,7 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
...
@@ -179,7 +179,7 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
return
nil
return
nil
}
}
func
main
()
{
func
Sync
()
{
t
:=
&
RecvPro
{}
t
:=
&
RecvPro
{}
rabbitmq
.
Recv
(
rabbitmq
.
QueueExchange
{
rabbitmq
.
Recv
(
rabbitmq
.
QueueExchange
{
"store_supplier"
,
"store_supplier"
,
...
...
cmd/queue/sync_supplier/product.go
→
cmd/queue/sync_supplier/product
/product
.go
View file @
43f08466
File moved
cmd/source/customer/customer.go
View file @
43f08466
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/model"
"scm_server/internal/service"
"sync"
"sync"
)
)
...
@@ -26,7 +27,7 @@ func init() {
...
@@ -26,7 +27,7 @@ func init() {
func
Import
(
wg
*
sync
.
WaitGroup
)
{
func
Import
(
wg
*
sync
.
WaitGroup
)
{
defer
func
()
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
if
err
:=
recover
();
err
!=
nil
{
fmt
.
Println
(
err
)
service
.
SendDingTalkRobotToApi
(
fmt
.
Sprintf
(
"%s"
,
err
)
)
}
}
wg
.
Done
()
wg
.
Done
()
}()
}()
...
@@ -41,7 +42,7 @@ func Import(wg *sync.WaitGroup) {
...
@@ -41,7 +42,7 @@ func Import(wg *sync.WaitGroup) {
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"open failed: %s
\n
"
,
err
)
fmt
.
Printf
(
"open failed: %s
\n
"
,
err
)
}
}
i
:=
0
i
:=
0
//循环遍历数据
//循环遍历数据
for
_
,
sheet
:=
range
xlFile
.
Sheets
{
for
_
,
sheet
:=
range
xlFile
.
Sheets
{
for
key
,
row
:=
range
sheet
.
Rows
{
for
key
,
row
:=
range
sheet
.
Rows
{
...
...
cmd/source/goods/goods.go
View file @
43f08466
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/model"
"scm_server/internal/service"
"sync"
"sync"
)
)
...
@@ -28,7 +29,7 @@ func init() {
...
@@ -28,7 +29,7 @@ func init() {
func
Import
(
wg
*
sync
.
WaitGroup
)
{
func
Import
(
wg
*
sync
.
WaitGroup
)
{
defer
func
()
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
if
err
:=
recover
();
err
!=
nil
{
fmt
.
Println
(
err
)
service
.
SendDingTalkRobotToApi
(
fmt
.
Sprintf
(
"%s"
,
err
)
)
}
}
wg
.
Done
()
wg
.
Done
()
}()
}()
...
...
cmd/source/supplier/supplier.go
View file @
43f08466
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/model"
"scm_server/internal/service"
"sync"
"sync"
)
)
...
@@ -28,7 +29,7 @@ func init() {
...
@@ -28,7 +29,7 @@ func init() {
func
Import
(
wg
*
sync
.
WaitGroup
)
{
func
Import
(
wg
*
sync
.
WaitGroup
)
{
defer
func
()
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
if
err
:=
recover
();
err
!=
nil
{
fmt
.
Println
(
err
)
service
.
SendDingTalkRobotToApi
(
fmt
.
Sprintf
(
"%s"
,
err
)
)
}
}
wg
.
Done
()
wg
.
Done
()
}()
}()
...
...
conf/config.ini
View file @
43f08466
...
@@ -10,7 +10,10 @@ url = "amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
...
@@ -10,7 +10,10 @@ url = "amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
[api]
[api]
base
=
http://192.168.2.113:40001
base
=
http://192.168.2.113:40001
out_store
=
http://192.168.2.179:40003
out_store
=
http://192.168.2.179:40003
in_store
=
http://192.168.2.239:40004
"
in_store
=
http://192.168.2.239: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
[falcon]
push_url
=
http://192.168.1.237:1988/v1/push
configs/env.go
View file @
43f08466
package
configs
package
configs
////基础物料服务的地址
//const BasicApiUrl = "http://192.168.2.113:40001"
//
////出库服务的地址
//const OutStoreApiUrl = "http://192.168.2.179:40003"
//
////出库服务的地址
//const InStoreApiUrl = "http://192.168.2.239:40004"
//
//
////金蝶同步状态接口
//const ErpSyncBaseDataStatusApi = "http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl"
//
//const ErpSyncBillStatusApi = "http://192.168.2.253:6888/ormrpc/services/WSInventoryManagementFacade?wsdl"
//
//const ErpLoginStatusApi = "http://192.168.2.253:6888/ormrpc/services/EASLogin?wsdl"
//基础物料服务的地址
//基础物料服务的地址
var
BasicApiUrl
string
var
BasicApiUrl
string
...
@@ -33,6 +16,8 @@ var ErpSyncBillStatusApi string
...
@@ -33,6 +16,8 @@ var ErpSyncBillStatusApi string
var
ErpLoginStatusApi
string
var
ErpLoginStatusApi
string
var
OpenFalconPushUrl
string
func
init
()
{
func
init
()
{
BasicApiUrl
=
GetConfig
(
"api"
,
"base"
)
BasicApiUrl
=
GetConfig
(
"api"
,
"base"
)
OutStoreApiUrl
=
GetConfig
(
"api"
,
"out_store"
)
OutStoreApiUrl
=
GetConfig
(
"api"
,
"out_store"
)
...
@@ -40,4 +25,5 @@ func init() {
...
@@ -40,4 +25,5 @@ func init() {
ErpSyncBaseDataStatusApi
=
GetConfig
(
"api"
,
"erp_sync_base_data_status"
)
ErpSyncBaseDataStatusApi
=
GetConfig
(
"api"
,
"erp_sync_base_data_status"
)
ErpSyncBillStatusApi
=
GetConfig
(
"api"
,
"erp_sync_bill_status"
)
ErpSyncBillStatusApi
=
GetConfig
(
"api"
,
"erp_sync_bill_status"
)
ErpLoginStatusApi
=
GetConfig
(
"api"
,
"erp_login_status"
)
ErpLoginStatusApi
=
GetConfig
(
"api"
,
"erp_login_status"
)
OpenFalconPushUrl
=
GetConfig
(
"falcon"
,
"push_url"
)
}
}
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