Pārlūkot izejas kodu

fix:计算指标刷新调整,还是把时间限制给加上

Roc 3 gadi atpakaļ
vecāks
revīzija
134f568106
2 mainītis faili ar 25 papildinājumiem un 25 dzēšanām
  1. 9 9
      services/data/data_calculate.go
  2. 16 16
      services/data/edb_info.go

+ 9 - 9
services/data/data_calculate.go

@@ -13,7 +13,7 @@ import (
 )
 
 //指标运算刷新数据
-func RefreshCalculate(edbInfoIdArr []*data_manage.EdbInfo, edbInfoId int, edbCode, formulaStr string, edbInfoIdBytes []string) (err error) {
+func RefreshCalculate(edbInfoIdArr []*data_manage.EdbInfo, edbInfoId int, edbCode, formulaStr, startDate, endDate string, edbInfoIdBytes []string) (err error) {
 	defer func() {
 		if err != nil {
 			utils.FileLog.Info("Calculate Err:%s" + err.Error())
@@ -26,14 +26,14 @@ func RefreshCalculate(edbInfoIdArr []*data_manage.EdbInfo, edbInfoId int, edbCod
 		var pars []interface{}
 		condition += " AND edb_info_id=? "
 		pars = append(pars, v.EdbInfoId)
-		//if startDate != "" {
-		//	condition += " AND data_time>=? "
-		//	pars = append(pars, startDate)
-		//}
-		//if endDate != "" {
-		//	condition += " AND data_time<=? "
-		//	pars = append(pars, endDate)
-		//}
+		if startDate != "" {
+			condition += " AND data_time>=? "
+			pars = append(pars, startDate)
+		}
+		if endDate != "" {
+			condition += " AND data_time<=? "
+			pars = append(pars, endDate)
+		}
 		dataList, err := data_manage.GetEdbDataListAll(condition, pars, v.Source, 1)
 
 		if err != nil {

+ 16 - 16
services/data/edb_info.go

@@ -253,21 +253,21 @@ func RefreshDataFromCalculateAll() (err error) {
 		source := v.Source
 		fmt.Println(v.EdbInfoId, v.EdbCode, v.EdbName, v.SourceName, source)
 		if source == utils.DATA_SOURCE_CALCULATE {
-			//startDate := ""
-			//if v.Frequency == "日度" {
-			//	startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
-			//} else if v.Frequency == "周度" {
-			//	startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
-			//} else if v.Frequency == "月度" {
-			//	startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
-			//} else if v.Frequency == "季度" {
-			//	startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
-			//} else if v.Frequency == "年度" {
-			//	startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
-			//} else {
-			//	startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
-			//}
-			//endDate := time.Now().Format(utils.FormatDate)
+			startDate := ""
+			if v.Frequency == "日度" {
+				startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
+			} else if v.Frequency == "周度" {
+				startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
+			} else if v.Frequency == "月度" {
+				startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
+			} else if v.Frequency == "季度" {
+				startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
+			} else if v.Frequency == "年度" {
+				startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
+			} else {
+				startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
+			}
+			endDate := time.Now().Format(utils.FormatDate)
 			var edbInfoIdBytes []string
 			calculateMap, err := data_manage.GetEdbInfoCalculateDetail(int(v.EdbInfoId))
 			if err != nil {
@@ -282,7 +282,7 @@ func RefreshDataFromCalculateAll() (err error) {
 				edbInfoList = append(edbInfoList, edbInfo)
 			}
 			//endDate = ""
-			err = RefreshCalculate(edbInfoList, edbInfoId, edbCode, v.CalculateFormula, edbInfoIdBytes)
+			err = RefreshCalculate(edbInfoList, edbInfoId, edbCode, v.CalculateFormula, startDate, endDate, edbInfoIdBytes)
 			if err != nil {
 				return errors.New("RefreshCalculate Err:" + err.Error())
 			}