Browse Source

fenzhihebing

123456 2 years ago
parent
commit
528b9dbdd6

+ 2 - 4
entbase/src/service/behavior/behaviorshow.go

@@ -1,9 +1,6 @@
 package behavior
 
 import (
-	. "api"
-	. "ent/entity"
-	. "ent/util"
 	"fmt"
 	"github.com/go-xweb/xweb"
 	qutil "qfw/util"
@@ -53,6 +50,7 @@ func (a *Action) BehaviorShow() {
 		return
 	}
 	page, _ := a.GetInteger("page")
+	pageSize, _ := a.GetInteger("pageSize")
 	startTime, _ := a.GetInteger("startTime")
 	endTime, _ := a.GetInteger("endTime")
 	name := a.GetString("name")
@@ -88,7 +86,7 @@ func (a *Action) BehaviorShow() {
 		`+quryname+`
 		ORDER BY c.createtime`, departmentId, departmentId, frameworkEntId, frameworkEntId, startTime, endTime)
 env:
-	count, data := Paging(page, 20, entniche_infos)
+	count, data := Paging(page, pageSize, entniche_infos)
 	a.ServeJson(Result{Data: M{
 		"count":        count,
 		"behaviorData": data,

+ 16 - 0
entdataexport/src/config.json

@@ -51,6 +51,22 @@
     "maxOpenConns": 2,
     "maxIdleConns": 2
   },
+  "baseMysql": {
+    "dbName": "base_service",
+    "address": "192.168.3.14:4000",
+    "userName": "root",
+    "passWord": "=PDT49#80Z!RVv52_z",
+    "maxOpenConns": 5,
+    "maxIdleConns": 5
+  },
+  "globalCommonData": {
+    "dbName": "global_common_data",
+    "address": "192.168.3.14:4000",
+    "userName": "root",
+    "passWord": "=PDT49#80Z!RVv52_z",
+    "maxOpenConns": 5,
+    "maxIdleConns": 5
+  },
   "maxExportCount": 20000,
   "costUserAccount": [
     2081

+ 17 - 1
entdataexport/src/config/config.go

@@ -57,9 +57,25 @@ type config struct {
 		MaxOpenConns int
 		MaxIdleConns int
 	}
+	BaseMysql struct {
+		DbName       string
+		Address      string
+		UserName     string
+		PassWord     string
+		MaxOpenConns int
+		MaxIdleConns int
+	}
+	GlobalCommonData struct {
+		DbName       string
+		Address      string
+		UserName     string
+		PassWord     string
+		MaxOpenConns int
+		MaxIdleConns int
+	}
 	MaxExportCount  int
 	CostUserAccount []int
-	DedupUrl string
+	DedupUrl        string
 }
 
 var Config *config

+ 27 - 0
entdataexport/src/db/db.go

@@ -11,6 +11,8 @@ import (
 )
 
 var PushMysql *mysql.Mysql
+var BaseMysql *mysql.Mysql
+var GlobalCommonData *mysql.Mysql
 var Qyfw mg.MongodbSim
 var Mgo_bidding mg.MongodbSim
 
@@ -72,6 +74,31 @@ func init() {
 	}
 	PushMysql.Init()
 	jy.PushMapping.Init(PushMysql)
+	BaseMysql = &mysql.Mysql{
+		Address:      Config.BaseMysql.Address,
+		UserName:     Config.BaseMysql.UserName,
+		PassWord:     Config.BaseMysql.PassWord,
+		DBName:       Config.BaseMysql.DbName,
+		MaxOpenConns: Config.BaseMysql.MaxOpenConns,
+		MaxIdleConns: Config.BaseMysql.MaxIdleConns,
+	}
+	BaseMysql.Init()
+	GlobalCommonData = &mysql.Mysql{
+
+		Address: Config.GlobalCommonData.Address,
+
+		UserName: Config.GlobalCommonData.UserName,
+
+		PassWord: Config.GlobalCommonData.PassWord,
+
+		DBName: Config.GlobalCommonData.DbName,
+
+		MaxOpenConns: Config.GlobalCommonData.MaxOpenConns,
+
+		MaxIdleConns: Config.GlobalCommonData.MaxIdleConns,
+	}
+	GlobalCommonData.Init()
+	jy.NewPushMapping.Init(GlobalCommonData)
 	//初始化elastic
 	elastic.InitElasticSize(Config.Elasticsearch.Address, Config.Elasticsearch.Size)
 }

+ 34 - 37
entdataexport/src/service/dataexport/dataexport.go

@@ -37,9 +37,9 @@ type EntDataExport struct {
 }
 
 var (
-	SE             = util.SimpleEncrypt{Key: "topJYBX2019"}
-	qstr           = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget"]}`
-	PageSize       = 50
+	SE   = util.SimpleEncrypt{Key: "topJYBX2019"}
+	qstr = `{"query":{"terms":{"_id":["%s"]}},"_source":["_id","area", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "buyerclass","bidamount","budget"]}`
+	//PageSize       = 50
 	EntTable       = "winner_enterprise"
 	ClearHtml      = regexp.MustCompile("<[^>]*>")
 	ClearOther     = regexp.MustCompile("[\n\r\\s\u3000\u2003\u00a0]")
@@ -52,11 +52,19 @@ var (
 
 func (a *EntDataExport) SubscribeList() {
 	pageNum, err := a.GetInteger("pageNum")
+	pageSize, err := a.GetInteger("pageSize")
 	if err != nil {
 		pageNum = 1
 		log.Println("页码获取失败")
+		pageSize = 10
+	}
+	if pageSize == 0 {
+		pageSize = 10
 	}
 	log.Println("pageNum", pageNum)
+	if pageSize == 0 {
+		pageSize = 10
+	}
 	area := a.GetString("area")
 	selectTime := a.GetString("time")
 	buyerclass := a.GetString("buyerclass")
@@ -69,7 +77,7 @@ func (a *EntDataExport) SubscribeList() {
 	}
 	isGetSubscribe := true
 	if getsubscribe != 1 {
-		hasNextPage, list, count := jy.EntnichePush.NewDatas(Mgo_bidding, biddings, biddings_back, PushMysql, entId, entUserId, pageNum, selectTime, area, buyerclass, isEnt,config.Config.DedupUrl)
+		hasNextPage, list, count := jy.EntnichePush.NewDatas(Mgo_bidding, biddings, biddings_back, BaseMysql, entId, entUserId, pageNum, selectTime, area, buyerclass, isEnt, config.Config.DedupUrl, pageSize)
 		if list != nil && len(list) > 0 {
 			isGetSubscribe = false
 		}
@@ -93,25 +101,17 @@ func (a *EntDataExport) SubscribeList() {
 
 func (this *EntDataExport) SubscribeExport() {
 	area := this.GetString("area")
+	city := this.GetString("city")
 	buyerclass := this.GetString("buyerclass")
 	selectTime := this.GetString("time")
 	isFirst, _ := this.GetBool("isFirst")
 	entId := util.IntAll(this.GetSession("entId"))
 	entUserId := util.IntAll(this.GetSession("entUserId"))
-	//entId := 1956
-	//entUserId := 3156
-	// log.Println("entUserId", entUserId)
 	isEnt, _ := this.GetBool("isEnt")
-	//
 	MainLock.Lock()
 	UserLockMap[entId] = &sync.Mutex{}
 	entLock := UserLockMap[entId]
 	MainLock.Unlock()
-	var (
-		//entexportPool      = make(chan bool, 20)
-		//entexportWaitGroup = &sync.WaitGroup{}
-		//newsDatalen        = make(chan bool, 1000000)
-	)
 	entUserData := Mysql.FindOne("entniche_user", map[string]interface{}{"id": entUserId}, "export_power", "")
 	if entUserData != nil {
 		export_power := util.IntAll((*entUserData)["export_power"])
@@ -123,7 +123,6 @@ func (this *EntDataExport) SubscribeExport() {
 			return
 		}
 	}
-	//
 	entLock.Lock()
 	current := 0
 	if config.CostModelMap[entId] {
@@ -132,12 +131,11 @@ func (this *EntDataExport) SubscribeExport() {
 	} else {
 		current = GetCurrentCount(entId)
 	}
-
 	//新扣除条数
 	newCount := 0
 	isOk := true
 	url := config.Config.DedupUrl
-	list, count, secondCount := jy.EntnichePush.NewExportDatas(Mgo_bidding, biddings, biddings_back, PushMysql, entId, entUserId, selectTime, area, buyerclass, isEnt, MaxExportCount,url )
+	list, count, secondCount := jy.EntnichePush.NewExportDatas(Mgo_bidding, biddings, biddings_back, BaseMysql, entId, entUserId, selectTime, area, city, buyerclass, isEnt, MaxExportCount, url)
 	if secondCount > current {
 		isOk = false
 	}
@@ -148,7 +146,7 @@ func (this *EntDataExport) SubscribeExport() {
 		if !isFirst && isOk {
 			insertFlag = "true"
 		}
-		log.Println(len(list),"123list")
+		log.Println(len(list), "123list")
 		m := map[string]bool{}
 		for _, v := range list {
 			infoid := util.ObjToString(v["infoid"])
@@ -161,13 +159,13 @@ func (this *EntDataExport) SubscribeExport() {
 			if len(infoIdList) > 1000 {
 				//	 调接口
 				rs, err5 := util2.Post(config.Config.DedupUrl, map[string]string{
-					"personId": "0",// 没有使用这个参数
+					"personId": "0", // 没有使用这个参数
 					"infoId":   strings.Join(infoIdList, ","),
 					"entId":    fmt.Sprintf("%d", entId),
 					"isInsert": insertFlag,
 					"isEnt":    "true",
 				})
-				if err5 != nil || util.IntAll(rs["code"])!=0{
+				if err5 != nil || util.IntAll(rs["code"]) != 0 {
 					log.Println("企业订阅数据导出接口判重失败", err5)
 				} else {
 					log.Println("企业订阅数据导出")
@@ -175,9 +173,9 @@ func (this *EntDataExport) SubscribeExport() {
 					infoIdList = []string{}
 					// 本次数据累计
 					returnData := rs["data"].(map[string]interface{})
-					log.Println(newCount,"加之前")
-					newCount+=int(returnData["newCount"].(float64))
-					log.Println(newCount,"加之后")
+					log.Println(newCount, "加之前")
+					newCount += int(returnData["newCount"].(float64))
+					log.Println(newCount, "加之后")
 				}
 
 			}
@@ -189,26 +187,25 @@ func (this *EntDataExport) SubscribeExport() {
 				// v["infoid"] = infoid
 			}
 		}
-		if len(infoIdList)>0{
+		if len(infoIdList) > 0 {
 			log.Println(entId)
-			rs,err5 := util2.Post(config.Config.DedupUrl, map[string]string{
-				"personId":"0",// 没有使用这个参数
-				"infoId":strings.Join(infoIdList,","),
-				"entId":fmt.Sprintf("%d", entId),
-				"isInsert":insertFlag,
-				"isEnt":"true",
-
+			rs, err5 := util2.Post(config.Config.DedupUrl, map[string]string{
+				"personId": "0", // 没有使用这个参数
+				"infoId":   strings.Join(infoIdList, ","),
+				"entId":    fmt.Sprintf("%d", entId),
+				"isInsert": insertFlag,
+				"isEnt":    "true",
 			})
-			if err5 !=nil|| util.IntAll(rs["code"])!=0{
-				log.Println("判重失败===",err5)
+			if err5 != nil || util.IntAll(rs["code"]) != 0 {
+				log.Println("判重失败===", err5)
 				return
-			}else {
+			} else {
 				//log.Println(rs)
 				// 置空
 				infoIdList = []string{}
 				// 本次数据累计
 				returnData := rs["data"].(map[string]interface{})
-				newCount+=int(returnData["newCount"].(float64))
+				newCount += int(returnData["newCount"].(float64))
 			}
 		}
 		//entexportWaitGroup.Wait()
@@ -283,7 +280,7 @@ func (this *EntDataExport) IsSubscribeExport() {
 }
 
 //生成SQL语句
-func GetSQL(selectTime, area, buyerclass string, entId, entUserId, pageNum int) string {
+func GetSQL(selectTime, area, buyerclass string, entId, entUserId, pageNum, pageSize int) string {
 	findSQL := "select id,date,infoid,isvisit,matchkeys,type,1 as isvip from pushentniche where entid=" + fmt.Sprint(entId) + " and userid=" + fmt.Sprint(entUserId)
 	findStr := ""
 	if selectTime != "" {
@@ -322,8 +319,8 @@ func GetSQL(selectTime, area, buyerclass string, entId, entUserId, pageNum int)
 	}
 	findStr += " order by id desc"
 	if pageNum > 0 {
-		start := (pageNum - 1) * PageSize
-		findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(PageSize)
+		start := (pageNum - 1) * pageSize
+		findStr += " limit " + fmt.Sprint(start) + "," + fmt.Sprint(pageSize)
 	}
 	findSQL = findSQL + findStr
 	return findSQL

+ 102 - 0
entdataexport/src/util/pushmapping.go

@@ -0,0 +1,102 @@
+package util
+
+import (
+	"fmt"
+	"log"
+	"qfw/util"
+	"qfw/util/mysql"
+)
+
+var PushMapping = &pushMapping{}
+
+const (
+	CODEAREA          = "code_area"
+	CODEBIDSCOPE      = "code_bidscope"
+	CODEBIDTOPSUBTYPE = "code_bidtopsubtype"
+	CODEBUYERCLASS    = "code_buyerclass"
+	Baseinfo          = "global_common_data.dws_f_bid_baseinfo"
+	BidTags           = "global_common_data.dws_f_bid_tags"
+	PushEntniche      = "pushentniche"
+)
+
+type pushMapping struct {
+	Area          map[string]string
+	City          map[string]string
+	Toptype       map[string]string
+	Subtype       map[string]string
+	Buyerclass    map[string]string
+	Subscopeclass map[string]string
+}
+
+func (p *pushMapping) Init(Mysql *mysql.Mysql) {
+	//信息类型
+	infotype := Mysql.SelectBySql(fmt.Sprintf("select level,code,name from %s where level=2", CODEBIDTOPSUBTYPE))
+	Subtype := map[string]string{}
+	if infotype != nil && len(*infotype) > 0 {
+		for _, v := range *infotype {
+			code := util.ObjToString(v["code"])
+			name := util.ObjToString(v["name"])
+			Subtype[name] = code
+		}
+		if len(Subtype) == 0 {
+			log.Fatalln("PushMapping Subtype Init Error")
+		}
+		p.Subtype = Subtype
+	}
+	//采购单位行业
+	Buyerclass := map[string]string{}
+	buyerclass := Mysql.SelectBySql(fmt.Sprintf("select code,name from %s where level=1", CODEBUYERCLASS))
+	if buyerclass != nil && len(*buyerclass) > 0 {
+		for _, v := range *buyerclass {
+			code := util.ObjToString(v["code"])
+			name := util.ObjToString(v["name"])
+			Buyerclass[name] = code
+		}
+
+		if len(Buyerclass) == 0 {
+			log.Fatalln("PushMapping Buyerclass Init Error")
+		}
+		p.Buyerclass = Buyerclass
+	}
+
+	//公告类型处理
+	Subscopeclass := map[string]string{}
+	subscopeclass := Mysql.SelectBySql(fmt.Sprintf("select a.code, CONCAT(b.name,'_',a.name) as name  from %s a LEFT JOIN %s b on a.pcode=b.code where  a.level=2", CODEBIDSCOPE, CODEBIDSCOPE))
+	if subscopeclass != nil && len(*subscopeclass) > 0 {
+		for _, v := range *subscopeclass {
+			code := util.ObjToString(v["code"])
+			name := util.ObjToString(v["name"])
+			Subscopeclass[name] = code
+		}
+
+		if len(Subscopeclass) == 0 {
+			log.Fatalln("PushMapping subscopeclass Init Error")
+		}
+		p.Subscopeclass = Subscopeclass
+	}
+	//省份处理
+	Area := map[string]string{}
+	City := map[string]string{}
+	province := Mysql.SelectBySql(fmt.Sprintf("select code,area,city from %s where (district is null or district='')", CODEAREA))
+	if province != nil && len(*province) > 0 {
+		for _, v := range *province {
+			code := util.ObjToString(v["code"])
+			city := util.ObjToString(v["city"])
+			area := util.ObjToString(v["area"])
+			if city == "" {
+				Area[area] = code
+			} else {
+				City[city] = code
+			}
+		}
+		if len(Area) == 0 {
+			log.Fatalln("PushMapping Area Init Error")
+		}
+		if len(City) == 0 {
+			log.Fatalln("PushMapping City Init Error")
+		}
+		p.Area = Area
+		p.City = City
+	}
+
+}

+ 1 - 1
entniche_new/src/entity/portrait_screen.go

@@ -283,7 +283,7 @@ func (pwp *PortraitProjectScreen) GetBuyerListSearch() (list *[]map[string]inter
 		}
 	} else { //免费用户可以查看三条
 		pwp.PageNum = 1
-		pwp.PageSize = 3
+		pwp.PageSize = 5
 	}
 
 	//仅第一页查询总量(非数据导出)