lianbingjie 2 år sedan
förälder
incheckning
94342dcdc1

+ 1 - 0
README.md

@@ -1,5 +1,6 @@
 bi页面的相关服务接口
 goctl rpc proto -src biService.proto -dir .
+goctl rpc protoc biService.proto --go_out=. --go-grpc_out=. --zrpc_out=.
 goctl api go -api biService.api -dir .
 go test -v -coverprofile=coverage
 go tool cover -html=coverage -o coverage.html

+ 14 - 0
api/biService.api

@@ -29,6 +29,16 @@ type (
 	getInfoIdReq {
 		PositionId int64 `header:"positionId,optional"`
 	}
+
+	drawClueReq {
+		PositionId int64 `header:"positionId,optional"`
+		Count      int64 `json:"count,optional"`
+	}
+
+	callReq {
+		PositionId int64  `header:"positionId,optional"`
+		Phone      string `json:"phone"`
+	}
 )
 
 service biService-api {
@@ -38,4 +48,8 @@ service biService-api {
 	post /biService/addProject (addProjectReq) returns (resp)
 	@handler GetInfoId
 	post /biService/getInfoId (getInfoIdReq) returns (resp)
+	@handler DrawClue
+	post /biService/drawClue (drawClueReq) returns (resp)
+	@handler Call
+	post /biService/call (callReq) returns (resp)	//拨打电话
 }

+ 2 - 2
api/etc/biservice-api.yaml

@@ -10,10 +10,10 @@ BiServiceRpc:
 GatewayRpcConf:
   Etcd:
     Hosts:
-      -  192.168.3.11:2379
+      -  127.0.0.1:2379
     Key: gatewayDemo.rpc
 Logx:
   Mode: console #console|file|volume
   Path: ./logs
   Level: info #info|error|severe
-  KeepDays: 10
+  KeepDays: 10

+ 28 - 0
api/internal/handler/callhandler.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 CallHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CallReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewCallLogic(r.Context(), svcCtx)
+		resp, err := l.Call(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 28 - 0
api/internal/handler/drawcluehandler.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 DrawClueHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.DrawClueReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewDrawClueLogic(r.Context(), svcCtx)
+		resp, err := l.DrawClue(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

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

@@ -27,6 +27,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/biService/getInfoId",
 				Handler: GetInfoIdHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/biService/drawClue",
+				Handler: DrawClueHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/biService/call",
+				Handler: CallHandler(serverCtx),
+			},
 		},
 	)
 }

+ 46 - 0
api/internal/logic/calllogic.go

@@ -0,0 +1,46 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CallLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCallLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CallLogic {
+	return &CallLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *CallLogic) Call(req *types.CallReq) (resp *types.Resp, err error) {
+	resp = &types.Resp{}
+	callresp, err := l.svcCtx.BiServiceRpc.Call(l.ctx, &pb.CallReq{
+		PositionId: req.PositionId,
+		Phone:      req.Phone,
+	})
+
+	if callresp == nil || err != nil {
+		resp.Error_msg = "暂无数据"
+		resp.Error_code = -1
+		resp.Data = map[string]interface{}{
+			"status": -1,
+		}
+	}
+	resp.Data = map[string]interface{}{
+		"status": callresp.Status,
+	}
+	return
+}

+ 34 - 0
api/internal/logic/drawcluelogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"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 DrawClueLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewDrawClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DrawClueLogic {
+	return &DrawClueLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *DrawClueLogic) DrawClue(req *types.DrawClueReq) (resp *types.Resp, err error) {
+	// todo: add your logic here and delete this line
+	res, err := l.svcCtx.BiServiceRpc.DrawClue(l.ctx, &biservice.DrawClueReq{
+		PositionId: req.PositionId,
+		Count:      req.Count,
+	})
+	return &types.Resp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: res.Data}, err
+}

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

@@ -29,3 +29,13 @@ type AddProjectReq struct {
 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"`
+}

+ 30 - 0
entity/entity.go

@@ -2,6 +2,7 @@ package entity
 
 import (
 	"log"
+	"strings"
 
 	"encoding/json"
 
@@ -9,6 +10,7 @@ import (
 	elastic "app.yhyue.com/moapp/jybase/esv1"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
+	"app.yhyue.com/moapp/jybase/redis"
 	"github.com/nsqio/go-nsq"
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -22,8 +24,19 @@ var (
 	Mgo        *mongodb.MongodbSim
 	Es         *elastic.Elastic
 	AreaCode   = map[string]string{}
+	Hlyj       *HlyjS
 )
 
+type HlyjS struct {
+	Appid        string
+	Account      string
+	Secret       string
+	TokenUrl     string
+	CallFlag     int
+	CallUrl      string
+	Integratedid string
+}
+
 type Handler struct {
 }
 
@@ -140,3 +153,20 @@ func (h *Handler) HandleMessage(m *nsq.Message) error {
 	}
 	return nil
 }
+
+// 初始化reidis
+func InitRedis(redisAddr []string) {
+	redis.InitRedisBySize(strings.Join(redisAddr, ","), 100, 30, 300)
+}
+
+func GetHlyj(appid, account, secret, tokenUrl, callUrl, integratedid string, callFlag int) {
+	Hlyj = &HlyjS{
+		Appid:        appid,
+		Account:      account,
+		Secret:       secret,
+		TokenUrl:     tokenUrl,
+		CallFlag:     callFlag,
+		CallUrl:      callUrl,
+		Integratedid: integratedid,
+	}
+}

+ 13 - 2
go.mod

@@ -1,28 +1,33 @@
 module bp.jydev.jianyu360.cn/BaseService/biService
 
-go 1.17
+go 1.19
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20221010080805-39dc6a853eff
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
+	github.com/gogf/gf/v2 v2.0.6
 	github.com/golang/protobuf v1.5.2
 	github.com/nsqio/go-nsq v1.1.0
-	github.com/zeromicro/go-zero v1.4.2
+	github.com/zeromicro/go-zero v1.3.5
 	google.golang.org/grpc v1.51.0
 	google.golang.org/protobuf v1.28.1
 )
 
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
+	github.com/BurntSushi/toml v0.4.1 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect
 	github.com/cenkalti/backoff/v4 v4.1.3 // indirect
 	github.com/cespare/xxhash/v2 v2.1.2 // indirect
