瀏覽代碼

feat:初始化

wangchuanjin 9 月之前
父節點
當前提交
8e17871429

二進制
api/api.exe


+ 17 - 41
api/common/initconfig.go

@@ -11,13 +11,8 @@ import (
 	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/mysql"
 	"app.yhyue.com/moapp/jybase/redis"
-	"app.yhyue.com/moapp/jypkg/middleground"
-	"bp.jydev.jianyu360.cn/BaseService/fileCenter/rpc/filecenter"
-	"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/config"
 	"bp.jydev.jianyu360.cn/CRM/application/entity"
-	"bp.jydev.jianyu360.cn/CRM/baseCenter/rpc/basecenter"
-	"bp.jydev.jianyu360.cn/SocialPlatform/socialPlatform/rpc/social/social"
 	"github.com/ClickHouse/clickhouse-go/v2"
 	"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
 	"github.com/zeromicro/go-zero/core/conf"
@@ -34,20 +29,11 @@ var dbFile = flag.String("df", "etc/db.yaml", "the db file")
 var DB config.Db
 
 var (
-	MgoBidding        mongodb.MongodbSim
-	MgoEnt            mongodb.MongodbSim
-	MainMysql         *mysql.Mysql
-	BaseMysql         *mysql.Mysql
-	CrmMysql          *mysql.Mysql
-	Mgo               mongodb.MongodbSim
-	UserCenterRpc     usercenter.UserCenter
-	FileCenterRpc     filecenter.FileCenter
-	BaseCenterRpc     basecenter.BaseCenter
-	SocialPlatformRpc social.Social
-	MgoProject        mongodb.MongodbSim
-	NiJian            *mysql.Mysql
-	Middleground      *middleground.Middleground
-	ClickhouseConn    driver.Conn
+	MgoBidding     mongodb.MongodbSim
+	BaseMysql      *mysql.Mysql
+	CrmMysql       *mysql.Mysql
+	Mgo            mongodb.MongodbSim
+	ClickhouseConn driver.Conn
 )
 
 func InitConf() {
@@ -69,6 +55,18 @@ func InitConf() {
 	}
 
 	conf.MustLoad(*dbFile, &DB)
+	if DB.Mysql.BaseService.Address != "" {
+		log.Println("--初始化 base mysql--")
+		BaseMysql = &mysql.Mysql{
+			Address:      DB.Mysql.BaseService.Address,
+			UserName:     DB.Mysql.BaseService.UserName,
+			PassWord:     DB.Mysql.BaseService.Password,
+			DBName:       DB.Mysql.BaseService.DbName,
+			MaxOpenConns: DB.Mysql.BaseService.MaxOpenConns,
+			MaxIdleConns: DB.Mysql.BaseService.MaxIdleConns,
+		}
+		BaseMysql.Init()
+	}
 	if DB.Mysql.CrmService.Address != "" {
 		log.Println("--初始化 crm mysql--")
 		CrmMysql = &mysql.Mysql{
@@ -101,28 +99,6 @@ func InitConf() {
 		}
 		MgoBidding.InitPool()
 	}
-	if DB.Mongo.Ent.Address != "" {
-		logx.Info("--初始化 mongodb ent --")
-		MgoEnt = mongodb.MongodbSim{
-			MongodbAddr: DB.Mongo.Ent.Address,
-			Size:        DB.Mongo.Ent.Size,
-			DbName:      DB.Mongo.Ent.DbName,
-			Password:    DB.Mongo.Ent.Password,
-			UserName:    DB.Mongo.Ent.UserName,
-		}
-		MgoEnt.InitPool()
-	}
-	if DB.Mongo.Project.Address != "" {
-		logx.Info("--初始化 mongodb ent --")
-		MgoProject = mongodb.MongodbSim{
-			MongodbAddr: DB.Mongo.Project.Address,
-			Size:        DB.Mongo.Project.Size,
-			DbName:      DB.Mongo.Project.DbName,
-			Password:    DB.Mongo.Project.Password,
-			UserName:    DB.Mongo.Project.UserName,
-		}
-		MgoProject.InitPool()
-	}
 	//初始化 elasticsearch
 	if DB.Es.Addr != "" {
 		log.Println("--初始化 elasticsearch--")

+ 7 - 18
api/etc/db.yaml

@@ -1,4 +1,11 @@
 mysql:
+    baseService:
+        dbName: base_service
+        address: 192.168.3.14:4000
+        userName: root
+        passWord: =PDT49#80Z!RVv52_z
+        maxOpenConns: 5
+        maxIdleConns: 5
     crmService:
         dbName: crm
         address: 192.168.3.14:4000
@@ -19,24 +26,6 @@ mongo:
         collection_change: bidding_back
         userName: jyDevGroup
         password: jy@DevGroup
-    ent:
-        address: 192.168.3.149:27102
-        size: 5
-        dbName: mixdata
-        replSet: ""
-        collection: qyxy
-        collection_change: qyxy_change
-        userName: jyDevGroup
-        password: jy@DevGroup
-    projectset:
-        address: 192.168.3.149:27102
-        size: 5
-        dbName: qfw_data
-        replSet: ""
-        collection: qyxy
-        collection_change: qyxy_change
-        userName: jyDevGroup
-        password: jy@DevGroup
 es:
     addr: http://192.168.3.149:9200
     size: 50

+ 4 - 36
api/etc/networkmanage.yaml

@@ -1,42 +1,10 @@
-Name: wcj_crmApplication
+Name: networkManage
 Host: 0.0.0.0
-Port: 8887
+Port: 8837
 Timeout: 20000
 Gateway:
-  ServerCode: crmApplication
+  ServerCode: networkManage
   Etcd:
     - 192.168.3.207:2379
     - 192.168.3.165:2379
-    - 192.168.3.204:2379
-UserCenterRpc:
-  Etcd:
-    Hosts:
-    - 192.168.3.207:2379
-    - 192.168.3.165:2379
-    - 192.168.3.204:2379
-    Key: usercenter.rpc
-FileCenterRpc:
-  Etcd:
-    Hosts:
-    - 192.168.3.207:2379
-    - 192.168.3.165:2379
-    - 192.168.3.204:2379
-    Key: filecenter.rpc
-ossBucketName: jytest2022
-ossUrl: https://jytest2022.oss-cn-beijing.aliyuncs.com
-BaseCenterRpc:
-  Etcd:
-    Hosts:
-    - 192.168.3.207:2379
-    - 192.168.3.165:2379
-    - 192.168.3.204:2379
-    Key: basecenter.rpc
-NextFollowUpTime: 2
-SocialPlatformRpc:
-  Etcd:
-    Hosts:
-    - 192.168.3.207:2379
-    - 192.168.3.165:2379
-    - 192.168.3.204:2379
-    Key: social.rpc
-ResourceCenterKey: resource.rpc
+    - 192.168.3.204:2379

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

@@ -1,28 +0,0 @@
-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 candidateChannelListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
-	return func(w http.ResponseWriter, r *http.Request) {
-		var req types.ChannelListReq
-		if err := httpx.Parse(r, &req); err != nil {
-			httpx.ErrorCtx(r.Context(), w, err)
-			return
-		}
-
-		l := logic.NewCandidateChannelListLogic(r.Context(), svcCtx)
-		resp, err := l.CandidateChannelList(&req)
-		if err != nil {
-			httpx.ErrorCtx(r.Context(), w, err)
-		} else {
-			httpx.OkJsonCtx(r.Context(), w, resp)
-		}
-	}
-}

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

@@ -77,11 +77,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/networkManage/owner/cooperate",
 				Handler: ownerCooperateHandler(serverCtx),
 			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/networkManage/candidate/channel/list",
-				Handler: candidateChannelListHandler(serverCtx),
-			},
 		},
 	)
 }

