Explorar o código

Merge branch 'aj_business_trip' into debug

tuoling805 %!s(int64=2) %!d(string=hai) anos
pai
achega
c76923ba1f

+ 32 - 0
models/business_apply.go

@@ -0,0 +1,32 @@
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+func BusinessTripApplyStatusOutTime(returnDate string) (err error) {
+	o := orm.NewOrm()
+	tx, err := o.Begin()
+	if err != nil {
+		return err
+	}
+	defer func() {
+		if err != nil {
+			tx.Commit()
+		} else {
+			tx.Rollback()
+		}
+	}()
+	//客户产品状态变更
+	sql := `UPDATE business_apply SET status='已过期',modify_time=NOW()  WHERE status='待审批' AND return_date < ? `
+	_, err = tx.Raw(sql, returnDate).Exec()
+	if err != nil {
+		return
+	}
+
+	// 将历史的任务给标记删除掉
+	sql = `UPDATE business_apply_peer SET status='已过期',modify_time=NOW() WHERE status='待审批' AND return_date < ? `
+	_, err = o.Raw(sql, returnDate).Exec()
+	if err != nil {
+		return
+	}
+	return
+}

+ 14 - 0
services/business_apply.go

@@ -0,0 +1,14 @@
+package services
+
+import (
+	"context"
+	"hongze/hongze_task/models"
+	"hongze/hongze_task/utils"
+	"time"
+)
+
+func CheckBusinessTripApply(cont context.Context) (err error) {
+	endDate := time.Now().Format(utils.FormatDate)
+	err = models.BusinessTripApplyStatusOutTime(endDate)
+	return err
+}

+ 5 - 1
services/data/edb_info.go

@@ -938,6 +938,7 @@ func RefreshDataFromManual(wg *sync.WaitGroup) (err error) {
 		}
 		wg.Done()
 	}()
+	
 	var condition string
 	var pars []interface{}
 	condition += " AND source=? "
@@ -953,7 +954,10 @@ func RefreshDataFromManual(wg *sync.WaitGroup) (err error) {
 		//if err != nil {
 		//	return errors.New("RefreshManual:edbCode:" + v.EdbCode + ":" + err.Error())
 		//}
-		startDate := v.StartDate.Format(utils.FormatDate)
+		startDate := ``
+		if !v.StartDate.IsZero(){
+			startDate = v.StartDate.Format(utils.FormatDate)
+		}
 		resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.EdbCode, startDate)
 		if err != nil {
 			return errors.New("RefreshEdbData Err:" + err.Error())

+ 2 - 0
services/report_push.go

@@ -734,6 +734,8 @@ func CheckThsReportList(cont context.Context) (err error) {
 			//fmt.Println("定时检测同花顺客群推送状态:\n"+strings.Join(errMsgList, "\n"), 3)
 		}
 	}()
+	// 暂时关停检测
+	return
 	tshListRowsResult, err := thsReportList(`50`)
 	if err != nil {
 		return

+ 11 - 6
services/task.go

@@ -122,7 +122,7 @@ func Task() {
 	task.AddTask("定时发布研报语音播报", publishVoiceBroadcast)
 
 	// 定时生成本周研究汇总
-	cygxResearchSummary := task.NewTask("cygxResearchSummary", "0 0 10 * * 5", CygxResearchSummary)
+	cygxResearchSummary := task.NewTask("cygxResearchSummary", "0 0 15 * * 5", CygxResearchSummary)
 	task.AddTask("定时生成本周研究汇总", cygxResearchSummary)
 
 	// 定时生成上周纪要汇总
@@ -130,6 +130,11 @@ func Task() {
 	task.AddTask("定时生成上周纪要汇总", cygxLastWeekSummary)
 	//CygxResearchSummary()
 	//CygxLastWeekSummary()
+
+	// 出差申请过期状态检测
+	checkBusinessTripApply := task.NewTask("checkBusinessTripApply", "0 */30 * * * *", CheckBusinessTripApply)
+	task.AddTask("checkBusinessTripApply", checkBusinessTripApply)
+
 	task.StartTask()
 
 	fmt.Println("task end")
@@ -142,7 +147,7 @@ func Task() {
 //	fmt.Println("end")
 //}
 
-//生产环境需要走的任务
+// 生产环境需要走的任务
 func releaseTask() {
 	////隆众调研指标获取
 	//getLzSurveyProduct := task.NewTask("getLzSurveyProduct", "0 5 08-19/1 * * * ", GetLzSurveyProduct)
@@ -333,7 +338,7 @@ func RefreshEicData(cont context.Context) (err error) {
 	return
 }
 
-//刷新基础数据
+// 刷新基础数据
 func RefreshBaseData(cont context.Context) (err error) {
 	now := time.Now()
 	if now.Hour() == 0 || now.Hour() == 19 {
@@ -344,7 +349,7 @@ func RefreshBaseData(cont context.Context) (err error) {
 	return
 }
 
-//刷新基础数据
+// 刷新基础数据
 func SyncBaseData(cont context.Context) (err error) {
 	now := time.Now()
 	if now.Hour() == 0 || now.Hour() == 19 {
@@ -355,7 +360,7 @@ func SyncBaseData(cont context.Context) (err error) {
 	return
 }
 
-//刷新基础数据
+// 刷新基础数据
 func SyncBaseDataExt(cont context.Context) (err error) {
 	now := time.Now()
 	if now.Hour() == 0 || now.Hour() == 19 {
@@ -799,7 +804,7 @@ func deleteTask() {
 	}
 }
 
-//检测数据服务
+// 检测数据服务
 func checkDataServer(cont context.Context) (err error) {
 	//检测wind新服务器
 	go data.CheckWindDataInterface(cont)