123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- 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)
- }
|