浏览代码

Merge branch 'ths/list' into debug

# Conflicts:
#	models/wx_template_msg.go
Roc 2 年之前
父节点
当前提交
39e28d64a7
共有 6 个文件被更改,包括 117 次插入57 次删除
  1. 7 0
      models/wx_template_msg.go
  2. 6 3
      services/data/edb_info_notice.go
  3. 76 5
      services/report_push.go
  4. 8 0
      services/save_log.go
  5. 17 49
      services/task.go
  6. 3 0
      utils/config.go

+ 7 - 0
models/wx_template_msg.go

@@ -48,3 +48,10 @@ func GetOpenIdListV2() (items []*OpenIdList, err error) {
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
 }
+
+func DeleteTemplateRecordByDate(date string) (err error) {
+	sql := `DELETE FROM user_template_record WHERE create_time<? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, date).Exec()
+	return
+}

+ 6 - 3
services/data/edb_info_notice.go

@@ -19,6 +19,9 @@ func RefreshNotice() (err error) {
 	var condition string
 	var pars []interface{}
 
+	endDate := time.Now().AddDate(0, -6, 0)
+	condition += ` AND end_date > ? `
+	pars = append(pars, endDate)
 	items, err := data_manage.GetEdbInfoByCondition(condition, pars, 1)
 	if err != nil {
 		return errors.New("GetEdbInfoByCondition:" + err.Error())
@@ -148,9 +151,9 @@ func getTableTr(item *data_manage.EdbInfoList, tableType int) string {
 			if tableType != 4 {
 				//获取依赖指标
 				mapList, _ := data_manage.GetEdbInfoCalculateMap(item.EdbInfoId, item.Source)
-				mapStr:=""
-				for _,v:=range mapList{
-					mapStr+="<p>指标编码:"+v.FromEdbCode+" 来源:"+v.FromSourceName+" 更新日期:"+v.EndDate+"</p>"
+				mapStr := ""
+				for _, v := range mapList {
+					mapStr += "<p>指标编码:" + v.FromEdbCode + " 来源:" + v.FromSourceName + " 更新日期:" + v.EndDate + "</p>"
 				}
 				trHtml += `<td>` + mapStr + `</td>`
 			}

+ 76 - 5
services/report_push.go

@@ -527,9 +527,9 @@ func SendYbCommunityVideoToThs(videoId int) (err error) {
 		err = errors.New("获取视频信息失败, Err:" + e.Error())
 		return
 	}
-	permissionName := "宏观"	// 所有客群都推
+	permissionName := "宏观" // 所有客群都推
 	title := video.Title
-	jumpUrl := fmt.Sprint(utils.WxYbAppId + `/pages/video/videoList?videoId=`, videoId)
+	jumpUrl := fmt.Sprint(utils.WxYbAppId+`/pages/video/videoList?videoId=`, videoId)
 	logoUrl := `https://hongze.oss-cn-shanghai.aliyuncs.com/hzyj.png`
 	// 推送至同花顺
 	dataType := "2"
@@ -549,12 +549,83 @@ func SendYbVoiceBroadcastToThs(voiceId int) (err error) {
 		err = errors.New("获取语音播报信息失败, Err:" + e.Error())
 		return
 	}
-	permissionName := "宏观"	// 所有客群都推
+	permissionName := "宏观" // 所有客群都推
 	title := voice.BroadcastName
-	jumpUrl := fmt.Sprint(utils.WxYbAppId + `/pages-voice/voiceDetail?voiceId=`, voiceId)
+	jumpUrl := fmt.Sprint(utils.WxYbAppId+`/pages-voice/voiceDetail?voiceId=`, voiceId)
 	logoUrl := `https://hongze.oss-cn-shanghai.aliyuncs.com/hzyj.png`
 	// 推送至同花顺
 	dataType := "2"
 	err = SendThs(title, permissionName, title, jumpUrl, logoUrl, dataType)
 	return
-}
+}
+
+//TshListResult 同花顺返回信息
+type TshListResult struct {
+	ErrorCode int    `json:"error" description:"错误状态码"`
+	Message   string `json:"message" description:"提示信息"`
+}
+
+// ThsReportList 同花顺列表接口
+func ThsReportList() (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)
+		}
+	}()
+	pubKey := utils.THS_PubKey
+	sendUrl := utils.THS_SyncWxGroupUrl
+	//fmt.Println("sendUrl:", sendUrl)
+
+	pageNumStr := "10"
+	utils.FileLog.Info(fmt.Sprintf("pageNum:%s", pageNumStr))
+	pageNumStr, err = gorsa.PublicEncrypt(pageNumStr, pubKey)
+	if err != nil {
+		return
+	}
+
+	numPerPageStr := "1" // 页码;默认1
+	utils.FileLog.Info(fmt.Sprintf("numPerPage:%s", numPerPageStr))
+	numPerPageStr, err = gorsa.PublicEncrypt(numPerPageStr, pubKey)
+	if err != nil {
+		return
+	}
+
+	//pageNum	int	页码;默认1	否
+	//numPerPage	int	每页数量;默认10	否
+	//title	String	标题	否
+	//startDate	String	开始日期;如2022-08-12	否
+	//endDate	String	结束日期;如2022-08-12	否
+
+	//开始发送
+	client := http.Client{}
+	form := url.Values{}
+	form.Add("pageNum", pageNumStr)
+	form.Add("numPerPage", numPerPageStr)
+
+	utils.FileLog.Info(fmt.Sprintf("Ths List parms:%s", form.Encode()))
+	resp, err := client.PostForm(sendUrl, form)
+	if err != nil {
+		return
+	}
+	defer resp.Body.Close()
+
+	body, _ := ioutil.ReadAll(resp.Body)
+
+	//fmt.Println(string(body))
+	utils.FileLog.Info(fmt.Sprintf("Ths List Result parms:%s", string(body)))
+
+	//同花顺接口返回数据
+	var tshResult TshResult
+	err = json.Unmarshal(body, &tshResult)
+	if err != nil {
+		err = errors.New(fmt.Sprint("同花顺接口返回数据转换成结构体异常,Err:", err))
+		return
+	}
+	if tshResult.ErrorCode != 1 {
+		err = errors.New(fmt.Sprint("发送数据到同花顺接口异常,result:", string(body)))
+		return
+	}
+	return
+}