+ 0 - 52
api/internal/logic/candidatechannellistlogic.go

@@ -1,52 +0,0 @@
-package logic
-
-import (
-	"context"
-	"fmt"
-
-	"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"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type CandidateChannelListLogic struct {
-	logx.Logger
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-}
-
-func NewCandidateChannelListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CandidateChannelListLogic {
-	return &CandidateChannelListLogic{
-		Logger: logx.WithContext(ctx),
-		ctx:    ctx,
-		svcCtx: svcCtx,
-	}
-}
-
-func (l *CandidateChannelListLogic) CandidateChannelList(req *types.ChannelListReq) (resp *types.Reply, err error) {
-	// todo: add your logic here and delete this line
-	logx.Info(fmt.Sprintf("%+v", req))
-	resp = &types.Reply{}
-	ownerService := &service.OwnerService{
-		PartyA:       req.PartyA,
-		Supplier:     req.Supplier,
-		Intermediary: req.Intermediary,
-		Heterotophy:  req.Heterotophy,
-		Agency:       req.Agency,
-		PositionId:   req.PositionId,
-		EntAccountId: req.EntAccountId,
-		Type:         req.Type,
-	}
-	data, a1, a2, a3, a4 := ownerService.CandidateChannel()
-	resp.Data = map[string]interface{}{
-		"list":  data,
-		"size1": a1,
-		"size3": a2,
-		"size4": a3,
-		"size2": a4,
-	}
-	return
-}

+ 2 - 199
api/internal/service/owner.go

@@ -6,14 +6,11 @@ import (
 	"fmt"
 	"sort"
 	"strings"
-	"sync"
 	"time"
 
-	elastic "app.yhyue.com/moapp/jybase/es"
-
-	"app.yhyue.com/moapp/jybase/encrypt"
-
 	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/es"
 	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"bp.jydev.jianyu360.cn/CRM/application/entity"
 	"github.com/gogf/gf/v2/util/gconv"
@@ -1087,197 +1084,3 @@ func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
 	}
 	return returData
 }
