瀏覽代碼

数据上限处理

WH01243 1 年之前
父節點
當前提交
f3383b1fa3

+ 8 - 8
api/biService.api

@@ -3,7 +3,7 @@ syntax = "v1"
 type (
 	biResp {
 		Error_code int64       `json:"error_code"` //响应代码
-		Error_msg  string      `json:"error_msg"` //响应消息
+		Error_msg  string      `json:"error_msg"`  //响应消息
 		Data       interface{} `json:"data"`
 	}
 	myDataAssetReq {
@@ -42,11 +42,12 @@ type (
 		IsTask     int64                    `json:"isTask"`
 	}
 	DistributeClueShowReq {
-		ClueIdList string                   `json:"clueIdList"`
-		Datas      []map[string]interface{} `json:"datas"`
-		PositionId int64                    `header:"positionId,optional"`
-		IsTask     int64                    `json:"isTask"`
-		DataType   int64                    `json:"dataType"`
+		ClueIdList       string                   `json:"clueIdList"`
+		Datas            []map[string]interface{} `json:"datas"`
+		PositionId       int64                    `header:"positionId,optional"`
+		IsTask           int64                    `json:"isTask"`
+		DataType         int64                    `json:"dataType"`
+		UpdataPositionID int64                    `json:"updataPositionID"`
 	}
 	ClueImportReq {
 		PositionId int64  `header:"positionId,optional"`
@@ -190,5 +191,4 @@ service biService-api {
 	@doc "附件上传"
 	@handler upFile
 	post /biService/upFile (UpFileReq) returns (biResp)
-}
-
+}

+ 6 - 5
api/internal/logic/distributeclueshowlogic.go

@@ -36,11 +36,12 @@ func (l *DistributeClueShowLogic) DistributeClueShow(req *types.DistributeClueSh
 		datas = append(datas, data)
 	}
 	res, err := l.svcCtx.BiServiceRpc.DistributeClueShow(l.ctx, &biservice.DistributeClueShowReq{
-		DataType:   req.DataType,
-		ClueIdList: req.ClueIdList,
-		PositionId: req.PositionId,
-		Datas:      datas,
-		IsTask:     req.IsTask,
+		DataType:         req.DataType,
+		ClueIdList:       req.ClueIdList,
+		PositionId:       req.PositionId,
+		Datas:            datas,
+		IsTask:           req.IsTask,
+		UpdataPositionID: req.UpdataPositionID,
 	})
 	return &types.BiResp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: res.Data}, err
 }

+ 85 - 84
api/internal/types/types.go

@@ -1,6 +1,67 @@
 // Code generated by goctl. DO NOT EDIT.
 package types
 
