// 保存投放轨迹到电信ftp func (this *JsPut) saveTraceToDianxin() { var ( ftp = lib.GetConfVal("jiangsu::ftp_path") ppath = lib.GetConfVal("jiangsu::put_path") rk = "account.10046.sha1." + time.Now().Add(-time.Hour).Format("200601021504") fname = ppath + "/" + rk adcount = 0 ) f, err := os.Create(fname) if err != nil { log.Error("创建文件失败", err) return } defer f.Close() this.kf.AdSet(func(ad string) { if v, ok := this.areamap[ad]; ok { f.WriteString(ad + "," + v + "\n") adcount++ } }) cmd := exec.Command(ftp, rk) str, err := cmd.Output() log.Info(string(str), err) // 广告数量统计数据 dx_stats , js_1461016800, 11111 lib.StatisticsData("dx_stats", fmt.Sprintf("js_%s", timestamp.GetHourTimestamp(-1)), convert.ToString(adcount), "") }
// 保存投放轨迹到电信redis func (this *ZjPut) saveTraceToDianxin() { var ( db = lib.GetConfVal("zhejiang::dx_redis_db") pwd = lib.GetConfVal("zhejiang::dx_redis_pwd") adcount = 0 ) rdb, err := lib.GetZJDxRedisObj() if err != nil { log.Error("redis连接失败", err) return } rdb.Auth(pwd) rdb.SelectDb(db) rdb.FlushDb() // ua默认md5加密 go func() { for { rdb.Receive() } }() this.kf.AdUaIdsSet(func(ad string, ua string, ids map[string]int8) { var key = ad + "|" + strings.ToUpper(ua) rdb.Set(key, "1") adcount++ }) rdb.Flush() rdb.Close() // 广告数量统计数据 dx_stats , Zj_1461016800, 11111 lib.StatisticsData("dx_stats", fmt.Sprintf("zj_%s", this.Timestamp), convert.ToString(adcount), "") }
// 初始化cox对应区域 func (this *JsPut) initArea() { this.areamap = make(map[string]string) f, err := os.Open(lib.GetConfVal("jiangsu::areapath")) if err != nil { log.Error(err) return } defer f.Close() bi := bufio.NewReader(f) for { line, err := bi.ReadString('\n') if err == io.EOF { break } //0006f21d119b032d59acc3c2b90f10624eeaebe8,511 info := strings.Split(line, ",") if len(info) != 2 { continue } this.areamap[info[0]] = strings.TrimSpace(info[1]) } log.Info("江苏区域数量", len(this.areamap)) }
// 保存广告对应的ad,ua func (this *ZjPut) saveAdvertSet() { tname := "advert_tj_zj_" + this.Timestamp + "_" fname := lib.GetConfVal("zhejiang::data_path") + tname this.kf.IDAdUaSet(fname, func(info map[string]int) { tm := this.Timestamp for k, v := range info { aid := strings.TrimPrefix(k, tname) // 广告数量统计数据 advert_stats , zj_1461016800_1111, 11111 lib.StatisticsData("advert_stats", fmt.Sprintf("zj_%s_%s", tm, aid), convert.ToString(v), "") } }, false) }
// 初始化需要投放的广告 func (this *JsPut) initPutAdverts() { rdb, err := lib.GetRedisObj() if err != nil { log.Fatal(err) } rdb.SelectDb("0") this.putAdverts = make(map[string]int) alist := rdb.SMembers(lib.GetConfVal("jiangsu::province_prefix")) for _, v := range alist { this.putAdverts[v] = 1 } rdb.Close() }
// 初始化需要投放的广告 func (this *ShPut) initPutAdverts() { rdb, err := lib.GetRedisObj() if err != nil { log.Fatal(err) } rdb.SelectDb("0") this.putAdverts = make(map[string]int) alist := rdb.SMembers(lib.GetConfVal("shanghai::province_prefix")) log.Info(alist) for _, v := range alist { if this.filterPriceAdvert(v) { this.putAdverts[v] = 1 } } rdb.Close() }
// 初始化需要投放的广告 func (this *CookiePut) initPutAdverts() { rdb, err := lib.GetRedisObj() if err != nil { log.Fatal(err) } rdb.SelectDb("0") this.putAdverts = make(map[string]int) for _, v := range strings.Split(lib.GetConfVal("cookie::province_prefix"), ",") { alist := rdb.SMembers(v) for _, v := range alist { this.putAdverts[v] = 1 } } rdb.Close() }