package figure import ( "fmt" log "github.com/donnie4w/go-logger/logger" "go.mongodb.org/mongo-driver/bson" qu "qfw/util" "strings" "time" u "ul" "unicode/utf8" ) //打通用分 func FigureGlobalScoreInfo() { q, total := map[string]interface{}{}, 0 sess := u.Ext_Mgo.GetMgoConn() defer u.Ext_Mgo.DestoryMongoConn(sess) it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_info").Find(&q).Sort("_id").Select(map[string]interface{}{ "qua_res": 1, }).Iter() for tmp := make(map[string]interface{}); it.Next(&tmp); total++ { if total%10000 == 0 { log.Debug("cur index ", total) } tmpid := u.BsonTOStringId(tmp["_id"]) qua_res := *qu.ObjToMap(tmp["qua_res"]) qua_score := *qu.ObjToMap(qua_res["qua_score"]) ns := 0 for _, v := range qua_score { nv := *qu.ObjToMap(v) ns += qu.IntAll(nv["score"]) } u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{ "$set": map[string]interface{}{ "qua_score": ns, }, }) tmp = make(map[string]interface{}) } log.Debug("is over ...", total) } func FigureUnLevelScreenNumber() { dataArr, _ := u.Ext_Mgo.Find("zktest_marked_info", map[string]interface{}{ "qua_rejecty": 1, }, nil, map[string]interface{}{ "subtype": 1, "qua_res": 1, "qua_tag": 1, }) n1, n2, n3, n4 := 0, 0, 0, 0 n5, n6, n7, n8 := 0, 0, 0, 0 for _, v := range dataArr { subtype := qu.ObjToString(v["subtype"]) qua_tag := qu.IntAll(v["qua_tag"]) qua_res := *qu.ObjToMap(v["qua_res"]) qua_level := qu.IntAll(qua_res["qua_level"]) if subtype == "中标" || subtype == "成交" || subtype == "合同" { if qua_level == -1 { if qua_tag == 1 { n3++ } else { n4++ } } if qua_level == 0 { if qua_tag == 1 { n7++ } else { n8++ } } } else { if qua_level == -1 { if qua_tag == 1 { n1++ } else { n2++ } } if qua_level == 0 { if qua_tag == 1 { n5++ } else { n6++ } } } } log.Debug("不可信级别招标~", n1, "~", n2) log.Debug("不可信级别结果~", n3, "~", n4) log.Debug("边缘级别招标~", n5, "~", n6) log.Debug("边缘级别结果~", n7, "~", n8) } //根据不可信维度-再度提取-可信数据 func FigureUnLevelScreenInfo() { //加载正文信息 q, total1 := map[string]interface{}{}, 0 det_res := map[string]string{} sess := u.Ext_Mgo.GetMgoConn() defer u.Ext_Mgo.DestoryMongoConn(sess) it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_source").Find(&q).Sort("_id").Select(map[string]interface{}{ "detail": 1, "filetext": 1, }).Iter() for tmp := make(map[string]interface{}); it.Next(&tmp); total1++ { if total1%10000 == 0 { log.Debug("cur index ", total1, "~", len(det_res)) } detail := qu.ObjToString(tmp["detail"]) filetext := qu.ObjToString(tmp["filetext"]) tmpid := u.BsonTOStringId(tmp["_id"]) if utf8.RuneCountInString(detail) < 100 && filetext == "" && !strings.Contains(detail, "详情请访问原网页") { det_res[tmpid] = tmpid } tmp = make(map[string]interface{}) } log.Debug("is over ...", total1, "~", len(det_res)) total2, isok1, isok2 := 0, 0, 0 sess = u.Ext_Mgo.GetMgoConn() defer u.Ext_Mgo.DestoryMongoConn(sess) it = sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_info").Find(&q).Sort("_id").Select(map[string]interface{}{ "qua_res": 1, "qua_tag": 1, "buyer": 1, "s_winner": 1, "subtype": 1, }).Iter() for tmp := make(map[string]interface{}); it.Next(&tmp); total2++ { if total2%10000 == 0 { log.Debug("cur index ", total2, "~", isok1, "~", isok2) } tmpid := u.BsonTOStringId(tmp["_id"]) buyer := qu.ObjToString(tmp["buyer"]) s_winner := qu.ObjToString(tmp["s_winner"]) subtype := qu.ObjToString(tmp["subtype"]) qua_res := *qu.ObjToMap(tmp["qua_res"]) qua_level := qu.IntAll(qua_res["qua_level"]) qua_tag := qu.IntAll(tmp["qua_tag"]) if qua_level == 0 || qua_level == -1 { if det_res[tmpid] != "" { if subtype == "中标" || subtype == "成交" || subtype == "合同" { if s_winner != "" && buyer != "" { if qua_tag == 2 { isok2++ } else { isok1++ } u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{ "$set": map[string]interface{}{ "qua_rejecty": 1, }, }) } } else { if buyer != "" { if qua_tag == 2 { isok2++ } else { isok1++ } u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{ "$set": map[string]interface{}{ "qua_rejecty": 1, }, }) } } } } tmp = make(map[string]interface{}) } log.Debug("is over ... ", total2, "~", isok1, "~", isok2) time.Sleep(time.Second * 2) } //评估占比 func FigurelQualityLevelFirst() { n1, n2, n3, n4 := 0, 0, 0, 0 dataArr, _ := u.Ext_Mgo.Find("zktest_marked_source", nil, nil, bson.M{"qua_res": 1, "subtype": 1}) log.Debug("查询...", len(dataArr)) for _, v := range dataArr { qua_res := qu.IntAll(v["qua_res"]) subtype := qu.ObjToString(v["subtype"]) if subtype == "中标" || subtype == "成交" || subtype == "合同" { if qua_res == 1 { n3++ } else { n4++ } } else { if qua_res == 1 { n1++ } else { n2++ } } } log.Debug("招标类:", n1, "~", n2) log.Debug("结果类:", n3, "~", n4) } //评估占比 func FigurelQualityLevelSecond() { q, total := map[string]interface{}{}, 0 sess := u.Ext_Mgo.GetMgoConn() defer u.Ext_Mgo.DestoryMongoConn(sess) it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_info").Find(&q).Sort("_id").Iter() zb_info, jg_info := map[string]map[string]int{}, map[string]map[string]int{} for tmp := make(map[string]interface{}); it.Next(&tmp); total++ { if total%10000 == 0 { log.Debug("cur index ", total) } subtype := qu.ObjToString(tmp["subtype"]) qua_tag := fmt.Sprintf("%d", qu.IntAll(tmp["qua_tag"])) qua := *qu.ObjToMap(tmp["qua_res"]) level := qu.IntAll(qua["qua_level"]) key := fmt.Sprintf("%d", level) if subtype == "中标" || subtype == "成交" || subtype == "合同" { info := jg_info[key] if info == nil { info = map[string]int{} } num := qu.IntAll(info[qua_tag]) info[qua_tag] = num + 1 jg_info[key] = info } else { info := zb_info[key] if info == nil { info = map[string]int{} } num := qu.IntAll(info[qua_tag]) info[qua_tag] = num + 1 zb_info[key] = info } tmp = make(map[string]interface{}) } log.Debug("可信招标类:", zb_info["1"]["1"]+zb_info["1"]["2"], "~", zb_info["1"]["1"], "~", zb_info["1"]["2"]) log.Debug("模糊招标类:", zb_info["0"]["1"]+zb_info["0"]["2"], "~", zb_info["0"]["1"], "~", zb_info["0"]["2"]) log.Debug("不可信招类:", zb_info["-1"]["1"]+zb_info["-1"]["2"], "~", zb_info["-1"]["1"], "~", zb_info["-1"]["2"]) log.Debug("可信结果类:", jg_info["1"]["1"]+jg_info["1"]["2"], "~", jg_info["1"]["1"], "~", jg_info["1"]["2"]) log.Debug("模糊结果类:", jg_info["0"]["1"]+jg_info["0"]["2"], "~", jg_info["0"]["1"], "~", jg_info["0"]["2"]) log.Debug("不可信结类:", jg_info["-1"]["1"]+jg_info["-1"]["2"], "~", jg_info["-1"]["1"], "~", jg_info["-1"]["2"]) } //不考虑area 与 city 计算是否修改率 func FigurelSourceInfoQuantity() { q, total := map[string]interface{}{}, 0 sess := u.Ext_Mgo.GetMgoConn() defer u.Ext_Mgo.DestoryMongoConn(sess) it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_source").Find(&q).Sort("_id").Select(map[string]interface{}{ "ck_bidamount": 1, "ck_budget": 1, "ck_buyer": 1, "ck_s_winner": 1, "ck_projectcode": 1, "ck_projectname": 1, "subtype": 1, }).Iter() isok1, isok2 := 0, 0 for tmp := make(map[string]interface{}); it.Next(&tmp); total++ { if total%10000 == 0 { log.Debug("cur index ", total, "~", isok1, "~", isok2) } subtype := qu.ObjToString(tmp["subtype"]) isT := true for k, v := range tmp { if strings.Contains(k, "ck_") { if subtype == "中标" || subtype == "成交" || subtype == "合同" { if qu.IntAll(v) > 1 { isT = false break } } else { if k == "ck_bidamount" || k == "ck_s_winner" { } else { if qu.IntAll(v) > 1 { isT = false break } } } } } tmpid := u.BsonTOStringId(tmp["_id"]) if isT { isok1++ u.Ext_Mgo.UpdateById("zktest_marked_source", tmpid, map[string]interface{}{ "$set": map[string]interface{}{ "qua_tag": 1, }, }) u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{ "$set": map[string]interface{}{ "qua_tag": 1, }, }) } else { isok2++ u.Ext_Mgo.UpdateById("zktest_marked_source", tmpid, map[string]interface{}{ "$set": map[string]interface{}{ "qua_tag": 2, }, }) u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{ "$set": map[string]interface{}{ "qua_tag": 2, }, }) } tmp = make(map[string]interface{}) } log.Debug("is over ...", total, "~", isok1, "~", isok2) }