liuxiaolong
2020-08-17 bae4af47f77a195a12a0437584d667465e826e12
controllers/car.go
@@ -42,7 +42,7 @@
               if left <=lowerLimit && left != prePushLeft {
                  go func() {
                     message := fmt.Sprintf("%s 剩余车位:%d个", time.Now().Format("2006-01-02 15:04:05"), left)
                     b, e := service.PushByAlias("育英智慧停车", message)
                     b, e := service.PushByAlias("育英中学停车", message)
                     prePushLeft = left
@@ -53,7 +53,7 @@
            }
            //判断当前是否在22:00-22:30之间
            now := time.Now()
            if now.Hour() == 21 && now.Minute()>=0 && now.Minute() <=29{
            if now.Hour() == 22 && now.Minute()>=0 && now.Minute() <=30{
               if now.Minute() == 0 {
                  if nightPushTimes ==0 {
                     go nightPush()
@@ -69,7 +69,7 @@
                     go nightPush()
                     nightPushTimes++
                  }
               } else if now.Minute() == 29 {
               } else if now.Minute() == 30 {
                  if nightPushTimes == 3{
                     go nightPush()
                     nightPushTimes++
@@ -88,7 +88,7 @@
func nightPush(){
   message := fmt.Sprintf("%s 请尽快驶出停车场", time.Now().Format("2006-01-02 15:04:05"))
   b, e := service.NightPush("育英智慧停车", message)
   b, e := service.NightPush("育英中学停车", message)
   fmt.Println("b:", b,"e:",e, "message:", message)
@@ -160,6 +160,27 @@
   c.ServeJSON()
}
// @router /testPush [get]
func (c *CarController) TestPush() {
   left := getSpaceLeft()
   message := fmt.Sprintf("%s 剩余车位:%d个", time.Now().Format("2006-01-02 15:04:05"), left)
   b, e := service.PushByAlias("育英中学停车", message)
   fmt.Println("b:", b,"e:",e, "message:", message)
   resp := code.Code{}
   if b {
      resp.Success = true
      resp.Status = http.StatusOK
      resp.Data = "推送成功"
   } else {
      resp.Success = false
      resp.Status = http.StatusInternalServerError
      resp.Data = e.Error()
   }
   c.Data["json"] = resp
   c.ServeJSON()
}
// @router /crossRecord [get]
func (c *CarController) CrossRecord() {
   sv := service.NewCarService()