|
@@ -140,7 +140,7 @@ func (c *CustomerRule) ProductData() {
|
|
|
defer qu.Catch()
|
|
|
if c.Method() == "POST" {
|
|
|
log.Println("正在生成预览数据。。。")
|
|
|
- rep := false
|
|
|
+ // rep := false
|
|
|
id := c.GetString("id")
|
|
|
tag, ok := Mgo.FindById("entniche_rule", id, `{}`)
|
|
|
if !ok {
|
|
@@ -157,13 +157,13 @@ func (c *CustomerRule) ProductData() {
|
|
|
if escount > 5000 {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": false,
|
|
|
- "msg": "本次匹配数据量:" + fmt.Sprint(escount) + "条,数据量大于5000,无法预览自助导出,请调整查询时间后重新点击生成数据",
|
|
|
+ "msg": "本次匹配数据量:" + fmt.Sprint(escount) + "条,数据量大于5000,无法预览自助导出,请调整规则条件后重新预览",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//
|
|
|
- s_startTime := qu.IntAll((*tag)["i_starttime"])
|
|
|
- s_endTime := qu.IntAll((*tag)["i_endtime"])
|
|
|
+ // s_startTime := qu.IntAll((*tag)["i_starttime"])
|
|
|
+ // s_endTime := qu.IntAll((*tag)["i_endtime"])
|
|
|
totalCount := 0
|
|
|
//
|
|
|
multiMatchcount := strings.Count(s_esquery, "multi_match")
|
|
@@ -186,13 +186,13 @@ func (c *CustomerRule) ProductData() {
|
|
|
if rangeCount != -1 {
|
|
|
totalCount += rangeCount
|
|
|
}
|
|
|
- if totalCount > 1000 && (s_startTime == 0 || s_endTime == 0) {
|
|
|
- c.ServeJson(map[string]interface{}{
|
|
|
- "rep": false,
|
|
|
- "msg": "查询过多,请限制开始时间及结束时间",
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
+ // if totalCount > 1000 && (s_startTime == 0 || s_endTime == 0) {
|
|
|
+ // c.ServeJson(map[string]interface{}{
|
|
|
+ // "rep": false,
|
|
|
+ // "msg": "查询过多,请限制开始时间及结束时间",
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ // }
|
|
|
if totalCount > 8000 {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": false,
|
|
@@ -204,12 +204,13 @@ func (c *CustomerRule) ProductData() {
|
|
|
// 其他的分隔
|
|
|
// 1000<=总个数<4000,将时间(publishtime)按照每3个月进行分割,然后查询到的数据量进行求和。
|
|
|
// 4000<=总个数<8000,将时间(publishtime)按照每1个月进行分割,然后查询到的数据量进行求和
|
|
|
- var err error
|
|
|
- var count int64
|
|
|
+ // var err error
|
|
|
+ // var count int64
|
|
|
// var n int
|
|
|
// 小于1000的直接查
|
|
|
// if totalCount < 1000 {
|
|
|
- err, count = UtilEsFind1(*tag)
|
|
|
+ // err, count = UtilEsFind1(*tag)
|
|
|
+ go UtilEsFind1(*tag)
|
|
|
// } else {
|
|
|
// if totalCount >= 1000 && totalCount < 4000 {
|
|
|
// n = 3
|
|
@@ -219,44 +220,100 @@ func (c *CustomerRule) ProductData() {
|
|
|
// }
|
|
|
// err, count = UtilEsFind2(*tag, n)
|
|
|
// }
|
|
|
- var msg string
|
|
|
- if err == nil {
|
|
|
- rep = true
|
|
|
- msg = "数据生成成功"
|
|
|
- } else {
|
|
|
- rep = false
|
|
|
- msg = "数据生成失败"
|
|
|
- }
|
|
|
- c.ServeJson(map[string]interface{}{
|
|
|
- "rep": rep,
|
|
|
- "count": count,
|
|
|
- "msg": msg,
|
|
|
- })
|
|
|
+ // var msg string
|
|
|
+ // if err == nil {
|
|
|
+ // rep = true
|
|
|
+ // msg = "数据生成成功"
|
|
|
+ // } else {
|
|
|
+ // rep = false
|
|
|
+ // msg = "数据生成失败"
|
|
|
+ // }
|
|
|
+ // c.ServeJson(map[string]interface{}{
|
|
|
+ // "rep": rep,
|
|
|
+ // "count": count,
|
|
|
+ // "msg": msg,
|
|
|
+ // })
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (r *CustomerRule) DemoData() {
|
|
|
defer qu.Catch()
|
|
|
if r.Method() == "POST" {
|
|
|
- sDataid := r.GetString("s_dataid")
|
|
|
- start, _ := r.GetInteger("start")
|
|
|
- limit, _ := r.GetInteger("length")
|
|
|
+ esquery := r.GetString("esquery")
|
|
|
+ id := r.GetString("id")
|
|
|
draw, _ := r.GetInteger("draw")
|
|
|
- query := bson.M{
|
|
|
- "s_dataid": sDataid,
|
|
|
- }
|
|
|
- data, _ := Mgo.Find("tagsdata", query, `{"publishtime":-1}`, nil, false, start, limit)
|
|
|
- count := Mgo.Count("tagsdata", query)
|
|
|
- for _, v := range *data {
|
|
|
- if v["budget"] != nil {
|
|
|
- v["budget"] = qu.Float64All(fmt.Sprintf("%f", qu.Float64All(v["budget"])/10000))
|
|
|
+ tag, _ := Mgo.FindById("entniche_rule", id, `{}`)
|
|
|
+ tags := *tag
|
|
|
+ maths := make([]map[string]string, 0)
|
|
|
+ if orules, ok := tags["o_rules"].([]interface{}); ok {
|
|
|
+ for _, v := range orules {
|
|
|
+ orule, _ := v.(map[string]interface{})
|
|
|
+ maths = append(maths, map[string]string{
|
|
|
+ "s_matchkey": qu.ObjToString(orule["s_matchkey"]),
|
|
|
+ "s_keymatch": qu.ObjToString(orule["s_keymatch"]),
|
|
|
+ })
|
|
|
}
|
|
|
- if v["bidamount"] != nil {
|
|
|
- v["bidamount"] = qu.Float64All(fmt.Sprintf("%f", qu.Float64All(v["bidamount"])/10000))
|
|
|
+ } else if orules, ok := tags["o_rules"].([]map[string]interface{}); ok {
|
|
|
+ for _, v := range orules {
|
|
|
+ maths = append(maths, map[string]string{
|
|
|
+ "s_matchkey": qu.ObjToString(v["s_matchkey"]),
|
|
|
+ "s_keymatch": qu.ObjToString(v["s_keymatch"]),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ esquery = esquery[:len(esquery)-1] + `,"size":` + fmt.Sprintf("%d", 100) + `}`
|
|
|
+ data := Es.Get(InterimIndex, Itype, esquery)
|
|
|
+ count := 0
|
|
|
+ if data != nil && len(*data) > 0 {
|
|
|
+ count = len(*data)
|
|
|
+ for _, item := range *data {
|
|
|
+ if item["budget"] != nil {
|
|
|
+ item["budget"] = qu.Float64All(fmt.Sprintf("%f", qu.Float64All(item["budget"])/10000))
|
|
|
+ }
|
|
|
+ if item["bidamount"] != nil {
|
|
|
+ item["bidamount"] = qu.Float64All(fmt.Sprintf("%f", qu.Float64All(item["bidamount"])/10000))
|
|
|
+ }
|
|
|
+ info_id := qu.ObjToString(item["_id"])
|
|
|
+ item["info_id"] = info_id
|
|
|
+ //
|
|
|
+ subType := qu.ObjToString(item["subtype"])
|
|
|
+ subTypeStr := "拟建,采购意向,预告,预审,预审结果,论证意见,需求公示"
|
|
|
+ if strings.Contains(subTypeStr, subType) {
|
|
|
+ item["s_jyhref"] = `https://www.jianyu360.cn/article/bdprivate/` + qu.CommonEncodeArticle("bdprivate", info_id) + `.html`
|
|
|
+ } else {
|
|
|
+ item["s_jyhref"] = `https://www.jianyu360.cn/article/content/` + qu.CommonEncodeArticle("content", info_id) + `.html`
|
|
|
+ }
|
|
|
+ //
|
|
|
+ item["i_createtime"] = time.Now().Unix()
|
|
|
+ delete(item, "_id")
|
|
|
+ //二次匹配关键词
|
|
|
+ matchKeys := GetMactchKey(maths, item)
|
|
|
+ if len(maths) > 0 {
|
|
|
+ if matchKeys != "" {
|
|
|
+ item["s_matchkey"] = matchKeys
|
|
|
+ }
|
|
|
+ }
|
|
|
+ findwinner := strings.TrimSpace(qu.ObjToString(item["winner"]))
|
|
|
+ if findwinner != "" {
|
|
|
+ finddata := MgoEnps.FindOne(EnpsColl, bson.M{"company_name": findwinner})
|
|
|
+ if finddata != nil {
|
|
|
+ if legal_person := qu.ObjToString(finddata["legal_person"]); legal_person != "" {
|
|
|
+ item["legal_person"] = legal_person
|
|
|
+ }
|
|
|
+ if email := qu.ObjToString(finddata["company_email"]); email != "" {
|
|
|
+ item["company_email"] = email
|
|
|
+ }
|
|
|
+ if phone := qu.ObjToString(finddata["company_phone"]); phone != "" {
|
|
|
+ item["company_phone"] = phone
|
|
|
+ }
|
|
|
+ item["qyk"] = finddata
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
r.ServeJson(map[string]interface{}{
|
|
|
"data": data,
|
|
|
+ "count": count,
|
|
|
"draw": draw,
|
|
|
"recordsFiltered": count,
|
|
|
"recordsTotal": count,
|