+	github.com/clbanning/mxj/v2 v2.5.5 // indirect
 	github.com/coreos/go-semver v0.3.0 // indirect
 	github.com/coreos/go-systemd/v22 v22.3.2 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 	github.com/fatih/color v1.13.0 // indirect
+	github.com/fsnotify/fsnotify v1.5.1 // indirect
+	github.com/garyburd/redigo v1.6.2 // indirect
 	github.com/go-logr/logr v1.2.3 // indirect
 	github.com/go-logr/stdr v1.2.2 // indirect
 	github.com/go-redis/redis/v8 v8.11.5 // indirect
@@ -35,17 +40,22 @@ require (
 	github.com/google/gofuzz v1.2.0 // indirect
 	github.com/google/uuid v1.3.0 // indirect
 	github.com/googleapis/gnostic v0.5.5 // indirect
+	github.com/gorilla/websocket v1.5.0 // indirect
+	github.com/grokify/html-strip-tags-go v0.0.1 // indirect
 	github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.1 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/klauspost/compress v1.13.6 // indirect
+	github.com/longbridgeapp/sqlparser v0.3.1 // indirect
 	github.com/mattn/go-colorable v0.1.9 // indirect
 	github.com/mattn/go-isatty v0.0.14 // indirect
+	github.com/mattn/go-runewidth v0.0.13 // indirect
 	github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
+	github.com/olekukonko/tablewriter v0.0.5 // indirect
 	github.com/olivere/elastic v6.2.37+incompatible // indirect
 	github.com/openzipkin/zipkin-go v0.4.0 // indirect
 	github.com/pelletier/go-toml/v2 v2.0.5 // indirect
@@ -54,6 +64,7 @@ require (
 	github.com/prometheus/client_model v0.2.0 // indirect
 	github.com/prometheus/common v0.37.0 // indirect
 	github.com/prometheus/procfs v0.8.0 // indirect
+	github.com/rivo/uniseg v0.2.0 // indirect
 	github.com/spaolacci/murmur3 v1.1.0 // indirect
 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
 	github.com/xdg-go/scram v1.1.1 // indirect

+ 3 - 0
go.sum

@@ -167,6 +167,7 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4
 github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
 github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
 github.com/fullstorydev/grpcurl v1.8.7/go.mod h1:pVtM4qe3CMoLaIzYS8uvTuDj2jVYmXqMUkZeijnXp/E=
+github.com/garyburd/redigo v1.6.2 h1:yE/pwKCrbLpLpQICzYTeZ7JsTA/C53wFTJHaEtRqniM=
 github.com/garyburd/redigo v1.6.2/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
 github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@@ -211,6 +212,7 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC
 github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
+github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M=
 github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
 github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
 github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
@@ -602,6 +604,7 @@ github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLC
 github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
 github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
 github.com/zeromicro/go-zero v1.3.2/go.mod h1:DEj3Fwj1Ui1ltsgf6YqwTL9nD4+tYzIRX0c1pWtQo1E=
+github.com/zeromicro/go-zero v1.3.5 h1:+3T4Rx/5o/EgLuCE3Qo4X0i+3GCHRYEgkabmfKhhQ7Q=
 github.com/zeromicro/go-zero v1.3.5/go.mod h1:wh4o794b7Ul3W0k35Pw9nc3iB4O0OpaQTMQz/PJc1bc=
 github.com/zeromicro/go-zero v1.4.2 h1:1P9TuzxONqxQG3Bvpk7r7vPOGEnfXn3lTX/4W5Y2GlQ=
 github.com/zeromicro/go-zero v1.4.2/go.mod h1:OK8ilGkhRzhi1NRRC76h5qTNFm6NbsYrUqld38i4NF4=

+ 19 - 0
rpc/biService.proto

@@ -43,6 +43,7 @@ message AddProjectResp {
 
 message AddProject {
 	int64 status = 1;
+	int64 count = 2;
 }
 
 message GetInfoIdResp {
@@ -51,8 +52,26 @@ message GetInfoIdResp {
 	repeated string data = 3;
 }
 
+message drawClueReq {
+	int64 positionId = 1;
+	int64 count = 2;
+}
+
+message CallReq{
+	int64 position_id =1;
+	string phone =2; 
+}
+
+message Resp{
+	int64 error_code = 1;
+	string error_msg = 2;
+	int64 status =3;
+}
+
 service BiService {
 	rpc myDataAsset (MyDataAssetReq) returns (MyDataAssetResp); //我的数据资产
 	rpc addProject (AddProjectReq) returns (AddProjectResp); //添加项目
 	rpc getInfoId (AddProjectReq) returns (GetInfoIdResp); //获取添加过项目的信息id
+	rpc drawClue (drawClueReq) returns (AddProjectResp); //领取线索
+	rpc Call (CallReq) returns (Resp); //外呼集成
 }

+ 3 - 0
rpc/biservice.go

@@ -31,6 +31,9 @@ func main() {
 	entity.InitMongo(c.Mongo.Qfw.MongodbAddr, c.Mongo.Qfw.DbName, c.Mongo.Qfw.Size)
 	entity.InitEs(c.Es.Address, c.Es.DbSize)
 	entity.InitArea()
+	entity.InitRedis(c.RedisAddress)
+	//合力亿捷
+	entity.GetHlyj(c.Hlyj.Appid, c.Hlyj.Account, c.Hlyj.Secret, c.Hlyj.TokenUrl, c.Hlyj.CallUrl, c.Hlyj.Integratedid, c.Hlyj.CallFlag)
 	//nsq
 	config := nsq.NewConfig()
 	consumer, err := nsq.NewConsumer(c.TopicName, "jy_position_sync", config)

+ 30 - 16
rpc/biservice/biservice.go

@@ -1,8 +1,6 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctl. DO NOT EDIT.
 // Source: biService.proto
 
-//go:generate mockgen -destination ./biservice_mock.go -package biservice -source $GOFILE
-
 package biservice
 
 import (
@@ -11,21 +9,27 @@ import (
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
 
 	"github.com/zeromicro/go-zero/zrpc"
+	"google.golang.org/grpc"
 )
 
 type (
-	MyDataAssetReq  = pb.MyDataAssetReq
-	MyDataAssetResp = pb.MyDataAssetResp
-	MyDataAsset     = pb.MyDataAsset
+	AddProject      = pb.AddProject
 	AddProjectReq   = pb.AddProjectReq
 	AddProjectResp  = pb.AddProjectResp
-	AddProject      = pb.AddProject
+	CallReq         = pb.CallReq
+	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) (*MyDataAssetResp, error)
-		AddProject(ctx context.Context, in *AddProjectReq) (*AddProjectResp, error)
-		GetInfoId(ctx context.Context, in *AddProjectReq) (*GetInfoIdResp, error)
+		MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
+		AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error)
+		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)
 	}
 
 	defaultBiService struct {
@@ -39,17 +43,27 @@ func NewBiService(cli zrpc.Client) BiService {
 	}
 }
 
-func (m *defaultBiService) MyDataAsset(ctx context.Context, in *MyDataAssetReq) (*MyDataAssetResp, error) {
+func (m *defaultBiService) MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.MyDataAsset(ctx, in, opts...)
+}
+
+func (m *defaultBiService) AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.AddProject(ctx, in, opts...)
+}
+
+func (m *defaultBiService) GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error) {
 	client := pb.NewBiServiceClient(m.cli.Conn())
-	return client.MyDataAsset(ctx, in)
+	return client.GetInfoId(ctx, in, opts...)
 }
 
-func (m *defaultBiService) AddProject(ctx context.Context, in *AddProjectReq) (*AddProjectResp, error) {
+func (m *defaultBiService) DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
 	client := pb.NewBiServiceClient(m.cli.Conn())
-	return client.AddProject(ctx, in)
+	return client.DrawClue(ctx, in, opts...)
 }
 
-func (m *defaultBiService) GetInfoId(ctx context.Context, in *AddProjectReq) (*GetInfoIdResp, error) {
+func (m *defaultBiService) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error) {
 	client := pb.NewBiServiceClient(m.cli.Conn())
-	return client.GetInfoId(ctx, in)
+	return client.Call(ctx, in, opts...)
 }

+ 14 - 1
rpc/etc/biservice.yaml

@@ -47,7 +47,7 @@ Mongo:
     DbName: qfw
     Size: 10
 Es:
-  Address: http://127.0.0.1:9800
+  Address: http://192.168.3.206:9800
   DbSize: 5
   Index: projectset
   IType: projectset
@@ -57,5 +57,18 @@ Logx:
   Level: info #info|error|severe
   KeepDays: 100
 AddCountLimit: 500
+DrawCountLimit: 1000
 TopicName: jy_position_sync
 NsqUrl: 192.168.3.240:4161
+#合力亿捷account_token存储
+RedisAddress:
+  - newother=192.168.3.11:1712
+#合力亿捷相关调用参数
+Hlyj:
+  Appid: w4w2ex0bnt1n61or
+  Account: N000000029739
+  Secret: 3c8f7dd04d2c11edb786132b38c4d48a
+  TokenUrl: https://a1.7x24cc.com/accessToken #获取token接口
+  CallFlag: 104 #外呼集成的接口号	
+  CallUrl: https://a1.7x24cc.com/commonInte #外呼集成接口
+  Integratedid: "8546" 

+ 15 - 4
rpc/internal/config/config.go

@@ -30,8 +30,19 @@ type Config struct {
 		Index   string
 		IType   string
 	}
-	Mode          string
-	AddCountLimit int
-	TopicName     string
-	NsqUrl        string
+	Mode           string
+	AddCountLimit  int
+	DrawCountLimit int
+	TopicName      string
+	NsqUrl         string
+	RedisAddress   []string
+	Hlyj           struct {
+		Appid        string
+		Account      string
+		Secret       string
+		TokenUrl     string
+		CallFlag     int
+		CallUrl      string
+		Integratedid string
+	}
 }

