Browse Source

Merge branch 'pool_delete_log'

ziwen 2 years ago
parent
commit
81cdc3517d

+ 15 - 0
models/data_manage/ppt_v2_save_log.go

@@ -0,0 +1,15 @@
+package data_manage
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+)
+
+func DeletePPTLogByDate(date string) (err error) {
+	sql := `DELETE FROM ppt_v2_save_log WHERE create_time<%s `
+	sql = fmt.Sprintf(sql, date)
+	o := orm.NewOrmUsingDB("rddp")
+	_, err = o.Raw(sql, date).Exec()
+
+	return
+}

+ 15 - 0
models/data_manage/report_save_log.go

@@ -0,0 +1,15 @@
+package data_manage
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+)
+
+func DeleteReportLogByDate(date string) (err error) {
+	sql := `DELETE FROM report_save_log WHERE create_time<%s `
+	sql = fmt.Sprintf(sql, date)
+	o := orm.NewOrmUsingDB("rddp")
+	_, err = o.Raw(sql, date).Exec()
+
+	return
+}

+ 28 - 0
services/save_log.go

@@ -0,0 +1,28 @@
+package services
+
+import (
+	"context"
+	"hongze/hongze_task/models/data_manage"
+	"hongze/hongze_task/services/alarm_msg"
+	"hongze/hongze_task/utils"
+	"time"
+)
+
+func DeleteLog(cont context.Context) (err error) {
+	date := time.Now().AddDate(0,-1,0).Format(utils.FormatDateTime)
+	go func() {
+		err = data_manage.DeletePPTLogByDate(date)
+		if err != nil {
+			alarm_msg.SendAlarmMsg("DeletePPTLogByDate ErrMsg:"+err.Error(), 3)
+		}
+	}()
+
+	go func() {
+		err = data_manage.DeleteReportLogByDate(date)
+		if err != nil {
+			alarm_msg.SendAlarmMsg("DeleteReportLogByDate ErrMsg:"+err.Error(), 3)
+		}
+	}()
+
+	return
+}

+ 8 - 0
services/task.go

@@ -109,6 +109,14 @@ func Task() {
 	syncComeinMeeting := task.NewTask("SyncComeinMeeting", "0 1 */1 * * * ", SyncComeinMeeting)
 	task.AddTask("SyncComeinMeeting", syncComeinMeeting)
 
+
+
+
+	//删除日志 report_save_log,ppt_v2_save_log,保留一个月的
+	deleteLog := task.NewTask("syncSubStatus", "0 0 2 1 * *", DeleteLog)
+	task.AddTask("deleteLog", deleteLog)
+
+
 	task.StartTask()
 
 	fmt.Println("task end")