xuzhiheng %!s(int64=2) %!d(string=hai) anos
pai
achega
8973ea4a8f

+ 9 - 0
api/biService.api

@@ -39,6 +39,13 @@ type (
 		PositionId int64  `header:"positionId,optional"`
 		Phone      string `json:"phone"`
 	}
+
+	DistributeClueReq {
+		ClueCount  string                   `json:"clueCount"`
+		ClueIdList []int64                  `json:"clueIdList"`
+		Datas      []map[string]interface{} `json:"datas"`
+		PositionId int64                    `header:"positionId,optional"`
+	}
 )
 
 service biService-api {
@@ -52,4 +59,6 @@ service biService-api {
 	post /biService/drawClue (drawClueReq) returns (resp)
 	@handler Call
 	post /biService/call (callReq) returns (resp)	//拨打电话
+	@handler DistributeClue
+	post /biService/distributeClue (DistributeClueReq) returns (resp)
 }

+ 28 - 0
api/internal/handler/distributecluehandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/logic"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func DistributeClueHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.DistributeClueReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewDistributeClueLogic(r.Context(), svcCtx)
+		resp, err := l.DistributeClue(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
api/internal/handler/routes.go

@@ -37,6 +37,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/biService/call",
 				Handler: CallHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/biService/distributeClue",
+				Handler: DistributeClueHandler(serverCtx),
+			},
 		},
 	)
 }

+ 48 - 0
api/internal/logic/distributecluelogic.go

@@ -0,0 +1,48 @@
+package logic
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jybase/common"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DistributeClueLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewDistributeClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DistributeClueLogic {
+	return &DistributeClueLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *DistributeClueLogic) DistributeClue(req *types.DistributeClueReq) (resp *types.Resp, err error) {
+	// todo: add your logic here and delete this line
+	datas := []*biservice.DistributeDatas{}
+	for _, v := range req.Datas {
+		data := &biservice.DistributeDatas{
+			Name:             common.ObjToString(v["name"]),
+			PositionId:       common.Int64All(v["positionId"]),
+			TotalCount:       common.ObjToString(v["totalCount"]),
+			UncompletedCount: common.ObjToString(v["uncompletedCount"]),
+			DistributedCount: common.ObjToString(v["distributedCount"]),
+		}
+		datas = append(datas, data)
+	}
+	res, err := l.svcCtx.BiServiceRpc.DistributeClue(l.ctx, &biservice.DistributeClueReq{
+		ClueCount:  req.ClueCount,
+		ClueIdList: req.ClueIdList,
+		PositionId: req.PositionId,
+		Datas:      datas,
+	})
+	return &types.Resp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: res.Data}, err
+}

+ 7 - 0
api/internal/types/types.go

@@ -39,3 +39,10 @@ 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"`
+}

+ 20 - 4
rpc/biService.proto

@@ -52,26 +52,42 @@ message GetInfoIdResp {
 	repeated string data = 3;
 }
 
