Jianghan преди 11 месеца
родител
ревизия
8dcdfefc1b
променени са 4 файла, в които са добавени 52 реда и са изтрити 39 реда
  1. 13 13
      telemarketingEtl/config.yaml
  2. 30 21
      telemarketingEtl/entity/Voiced.go
  3. 9 5
      telemarketingEtl/entity/dwd_f_userbase_visit_info.go
  4. BIN
      telemarketingEtl/telemarketingEtl

+ 13 - 13
telemarketingEtl/config.yaml

@@ -1,47 +1,47 @@
 tidb:
   jianyuSubjectdb:
-    dbName: Jianyu_subjectdb
-    address: 192.168.3.217:4000
+    dbName: jianyu_subjectdb_test
+    address: 192.168.3.149:4000
     userName: root
-    password: '=PDT49#80Z!RVv52_z'
+    password: 'Tibi#20211222'
     maxOpenConns: 80
     maxIdleConns: 5
   callAccount:
     dbName: Call_Accounting
-    address: 192.168.3.217:4000
+    address: 192.168.3.149:4000
     userName: root
-    password: '=PDT49#80Z!RVv52_z'
+    password: 'Tibi#20211222'
     maxOpenConns: 80
     maxIdleConns: 5
 mysql:
   main:
     dbName: jianyu
-    address: 192.168.3.149:3306
+    address: 192.168.3.14:4000
     userName: root
-    password: 'Topnet123'
+    password: '=PDT49#80Z!RVv52_z'
     maxOpenConns: 80
     maxIdleConns: 5
 mongo:
   main:
     dbName: qfw
     size: 50
-    address: 192.168.3.206:27080
+    address: 192.168.3.149:27180
   log:
     dbName: qfw
     size: 50
-    address: 192.168.3.206:27090
+    address: 192.168.3.149:27190
     userName: admin
     password: 123456
   ent:
     dbName: mixdata
     size: 50
-    address: 192.168.3.206:27002
+    address: 192.168.3.149:27102
     collection: qyxy
     collectionChange: qyxy_change
     userName: jyDevGroup
     password: jy@DevGroup
   bidding:
-    address: 192.168.3.206:27002
+    address: 192.168.3.149:27102
     size: 50
     dbName: qfw_data
     collection: bidding
@@ -102,7 +102,7 @@ deleteOpenSeaTask: '0 0 0 * * *'
 #自动退回公海
 returnOpenSeaTask: '0 0 0 * * *'
 #定时任务 近30天最多访问
-countMaxVisitTask: '0 0 * * * *'
+countMaxVisitTask: '0 0 0 * * *'
 #定时任务 最近7天外呼次数
 countCallsTask: '0 0 * * * *'
 #定时任务 最近连续未接听次数
@@ -116,7 +116,7 @@ eventInfoTime: 5
 #搜索
 searchInfoTime: 5
 #每日
-visitInfoTime: 5
+visitInfoTime: 1000
 #定时
 openSeaTime: 5
 #退出

+ 30 - 21
telemarketingEtl/entity/Voiced.go

