Commit 43f08466 by mushishixian

修改优化

parent 171f4b4d
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)
}
}
package main
package sync_customer
import (
"encoding/json"
......@@ -179,7 +179,7 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
return nil
}
func main() {
func Sync() {
t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{
"store_customer",
......
package main
package sync_customer
import (
"encoding/json"
......
......@@ -183,7 +183,7 @@ func TransformParams(message InStoreMessage) (result req.Param) {
params = make(map[string]interface{})
outStoreDetail = make(map[string]interface{})
for key, entry = range message.Data.FEntrys {
var isInsp, isPrint int
var isInsp, isPrint, isRecordLotAndDC int
if entry.CFIsInsp {
isInsp = 1
} else {
......@@ -194,6 +194,11 @@ func TransformParams(message InStoreMessage) (result req.Param) {
} else {
isPrint = 0
}
if entry.FIsRecordLotAndDC {
isRecordLotAndDC = 1
} else {
isRecordLotAndDC = 2
}
detailPrefix = fmt.Sprintf("detail[%d][", key)
detailMap = map[string]interface{}{
detailPrefix + "erp_entry_sn]": entry.FSourceBillEntryID,
......@@ -205,6 +210,7 @@ func TransformParams(message InStoreMessage) (result req.Param) {
detailPrefix + "goods_unit]": entry.FUnit,
detailPrefix + "is_insp]": isInsp,
detailPrefix + "is_print]": isPrint,
detailPrefix + "is_record_batch_dc]": isRecordLotAndDC,
}
for k, v := range detailMap {
outStoreDetail[k] = v
......
......@@ -124,7 +124,6 @@ func SyncErpDataStatus(syncName, uniqueId string) (err error) {
default:
return errors.New("同步金蝶状态出现非法的同步类型" + syncName)
}
fmt.Println(apiMethod)
soap, err = gosoap.SoapClient(apiUrl)
if err != nil {
return
......
package main
package sync_supplier
import (
"encoding/json"
......@@ -179,7 +179,7 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
return nil
}
func main() {
func Sync() {
t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{
"store_supplier",
......
......@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/service"
"sync"
)
......@@ -26,7 +27,7 @@ func init() {
func Import(wg *sync.WaitGroup) {
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
service.SendDingTalkRobotToApi(fmt.Sprintf("%s", err))
}
wg.Done()
}()
......@@ -41,7 +42,7 @@ func Import(wg *sync.WaitGroup) {
if err != nil {
fmt.Printf("open failed: %s\n", err)
}
i:=0
i := 0
//循环遍历数据
for _, sheet := range xlFile.Sheets {
for key, row := range sheet.Rows {
......
......@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/service"
"sync"
)
......@@ -28,7 +29,7 @@ func init() {
func Import(wg *sync.WaitGroup) {
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
service.SendDingTalkRobotToApi(fmt.Sprintf("%s", err))
}
wg.Done()
}()
......
......@@ -8,6 +8,7 @@ import (
"scm_server/configs"
"scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/service"
"sync"
)
......@@ -28,7 +29,7 @@ func init() {
func Import(wg *sync.WaitGroup) {
defer func() {
if err := recover(); err != nil {
fmt.Println(err)
service.SendDingTalkRobotToApi(fmt.Sprintf("%s", err))
}
wg.Done()
}()
......
......@@ -10,7 +10,10 @@ url = "amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
[api]
base = http://192.168.2.113:40001
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_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
[falcon]
push_url = http://192.168.1.237:1988/v1/push
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
......@@ -33,6 +16,8 @@ var ErpSyncBillStatusApi string
var ErpLoginStatusApi string
var OpenFalconPushUrl string
func init() {
BasicApiUrl = GetConfig("api", "base")
OutStoreApiUrl = GetConfig("api", "out_store")
......@@ -40,4 +25,5 @@ func init() {
ErpSyncBaseDataStatusApi = GetConfig("api", "erp_sync_base_data_status")
ErpSyncBillStatusApi = GetConfig("api", "erp_sync_bill_status")
ErpLoginStatusApi = GetConfig("api", "erp_login_status")
OpenFalconPushUrl = GetConfig("falcon", "push_url")
}
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