feat(erp): 新增做账合同生成功能和数据归档接口
- 在 accounting 模块中新增 Gen 方法用于生成做账合同 - 在 shipment 模块中新增 ArchiveData 方法用于数据归档 - 调整 import 包顺序并优化 rpcx 客户端初始化逻辑 -为 erp服务添加本地调试用的 p2p discovery 配置
This commit is contained in:
@@ -4,14 +4,15 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.kumo.work/shama/service/config"
|
||||
consulClient "git.kumo.work/shama/service/lib/consul"
|
||||
"github.com/smallnest/rpcx/client"
|
||||
"log"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.kumo.work/shama/service/config"
|
||||
consulClient "git.kumo.work/shama/service/lib/consul"
|
||||
"github.com/smallnest/rpcx/client"
|
||||
)
|
||||
|
||||
var mClient = sync.Map{}
|
||||
@@ -60,17 +61,33 @@ func GetClient(s interface{}) (*RpcClient, error) {
|
||||
mutex.Lock()
|
||||
xClient, ok = mClient.Load(key)
|
||||
if !ok {
|
||||
d, err := consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil)
|
||||
if err != nil {
|
||||
return nil, errors.New("系统异常")
|
||||
log.Println(11111111111111111, basePath, servicePath)
|
||||
if basePath == "erp" {
|
||||
//d, err := consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil)
|
||||
d, err := client.NewPeer2PeerDiscovery("tcp@127.0.0.1:8082", "")
|
||||
if err != nil {
|
||||
return nil, errors.New("系统异常")
|
||||
}
|
||||
option := client.DefaultOption
|
||||
option.Retries = 3
|
||||
option.GenBreaker = func() client.Breaker {
|
||||
return client.NewConsecCircuitBreaker(2, 30*time.Second)
|
||||
}
|
||||
xClient = client.NewXClient(servicePath, client.Failover, client.RoundRobin, d, option)
|
||||
mClient.Store(key, xClient)
|
||||
} else {
|
||||
d, err := consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil)
|
||||
if err != nil {
|
||||
return nil, errors.New("系统异常")
|
||||
}
|
||||
option := client.DefaultOption
|
||||
option.Retries = 3
|
||||
option.GenBreaker = func() client.Breaker {
|
||||
return client.NewConsecCircuitBreaker(2, 30*time.Second)
|
||||
}
|
||||
xClient = client.NewXClient(servicePath, client.Failover, client.RoundRobin, d, option)
|
||||
mClient.Store(key, xClient)
|
||||
}
|
||||
option := client.DefaultOption
|
||||
option.Retries = 3
|
||||
option.GenBreaker = func() client.Breaker {
|
||||
return client.NewConsecCircuitBreaker(2, 30*time.Second)
|
||||
}
|
||||
xClient = client.NewXClient(servicePath, client.Failover, client.RoundRobin, d, option)
|
||||
mClient.Store(key, xClient)
|
||||
}
|
||||
mutex.Unlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user