hongze 3 năm trước cách đây
mục cha
commit
5780c18658

+ 0 - 181
models/data_manage/edb_data_quarter.go

@@ -1,13 +1,7 @@
 package data_manage
 
 import (
-	"fmt"
-	"hongze/hongze_task/utils"
 	"rdluck_tools/orm"
-	"sort"
-	"strconv"
-	"strings"
-	"time"
 )
 
 func GetEdbDataQuarterCount(edbInfoId int) (count int, err error) {
@@ -17,178 +11,3 @@ func GetEdbDataQuarterCount(edbInfoId int) (count int, err error) {
 	err = o.Raw(hsql, edbInfoId).QueryRow(&count)
 	return
 }
-
-//指标季度数据计算
-func RefreshCalculateQuarter(edbInfoId, source int, edbCode string) (err error) {
-	o := orm.NewOrm()
-	o.Using("data")
-	o.Begin()
-	defer func() {
-		if err != nil {
-			fmt.Println("Err:", err)
-			o.Rollback()
-		} else {
-			o.Commit()
-		}
-	}()
-
-	edbInfoIdStr := strconv.Itoa(edbInfoId)
-
-	startDate := time.Now().AddDate(-2, -2, 0).Format(utils.FormatDate)
-	//计算数据
-	var condition string
-	var pars []interface{}
-	condition += " AND edb_info_id=? "
-	pars = append(pars, edbInfoId)
-	condition += " AND data_time>=? "
-	pars = append(pars, startDate)
-
-	dataList, err := GetEdbDataListAll(condition, pars, source, 0)
-	if err != nil {
-		return err
-	}
-
-	//计算数据
-	var existCondition string
-	var existPars []interface{}
-	existCondition += " AND edb_info_id=? "
-	existPars = append(existPars, edbInfoId)
-	existCondition += " AND data_time>=? "
-	existPars = append(existPars, startDate)
-
-	existDataList, err := GetEdbDataListAll(existCondition, existPars, utils.DATA_SOURCE_QUARTER, 0)
-	if err != nil {
-		return err
-	}
-	existMap := make(map[string]float64)
-	for _, v := range existDataList {
-		existMap[v.DataTime] = v.Value
-	}
-
-	var yearArr []int
-	yearMap := make(map[int]int)
-	dataMap := make(map[string]*EdbInfoSearchData)
-	for _, v := range dataList {
-		//日其中获取年
-		itemDate, err := time.Parse(utils.FormatDate, v.DataTime)
-		if err != nil {
-			return err
-		}
-		year := itemDate.Year()
-		if _, ok := yearMap[year]; !ok {
-			yearArr = append(yearArr, year)
-			yearMap[year] = year
-		}
-		dataMap[v.DataTime] = v
-	}
-	sort.Sort(sort.Reverse(sort.IntSlice(yearArr)))
-	addSql := ` INSERT INTO edb_data_quarter(edb_info_id,edb_code,data_time,value,create_time,modify_time,status,data_timestamp) values `
-	var isAdd bool
-	yearLen := len(yearArr)
-
-	fmt.Println(yearArr)
-
-	for yk, yv := range yearArr {
-		currentYear := yv
-		hsql := `SELECT * FROM holiday WHERE year=? `
-		currentHolidayObj := new(Holiday)
-		err = o.Raw(hsql, currentYear).QueryRow(&currentHolidayObj)
-		if err != nil {
-			return err
-		}
-		nextIndex := yk + 1
-		if nextIndex < yearLen {
-			nextYear := yearArr[nextIndex]
-			fmt.Println("year:", currentYear, nextYear)
-			nextHolidayObj := new(Holiday)
-			hsql := `SELECT * FROM holiday WHERE year=? `
-			err = o.Raw(hsql, nextYear).QueryRow(&nextHolidayObj)
-			if err != nil {
-				return err
-			}
-			nextHolidayStr := nextHolidayObj.HolidayDate.Format(utils.FormatDate)
-			currentHolidayStr := currentHolidayObj.HolidayDate.Format(utils.FormatDate)
-
-			if findItem, ok := dataMap[nextHolidayStr]; ok {
-				timestamp := currentHolidayObj.HolidayDate.UnixNano() / 1e6
-				timestampStr := fmt.Sprintf("%d", timestamp)
-				if _, ok := existMap[currentHolidayStr]; !ok {
-					valStr := utils.SubFloatToString(findItem.Value, 4)
-					addSql += GetAddSql(edbInfoIdStr, edbCode, currentHolidayStr, timestampStr, valStr)
-					isAdd = true
-				}
-			}
-
-			nextMinDate := strconv.Itoa(nextYear) + "-01-01"
-			nextMaxDate := strconv.Itoa(nextYear) + "-12-31"
-			currentMinDate := strconv.Itoa(currentYear) + "-01-01"
-			currentMaxDate := strconv.Itoa(currentYear) + "-12-31"
-
-			i := 0
-			for {
-				i--
-				nextHolidayFormat := nextHolidayObj.HolidayDate.AddDate(0, 0, i)
-				currentHolidayFormat := currentHolidayObj.HolidayDate.AddDate(0, 0, i)
-
-				nextHolidayStr := nextHolidayFormat.Format(utils.FormatDate)
-				currentHolidayStr := currentHolidayFormat.Format(utils.FormatDate)
-
-				fmt.Println("currentHolidayStr:", currentHolidayStr, nextHolidayStr)
-				if findItem, ok := dataMap[nextHolidayStr]; ok {
-					timestamp := currentHolidayFormat.UnixNano() / 1e6
-					timestampStr := fmt.Sprintf("%d", timestamp)
-					if _, ok := existMap[currentHolidayStr]; !ok {
-						valStr := utils.SubFloatToString(findItem.Value, 4)
-						addSql += GetAddSql(edbInfoIdStr, edbCode, currentHolidayStr, timestampStr, valStr)
-						isAdd = true
-					}
-				}
-				//fmt.Println("nextHolidayStr:", nextHolidayStr,nextMinDate)
-				if nextHolidayStr == nextMinDate || currentHolidayStr == currentMinDate {
-					fmt.Println("min跳出循环:" + nextMinDate)
-					break
-				}
-			}
-
-			n := 0
-			for {
-				n++
-				nextHolidayFormat := nextHolidayObj.HolidayDate.AddDate(0, 0, n)
-				currentHolidayFormat := currentHolidayObj.HolidayDate.AddDate(0, 0, n)
-
-				nextHolidayStr := nextHolidayFormat.Format(utils.FormatDate)
-				currentHolidayStr := currentHolidayFormat.Format(utils.FormatDate)
-
-				fmt.Println("currentHolidayStr:", currentHolidayStr, nextHolidayStr)
-
-				if findItem, ok := dataMap[nextHolidayStr]; ok {
-					timestamp := currentHolidayFormat.UnixNano() / 1e6
-					timestampStr := fmt.Sprintf("%d", timestamp)
-
-					if _, ok := existMap[currentHolidayStr]; !ok {
-						valStr := utils.SubFloatToString(findItem.Value, 4)
-						addSql += GetAddSql(edbInfoIdStr, edbCode, currentHolidayStr, timestampStr, valStr)
-						isAdd = true
-					}
-				}
-
-				//fmt.Println("nextHolidayStr:", nextHolidayStr,nextMaxDate)
-				if nextHolidayStr == nextMaxDate || currentHolidayStr == currentMaxDate {
-					fmt.Println("max跳出循环:" + nextMaxDate)
-					break
-				}
-			}
-		}
-	}
-	fmt.Println("isAdd", isAdd)
-	if isAdd {
-		addSql = strings.TrimRight(addSql, ",")
-		utils.FileLog.Info(addSql)
-		_, err = o.Raw(addSql).Exec()
-		fmt.Println("err:", err)
-		if err != nil {
-			return err
-		}
-	}
-	return
-}

+ 0 - 2
models/data_manage/edb_data_table.go

@@ -25,8 +25,6 @@ func GetEdbDataTableName(source int) (tableName string) {
 		tableName = "edb_data_calculate_tcz"
 	case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
 		tableName = "edb_data_calculate_nszydpjjs"
-	case utils.DATA_SOURCE_QUARTER:
-		tableName = "edb_data_quarter"
 	default:
 		tableName = ""
 		errors.New("无效的渠道:" + strconv.Itoa(source))

+ 0 - 20
services/data/edb_info.go

@@ -357,26 +357,6 @@ func RefreshDataFromCalculateAll() (err error) {
 	return err
 }
 
-//刷新指标农历数据
-func RefreshDataFromQuarterAll() (err error) {
-	defer func() {
-		if err != nil {
-			utils.FileLog.Info("RefreshDataFromQuarterAll Err:" + err.Error())
-			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromQuarterAll ErrMsg:"+err.Error(), utils.EmailSendToUsers)
-		}
-	}()
-
-	items, err := data_manage.GetQuarterEdbInfo()
-	if err != nil {
-		return err
-	}
-
-	for _, v := range items {
-		data_manage.RefreshCalculateQuarter(v.EdbInfoId, v.Source, v.EdbCode)
-	}
-	return err
-}
-
 //刷新手工指标数据
 func RefreshDataFromManual(wg *sync.WaitGroup) (err error) {
 	defer func() {