|
@@ -13,20 +13,21 @@ import (
|
|
|
|
|
|
|
|
|
var (
|
|
|
- Sysconfig map[string]interface{} //配置文件
|
|
|
+ sysconfig map[string]interface{} //配置文件
|
|
|
mgo *MongodbSim //mongodb操作对象
|
|
|
qy_mgo *MongodbSim
|
|
|
udpclient mu.UdpClient //udp对象
|
|
|
nextNode []map[string]interface{} //下节点数组
|
|
|
siteMap map[string]map[string]interface{} //站点map
|
|
|
coll_name,qy_coll_name string
|
|
|
- core_element,other_element []string //要素
|
|
|
- total_score,core_max,core_each,other_max,other_each int
|
|
|
+ core_element,other_element []map[string]interface{} //要素
|
|
|
+ deduct_element []string
|
|
|
+ total_score,core_max,core_each,other_max,other_each ,deduct_each int
|
|
|
)
|
|
|
|
|
|
func initSite() {
|
|
|
//站点配置
|
|
|
- mconf := Sysconfig["mongodb"].(map[string]interface{})
|
|
|
+ mconf := sysconfig["mongodb"].(map[string]interface{})
|
|
|
site := mconf["site"].(map[string]interface{})
|
|
|
siteMap = make(map[string]map[string]interface{}, 0)
|
|
|
start := int(time.Now().Unix())
|
|
@@ -44,7 +45,8 @@ func initSite() {
|
|
|
}
|
|
|
|
|
|
func initMgo() {
|
|
|
- mconf := Sysconfig["mongodb"].(map[string]interface{})
|
|
|
+ mconf := sysconfig["mongodb"].(map[string]interface{})
|
|
|
+ log.Println(mconf)
|
|
|
mgo = &MongodbSim{
|
|
|
MongodbAddr: mconf["addrName"].(string),
|
|
|
DbName: mconf["dbName"].(string),
|
|
@@ -53,7 +55,7 @@ func initMgo() {
|
|
|
mgo.InitPool()
|
|
|
|
|
|
|
|
|
- qy_mconf := Sysconfig["qy_mongodb"].(map[string]interface{})
|
|
|
+ qy_mconf := sysconfig["qy_mongodb"].(map[string]interface{})
|
|
|
qy_mgo = &MongodbSim{
|
|
|
MongodbAddr: qy_mconf["qy_addrName"].(string),
|
|
|
DbName: qy_mconf["qy_dbName"].(string),
|
|
@@ -64,20 +66,23 @@ func initMgo() {
|
|
|
coll_name = mconf["collName"].(string)
|
|
|
qy_coll_name = qy_mconf["qy_collName"].(string)
|
|
|
|
|
|
- core_element = qu.ObjArrToStringArr(Sysconfig["core_element"].([]interface{}))
|
|
|
- other_element = qu.ObjArrToStringArr(Sysconfig["other_element"].([]interface{}))
|
|
|
- score_standard := Sysconfig["score_standard"].(map[string]interface{})
|
|
|
+ core_element = qu.ObjArrToMapArr(sysconfig["core_element"].([]interface{}))
|
|
|
+ other_element = qu.ObjArrToMapArr(sysconfig["other_element"].([]interface{}))
|
|
|
+ deduct_element =qu.ObjArrToStringArr(sysconfig["deduct_element"].([]interface{}))
|
|
|
+
|
|
|
+ score_standard := sysconfig["score_standard"].(map[string]interface{})
|
|
|
total_score = qu.IntAll(score_standard["total_score"])
|
|
|
core_max = qu.IntAll(score_standard["core_max"])
|
|
|
core_each = qu.IntAll(score_standard["core_each"])
|
|
|
other_max = qu.IntAll(score_standard["other_max"])
|
|
|
other_each = qu.IntAll(score_standard["other_each"])
|
|
|
+ deduct_each = qu.IntAll(score_standard["deduct_each"])
|
|
|
}
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
//加载配置文件
|
|
|
- qu.ReadConfig(&Sysconfig)
|
|
|
+ qu.ReadConfig(&sysconfig)
|
|
|
initMgo()
|
|
|
initSite()//加载站点
|
|
|
log.Println("采用udp模式")
|
|
@@ -86,7 +91,7 @@ func init() {
|
|
|
|
|
|
func mainT() {
|
|
|
go checkMapJob()
|
|
|
- updport := Sysconfig["udpport"].(string)
|
|
|
+ updport := sysconfig["udpport"].(string)
|
|
|
udpclient = mu.UdpClient{Local: updport, BufSize: 1024}
|
|
|
udpclient.Listen(processUdpMsg)
|
|
|
log.Println("Udp服务监听", updport)
|
|
@@ -96,8 +101,8 @@ func mainT() {
|
|
|
//快速测试使用
|
|
|
func main() {
|
|
|
|
|
|
- sid := "4f16936d52c1d9fbf843c60e"
|
|
|
- eid := "6f16936d52c1d9fbf843c60e"
|
|
|
+ sid := "1f0000000000000000000000"
|
|
|
+ eid := "9f0000000000000000000000"
|
|
|
log.Println(sid, "---", eid)
|
|
|
mapinfo := map[string]interface{}{}
|
|
|
if sid == "" || eid == "" {
|
|
@@ -157,6 +162,7 @@ func startTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
"$lte": StringTOBsonId(mapInfo["lteid"].(string)),
|
|
|
},
|
|
|
}
|
|
|
+ log.Println("查询条件:",q)
|
|
|
sess := mgo.GetMgoConn()
|
|
|
defer mgo.DestoryMongoConn(sess)
|
|
|
it := sess.DB(mgo.DbName).C(coll_name).Find(&q).Iter()
|
|
@@ -164,12 +170,12 @@ func startTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
index:=0
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
|
if index%10000 == 0 {
|
|
|
- log.Println("current:", index, tmp["_id"])
|
|
|
+ log.Println("当前数量:", index, tmp["_id"])
|
|
|
}
|
|
|
|
|
|
- element_score:=dealWithElementRate(tmp)
|
|
|
- error_score,abnormal_score:=dealWithErrorRate(tmp)
|
|
|
- log.Println("元素分:",element_score,"错误分:",error_score,"异常分:",abnormal_score)
|
|
|
+ element_score,element_reason:=dealWithElementRate(tmp)
|
|
|
+ error_score,abnormal_score,error_reason,abnormal_reason:=dealWithErrorRate(tmp)
|
|
|
+ //log.Println("元素分:",element_score,"错误分:",error_score,"异常分:",abnormal_score)
|
|
|
|
|
|
updateExtract = append(updateExtract, []map[string]interface{}{
|
|
|
map[string]interface{}{
|
|
@@ -180,6 +186,11 @@ func startTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
"element_score": element_score,
|
|
|
"error_score":error_score,
|
|
|
"abnormal_score": abnormal_score,
|
|
|
+ "quality_reason":map[string]interface{}{
|
|
|
+ "element_reason":element_reason,
|
|
|
+ "error_reason":error_reason,
|
|
|
+ "abnormal_reason":abnormal_reason,
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
})
|
|
@@ -196,6 +207,9 @@ func startTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
mgo.UpSertBulk(coll_name, updateExtract...)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ log.Println("task quality over - 总计数量",index)
|
|
|
+
|
|
|
time.Sleep(60 * time.Second)
|
|
|
|
|
|
//任务完成,开始发送广播通知下面节点
|
|
@@ -221,4 +235,7 @@ func startTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|