+ 8 - 0
services/save_log.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"context"
+	"hongze/hongze_task/models"
 	"hongze/hongze_task/models/data_manage"
 	"hongze/hongze_task/services/alarm_msg"
 	"hongze/hongze_task/utils"
@@ -24,5 +25,12 @@ func DeleteLog(cont context.Context) (err error) {
 		}
 	}()
 
+	go func() {
+		err = models.DeleteTemplateRecordByDate(date)
+		if err != nil {
+			alarm_msg.SendAlarmMsg("DeleteTemplateRecordByDate ErrMsg:"+err.Error(), 3)
+		}
+	}()
+
 	return
 }

+ 17 - 49
services/task.go

@@ -18,6 +18,7 @@ import (
 )
 
 func Task() {
+	ThsReportList()
 	fmt.Println("task start")
 	//如果是生产环境,才需要走这些任务
 	if utils.RunMode == "release" {
@@ -47,10 +48,6 @@ func Task() {
 	companyReportPermissionClose := task.NewTask("companyReportPermissionClose", "0 35 2 * * *", CompanyReportPermissionClose)
 	task.AddTask("用户产品权限试用-->关闭", companyReportPermissionClose)
 
-	//删除日志记录
-	//deleteReportSaveLog := task.NewTask("deleteReportSaveLog", "0 30 08 * * *", DeleteReportSaveLog)
-	//task.AddTask("deleteReportSaveLog", deleteReportSaveLog)
-
 	// 存量客户数据统计
 	stackCompanyStatistic := task.NewTask("stackCompanyStatistic", "0 35 2 * * *", StackCompanyStatistic)
 	task.AddTask("存量客户数据统计", stackCompanyStatistic)
@@ -66,11 +63,6 @@ func Task() {
 	// 研报沙龙提醒
 	ybSalonRemind := task.NewTask("ybSalonRemind", "0 */1 * * * * ", YbSalonRemind)
 	task.AddTask("研报沙龙提醒", ybSalonRemind)
-	//GetHistoryLzProductDetail()
-	//GetLzPrice()
-	//GetLzProductDetail()
-	//LzExportExcel()
-	//GetLzProductList()GetLzProductDetail
 
 	// 定时新增手工指标数据提醒
 	addEdbTask := task.NewTask("sendWaitReport", "1 0 2 * * * ", AddEdbTask)
@@ -146,9 +138,6 @@ func releaseTask() {
 	sendEmail := task.NewTask("sendEmail", "0 0 12 * * 0 ", SendEmail)
 	task.AddTask("sendEmail", sendEmail)
 
-	//oneMinute := task.NewTask("oneMinute", "0 */1 7-23 * * * ", OneMinute)
-	//task.AddTask("oneMinute", oneMinute)
-
 	// 正式/试用 用户到期提醒
 	companyRemind := task.NewTask("companyRemind", "0 30 08 * * *", CompanyRemind)
 	task.AddTask("companyRemind", companyRemind)
@@ -188,19 +177,9 @@ func releaseTask() {
 	syncThsWxGroupEveryDay := task.NewTask("syncThsWxGroupEveryDay", "0 1 4 * * * ", SyncWxGroupEveryDay)
 	task.AddTask("定时往同花顺同步微信群的截止日期", syncThsWxGroupEveryDay)
 
-	checkPbDataInterface := task.NewTask("checkPbDataInterface", "0 */2 * * * * ", data.CheckPbDataInterface)
-	task.AddTask("checkPbDataInterface", checkPbDataInterface)
-
-	checkLtDataInterface := task.NewTask("checkLtDataInterface", "0 */2 * * * * ", data.CheckLtDataInterface)
-	task.AddTask("checkLtDataInterface", checkLtDataInterface)
-
-	//检测wind新服务器
-	checkWindDataInterface := task.NewTask("checkWindDataInterface", "0 */2 * * * * ", data.CheckWindDataInterface)
-	task.AddTask("checkWindDataInterface", checkWindDataInterface)
-
-	// 检测同花顺数据服务器
-	checkThsDataInterface := task.NewTask("checkThsDataInterface", "0 */2 * * * * ", data.CheckThsDataInterface)
-	task.AddTask("checkThsDataInterface", checkThsDataInterface)
+	//检测数据服务器
+	checkDataServer := task.NewTask("checkDataServer", "0 */2 * * * * ", checkDataServer)
+	task.AddTask("checkDataServer", checkDataServer)
 
 	//初始化指标更新状态
 	resetEdbInfoIsUpdate := task.NewTask("resetEdbInfoIsUpdate", "0 0 0 * * *", data.ResetEdbInfoIsUpdate)
@@ -351,30 +330,6 @@ func SyncBaseDataExt(cont context.Context) (err error) {
 	return
 }
 
-//func RefreshCalculateData(cont context.Context) (err error) {
-//	//计算指标
-//	go data.RefreshDataFromCalculateAll()
-//	//刷新公历转农历数据
-//	//go data.RefreshDataFromQuarterAll()
-//	return
-//}
-
-//func Task() {
-//	fmt.Println("start")
-//	data.RefreshDataFromCalculateAll()
-//	//startDate := time.Now().AddDate(-30, 0, 0).UnixNano() / 1e6
-//
-//	//fmt.Println(startDate)
-//	//fmt.Println(endDate)
-//	fmt.Println("end")
-//}
-
-/*
-endData:=time.Now().UnixNano()/1e6
-	dateTime:=time.Unix(endData/1000,0)
-	fmt.Println(dateTime)
-*/
-
 // EdbTaskNameMap 手工指标定时任务名称map集合
 var EdbTaskNameMap map[string]map[string]bool
 
@@ -822,3 +777,16 @@ func deleteTask() {
 		}
 	}
 }
+
+//检测数据服务
+func checkDataServer(cont context.Context) (err error) {
+	//检测wind新服务器
+	go data.CheckWindDataInterface(cont)
+	//检测同花顺数据服务器
+	go data.CheckThsDataInterface(cont)
+	//检测路透数据服务器
+	go data.CheckLtDataInterface(cont)
+	//检测彭博
+	go data.CheckPbDataInterface(cont)
+	return
+}

+ 3 - 0
utils/config.go

@@ -48,6 +48,7 @@ var (
 var (
 	THS_SendUrl        string //同花顺地址url
 	THS_SyncWxGroupUrl string //同花顺同步微信群url
+	THS_List_Url       string // 同花顺报告列表地址url
 	THS_PubKey         string //同花顺公钥
 )
 
@@ -124,6 +125,7 @@ ZwIDAQAB
 		//同花顺正式地址
 		THS_SendUrl = `https://board.10jqka.com.cn/gateway/ps/syncNews`
 		THS_SyncWxGroupUrl = `https://board.10jqka.com.cn/gateway/ps/syncWechatGroupInfo`
+		THS_List_Url = `https://board.10jqka.com.cn/gateway/ps/syncNews/listPage`
 		//同花顺,万得接口服务地址(阿里云windows服务器地址;内网地址)
 		Hz_Server_Data_Url = "http://172.19.173.231:7000/"
 
@@ -145,6 +147,7 @@ ZwIDAQAB
 		//同花顺测试地址
 		THS_SendUrl = `https://mtest.10jqka.com.cn/gateway/ps/syncNews`
 		THS_SyncWxGroupUrl = `https://mtest.10jqka.com.cn/gateway/ps/syncWechatGroupInfo`
+		THS_SyncWxGroupUrl = `https://mtest.10jqka.com.cn/gateway/ps/syncNews/listPage`
 		//同花顺,万得接口服务地址(阿里云windows服务器地址;外网地址)
 		Hz_Server_Data_Url = "http://139.196.136.213:7000/"