figure.go 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. package figure
  2. import (
  3. "fmt"
  4. log "github.com/donnie4w/go-logger/logger"
  5. "go.mongodb.org/mongo-driver/bson"
  6. qu "qfw/util"
  7. "strings"
  8. "time"
  9. u "ul"
  10. "unicode/utf8"
  11. )
  12. //打通用分
  13. func FigureGlobalScoreInfo() {
  14. q, total := map[string]interface{}{}, 0
  15. sess := u.Ext_Mgo.GetMgoConn()
  16. defer u.Ext_Mgo.DestoryMongoConn(sess)
  17. it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_info").Find(&q).Sort("_id").Select(map[string]interface{}{
  18. "qua_res": 1,
  19. }).Iter()
  20. for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
  21. if total%10000 == 0 {
  22. log.Debug("cur index ", total)
  23. }
  24. tmpid := u.BsonTOStringId(tmp["_id"])
  25. qua_res := *qu.ObjToMap(tmp["qua_res"])
  26. qua_score := *qu.ObjToMap(qua_res["qua_score"])
  27. ns := 0
  28. for _, v := range qua_score {
  29. nv := *qu.ObjToMap(v)
  30. ns += qu.IntAll(nv["score"])
  31. }
  32. u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{
  33. "$set": map[string]interface{}{
  34. "qua_score": ns,
  35. },
  36. })
  37. tmp = make(map[string]interface{})
  38. }
  39. log.Debug("is over ...", total)
  40. }
  41. func FigureUnLevelScreenNumber() {
  42. dataArr, _ := u.Ext_Mgo.Find("zktest_marked_info", map[string]interface{}{
  43. "qua_rejecty": 1,
  44. }, nil, map[string]interface{}{
  45. "subtype": 1,
  46. "qua_res": 1,
  47. "qua_tag": 1,
  48. })
  49. n1, n2, n3, n4 := 0, 0, 0, 0
  50. n5, n6, n7, n8 := 0, 0, 0, 0
  51. for _, v := range dataArr {
  52. subtype := qu.ObjToString(v["subtype"])
  53. qua_tag := qu.IntAll(v["qua_tag"])
  54. qua_res := *qu.ObjToMap(v["qua_res"])
  55. qua_level := qu.IntAll(qua_res["qua_level"])
  56. if subtype == "中标" || subtype == "成交" || subtype == "合同" {
  57. if qua_level == -1 {
  58. if qua_tag == 1 {
  59. n3++
  60. } else {
  61. n4++
  62. }
  63. }
  64. if qua_level == 0 {
  65. if qua_tag == 1 {
  66. n7++
  67. } else {
  68. n8++
  69. }
  70. }
  71. } else {
  72. if qua_level == -1 {
  73. if qua_tag == 1 {
  74. n1++
  75. } else {
  76. n2++
  77. }
  78. }
  79. if qua_level == 0 {
  80. if qua_tag == 1 {
  81. n5++
  82. } else {
  83. n6++
  84. }
  85. }
  86. }
  87. }
  88. log.Debug("不可信级别招标~", n1, "~", n2)
  89. log.Debug("不可信级别结果~", n3, "~", n4)
  90. log.Debug("边缘级别招标~", n5, "~", n6)
  91. log.Debug("边缘级别结果~", n7, "~", n8)
  92. }
  93. //根据不可信维度-再度提取-可信数据
  94. func FigureUnLevelScreenInfo() {
  95. //加载正文信息
  96. q, total1 := map[string]interface{}{}, 0
  97. det_res := map[string]string{}
  98. sess := u.Ext_Mgo.GetMgoConn()
  99. defer u.Ext_Mgo.DestoryMongoConn(sess)
  100. it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_source").Find(&q).Sort("_id").Select(map[string]interface{}{
  101. "detail": 1,
  102. "filetext": 1,
  103. }).Iter()
  104. for tmp := make(map[string]interface{}); it.Next(&tmp); total1++ {
  105. if total1%10000 == 0 {
  106. log.Debug("cur index ", total1, "~", len(det_res))
  107. }
  108. detail := qu.ObjToString(tmp["detail"])
  109. filetext := qu.ObjToString(tmp["filetext"])
  110. tmpid := u.BsonTOStringId(tmp["_id"])
  111. if utf8.RuneCountInString(detail) < 100 && filetext == "" && !strings.Contains(detail, "详情请访问原网页") {
  112. det_res[tmpid] = tmpid
  113. }
  114. tmp = make(map[string]interface{})
  115. }
  116. log.Debug("is over ...", total1, "~", len(det_res))
  117. total2, isok1, isok2 := 0, 0, 0
  118. sess = u.Ext_Mgo.GetMgoConn()
  119. defer u.Ext_Mgo.DestoryMongoConn(sess)
  120. it = sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_info").Find(&q).Sort("_id").Select(map[string]interface{}{
  121. "qua_res": 1,
  122. "qua_tag": 1,
  123. "buyer": 1,
  124. "s_winner": 1,
  125. "subtype": 1,
  126. }).Iter()
  127. for tmp := make(map[string]interface{}); it.Next(&tmp); total2++ {
  128. if total2%10000 == 0 {
  129. log.Debug("cur index ", total2, "~", isok1, "~", isok2)
  130. }
  131. tmpid := u.BsonTOStringId(tmp["_id"])
  132. buyer := qu.ObjToString(tmp["buyer"])
  133. s_winner := qu.ObjToString(tmp["s_winner"])
  134. subtype := qu.ObjToString(tmp["subtype"])
  135. qua_res := *qu.ObjToMap(tmp["qua_res"])
  136. qua_level := qu.IntAll(qua_res["qua_level"])
  137. qua_tag := qu.IntAll(tmp["qua_tag"])
  138. if qua_level == 0 || qua_level == -1 {
  139. if det_res[tmpid] != "" {
  140. if subtype == "中标" || subtype == "成交" || subtype == "合同" {
  141. if s_winner != "" && buyer != "" {
  142. if qua_tag == 2 {
  143. isok2++
  144. } else {
  145. isok1++
  146. }
  147. u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{
  148. "$set": map[string]interface{}{
  149. "qua_rejecty": 1,
  150. },
  151. })
  152. }
  153. } else {
  154. if buyer != "" {
  155. if qua_tag == 2 {
  156. isok2++
  157. } else {
  158. isok1++
  159. }
  160. u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{
  161. "$set": map[string]interface{}{
  162. "qua_rejecty": 1,
  163. },
  164. })
  165. }
  166. }
  167. }
  168. }
  169. tmp = make(map[string]interface{})
  170. }
  171. log.Debug("is over ... ", total2, "~", isok1, "~", isok2)
  172. time.Sleep(time.Second * 2)
  173. }
  174. //评估占比
  175. func FigurelQualityLevelFirst() {
  176. n1, n2, n3, n4 := 0, 0, 0, 0
  177. dataArr, _ := u.Ext_Mgo.Find("zktest_marked_source", nil, nil, bson.M{"qua_res": 1, "subtype": 1})
  178. log.Debug("查询...", len(dataArr))
  179. for _, v := range dataArr {
  180. qua_res := qu.IntAll(v["qua_res"])
  181. subtype := qu.ObjToString(v["subtype"])
  182. if subtype == "中标" || subtype == "成交" || subtype == "合同" {
  183. if qua_res == 1 {
  184. n3++
  185. } else {
  186. n4++
  187. }
  188. } else {
  189. if qua_res == 1 {
  190. n1++
  191. } else {
  192. n2++
  193. }
  194. }
  195. }
  196. log.Debug("招标类:", n1, "~", n2)
  197. log.Debug("结果类:", n3, "~", n4)
  198. }
  199. //评估占比
  200. func FigurelQualityLevelSecond() {
  201. q, total := map[string]interface{}{}, 0
  202. sess := u.Ext_Mgo.GetMgoConn()
  203. defer u.Ext_Mgo.DestoryMongoConn(sess)
  204. it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_info").Find(&q).Sort("_id").Iter()
  205. zb_info, jg_info := map[string]map[string]int{}, map[string]map[string]int{}
  206. for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
  207. if total%10000 == 0 {
  208. log.Debug("cur index ", total)
  209. }
  210. subtype := qu.ObjToString(tmp["subtype"])
  211. qua_tag := fmt.Sprintf("%d", qu.IntAll(tmp["qua_tag"]))
  212. qua := *qu.ObjToMap(tmp["qua_res"])
  213. level := qu.IntAll(qua["qua_level"])
  214. key := fmt.Sprintf("%d", level)
  215. if subtype == "中标" || subtype == "成交" || subtype == "合同" {
  216. info := jg_info[key]
  217. if info == nil {
  218. info = map[string]int{}
  219. }
  220. num := qu.IntAll(info[qua_tag])
  221. info[qua_tag] = num + 1
  222. jg_info[key] = info
  223. } else {
  224. info := zb_info[key]
  225. if info == nil {
  226. info = map[string]int{}
  227. }
  228. num := qu.IntAll(info[qua_tag])
  229. info[qua_tag] = num + 1
  230. zb_info[key] = info
  231. }
  232. tmp = make(map[string]interface{})
  233. }
  234. log.Debug("可信招标类:", zb_info["1"]["1"]+zb_info["1"]["2"], "~", zb_info["1"]["1"], "~", zb_info["1"]["2"])
  235. log.Debug("模糊招标类:", zb_info["0"]["1"]+zb_info["0"]["2"], "~", zb_info["0"]["1"], "~", zb_info["0"]["2"])
  236. log.Debug("不可信招类:", zb_info["-1"]["1"]+zb_info["-1"]["2"], "~", zb_info["-1"]["1"], "~", zb_info["-1"]["2"])
  237. log.Debug("可信结果类:", jg_info["1"]["1"]+jg_info["1"]["2"], "~", jg_info["1"]["1"], "~", jg_info["1"]["2"])
  238. log.Debug("模糊结果类:", jg_info["0"]["1"]+jg_info["0"]["2"], "~", jg_info["0"]["1"], "~", jg_info["0"]["2"])
  239. log.Debug("不可信结类:", jg_info["-1"]["1"]+jg_info["-1"]["2"], "~", jg_info["-1"]["1"], "~", jg_info["-1"]["2"])
  240. }
  241. //不考虑area 与 city 计算是否修改率
  242. func FigurelSourceInfoQuantity() {
  243. q, total := map[string]interface{}{}, 0
  244. sess := u.Ext_Mgo.GetMgoConn()
  245. defer u.Ext_Mgo.DestoryMongoConn(sess)
  246. it := sess.DB(u.Ext_Mgo.DbName).C("zktest_marked_source").Find(&q).Sort("_id").Select(map[string]interface{}{
  247. "ck_bidamount": 1,
  248. "ck_budget": 1,
  249. "ck_buyer": 1,
  250. "ck_s_winner": 1,
  251. "ck_projectcode": 1,
  252. "ck_projectname": 1,
  253. "subtype": 1,
  254. }).Iter()
  255. isok1, isok2 := 0, 0
  256. for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
  257. if total%10000 == 0 {
  258. log.Debug("cur index ", total, "~", isok1, "~", isok2)
  259. }
  260. subtype := qu.ObjToString(tmp["subtype"])
  261. isT := true
  262. for k, v := range tmp {
  263. if strings.Contains(k, "ck_") {
  264. if subtype == "中标" || subtype == "成交" || subtype == "合同" {
  265. if qu.IntAll(v) > 1 {
  266. isT = false
  267. break
  268. }
  269. } else {
  270. if k == "ck_bidamount" || k == "ck_s_winner" {
  271. } else {
  272. if qu.IntAll(v) > 1 {
  273. isT = false
  274. break
  275. }
  276. }
  277. }
  278. }
  279. }
  280. tmpid := u.BsonTOStringId(tmp["_id"])
  281. if isT {
  282. isok1++
  283. u.Ext_Mgo.UpdateById("zktest_marked_source", tmpid, map[string]interface{}{
  284. "$set": map[string]interface{}{
  285. "qua_tag": 1,
  286. },
  287. })
  288. u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{
  289. "$set": map[string]interface{}{
  290. "qua_tag": 1,
  291. },
  292. })
  293. } else {
  294. isok2++
  295. u.Ext_Mgo.UpdateById("zktest_marked_source", tmpid, map[string]interface{}{
  296. "$set": map[string]interface{}{
  297. "qua_tag": 2,
  298. },
  299. })
  300. u.Ext_Mgo.UpdateById("zktest_marked_info", tmpid, map[string]interface{}{
  301. "$set": map[string]interface{}{
  302. "qua_tag": 2,
  303. },
  304. })
  305. }
  306. tmp = make(map[string]interface{})
  307. }
  308. log.Debug("is over ...", total, "~", isok1, "~", isok2)
  309. }