+type BiResp struct {
+	Error_code int64       `json:"error_code"` //响应代码
+	Error_msg  string      `json:"error_msg"`  //响应消息
+	Data       interface{} `json:"data"`
+}
+
+type MyDataAssetReq struct {
+	UserId    string `header:"userId,optional"`
+	NewUserId int64  `header:"newUserId,optional"`
+	EntUserId int64  `header:"entUserId,optional"`
+}
+
+type AddProjectReq struct {
+	PositionId   int64  `header:"positionId,optional"`
+	Source       int64  `json:"source,optional"`
+	InfoId       string `json:"info_id,optional"`
+	PositionType int64  `header:"positionType,optional"`
+	AccountId    int64  `header:"accountId,optional"`
+	CompanyName  string `header:"entName,optional"`
+	UserName     string `header:"userName,optional"`
+	UserId       int64  `header:"newUserId,optional"`
+	EntId        int64  `header:"entId,optional"`
+	EntUserName  string `header:"entUserName,optional"`
+}
+
+type GetInfoIdReq struct {
+	PositionId int64 `header:"positionId,optional"`
+}
+
+type DrawClueReq struct {
+	PositionId int64 `header:"positionId,optional"`
+	Count      int64 `json:"count,optional"`
+}
+
+type CallReq struct {
+	PositionId int64  `header:"positionId,optional"`
+	Phone      string `json:"phone"`
+}
+
+type DistributeClueReq struct {
+	ClueCount  string                   `json:"clueCount"`
+	ClueIdList []int64                  `json:"clueIdList"`
+	Datas      []map[string]interface{} `json:"datas"`
+	PositionId int64                    `header:"positionId,optional"`
+	IsTask     int64                    `json:"isTask"`
+}
+
+type DistributeClueShowReq struct {
+	ClueIdList       string                   `json:"clueIdList"`
+	Datas            []map[string]interface{} `json:"datas"`
+	PositionId       int64                    `header:"positionId,optional"`
+	IsTask           int64                    `json:"isTask"`
+	DataType         int64                    `json:"dataType"`
+	UpdataPositionID int64                    `json:"updataPositionID"`
+}
+
+type ClueImportReq struct {
+	PositionId int64  `header:"positionId,optional"`
+	Pcbh       string `json:"pcbh"`
+}
+
 type ClueAddReq struct {
 	Phone            string `json:"phone"`
 	Username         string `json:"username,optional"`
@@ -18,34 +79,27 @@ type ClueAddReq struct {
 	CustomerBudget   string `json:"customerBudget,optional"`
 }
 
-type ClueImportReq struct {
-	PositionId int64  `header:"positionId,optional"`
-	Pcbh       string `json:"pcbh"`
+type SqlManageReq struct {
+	Id     float64 `json:"id"`
+	Params []Param `json:"params"`
 }
 
-type DistributeClueReq struct {
-	ClueCount  string                   `json:"clueCount"`
-	ClueIdList []int64                  `json:"clueIdList"`
-	Datas      []map[string]interface{} `json:"datas"`
-	PositionId int64                    `header:"positionId,optional"`
-	IsTask     int64                    `json:"isTask"`
+type Param struct {
+	Value string `json:"value"`
+	Type  string `json:"type"`
 }
 
-type DistributeClueShowReq struct {
-	ClueIdList string                   `json:"clueIdList"`
-	Datas      []map[string]interface{} `json:"datas"`
-	PositionId int64                    `header:"positionId,optional"`
-	IsTask     int64                    `json:"isTask"`
-	DataType   int64                    `json:"dataType"`
+type MyInfoReq struct {
+	Bid string `json:"bid,optional"`
+	Sid string `json:"sid"`
 }
 
-type ExportByDbReq struct {
-	Token   string `json:"token"`
-	Title   string `json:"title"`
-	Content string `json:"content"`
-	Mails   string `json:"mails"`
-	Query   string `json:"query"`
-	Stype   string `json:"stype"`
+type ResEmpowerReq struct {
+	EntId        int64  `header:"entId"`
+	ReqType      int64  `json:"reqType"`
+	FunctionCode string `json:"functionCode"`
+	EntUserId    string `json:"entUserId"`
+	PositionId   string `json:"positionId"`
 }
 
 type ExportReq struct {
@@ -54,32 +108,22 @@ type ExportReq struct {
 	PositionId int64    `header:"positionId,optional"`
 }
 
-type MyInfoReq struct {
-	Bid string `json:"bid,optional"`
-	Sid string `json:"sid"`
-}
-
 type OperateReq struct {
 	NewId string `json:"newId"`
 	Type  int64  `json:"type"`
 }
 
-type Param struct {
-	Value string `json:"value"`
-	Type  string `json:"type"`
-}
-
-type ResEmpowerReq struct {
-	EntId        int64  `header:"entId"`
-	ReqType      int64  `json:"reqType"`
-	FunctionCode string `json:"functionCode"`
-	EntUserId    string `json:"entUserId"`
-	PositionId   string `json:"positionId"`
+type GetCompanyTypeReq struct {
+	CompanyName string `json:"companyName"`
 }
 
-type SqlManageReq struct {
-	Id     float64 `json:"id"`
-	Params []Param `json:"params"`
+type ExportByDbReq struct {
+	Token   string `json:"token"`
+	Title   string `json:"title"`
+	Content string `json:"content"`
+	Mails   string `json:"mails"`
+	Query   string `json:"query"`
+	Stype   string `json:"stype"`
 }
 
 type UpFileReq struct {
@@ -90,46 +134,3 @@ type UpFileReq struct {
 	EntId      int64  `header:"entId,optional"`
 	FileType   string `form:"fileType"`
 }
-
-type AddProjectReq struct {
-	PositionId   int64  `header:"positionId,optional"`
-	Source       int64  `json:"source,optional"`
-	InfoId       string `json:"info_id,optional"`
-	PositionType int64  `header:"positionType,optional"`
-	AccountId    int64  `header:"accountId,optional"`
-	CompanyName  string `header:"entName,optional"`
-	UserName     string `header:"userName,optional"`
-	UserId       int64  `header:"newUserId,optional"`
-	EntId        int64  `header:"entId,optional"`
-	EntUserName  string `header:"entUserName,optional"`
-}
-
-type BiResp struct {
-	Error_code int64       `json:"error_code"` //响应代码
-	Error_msg  string      `json:"error_msg"`  //响应消息
-	Data       interface{} `json:"data"`
-}
-
-type CallReq struct {
-	PositionId int64  `header:"positionId,optional"`
-	Phone      string `json:"phone"`
-}
-
-type DrawClueReq struct {
-	PositionId int64 `header:"positionId,optional"`
-	Count      int64 `json:"count,optional"`
-}
-
-type GetCompanyTypeReq struct {
-	CompanyName string `json:"companyName"`
-}
-
-type GetInfoIdReq struct {
-	PositionId int64 `header:"positionId,optional"`
-}
-
-type MyDataAssetReq struct {
-	UserId    string `header:"userId,optional"`
-	NewUserId int64  `header:"newUserId,optional"`
-	EntUserId int64  `header:"entUserId,optional"`
-}

+ 2 - 0
rpc/biService.proto

@@ -163,6 +163,7 @@ message DistributeClueShowReq {
 	string clueIdList = 3;
 	repeated DistributeClueShows datas = 4;
 	int64 IsTask = 5;
+	int64 UpdataPositionID=6;
 }
 
 message DistributeClueShows {
@@ -175,6 +176,7 @@ message DistributeClueShowss {
 	int64 clueCount = 3;
 	int64 minCount = 4;
 	int64 companyCounts = 5;
+	int64 existingCount=6;
 }
 
 message DistributeClueShowResp {

+ 23 - 25
rpc/biservice.go

@@ -5,7 +5,7 @@ package main
 
 import (
 	"bp.jydev.jianyu360.cn/BaseService/biService/entity"
-	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/config"
+	IC "bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/config"
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/server"
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
@@ -24,46 +24,44 @@ var configFile = flag.String("f", "etc/biservice.yaml", "the config file")
 func main() {
 	flag.Parse()
 
-	var c config.Config
-
-	conf.MustLoad(*configFile, &c)
-	ctx := svc.NewServiceContext(c)
+	conf.MustLoad(*configFile, &IC.IC)
+	ctx := svc.NewServiceContext(IC.IC)
 	srv := server.NewBiServiceServer(ctx)
-	logx.MustSetup(c.Logx)
-	entity.PublicKey = c.PublicKey
-	entity.InitMysql(c.Mysql.JianYu, c.Mysql.JyDoc, c.Mysql.Bi, c.Mysql.Tidb, c.Mysql.BiTidb, c.Mysql.CallTidb, c.Mysql.BiService)
-	entity.InitMail(c.Mail)
-	entity.InitMongo(c.Mongo.Qfw.MongodbAddr, c.Mongo.Qfw.DbName, c.Mongo.Qfw.Size)
-	entity.InitBiddingMgo(c.Mongo.Bidding.MongodbAddr, c.Mongo.Bidding.DbName, c.Mongo.Bidding.UserName, c.Mongo.Bidding.Password, c.Mongo.Bidding.Size)
-	entity.InitQyxyMgo(c.Mongo.Qyxy.MongodbAddr, c.Mongo.Qyxy.DbName, c.Mongo.Qyxy.UserName, c.Mongo.Qyxy.Password, c.Mongo.Qyxy.Size)
-	entity.InitEs(c.Es.Version, c.Es.Address, c.Es.UserName, c.Es.Password, c.Es.DbSize)
-	entity.InitEntEs(c.EntEs.Version, c.EntEs.Address, c.EntEs.UserName, c.EntEs.Password, c.EntEs.DbSize)
+	logx.MustSetup(IC.IC.Logx)
+	entity.PublicKey = IC.IC.PublicKey
+	entity.InitMysql(IC.IC.Mysql.JianYu, IC.IC.Mysql.JyDoc, IC.IC.Mysql.Bi, IC.IC.Mysql.Tidb, IC.IC.Mysql.BiTidb, IC.IC.Mysql.CallTidb, IC.IC.Mysql.BiService)
+	entity.InitMail(IC.IC.Mail)
+	entity.InitMongo(IC.IC.Mongo.Qfw.MongodbAddr, IC.IC.Mongo.Qfw.DbName, IC.IC.Mongo.Qfw.Size)
+	entity.InitBiddingMgo(IC.IC.Mongo.Bidding.MongodbAddr, IC.IC.Mongo.Bidding.DbName, IC.IC.Mongo.Bidding.UserName, IC.IC.Mongo.Bidding.Password, IC.IC.Mongo.Bidding.Size)
+	entity.InitQyxyMgo(IC.IC.Mongo.Qyxy.MongodbAddr, IC.IC.Mongo.Qyxy.DbName, IC.IC.Mongo.Qyxy.UserName, IC.IC.Mongo.Qyxy.Password, IC.IC.Mongo.Qyxy.Size)
+	entity.InitEs(IC.IC.Es.Version, IC.IC.Es.Address, IC.IC.Es.UserName, IC.IC.Es.Password, IC.IC.Es.DbSize)
+	entity.InitEntEs(IC.IC.EntEs.Version, IC.IC.EntEs.Address, IC.IC.EntEs.UserName, IC.IC.EntEs.Password, IC.IC.EntEs.DbSize)
 	entity.InitArea()
-	entity.InitRedis(c.RedisAddress)
-	entity.InitConfig(c.ExportDirectory, c.ComFileDir, c.UpdateProjectUrl, c.ExportUrl, c.ComFileUrl, c.ExportCount)
+	entity.InitRedis(IC.IC.RedisAddress)
+	entity.InitConfig(IC.IC.ExportDirectory, IC.IC.ComFileDir, IC.IC.UpdateProjectUrl, IC.IC.ExportUrl, IC.IC.ComFileUrl, IC.IC.ExportCount)
 	//合力亿捷
-	entity.GetHlyj(c.Hlyj.Appid, c.Hlyj.Account, c.Hlyj.Secret, c.Hlyj.TokenUrl, c.Hlyj.CallUrl, c.Hlyj.Integratedid, c.Hlyj.CallFlag)
-	entity.InitMiddleground(c.RpcServerConf.Etcd.Hosts, c.ResourceCenterKey)
+	entity.GetHlyj(IC.IC.Hlyj.Appid, IC.IC.Hlyj.Account, IC.IC.Hlyj.Secret, IC.IC.Hlyj.TokenUrl, IC.IC.Hlyj.CallUrl, IC.IC.Hlyj.Integratedid, IC.IC.Hlyj.CallFlag)
+	entity.InitMiddleground(IC.IC.RpcServerConf.Etcd.Hosts, IC.IC.ResourceCenterKey)
 
-	entity.FileCenterRpc = filecenter.NewFileCenter(zrpc.MustNewClient(c.FileCenterRpc))
-	entity.OssBucketName = c.OssBucketName
-	entity.OssUrl = c.OssUrl
+	entity.FileCenterRpc = filecenter.NewFileCenter(zrpc.MustNewClient(IC.IC.FileCenterRpc))
+	entity.OssBucketName = IC.IC.OssBucketName
+	entity.OssUrl = IC.IC.OssUrl
 	//nsq
 	config := nsq.NewConfig()
-	consumer, err := nsq.NewConsumer(c.TopicName, "jy_position_sync", config)
+	consumer, err := nsq.NewConsumer(IC.IC.TopicName, "jy_position_sync", config)
 	if err != nil {
 		fmt.Println(err)
 	}
 	consumer.AddHandler(&entity.Handler{})
-	err = consumer.ConnectToNSQLookupd(c.NsqUrl)
+	err = consumer.ConnectToNSQLookupd(IC.IC.NsqUrl)
 	if err != nil {
 		fmt.Println(err)
 	}
-	s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
+	s := zrpc.MustNewServer(IC.IC.RpcServerConf, func(grpcServer *grpc.Server) {
 		pb.RegisterBiServiceServer(grpcServer, srv)
 	})
 	defer s.Stop()
 
-	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
+	fmt.Printf("Starting rpc server at %s...\n", IC.IC.ListenOn)
 	s.Start()
 }

+ 3 - 0
rpc/internal/config/config.go

@@ -6,6 +6,8 @@ import (
 	"github.com/zeromicro/go-zero/zrpc"
 )
 
+var IC Config
+
 type Config struct {
 	zrpc.RpcServerConf
 	UserCenterRpc zrpc.RpcClientConf
@@ -88,4 +90,5 @@ type Config struct {
 	ResourceCenterKey string
 	OssBucketName     string
 	OssUrl            string
+	AllocationCap     int64
 }

+ 2 - 1
rpc/internal/logic/distributeclueshowlogic.go

@@ -1,6 +1,7 @@
 package logic
 
 import (
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/config"
 	"context"
 
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
@@ -26,5 +27,5 @@ func NewDistributeClueShowLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 func (l *DistributeClueShowLogic) DistributeClueShow(in *pb.DistributeClueShowReq) (*pb.DistributeClueShowResp, error) {
 	// todo: add your logic here and delete this line
 
-	return service.DistributeClueShow(in), nil
+	return service.DistributeClueShow(in, config.IC.AllocationCap), nil
 }

+ 133 - 112
rpc/pb/biService.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.32.0
-// 	protoc        v4.25.2
+// 	protoc-gen-go v1.31.0
+// 	protoc        v3.15.1
 // source: biService.proto
 
 package pb
@@ -1625,11 +1625,12 @@ type DistributeClueShowReq struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	PositionId int64                  `protobuf:"varint,1,opt,name=positionId,proto3" json:"positionId,omitempty"`
-	DataType   int64                  `protobuf:"varint,2,opt,name=dataType,proto3" json:"dataType,omitempty"`
-	ClueIdList string                 `protobuf:"bytes,3,opt,name=clueIdList,proto3" json:"clueIdList,omitempty"`
-	Datas      []*DistributeClueShows `protobuf:"bytes,4,rep,name=datas,proto3" json:"datas,omitempty"`
-	IsTask     int64                  `protobuf:"varint,5,opt,name=IsTask,proto3" json:"IsTask,omitempty"`
+	PositionId       int64                  `protobuf:"varint,1,opt,name=positionId,proto3" json:"positionId,omitempty"`
+	DataType         int64                  `protobuf:"varint,2,opt,name=dataType,proto3" json:"dataType,omitempty"`
+	ClueIdList       string                 `protobuf:"bytes,3,opt,name=clueIdList,proto3" json:"clueIdList,omitempty"`
+	Datas            []*DistributeClueShows `protobuf:"bytes,4,rep,name=datas,proto3" json:"datas,omitempty"`
+	IsTask           int64                  `protobuf:"varint,5,opt,name=IsTask,proto3" json:"IsTask,omitempty"`
+	UpdataPositionID int64                  `protobuf:"varint,6,opt,name=UpdataPositionID,proto3" json:"UpdataPositionID,omitempty"`
 }
 
 func (x *DistributeClueShowReq) Reset() {
@@ -1699,6 +1700,13 @@ func (x *DistributeClueShowReq) GetIsTask() int64 {
 	return 0
 }
 
+func (x *DistributeClueShowReq) GetUpdataPositionID() int64 {
+	if x != nil {
+		return x.UpdataPositionID
+	}
+	return 0
+}
+
 type DistributeClueShows struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -1764,6 +1772,7 @@ type DistributeClueShowss struct {
 	ClueCount     int64 `protobuf:"varint,3,opt,name=clueCount,proto3" json:"clueCount,omitempty"`
 	MinCount      int64 `protobuf:"varint,4,opt,name=minCount,proto3" json:"minCount,omitempty"`
 	CompanyCounts int64 `protobuf:"varint,5,opt,name=companyCounts,proto3" json:"companyCounts,omitempty"`
+	ExistingCount int64 `protobuf:"varint,6,opt,name=existingCount,proto3" json:"existingCount,omitempty"`
 }
 
 func (x *DistributeClueShowss) Reset() {
@@ -1833,6 +1842,13 @@ func (x *DistributeClueShowss) GetCompanyCounts() int64 {
 	return 0
 }
 
+func (x *DistributeClueShowss) GetExistingCount() int64 {
+	if x != nil {
+		return x.ExistingCount
+	}
+	return 0
+}
+
 type DistributeClueShowResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -2272,7 +2288,7 @@ var file_biService_proto_rawDesc = []byte{
 	0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79,
 	0x4e, 0x61, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x52,
 	0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20,
-	0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xb7, 0x01, 0x0a, 0x15,
+	0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xe3, 0x01, 0x0a, 0x15,
 	0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68,
 	0x6f, 0x77, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
 	0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74,
@@ -2284,111 +2300,116 @@ var file_biService_proto_rawDesc = []byte{
 	0x32, 0x14, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75,
 	0x65, 0x53, 0x68, 0x6f, 0x77, 0x73, 0x52, 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x12, 0x16, 0x0a,
 	0x06, 0x49, 0x73, 0x54, 0x61, 0x73, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x49,
-	0x73, 0x54, 0x61, 0x73, 0x6b, 0x22, 0x61, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62,
-	0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x73, 0x12, 0x1e, 0x0a, 0x0a,
-	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
-	0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10,
-	0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74,
-	0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
-	0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xba, 0x01, 0x0a, 0x14, 0x44, 0x69, 0x73,
-	0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x73,
-	0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18,
-	0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49,
-	0x64, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x75, 0x6e,
-	0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79,
-	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x65, 0x43, 0x6f, 0x75,
-	0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x65, 0x43, 0x6f,
-	0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18,
-	0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12,
-	0x24, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73,
-	0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x43,
-	0x6f, 0x75, 0x6e, 0x74, 0x73, 0x22, 0x7f, 0x0a, 0x16, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62,
-	0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x52, 0x65, 0x73, 0x70, 0x12,
-	0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
-	0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b,
-	0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28,
-	0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x29, 0x0a, 0x04, 0x64,
-	0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x69, 0x73, 0x74,
-	0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x73, 0x73,
-	0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x97, 0x01, 0x0a, 0x0d, 0x45, 0x78, 0x70, 0x6f, 0x72,
-	0x74, 0x42, 0x79, 0x44, 0x62, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65,
-	0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14,
-	0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74,
-	0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18,
-	0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x14,
-	0x0a, 0x05, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d,
-	0x61, 0x69, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x05, 0x20,
-	0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74,
-	0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65,
-	0x22, 0xef, 0x01, 0x0a, 0x09, 0x55, 0x70, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x12, 0x14,
-	0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61,
-	0x70, 0x70, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02,
-	0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a,
-	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03,
-	0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09,
-	0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52,
-	0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e,
-	0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64,
-	0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
-	0x05, 0x73, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x07,
-	0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69,
-	0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69,
-	0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x69,
-	0x7a, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x69,
-	0x7a, 0x65, 0x32, 0xbf, 0x06, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
-	0x12, 0x30, 0x0a, 0x0b, 0x6d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x12,
-	0x0f, 0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71,
-	0x1a, 0x10, 0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65,
-	0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
-	0x12, 0x0e, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71,
-	0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73,
-	0x70, 0x12, 0x2b, 0x0a, 0x09, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x12, 0x0e,
-	0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0e,
-	0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x29,
-	0x0a, 0x08, 0x64, 0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x12, 0x0c, 0x2e, 0x44, 0x72, 0x61,
-	0x77, 0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72,
-	0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x19, 0x0a, 0x04, 0x43, 0x61, 0x6c,
-	0x6c, 0x12, 0x08, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x07, 0x2e, 0x42, 0x69,
-	0x52, 0x65, 0x73, 0x70, 0x12, 0x35, 0x0a, 0x0e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
-	0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62,
-	0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64,
-	0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a, 0x63,
-	0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x65,
-	0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x43, 0x6c, 0x75, 0x65,
-	0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x27, 0x0a, 0x07, 0x63, 0x6c,
-	0x75, 0x65, 0x41, 0x64, 0x64, 0x12, 0x0b, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x41, 0x64, 0x64, 0x52,
+	0x73, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x2a, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x61, 0x50,
+	0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49,
+	0x44, 0x22, 0x61, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43,
+	0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x6f, 0x73, 0x69,
+	0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f,
+	0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x64, 0x69, 0x73, 0x74,
+	0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x10, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x43,
+	0x6f, 0x75, 0x6e, 0x74, 0x22, 0xe0, 0x01, 0x0a, 0x14, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62,
+	0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x73, 0x73, 0x12, 0x1e, 0x0a,
+	0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x22, 0x0a,
+	0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x75, 0x6e,
+	0x74, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03,
+	0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12,
+	0x1a, 0x0a, 0x08, 0x6d, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28,
+	0x03, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x63,
+	0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74,
+	0x73, 0x12, 0x24, 0x0a, 0x0d, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x75,
+	0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69,
+	0x6e, 0x67, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x7f, 0x0a, 0x16, 0x44, 0x69, 0x73, 0x74, 0x72,
+	0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x52, 0x65, 0x73,
+	0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18,
+	0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65,
+	0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x29, 0x0a,
+	0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x69,
+	0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77,
+	0x73, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x97, 0x01, 0x0a, 0x0d, 0x45, 0x78, 0x70,
+	0x6f, 0x72, 0x74, 0x42, 0x79, 0x44, 0x62, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f,
+	0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
+	0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
+	0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
+	0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18,
+	0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05,
+	0x73, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x79,
+	0x70, 0x65, 0x22, 0xef, 0x01, 0x0a, 0x09, 0x55, 0x70, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71,
+	0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e,
+	0x0a, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1c,
+	0x0a, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28,
+	0x03, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05,
+	0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x6e, 0x74,
+	0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65,
+	0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08,
+	0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
+	0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65,
+	0x53, 0x69, 0x7a, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65,
+	0x53, 0x69, 0x7a, 0x65, 0x32, 0xbf, 0x06, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69,
+	0x63, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x6d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65,
+	0x74, 0x12, 0x0f, 0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52,
+	0x65, 0x71, 0x1a, 0x10, 0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74,
+	0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x0a, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65,
+	0x63, 0x74, 0x12, 0x0e, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52,
 	0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52,
-	0x65, 0x73, 0x70, 0x12, 0x2f, 0x0a, 0x0c, 0x63, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72,
-	0x74, 0x54, 0x74, 0x12, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74,
-	0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74,
-	0x52, 0x65, 0x73, 0x70, 0x12, 0x27, 0x0a, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x46, 0x6f, 0x6c, 0x6c,
-	0x6f, 0x77, 0x12, 0x08, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x43,
-	0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a,
-	0x09, 0x73, 0x71, 0x6c, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x12, 0x0d, 0x2e, 0x53, 0x71, 0x6c,
-	0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65,
-	0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x06, 0x6d, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0a, 0x2e,
-	0x4d, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65,
-	0x70, 0x6c, 0x79, 0x12, 0x25, 0x0a, 0x0d, 0x61, 0x6c, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x45, 0x78,
-	0x70, 0x6f, 0x72, 0x74, 0x12, 0x0a, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71,
-	0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, 0x61, 0x6c,
-	0x6c, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0a,
-	0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52,
-	0x65, 0x70, 0x6c, 0x79, 0x12, 0x24, 0x0a, 0x0b, 0x69, 0x6e, 0x66, 0x6f, 0x4f, 0x70, 0x65, 0x72,
-	0x61, 0x74, 0x65, 0x12, 0x0b, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71,
-	0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2b, 0x0a, 0x0e, 0x67, 0x65,
-	0x74, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x2e, 0x43,
-	0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x43, 0x6f, 0x6d, 0x70,
-	0x61, 0x6e, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x45, 0x0a, 0x12, 0x64, 0x69, 0x73, 0x74, 0x72,
-	0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x12, 0x16, 0x2e,
-	0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68,
-	0x6f, 0x77, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75,
-	0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24,
-	0x0a, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x4d, 0x61, 0x69, 0x6c, 0x12, 0x0e, 0x2e, 0x45, 0x78, 0x70,
-	0x6f, 0x72, 0x74, 0x42, 0x79, 0x44, 0x62, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52,
-	0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x06, 0x75, 0x70, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x0a,
-	0x2e, 0x55, 0x70, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52,
-	0x65, 0x70, 0x6c, 0x79, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
-	0x6f, 0x74, 0x6f, 0x33,
+	0x65, 0x73, 0x70, 0x12, 0x2b, 0x0a, 0x09, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64,
+	0x12, 0x0e, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71,
+	0x1a, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x29, 0x0a, 0x08, 0x64, 0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x12, 0x0c, 0x2e, 0x44,
+	0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64,
+	0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x19, 0x0a, 0x04, 0x43,
+	0x61, 0x6c, 0x6c, 0x12, 0x08, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x07, 0x2e,
+	0x42, 0x69, 0x52, 0x65, 0x73, 0x70, 0x12, 0x35, 0x0a, 0x0e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69,
+	0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72,
+	0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41,
+	0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a,
+	0x0a, 0x63, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0e, 0x2e, 0x43, 0x6c,
+	0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x43, 0x6c,
+	0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x27, 0x0a, 0x07,
+	0x63, 0x6c, 0x75, 0x65, 0x41, 0x64, 0x64, 0x12, 0x0b, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x41, 0x64,
+	0x64, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
+	0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2f, 0x0a, 0x0c, 0x63, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70,
+	0x6f, 0x72, 0x74, 0x54, 0x74, 0x12, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f,
+	0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f,
+	0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x27, 0x0a, 0x0a, 0x61, 0x75, 0x74, 0x6f, 0x46, 0x6f,
+	0x6c, 0x6c, 0x6f, 0x77, 0x12, 0x08, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x0f,
+	0x2e, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x24, 0x0a, 0x09, 0x73, 0x71, 0x6c, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x12, 0x0d, 0x2e, 0x53,
+	0x71, 0x6c, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69,
+	0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x06, 0x6d, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12,
+	0x0a, 0x2e, 0x4d, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69,
+	0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x25, 0x0a, 0x0d, 0x61, 0x6c, 0x6c, 0x49, 0x6e, 0x66, 0x6f,
+	0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0a, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52,
+	0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10,
+	0x61, 0x6c, 0x6c, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74,
+	0x12, 0x0a, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42,
+	0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x24, 0x0a, 0x0b, 0x69, 0x6e, 0x66, 0x6f, 0x4f, 0x70,
+	0x65, 0x72, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52,
+	0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2b, 0x0a, 0x0e,
+	0x67, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b,
+	0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x0c, 0x2e, 0x43, 0x6f,
+	0x6d, 0x70, 0x61, 0x6e, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x45, 0x0a, 0x12, 0x64, 0x69, 0x73,
+	0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x12,
+	0x16, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65,
+	0x53, 0x68, 0x6f, 0x77, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69,
+	0x62, 0x75, 0x74, 0x65, 0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x24, 0x0a, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x4d, 0x61, 0x69, 0x6c, 0x12, 0x0e, 0x2e, 0x45,
+	0x78, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x79, 0x44, 0x62, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42,
+	0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x06, 0x75, 0x70, 0x46, 0x69, 0x6c, 0x65,
+	0x12, 0x0a, 0x2e, 0x55, 0x70, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42,
+	0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (

+ 1 - 1
rpc/pb/biService_grpc.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
 // versions:
 // - protoc-gen-go-grpc v1.3.0
-// - protoc             v4.25.2
+// - protoc             v3.15.1
 // source: biService.proto
 
 package pb

+ 71 - 20
service/company.go

@@ -1,9 +1,10 @@
 package service
 
 import (
+	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"strconv"
 	"strings"
-
 	"sync"
 	"time"
 
@@ -45,13 +46,18 @@ func CompanyType(companyName string) (bool, bool) {
 	return isGroup, isCommerce
 }
 
-func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.DistributeClueShowResp {
-	// if DistributeLock.TryLock() {
-	// 	defer DistributeLock.Unlock()
-
-	// } else {
+// 查询是否达上限
+func FindUpperLimit(positionId int64) bool {
+	if positionId == 0 {
+		return false
+	}
+	return JyBiTidb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and trailstatus!= '08' `, positionId) >= 400
+}
 
-	// }
+// CompanyCount 分配的数量
+// CompanyCounts 目前数量
+// ClueCount 线索的数量
+func DistributeClueShow(this *biservice.DistributeClueShowReq, allocationCap int64) *biservice.DistributeClueShowResp {
 	rdata := []*biservice.DistributeClueShowss{}
 	pArr := []string{}
 	for _, c := range this.Datas { //初始化返回数据
@@ -59,6 +65,9 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 		m.PositionId = c.PositionId
 		m.ClueCount = 0
 		m.CompanyCounts = 0
+		//现有数据查询
+		existingCount := JyBiTidb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and trailstatus != '08' `, m.PositionId)
+		m.ExistingCount = existingCount
 		if this.DataType == 1 {
 			m.CompanyCount = 0
 			m.MinCount = 0
@@ -71,7 +80,11 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 	clueArrs1 := []string{}
 	clueArrs := []string{}
 	clueArrSync := &sync.Mutex{}
-	sql1 := `SELECT b.cluename,b.position_id,count(*) as count FROM dwd_f_crm_clue_info a INNER JOIN (SELECT cluename,position_id FROM dwd_f_crm_clue_info WHERE position_id in (` + strings.Join(pArr, ",") + `) AND id not in (` + this.ClueIdList + `) AND company_nature = 0 AND company_verification = 1 GROUP BY cluename) AS b ON a.cluename = b.cluename WHERE id in (` + this.ClueIdList + `) GROUP BY cluename`
+	//统计同一个公司其他线索
+	sql1 := `SELECT b.cluename,b.position_id,count(*) as count FROM dwd_f_crm_clue_info a 
+    INNER JOIN (SELECT cluename,position_id FROM dwd_f_crm_clue_info 
+                                            WHERE position_id in (` + strings.Join(pArr, ",") + `) AND id not in (` + this.ClueIdList + `) AND company_nature = 0 AND company_verification = 1 GROUP BY cluename) AS b ON a.cluename = b.cluename 
+	WHERE id in (` + this.ClueIdList + `) GROUP BY cluename`
 	logx.Info("sql1 ", sql1)
 	sdata := JyBiTidb.SelectBySql(sql1) //查这一批线索中属于当前分配人员的线索提前分配数量
 	if sdata != nil && len(*sdata) > 0 {
@@ -95,7 +108,11 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 			}
 		}
 	}
-	sql2 := `SELECT a.id,b.position_id FROM dwd_f_crm_clue_info a INNER JOIN (SELECT id,cluename,position_id FROM dwd_f_crm_clue_info WHERE position_id in (` + strings.Join(pArr, ",") + `) AND id not in (` + this.ClueIdList + `) AND company_nature = 0 AND company_verification = 1 GROUP BY cluename) AS b ON a.cluename = b.cluename WHERE a.id in (` + this.ClueIdList + `)`
+	sql2 := `SELECT a.id,b.position_id FROM dwd_f_crm_clue_info a 
+    INNER JOIN (
+    SELECT id,cluename,position_id FROM dwd_f_crm_clue_info 
+                                   WHERE position_id in (` + strings.Join(pArr, ",") + `) AND id not in (` + this.ClueIdList + `) AND company_nature = 0 AND company_verification = 1 GROUP BY cluename) AS b ON a.cluename = b.cluename
+	WHERE a.id in (` + this.ClueIdList + `)`
 	logx.Info("sql2 ", sql2) //查这一批线索中属于当前分配人员的线索id,分出去,并且排除掉
 	ldata := JyBiTidb.SelectBySql(sql2)
 	if ldata != nil && len(*ldata) > 0 {
@@ -134,7 +151,13 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 	}
 	logx.Info("clueArrs ", clueArrs)
 	if len(clueArrs) > 0 {
-		sql0 := `SELECT a.cluename,a.id,b.position_id FROM dwd_f_crm_clue_info a INNER JOIN (SELECT a.cluename,a.position_id FROM dwd_f_crm_clue_info a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id WHERE a.cluename in (SELECT cluename FROM dwd_f_crm_clue_info WHERE id in (` + strings.Join(clueArrs, ",") + `) GROUP BY cluename) AND a.id not in (` + strings.Join(clueArrs, ",") + `) AND b.resign = 1 AND a.company_nature = 0 AND a.company_verification = 1 GROUP BY a.cluename) as b on b.cluename = a.cluename where a.id in (` + strings.Join(clueArrs, ",") + `)`
+		sql0 := `SELECT a.cluename,a.id,b.position_id FROM dwd_f_crm_clue_info a 
+    INNER JOIN (
+    SELECT a.cluename,a.position_id FROM dwd_f_crm_clue_info a 
+        INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id 
+                                    WHERE a.cluename in (
+                                    SELECT cluename FROM dwd_f_crm_clue_info WHERE id in (` + strings.Join(clueArrs, ",") + `) GROUP BY cluename) AND a.id not in (` + strings.Join(clueArrs, ",") + `) AND b.resign = 1 AND a.company_nature = 0 AND a.company_verification = 1 GROUP BY a.cluename) as b on b.cluename = a.cluename 
+		where a.id in (` + strings.Join(clueArrs, ",") + `)`
 		logx.Info("sql0", sql0)
 		mdata := JyBiTidb.SelectBySql(sql0)
 		if mdata != nil && len(*mdata) > 0 {
@@ -158,7 +181,10 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 				}
 			}
 			for k, v := range nameMap {
-				ppdata := JyBiTidb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) AND b.position_id != ?`, namePMap[k], namePMap[k])
+				ppdata := JyBiTidb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a 
+    INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id 
+                                          where a.bi_pcode = (
+                                          SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) AND b.position_id != ?`, namePMap[k], namePMap[k])
 				if ppdata != nil && len(*ppdata) > 0 {
 					ppMap := map[int64]int{}
 					for _, vv := range *ppdata {
@@ -167,7 +193,7 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 					}
 					isOk, sindex, paid := false, 0, int64(0)
 				L:
-					for pa, _ := range ppMap {
+					for pa := range ppMap {
 						if pa > 0 {
 							for n, r := range rdata {
 								if r.PositionId == pa {
@@ -218,7 +244,10 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 		logx.Info("sql3 ", sql3) //从大到小排列这一列线索名称分组及数量情况
 		cdata := JyBiTidb.SelectBySql(sql3)
 		if cdata != nil && len(*cdata) > 0 {
-			for _, v := range *cdata {
+			for k1, v := range *cdata {
+				if k1 == 37 {
+					fmt.Println(1111)
+				}
 				count := common.IntAll(v["count"])
 				cluename := common.ObjToString(v["cluename"])
 				minCount, minIndex := int64(0), 0
@@ -246,18 +275,39 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 					}
 				}
 				for k, r := range rdata {
-					if this.DataType == 1 {
-						if r.CompanyCounts <= minCount {
-							minCount = r.CompanyCounts
-							minIndex = k
+					countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
+					fmt.Println(1111, k, rdata[minIndex], rdata[minIndex].ExistingCount, rdata[minIndex].ClueCount, int64(count))
+					if countNumber >= allocationCap {
+						if gconv.Int(allocationCap-rdata[minIndex].ExistingCount-rdata[minIndex].ClueCount) == 0 {
+							minIndex = minIndex + 1
+							continue
+						} else {
+							count = gconv.Int(allocationCap - rdata[minIndex].ExistingCount - rdata[minIndex].ClueCount)
+						}
+						if this.UpdataPositionID == rdata[minIndex].PositionId {
+							return &biservice.DistributeClueShowResp{
+								ErrorCode: 1,
+								ErrorMsg:  "线索已达上限",
+							}
 						}
+
 					} else {
-						if r.CompanyCounts <= minCount && r.CompanyCounts < r.CompanyCount {
-							minCount = r.CompanyCounts
-							minIndex = k
+						if this.DataType == 1 {
+							if r.CompanyCounts <= minCount {
+								minCount = r.CompanyCounts
+								minIndex = k
+							}
+						} else {
+							if r.CompanyCounts <= minCount && r.CompanyCounts < r.CompanyCount {
+								minCount = r.CompanyCounts
+								minIndex = k
+							}
 						}
 					}
 				}
+				if minIndex >= len(rdata) {
+					continue
+				}
 				if this.DataType == 1 {
 					rdata[minIndex].CompanyCount++
 					rdata[minIndex].CompanyCounts++
@@ -299,6 +349,7 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 }
 
 func dclue(v, positionId, isTask, thispositionId int64) {
+
 	clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": v}, "", "")
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	if clueData != nil && len(*clueData) > 0 {