Selaa lähdekoodia

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

# Conflicts:
#	api/internal/types/types.go
WH01243 1 vuosi sitten
vanhempi
commit
d5c737c511

+ 42 - 40
api/application.api

@@ -239,20 +239,22 @@ type (
 		ChannelType  string `json:"channelType"`
 	}
 	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"`
-		Contact_phone          string `json:"contact_phone"`
-		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"`
+		PositionId              int64  `header:"positionId"`
+		EntUserId               int64  `header:"entUserId,optional"`
+		EntId                   int64  `header:"entId,optional"`
+		EntDeptId               int64  `header:"entDeptId,optional"`
+		Qyxy_id                 string `json:"company_id,optional"`
+		Company_id              string `json:"company_id,optional"`
+		Company_name            string `json:"company_name,optional"`
+		Contact_person          string `json:"contact_person"`
+		Contact_phone           string `json:"contact_phone"`
+		Introduce_owner_id      string `json:"introduce_owner_id,optional"`
+		Introduce_owner_qyxy_id string `json:"introduce_owner_qyxy_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"`
 	}
 	AssociateReq {
 		EntAccountId int64  `header:"entAccountId"`
@@ -264,7 +266,7 @@ type (
 		EntAccountId int64  `header:"entAccountId"`
 		PositionId   int64  `header:"positionId"`
 		Name         string `json:"name,optional"`
-		Type         int64  `json:"type,optional"`
+		Type         string `json:"type,optional"`
 		Id           string `json:"id,optional"`
 	}
 	NetWorkListReq {
@@ -332,103 +334,103 @@ service crmApplication {
 	@doc "添加线索"
 	@handler clueAdd
 	post /crmApplication/clue/add (ClueAddReq) returns (Reply)
-
+	
 	@doc "创建销售机会"
 	@handler saleChanceAdd
 	post /crmApplication/saleChance/add (SaleChanceReq) returns (Reply)
-
+	
 	@doc "收录操作"
 	@handler employOperate
 	post /crmApplication/employ/operate (EmployOperateReq) returns (Reply)
-
+	
 	@doc "商业资讯的转办"
 	@handler transfer
 	post /crmApplication/information/transfer (TransferReq) returns (Reply)
-
+	
 	@doc "忽略操作"
 	@handler ignoreOperate
 	post /crmApplication/ignore/operate (IgnoreOperateReq) returns (Reply)
-
+	
 	@doc "收录情况"
 	@handler employInfo
 	post /crmApplication/employ/info (InfoEmployinfoReq) returns (InfoReply)
-
+	
 	@doc "创建客户"
 	@handler customAdd
 	post /crmApplication/custom/add (CustomAddReq) returns (Reply)
-
+	
 	@doc "文件上传"
 	@handler fileUpload
 	post /crmApplication/file/upload (FileUploadReq) returns (Reply)
-
+	
 	@doc "分发"
 	@handler employDistribute
 	post /crmApplication/employ/distribute (EmployDistributeReq) returns (Reply)
-
+	
 	@doc "企业详情"
 	@handler entinfo
 	post /crmApplication/ent/info (EntInfoReq) returns (Reply)
-
+	
 	@doc "消息推送"
 	@handler pushMsg
 	post /crmApplication/info/push (PushMsgReq) returns (Reply)
-
+	
 	@doc "是否可以创建"
 	@handler canAddReq
 	post /crmApplication/info/canAdd (CanAddReq) returns (Reply)
-
+	
 	@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/project/analyse (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 networkList
 	post /crmApplication/network/networkList (NetWorkListReq) returns (Reply)
-
+	
 	@doc "忽略操作"
 	@handler ignoreAction
 	post /crmApplication/ignore/action (IgnoreReq) returns (Reply)
-
+	
 	@doc "情报详情"
 	@handler infoDetail
 	post /crmApplication/infomation/detail (InfoDetailReq) returns (Reply)
-
+	
 	@doc "人脉项目分析-业主合作历史"
 	@handler projectHistory
 	post /crmApplication/pr/project/history (PrjectHistoryReq) returns (Reply)
-
+	
 	@doc "可介绍业主路径"
 	@handler ownerRoute
 	post /crmApplication/owner/route (RouteOwnerListReq) returns (Reply)
-
+	
 	@doc "可介绍业主合作次数"
 	@handler ownerCooperate
 	post /crmApplication/owner/cooperate (CooperateOwnerListReq) returns (Reply)
-
+	
 	@doc "候选渠道列表"
 	@handler candidateChannel
 	post /crmApplication/candidate/channel (ChannelListReq) returns (Reply)

+ 2 - 3
api/common/initconfig.go

@@ -4,10 +4,11 @@ import (
 	"context"
 	"flag"
 	"fmt"
-	"github.com/zeromicro/go-zero/zrpc"
 	"log"
 	"time"
 
+	"github.com/zeromicro/go-zero/zrpc"
+
 	"app.yhyue.com/moapp/jypkg/middleground"
 
 	. "app.yhyue.com/moapp/jybase/es"
@@ -176,8 +177,6 @@ func InitConf() {
 	SocialPlatformRpc = social.NewSocial(zrpc.MustNewClient(C.SocialPlatformRpc))
 	Middleground = middleground.NewMiddleground(C.BaseCenterRpc.Etcd.Hosts).
 		RegResourceCenter(C.ResourceCenterKey)
-	/*	Middleground = middleground.NewMiddleground([]string{"192.168.3.206:2379"}).
-		//	RegResourceCenter(C.ResourceCenterKey)*/
 	conf.MustLoad(*pushFile, &Push)
 	ConnectClickhouse(DB.Clickhouse)
 }

+ 3 - 3
api/etc/crmapplication.yaml

@@ -1,11 +1,11 @@
-Name: crmApplication
+Name: wcj_crmApplication
 Host: 0.0.0.0
 Port: 8887
 Timeout: 20000
 Gateway:
-  ServerCode: crmApplication
+  ServerCode: wcj_crmApplication
   Etcd:
-    - 127.0.0.1:2379
+    - 192.168.3.206:2379
 UserCenterRpc:
   Etcd:
     Hosts:

+ 1 - 1
api/etc/db.yaml

@@ -60,7 +60,7 @@ mongo:
         userName: jyDevGroup
         password: jy@DevGroup
 es:
-    addr: http://192.168.3.241:9205
+    addr: http://192.168.3.149:9200
     size: 50
     version: v7
     userName: ""

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

@@ -143,6 +143,5 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Handler: candidateChannelHandler(serverCtx),
 			},
 		},
-		rest.WithMaxBytes(104857600),
 	)
 }

+ 7 - 6
api/internal/logic/coophistorylistlogic.go

@@ -2,11 +2,9 @@ package logic
 
 import (
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
-	"context"
-	"log"
-
 	"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"
 )
@@ -27,14 +25,17 @@ func NewCoopHistoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
 
 func (l *CoopHistoryListLogic) CoopHistoryList(req *types.CoopHistoryReq) (resp *types.Reply, err error) {
 	resp = &types.Reply{}
-	result := service.GetPrList(req)
-	log.Println(result)
+	result, size1, size2, size3, size4 := service.GetPrList(req)
 	if result == nil {
 		resp.Error_code = -1
 		resp.Error_msg = "查询异常"
 	} else {
 		resp.Data = map[string]interface{}{
-			"list": result,
+			"list":  result,
+			"size1": size1,
+			"size2": size2,
+			"size3": size3,
+			"size4": size4,
 		}
 	}
 

+ 3 - 3
api/internal/logic/ignoreactionlogic.go

@@ -44,7 +44,7 @@ func (l *IgnoreActionLogic) IgnoreAction(req *types.IgnoreReq) (resp *types.Repl
 		b := T.CrmMysql.Update("connection_status", query, update)
 		if !b {
 			resp.Error_code = -1
-			resp.Error_msg = "更新失败"
+			resp.Error_msg = "状态更新失败"
 		} else {
 			resp.Error_msg = "更新成功"
 		}
@@ -66,14 +66,14 @@ func (l *IgnoreActionLogic) IgnoreAction(req *types.IgnoreReq) (resp *types.Repl
 			i := T.CrmMysql.Insert("connection_status", save)
 			if i <= 0 {
 				resp.Error_code = -1
-				resp.Error_msg = "更新失败"
+				resp.Error_msg = "插入失败"
 			} else {
 				resp.Data = i
 				resp.Error_msg = "更新成功"
 			}
 		} else {
 			resp.Error_code = -1
-			resp.Error_msg = "更新失败"
+			resp.Error_msg = "未查询到收录信息"
 		}
 	}
 	return

+ 2 - 1
api/internal/logic/ownerlistlogic.go

@@ -1,9 +1,10 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
 
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
+
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
 

+ 60 - 50
api/internal/service/CoopHistoryService.go

@@ -44,78 +44,88 @@ type ProjectTmp struct {
 	PropertyForm []string `ch:"property_form"`
 }
 
-func GetPrList(req *types.CoopHistoryReq) (result []*ResultData) {
+func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2, size_3, size_4 int64) {
 	pTmp := ProjectTmp{}
 	err := T.ClickhouseConn.QueryRow(context.TODO(), sql_2_0, req.Pid).ScanStruct(&pTmp)
 	if err != nil {
-		return nil
+		return nil, 0, 0, 0, 0
 	}
 	propertyForm := ""
 	m1 := T.CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": req.EntAccountId}, "probusfor", "")
 	if m1 != nil && len(*m1) > 0 {
 		propertyForm = common.ObjToString((*m1)["probusfor"])
 	}
-
 	// firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构 sup_sub: 上下级
-	// 1、同甲异业数据/招标代理机构渠道
-	r1, r2 := GetData(propertyForm, pTmp.BuyerId)
-	if r1 != nil && len(r1) > 0 {
-		for _, m := range r1 {
-			near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "adiffb")
-			tmp := ResultData{
-				SourceType:  "adiffb",
-				EntName:     common.ObjToString(m["name"]),
-				ProjectNum:  common.IntAll(m["coop_size"]),
-				TotalAmount: common.Float64All(m["coop_amount"]),
-				RecentTime:  zbtime,
-				NearlyYears: near,
+	// 1、同甲异业数据/ 3、招标代理机构渠道
+	if req.ChannelType == "0" || req.ChannelType == "1" || req.ChannelType == "3" {
+		r1, r2 := GetData(propertyForm, pTmp.BuyerId)
+		if (req.ChannelType == "0" || req.ChannelType == "1") && r1 != nil && len(r1) > 0 {
+			size_1 = int64(len(r1))
+			for _, m := range r1 {
+				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "adiffb")
+				tmp := ResultData{
+					SourceType:  "adiffb",
+					EntName:     common.ObjToString(m["name"]),
+					ProjectNum:  common.IntAll(m["coop_size"]),
+					TotalAmount: common.Float64All(m["coop_amount"]),
+					RecentTime:  zbtime,
+					NearlyYears: near,
+				}
+				result = append(result, &tmp)
 			}
-			result = append(result, &tmp)
 		}
-	}
-	if r2 != nil && len(r2) > 0 {
-		for _, m := range r2 {
-			near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "agency")
-			tmp := ResultData{
-				SourceType:  "agency",
-				EntName:     common.ObjToString(m["name"]),
-				ProjectNum:  common.IntAll(m["coop_size"]),
-				TotalAmount: common.Float64All(m["coop_amount"]),
-				RecentTime:  zbtime,
-				NearlyYears: near,
+		if req.ChannelType == "0" || req.ChannelType == "3" && r2 != nil && len(r2) > 0 {
+			size_3 = int64(len(r2))
+			for _, m := range r2 {
+				near, zbtime := LastTimeCoop(pTmp.BuyerId, common.ObjToString(m["name"]), "agency")
+				tmp := ResultData{
+					SourceType:  "agency",
+					EntName:     common.ObjToString(m["name"]),
+					ProjectNum:  common.IntAll(m["coop_size"]),
+					TotalAmount: common.Float64All(m["coop_amount"]),
+					RecentTime:  zbtime,
+					NearlyYears: near,
+				}
+				result = append(result, &tmp)
 			}
-			result = append(result, &tmp)
 		}
 	}
 	if pTmp.BuyerId != "" {
-		// 中间人可介绍业主
-		var r3 []map[string]interface{}
-		r3 = FindMiddleman([]string{pTmp.BuyerId}, req.PositionId, r3)
-		if r3 != nil && len(r3) > 0 {
-			for _, m := range r3 {
-				tmp := ResultData{
-					SourceType:   "middleman",
-					EntName:      common.ObjToString(m["b_name"]),
-					EntPerson:    common.ObjToString(m["personName"]),
-					Relationship: "业主的关系人",
+		if req.ChannelType == "0" || req.ChannelType == "4" {
+			// 中间人可介绍业主
+			var r3 []map[string]interface{}
+			r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", pTmp.BuyerId)}, req.PositionId, r3)
+			if r3 != nil && len(r3) > 0 {
+				for _, m := range r3 {
+					size_4 = int64(len(r3))
+					tmp := ResultData{
+						SourceType:   "middleman",
+						EntName:      common.ObjToString(m["b_name"]),
+						EntPerson:    common.ObjToString(m["personName"]),
+						Relationship: "业主的关系人",
+					}
+					result = append(result, &tmp)
 				}
-				result = append(result, &tmp)
 			}
 		}
-		// 关联单位
-		var r4 []map[string]interface{}
-		r4 = Findfirstparty([]string{pTmp.BuyerId}, r4)
-		if r4 != nil && len(r4) > 0 {
-			for _, m := range r3 {
-				tmp := ResultData{
-					SourceType:   "sup_sub",
-					EntName:      common.ObjToString(m["b_name"]),
-					EntPerson:    common.ObjToString(m["personName"]),
-					Relationship: common.ObjToString(m["relationship"]),
+		if req.ChannelType == "0" || req.ChannelType == "2" {
+			// 关联单位
+			var r4 []map[string]interface{}
+			r4 = Findfirstparty([]string{fmt.Sprintf("'%s'", pTmp.BuyerId)}, r4)
+			if r4 != nil && len(r4) > 0 {
+				size_2 = int64(len(r4))
+				for _, m := range r4 {
+					tmp := ResultData{
+						SourceType:   "sup_sub",
+						EntName:      common.ObjToString(m["b_name"]),
+						EntPerson:    common.ObjToString(m["personName"]),
+						Relationship: common.ObjToString(m["relationship"]),
+					}
+					result = append(result, &tmp)
 				}
-				result = append(result, &tmp)
 			}
 		}
+
 	}
 	return
 }

+ 83 - 38
api/internal/service/network.go

@@ -31,11 +31,12 @@ type networkTree struct {
 	Children []*networkTreeChild `json:"children"`
 }
 type networkTreeChild struct {
-	Count      int64  `json:"count"`
-	Name       string `json:"name"`
-	Id         string `json:"id"`
-	Type       string `json:"type"`
-	CreateTime string `json:"createTime"`
+	Count       int64  `json:"count"`
+	Id          int64  `json:"id"`
+	CompanyId   string `json:"companyId"`
+	CompanyName string `json:"companyName"`
+	Type        string `json:"type"`
+	CreateTime  string `json:"createTime"`
 }
 
 func (s *networkTree) Len() int {
@@ -44,7 +45,7 @@ func (s *networkTree) Len() int {
 
 func (s *networkTree) Less(i, j int) bool {
 	if s.Name == "甲方" {
-		return s.Children[i].Name < s.Children[j].Name
+		return s.Children[i].CompanyName < s.Children[j].CompanyName
 	}
 	it, err1 := time.ParseInLocation(Date_Full_Layout, s.Children[i].CreateTime, time.Local)
 	if err1 != nil {
@@ -91,12 +92,13 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 		}
 		values := []interface{}{}
 		ioi := strings.Split(in.Introduce_owner_id, ",")
+		ioqi := strings.Split(in.Introduce_owner_qyxy_id, ",")
 		ion := strings.Split(in.Introduce_owner_name, ",")
-		if len(ioi) != len(ion) {
+		if len(ioi) != len(ion) || len(ioi) != len(ioqi) {
 			return false
 		}
 		for k, v := range ioi {
-			values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, ion[k], 1, nowFormat)
+			values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, ioqi[k], v, ion[k], 1, nowFormat)
 		}
 		ipi := strings.Split(in.Introduce_project_id, ",")
 		ipn := strings.Split(in.Introduce_project_name, ",")
@@ -104,13 +106,13 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 			return false
 		}
 		for k, v := range ipi {
-			values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, v, ipn[k], 2, nowFormat)
+			values = append(values, in.PositionId, in.EntId, in.EntDeptId, in.EntUserId, cid, nil, v, ipn[k], 2, nowFormat)
 		}
 		var r2 int64
 		if isUpdate {
 			r2 = CrmMysql.UpdateOrDeleteBySqlByTx(tx, `delete from crm.connection_introduce where connection_id=? and position_id=?`, in.Id, in.PositionId)
 		}
-		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)
+		r3, _ := CrmMysql.InsertBatchByTx(tx, "crm.connection_introduce", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "connection_id", "qyxy_id", "relate_id", "relate_name", "itype", "create_time"}, values)
 		return r2 >= 0 && r3 > 0
 	}
 	itype := n.TypeStrConvert(in.Type)
@@ -148,7 +150,7 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 		}
 		var r1 int64
 		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})
+			_, r1 = CrmMysql.InsertBatchByTx(tx, "crm.connection", []string{"position_id", "ent_id", "ent_dept_id", "ent_user_id", "itype", "company_name", "company_id", "qyxy_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.Qyxy_id, in.Contact_person, in.Contact_phone, 1, nowFormat, nowFormat})
 			return r1 > 0 && saveIntroduce(tx, r1, false)
 		}) {
 			reply.Data = map[string]interface{}{
@@ -163,7 +165,7 @@ func (n *network) AddOrUpdate(in *types.AddOrUpdateReq) *types.Reply {
 //人脉库-业主名称联想
 func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
 	//类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
-	res := []map[string]interface{}{}
+	res := []map[string]string{}
 	reply = &types.Reply{Data: res}
 	in.Name = strings.TrimSpace(in.Name)
 	if in.Name == "" {
@@ -182,6 +184,7 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
 				logx.Error(err)
 			} else {
 				repeat := map[string]bool{}
+				ids := []string{}
 				for rows.Next() {
 					var (
 						winner_id []string
@@ -199,18 +202,23 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
 						if k >= len(winner_id) {
 							continue
 						}
-						res = append(res, map[string]interface{}{
+						ids = append(ids, winner_id[k])
+						res = append(res, map[string]string{
 							"company_name": v,
 							"company_id":   winner_id[k],
 						})
+						if len(res) == pageSize {
+							break
+						}
 					}
 				}
 				rows.Close()
 				if err := rows.Err(); err != nil {
 					logx.Error(err)
 				}
-				if len(res) > pageSize {
-					res = res[:pageSize]
+				qyxyId := n.GetQyxyId(ids)
+				for _, v := range res {
+					v["qyxy_id"] = qyxyId[v["company_id"]]
 				}
 			}
 		}
@@ -228,14 +236,15 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
 		case "agency":
 			must = append(must, `{"term":{"company_unit_type":4}}`)
 		}
-		q := fmt.Sprintf(`{"query":{"bool":{"must":[%s]}},"size":%d,"_source":["id","company_name"]}`, strings.Join(must, ","), pageSize)
+		q := fmt.Sprintf(`{"query":{"bool":{"must":[%s]}},"size":%d,"_source":["id","company_id","company_name"]}`, strings.Join(must, ","), pageSize)
 		logx.Info("人脉库-业主名称联想", q)
 		datas := VarEs.Get("ent_info", "ent_info", q)
 		if datas != nil {
 			for _, v := range *datas {
-				res = append(res, map[string]interface{}{
+				res = append(res, map[string]string{
 					"company_name": ObjToString(v["company_name"]),
 					"company_id":   ObjToString(v["id"]),
+					"qyxy_id":      ObjToString(v["company_id"]),
 				})
 			}
 		}
@@ -254,7 +263,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 	var count int64
 	var list []*networkTree
 	if in.Id != "" {
-		if in.Type == 1 {
+		if in.Type == "firstparty" {
 			result := n.FirstpartyNetwork(in.Name, []string{in.Id})
 			if result[in.Id] != nil {
 				nameIndex := map[string]int{}
@@ -273,12 +282,12 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 							wait.Done()
 						}()
 						ntc := &networkTreeChild{
-							Name: cName,
-							Id:   cId,
-							Type: "firstparty",
+							CompanyName: cName,
+							CompanyId:   cId,
+							Type:        "firstparty",
 						}
 						if wh != "" {
-							thisArgs := []interface{}{ntc.Id}
+							thisArgs := []interface{}{ntc.CompanyId}
 							thisArgs = append(thisArgs, newArgs...)
 							ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
 						}
@@ -293,7 +302,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			}
 		}
 	} else {
-		q := `SELECT a.company_id,a.company_name,a.itype,a.create_time,COUNT(b.id) AS ipc FROM crm.connection a 
+		q := `SELECT a.id,a.company_id,a.company_name,a.itype,a.create_time,COUNT(b.id) AS ipc FROM crm.connection a 
 			LEFT JOIN crm.connection_introduce b ON (b.position_id=? AND b.itype=2 AND a.id=b.connection_id) WHERE a.position_id=?`
 		args := []interface{}{in.PositionId, in.PositionId}
 		if in.Name != "" {
@@ -342,13 +351,14 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 					company_name = "未填写"
 				}
 				ntc := &networkTreeChild{
-					Name:       company_name,
-					Id:         ObjToString(v["company_id"]),
-					Type:       n.TypeIntConvert(Int64All(v["itype"])),
-					CreateTime: ObjToString(v["create_time"]),
+					Id:          Int64All(v["id"]),
+					CompanyName: company_name,
+					CompanyId:   ObjToString(v["company_id"]),
+					Type:        n.TypeIntConvert(Int64All(v["itype"])),
+					CreateTime:  ObjToString(v["create_time"]),
 				}
 				if wh != "" {
-					thisArgs := []interface{}{ntc.Id}
+					thisArgs := []interface{}{ntc.CompanyId}
 					thisArgs = append(thisArgs, newArgs...)
 					if itype == 1 {
 						ntc.Count = NetworkCom.Count(`select count(1) from information.transaction_info where buyer_id=? and hasAny(property_form,[`+wh+`])`, thisArgs...)
@@ -393,14 +403,18 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			if pType != "" {
 				pType += ","
 			}
-			ID += vv.Id
+			tempId := vv.CompanyId
+			if vv.Type == "middleman" {
+				tempId = fmt.Sprint(vv.Id)
+			}
+			ID += tempId
 			pType += vv.Type
 			cm := map[string]interface{}{
-				"NAME":      vv.Name,
-				"ID":        vv.Id,
+				"NAME":      vv.CompanyName,
+				"ID":        tempId,
 				"SZ_PID0":   v.Name,
-				"SZ_PID1":   v.Name + ":" + vv.Id,
-				"CODE":      v.Name + ":" + vv.Id,
+				"SZ_PID1":   v.Name + ":" + tempId,
+				"CODE":      v.Name + ":" + tempId,
 				"PCODE":     v.Name,
 				"DATACOUNT": vv.Count,
 				"SZ_LEVEL":  1,
@@ -424,7 +438,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 
 //人脉库-列表
 func (n *network) List(in *types.NetWorkListReq) *types.Reply {
-	q := `select a.company_id,a.company_name,a.itype,a.contact_person as person,a.contact_phone as phone,count(DISTINCT if(b.itype=1,b.relate_id,null)) as buyer_count,count(DISTINCT if(b.itype=2,b.relate_id,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,b.relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=2,b.relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a 
+	q := `select a.id,a.company_id,a.company_name,a.qyxy_id,a.itype,a.contact_person as person,a.contact_phone as phone,count(DISTINCT if(b.itype=1,b.relate_id,null)) as buyer_count,count(DISTINCT if(b.itype=2,b.relate_id,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,b.relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=2,b.relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a 
 		left join crm.connection_introduce b on (a.id=b.connection_id) where a.position_id=?`
 	args := []interface{}{in.PositionId}
 	if in.Type != "" {
@@ -537,7 +551,7 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 			case 4:
 				itype = "中间人"
 				jump_type = "middleman"
-				jump_id = company_id
+				jump_id = fmt.Sprint(Int64All(v["id"]))
 				middleman_count++
 				buyer_count = Int64All(v["buyer_count"])
 				project_count = Int64All(v["project_count"])
@@ -587,16 +601,19 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 			} else if in.Project_matchme == 1 && project_count == 0 {
 				continue
 			}
-
 			export_url := ""
 			if len(export_id) > 0 {
 				export_url = "/subscribepay/network/projectExport?export_id=" + encrypt.SE.EncodeStringByCheck(strings.Join(export_id, ","))
 			}
+			url := ""
 			company_name, _ := v["company_name"].(string)
-			url := "/swordfish/page_big_pc/unit_portrayal/" + company_name
 			if company_name == "" {
 				company_name = "未填写"
-				url = ""
+			}
+			if qyxy_id := ObjToString(v["qyxy_id"]); qyxy_id != "" && (jump_type == "supplier" || jump_type == "adiffb") {
+				url = "/swordfish/page_big_pc/ent_portrait/" + encrypt.EncodeArticleId2ByCheck(qyxy_id)
+			} else if jump_type == "firstparty" && company_name != "" {
+				url = "/swordfish/page_big_pc/unit_portrayal/" + company_name
 			}
 			list = append(list, &map[string]interface{}{
 				"company_id":    company_id,
@@ -943,3 +960,31 @@ func (n *network) TypeIntConvert(itype int64) string {
 	}
 	return ""
 }
+
+//
+func (n *network) GetQyxyId(ids []string) map[string]string {
+	wh, args := NetworkCom.WhArgs(ids)
+	q := `select id,company_id from information.ent_info where id in (` + wh + `)`
+	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
+	m := map[string]string{}
+	if err != nil {
+		logx.Error(err)
+	} else {
+		for rows.Next() {
+			var (
+				id         string
+				company_id string
+			)
+			if err := rows.Scan(&id, &company_id); err != nil {
+				logx.Error(err)
+				continue
+			}
+			m[id] = company_id
+		}
+		rows.Close()
+		if err := rows.Err(); err != nil {
+			logx.Error(err)
+		}
+	}
+	return m
+}

+ 14 - 1
api/internal/service/network_test.go

@@ -28,7 +28,7 @@ func initDb() {
 		Addr:         "192.168.3.207:19000",
 		UserName:     "jytop",
 		Password:     "pwdTopJy123",
-		DbName:       "jianyu",
+		DbName:       "information",
 		MaxIdleConns: 2,
 		MaxOpenConns: 2,
 	})
@@ -139,3 +139,16 @@ func TestAllProject(t *testing.T) {
 	b, _ := json.Marshal(res.Data)
 	log.Println(string(b))
 }
+
+func TestOwner(t *testing.T) {
+	initDb()
+	ownerService := &OwnerService{
+		Intermediary: "wcj_11111111f",
+		PositionId:   935,
+		PageIndex:    1,
+		PageSize:     100,
+	}
+	data := ownerService.OwnerlList()
+	b, _ := json.Marshal(data)
+	log.Println(string(b))
+}

+ 7 - 22
api/internal/service/plistService.go

@@ -2,7 +2,6 @@ package service
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
-	P "app.yhyue.com/moapp/jybase/mapping"
 	"app.yhyue.com/moapp/jypkg/ent/util"
 	T "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
@@ -147,38 +146,24 @@ func getQuerySql(req *types.ProjectListReq, isPage bool, buyerArr []string) (cou
 	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, ",")))
+		if req.City != "" {
+			regionArr = append(regionArr, fmt.Sprintf(" a.city in ('%s') ", req.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, ",")))
+		if req.Area != "" {
+			regionArr = append(regionArr, fmt.Sprintf(" a.area in ('%s') ", req.Area))
 		}
 		//区域
 		district := []string{}
 		if req.District != "" {
 			for _, v := range strings.Split(req.District, ",") {
-				cityName := strings.Split(v, "_")[0]
+				//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]))
-				}
+				district = append(district, districtName)
 			}
 		}
 		if len(district) > 0 {
-			regionArr = append(regionArr, fmt.Sprintf(" a.district in (%s) ", strings.Join(district, ",")))
+			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")))