Browse Source

no message

xingzai 1 year ago
parent
commit
247e70f833
2 changed files with 17 additions and 21 deletions
  1. 14 21
      services/activity_task.go
  2. 3 0
      services/task.go

+ 14 - 21
services/activity_task.go

@@ -1,17 +1,16 @@
 package services
 
 import (
+	"context"
 	"crypto/tls"
 	"encoding/json"
-	"io/ioutil"
-	"net/http"
-	"strings"
-
-	//"context"
 	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"io/ioutil"
+	"net/http"
+	"strings"
 	"time"
 )
 
@@ -66,13 +65,13 @@ type VmpRobotMeetingResult struct {
 	VmpRobotMeetinId  int    `json:"id"`
 }
 
-func init() {
-	PushVmpRobotMeeting()
-}
+//func init() {
+//	PushVmpRobotMeeting()
+//}
 
 // 研选活动会前15分钟推送给上海那边的机器人
-// func PushVmpRobotMeeting(cont context.Context) (err error) {
-func PushVmpRobotMeeting() (err error) {
+func PushVmpRobotMeeting(cont context.Context) (err error) {
+	//func PushVmpRobotMeeting() (err error) {
 	defer func() {
 		if err != nil {
 			go utils.SendAlarmMsg("15分钟会议消息提醒失败", 2)
@@ -85,14 +84,14 @@ func PushVmpRobotMeeting() (err error) {
 	var condition string
 	var pars []interface{}
 	endDate := time.Now().Add(+time.Minute * 15).Format(utils.FormatDateTime)
-	condition = ` AND activity_time <= ? AND activity_time >= NOW()  AND  publish_status = 1  AND   chart_permission_id  = ? AND  vmp_robot_meeting_id = 0 AND active_state = 1  AND  mainland_tell != ''  OR activity_id = 4644  `
+	condition = ` AND activity_time <= ? AND activity_time >= NOW()  AND  publish_status = 1  AND   chart_permission_id  = ? AND  vmp_robot_meeting_id = 0 AND active_state = 1  AND  mainland_tell != ''  `
 	pars = append(pars, endDate, utils.CHART_PERMISSION_ID_YANXUAN)
-	listActivity, e := models.GetCygxActivityList(condition, pars, 0, 100)
+	listActivity, e := models.GetCygxActivityList(condition, pars, 0, 10)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetCygxActivityList, Err: " + e.Error())
 		return
 	}
-	fmt.Println(len(listActivity))
+	//fmt.Println(len(listActivity))
 
 	//return
 	if len(listActivity) == 0 {
@@ -124,7 +123,7 @@ func PushVmpRobotMeeting() (err error) {
 			fmt.Println("json.Marshal Err:" + err.Error())
 			return
 		}
-		fmt.Println(item)
+		//fmt.Println(item)
 		//return
 		tr := &http.Transport{
 			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
@@ -143,8 +142,7 @@ func PushVmpRobotMeeting() (err error) {
 			fmt.Println("client.Do Err:" + err.Error())
 			return
 		}
-		fmt.Println("resp")
-		fmt.Println(resp)
+		//fmt.Println(resp)
 		defer resp.Body.Close()
 		body, e := ioutil.ReadAll(resp.Body)
 		if e != nil {
@@ -152,7 +150,6 @@ func PushVmpRobotMeeting() (err error) {
 			err = e
 			return
 		}
-		fmt.Println("body:", string(body))
 		result := new(VmpRobotMeetingDataResult)
 		e = json.Unmarshal(body, &result)
 		if e != nil {
@@ -161,9 +158,6 @@ func PushVmpRobotMeeting() (err error) {
 			return
 		}
 		vmpRobotMeetinId := result.Data.VmpRobotMeetinId
-		fmt.Println("vmpRobotMeetinId", vmpRobotMeetinId)
-		fmt.Println(result)
-		fmt.Println(v.ActivityId)
 		e = models.UpdateActivityVmpRobotMeetingId(vmpRobotMeetinId, v.ActivityId)
 		if e != nil {
 			fmt.Println("UpdateActivityVmpRobotMeetingId  Err:" + err.Error())
@@ -176,7 +170,6 @@ func PushVmpRobotMeeting() (err error) {
 		itemlog.Body = string(jsonBody)
 		itemlog.Result = string(body)
 		go models.AddCygxShanghaiCompanyLog(itemlog)
-
 	}
 
 	return

+ 3 - 0
services/task.go

@@ -43,6 +43,9 @@ func Task() {
 
 		getYiDongActivity := task.NewTask("getYiDongActivity", "0 */10 * * * *", GetYiDongActivity) //同步易董的活动信息
 		task.AddTask("getYiDongActivity", getYiDongActivity)
+
+		pushVmpRobotMeeting := task.NewTask("pushVmpRobotMeeting", "0 */10 6-23 * * *", PushVmpRobotMeeting) //研选活动会前15分钟推送给上海那边的机器人
+		task.AddTask("pushVmpRobotMeeting", pushVmpRobotMeeting)
 	}
 
 	if utils.IsTask {