-
-// 候选渠道
-func (t *OwnerService) CandidateChannel() (*ResultDatas, int, int, int, int) {
-	returnData := []*ResultData{}
-	dataMap := &map[string]map[string]interface{}{}
-	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
-		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency,
-			t.PositionId)
-	}
-	a1, a2, a3, a4 := 0, 0, 0, 0
-	if len(*dataMap) > 0 && dataMap != nil {
-		propertyForm := NetworkCom.GetMyProbusfor(t.EntAccountId)
-		buyerIds := []string{}
-		for buyerId := range *dataMap {
-			buyerIds = append(buyerIds, buyerId)
-		}
-		if len(buyerIds) > 300 {
-			buyerIds = buyerIds[:300]
-		}
-		logx.Info("CandidateChannel start ", t.PositionId)
-		buyerIdsTemp := []string{}
-		rs1, rs2 := map[string][]map[string]interface{}{}, map[string][]map[string]interface{}{}
-		for _, v := range buyerIds {
-			buyerIdsTemp = append(buyerIdsTemp, v)
-			if len(buyerIdsTemp) == 50 {
-				rs1Temp, rs2Temp := GetData(propertyForm, strings.Join(buyerIdsTemp, ","))
-				for kk, vv := range rs1Temp {
-					rs1[kk] = vv
-				}
-				for kk, vv := range rs2Temp {
-					rs2[kk] = vv
-				}
-				buyerIdsTemp = []string{}
-			}
-		}
-		if len(buyerIdsTemp) > 0 {
-			rs1Temp, rs2Temp := GetData(propertyForm, strings.Join(buyerIdsTemp, ","))
-			for kk, vv := range rs1Temp {
-				rs1[kk] = vv
-			}
-			for kk, vv := range rs2Temp {
-				rs2[kk] = vv
-			}
-		}
-		logx.Info("CandidateChannel GetData over ", t.PositionId)
-		winners, agency := []string{}, []string{}
-		for buyerId := range *dataMap {
-			for _, m := range rs1[buyerId] {
-				winners = append(winners, common.ObjToString(m["name"]))
-			}
-			for _, m := range rs2[buyerId] {
-				agency = append(agency, common.ObjToString(m["name"]))
-			}
-		}
-		logx.Info("CandidateChannel LastTimeCoopBath start ", t.PositionId, " ", len(buyerIds), " ", len(winners), " ", len(agency))
-		ltcs1, ltcs2 := LastTimeCoopBath(t.PositionId, buyerIds, winners, agency)
-		logx.Info("CandidateChannel LastTimeCoopBath over ", t.PositionId)
-		pool := make(chan bool, 3)
-		wait := &sync.WaitGroup{}
-		lock := &sync.Mutex{}
-		maxByIdCount := 0
-		for buyerId := range *dataMap {
-			if ltcs1[buyerId] != nil {
-				for _, m := range rs1[buyerId] {
-					ltc := ltcs1[buyerId][common.ObjToString(m["name"])]
-					if ltc == nil {
-						continue
-					}
-					tmp := ResultData{
-						SourceType:  "adiffb",
-						EntId:       common.ObjToString(m["nameId"]),
-						EntName:     common.ObjToString(m["name"]),
-						ProjectNum:  common.IntAll(m["coop_size"]),
-						TotalAmount: common.Float64All(m["coop_amount"]),
-						BuyerId:     buyerId,
-						RecentTime:  ltc.ZbTime,
-						NearlyYears: ltc.Near,
-					}
-					if tmp.EntId == "" || tmp.BuyerId == "" {
-						continue
-					}
-					a1++
-					returnData = append(returnData, &tmp)
-				}
-			}
-			if ltcs2[buyerId] != nil {
-				for _, m := range rs2[buyerId] {
-					ltc := ltcs1[buyerId][common.ObjToString(m["name"])]
-					if ltc == nil {
-						continue
-					}
-					tmp := ResultData{
-						SourceType:  "agency",
-						EntName:     common.ObjToString(m["name"]),
-						ProjectNum:  common.IntAll(m["coop_size"]),
-						TotalAmount: common.Float64All(m["coop_amount"]),
-						RecentTime:  ltc.ZbTime,
-						NearlyYears: ltc.Near,
-						EntId:       common.ObjToString(m["nameId"]),
-						BuyerId:     buyerId,
-					}
-					if tmp.EntId == "" || tmp.BuyerId == "" {
-						continue
-					}
-					a2++
-					returnData = append(returnData, &tmp)
-				}
-			}
-			maxByIdCount++
-			if maxByIdCount > 50 {
-				break
-			}
-			pool <- true
-			wait.Add(1)
-			go func(byId string) {
-				defer common.Catch()
-				defer func() {
-					<-pool
-					wait.Done()
-				}()
-				// 中间人可介绍业主
-				var r3 []map[string]interface{}
-				r3 = FindMiddleman([]string{fmt.Sprintf("'%s'", byId)}, t.PositionId, r3)
-				lock.Lock()
-				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: "业主的关系人",
-							EntId:        common.ObjToString(m["b_id"]),
-							BuyerId:      byId,
-						}
-						if tmp.EntId == "" || tmp.BuyerId == "" {
-							continue
-						}
-						a3++
-						returnData = append(returnData, &tmp)
-					}
-				}
-				lock.Unlock()
-				// 关联单位
-				var r4 []map[string]interface{}
-				r4 = Findfirstparty([]string{fmt.Sprintf("'%s'", byId)}, r4)
-				lock.Lock()
-				if r4 != nil && len(r4) > 0 {
-					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"]),
-							EntId:        common.ObjToString(m["b_id"]),
-							BuyerId:      byId,
-						}
-						if tmp.EntId == "" || tmp.BuyerId == "" {
-							continue
-						}
-						a4++
-						returnData = append(returnData, &tmp)
-					}
-				}
-				lock.Unlock()
-			}(buyerId)
-		}
-		wait.Wait()
-	}
-	logx.Info("CandidateChannel over", t.PositionId)
-	//状态处理
-	result := &ResultDatas{}
-	if len(returnData) > 0 {
-		monitorMap := NetworkCom.EntMonitor(gconv.String(t.PositionId))
-		_, ignoredMap, createdMap := FindStatus(t.PositionId)
-		for k, value := range returnData {
-			if _, ok := ignoredMap[value.EntId]; ok {
-				value.IsIgnore = true
-			}
-			if _, ok := createdMap[value.EntId]; ok {
-				value.IsCreateCustomer = true
-			}
-			if _, ok := monitorMap[value.EntName]; ok {
-				value.IsMonitor = true
-			}
-			returnData[k] = value
-			if t.Type != "" && t.Type != value.SourceType {
-				continue
-			}
-			*result = append(*result, value)
-		}
-	}
-	sort.Sort(result)
-	return result, a1, a2, a3, a4
-}

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