+ 47 - 0
rpc/internal/logic/calllogic.go

@@ -0,0 +1,47 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"bp.jydev.jianyu360.cn/BaseService/biService/service"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CallLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewCallLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CallLogic {
+	return &CallLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *CallLogic) Call(in *pb.CallReq) (*pb.Resp, error) {
+	resp := &pb.Resp{}
+	hlyj := service.HlyjStruct{
+		Account:      entity.Hlyj.Account,
+		TokenUrl:     entity.Hlyj.TokenUrl,
+		Appid:        entity.Hlyj.Appid,
+		Secret:       entity.Hlyj.Secret,
+		CallUrl:      entity.Hlyj.CallUrl,
+		Integratedid: entity.Hlyj.Integratedid,
+		CallFlag:     entity.Hlyj.CallFlag,
+	}
+	status := hlyj.Call(in.Phone, in.PositionId)
+	if status {
+		resp.Status = 1
+	} else {
+		resp.Status = -1
+	}
+	return resp, nil
+}

+ 30 - 0
rpc/internal/logic/drawcluelogic.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 DrawClueLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDrawClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DrawClueLogic {
+	return &DrawClueLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DrawClueLogic) DrawClue(in *pb.DrawClueReq) (*pb.AddProjectResp, error) {
+	// todo: add your logic here and delete this line
+
+	return service.DrawClue(in, l.svcCtx.Config.DrawCountLimit), nil
+}

