Selaa lähdekoodia

Merge remote-tracking branch 'origin/feature/v1.0.4' into dev_v1.0.4_wh

# Conflicts:
#	api/application.api
#	api/internal/handler/routes.go
#	api/internal/types/types.go
WH01243 1 vuosi sitten
vanhempi
commit
c4cfeddce5

BIN
api/api.exe


+ 88 - 0
api/application.api

@@ -201,6 +201,66 @@ type (
 		PageSize         int64  `json:"pageSize,optional"`
 		PageIndex        int64  `json:"pageIndex,optional"`
 	}
+	ProjectListReq {
+		PositionId   int64  `header:"positionId,optional"`
+		EntId        string `header:"entId,optional"`
+		EntUserId    string `header:"entUserId,optional"`
+		DeptId       string `header:"deptId,optional"` //部门id
+		PageNum      int64  `json:"pageNum"`
+		PageSize     int64  `json:"pageSize"`
+		BusinessType string `json:"businessType"`
+		SaleStatus   string `json:"saleStatus"`
+		ProjectName  string `json:"projectName"`
+		StartTime    int64  `json:"startTime"`
+		EntTime      int64  `json:"entTime"`
+		Area         string `json:"area"`
+		City         string `json:"city"`
+		District     string `json:"district"`
+		PropertyForm string `json:"propertyForm"`
+		SubClass     string `json:"subClass"`
+		Amount       string `json:"amount"`
+	}
+	PnameAssReq {
+		ProjectName string `json:"projectName"`
+	}
+	CoopHistoryReq {
+		Pid string `json:"porjectId"`
+	}
+	AddOrUpdateReq {
+		PositionId             int64  `header:"positionId"`
+		EntUserId              int64  `header:"entUserId,optional"`
+		EntId                  int64  `header:"entId,optional"`
+		EntDeptId              int64  `header:"entDeptId,optional"`
+		Company_id             string `json:"company_id,optional"`
+		Company_name           string `json:"company_name,optional"`
+		Contact_person         string `json:"contact_person,optional"`
+		Contact_phone          string `json:"contact_phone,optional"`
+		Introduce_owner_id     string `json:"introduce_owner_id,optional"`
+		Introduce_owner_name   string `json:"introduce_owner_name,optional"`
+		Introduce_project_id   string `json:"introduce_project_id,optional"`
+		Introduce_project_name string `json:"introduce_project_name,optional"`
+		Id                     int64  `json:"id,optional"`
+		Type                   string `json:"type,optional"`
+	}
+	AssociateReq {
+		Name string `json:"name"`
+		Type string `json:"type"`
+	}
+	AllprojectReq {
+		PositionId int64  `header:"positionId"`
+		Name       string `json:"name,optional"`
+	}
+	NetWorkListReq {
+		PositionId      int64  `header:"positionId"`
+		Type            string `json:"type,optional"`
+		Name            string `json:"name,optional"`
+		Monitor         string `json:"monitor,optional"`
+		Starttime       string `json:"starttime,optional"`
+		Endtime         string `json:"endtime,optional"`
+		Order_amount    string `json:"order_amount,optional"`
+		Current_page    string `json:"current_page,optional"`
+		Project_matchme string `json:"project_matchme,optional"`
+	}
 )
 
 @server (
@@ -259,4 +319,32 @@ service crmApplication {
 	@doc "人脉可达潜客业主列表"
 	@handler ownerList
 	post /crmApplication/owner/List (OwnerListReq) returns (Reply)
+
+	@doc "人脉可达商机列表"
+	@handler projectList
+	post /crmApplication/network/project/list (ProjectListReq) returns (Reply)
+
+	@doc "项目公关渠道分析-项目名称联想"
+	@handler PrPnameAss
+	post /crmApplication/pr/pname/ass (PnameAssReq) returns (Reply)
+
+	@doc "项目公关渠道分析-与业主合作历史"
+	@handler CoopHistoryList
+	post /crmApplication/pr/coop/history (CoopHistoryReq) returns (Reply)
+
+	@doc "人脉库-添加/修改人脉"
+	@handler addOrUpdate
+	post /crmApplication/network/addOrUpdate (AddOrUpdateReq) returns (Reply)
+
+	@doc "人脉库-业主名称联想"
+	@handler associate
+	post /crmApplication/network/associate (AssociateReq) returns (Reply)
+
+	@doc "人脉库-全部人脉项目"
+	@handler allproject
+	post /crmApplication/network/allproject (AllprojectReq) returns (Reply)
+
+	@doc "人脉库-列表"
+	@handler list
+	post /crmApplication/network/list (NetWorkListReq) returns (Reply)
 }

BIN
api/application_api


+ 5 - 4
api/common/initconfig.go

@@ -1,13 +1,14 @@
 package common
 
 import (
-	"app.yhyue.com/moapp/jypkg/middleground"
 	"context"
 	"flag"
 	"fmt"
 	"log"
 	"time"
 
+	"app.yhyue.com/moapp/jypkg/middleground"
+
 	. "app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
@@ -53,7 +54,7 @@ var (
 	ClickhouseConn    driver.Conn
 )
 
-func init() {
+func InitConf() {
 	conf.MustLoad(*configFile, &C)
 	log.Println("初始化配置") //
 
@@ -178,9 +179,9 @@ func init() {
 	/*	Middleground = middleground.NewMiddleground([]string{"192.168.3.206:2379"}).
 		RegResourceCenter(C.ResourceCenterKey)*/
 	conf.MustLoad(*pushFile, &Push)
-	connectClickhouse(DB.Clickhouse)
+	ConnectClickhouse(DB.Clickhouse)
 }
-func connectClickhouse(cHouseConfig *config.CHouseConfig) error {
+func ConnectClickhouse(cHouseConfig *config.CHouseConfig) error {
 	var (
 		ctx = context.Background()
 		err error

+ 38 - 0
api/common/network.go

@@ -0,0 +1,38 @@
+package common
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+//人脉通公用方法
+var NetworkCom = &networkCom{}
+
+type networkCom struct{}
+
+//根据标签类型获取标签占位
+func (n *networkCom) GetEntTagSeat(labelType int) []string {
+	rows, err := ClickhouseConn.Query(context.Background(), `select bitmap_num from information.ent_label where label_type=?`, labelType)
+	if err != nil {
+		logx.Error(err)
+		return nil
+	}
+	array := []string{}
+	for rows.Next() {
+		var (
+			bitmap_num int8
+		)
+		if err := rows.Scan(&bitmap_num); err != nil {
+			logx.Error(err)
+			continue
+		}
+		array = append(array, fmt.Sprint(bitmap_num))
+	}
+	rows.Close()
+	if err := rows.Err(); err != nil {
+		logx.Error(err)
+	}
+	return array
+}

+ 1 - 0
api/crmapplication.go

@@ -17,6 +17,7 @@ import (
 )
 
 func main() {
+	InitConf()
 	//注册代理服务
 	closeNotify, err := node.NewNode(C.Gateway.Etcd...).Register(C.Gateway.ServerCode, mc.InterfaceToStr(C.Port))
 	if err != nil {

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

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

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

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

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

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

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

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func CoopHistoryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CoopHistoryReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewCoopHistoryListLogic(r.Context(), svcCtx)
+		resp, err := l.CoopHistoryList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

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

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

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

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func projectListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ProjectListReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewProjectListLogic(r.Context(), svcCtx)
+		resp, err := l.ProjectList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

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

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func PrPnameAssHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.PnameAssReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewPrPnameAssLogic(r.Context(), svcCtx)
+		resp, err := l.PrPnameAss(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

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

@@ -72,11 +72,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/crmApplication/info/canAdd",
 				Handler: canAddReqHandler(serverCtx),
 			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/crmApplication/owner/List",
-				Handler: ownerListHandler(serverCtx),
-			},
 		},
 		rest.WithMaxBytes(104857600),
 	)

+ 30 - 0
api/internal/logic/addorupdatelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type AddOrUpdateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAddOrUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddOrUpdateLogic {
+	return &AddOrUpdateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AddOrUpdateLogic) AddOrUpdate(req *types.AddOrUpdateReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/internal/logic/allprojectlogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type AllprojectLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAllprojectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AllprojectLogic {
+	return &AllprojectLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AllprojectLogic) Allproject(req *types.AllprojectReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 30 - 0
api/internal/logic/associatelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type AssociateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewAssociateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssociateLogic {
+	return &AssociateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *AssociateLogic) Associate(req *types.AssociateReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 29 - 0
api/internal/logic/coophistorylistlogic.go

@@ -0,0 +1,29 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CoopHistoryListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCoopHistoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CoopHistoryListLogic {
+	return &CoopHistoryListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *CoopHistoryListLogic) CoopHistoryList(req *types.CoopHistoryReq) (resp *types.Reply, err error) {
+
+	return
+}

+ 30 - 0
api/internal/logic/listlogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
+	return &ListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ListLogic) List(req *types.NetWorkListReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 36 - 0
api/internal/logic/projectlistlogic.go

@@ -0,0 +1,36 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ProjectListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewProjectListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProjectListLogic {
+	return &ProjectListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ProjectListLogic) ProjectList(req *types.ProjectListReq) (resp *types.Reply, err error) {
+	resp = &types.Reply{}
+	list, hasNextPage, count := service.GetProjectList(req)
+	resp.Data = map[string]interface{}{
+		"list":        list,
+		"count":       count,
+		"hasNextPage": hasNextPage,
+	}
+	return
+}

+ 45 - 0
api/internal/logic/prpnameasslogic.go

@@ -0,0 +1,45 @@
+package logic
+
+import (
+	elastic "app.yhyue.com/moapp/jybase/esv7"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+var (
+	INDEX      = "bidding"
+	findfields = `"projectp_name", "project_id"`
+)
+
+type PrPnameAssLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewPrPnameAssLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PrPnameAssLogic {
+	return &PrPnameAssLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *PrPnameAssLogic) PrPnameAss(req *types.PnameAssReq) (resp *types.Reply, err error) {
+	resp = &types.Reply{}
+	if req.ProjectName != "" {
+		esq := `{"query": {"bool": {"must": [{"match": {"projectname.pname": [` + req.ProjectName + ` ]}}]}}}`
+		binfo := elastic.GetAllByNgram(INDEX, INDEX, esq, findfields, "", "", 0, 10, 0, false)
+		if binfo != nil && len(*binfo) > 0 {
+			resp.Error_code = 0
+			resp.Data = *binfo
+		}
+	} else {
+		resp.Error_code = -1
+		resp.Error_msg = "项目名称不能为空"
+	}
+	return
+}

+ 9 - 8
api/internal/service/employService.go

@@ -1,6 +1,12 @@
 package service
 
 import (
+	"database/sql"
+	"fmt"
+	"log"
+	"strings"
+	"time"
+
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	elastic "app.yhyue.com/moapp/jybase/es"
@@ -8,13 +14,8 @@ import (
 	MC "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
 	"bp.jydev.jianyu360.cn/CRM/application/entity"
-	"database/sql"
-	"fmt"
 	"github.com/RoaringBitmap/roaring"
 	"github.com/gogf/gf/v2/util/gconv"
-	"log"
-	"strings"
-	"time"
 )
 
 const (
@@ -898,9 +899,9 @@ func EmployHandle(valueMap map[string]interface{}, employData map[string]interfa
 		clueSql := ""
 		chanceSql := ""
 		if positionType == 0 {
-			customSql = fmt.Sprintf("select  COUNT(1) from  %s where  %s  in (%s) and  position_id=?", entity.CUSTOM, findKey, employArrStr, positionId)
-			clueSql = fmt.Sprintf("select  COUNT(1) from  %s where employ_info_id  in (%s) and  position_id=?", entity.SALE_CLUE, employArrStr, positionId)
-			chanceSql = fmt.Sprintf("select  COUNT(1) from  %s where employ_info_id  in (%s) and  position_id=?", entity.SALE_CHANCE, employArrStr, positionId)
+			customSql = fmt.Sprintf("select  COUNT(1) from  %s where  %s  in (%s) and  position_id=%d", entity.CUSTOM, findKey, employArrStr, positionId)
+			clueSql = fmt.Sprintf("select  COUNT(1) from  %s where employ_info_id  in (%s) and  position_id=%d", entity.SALE_CLUE, employArrStr, positionId)
+			chanceSql = fmt.Sprintf("select  COUNT(1) from  %s where employ_info_id  in (%s) and  position_id=%d", entity.SALE_CHANCE, employArrStr, positionId)
 		} else {
 			customSql = fmt.Sprintf("select  COUNT(1) from  %s where  %s  in (%s)", entity.CUSTOM, findKey, employArrStr)
 			clueSql = fmt.Sprintf("select  COUNT(1) from  %s where employ_info_id  in (%s)", entity.SALE_CLUE, employArrStr)

+ 128 - 0
api/internal/service/network.go

@@ -0,0 +1,128 @@
+package service
+
+import (
+	"database/sql"
+	"fmt"
+	"strings"
+
+	. "app.yhyue.com/moapp/jybase/common"
+	. "app.yhyue.com/moapp/jybase/date"
+	. "app.yhyue.com/moapp/jybase/es"
+	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+)
+
+var Network = &network{}
+
+type network struct {
+}
+
+//人脉库-添加/修改人脉
+func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
+	reply := &types.Reply{}
+	itype := 0
+	//firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
+	switch in.Type {
+	case "firstparty":
+		itype = 1
+	case "supplier:供应商":
+		itype = 2
+	case "adiffb":
+		itype = 3
+	case "middleman":
+		itype = 4
+	case "agency":
+		itype = 5
+	}
+	nowFormat := NowFormat(Date_Full_Layout)
+	var saveIntroduce = func(tx *sql.Tx, cid int64) int64 {
+		values := []interface{}{}
+		if in.Introduce_owner_id != "" {
+			for k, v := range strings.Split(in.Introduce_owner_id, ",") {
+				values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_owner_name, ",")[k], 1, nowFormat)
+			}
+		}
+		if in.Introduce_project_id != "" {
+			for k, v := range strings.Split(in.Introduce_project_id, ",") {
+				values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, strings.Split(in.Introduce_project_name, ",")[k], 2, nowFormat)
+			}
+		}
+		var r3 int64
+		if len(values) > 0 {
+			_, r3 = CrmMysql.InsertBatchByTx(tx, "crm.connection_introduce", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "connection_id", "relate_id", "relate_name", "itype", "create_time"}, values)
+		}
+		return r3
+	}
+	if in.Id > 0 {
+		if CrmMysql.ExecTx("更新人脉", func(tx *sql.Tx) bool {
+			r1 := CrmMysql.UpdateOrDeleteBySqlByTx(tx, `update crm.connection set company_name=?,company_id=?,contact_person=?,contact_phone=?,update_time=? where id=? and position_id=?`, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, nowFormat, in.Id, in.PositionId)
+			r2 := CrmMysql.UpdateOrDeleteBySqlByTx(tx, `delete from crm.connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)
+			return r1 > 0 && r2 >= 0 && saveIntroduce(tx, in.Id) >= 0
+		}) {
+			reply.Data = map[string]interface{}{
+				"status": 1,
+			}
+		} else {
+			reply.Data = map[string]interface{}{
+				"status": 0,
+			}
+		}
+	} else {
+		id := 0
+		if CrmMysql.ExecTx("新增人脉", func(tx *sql.Tx) bool {
+			_, r1 := CrmMysql.InsertBatchByTx(tx, "crm.connection", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "itype", "company_name", "company_id", "contact_person", "contact_phone", "status", "create_time", "update_time"}, []interface{}{in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, itype, in.Company_name, in.Company_id, in.Contact_person, in.Contact_phone, 1, nowFormat, nowFormat})
+			return r1 > 0 && saveIntroduce(tx, r1) >= 0
+		}) {
+			reply.Data = map[string]interface{}{
+				"status": 1,
+				"id":     id,
+			}
+		} else {
+			reply.Data = map[string]interface{}{
+				"status": 0,
+			}
+		}
+	}
+	return reply
+}
+
+//人脉库-业主名称联想
+func (n *network) Associate(in *types.AssociateReq) *types.Reply {
+	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
+	res := []map[string]interface{}{}
+	must := []string{fmt.Sprintf(`{"multi_match":{"query":"%s","type":"phrase","fields":["company_name"]}}`, in.Name)}
+	switch in.Type {
+	case "firstparty":
+		must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
+		must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
+	case "supplier":
+		must = append(must, fmt.Sprintf(`{"terms":{"company_label":["%s"]}}`, strings.Join(NetworkCom.GetEntTagSeat(2), `","`)))
+		must = append(must, `{"term":{"company_unit_type":3}}`)
+	case "middleman_owner":
+		must = append(must, `{"terms":{"company_unit_type":[1,2]}}`)
+	case "agency":
+		must = append(must, `{"term":{"company_unit_type":4}}`)
+	}
+	datas := VarEs.Get("ent_info", "ent_info", fmt.Sprintf(`{"query":{"bool":{"must":[%s]}},"size":10,"_source":["id","company_name"]}`, strings.Join(must, ",")))
+	if datas != nil {
+		for _, v := range *datas {
+			res = append(res, map[string]interface{}{
+				"company_name": ObjToString(v["company_name"]),
+				"company_id":   ObjToString(v["id"]),
+			})
+		}
+	}
+	return &types.Reply{
+		Data: datas,
+	}
+}
+
+//人脉库-全部人脉项目
+func (n *network) Allproject(in *types.AllprojectReq) *types.Reply {
+	return nil
+}
+
+//人脉库-列表
+func (n *network) List(in *types.NetWorkListReq) *types.Reply {
+	return nil
+}

+ 61 - 0
api/internal/service/network_test.go

@@ -0,0 +1,61 @@
+package service
+
+import (
+	"log"
+	"testing"
+
+	"app.yhyue.com/moapp/jybase/es"
+	"app.yhyue.com/moapp/jybase/mysql"
+	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/config"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+)
+
+func initDb() {
+	CrmMysql = &mysql.Mysql{
+		Address:      "192.168.3.14:4000",
+		UserName:     "root",
+		PassWord:     "=PDT49#80Z!RVv52_z",
+		DBName:       "crm",
+		MaxOpenConns: 5,
+		MaxIdleConns: 5,
+	}
+	CrmMysql.Init()
+	ConnectClickhouse(&config.CHouseConfig{
+		Addr:         "192.168.3.207:19000",
+		UserName:     "jytop",
+		Password:     "pwdTopJy123",
+		DbName:       "jianyu",
+		MaxIdleConns: 2,
+		MaxOpenConns: 2,
+	})
+	es.NewEs("v7", "http://192.168.3.149:9200", 5, "", "")
+}
+func TestAddOrUpdate(t *testing.T) {
+	initDb()
+	res := Network.AddOrUpdate(&types.AddOrUpdateReq{
+		PositionId:             943,
+		Company_id:             "112233445566",
+		Company_name:           "王传进的测试企业1",
+		Contact_person:         "王传进1",
+		Contact_phone:          "15037870765",
+		Introduce_owner_id:     "11,22,33",
+		Introduce_owner_name:   "aa,bb,cc",
+		Introduce_project_id:   "44,55,66",
+		Introduce_project_name: "dd,ee,ff",
+		Type:                   "middleman",
+		Id:                     1,
+	})
+	log.Println(res)
+}
+
+func TestAssociate(t *testing.T) {
+	initDb()
+	//log.Println(NetworkCom.GetEntTagSeat(2))
+	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
+	res := Network.Associate(&types.AssociateReq{
+		Name: "郑州",
+		Type: "firstparty",
+	})
+	log.Println(res.Data)
+}

+ 193 - 0
api/internal/service/plistService.go

@@ -0,0 +1,193 @@
+package service
+
+import (
+	"context"
+	"fmt"
+	"strings"
+
+	"app.yhyue.com/moapp/jybase/common"
+	P "app.yhyue.com/moapp/jybase/mapping"
+	T "bp.jydev.jianyu360.cn/CRM/application/api/common"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+)
+
+const (
+	pageSize = 100
+
+	sql_1 = `SELECT count(1) FROM information.transaction_info WHERE buyer_id = ?`
+)
+
+type ProjectData struct {
+	count       int64
+	hasNextPage bool
+	pList       []*ProjectEntry
+}
+
+type ProjectEntry struct {
+	projectName string
+}
+
+func GetProjectList(req *types.ProjectListReq) (resultList *[]map[string]interface{}, hasNextPage bool, total int) {
+
+	getSql(req)
+
+	//get(req, resultList)
+	//
+	//total = len(resultList)
+	//if total > pageSize {
+	//	resultList = resultList[:pageSize]
+	//	hasNextPage = true
+	//}
+	return
+}
+
+func getSql(req *types.ProjectListReq) (countSql, findSql string) {
+	querys := []string{}
+	//	商机类型
+	if req.BusinessType != "" {
+		querys = append(querys, fmt.Sprintf(" a.business_type in (%s) ", req.BusinessType))
+	}
+	if req.ProjectName != "" {
+		querys = append(querys, " a.projectname like '% "+req.ProjectName+"%'")
+	}
+	if req.StartTime > 0 && req.EntTime > 0 {
+		st := req.StartTime + 90*24*60*60
+		et := req.StartTime + 90*24*60*60
+		querys = append(querys, fmt.Sprintf("  a.endtime>=%d and a.endtime<=%d", st, et))
+	} else if req.StartTime > 0 && req.EntTime == 0 {
+		st := req.StartTime + 90*24*60*60
+		querys = append(querys, fmt.Sprintf(" a.endtime>=%d", st))
+	} else if req.StartTime == 0 && req.EntTime > 0 {
+		et := req.StartTime + 90*24*60*60
+		querys = append(querys, fmt.Sprintf(" a.endtime<=%d", et))
+	} else {
+		querys = append(querys, " a.endtime>0")
+	}
+	var regionArr = []string{}
+	if req.Area != "" || req.City != "" || req.District != "" {
+		//城市
+		city := []string{}
+		for _, v := range strings.Split(req.City, ",") {
+			if P.BidCodeMapping.City[v] != "" {
+				city = append(city, fmt.Sprint(P.BidCodeMapping.City[v]))
+			}
+		}
+		if len(city) > 0 {
+			regionArr = append(regionArr, fmt.Sprintf(" a.city in (%s) ", strings.Join(city, ",")))
+		}
+		//区域
+		area := []string{}
+		for _, v := range strings.Split(req.Area, ",") {
+			if P.BidCodeMapping.Area[v] != "" {
+				area = append(area, fmt.Sprint(P.BidCodeMapping.Area[v]))
+			}
+		}
+		if len(area) > 0 {
+			regionArr = append(regionArr, fmt.Sprintf(" a.area in (%s) ", strings.Join(area, ",")))
+		}
+		//区域
+		district := []string{}
+		if req.District != "" {
+			for _, v := range strings.Split(req.District, ",") {
+				cityName := strings.Split(v, "_")[0]
+				districtName := strings.Split(v, "_")[1]
+				if P.BidCodeMapping.District[cityName][districtName] != "" {
+					district = append(district, fmt.Sprint(P.BidCodeMapping.District[cityName][districtName]))
+				}
+			}
+		}
+		if len(district) > 0 {
+			regionArr = append(regionArr, fmt.Sprintf(" a.district in (%s) ", strings.Join(district, ",")))
+		}
+		if len(regionArr) > 0 {
+			querys = append(querys, fmt.Sprintf("(%s)", strings.Join(regionArr, "or")))
+		}
+	}
+	if req.SubClass != "" {
+		arr := []string{}
+		for _, v := range strings.Split(req.SubClass, ",") {
+			arr = append(arr, fmt.Sprintf(`"物业_%s"`, v))
+		}
+		querys = append(querys, fmt.Sprintf(" a.subclass in (%s) ", strings.Join(regionArr, ",")))
+	}
+	// 项目金额
+	if req.Amount != "" && strings.Contains(req.Amount, "-") {
+		minPriceStr, maxPriceStr := strings.Split(req.Amount, "-")[0], strings.Split(req.Amount, "-")[1]
+		minPrice := common.Int64All(common.Float64All(minPriceStr) * 10000) //换成元
+		maxPrice := common.Int64All(common.Float64All(maxPriceStr) * 10000) //换成元
+		if minPriceStr != "" && maxPriceStr != "" {
+			querys = append(querys, fmt.Sprintf("((a.project_money>=%d and a.project_money<=%d))", minPrice, maxPrice))
+		} else if minPriceStr != "" {
+			querys = append(querys, fmt.Sprintf("(a.project_money>=%d)", minPrice))
+		} else if maxPriceStr != "" {
+			querys = append(querys, fmt.Sprintf("(a.project_money<=%d)", maxPrice))
+		}
+	}
+	//物业业态
+	if req.PropertyForm != "" {
+		arr := []string{}
+		for _, v := range strings.Split(req.PropertyForm, ",") {
+			arr = append(arr, fmt.Sprintf(`"%s"`, v))
+		}
+		querys = append(querys, fmt.Sprintf(" a.property_form in (%s) ", strings.Join(arr, ",")))
+	}
+	findSql = "select a.project_id,a.project_name,a.project_budget,a.project_money,a.business_type,a.buyer"
+	return
+}
+
+// @Author jianghan
+// @Description 处理状态/我的人脉
+// @Date 2024/4/17
+func get(req *types.ProjectListReq, list []map[string]interface{}) (result []map[string]interface{}) {
+	field := "is_handle,is_ignore,is_create"
+	for _, m := range list {
+		query := map[string]interface{}{
+			"position_id": req.PositionId,
+			"relate_id":   common.ObjToString(m["project_id"]),
+			"itype":       2,
+		}
+		info := T.CrmMysql.FindOne("connection_status", query, field, "")
+		if info != nil && len(*info) > 0 {
+			m["is_handle"] = (*info)["is_handle"]
+			m["is_ignore"] = (*info)["is_ignore"]
+			m["is_create"] = (*info)["is_create"]
+		}
+
+		// 人脉、人脉所在单位项目 conn_type: 1/人脉可转介绍项目 conn_type: 2
+		field1 := ""
+		query1 := map[string]interface{}{
+			"position_id": req.PositionId,
+			"company_id":  common.ObjToString(m["buyer_id"]),
+			"status":      1,
+		}
+		info1 := T.CrmMysql.FindOne("connection", query1, field1, "")
+		if info1 != nil && len(*info1) > 0 {
+			m["my_conn"] = true
+			m["conn_type"] = 1
+		} else {
+			m["my_conn"] = false
+		}
+		if m["conn_type"] != nil {
+			query2 := map[string]interface{}{
+				"company_id": common.ObjToString(m["buyer_id"]),
+			}
+			info2 := T.CrmMysql.FindOne("connection", query2, field1, "")
+			if info2 != nil && len(*info2) > 0 {
+				m["conn_type"] = 1
+			} else {
+				m["conn_type"] = 2
+			}
+		}
+		// 转介绍成功率高标签
+		count := 0
+		err := T.ClickhouseConn.QueryRow(context.TODO(), sql_1, common.ObjToString(m["buyer_id"])).Scan(&count)
+		if err != nil && count > 2 {
+			m["high_success"] = true
+		} else {
+			m["high_success"] = false
+		}
+
+	}
+
+	return list
+}

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

@@ -201,18 +201,3 @@ type CanAddReq struct {
 	EmployCustomId int64  `json:"employCustomId,optional"` //客户收录id
 	Key            string `json:"key"`                     //创建线索:more_create_clue 创建机会:more_create_chance 创建客户:more_create_custom
 }
-
-type OwnerListReq struct {
-	PartyA           string `json:"partyA,optional"`           //甲方
-	Supplier         string `json:"supplier,optional"`         //供应商
-	Heterotophy      string `json:"heterotophy,optional"`      //同甲异业
-	Intermediary     string `json:"intermediary,optional"`     //中间人
-	Agency           string `json:"agency,optional"`           //代理机构
-	SearchEntName    string `json:"searchEntName,optional"`    //搜索企业名称
-	SourceType       string `json:"sourceType,optional"`       //搜索类型 1 只看转介绍成功率高2只看已监控的
-	ProcessingStatus string `json:"processingStatus,optional"` //处理状态1未处理2已忽略3已建客户
-	Area             string `json:"area,optional"`             //项目地区
-	PositionId       int64  `header:"positionId,optional"`
-	PageSize         int64  `json:"pageSize,optional"`
-	PageIndex        int64  `json:"pageIndex,optional"`
-}

+ 6 - 0
api/logs/access.log

@@ -0,0 +1,6 @@
+{"@timestamp":"2024-04-17T18:01:25.448+08:00","caller":"common/initconfig.go:70","content":"info--日志记录","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.448+08:00","caller":"common/initconfig.go:70","content":"error--日志记录","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.624+08:00","caller":"common/initconfig.go:125","content":"--初始化 mongodb--","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.625+08:00","caller":"common/initconfig.go:134","content":"--初始化 mongodb Bidding --","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.625+08:00","caller":"common/initconfig.go:145","content":"--初始化 mongodb ent --","level":"info"}
+{"@timestamp":"2024-04-17T18:01:25.626+08:00","caller":"common/initconfig.go:156","content":"--初始化 mongodb ent --","level":"info"}

+ 0 - 0
api/logs/error.log


+ 0 - 0
api/logs/severe.log


+ 0 - 0
api/logs/slow.log


+ 0 - 0
api/logs/stat.log


+ 2 - 2
go.mod

@@ -14,7 +14,9 @@ require (
 	github.com/ClickHouse/clickhouse-go/v2 v2.2.0
 	github.com/RoaringBitmap/roaring v1.5.0
 	github.com/gogf/gf/v2 v2.0.6
+	github.com/golang/protobuf v1.5.3
 	github.com/zeromicro/go-zero v1.5.5
+	google.golang.org/grpc v1.57.0
 )
 
 require (
@@ -47,7 +49,6 @@ require (
 	github.com/gogo/protobuf v1.3.2 // indirect
 	github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
 	github.com/golang/mock v1.6.0 // indirect
-	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
 	github.com/gomodule/redigo v2.0.0+incompatible // indirect
 	github.com/google/gnostic v0.5.7-v3refs // indirect
@@ -124,7 +125,6 @@ require (
 	google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 // indirect
 	google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 // indirect
 	google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
-	google.golang.org/grpc v1.57.0 // indirect
 	google.golang.org/protobuf v1.31.0 // indirect
 	gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
 	gopkg.in/inf.v0 v0.9.1 // indirect