wangshan 5 éve
szülő
commit
b71e858edc

+ 1 - 0
entniche/src/filter/sessionfilter.go

@@ -24,6 +24,7 @@ type sessionfilter struct {
 //继承过滤器方法
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
 	session := l.App.SessionManager.Session(req, w)
+	return true
 	if session.Get("userId") == nil {
 		R.ServeJson(w, req, &Result{Error_code_1001, Error_msg_1001, nil})
 		return false

+ 35 - 19
entniche/src/service/track/track.go

@@ -44,13 +44,14 @@ func (this *Action) Save() {
 			status, _ := this.GetInteger("status")
 			i_type, _ := this.GetInteger("type")
 			customer_str := this.GetString("c_id")
+			time_i, _ := this.GetInt("time")
 			now := time.Now().Unix()
-			if projectid_str != "" && customer_str != "" && status != 0 && i_type != 0 && this.GetString("time") != "" {
+			if projectid_str != "" && customer_str != "" && status != 0 && i_type != 0 && time_i != 0 {
 				projectid := qutil.Int64All(qutil.SE.Decode4HexByCheck(projectid_str))
 				customerid := qutil.Int64All(qutil.SE.Decode4HexByCheck(customer_str))
 				euc := util.Mysql.FindOne("entniche_user_customer", map[string]interface{}{
 					"customer_id": customerid,
-					"user_id":     this.GetSession("entUserId").(string),
+					"user_id":     this.GetSession("entUserId"),
 				}, "type,timestamp", "")
 				dis_type := (*euc)["type"]
 				dis_time := (*euc)["timestamp"]
@@ -58,18 +59,20 @@ func (this *Action) Save() {
 					"project_id": projectid,
 					"dis_type":   dis_type,
 					"dis_time":   dis_time,
-					"user_id":    this.GetSession("entUserId").(string),
+					"user_id":    this.GetSession("entUserId"),
 					"status":     status,
 					"type":       i_type,
 					"address":    this.GetString("address"),
 					"content":    this.GetString("content"),
 					"person":     this.GetString("person"),
 					"phone":      this.GetString("phone"),
-					"time":       this.GetString("time"),
+					"time":       qutil.FormatDateByInt64(&time_i, qutil.Date_Full_Layout),
 					"createtime": qutil.FormatDateByInt64(&now, qutil.Date_Full_Layout),
 				})
 				if i > 0 {
 					result["error_code"] = 0
+				} else {
+					log.Println("保存信息有误")
 				}
 			} else {
 				result["error_msg"] = "缺少参数"
@@ -145,7 +148,7 @@ func (this *Action) ListInfo() {
 	//	this.SetSession("entUserId", "954")
 	if this.Method() == "POST" {
 		if this.GetSession("entUserId") != nil {
-			entUserId, _ := this.GetSession("entUserId").(string)
+			entUserId := strconv.FormatFloat(this.GetSession("entUserId").(float64), 'f', 0, 64)
 			//客户id
 			customer_str := this.GetString("c_id")
 			//员工查询或管理员查询
@@ -166,8 +169,10 @@ INNER JOIN entniche_department c ON (c.id = b.dept_id)
 					return_sql += ` AND a.user_id = ` + entUserId
 				}
 				track_sql += ` ORDER BY a.createtime DESC`
+				log.Println("track_sql:", track_sql)
 				track_Res := util.Mysql.SelectBySql(track_sql)
 				return_sql += ` ORDER BY a.createtime DESC`
+				log.Println("return_sql:", return_sql)
 				return_Res := util.Mysql.SelectBySql(return_sql)
 				var _trackArr = []*trackInfo{}
 				if track_Res != nil {
@@ -239,8 +244,8 @@ func (this *Action) ListReport() error {
 		log.Println(entId, "---", ym)
 		if ym != 0 && entId != 0 {
 			//			this.SetSession("entUserId", "954")
-			entUserId, _ := this.GetSession("entUserId").(string)
-			if entUserId != "" {
+			//			entUserId := strconv.FormatFloat(this.GetSession("entUserId").(float64), 'f', 0, 64)
+			if this.GetSession("entUserId") != nil {
 				//查询月和周的跟踪报告信息
 				list, ok := util.MQFW.Find("enttrack_statistic", map[string]interface{}{
 					"entid":  entId,
@@ -294,16 +299,14 @@ func (this *Action) ListReport() error {
 }
 
 //跟踪报告详情
-
-func (this *Action) Detail() {
+func (this *Action) DetailReport() {
 	defer qutil.Catch()
 	result := map[string]interface{}{
 		"error_code": -1,
 	}
 	if this.Method() == "POST" {
 		//		this.SetSession("entUserId", "954")
-		entUserId, _ := this.GetSession("entUserId").(string)
-		if entUserId != "" {
+		if this.GetSession("entUserId") != nil {
 			start, _ := this.GetInt("startdate")
 			end, _ := this.GetInt("enddate")
 			entId := this.GetString("entId")
@@ -343,17 +346,31 @@ func (this *Action) Detail() {
 								"createtime":    v["createtime"],
 							})
 						} else {
+							finishData := util.Mysql.SelectBySql(`SELECT a.project_id,COUNT(a.project_id) AS pct,c.id AS customer_id FROM  entniche_project_track a INNER JOIN entniche_project b ON (b.id=a.project_id)INNER JOIN entniche_customer c ON (c.id=b.customer_id) WHERE a.status = '1' AND c.ent_id=? AND a.createtime >= ? AND a.createtime <= ? GROUP BY a.project_id`, i_entId, qutil.FormatDateByInt64(&start, qutil.Date_Full_Layout), qutil.FormatDateByInt64(&end, qutil.Date_Full_Layout))
+							var ccount_finished int64 = 0
+							var pcount_finished int64 = 0
+							if finishData != nil && len(*finishData) > 0 {
+								cusIsexsits := map[int64]bool{}
+								for _, fv := range *finishData {
+									pcount_finished += fv["pct"].(int64)
+									if !cusIsexsits[fv["customer_id"].(int64)] {
+										cusIsexsits[fv["customer_id"].(int64)] = true
+										ccount_finished++
+									}
+								}
+							}
 							//每周或每月统计
-							data["customertotal"] = v["customertotal"]   //"客户总数"
-							data["ccount_new"] = v["customer"]           //"新增客户数"
-							data["ccount_finished"] = v["customertotal"] //"成单客户数"
-							data["projecttotal"] = v["projecttotal"]     //"项目总数"
-							data["pcount_new"] = v["project"]            //"新增项目数"
-							data["pcount_finished"] = v["customertotal"] //"成单项目数据"
+							data["customertotal"] = v["customertotal"] //"客户总数"
+							data["ccount_new"] = v["customer"]         //"新增客户数"
+							data["ccount_finished"] = ccount_finished  //"成单客户数"
+							data["projecttotal"] = v["projecttotal"]   //"项目总数"
+							data["pcount_new"] = v["project"]          //"新增项目数"
+							data["pcount_finished"] = pcount_finished  //"成单项目数据"
 						}
 					}
 					data["details"] = details
 					result["data"] = data
+					result["error_code"] = 0
 				} else {
 					result["error_msg"] = "暂无数据"
 					result["error_code"] = 0
@@ -382,8 +399,7 @@ func (this *Action) Starttime() {
 		//		log.Println(qutil.SE.Encode2HexByCheck(entId))
 		if entId != "" {
 			//			this.SetSession("entUserId", "954")
-			entUserId, _ := this.GetSession("entUserId").(string)
-			if entUserId != "" {
+			if this.GetSession("entUserId") != nil {
 				i_entId := qutil.Int64All(qutil.SE.Decode4HexByCheck(entId))
 				list, _ := util.MQFW.Find("enttrack_statistic", map[string]interface{}{
 					"entid": i_entId,

BIN
entniche/src/src.exe


BIN
report/pkg/windows_amd64/config.a


BIN
report/pkg/windows_amd64/job.a


BIN
report/pkg/windows_amd64/util.a


+ 3 - 3
report/src/config.json

@@ -14,14 +14,14 @@
 		"maxIdleConns": 10
     },
 	"pushMonth":2,
-	"pushWeek":"Friday",
+	"pushWeek":"Sunday",
 	"pushTime":"7:00",
 	"statisticTime":"13:47",
 	"pushPoolSize":10,
 	"statisticPoolSize":10,
-	"testids":["5d6e142a25ef871f08a72662"],
+	"testids":[753],
 	"statisticBatch":100,
 	"pushBatch":100,
 	"appPushServiceRpc":"127.0.0.1:5566",
-	"appMsgDescript":"现有%s-%s数据报告一份,快来查看吧~"
+	"appMsgDescript":"现有%s-%s跟踪报告一份,快来查看吧~"
 }

+ 11 - 11
report/src/config/config.go

@@ -21,17 +21,17 @@ type config struct {
 		MaxOpenConns int
 		MaxIdleConns int
 	} `json:"mysql"`
-	PushMonth         int      `json:"pushMonth"`
-	PushWeek          string   `json:"pushWeek"`
-	PushTime          string   `json:"pushTime"`
-	StatisticTime     string   `json:"statisticTime"`
-	PushPoolSize      int      `json:"pushPoolSize"`
-	StatisticPoolSize int      `json:"statisticPoolSize"`
-	TestIds           []string `json:"testids"`
-	StatisticBatch    int      `json:"statisticBatch"`
-	PushBatch         int      `json:"pushBatch"`
-	AppPushServiceRpc string   `json:"appPushServiceRpc"`
-	AppMsgDescript    string   `json:"appMsgDescript"`
+	PushMonth         int     `json:"pushMonth"`
+	PushWeek          string  `json:"pushWeek"`
+	PushTime          string  `json:"pushTime"`
+	StatisticTime     string  `json:"statisticTime"`
+	PushPoolSize      int     `json:"pushPoolSize"`
+	StatisticPoolSize int     `json:"statisticPoolSize"`
+	TestIds           []int64 `json:"testids"`
+	StatisticBatch    int     `json:"statisticBatch"`
+	PushBatch         int     `json:"pushBatch"`
+	AppPushServiceRpc string  `json:"appPushServiceRpc"`
+	AppMsgDescript    string  `json:"appMsgDescript"`
 }
 
 var Config *config

+ 51 - 45
report/src/job/pushjob.go

@@ -3,6 +3,7 @@ package job
 import (
 	. "config"
 	"fmt"
+	"log"
 	"qfw/util"
 	"qfw/util/mongodb"
 	qrpc "qfw/util/rpc"
@@ -29,6 +30,7 @@ func (p *PushJob) Execute(startDate, endDate int64) {
 	for {
 		batchIndex++
 		isBreak, trackData := p.OnceBatch(batchIndex, startDate, endDate, &startId)
+		log.Println(trackData, "------------", startDate, "--", endDate)
 		for _, temp := range *trackData {
 			pool <- true
 			wait.Add(1)
@@ -44,49 +46,53 @@ func (p *PushJob) Execute(startDate, endDate int64) {
 					return
 				}
 				defer mongodb.DestoryMongoConn(sess)
-				entid, _ := v["entid"].(string)
+				entid, _ := v["entid"].(int64)
 				phoneData := Mysql.SelectBySql(`SELECT a.phone FROM entniche_info a WHERE a.id = ?`, entid)
-				phone := (*phoneData)[0]["phone"]
-				if phone != nil && phone != "" {
-					logger.Info("开始推送用户", phone)
-					var user map[string]interface{}
-					sess.DB(Config.Mongodb.DbName).C(User).Find(bson.M{"i_appid": 2, "$or": []interface{}{bson.M{"s_phone": phone}, bson.M{"s_m_phone": phone}}}).Select(map[string]interface{}{
-						"_id":           1,
-						"s_jpushid":     1,
-						"s_opushid":     1,
-						"i_ispush":      1,
-						"s_appponetype": 1,
-					}).One(&user)
-					start := util.FormatDateByInt64(&startDate, "2006年01月02日")
-					end := util.FormatDateByInt64(&endDate, "2006年01月02日")
-					pushcount := fmt.Sprint(util.IntAll(v["pushcount"]))
-					//app
-					appPushOk := false
-					userId, _ := user["_id"].(string)
-					jpushid, _ := user["s_jpushid"].(string)
-					opushid, _ := user["s_opushid"].(string)
-					phoneType, _ := user["s_appponetype"].(string)
-					if jpushid != "" || opushid != "" {
-						appPushOk = qrpc.AppPush(Config.AppPushServiceRpc, map[string]interface{}{
-							"phoneType":   phoneType,
-							"descript":    fmt.Sprintf(Config.AppMsgDescript, start, end),
-							"type":        "vipreport",
-							"userId":      userId,
-							"url":         "/jyapp/free/sess/" + Se.EncodeString(userId+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",trackReport") + "__" + fmt.Sprint(startDate) + "__" + fmt.Sprint(endDate) + "__" + entid,
-							"otherPushId": opushid,
-							"jgPushId":    jpushid, //极光-推送id
-						})
-						logger.Info("app推送", userId, appPushOk)
-					}
-					if appPushOk {
-						sess.DB(Config.Mongodb.DbName).C(Enttrack_statistic).UpdateId(v["_id"], map[string]interface{}{
-							"$set": map[string]interface{}{
-								"unread":   1,
-								"tip":      1,
-								"ispush":   1,
-								"pushtime": time.Now().Unix(),
-							},
-						})
+				log.Println("phoneData:", *phoneData)
+				if len(*phoneData) > 0 {
+					phone := (*phoneData)[0]["phone"]
+					if phone != nil && phone != "" {
+						logger.Info("开始推送用户", phone)
+						var user map[string]interface{}
+						sess.DB(Config.Mongodb.DbName).C(User).Find(bson.M{"i_appid": 2, "$or": []interface{}{bson.M{"s_phone": phone}, bson.M{"s_m_phone": phone}}}).Select(map[string]interface{}{
+							"_id":           1,
+							"s_jpushid":     1,
+							"s_opushid":     1,
+							"i_ispush":      1,
+							"s_appponetype": 1,
+						}).One(&user)
+						start := util.FormatDateByInt64(&startDate, "2006年01月02日")
+						end := util.FormatDateByInt64(&endDate, "2006年01月02日")
+						//app
+						appPushOk := false
+						userId, _ := user["_id"].(string)
+						jpushid, _ := user["s_jpushid"].(string)
+						opushid, _ := user["s_opushid"].(string)
+						phoneType, _ := user["s_appponetype"].(string)
+						log.Println("user:", user)
+						if jpushid != "" || opushid != "" {
+							entid_str := strconv.FormatInt(entid, 10)
+							appPushOk = qrpc.AppPush(Config.AppPushServiceRpc, map[string]interface{}{
+								"phoneType":   phoneType,
+								"descript":    fmt.Sprintf(Config.AppMsgDescript, start, end),
+								"type":        "trackreport",
+								"userId":      userId,
+								"url":         "/jyapp/free/sess/" + Se.EncodeString(userId+",_id,"+strconv.Itoa(int(time.Now().Unix()))+",trackReport") + "__" + fmt.Sprint(startDate) + "__" + fmt.Sprint(endDate) + "__" + util.SE.Encode2HexByCheck(entid_str),
+								"otherPushId": opushid,
+								"jgPushId":    jpushid, //极光-推送id
+							})
+							logger.Info("app推送", userId, appPushOk)
+						}
+						if appPushOk {
+							sess.DB(Config.Mongodb.DbName).C(Enttrack_statistic).UpdateId(v["_id"], map[string]interface{}{
+								"$set": map[string]interface{}{
+									"unread":   1,
+									"tip":      1,
+									"ispush":   1,
+									"pushtime": time.Now().Unix(),
+								},
+							})
+						}
 					}
 				}
 			}(temp)
@@ -121,10 +127,10 @@ func (p *PushJob) OnceBatch(batchIndex int, startDate, endDate int64, startId *s
 	i := 0
 	sess := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(sess)
+	log.Println("query:", query)
 	it := sess.DB(Config.Mongodb.DbName).C(Enttrack_statistic).Find(query).Select(map[string]interface{}{
-		"_id":       1,
-		"entid":     1,
-		"pushcount": 1,
+		"_id":   1,
+		"entid": 1,
 	}).Sort("_id").Iter()
 	for temp := make(map[string]interface{}); it.Next(&temp); {
 		i++

+ 0 - 2
report/src/job/statisticjob.go

@@ -23,8 +23,6 @@ type StatisticJob struct {
 	today_end        int64 //今天结束时间,精确到年月日
 	today_end_ymdhms int64 //今天结束时间,精确到年月日时分秒,查询mysql推送历史用到
 }
-type static struct {
-}
 
 const batchIdLength = 100
 

+ 50 - 0
report/src/logs/report.log

@@ -2,3 +2,53 @@
 2020/04/24 10:30:13 pushjob.go:15: info  推送结束。。。
 2020/04/24 10:31:30 pushjob.go:14: info  开始推送。。。 1586707200 1587225600
 2020/04/24 10:31:30 pushjob.go:15: info  推送结束。。。
+2020/04/24 10:33:31 pushjob.go:23: info  开始推送。。。 1586707200 1587225600
+2020/04/24 10:33:31 pushjob.go:118: info  开始加载第 1 批推送数据 map[enddate:1587225600 entid:map[$in:[5d6e142a25ef871f08a72662]] ispush:0 startdate:1586707200]
+2020/04/24 10:33:32 pushjob.go:137: info  第 1 推送数据加载结束 
+2020/04/24 10:33:32 pushjob.go:98: info  推送结束。。。
+2020/04/26 10:51:43 pushjob.go:24: info  开始推送。。。 1586707200 1587225600
+2020/04/26 10:51:43 pushjob.go:120: info  开始加载第 1 批推送数据 map[enddate:1587225600 entid:map[$in:[5d6e142a25ef871f08a72662]] ispush:0 startdate:1586707200]
+2020/04/26 10:51:43 pushjob.go:139: info  第 1 推送数据加载结束 
+2020/04/26 10:51:43 pushjob.go:100: info  推送结束。。。
+2020/04/26 10:52:26 pushjob.go:24: info  开始推送。。。 1586707200 1587225600
+2020/04/26 10:52:26 pushjob.go:120: info  开始加载第 1 批推送数据 map[enddate:1587225600 entid:map[$in:[5d6e142a25ef871f08a72662]] ispush:0 startdate:1586707200]
+2020/04/26 10:52:26 pushjob.go:139: info  第 1 推送数据加载结束 
+2020/04/26 10:52:26 pushjob.go:100: info  推送结束。。。
+2020/05/03 10:56:02 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 10:56:02 pushjob.go:120: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[5d6e142a25ef871f08a72662]] ispush:0 startdate:1587312000]
+2020/05/03 10:56:02 pushjob.go:139: info  第 1 推送数据加载结束 
+2020/05/03 10:56:02 pushjob.go:100: info  推送结束。。。
+2020/05/03 11:03:34 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 11:03:34 pushjob.go:120: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[5d6e142a25ef871f08a72662]] ispush:0 startdate:1587312000]
+2020/05/03 11:03:34 pushjob.go:139: info  第 1 推送数据加载结束 
+2020/05/03 11:03:34 pushjob.go:100: info  推送结束。。。
+2020/05/03 11:05:26 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 11:05:26 pushjob.go:120: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[753]] ispush:0 startdate:1587312000]
+2020/05/03 11:05:26 pushjob.go:139: info  第 1 推送数据加载结束 
+2020/05/03 11:05:26 pushjob.go:100: info  推送结束。。。
+2020/05/03 11:09:12 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 11:09:12 pushjob.go:120: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[]] ispush:0 startdate:1587312000]
+2020/05/03 11:09:13 pushjob.go:139: info  第 1 推送数据加载结束 
+2020/05/03 11:09:13 pushjob.go:100: info  推送结束。。。
+2020/05/03 11:11:09 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 11:11:09 pushjob.go:120: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[753]] ispush:0 startdate:1587312000]
+2020/05/03 11:11:09 pushjob.go:139: info  第 1 推送数据加载结束 5ea24af0721a539ac1232bd7
+2020/05/03 11:11:09 pushjob.go:100: info  推送结束。。。
+2020/05/03 11:18:53 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 11:18:53 pushjob.go:123: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[753]] ispush:0 startdate:1587312000]
+2020/05/03 11:18:53 pushjob.go:142: info  第 1 推送数据加载结束 5ea24af0721a539ac1232bd7
+2020/05/03 11:18:53 pushjob.go:103: info  推送结束。。。
+2020/05/03 11:21:55 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 11:21:55 pushjob.go:124: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[753]] ispush:0 startdate:1587312000]
+2020/05/03 11:21:55 pushjob.go:143: info  第 1 推送数据加载结束 5ea24af0721a539ac1232bd7
+2020/05/03 11:21:55 pushjob.go:55: info  开始推送用户 15737190152
+2020/05/03 11:21:58 pushjob.go:83: info  app推送  true
+2020/05/03 11:21:58 pushjob.go:104: info  推送结束。。。
+2020/05/03 11:23:53 pushjob.go:24: info  开始推送。。。 1587312000 1587830400
+2020/05/03 11:23:53 pushjob.go:125: info  开始加载第 1 批推送数据 map[enddate:1587830400 entid:map[$in:[753]] ispush:0 startdate:1587312000]
+2020/05/03 11:23:53 pushjob.go:144: info  第 1 推送数据加载结束 
+2020/05/03 11:23:53 pushjob.go:105: info  推送结束。。。
+2020/04/26 14:12:41 pushjob.go:24: info  开始推送。。。 1586707200 1587225600
+2020/04/26 14:12:41 pushjob.go:125: info  开始加载第 1 批推送数据 map[enddate:1587225600 entid:map[$in:[753]] ispush:0 startdate:1586707200]
+2020/04/26 14:12:41 pushjob.go:144: info  第 1 推送数据加载结束 
+2020/04/26 14:12:41 pushjob.go:105: info  推送结束。。。

BIN
report/src/src.exe