diff --git a/client/client.go b/client/client.go index d6c189e..09a65c5 100644 --- a/client/client.go +++ b/client/client.go @@ -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() } diff --git a/erp/accounting.go b/erp/accounting.go index 68ad03d..c1c0ffa 100644 --- a/erp/accounting.go +++ b/erp/accounting.go @@ -2,11 +2,12 @@ package erp import ( "context" + "time" + "git.kumo.work/shama/service/client" accounting2 "git.kumo.work/shama/service/erp/accounting" "git.kumo.work/shama/service/lib/bean" "github.com/shopspring/decimal" - "time" ) type accounting struct { @@ -98,6 +99,16 @@ func (a *accounting) Add(ctx context.Context, args ArgsAccountingAdd) (accountId return } +// Gen @TITLE 生成做账合同 +func (a *accounting) Gen(ctx context.Context, shipmentId int64) (err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Gen", shipmentId, &reply) +} + type ReplyAccountingInfo struct { Id int64 `json:"id"` CustomId int64 `json:"customId"` diff --git a/erp/shipment.go b/erp/shipment.go index 9a58b8a..05fb70b 100644 --- a/erp/shipment.go +++ b/erp/shipment.go @@ -2,12 +2,13 @@ package erp import ( "context" + "time" + "git.kumo.work/shama/service/client" bean2 "git.kumo.work/shama/service/erp/bean" shipment2 "git.kumo.work/shama/service/erp/shipment" "git.kumo.work/shama/service/lib/bean" "github.com/shopspring/decimal" - "time" ) type shipment struct { @@ -261,3 +262,13 @@ func (s *shipment) Clone(ctx context.Context, args ArgsShipmentClone) (reply int err = xClient.Call(ctx, "Clone", args, &reply) return } + +// ArchiveData @TITLE 归档 +func (s *shipment) ArchiveData(ctx context.Context, shipmentIds []int64) (reply int64, err error) { + xClient, err := client.GetClient(s) + if err != nil { + return + } + err = xClient.Call(ctx, "ArchiveData", shipmentIds, &reply) + return +}