@@ -5,6 +5,7 @@ import (
 	"app.yhyue.com/moapp/jybase/date"
 	"go.mongodb.org/mongo-driver/bson"
 	"log"
+	"strings"
 	"sync"
 	"telemarketingEtl/config"
 	"time"
@@ -52,15 +53,17 @@ func CountCalled() {
 		uid := userPhone[s]
 		mUser[uid].frequency += 1
 	}
-	log.Println("通话次数匹配结束...")
+	log.Println("CountCalled 通话次数匹配结束...")
 	for k, v := range mUser {
-		if b := config.JianyuSubjectdb.Update("dwd_f_crm_attribute_label", bson.M{"uid": k}, bson.M{"outbound_count": v.frequency}); !b {
-			config.JianyuSubjectdb.Insert("dwd_f_crm_attribute_label", map[string]interface{}{
-				"uid":            k,
-				"members_info":   "昨日未浏览",
-				"updatetime":     time.Now(),
-				"outbound_count": v.frequency,
-			})
+		if v.frequency > 0 {
+			if b := config.JianyuSubjectdb.Update("dwd_f_crm_attribute_label", bson.M{"uid": k}, bson.M{"outbound_count": v.frequency}); !b {
+				config.JianyuSubjectdb.Insert("dwd_f_crm_attribute_label", map[string]interface{}{
+					"uid":            k,
+					"members_info":   "昨日未浏览",
+					"updatetime":     time.Now(),
+					"outbound_count": v.frequency,
+				})
+			}
 		}
 	}
 
@@ -119,19 +122,22 @@ func getUser() {
 
 func getRecord() {
 	var (
-		sql   string
-		count int
-		total int64
+		sql      string
+		countSql string
+		count    int
+		total    int64
 	)
 	if firstLoad {
 		// 当日首次执行	1、全部归0 outbound_count
 		config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_crm_attribute_label SET outbound_count = 0")
 		sql = "SELECT createTime, CallNo, CalledNo FROM voice_record WHERE DATE(createTime) BETWEEN DATE(NOW() - INTERVAL 7 DAY) AND DATE(NOW()) ORDER BY createTime ASC"
+		countSql = "SELECT COUNT(id) FROM voice_record WHERE DATE(createTime) BETWEEN DATE(NOW() - INTERVAL 7 DAY) AND DATE(NOW())"
 	} else {
 		aTime := time.Now().Add(-1 * time.Hour)
-		sql = "SELECT createTime, CallNo, CalledNo FROM voice_record WHERE creatime >= " + aTime.Format(time.DateTime) + " ORDER BY createTime ASC"
+		sql = "SELECT createTime, CallNo, CalledNo FROM voice_record WHERE createTime >= " + aTime.Format(time.DateTime) + " ORDER BY createTime ASC"
+		countSql = "SELECT COUNT(id) FROM voice_record WHERE createTime >= " + aTime.Format(time.DateTime)
 	}
-	total = config.VoicedRecordDb.CountBySql(sql)
+	total = config.VoicedRecordDb.CountBySql(countSql)
 	log.Println("CountCalled getRecord---", total)
 	if total <= 0 {
 		return
@@ -190,18 +196,21 @@ func MissedCalls() {
 
 func getMissedCalls() {
 	var (
-		sql   string
-		count int
-		total int64
+		sql      string
+		countSql string
+		count    int
+		total    int64
 	)
 	if firstLoad1 {
 		sql = "SELECT createTime, CallNo, CalledNo FROM voice_record WHERE State != 'dealing' ORDER BY createTime ASC"
+		countSql = "SELECT COUNT(id) FROM voice_record WHERE State != 'dealing'"
 		firstLoad1 = false
 	} else {
 		aTime := time.Now().Add(-1 * time.Hour)
-		sql = "SELECT createTime, CallNo, CalledNo FROM voice_record WHERE State != 'dealing' AND creatime >= " + aTime.Format(time.DateTime) + " ORDER BY createTime ASC"
+		sql = "SELECT createTime, CallNo, CalledNo FROM voice_record WHERE State != 'dealing' AND createTime >= " + aTime.Format(time.DateTime) + " ORDER BY createTime ASC"
+		countSql = "SELECT COUNT(id) FROM voice_record WHERE State != 'dealing' AND createTime >= " + aTime.Format(time.DateTime)
 	}
-	total = config.VoicedRecordDb.CountBySql(sql)
+	total = config.VoicedRecordDb.CountBySql(countSql)
 	log.Println("MissedCalls getMissedCalls---", total)
 	if total <= 0 {
 		return
@@ -240,15 +249,15 @@ func getMissedCalls() {
 		if missedPhone[uid] != nil {
 			v := missedPhone[uid]
 			if VerifyDate(v.vDate, vdate) <= 1 {
-				v.vDate = vdate
+				v.vDate = strings.Split(vdate, " ")[0]
 				v.missed += 1
 			} else {
 				v.missed = 1
-				v.vDate = vdate
+				v.vDate = strings.Split(vdate, " ")[0]
 			}
 		} else {
 			missedPhone[uid] = &Voiced{
-				vDate:  vdate,
+				vDate:  strings.Split(vdate, " ")[0],
 				missed: 0,
 			}
 		}

+ 9 - 5
telemarketingEtl/entity/dwd_f_userbase_visit_info.go

@@ -74,7 +74,7 @@ func VisitInfoAdd(start, end int64) {
 						userid, uid = GetUserIdByPositionId(userid)
 					} else {
 						idmdata := config.JianyuSubjectdb.SelectBySql(`select uid from dwd_f_userbase_id_mapping where userid = "` + userid + `"`)
-						if idmdata != nil {
+						if idmdata != nil && len(*idmdata) > 0 {
 							uid = gconv.String((*idmdata)[0]["uid"])
 						}
 					}
@@ -125,7 +125,7 @@ func VisitInfoAdd(start, end int64) {
 					} else {
 						config.JianyuSubjectdb.InsertBySql(`INSERT INTO dwd_f_userbase_visit_info
 														(userid,DATE, number, platform,createtime,contentnum,portraitnum,searchnum)
-														VALUES (?,?,?,?,?,?)`, userid, craetetimeStr, 1, platform, craetetimeStr, contentnum, portraitnum, searchnum)
+														VALUES (?,?,?,?,?,?,?,?)`, userid, craetetimeStr, 1, platform, craetetimeStr, contentnum, portraitnum, searchnum)
 					}
 					if uid != "" {
 						if config.JianyuSubjectdb.CountBySql(`select count(1) from dwd_f_crm_attribute_label where uid = ?`, uid) > 0 {
@@ -145,6 +145,7 @@ func VisitInfoAdd(start, end int64) {
 				}
 				thisData = map[string]interface{}{}
 			}
+			log.Printf("%s一共完成%d条数据\n", table, count)
 			log.Println("end!")
 			// sWait.Wait()
 		}(table)
@@ -202,7 +203,7 @@ func CountMaxVisit() {
 		}
 		count++
 		if count%2000 == 0 {
-			log.Println("current-------", count)
+			log.Println("CountMaxVisit current-------", count)
 		}
 		userid := common.ObjToString(ret["userid"])
 		mDate := common.ObjToString(ret["date"])
@@ -243,6 +244,8 @@ func CountMaxVisit() {
 		}
 	}
 
+	// 先 归0
+	config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_crm_attribute_label SET continuous_visit_day = 0 WHERE continuous_visit_day != 0")
 	for _, v := range mData {
 		if b := config.JianyuSubjectdb.Update("dwd_f_crm_attribute_label", bson.M{"uid": v.uId}, bson.M{"continuous_visit_day": v.days}); !b {
 			config.JianyuSubjectdb.Insert("dwd_f_crm_attribute_label", map[string]interface{}{
@@ -259,6 +262,7 @@ func CountMaxVisit() {
 // @Description 日期相差天数
 // @Date 2024/8/22
 func VerifyDate(d1, d2 string) int {
+	log.Println("d1: ", d1, "d2: ", d2)
 	if d1 == d2 {
 		return 0
 	}
@@ -413,7 +417,7 @@ func Count3DaysDetail() {
 func VipExpire() {
 	now := time.Now()
 	config.JianyuSubjectdb.ExecBySql("update dwd_f_crm_attribute_label set supersub = 0 where supersub = 1")
-	config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_data_equity_info SET supersub = 1 WHERE product_type = '超级订阅' AND endtime > ?", now.Format(date.Date_Short_Layout))
+	config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_crm_attribute_label SET supersub = 1 WHERE product_type = '超级订阅' AND endtime > ?", now.Format(date.Date_Short_Layout))
 	config.JianyuSubjectdb.ExecBySql("update dwd_f_crm_attribute_label set areasubpkg = 0 where areasubpkg = 1")
-	config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_data_equity_info SET areasubpkg = 1 WHERE product_type = '省份订阅包' AND endtime > ?", now.Format(date.Date_Short_Layout))
+	config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_crm_attribute_label SET areasubpkg = 1 WHERE product_type = '省份订阅包' AND endtime > ?", now.Format(date.Date_Short_Layout))
 }

BIN
telemarketingEtl/telemarketingEtl