|
@@ -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
|