|
@@ -360,9 +360,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
logx.Info("searchSql", searchSql)
|
|
|
//查询总数
|
|
|
count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select count(a.id)" + searchSql))
|
|
|
- findSql = "SELECT aa.*, cc.name as buyer, bb.labelvalues as industry FROM (select DISTINCT a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count,b.site," +
|
|
|
- "b.title,b.area_code,b.buyerclass_code,b.subtype_code,b.publishtime,b.budget,b.bidamount,b.projectname,b.bidopentime,b.buyer_id "
|
|
|
-
|
|
|
+ findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
} else {
|
|
|
if spqp.IsEnt {
|
|
|
isNew := 0
|
|
@@ -541,8 +539,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
start2 = time.Now().Unix()
|
|
|
logx.Info("count:", count, "---", s.ModuleFlag)
|
|
|
logx.Info("查询数据总数用时", start2-start)
|
|
|
- findSql = "SELECT aa.*, bb.labelvalues as industry, cc.name as buyer FROM (select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count,b.site," +
|
|
|
- "b.title,b.area_code,b.buyerclass_code,b.subtype_code,b.publishtime,b.budget,b.bidamount,b.projectname,b.bidopentime,b.buyer_id "
|
|
|
+ findSql = "select DISTINCT a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
if s.ModuleFlag == EntnicheFlag {
|
|
|
findSql += ", IF(a.source is NULL,1,a.source) as source "
|
|
|
}
|
|
@@ -554,17 +551,17 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
if isLimit {
|
|
|
findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
|
|
|
}
|
|
|
- findSql += fmt.Sprintf(") aa LEFT JOIN %s bb ON ( aa.infoid = bb.infoid ) AND bb.labelcode = 2 left join global_common_data.dws_f_ent_baseinfo cc on aa.buyer_id=cc.name_id ORDER BY aa.id desc ", BidTags)
|
|
|
+
|
|
|
logx.Info(spqp.NewUserId, "subscribePush query sql:", findSql)
|
|
|
list := spqp.BaseServiceMysql.SelectBySql(findSql)
|
|
|
start3 := time.Now().Unix()
|
|
|
logx.Info("查询数据用时", start3-start2)
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
- pushCas, subscribeInfo := s.GetJyPushs(*list, codeMap)
|
|
|
+ pushCas := s.GetJyPushs(*list)
|
|
|
start4 := time.Now().Unix()
|
|
|
logx.Info("清洗数据耗时", start4-start3)
|
|
|
if !spqp.Export {
|
|
|
- result = subscribeInfo
|
|
|
+ result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
|
|
|
} else {
|
|
|
result = s.GetOnlyExportInfo(pushCas)
|
|
|
}
|
|
@@ -659,9 +656,11 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
|
|
|
}
|
|
|
for k, v := range pushCas {
|
|
|
info := infos[v.InfoId]
|
|
|
- info["Visit"] = v.Visit
|
|
|
+ info["Visit"] = 0
|
|
|
if info == nil {
|
|
|
info = map[string]interface{}{}
|
|
|
+ } else {
|
|
|
+ info["Visit"] = common.InterfaceToStr(v.Visit)
|
|
|
}
|
|
|
array[k] = s.InfoFormat(v, &info)
|
|
|
}
|
|
@@ -669,36 +668,9 @@ func (s *subscribePush) GetInfoByIds(Mgo_bidding mongodb.MongodbSim, bidding, bi
|
|
|
}
|
|
|
|
|
|
// 获取历史推送
|
|
|
-func (s *subscribePush) GetJyPushs(datas []map[string]interface{}, codeMap *codeservice.Response) ([]*PushCa, []*bxsubscribe.SubscribeInfo) {
|
|
|
- pushCas := []*PushCa{}
|
|
|
- subscribeInfo := []*bxsubscribe.SubscribeInfo{}
|
|
|
- areaMap := map[string]string{}
|
|
|
- subtypeMap := map[string]string{}
|
|
|
- buyerClassMap := map[string]string{}
|
|
|
- industryMap := map[string]string{}
|
|
|
- for k, v := range codeMap.Data.Area {
|
|
|
- areaMap[v] = k
|
|
|
- }
|
|
|
- for k, v := range codeMap.Data.Subscopeclass {
|
|
|
- industryMap[v] = k
|
|
|
- }
|
|
|
- for k, v := range codeMap.Data.Subtype {
|
|
|
- subtypeMap[v] = k
|
|
|
- }
|
|
|
- for k, v := range codeMap.Data.Buyerclass {
|
|
|
- buyerClassMap[v] = k
|
|
|
- }
|
|
|
- array := []map[string]interface{}{}
|
|
|
- m := map[int64]int64{}
|
|
|
+func (s *subscribePush) GetJyPushs(datas []map[string]interface{}) (pushCas []*PushCa) {
|
|
|
+ pushCas = []*PushCa{}
|
|
|
for _, v := range datas {
|
|
|
- id := v["id"].(int64)
|
|
|
- if m[id] != 0 {
|
|
|
- } else {
|
|
|
- m[id] = id
|
|
|
- array = append(array, v)
|
|
|
- }
|
|
|
- }
|
|
|
- for _, v := range array {
|
|
|
keys := []string{}
|
|
|
if matchkeys := common.ObjToString(v["matchkeys"]); matchkeys != "" {
|
|
|
keys = strings.Split(matchkeys, " ")
|
|
@@ -712,52 +684,9 @@ func (s *subscribePush) GetJyPushs(datas []map[string]interface{}, codeMap *code
|
|
|
Type: common.IntAll(v["type"]),
|
|
|
Isvip: common.IntAll(v["isvip"]),
|
|
|
FileExists: common.IntAll(v["attachment_count"]) > 0,
|
|
|
- Source: common.Int64All(v["source"]),
|
|
|
- })
|
|
|
- area := common.ObjToString(v["area_code"])
|
|
|
- if area == "000000" {
|
|
|
- area = "全国"
|
|
|
- } else {
|
|
|
- area = areaMap[area]
|
|
|
- }
|
|
|
- //采购单位类型处理buyerClass
|
|
|
- buyerClass := buyerClassMap[common.ObjToString(v["buyerclass_code"])]
|
|
|
- //信息类型处理subtype
|
|
|
- subtype := subtypeMap[common.ObjToString(v["subtype_code"])]
|
|
|
- iss := strings.Split(industryMap[common.ObjToString(v["industry"])], "_")
|
|
|
- industry := ""
|
|
|
- if len(iss) > 0 {
|
|
|
- industry = iss[0]
|
|
|
- }
|
|
|
- publishTimeStr := common.InterfaceToStr(v["publishtime"])
|
|
|
- publishTime, _ := time.ParseInLocation("2006-01-02 15:04:05", publishTimeStr, time.Local)
|
|
|
- bidopentimeStr := common.InterfaceToStr(v["bidopentime"])
|
|
|
- bidopentime, _ := time.ParseInLocation("2006-01-02 15:04:05", bidopentimeStr, time.Local)
|
|
|
- subscribeInfo = append(subscribeInfo, &bxsubscribe.SubscribeInfo{
|
|
|
- XId: encrypt.EncodeArticleId2ByCheck(common.ObjToString(v["infoid"])),
|
|
|
- Title: common.InterfaceToStr(v["title"]),
|
|
|
- Area: area,
|
|
|
- BuyerClass: buyerClass,
|
|
|
- Subtype: subtype,
|
|
|
- Industry: industry,
|
|
|
- PublishTime: publishTime.Unix(),
|
|
|
- CaIndex: common.Int64All(v["id"]),
|
|
|
- CaDate: common.Int64All(v["date"]),
|
|
|
- CaIsvisit: common.Int64All(v["isvisit"]),
|
|
|
- CaType: common.Int64All(v["type"]),
|
|
|
- MatchKeys: keys,
|
|
|
- Budget: common.InterfaceToStr(v["budget"]),
|
|
|
- BidAmount: common.InterfaceToStr(v["bidamount"]),
|
|
|
- ProjectName: common.InterfaceToStr(v["projectname"]),
|
|
|
- Winner: common.InterfaceToStr(v["s_winner"]),
|
|
|
- BidOpenTime: bidopentime.Unix(),
|
|
|
- CaFileExists: common.IntAll(v["attachment_count"]) > 0,
|
|
|
- Source: common.Int64All(v["source"]),
|
|
|
- Site: common.InterfaceToStr(v["site"]),
|
|
|
- Buyer: common.InterfaceToStr(v["buyer"]),
|
|
|
})
|
|
|
}
|
|
|
- return pushCas, subscribeInfo
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// 查看全部列表缓存
|