+ 12 - 1
rpc/internal/server/biserviceserver.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctl. DO NOT EDIT.
 // Source: biService.proto
 
 package server
@@ -13,6 +13,7 @@ import (
 
 type BiServiceServer struct {
 	svcCtx *svc.ServiceContext
+	pb.UnimplementedBiServiceServer
 }
 
 func NewBiServiceServer(svcCtx *svc.ServiceContext) *BiServiceServer {
@@ -35,3 +36,13 @@ func (s *BiServiceServer) GetInfoId(ctx context.Context, in *pb.AddProjectReq) (
 	l := logic.NewGetInfoIdLogic(ctx, s.svcCtx)
 	return l.GetInfoId(in)
 }
+
+func (s *BiServiceServer) DrawClue(ctx context.Context, in *pb.DrawClueReq) (*pb.AddProjectResp, error) {
+	l := logic.NewDrawClueLogic(ctx, s.svcCtx)
+	return l.DrawClue(in)
+}
+
+func (s *BiServiceServer) Call(ctx context.Context, in *pb.CallReq) (*pb.Resp, error) {
+	l := logic.NewCallLogic(ctx, s.svcCtx)
+	return l.Call(in)
+}

+ 272 - 189
rpc/pb/biService.pb.go

@@ -1,17 +1,12 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.23.0
-// 	protoc        v3.11.4
+// 	protoc-gen-go v1.28.1
+// 	protoc        v3.19.4
 // source: biService.proto
 
 package pb
 
 import (
-	context "context"
-	proto "github.com/golang/protobuf/proto"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	reflect "reflect"
@@ -25,10 +20,6 @@ const (
 	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
 )
 
-// This is a compile-time assertion that a sufficiently up-to-date version
-// of the legacy proto package is being used.
-const _ = proto.ProtoPackageIsVersion4
-
 type MyDataAssetReq struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -422,6 +413,7 @@ type AddProject struct {
 	unknownFields protoimpl.UnknownFields
 
 	Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
+	Count  int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
 }
 
 func (x *AddProject) Reset() {
@@ -463,6 +455,13 @@ func (x *AddProject) GetStatus() int64 {
 	return 0
 }
 
+func (x *AddProject) GetCount() int64 {
+	if x != nil {
+		return x.Count
+	}
+	return 0
+}
+
 type GetInfoIdResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -526,6 +525,179 @@ func (x *GetInfoIdResp) GetData() []string {
 	return nil
 }
 
+type DrawClueReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	PositionId int64 `protobuf:"varint,1,opt,name=positionId,proto3" json:"positionId,omitempty"`
+	Count      int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
+}
+
+func (x *DrawClueReq) Reset() {
+	*x = DrawClueReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_biService_proto_msgTypes[7]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *DrawClueReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DrawClueReq) ProtoMessage() {}
+
+func (x *DrawClueReq) ProtoReflect() protoreflect.Message {
+	mi := &file_biService_proto_msgTypes[7]
+	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 DrawClueReq.ProtoReflect.Descriptor instead.
+func (*DrawClueReq) Descriptor() ([]byte, []int) {
+	return file_biService_proto_rawDescGZIP(), []int{7}
+}
+
+func (x *DrawClueReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
+func (x *DrawClueReq) GetCount() int64 {
+	if x != nil {
+		return x.Count
+	}
+	return 0
+}
+
+type CallReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	PositionId int64  `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty"`
+	Phone      string `protobuf:"bytes,2,opt,name=phone,proto3" json:"phone,omitempty"`
+}
+
+func (x *CallReq) Reset() {
+	*x = CallReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_biService_proto_msgTypes[8]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *CallReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CallReq) ProtoMessage() {}
+
+func (x *CallReq) ProtoReflect() protoreflect.Message {
+	mi := &file_biService_proto_msgTypes[8]
+	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 CallReq.ProtoReflect.Descriptor instead.
+func (*CallReq) Descriptor() ([]byte, []int) {
+	return file_biService_proto_rawDescGZIP(), []int{8}
+}
+
+func (x *CallReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
+func (x *CallReq) GetPhone() string {
+	if x != nil {
+		return x.Phone
+	}
+	return ""
+}
+
+type Resp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ErrorCode int64  `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"`
+	ErrorMsg  string `protobuf:"bytes,2,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"`
+	Status    int64  `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
+}
+
+func (x *Resp) Reset() {
+	*x = Resp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_biService_proto_msgTypes[9]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Resp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Resp) ProtoMessage() {}
+
+func (x *Resp) ProtoReflect() protoreflect.Message {
+	mi := &file_biService_proto_msgTypes[9]
+	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 Resp.ProtoReflect.Descriptor instead.
+func (*Resp) Descriptor() ([]byte, []int) {
+	return file_biService_proto_rawDescGZIP(), []int{9}
+}
+
+func (x *Resp) GetErrorCode() int64 {
+	if x != nil {
+		return x.ErrorCode
+	}
+	return 0
+}
+
+func (x *Resp) GetErrorMsg() string {
+	if x != nil {
+		return x.ErrorMsg
+	}
+	return ""
+}
+
+func (x *Resp) GetStatus() int64 {
+	if x != nil {
+		return x.Status
+	}
+	return 0
+}
+
 var File_biService_proto protoreflect.FileDescriptor
 
 var file_biService_proto_rawDesc = []byte{
@@ -585,26 +757,46 @@ var file_biService_proto_rawDesc = []byte{
 	0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f,
 	0x72, 0x4d, 0x73, 0x67, 0x12, 0x1f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01,
 	0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52,
-	0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x24, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a,
+	0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a,
 	0x65, 0x63, 0x74, 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, 0x5f, 0x0a, 0x0d, 0x47,
-	0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 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, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
-	0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x99, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63,
+	0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e,
+	0x74, 0x22, 0x5f, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 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, 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,
+	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,
+	0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x40, 0x0a, 0x07, 0x43, 0x61, 0x6c, 0x6c, 0x52,
+	0x65, 0x71, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69,
+	0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
+	0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x5a, 0x0a, 0x04, 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, 0x16, 0x0a,
+	0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73,
+	0x74, 0x61, 0x74, 0x75, 0x73, 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,
 }
 
 var (
@@ -619,7 +811,7 @@ func file_biService_proto_rawDescGZIP() []byte {
 	return file_biService_proto_rawDescData
 }
 
-var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
+var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
 var file_biService_proto_goTypes = []interface{}{
 	(*MyDataAssetReq)(nil),  // 0: MyDataAssetReq
 	(*MyDataAssetResp)(nil), // 1: MyDataAssetResp
@@ -628,6 +820,9 @@ var file_biService_proto_goTypes = []interface{}{
 	(*AddProjectResp)(nil),  // 4: AddProjectResp
 	(*AddProject)(nil),      // 5: AddProject
 	(*GetInfoIdResp)(nil),   // 6: GetInfoIdResp
+	(*DrawClueReq)(nil),     // 7: drawClueReq
+	(*CallReq)(nil),         // 8: CallReq
+	(*Resp)(nil),            // 9: Resp
 }
 var file_biService_proto_depIdxs = []int32{
 	2, // 0: MyDataAssetResp.data:type_name -> MyDataAsset
@@ -635,11 +830,15 @@ var file_biService_proto_depIdxs = []int32{
 	0, // 2: BiService.myDataAsset:input_type -> MyDataAssetReq
 	3, // 3: BiService.addProject:input_type -> AddProjectReq
 	3, // 4: BiService.getInfoId:input_type -> AddProjectReq
-	1, // 5: BiService.myDataAsset:output_type -> MyDataAssetResp
-	4, // 6: BiService.addProject:output_type -> AddProjectResp
-	6, // 7: BiService.getInfoId:output_type -> GetInfoIdResp
-	5, // [5:8] is the sub-list for method output_type
-	2, // [2:5] is the sub-list for method input_type
+	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
@@ -735,6 +934,42 @@ func file_biService_proto_init() {
 				return nil
 			}
 		}
+		file_biService_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*DrawClueReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_biService_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*CallReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_biService_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Resp); 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{
@@ -742,7 +977,7 @@ func file_biService_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_biService_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   7,
+			NumMessages:   10,
 			NumExtensions: 0,
 			NumServices:   1,
 		},
@@ -755,155 +990,3 @@ func file_biService_proto_init() {
 	file_biService_proto_goTypes = nil
 	file_biService_proto_depIdxs = nil
 }
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// BiServiceClient is the client API for BiService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type BiServiceClient interface {
-	MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
-	AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error)
-	GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error)
-}
-
-type biServiceClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewBiServiceClient(cc grpc.ClientConnInterface) BiServiceClient {
-	return &biServiceClient{cc}
-}
-
-func (c *biServiceClient) MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error) {
-	out := new(MyDataAssetResp)
-	err := c.cc.Invoke(ctx, "/BiService/myDataAsset", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *biServiceClient) AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
-	out := new(AddProjectResp)
-	err := c.cc.Invoke(ctx, "/BiService/addProject", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *biServiceClient) GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error) {
-	out := new(GetInfoIdResp)
-	err := c.cc.Invoke(ctx, "/BiService/getInfoId", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-// BiServiceServer is the server API for BiService service.
-type BiServiceServer interface {
-	MyDataAsset(context.Context, *MyDataAssetReq) (*MyDataAssetResp, error)
-	AddProject(context.Context, *AddProjectReq) (*AddProjectResp, error)
-	GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error)
-}
-
-// UnimplementedBiServiceServer can be embedded to have forward compatible implementations.
-type UnimplementedBiServiceServer struct {
-}
-
-func (*UnimplementedBiServiceServer) MyDataAsset(context.Context, *MyDataAssetReq) (*MyDataAssetResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method MyDataAsset not implemented")
-}
-func (*UnimplementedBiServiceServer) AddProject(context.Context, *AddProjectReq) (*AddProjectResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method AddProject not implemented")
-}
-func (*UnimplementedBiServiceServer) GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method GetInfoId not implemented")
-}
-
-func RegisterBiServiceServer(s *grpc.Server, srv BiServiceServer) {
-	s.RegisterService(&_BiService_serviceDesc, srv)
-}
-
-func _BiService_MyDataAsset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(MyDataAssetReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(BiServiceServer).MyDataAsset(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/BiService/MyDataAsset",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(BiServiceServer).MyDataAsset(ctx, req.(*MyDataAssetReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _BiService_AddProject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(AddProjectReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(BiServiceServer).AddProject(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/BiService/AddProject",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(BiServiceServer).AddProject(ctx, req.(*AddProjectReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _BiService_GetInfoId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(AddProjectReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(BiServiceServer).GetInfoId(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/BiService/GetInfoId",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(BiServiceServer).GetInfoId(ctx, req.(*AddProjectReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-var _BiService_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "BiService",
-	HandlerType: (*BiServiceServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "myDataAsset",
-			Handler:    _BiService_MyDataAsset_Handler,
-		},
-		{
-			MethodName: "addProject",
-			Handler:    _BiService_AddProject_Handler,
-		},
-		{
-			MethodName: "getInfoId",
-			Handler:    _BiService_GetInfoId_Handler,
-		},
-	},
-	Streams:  []grpc.StreamDesc{},
-	Metadata: "biService.proto",
-}

+ 257 - 0
rpc/pb/biService_grpc.pb.go

@@ -0,0 +1,257 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+// versions:
+// - protoc-gen-go-grpc v1.3.0
+// - protoc             v3.19.4
+// source: biService.proto
+
+package pb
+
+import (
+	context "context"
+	grpc "google.golang.org/grpc"
+	codes "google.golang.org/grpc/codes"
+	status "google.golang.org/grpc/status"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
+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"
+)
+
+// BiServiceClient is the client API for BiService service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type BiServiceClient interface {
+	MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
+	AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error)
+	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)
+}
+
+type biServiceClient struct {
+	cc grpc.ClientConnInterface
+}
+
+func NewBiServiceClient(cc grpc.ClientConnInterface) BiServiceClient {
+	return &biServiceClient{cc}
+}
+
+func (c *biServiceClient) MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error) {
+	out := new(MyDataAssetResp)
+	err := c.cc.Invoke(ctx, BiService_MyDataAsset_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *biServiceClient) AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
+	out := new(AddProjectResp)
+	err := c.cc.Invoke(ctx, BiService_AddProject_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *biServiceClient) GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error) {
+	out := new(GetInfoIdResp)
+	err := c.cc.Invoke(ctx, BiService_GetInfoId_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *biServiceClient) DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
+	out := new(AddProjectResp)
+	err := c.cc.Invoke(ctx, BiService_DrawClue_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *biServiceClient) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*Resp, error) {
+	out := new(Resp)
+	err := c.cc.Invoke(ctx, BiService_Call_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
+type BiServiceServer interface {
+	MyDataAsset(context.Context, *MyDataAssetReq) (*MyDataAssetResp, error)
+	AddProject(context.Context, *AddProjectReq) (*AddProjectResp, error)
+	GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error)
+	DrawClue(context.Context, *DrawClueReq) (*AddProjectResp, error)
+	Call(context.Context, *CallReq) (*Resp, error)
+	mustEmbedUnimplementedBiServiceServer()
+}
+
+// UnimplementedBiServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedBiServiceServer struct {
+}
+
+func (UnimplementedBiServiceServer) MyDataAsset(context.Context, *MyDataAssetReq) (*MyDataAssetResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method MyDataAsset not implemented")
+}
+func (UnimplementedBiServiceServer) AddProject(context.Context, *AddProjectReq) (*AddProjectResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method AddProject not implemented")
+}
+func (UnimplementedBiServiceServer) GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetInfoId not implemented")
+}
+func (UnimplementedBiServiceServer) DrawClue(context.Context, *DrawClueReq) (*AddProjectResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method DrawClue not implemented")
+}
+func (UnimplementedBiServiceServer) Call(context.Context, *CallReq) (*Resp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
+}
+func (UnimplementedBiServiceServer) mustEmbedUnimplementedBiServiceServer() {}
+
+// UnsafeBiServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to BiServiceServer will
+// result in compilation errors.
+type UnsafeBiServiceServer interface {
+	mustEmbedUnimplementedBiServiceServer()
+}
+
+func RegisterBiServiceServer(s grpc.ServiceRegistrar, srv BiServiceServer) {
+	s.RegisterService(&BiService_ServiceDesc, srv)
+}
+
+func _BiService_MyDataAsset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(MyDataAssetReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).MyDataAsset(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_MyDataAsset_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).MyDataAsset(ctx, req.(*MyDataAssetReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _BiService_AddProject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(AddProjectReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).AddProject(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_AddProject_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).AddProject(ctx, req.(*AddProjectReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _BiService_GetInfoId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(AddProjectReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).GetInfoId(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_GetInfoId_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).GetInfoId(ctx, req.(*AddProjectReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _BiService_DrawClue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(DrawClueReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).DrawClue(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_DrawClue_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).DrawClue(ctx, req.(*DrawClueReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _BiService_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(CallReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).Call(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_Call_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).Call(ctx, req.(*CallReq))
+	}
+	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)
+var BiService_ServiceDesc = grpc.ServiceDesc{
+	ServiceName: "BiService",
+	HandlerType: (*BiServiceServer)(nil),
+	Methods: []grpc.MethodDesc{
+		{
+			MethodName: "myDataAsset",
+			Handler:    _BiService_MyDataAsset_Handler,
+		},
+		{
+			MethodName: "addProject",
+			Handler:    _BiService_AddProject_Handler,
+		},
+		{
+			MethodName: "getInfoId",
+			Handler:    _BiService_GetInfoId_Handler,
+		},
+		{
+			MethodName: "drawClue",
+			Handler:    _BiService_DrawClue_Handler,
+		},
+		{
+			MethodName: "Call",
+			Handler:    _BiService_Call_Handler,
+		},
+	},
+	Streams:  []grpc.StreamDesc{},
+	Metadata: "biService.proto",
+}

+ 290 - 0
service/clue.go

@@ -0,0 +1,290 @@
+package service
+
+import (
+	"database/sql"
+	"log"
+	"math"
+	"time"
+
+	common "app.yhyue.com/moapp/jybase/common"
+	. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
+)
+
+func DrawClue(this *biservice.DrawClueReq, countLimit int) *biservice.AddProjectResp {
+	count1 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 1})
+	count2 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 2})
+	// count3 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 3})
+	counts1, counts2, counts3 := int64(0), int64(0), int64(0)
+	counts1 = int64(math.Ceil(float64(this.Count) / float64(10) * 2))
+	if this.Count-counts1 == 0 {
+		counts2 = 0
+		counts3 = 0
+	} else {
+		counts2 = int64(math.Ceil(float64(this.Count) / float64(10) * 4))
+		if this.Count-counts1-counts2 == 0 {
+			counts3 = 0
+		} else {
+			counts3 = this.Count - counts1 - counts2
+		}
+	}
+	if counts1 > count1 {
+		counts2 += counts1 - count1
+		counts1 = count1
+	}
+	if counts2 > count2 {
+		counts3 += counts2 - count2
+		counts2 = count2
+	}
+	log.Println(count1, count2)
+	log.Println(counts1, counts2, counts3)
+	count := DrawClues(this.PositionId, counts1, counts2, counts3, int64(countLimit))
+	log.Println("领取数量 ", count)
+	return &biservice.AddProjectResp{
+		ErrorCode: 0,
+		Data: &biservice.AddProject{
+			Status: 1,
+			Count:  int64(count),
+		},
+	}
+}
+
+func DrawClues(positionId, count1, count2, count3, countLimit int64) int {
+	data1, data2, data3, drawCount := &[]map[string]interface{}{}, &[]map[string]interface{}{}, &[]map[string]interface{}{}, 0
+	if count1 > 0 {
+		data1 = JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 1}, "", "", 0, int(count1))
+	}
+	if count2 > 0 {
+		data2 = JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 2}, "", "", 0, int(count2))
+	}
+	if count3 > 0 {
+		data3 = JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 3}, "", "", 0, int(count3))
+	}
+	nowTime := time.Now().Format("2006-01-02 15:04:05")
+	seatNumber, name := getSeatNumber(positionId)
+	if data1 != nil && len(*data1) > 0 {
+		for _, v := range *data1 {
+			//update postionid and update record
+			clueId := common.Int64All(v["clue_id"])
+			if JyBiTidb.Count("dwd_f_crm_private_sea", map[string]interface{}{"position_id": positionId}) < countLimit {
+				if JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+					ok1 := JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber, "is_assign": 1, "trailstatus": "01", "updatetime": nowTime, "comeintime": nowTime})
+					ok2 := JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
+					seaId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      clueId,
+						"seatNumber":   seatNumber,
+						"position_id":  positionId,
+						"comeintime":   nowTime,
+						"comeinsource": 3,
+						"is_task":      1,
+						"task_time":    nowTime,
+						"tasktime":     nowTime,
+						"taskstatus":   0,
+						"tasksource":   "领取公海线索",
+					})
+					recordId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "position_id",
+						"change_type":  "所属人变更",
+						"old_value":    "/",
+						"new_value":    name,
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+					recordId1 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": positionId,
+						"change_type": "领取公海线索",
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": positionId,
+					})
+					recordId2 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": positionId,
+						"change_type": "加入任务车",
+						"new_value":   "领取公海线索",
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": positionId,
+					})
+					recordId3 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "trailstatus",
+						"change_type":  "基本信息变更",
+						"new_value":    "新增",
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+					return ok1 && ok2 && seaId > 0 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > 0
+				}) {
+					drawCount++
+					log.Println("领取线索1成功")
+				} else {
+					log.Println("领取线索1失败")
+				}
+			}
+		}
+	}
+	if data2 != nil && len(*data2) > 0 {
+		for _, v := range *data2 {
+			clueId := common.Int64All(v["clue_id"])
+			if JyBiTidb.Count("dwd_f_crm_private_sea", map[string]interface{}{"position_id": positionId}) < countLimit {
+				if JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+					ok1 := JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber, "is_assign": 1, "trailstatus": "01", "updatetime": nowTime, "comeintime": nowTime})
+					ok2 := JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
+					seaId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      clueId,
+						"seatNumber":   seatNumber,
+						"position_id":  positionId,
+						"comeintime":   nowTime,
+						"comeinsource": 3,
+						"is_task":      1,
+						"task_time":    nowTime,
+						"tasktime":     nowTime,
+						"taskstatus":   0,
+						"tasksource":   "领取公海线索",
+					})
+					recordId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "position_id",
+						"change_type":  "所属人变更",
+						"old_value":    "/",
+						"new_value":    name,
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+					recordId1 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": positionId,
+						"change_type": "领取公海线索",
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": positionId,
+					})
+					recordId2 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": positionId,
+						"change_type": "加入任务车",
+						"new_value":   "领取公海线索",
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": positionId,
+					})
+					recordId3 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "trailstatus",
+						"change_type":  "基本信息变更",
+						"new_value":    "新增",
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+					return ok1 && ok2 && seaId > 0 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > 0
+				}) {
+					drawCount++
+					log.Println("领取线索2成功")
+				} else {
+					log.Println("领取线索2失败")
+				}
+			}
+		}
+	}
+	if data3 != nil && len(*data3) > 0 {
+		for _, v := range *data3 {
+			clueId := common.Int64All(v["clue_id"])
+			if JyBiTidb.Count("dwd_f_crm_private_sea", map[string]interface{}{"position_id": positionId}) < countLimit {
+				if JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+					ok1 := JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber, "is_assign": 1, "trailstatus": "01", "updatetime": nowTime, "comeintime": nowTime})
+					ok2 := JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
+					seaId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      clueId,
+						"seatNumber":   seatNumber,
+						"position_id":  positionId,
+						"comeintime":   nowTime,
+						"comeinsource": 3,
+						"is_task":      1,
+						"task_time":    nowTime,
+						"tasktime":     nowTime,
+						"taskstatus":   0,
+						"tasksource":   "领取公海线索",
+					})
+					recordId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "position_id",
+						"change_type":  "所属人变更",
+						"old_value":    "/",
+						"new_value":    name,
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+					recordId1 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": positionId,
+						"change_type": "领取公海线索",
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": positionId,
+					})
+					recordId2 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":     clueId,
+						"position_id": positionId,
+						"change_type": "加入任务车",
+						"new_value":   "领取公海线索",
+						"createtime":  nowTime,
+						"BCPCID":      common.GetRandom(32),
+						"operator_id": positionId,
+					})
+					recordId3 := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "trailstatus",
+						"change_type":  "基本信息变更",
+						"new_value":    "新增",
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+					return ok1 && ok2 && seaId > 0 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > 0
+				}) {
+					drawCount++
+					log.Println("领取线索3成功")
+				} else {
+					log.Println("领取线索3失败")
+				}
+			}
+		}
+	}
+	return drawCount
+}
+
+func getSeatNumber(positionId int64) (seatNumber, name string) {
+	positionData := JyTidb.FindOne("base_position", map[string]interface{}{"id": positionId}, "", "")
+	if positionData != nil && len(*positionData) > 0 {
+		userId := common.Int64All((*positionData)["user_id"])
+		if userId > 0 {
+			userData, ok := Mgo.FindOne("user", map[string]interface{}{"base_user_id": userId})
+			if ok && userData != nil && len(*userData) > 0 {
+				s_phone := common.ObjToString((*userData)["s_phone"])
+				if s_phone == "" {
+					s_phone = common.ObjToString((*userData)["s_m_phone"])
+				}
+				saleData := JyBiTidb.FindOne("jy_salesperson_info", map[string]interface{}{"phone": s_phone}, "", "")
+				if saleData != nil && len(*saleData) > 0 {
+					seatNumber = common.ObjToString((*saleData)["seatNumber"])
+					name = common.ObjToString((*saleData)["name"])
+				}
+			}
+		}
+	}
+	return
+}

+ 79 - 0
service/hlyj.go

@@ -0,0 +1,79 @@
+package service
+
+import (
+	"context"
+	"log"
+	"time"
+
+	"app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/redis"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+)
+
+type HlyjStruct struct {
+	Account      string
+	TokenUrl     string
+	Appid        string
+	Secret       string
+	CallUrl      string
+	Integratedid string
+	CallFlag     int
+}
+
+func (this *HlyjStruct) GetRedisKey() string {
+	return "hlyj_access_token"
+}
+
+//获取token
+func (this *HlyjStruct) GetAccessToken() string {
+	//取缓存
+	if redisToken := redis.GetStr("newother", this.GetRedisKey()); redisToken != "" {
+		return redisToken
+	}
+
+	str := Get(this.TokenUrl, g.Map{"account": this.Account, "appid": this.Appid, "secret": this.Secret})
+
+	token, _ := gconv.Map(str)["accessToken"].(string)
+
+	// 计算时间差
+	invalidTime, _ := gconv.Map(str)["invalidTime"].(string)
+	t, _ := time.ParseInLocation(date.Date_Full_Layout, invalidTime, time.Local)
+	duration := time.Since(t)
+	timeout := -gconv.Int(duration.Seconds()) - 60 //
+
+	//缓存
+	redis.Put("newother", this.GetRedisKey(), token, timeout)
+	return token
+}
+
+func Get(url string, param map[string]interface{}) (str string) {
+	ctx := context.Background()
+	if r, err := g.Client().Get(ctx, url, param); err != nil {
+		g.Log().Error(ctx, err)
+	} else {
+		defer r.Close()
+		str = r.ReadAllString()
+		log.Println(url, "-", str)
+	}
+	return
+}
+
+//打电话
+func (this *HlyjStruct) Call(phone string, positionId int64) bool {
+	//获取token
+	token := this.GetAccessToken()
+	if token == "" {
+		log.Println("未获取到token")
+		return false
+	}
+	//获取坐席id
+	integratedid, _ := getSeatNumber(positionId)
+	if integratedid == "" {
+		log.Println("未获取到坐席id")
+		return false
+	}
+	//打电话接口
+	ret := Get(this.CallUrl, g.Map{"flag": this.CallFlag, "account": this.Account, "integratedid": integratedid, "accessToken": token, "phonenum": phone})
+	return ret == "200"
+}