-message drawClueReq {
+message DrawClueReq {
 	int64 positionId = 1;
 	int64 count = 2;
 }
 
-message CallReq{
+message CallReq {
 	int64 position_id =1;
 	string phone =2; 
 }
 
-message Resp{
+message Resp {
 	int64 error_code = 1;
 	string error_msg = 2;
 	string data =3;
 }
 
+message DistributeClueReq {
+	string clueCount = 1;
+	repeated int64 clueIdList = 2;
+	repeated DistributeDatas datas = 3;
+	int64 positionId = 4;
+}
+
+message DistributeDatas {
+	string name = 1;
+	int64 positionId = 2;
+	string totalCount = 3;
+	string uncompletedCount = 4;
+	string distributedCount = 5;
+}
+
 service BiService {
 	rpc myDataAsset (MyDataAssetReq) returns (MyDataAssetResp); //我的数据资产
 	rpc addProject (AddProjectReq) returns (AddProjectResp); //添加项目
 	rpc getInfoId (AddProjectReq) returns (GetInfoIdResp); //获取添加过项目的信息id
-	rpc drawClue (drawClueReq) returns (AddProjectResp); //领取线索
+	rpc drawClue (DrawClueReq) returns (AddProjectResp); //领取线索
 	rpc Call (CallReq) returns (Resp); //外呼集成
+	rpc distributeClue (DistributeClueReq) returns (AddProjectResp);
 }

+ 18 - 10
rpc/biservice/biservice.go

@@ -13,16 +13,18 @@ import (
 )
 
 type (
-	AddProject      = pb.AddProject
-	AddProjectReq   = pb.AddProjectReq
-	AddProjectResp  = pb.AddProjectResp
-	CallReq         = pb.CallReq
-	DrawClueReq     = pb.DrawClueReq
-	GetInfoIdResp   = pb.GetInfoIdResp
-	MyDataAsset     = pb.MyDataAsset
-	MyDataAssetReq  = pb.MyDataAssetReq
-	MyDataAssetResp = pb.MyDataAssetResp
-	Resp            = pb.Resp
+	AddProject        = pb.AddProject
+	AddProjectReq     = pb.AddProjectReq
+	AddProjectResp    = pb.AddProjectResp
+	CallReq           = pb.CallReq
+	DistributeClueReq = pb.DistributeClueReq
+	DistributeDatas   = pb.DistributeDatas
+	DrawClueReq       = pb.DrawClueReq
+	GetInfoIdResp     = pb.GetInfoIdResp
+	MyDataAsset       = pb.MyDataAsset
+	MyDataAssetReq    = pb.MyDataAssetReq
+	MyDataAssetResp   = pb.MyDataAssetResp
+	Resp              = pb.Resp
 
 	BiService interface {
 		MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
@@ -30,6 +32,7 @@ type (
 		GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error)
 		DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 		Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error)
+		DistributeClue(ctx context.Context, in *DistributeClueReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 	}
 
 	defaultBiService struct {
@@ -67,3 +70,8 @@ func (m *defaultBiService) Call(ctx context.Context, in *CallReq, opts ...grpc.C
 	client := pb.NewBiServiceClient(m.cli.Conn())
 	return client.Call(ctx, in, opts...)
 }
+
+func (m *defaultBiService) DistributeClue(ctx context.Context, in *DistributeClueReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.DistributeClue(ctx, in, opts...)
+}

+ 30 - 0
rpc/internal/logic/distributecluelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
+	"bp.jydev.jianyu360.cn/BaseService/biService/service"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DistributeClueLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDistributeClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DistributeClueLogic {
+	return &DistributeClueLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DistributeClueLogic) DistributeClue(in *pb.DistributeClueReq) (*pb.AddProjectResp, error) {
+	// todo: add your logic here and delete this line
+
+	return service.DistributeClue(in), nil
+}

+ 5 - 0
rpc/internal/server/biserviceserver.go

@@ -46,3 +46,8 @@ func (s *BiServiceServer) Call(ctx context.Context, in *pb.CallReq) (*pb.Resp, e
 	l := logic.NewCallLogic(ctx, s.svcCtx)
 	return l.Call(in)
 }
+
+func (s *BiServiceServer) DistributeClue(ctx context.Context, in *pb.DistributeClueReq) (*pb.AddProjectResp, error) {
+	l := logic.NewDistributeClueLogic(ctx, s.svcCtx)
+	return l.DistributeClue(in)
+}

+ 250 - 46
rpc/pb/biService.pb.go

@@ -698,6 +698,156 @@ func (x *Resp) GetData() string {
 	return ""
 }
 
+type DistributeClueReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ClueCount  string             `protobuf:"bytes,1,opt,name=clueCount,proto3" json:"clueCount,omitempty"`
+	ClueIdList []int64            `protobuf:"varint,2,rep,packed,name=clueIdList,proto3" json:"clueIdList,omitempty"`
+	Datas      []*DistributeDatas `protobuf:"bytes,3,rep,name=datas,proto3" json:"datas,omitempty"`
+	PositionId int64              `protobuf:"varint,4,opt,name=positionId,proto3" json:"positionId,omitempty"`
+}
+
+func (x *DistributeClueReq) Reset() {
+	*x = DistributeClueReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_biService_proto_msgTypes[10]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *DistributeClueReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DistributeClueReq) ProtoMessage() {}
+
+func (x *DistributeClueReq) ProtoReflect() protoreflect.Message {
+	mi := &file_biService_proto_msgTypes[10]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use DistributeClueReq.ProtoReflect.Descriptor instead.
+func (*DistributeClueReq) Descriptor() ([]byte, []int) {
+	return file_biService_proto_rawDescGZIP(), []int{10}
+}
+
+func (x *DistributeClueReq) GetClueCount() string {
+	if x != nil {
+		return x.ClueCount
+	}
+	return ""
+}
+
+func (x *DistributeClueReq) GetClueIdList() []int64 {
+	if x != nil {
+		return x.ClueIdList
+	}
+	return nil
+}
+
+func (x *DistributeClueReq) GetDatas() []*DistributeDatas {
+	if x != nil {
+		return x.Datas
+	}
+	return nil
+}
+
+func (x *DistributeClueReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
+type DistributeDatas struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Name             string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+	PositionId       int64  `protobuf:"varint,2,opt,name=positionId,proto3" json:"positionId,omitempty"`
+	TotalCount       string `protobuf:"bytes,3,opt,name=totalCount,proto3" json:"totalCount,omitempty"`
+	UncompletedCount string `protobuf:"bytes,4,opt,name=uncompletedCount,proto3" json:"uncompletedCount,omitempty"`
+	DistributedCount string `protobuf:"bytes,5,opt,name=distributedCount,proto3" json:"distributedCount,omitempty"`
+}
+
+func (x *DistributeDatas) Reset() {
+	*x = DistributeDatas{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_biService_proto_msgTypes[11]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *DistributeDatas) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DistributeDatas) ProtoMessage() {}
+
+func (x *DistributeDatas) ProtoReflect() protoreflect.Message {
+	mi := &file_biService_proto_msgTypes[11]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use DistributeDatas.ProtoReflect.Descriptor instead.
+func (*DistributeDatas) Descriptor() ([]byte, []int) {
+	return file_biService_proto_rawDescGZIP(), []int{11}
+}
+
+func (x *DistributeDatas) GetName() string {
+	if x != nil {
+		return x.Name
+	}
+	return ""
+}
+
+func (x *DistributeDatas) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
+func (x *DistributeDatas) GetTotalCount() string {
+	if x != nil {
+		return x.TotalCount
+	}
+	return ""
+}
+
+func (x *DistributeDatas) GetUncompletedCount() string {
+	if x != nil {
+		return x.UncompletedCount
+	}
+	return ""
+}
+
+func (x *DistributeDatas) GetDistributedCount() string {
+	if x != nil {
+		return x.DistributedCount
+	}
+	return ""
+}
+
 var File_biService_proto protoreflect.FileDescriptor
 
 var file_biService_proto_rawDesc = []byte{
@@ -767,7 +917,7 @@ var file_biService_proto_rawDesc = []byte{
 	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, 0x12,
 	0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61,
-	0x74, 0x61, 0x22, 0x43, 0x0a, 0x0b, 0x64, 0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x52, 0x65,
+	0x74, 0x61, 0x22, 0x43, 0x0a, 0x0b, 0x44, 0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 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, 0x69, 0x6f, 0x6e, 0x49,
 	0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
@@ -781,22 +931,47 @@ var file_biService_proto_rawDesc = []byte{
 	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, 0x12, 0x0a,
 	0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74,
-	0x61, 0x32, 0xdd, 0x01, 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, 0x64, 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, 0x17, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c,
-	0x12, 0x08, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73,
-	0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-	0x33,
+	0x61, 0x22, 0x99, 0x01, 0x0a, 0x11, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65,
+	0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x65, 0x43,
+	0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x65,
+	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6c, 0x75, 0x65, 0x49, 0x64, 0x4c,
+	0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x63, 0x6c, 0x75, 0x65, 0x49,
+	0x64, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x18, 0x03,
+	0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74,
+	0x65, 0x44, 0x61, 0x74, 0x61, 0x73, 0x52, 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x12, 0x1e, 0x0a,
+	0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28,
+	0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0xbd, 0x01,
+	0x0a, 0x0f, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61,
+	0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
+	0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74,
+	0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f,
+	0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c,
+	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x6c,
+	0x65, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x10, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e,
+	0x74, 0x12, 0x2a, 0x0a, 0x10, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64,
+	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x64, 0x69, 0x73,
+	0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x94, 0x02,
+	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, 0x17, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x08, 0x2e, 0x43,
+	0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -811,37 +986,42 @@ func file_biService_proto_rawDescGZIP() []byte {
 	return file_biService_proto_rawDescData
 }
 
-var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
+var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
 var file_biService_proto_goTypes = []interface{}{
-	(*MyDataAssetReq)(nil),  // 0: MyDataAssetReq
-	(*MyDataAssetResp)(nil), // 1: MyDataAssetResp
-	(*MyDataAsset)(nil),     // 2: MyDataAsset
-	(*AddProjectReq)(nil),   // 3: AddProjectReq
-	(*AddProjectResp)(nil),  // 4: AddProjectResp
-	(*AddProject)(nil),      // 5: AddProject
-	(*GetInfoIdResp)(nil),   // 6: GetInfoIdResp
-	(*DrawClueReq)(nil),     // 7: drawClueReq
-	(*CallReq)(nil),         // 8: CallReq
-	(*Resp)(nil),            // 9: Resp
+	(*MyDataAssetReq)(nil),    // 0: MyDataAssetReq
+	(*MyDataAssetResp)(nil),   // 1: MyDataAssetResp
+	(*MyDataAsset)(nil),       // 2: MyDataAsset
+	(*AddProjectReq)(nil),     // 3: AddProjectReq
+	(*AddProjectResp)(nil),    // 4: AddProjectResp
+	(*AddProject)(nil),        // 5: AddProject
+	(*GetInfoIdResp)(nil),     // 6: GetInfoIdResp
+	(*DrawClueReq)(nil),       // 7: DrawClueReq
+	(*CallReq)(nil),           // 8: CallReq
+	(*Resp)(nil),              // 9: Resp
+	(*DistributeClueReq)(nil), // 10: DistributeClueReq
+	(*DistributeDatas)(nil),   // 11: DistributeDatas
 }
 var file_biService_proto_depIdxs = []int32{
-	2, // 0: MyDataAssetResp.data:type_name -> MyDataAsset
-	5, // 1: AddProjectResp.data:type_name -> AddProject
-	0, // 2: BiService.myDataAsset:input_type -> MyDataAssetReq
-	3, // 3: BiService.addProject:input_type -> AddProjectReq
-	3, // 4: BiService.getInfoId:input_type -> AddProjectReq
-	7, // 5: BiService.drawClue:input_type -> drawClueReq
-	8, // 6: BiService.Call:input_type -> CallReq
-	1, // 7: BiService.myDataAsset:output_type -> MyDataAssetResp
-	4, // 8: BiService.addProject:output_type -> AddProjectResp
-	6, // 9: BiService.getInfoId:output_type -> GetInfoIdResp
-	4, // 10: BiService.drawClue:output_type -> AddProjectResp
-	9, // 11: BiService.Call:output_type -> Resp
-	7, // [7:12] is the sub-list for method output_type
-	2, // [2:7] is the sub-list for method input_type
-	2, // [2:2] is the sub-list for extension type_name
-	2, // [2:2] is the sub-list for extension extendee
-	0, // [0:2] is the sub-list for field type_name
+	2,  // 0: MyDataAssetResp.data:type_name -> MyDataAsset
+	5,  // 1: AddProjectResp.data:type_name -> AddProject
+	11, // 2: DistributeClueReq.datas:type_name -> DistributeDatas
+	0,  // 3: BiService.myDataAsset:input_type -> MyDataAssetReq
+	3,  // 4: BiService.addProject:input_type -> AddProjectReq
+	3,  // 5: BiService.getInfoId:input_type -> AddProjectReq
+	7,  // 6: BiService.drawClue:input_type -> DrawClueReq
+	8,  // 7: BiService.Call:input_type -> CallReq
+	10, // 8: BiService.distributeClue:input_type -> DistributeClueReq
+	1,  // 9: BiService.myDataAsset:output_type -> MyDataAssetResp
+	4,  // 10: BiService.addProject:output_type -> AddProjectResp
+	6,  // 11: BiService.getInfoId:output_type -> GetInfoIdResp
+	4,  // 12: BiService.drawClue:output_type -> AddProjectResp
+	9,  // 13: BiService.Call:output_type -> Resp
+	4,  // 14: BiService.distributeClue:output_type -> AddProjectResp
+	9,  // [9:15] is the sub-list for method output_type
+	3,  // [3:9] is the sub-list for method input_type
+	3,  // [3:3] is the sub-list for extension type_name
+	3,  // [3:3] is the sub-list for extension extendee
+	0,  // [0:3] is the sub-list for field type_name
 }
 
 func init() { file_biService_proto_init() }
@@ -970,6 +1150,30 @@ func file_biService_proto_init() {
 				return nil
 			}
 		}
+		file_biService_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*DistributeClueReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_biService_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*DistributeDatas); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -977,7 +1181,7 @@ func file_biService_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_biService_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   10,
+			NumMessages:   12,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 42 - 5
rpc/pb/biService_grpc.pb.go

@@ -19,11 +19,12 @@ import (
 const _ = grpc.SupportPackageIsVersion7
 
 const (
-	BiService_MyDataAsset_FullMethodName = "/BiService/myDataAsset"
-	BiService_AddProject_FullMethodName  = "/BiService/addProject"
-	BiService_GetInfoId_FullMethodName   = "/BiService/getInfoId"
-	BiService_DrawClue_FullMethodName    = "/BiService/drawClue"
-	BiService_Call_FullMethodName        = "/BiService/Call"
+	BiService_MyDataAsset_FullMethodName    = "/BiService/myDataAsset"
+	BiService_AddProject_FullMethodName     = "/BiService/addProject"
+	BiService_GetInfoId_FullMethodName      = "/BiService/getInfoId"
+	BiService_DrawClue_FullMethodName       = "/BiService/drawClue"
+	BiService_Call_FullMethodName           = "/BiService/Call"
+	BiService_DistributeClue_FullMethodName = "/BiService/distributeClue"
 )
 
 // BiServiceClient is the client API for BiService service.
@@ -35,6 +36,7 @@ type BiServiceClient interface {
 	GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error)
 	DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 	Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error)
+	DistributeClue(ctx context.Context, in *DistributeClueReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 }
 
 type biServiceClient struct {
@@ -90,6 +92,15 @@ func (c *biServiceClient) Call(ctx context.Context, in *CallReq, opts ...grpc.Ca
 	return out, nil
 }
 
+func (c *biServiceClient) DistributeClue(ctx context.Context, in *DistributeClueReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
+	out := new(AddProjectResp)
+	err := c.cc.Invoke(ctx, BiService_DistributeClue_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // BiServiceServer is the server API for BiService service.
 // All implementations must embed UnimplementedBiServiceServer
 // for forward compatibility
@@ -99,6 +110,7 @@ type BiServiceServer interface {
 	GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error)
 	DrawClue(context.Context, *DrawClueReq) (*AddProjectResp, error)
 	Call(context.Context, *CallReq) (*Resp, error)
+	DistributeClue(context.Context, *DistributeClueReq) (*AddProjectResp, error)
 	mustEmbedUnimplementedBiServiceServer()
 }
 
@@ -121,6 +133,9 @@ func (UnimplementedBiServiceServer) DrawClue(context.Context, *DrawClueReq) (*Ad
 func (UnimplementedBiServiceServer) Call(context.Context, *CallReq) (*Resp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
 }
+func (UnimplementedBiServiceServer) DistributeClue(context.Context, *DistributeClueReq) (*AddProjectResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method DistributeClue not implemented")
+}
 func (UnimplementedBiServiceServer) mustEmbedUnimplementedBiServiceServer() {}
 
 // UnsafeBiServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -224,6 +239,24 @@ func _BiService_Call_Handler(srv interface{}, ctx context.Context, dec func(inte
 	return interceptor(ctx, in, info, handler)
 }
 
+func _BiService_DistributeClue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(DistributeClueReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).DistributeClue(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_DistributeClue_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).DistributeClue(ctx, req.(*DistributeClueReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // BiService_ServiceDesc is the grpc.ServiceDesc for BiService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -251,6 +284,10 @@ var BiService_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "Call",
 			Handler:    _BiService_Call_Handler,
 		},
+		{
+			MethodName: "distributeClue",
+			Handler:    _BiService_DistributeClue_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "biService.proto",

+ 114 - 0
service/clue.go

@@ -4,13 +4,127 @@ import (
 	"database/sql"
 	"log"
 	"math"
+	"strconv"
+	"sync"
 	"time"
 
+	"app.yhyue.com/moapp/jybase/date"
+
 	common "app.yhyue.com/moapp/jybase/common"
 	. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
 )
 
+func DistributeClue(this *biservice.DistributeClueReq) *biservice.AddProjectResp {
+	saleMap, status, count := map[string]map[string]interface{}{}, int64(1), 0
+	saleData := JyBiTidb.SelectBySql("select * from jy_salesperson_info where is_complete = 1 or is_complete = 0")
+	if saleData != nil && len(*saleData) > 0 {
+		for _, v := range *saleData {
+			name := common.ObjToString(v["name"])
+			saleMap[name] = v
+		}
+	}
+	for _, data := range this.Datas {
+		seatNumber := common.ObjToString(saleMap[data.Name]["seatNumber"])
+		distributedCount, _ := strconv.Atoi(data.DistributedCount)
+		distributedArr := this.ClueIdList[count : count+distributedCount]
+		count += distributedCount
+		DistributeClueMore(saleMap, distributedArr, seatNumber, data.Name, data.PositionId, this.PositionId)
+	}
+	return &biservice.AddProjectResp{
+		ErrorCode: 0,
+		Data: &biservice.AddProject{
+			Status: status,
+		},
+	}
+}
+
+func DistributeClueMore(saleMap map[string]map[string]interface{}, distributedArr []int64, seatNumber, name string, positionId, thispositionId int64) {
+	wg := new(sync.WaitGroup)
+	ch := make(chan bool, 20)
+	for _, v := range distributedArr {
+		wg.Add(1)
+		ch <- true
+		go func(v int64) {
+			defer func() {
+				wg.Done()
+				<-ch
+			}()
+			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 {
+				isAssign := common.IntAll((*clueData)["is_assign"])
+				clueSeatNumber := common.ObjToString((*clueData)["seatNumber"])
+				oldName := ""
+				if clueSeatNumber != "" {
+					for _, s := range saleMap {
+						if common.ObjToString(s["seatNumber"]) == clueSeatNumber {
+							oldName = common.ObjToString(s["name"])
+						}
+					}
+				}
+				if isAssign == 1 {
+					ok := JyBiTidb.Update("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": v}, map[string]interface{}{
+						"position_id":  positionId,
+						"seatNumber":   seatNumber,
+						"comeinsource": 4,
+						"comeintime":   nowTime,
+						// "is_task":      1,
+						// "task_time":    nowTime,
+						// "tasktime":     nowTime,
+						// "taskstatus":   0,
+						// "tasksource":   "线索批量分配",
+					})
+					if ok {
+						JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+							"clue_id":      v,
+							"position_id":  positionId,
+							"change_field": "position_id",
+							"change_type":  "所属人变更",
+							"old_value":    oldName,
+							"new_value":    name,
+							"createtime":   nowTime,
+							"BCPCID":       common.GetRandom(32),
+							"operator_id":  thispositionId,
+						})
+					} else {
+						log.Println("私海修改失败 ", v, positionId, seatNumber)
+					}
+				} else {
+					seaId := JyBiTidb.Insert("dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      v,
+						"position_id":  positionId,
+						"seatNumber":   seatNumber,
+						"comeinsource": 4,
+						"comeintime":   nowTime,
+						// "is_task":      1,
+						// "task_time":    nowTime,
+						// "tasktime":     nowTime,
+						// "taskstatus":   0,
+						// "tasksource":   "线索批量分配",
+					})
+					if seaId > 0 {
+						JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+							"clue_id":      v,
+							"position_id":  positionId,
+							"change_field": "position_id",
+							"change_type":  "所属人变更",
+							"old_value":    "/",
+							"new_value":    name,
+							"createtime":   nowTime,
+							"BCPCID":       common.GetRandom(32),
+							"operator_id":  thispositionId,
+						})
+					} else {
+						log.Println("私海插入失败 ", v, positionId, seatNumber)
+					}
+				}
+			}
+		}(v)
+	}
+	wg.Wait()
+}
+
 func DrawClue(this *biservice.DrawClueReq) *biservice.AddProjectResp {
 	count, status := DrawClueSync(this)
 	log.Println("领取数量 ", count)