|
@@ -14,6 +14,7 @@ import (
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
"strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -561,34 +562,87 @@ func SendYbVoiceBroadcastToThs(voiceId int) (err error) {
|
|
|
|
|
|
//TshListResult 同花顺返回信息
|
|
|
type TshListResult struct {
|
|
|
- ErrorCode int `json:"error" description:"错误状态码"`
|
|
|
- Message string `json:"message" description:"提示信息"`
|
|
|
+ Error int64 `json:"error"`
|
|
|
+ Message string `json:"message"`
|
|
|
+ Rows TshListRowsResult `json:"rows"`
|
|
|
+}
|
|
|
+
|
|
|
+// TshListRowsResult 同花顺列表数据
|
|
|
+type TshListRowsResult struct {
|
|
|
+ BeginPageIndex int64 `json:"beginPageIndex"`
|
|
|
+ CurrentPage int64 `json:"currentPage"`
|
|
|
+ EndPageIndex int64 `json:"endPageIndex"`
|
|
|
+ HasNext bool `json:"hasNext"`
|
|
|
+ HasPre bool `json:"hasPre"`
|
|
|
+ NextPage int64 `json:"nextPage"`
|
|
|
+ NumPerPage int64 `json:"numPerPage"`
|
|
|
+ PageCount int64 `json:"pageCount"`
|
|
|
+ PrePage int64 `json:"prePage"`
|
|
|
+ RecordList []struct {
|
|
|
+ Ctime int64 `json:"ctime" description:"创建时间"`
|
|
|
+ DataType int64 `json:"dataType" description:"数据类型;1-文章,2-小程序"`
|
|
|
+ Description string `json:"description" description:"描述"`
|
|
|
+ Icon string `json:"icon" description:"图标"`
|
|
|
+ ID int64 `json:"id" description:""`
|
|
|
+ Label string `json:"label" description:"标签"`
|
|
|
+ OrgCode string `json:"orgCode" description:""`
|
|
|
+ PushTime string `json:"pushTime" description:""`
|
|
|
+ Pushed int64 `json:"pushed" description:"已推微信群数量"`
|
|
|
+ QueryRowCount int64 `json:"queryRowCount" description:""`
|
|
|
+ Title string `json:"title" description:"标题"`
|
|
|
+ Total int64 `json:"total" description:"推送微信群总数量"`
|
|
|
+ URL string `json:"url" description:"跳转地址"`
|
|
|
+ } `json:"recordList"`
|
|
|
+ TotalCount int64 `json:"totalCount"`
|
|
|
+}
|
|
|
+
|
|
|
+// CheckThsReportList 定时检测同花顺客群推送状态信息
|
|
|
+func CheckThsReportList(cont context.Context) (err error) {
|
|
|
+ errMsgList := make([]string, 0)
|
|
|
+ defer func() {
|
|
|
+ if len(errMsgList) > 0 {
|
|
|
+ go alarm_msg.SendAlarmMsg("定时检测同花顺客群推送状态: ErrMsg:"+strings.Join(errMsgList, "\n"), 3)
|
|
|
+ //fmt.Println("定时检测同花顺客群推送状态:\n"+strings.Join(errMsgList, "\n"), 3)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ tshListRowsResult, err := thsReportList(`50`)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range tshListRowsResult.RecordList {
|
|
|
+ if v.Pushed == 0 { //一个群都没有推送的情况
|
|
|
+ tmpTime := time.Unix(v.Ctime/1000, 0) //入库时间
|
|
|
+ //超时五分钟还未推送,那么就要去通知了
|
|
|
+ if time.Now().Sub(tmpTime).Minutes() > 5 {
|
|
|
+ errMsg := fmt.Sprintf("报告名称:《%s》超时未推送客群,接口通知同花顺时间:%s;报告跳转地址:%s", v.Title, tmpTime.Format(utils.FormatDateTime), v.URL)
|
|
|
+ errMsgList = append(errMsgList, errMsg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
-// ThsReportList 同花顺列表接口
|
|
|
-func ThsReportList() (err error) {
|
|
|
+// thsReportList 同花顺列表接口
|
|
|
+func thsReportList(numPerPageStr string) (tshListRowsResult TshListRowsResult, err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
//fmt.Println(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "发送消息至同花顺失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "发送消息至同花顺失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
|
- go alarm_msg.SendAlarmMsg("发送消息至同花顺失败 ErrMsg:"+err.Error(), 3)
|
|
|
+ go alarm_msg.SendAlarmMsg("定时获取同花顺列表数据接口失败 ErrMsg:"+err.Error(), 3)
|
|
|
}
|
|
|
}()
|
|
|
- pubKey := utils.THS_PubKey
|
|
|
- //sendUrl := utils.THS_List_Url
|
|
|
- sendUrl := `https://board.10jqka.com.cn/gateway/ps/syncNews/listPage`
|
|
|
- //fmt.Println("sendUrl:", sendUrl)
|
|
|
+ sendUrl := utils.THS_List_Url
|
|
|
+ //sendUrl := `https://board.10jqka.com.cn/gateway/ps/syncNews/listPage`
|
|
|
|
|
|
- pageNumStr := "10"
|
|
|
+ pageNumStr := `1` // 页码;默认1
|
|
|
utils.FileLog.Info(fmt.Sprintf("pageNum:%s", pageNumStr))
|
|
|
- pageNumStr, err = gorsa.PublicEncrypt(pageNumStr, pubKey)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- numPerPageStr := "1" // 页码;默认1
|
|
|
+ //numPerPageStr := "10" // 每页数量;默认10 否
|
|
|
utils.FileLog.Info(fmt.Sprintf("numPerPage:%s", numPerPageStr))
|
|
|
- numPerPageStr, err = gorsa.PublicEncrypt(numPerPageStr, pubKey)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -605,7 +659,7 @@ func ThsReportList() (err error) {
|
|
|
form.Add("pageNum", pageNumStr)
|
|
|
form.Add("numPerPage", numPerPageStr)
|
|
|
|
|
|
- utils.FileLog.Info(fmt.Sprintf("Ths List parms:%s", form.Encode()))
|
|
|
+ //utils.FileLog.Info(fmt.Sprintf("Ths List parms:%s", form.Encode()))
|
|
|
resp, err := client.PostForm(sendUrl, form)
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -618,15 +672,16 @@ func ThsReportList() (err error) {
|
|
|
utils.FileLog.Info(fmt.Sprintf("Ths List Result :%s", string(body)))
|
|
|
|
|
|
//同花顺接口返回数据
|
|
|
- var tshResult TshResult
|
|
|
+ var tshResult TshListResult
|
|
|
err = json.Unmarshal(body, &tshResult)
|
|
|
if err != nil {
|
|
|
err = errors.New(fmt.Sprint("同花顺接口返回数据转换成结构体异常,Err:", err))
|
|
|
return
|
|
|
}
|
|
|
- if tshResult.ErrorCode != 1 {
|
|
|
+ if tshResult.Error != 1 {
|
|
|
err = errors.New(fmt.Sprint("发送数据到同花顺接口异常,result:", string(body)))
|
|
|
return
|
|
|
}
|
|
|
+ tshListRowsResult = tshResult.Rows
|
|
|
return
|
|
|
}
|