package main

import (
	//"fmt"
	"log"
	"os"
	"qfw/util"
	"strings"
	"tools"
)

func main() {
	//	sess := tools.Mgo.GetMgoConn()
	//	defer tools.Mgo.DestoryMongoConn(sess)
	//	sess.DB(tools.Mgo.DbName).C
	res, _ := tools.Mgo.Find("rc_rule", `{"s_classid":"592f8c14e13823494a0ef74d"}`, nil, nil, false, -1, -1)
	m := map[string]bool{}
	m2 := map[string]bool{}
	n := 0
	all := 0
	for _, obj := range *res {
		keys := util.ObjArrToStringArr(obj["s_rule"].([]interface{}))
		for _, k := range keys {
			//k := k[1 : len(k)-1]
			k = strings.Replace(strings.Replace(k, "(", "", -1), ")", "", -1)
			ks := strings.Split(k, "|")
			for _, k1 := range ks {
				all++
				if m[k1] {
					n++
					m2[k1] = true
				} else {
					m[k1] = true
				}
			}
		}
	}
	f, _ := os.Create("test.log")

	log.Println("n,len(m2), all, len(m):", n, len(m2), all, len(m))
	//	for k, _ := range m2 {
	//fmt.Println(k)
	//f.WriteString(k + "\n")
	//}
	f.Close()
}