@@ -137,17 +137,6 @@ type PrjectHistoryReq struct {
 	WinnerId string `json:"winnerId"`
 }
 
-type ChannelListReq 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"`       //代理机构
-	PositionId   int64  `header:"positionId,optional"`
-	EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
-	Type         string `json:"type,optional"`
-}
-
 type RouteOwnerListReq struct {
 	BuyerId    string `json:"buyerId,optional"`
 	BuyerName  string `json:"buyerName,optional"`

+ 0 - 14
api/networkmanage.api

@@ -125,16 +125,6 @@ type (
 		BuyerId  string `json:"buyerId"`
 		WinnerId string `json:"winnerId"`
 	}
-	ChannelListReq {
-		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"`       //代理机构
-		PositionId   int64  `header:"positionId,optional"`
-		EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
-		Type         string `json:"type,optional"`
-	}
 	RouteOwnerListReq {
 		BuyerId    string `json:"buyerId,optional"`
 		BuyerName  string `json:"buyerName,optional"`
@@ -202,8 +192,4 @@ service networkManage {
 	@doc "可介绍业主合作次数"
 	@handler ownerCooperate
 	post /networkManage/owner/cooperate (CooperateOwnerListReq) returns (Reply)
-	
-	@doc "候选渠道列表"
-	@handler candidateChannelList
-	post /networkManage/candidate/channel/list (ChannelListReq) returns (Reply)
 }