From bf4ca3fdb8c0f0c1f99a4a871ad39436cefc6ab6 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期六, 10 十月 2020 19:37:05 +0800 Subject: [PATCH] 在地图上不显示vip车辆 --- controllers/car.go | 101 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 90 insertions(+), 11 deletions(-) diff --git a/controllers/car.go b/controllers/car.go index f576697..9cccaff 100644 --- a/controllers/car.go +++ b/controllers/car.go @@ -25,7 +25,7 @@ //3.鏅氫笂10鐐瑰埌10鐐瑰崐锛屾瘡闂撮殧10鍒嗛挓锛岀粰鍋滆溅鍦哄唴鐨勮溅杈嗘帹閫佹秷鎭細璇峰敖蹇┒鍑哄仠杞﹀満 func ComputeSpaceLeftRealTime() { ticker := time.NewTicker(3 * time.Second) - prePushLeft := 0 + prePushLeft, _ := beego.AppConfig.Int("initPushLeft") //鍒濆鍓╀綑鏁伴噺锛屼笂绾垮悗涓嶈兘姣忔鍚姩閮芥帹閫佹秷鎭� sv := service.NewCarService() initCacheM := false lowerLimit,_ := beego.AppConfig.Int("pushLowerLimit") //[0,5] @@ -45,7 +45,7 @@ go func() { t := time.Now().Format("2006-01-02 15:04:05") message := fmt.Sprintf("%s 鍓╀綑杞︿綅锛�%d涓�", t, left) - b, e, aliasArr := service.PushByAlias("鑲茶嫳涓鍋滆溅", message) + b, e, aliasArr := service.PushByAlias("鍓╀綑杞︿綅鎻愰啋", message, false) //璁板綍鎺ㄩ�佹棩蹇� logE := models.Log{ Id: uuid.NewV4().String(), @@ -71,22 +71,22 @@ if now.Hour() == 22 && now.Minute()>=0 && now.Minute() <=30{ if now.Minute() == 0 { if nightPushTimes ==0 { - go nightPush() + go nightPush(nightPushTimes) nightPushTimes++ } } else if now.Minute() == 10 { if nightPushTimes == 1 { - go nightPush() + go nightPush(nightPushTimes) nightPushTimes++ } } else if now.Minute() == 20 { if nightPushTimes == 2{ - go nightPush() + go nightPush(nightPushTimes) nightPushTimes++ } } else if now.Minute() == 30 { if nightPushTimes == 3{ - go nightPush() + go nightPush(nightPushTimes) nightPushTimes++ } } @@ -100,10 +100,10 @@ } } -func nightPush(){ +func nightPush(curTimes int){ message := fmt.Sprintf("%s 璇峰敖蹇┒鍑哄仠杞﹀満", time.Now().Format("2006-01-02 15:04:05")) - b, e, aliasArr := service.NightPush("鑲茶嫳涓鍋滆溅", message) + b, e, aliasArr,carOwnNames := service.NightPush("娓╅Θ鎻愮ず", message) //璁板綍鎺ㄩ�佹棩蹇� logE := models.Log{ Id: uuid.NewV4().String(), @@ -118,6 +118,28 @@ } logE.Insert() fmt.Println("b:", b,"e:",e, "message:", message) + + if curTimes == 3 { //鍙粰绠$悊鍛樻帹閫佷竴娆¤繖涓秷鎭� + //灏嗗叿浣撶殑杞︿富淇℃伅鎺ㄩ�佺粰绠$悊鍛� + if carOwnNames != nil && len(carOwnNames) >0 { + //鑾峰彇杞︿富濮撳悕 + managerMsg := strings.Join(carOwnNames, ",") + mb,me, managerArr := service.Push2Manager(fmt.Sprintf("%s 鏈┒绂昏溅杈�", time.Now().Format("2006-01-02 15:04:05")), managerMsg, false) + mLogE := models.Log{ + Id: uuid.NewV4().String(), + CreateTime: time.Now().Format("2006-01-02 15:04:05"), + Result: mb, + Phones: strings.Join(managerArr, ","), + } + if me != nil { + mLogE.Content = me.Error() + } else { + mLogE.Content = managerMsg + } + mLogE.Insert() + fmt.Println("mb:", mb, "me:", me, "message:", managerMsg) + } + } } @@ -191,7 +213,7 @@ func (c *CarController) TestPush() { left := getSpaceLeft() message := fmt.Sprintf("%s 鍓╀綑杞︿綅锛�%d涓�", time.Now().Format("2006-01-02 15:04:05"), left) - b, e, aliasArr := service.PushByAlias("鑲茶嫳涓鍋滆溅", message) + b, e, aliasArr := service.PushByAlias("鍓╀綑杞︿綅鎻愰啋", message, true) //璁板綍鎺ㄩ�佹棩蹇� logE := models.Log{ Id: uuid.NewV4().String(), @@ -221,14 +243,67 @@ c.ServeJSON() } +// @router /testNightPush [get] +func (c *CarController) TestNightPush() { + carOwnNames := service.GetLeftCarOwners() + + //灏嗗叿浣撶殑杞︿富淇℃伅鎺ㄩ�佺粰绠$悊鍛� + if carOwnNames != nil && len(carOwnNames) >0 { + //鑾峰彇杞︿富濮撳悕 + managerMsg := strings.Join(carOwnNames, ",") + mb,me, managerArr := service.Push2Manager(fmt.Sprintf("%s 鏈┒绂昏溅杈�", time.Now().Format("2006-01-02 15:04:05")), managerMsg, true) + mLogE := models.Log{ + Id: uuid.NewV4().String(), + CreateTime: time.Now().Format("2006-01-02 15:04:05"), + Result: mb, + Phones: strings.Join(managerArr, ","), + } + if me != nil { + mLogE.Content = me.Error() + } else { + mLogE.Content = managerMsg + } + mLogE.Insert() + fmt.Println("mb:", mb, "me:", me, "message:", managerMsg) + + c.Data["json"] = code.Code{ + Success: true, + Status: http.StatusOK, + Message: "鎺ㄩ�佸畬鎴�", + Data: managerMsg, + } + } else { + c.Data["json"] = code.Code{ + Success: true, + Status: http.StatusOK, + Message: "鏃犻渶鎺ㄩ�侊紝褰撳墠鍋滅暀杞﹁締淇℃伅涓虹┖", + } + } + + c.ServeJSON() +} // @router /spaceInfo [get] func (c *CarController) SpaceInfo() { + userId := c.GetString("userId") sv := service.NewCarService() - spaceInfo := sv.FindHikSpaceInfo() + spaceInfo := sv.FindHikSpaceInfo(userId) c.Data["json"] = code.Code{ Success: true, Status: http.StatusOK, Data: spaceInfo, + } + c.ServeJSON() +} + +// @router /spaceUser [get] +func (c *CarController) SpaceUser() { + userId := c.GetString("userId") + sv := service.NewCarService() + spaceUser := sv.FindHikSpaceUser(userId) + c.Data["json"] = code.Code{ + Success: true, + Status: http.StatusOK, + Data: spaceUser, } c.ServeJSON() } @@ -253,12 +328,16 @@ } var l models.Log total, logs := l.Find(curPage, pageSize, st, et) + var rl []models.Log + for _,le := range logs { + rl = append(rl, *le) + } resp := code.Code{ Success: true, Status: http.StatusOK, Data: map[string]interface{}{ "total": total, - "list": logs, + "list": rl, }, } c.Data["json"] = resp -- Gitblit v1.8.0