|
@@ -1,1639 +0,0 @@
|
|
|
-package data
|
|
|
-
|
|
|
-import (
|
|
|
- "errors"
|
|
|
- "fmt"
|
|
|
- "hongze/hongze_chart_lib/models"
|
|
|
- "hongze/hongze_chart_lib/models/data_manage"
|
|
|
- "hongze/hongze_chart_lib/utils"
|
|
|
- "sort"
|
|
|
- "strconv"
|
|
|
- "time"
|
|
|
-)
|
|
|
-
|
|
|
-//刷新计算指标
|
|
|
-func EdbInfoRefreshFromCalculate(edbInfoId, source int) (err error) {
|
|
|
- var errmsg string
|
|
|
- defer func() {
|
|
|
- fmt.Println("errmsg:" + errmsg)
|
|
|
- if err != nil {
|
|
|
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "EdbInfoRefreshFromCalculate:"+errmsg, utils.EmailSendToUsers)
|
|
|
- }
|
|
|
- }()
|
|
|
- baseEdbInfoArr, calculateInfoArr, err := data_manage.GetRefreshEdbInfoFromCalculate(edbInfoId, source)
|
|
|
- if err != nil {
|
|
|
- errmsg = "获取需要刷新的指标失败:Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- calculateItem, _ := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
- calculateInfoArr = append(calculateInfoArr, calculateItem)
|
|
|
- var calculateArr []int
|
|
|
- calculateMap := make(map[int]*data_manage.EdbInfo)
|
|
|
- for _, v := range calculateInfoArr {
|
|
|
- if _, ok := calculateMap[v.EdbInfoId]; !ok {
|
|
|
- calculateArr = append(calculateArr, v.EdbInfoId)
|
|
|
- }
|
|
|
- calculateMap[v.EdbInfoId] = v
|
|
|
- }
|
|
|
- sort.Ints(calculateArr)
|
|
|
-
|
|
|
- var startDate string
|
|
|
- endDate := time.Now().Format(utils.FormatDate)
|
|
|
- for _, bv := range baseEdbInfoArr {
|
|
|
- source := bv.Source
|
|
|
- edbInfoId := bv.EdbInfoId
|
|
|
- edbCode := bv.EdbCode
|
|
|
- startDate = bv.StartDate
|
|
|
- sTime, err := time.Parse(utils.FormatDate, bv.EndDate)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = sTime.Format(utils.FormatDate)
|
|
|
-
|
|
|
- if source == utils.DATA_SOURCE_THS {
|
|
|
- err = RefreshEdbDataByThs(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByThs Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_WIND {
|
|
|
- err = RefreshEdbDataByWind(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByWind Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_PB {
|
|
|
- startDate := sTime.Format(utils.FormatDateUnSpace)
|
|
|
- endDate := time.Now().Format(utils.FormatDateUnSpace)
|
|
|
- err = RefreshEdbDataByPb(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByPb Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_MANUAL {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByManual(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByManual Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_LZ {
|
|
|
- err = data_manage.RefreshEdbDataByLz(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByLz Err:" + err.Error()
|
|
|
- }
|
|
|
- }else if source == utils.DATA_SOURCE_LT {
|
|
|
- endDate := time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByLt(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByLT Err:" + err.Error()
|
|
|
- }
|
|
|
- }
|
|
|
- maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- return err
|
|
|
- }
|
|
|
- if maxAndMinItem != nil {
|
|
|
- err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //全部改成重新计算逻辑
|
|
|
-
|
|
|
- endDate = "" //计算指标不限制结束日期
|
|
|
-
|
|
|
- for _, v := range calculateArr {
|
|
|
- edbInfo := calculateMap[v]
|
|
|
- if edbInfo == nil {
|
|
|
- fmt.Println("edbInfo is nil:")
|
|
|
- return err
|
|
|
- }
|
|
|
- edbInfoId := edbInfo.EdbInfoId
|
|
|
- edbCode := edbInfo.EdbCode
|
|
|
- if edbInfo.Source == utils.DATA_SOURCE_CALCULATE {
|
|
|
-
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- sTime, err := time.Parse(utils.FormatDate, edbInfo.EndDate)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = sTime.Format(utils.FormatDate)
|
|
|
-
|
|
|
- var edbInfoIdBytes []string
|
|
|
- calculateMap, err := data_manage.GetEdbInfoCalculateDetail(edbInfoId, edbInfo.Source)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- var formulaStr string
|
|
|
- edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
|
-
|
|
|
- for _, v := range calculateMap {
|
|
|
- formulaStr += v.FromTag + ","
|
|
|
- edbInfoIdBytes = append(edbInfoIdBytes, v.FromTag)
|
|
|
- edbInfo, _ := data_manage.GetEdbInfoById(v.FromEdbInfoId)
|
|
|
- edbInfoList = append(edbInfoList, edbInfo)
|
|
|
- }
|
|
|
- err = RefreshCalculate(edbInfoList, int(edbInfoId), edbInfo.EdbCode, edbInfo.CalculateFormula, startDate, endDate, edbInfoIdBytes)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculate Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_LJZZY { //刷新累计值转月值
|
|
|
- calculateLjzzy, err := data_manage.GetEdbInfoCalculateLjzzyDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateLjzzyDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateLjzzy.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- year := time.Now().Year()
|
|
|
- startDate = strconv.Itoa(year) + "-01" + "-01"
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateLjzzy(edbInfoId, fromEdbInfo, calculateLjzzy.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateLjzzy Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_TBZ { //刷新同比值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateTbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- //startDate = calculateTbz.StartDate //time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateTbz(edbInfoId, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateTbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_TCZ { //同差值
|
|
|
- calculateTcz, err := data_manage.GetEdbInfoCalculateTczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTczDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTcz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateTcz(edbInfoId, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateTcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS { //N数值移动平均计算
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateNszydpjjs, err := data_manage.GetEdbInfoCalculateNszydpjjsDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateNszydpjjs.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- err = data_manage.RefreshCalculateNszydpjjs(edbInfoId, edbInfo.Source, formulaInt, fromEdbInfo, calculateNszydpjjs.EdbCode)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateNszydpjjs Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_HBZ { //环比
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateHbz(edbInfoId, edbInfo.Source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateHbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_HCZ { //环差
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateHcz(edbInfoId, edbInfo.Source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateHcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_BP { //变频
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateBpDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateBp(edbInfoId, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateBp Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(edbInfo.Source, edbCode)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- fmt.Println("GetEdbInfoMaxAndMinInfo Err:" + err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- if maxAndMinItem != nil {
|
|
|
- err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("ModifyEdbInfoMaxAndMinInfo:" + err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*for _, v := range calculateArr {
|
|
|
- edbInfo := calculateMap[v]
|
|
|
- if edbInfo == nil {
|
|
|
- fmt.Println("edbInfo is nil:")
|
|
|
- return err
|
|
|
- }
|
|
|
- edbInfoId := edbInfo.EdbInfoId
|
|
|
- edbCode := edbInfo.EdbCode
|
|
|
- if edbInfo.Source == utils.DATA_SOURCE_CALCULATE {
|
|
|
-
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- sTime, err := time.Parse(utils.FormatDate, edbInfo.EndDate)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = sTime.Format(utils.FormatDate)
|
|
|
-
|
|
|
- var edbInfoIdBytes []string
|
|
|
- calculateMap, err := data_manage.GetEdbInfoCalculateDetail(edbInfoId, edbInfo.Source)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- var formulaStr string
|
|
|
- edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
|
-
|
|
|
- for _, v := range calculateMap {
|
|
|
- formulaStr += v.FromTag + ","
|
|
|
- edbInfoIdBytes = append(edbInfoIdBytes, v.FromTag)
|
|
|
- edbInfo, _ := data_manage.GetEdbInfoById(v.FromEdbInfoId)
|
|
|
- edbInfoList = append(edbInfoList, edbInfo)
|
|
|
- }
|
|
|
- err = RefreshCalculate(edbInfoList, int(edbInfoId), edbInfo.EdbCode, edbInfo.CalculateFormula, startDate, endDate, edbInfoIdBytes)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculate Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_LJZZY { //刷新累计值转月值
|
|
|
- calculateLjzzy, err := data_manage.GetEdbInfoCalculateLjzzyDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateLjzzyDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateLjzzy.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- year := time.Now().Year()
|
|
|
- startDate = strconv.Itoa(year) + "-01" + "-01"
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateLjzzy(edbInfoId, fromEdbInfo, calculateLjzzy.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateLjzzy Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_TBZ { //刷新同比值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateTbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- //startDate = calculateTbz.StartDate //time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateTbz(edbInfoId, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateTbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_TCZ { //同差值
|
|
|
- calculateTcz, err := data_manage.GetEdbInfoCalculateTczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTczDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTcz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateTcz(edbInfoId, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateTcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS { //N数值移动平均计算
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateNszydpjjs, err := data_manage.GetEdbInfoCalculateNszydpjjsDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateNszydpjjs.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- err = data_manage.RefreshCalculateNszydpjjs(edbInfoId, edbInfo.Source, formulaInt, fromEdbInfo, calculateNszydpjjs.EdbCode)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateNszydpjjs Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_HBZ { //环比
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateHbz(edbInfoId, edbInfo.Source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateHbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_HCZ { //环差
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateHcz(edbInfoId, edbInfo.Source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateHcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if edbInfo.Source == utils.DATA_SOURCE_CALCULATE_BP { //变频
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateBpDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
-
|
|
|
- err = data_manage.RefreshCalculateBp(edbInfoId, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateBp Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(edbInfo.Source, edbCode)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- fmt.Println("GetEdbInfoMaxAndMinInfo Err:" + err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- if maxAndMinItem != nil {
|
|
|
- err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("ModifyEdbInfoMaxAndMinInfo:" + err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
- return err
|
|
|
-}
|
|
|
-
|
|
|
-//刷新基础指标
|
|
|
-func EdbInfoRefreshFromBase(edbInfoId int) (err error) {
|
|
|
- var errmsg string
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println("EdbInfoRefreshFromBase Err:" + err.Error() + ";errmsg:" + errmsg)
|
|
|
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "EdbInfoRefreshFromBase:"+errmsg, utils.EmailSendToUsers)
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- calculateList, err := data_manage.GetEdbInfoAllCalculate(edbInfoId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- return errors.New("GetEdbInfoAllCalculate Err:" + err.Error())
|
|
|
- }
|
|
|
- baseEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
- calculateInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
- baseEdbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- return errors.New("GetEdbInfoAllCalGetEdbInfoByIdr:" + err.Error())
|
|
|
- }
|
|
|
- baseEdbInfoArr = append(baseEdbInfoArr, baseEdbInfo)
|
|
|
-
|
|
|
- for _, v := range calculateList {
|
|
|
- getBaseEdbInfoArr, getCalculateInfoArr, err := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetRefreshEdbInfoFromBase err:" + err.Error())
|
|
|
- errmsg = "获取需要刷新的指标失败:Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- baseEdbInfoArr = append(baseEdbInfoArr, getBaseEdbInfoArr...)
|
|
|
- calculateInfoArr = append(calculateInfoArr, getCalculateInfoArr...)
|
|
|
- calculateInfoArr = append(calculateInfoArr, v)
|
|
|
- }
|
|
|
- //取重
|
|
|
- newBaseEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
- baseMap := make(map[int]int)
|
|
|
- for _, v := range baseEdbInfoArr {
|
|
|
- if _, ok := baseMap[v.EdbInfoId]; !ok {
|
|
|
- newBaseEdbInfoArr = append(newBaseEdbInfoArr, v)
|
|
|
- }
|
|
|
- baseMap[v.EdbInfoId] = v.EdbInfoId
|
|
|
- }
|
|
|
-
|
|
|
- var calculateArr []int
|
|
|
- newCalculateMap := make(map[int]*data_manage.EdbInfo)
|
|
|
- for _, v := range calculateInfoArr {
|
|
|
- if _, ok := newCalculateMap[v.EdbInfoId]; !ok {
|
|
|
- calculateArr = append(calculateArr, v.EdbInfoId)
|
|
|
- }
|
|
|
- newCalculateMap[v.EdbInfoId] = v
|
|
|
- }
|
|
|
- sort.Ints(calculateArr)
|
|
|
- var startDate string
|
|
|
- for _, bv := range newBaseEdbInfoArr {
|
|
|
- source := bv.Source
|
|
|
- edbInfoId := bv.EdbInfoId
|
|
|
- edbCode := bv.EdbCode
|
|
|
-
|
|
|
- sTime, err := time.Parse(utils.FormatDate, bv.EndDate)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = sTime.Format(utils.FormatDate)
|
|
|
-
|
|
|
- if source == utils.DATA_SOURCE_THS {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = RefreshEdbDataByThs(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByThs Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_WIND {
|
|
|
- endDate := time.Now().Format(utils.FormatDate)
|
|
|
- err = RefreshEdbDataByWind(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByWind Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_PB {
|
|
|
- startDate := sTime.Format(utils.FormatDateUnSpace)
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
- err = RefreshEdbDataByPb(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByPb Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_MANUAL {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByManual(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByManual Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_LZ {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByLz(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByLz Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_YS {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByYs(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByLz Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_GL {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByGl(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshEdbDataByGl Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_ZZ {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByZz(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByZz Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_DL {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByDl(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByDl Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_SH {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataBySh(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataBySh Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CFFEX {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByCffex(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByCffex Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_SHFE {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshEdbDataByShfe(edbInfoId, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByShfe Err:" + err.Error()
|
|
|
- }
|
|
|
- }else if source == utils.DATA_SOURCE_LT {
|
|
|
- endDate := time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByLt(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByLT Err:" + err.Error()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if maxAndMinItem != nil {
|
|
|
- err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- endDate := "" //计算指标不限制结束日期
|
|
|
- for _, v := range calculateArr {
|
|
|
- edbInfo := newCalculateMap[v]
|
|
|
- if edbInfo == nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- edbInfoId := edbInfo.EdbInfoId
|
|
|
- edbCode := edbInfo.EdbCode
|
|
|
- source := edbInfo.Source
|
|
|
- if source == utils.DATA_SOURCE_CALCULATE {
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- if startDate == "" {
|
|
|
- err = errors.New("运算指标更新开始日期不能为空")
|
|
|
- return err
|
|
|
- }
|
|
|
- sTime, err := time.Parse(utils.FormatDate, edbInfo.EndDate)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("time.Parse Err:" + err.Error())
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = sTime.Format(utils.FormatDate)
|
|
|
-
|
|
|
- var edbInfoIdBytes []string
|
|
|
- calculateMap, err := data_manage.GetEdbInfoCalculateDetail(edbInfoId, edbInfo.Source)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- var formulaStr string
|
|
|
- edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
|
-
|
|
|
- for _, v := range calculateMap {
|
|
|
- formulaStr += v.FromTag + ","
|
|
|
- edbInfoIdBytes = append(edbInfoIdBytes, v.FromTag)
|
|
|
- edbInfo, _ := data_manage.GetEdbInfoById(v.FromEdbInfoId)
|
|
|
- edbInfoList = append(edbInfoList, edbInfo)
|
|
|
- }
|
|
|
- err = RefreshCalculate(edbInfoList, int(edbInfoId), edbInfo.EdbCode, edbInfo.CalculateFormula, startDate, endDate, edbInfoIdBytes)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculate Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_LJZZY { //刷新累计值转月值
|
|
|
- calculateLjzzy, err := data_manage.GetEdbInfoCalculateLjzzyDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateLjzzyDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateLjzzy.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- year := time.Now().Year()
|
|
|
- startDate = strconv.Itoa(year) + "-01" + "-01"
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateLjzzy(edbInfoId, fromEdbInfo, calculateLjzzy.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateLjzzy Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_TBZ { //刷新同比值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateTbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateTbz(edbInfoId, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateTbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_TCZ { //同差值
|
|
|
- calculateTcz, err := data_manage.GetEdbInfoCalculateTczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTczDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTcz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateTcz(edbInfoId, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateTcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS { //N数值移动平均计算
|
|
|
- fmt.Println("刷新计算指标:", edbInfoId)
|
|
|
- calculateNszydpjjs, err := data_manage.GetEdbInfoCalculateNszydpjjsDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateNszydpjjs.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- err = data_manage.RefreshCalculateNszydpjjs(edbInfoId, edbInfo.Source, formulaInt, fromEdbInfo, calculateNszydpjjs.EdbCode)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateNszydpjjs Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_HBZ { //刷新环比值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateHbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateHbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateHbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_HCZ { //刷新环差值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateHczDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateHcz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateHcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_BP { //刷新同比值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateBpDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateBpDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = time.Now().AddDate(-1, -2, 0).Format(utils.FormatDate)
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshCalculateBp(edbInfoId, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateBp Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if maxAndMinItem != nil {
|
|
|
- err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return err
|
|
|
-}
|
|
|
-
|
|
|
-//全部刷新指标
|
|
|
-func EdbInfoRefreshAllFromBase(edbInfoId int) (err error) {
|
|
|
- var errmsg string
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println("EdbInfoRefreshAllFromBase Err:" + err.Error() + ";errmsg:" + errmsg)
|
|
|
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "EdbInfoRefreshFromBase:"+errmsg, utils.EmailSendToUsers)
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- calculateList, err := data_manage.GetEdbInfoAllCalculate(edbInfoId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- return errors.New("GetEdbInfoAllCalculate Err:" + err.Error())
|
|
|
- }
|
|
|
- baseEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
- calculateInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
- baseEdbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- return errors.New("GetEdbInfoAllCalGetEdbInfoByIdr:" + err.Error())
|
|
|
- }
|
|
|
- baseEdbInfoArr = append(baseEdbInfoArr, baseEdbInfo)
|
|
|
-
|
|
|
- switch baseEdbInfo.EdbType {
|
|
|
- case 1: //基础指标
|
|
|
- baseEdbInfoArr = append(baseEdbInfoArr, baseEdbInfo)
|
|
|
- case 2: //计算指标
|
|
|
- calculateList = append(calculateList, baseEdbInfo)
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- for _, v := range calculateList {
|
|
|
- getBaseEdbInfoArr, getCalculateInfoArr, err := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("GetRefreshEdbInfoFromBase err:" + err.Error())
|
|
|
- errmsg = "获取需要刷新的指标失败:Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- baseEdbInfoArr = append(baseEdbInfoArr, getBaseEdbInfoArr...)
|
|
|
- calculateInfoArr = append(calculateInfoArr, getCalculateInfoArr...)
|
|
|
- calculateInfoArr = append(calculateInfoArr, v)
|
|
|
- }
|
|
|
- //取重
|
|
|
- newBaseEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
- baseMap := make(map[int]int)
|
|
|
- for _, v := range baseEdbInfoArr {
|
|
|
- if _, ok := baseMap[v.EdbInfoId]; !ok {
|
|
|
- newBaseEdbInfoArr = append(newBaseEdbInfoArr, v)
|
|
|
- }
|
|
|
- baseMap[v.EdbInfoId] = v.EdbInfoId
|
|
|
- }
|
|
|
-
|
|
|
- var calculateArr []int
|
|
|
- newCalculateMap := make(map[int]*data_manage.EdbInfo)
|
|
|
- for _, v := range calculateInfoArr {
|
|
|
- if _, ok := newCalculateMap[v.EdbInfoId]; !ok {
|
|
|
- calculateArr = append(calculateArr, v.EdbInfoId)
|
|
|
- }
|
|
|
- newCalculateMap[v.EdbInfoId] = v
|
|
|
- }
|
|
|
- sort.Ints(calculateArr)
|
|
|
- var startDate string
|
|
|
- for _, bv := range newBaseEdbInfoArr {
|
|
|
- source := bv.Source
|
|
|
- edbInfoId := bv.EdbInfoId
|
|
|
- edbCode := bv.EdbCode
|
|
|
-
|
|
|
- sTime, err := time.Parse(utils.FormatDate, bv.StartDate)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = sTime.Format(utils.FormatDate)
|
|
|
-
|
|
|
- if source == utils.DATA_SOURCE_THS {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByThs(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByThs Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_WIND {
|
|
|
- endDate := time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByWind(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByWind Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_PB {
|
|
|
- startDate := sTime.Format(utils.FormatDateUnSpace)
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
- err = data_manage.RefreshAllEdbDataByPb(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByPb Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_MANUAL {
|
|
|
- err = data_manage.RefreshAllEdbDataByManual(edbInfoId, source, edbCode)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByManual Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_LZ {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByLz(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByLz Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_YS {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByYs(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByYs Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_GL {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByGl(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByGl Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_ZZ {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByZz(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByZz Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_DL {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByDl(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByDl Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_SH {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataBySh(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataBySh Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CFFEX {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByCffex(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByCffex Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_SHFE {
|
|
|
- endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByShfe(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByShfe Err:" + err.Error()
|
|
|
- }
|
|
|
- }else if source == utils.DATA_SOURCE_LT {
|
|
|
- endDate := time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllEdbDataByLt(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllEdbDataByLT Err:" + err.Error()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if maxAndMinItem != nil {
|
|
|
- err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- fmt.Println("end newBaseEdbInfoArr:", bv, time.Now())
|
|
|
- }
|
|
|
-
|
|
|
- endDate := "" //计算指标不限制日期
|
|
|
- //刷新相关计算指标
|
|
|
- for _, v := range calculateArr {
|
|
|
- edbInfo := newCalculateMap[v]
|
|
|
- if edbInfo == nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- edbInfoId := edbInfo.EdbInfoId
|
|
|
- source := edbInfo.Source
|
|
|
- edbCode := edbInfo.EdbCode
|
|
|
-
|
|
|
- if source == utils.DATA_SOURCE_CALCULATE {
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- sTime, err := time.Parse(utils.FormatDate, edbInfo.EndDate)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = sTime.Format(utils.FormatDate)
|
|
|
-
|
|
|
- var edbInfoIdBytes []string
|
|
|
- calculateMap, err := data_manage.GetEdbInfoCalculateDetail(edbInfoId, edbInfo.Source)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- var formulaStr string
|
|
|
- edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
|
-
|
|
|
- for _, v := range calculateMap {
|
|
|
- formulaStr += v.FromTag + ","
|
|
|
- edbInfoIdBytes = append(edbInfoIdBytes, v.FromTag)
|
|
|
- edbInfo, _ := data_manage.GetEdbInfoById(v.FromEdbInfoId)
|
|
|
- edbInfoList = append(edbInfoList, edbInfo)
|
|
|
- }
|
|
|
- err = data_manage.RefreshAllCalculate(edbInfoList, int(edbInfoId), source, edbInfo.EdbCode, edbInfo.CalculateFormula, startDate, endDate, edbInfoIdBytes)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculate Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_LJZZY { //刷新累计值转月值
|
|
|
- calculateLjzzy, err := data_manage.GetEdbInfoCalculateLjzzyDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateLjzzyDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateLjzzy.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllCalculateLjzzy(edbInfoId, source, fromEdbInfo, calculateLjzzy.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateLjzzy Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_TBZ { //刷新同比值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateTbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllCalculateTbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateTbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_TCZ { //同差值
|
|
|
- calculateTcz, err := data_manage.GetEdbInfoCalculateTczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTczDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTcz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllCalculateTcz(edbInfoId, source, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateTcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS { //N数值移动平均计算
|
|
|
- calculateNszydpjjs, err := data_manage.GetEdbInfoCalculateNszydpjjsDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateNszydpjjs.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- err = data_manage.RefreshAllCalculateNszydpjjs(edbInfoId, edbInfo.Source, formulaInt, fromEdbInfo, calculateNszydpjjs.EdbCode, startDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshCalculateNszydpjjs Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_HBZ { //刷新环比值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHbzDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateHbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- err = data_manage.RefreshAllCalculateHbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateHbz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_HCZ { //刷新环差值
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateHczDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateHczDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- err = data_manage.RefreshAllCalculateHcz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateHcz Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_BP { //刷新变频
|
|
|
- calculateTbz, err := data_manage.GetEdbInfoCalculateBpDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = data_manage.RefreshAllCalculateBp(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateBp Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_TIME_SHIFT {
|
|
|
- calculate, err := data_manage.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- fromEdbInfo, err := data_manage.GetEdbInfoById(calculate.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- formulaInt, _ := strconv.Atoi(calculate.CalculateFormula)
|
|
|
- err = data_manage.RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, calculate.MoveType, fromEdbInfo, calculate.EdbCode, startDate, endDate, calculate.MoveFrequency)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateTimeShift Err:" + err.Error()
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_ZJPJ { //刷新直接拼接
|
|
|
- err = data_manage.RefreshAllCalculateZjpj(edbInfo)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateZjpj Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- } else if source == utils.DATA_SOURCE_CALCULATE_LJZTBPJ { //刷新累计值同比拼接
|
|
|
- err = data_manage.RefreshAllCalculateLjztbpj(edbInfo)
|
|
|
- if err != nil {
|
|
|
- errmsg = "RefreshAllCalculateLjztbpj Err:" + err.Error()
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
-
|
|
|
- if maxAndMinItem != nil {
|
|
|
- err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- }
|
|
|
- fmt.Println("end calculateArr:", v, time.Now())
|
|
|
- }
|
|
|
- return err
|
|
|
-}
|
|
|
-
|
|
|
-// AddEdbInfo 新增手工指标数据
|
|
|
-func AddEdbInfo(secName, unit, frequency, noticeTime, mobile string, classifyId, userId int) (err error) {
|
|
|
- tradeCode, err := models.GetMaxTradeCode()
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if tradeCode == "" {
|
|
|
- err = errors.New("最大编码为空")
|
|
|
- return
|
|
|
- }
|
|
|
- maxTradeCode, err := utils.GetMaxTradeCode(tradeCode)
|
|
|
- if err != nil {
|
|
|
- err = errors.New("获取编码信息失败,Err:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if maxTradeCode == "" {
|
|
|
- err = errors.New("编码为空,请联系技术")
|
|
|
- return
|
|
|
- }
|
|
|
- //判断指标名称是否为空
|
|
|
- if secName == "" {
|
|
|
- err = errors.New("指标名称不能为空")
|
|
|
- return
|
|
|
- }
|
|
|
- item, err := models.GetEdbinfoBySecName(secName)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- err = errors.New("获取信息失败,Err:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if item != nil {
|
|
|
- err = errors.New("指标名称已存在")
|
|
|
- return
|
|
|
- }
|
|
|
- err = models.AddEdbinfo(maxTradeCode, secName, unit, "手动", frequency, noticeTime, classifyId, userId)
|
|
|
- if err != nil {
|
|
|
- err = errors.New("新增失败,Err:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- err = models.AddEdbinfoUser(maxTradeCode, mobile)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-//全部刷新指标
|
|
|
-//func EdbInfoRefreshAllFromBase(edbInfoId int) (err error) {
|
|
|
-// var errmsg string
|
|
|
-// defer func() {
|
|
|
-// if err != nil {
|
|
|
-// fmt.Println("EdbInfoRefreshAllFromBase Err:" + err.Error() + ";errmsg:" + errmsg)
|
|
|
-// go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "EdbInfoRefreshFromBase:"+errmsg, utils.EmailSendToUsers)
|
|
|
-// }
|
|
|
-// }()
|
|
|
-//
|
|
|
-// calculateList, err := data_manage.GetEdbInfoAllCalculate(edbInfoId)
|
|
|
-// if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
-// return errors.New("GetEdbInfoAllCalculate Err:" + err.Error())
|
|
|
-// }
|
|
|
-// baseEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
-// calculateInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
-// baseEdbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// return errors.New("GetEdbInfoAllCalGetEdbInfoByIdr:" + err.Error())
|
|
|
-// }
|
|
|
-// baseEdbInfoArr = append(baseEdbInfoArr, baseEdbInfo)
|
|
|
-//
|
|
|
-// for _, v := range calculateList {
|
|
|
-// getBaseEdbInfoArr, getCalculateInfoArr, err := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
-// if err != nil {
|
|
|
-// fmt.Println("GetRefreshEdbInfoFromBase err:" + err.Error())
|
|
|
-// errmsg = "获取需要刷新的指标失败:Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// baseEdbInfoArr = append(baseEdbInfoArr, getBaseEdbInfoArr...)
|
|
|
-// calculateInfoArr = append(calculateInfoArr, getCalculateInfoArr...)
|
|
|
-// calculateInfoArr = append(calculateInfoArr, v)
|
|
|
-// }
|
|
|
-// //取重
|
|
|
-// newBaseEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
-// baseMap := make(map[int]int)
|
|
|
-// for _, v := range baseEdbInfoArr {
|
|
|
-// if _, ok := baseMap[v.EdbInfoId]; !ok {
|
|
|
-// newBaseEdbInfoArr = append(newBaseEdbInfoArr, v)
|
|
|
-// }
|
|
|
-// baseMap[v.EdbInfoId] = v.EdbInfoId
|
|
|
-// }
|
|
|
-//
|
|
|
-// var calculateArr []int
|
|
|
-// newCalculateMap := make(map[int]*data_manage.EdbInfo)
|
|
|
-// for _, v := range calculateInfoArr {
|
|
|
-// if _, ok := newCalculateMap[v.EdbInfoId]; !ok {
|
|
|
-// calculateArr = append(calculateArr, v.EdbInfoId)
|
|
|
-// }
|
|
|
-// newCalculateMap[v.EdbInfoId] = v
|
|
|
-// }
|
|
|
-// sort.Ints(calculateArr)
|
|
|
-// var startDate string
|
|
|
-// for _, bv := range newBaseEdbInfoArr {
|
|
|
-// source := bv.Source
|
|
|
-// edbInfoId := bv.EdbInfoId
|
|
|
-// edbCode := bv.EdbCode
|
|
|
-//
|
|
|
-// sTime, err := time.Parse(utils.FormatDate, bv.StartDate)
|
|
|
-// if err != nil {
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = sTime.Format(utils.FormatDate)
|
|
|
-//
|
|
|
-// if source == utils.DATA_SOURCE_THS {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByThs(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByThs Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_WIND {
|
|
|
-// endDate := time.Now().Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByWind(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByWind Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_PB {
|
|
|
-// startDate := sTime.Format(utils.FormatDateUnSpace)
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDateUnSpace)
|
|
|
-// err = data_manage.RefreshAllEdbDataByPb(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByPb Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_MANUAL {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByManual(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByManual Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_LZ {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByLz(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByLz Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_YS {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByYs(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByYs Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_GL {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByGl(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByGl Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_ZZ {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByZz(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByZz Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_DL {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByDl(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByDl Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_SH {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataBySh(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataBySh Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CFFEX {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByCffex(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByCffex Err:" + err.Error()
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_SHFE {
|
|
|
-// endDate := time.Now().AddDate(utils.DATA_END_DATE_LIMIT, 0, 0).Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllEdbDataByShfe(edbInfoId, source, edbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllEdbDataByShfe Err:" + err.Error()
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
-// if err != nil {
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// if maxAndMinItem != nil {
|
|
|
-// err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
-// if err != nil {
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// }
|
|
|
-// fmt.Println("end newBaseEdbInfoArr:", bv, time.Now())
|
|
|
-// }
|
|
|
-//
|
|
|
-// endDate := "" //计算指标不限制日期
|
|
|
-// //刷新相关计算指标
|
|
|
-// for _, v := range calculateArr {
|
|
|
-// edbInfo := newCalculateMap[v]
|
|
|
-// if edbInfo == nil {
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// edbInfoId := edbInfo.EdbInfoId
|
|
|
-// source := edbInfo.Source
|
|
|
-// edbCode := edbInfo.EdbCode
|
|
|
-//
|
|
|
-// if source == utils.DATA_SOURCE_CALCULATE {
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// sTime, err := time.Parse(utils.FormatDate, edbInfo.EndDate)
|
|
|
-// if err != nil {
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = sTime.Format(utils.FormatDate)
|
|
|
-//
|
|
|
-// var edbInfoIdBytes []string
|
|
|
-// calculateMap, err := data_manage.GetEdbInfoCalculateDetail(edbInfoId, edbInfo.Source)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// var formulaStr string
|
|
|
-// edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
|
-//
|
|
|
-// for _, v := range calculateMap {
|
|
|
-// formulaStr += v.FromTag + ","
|
|
|
-// edbInfoIdBytes = append(edbInfoIdBytes, v.FromTag)
|
|
|
-// edbInfo, _ := data_manage.GetEdbInfoById(v.FromEdbInfoId)
|
|
|
-// edbInfoList = append(edbInfoList, edbInfo)
|
|
|
-// }
|
|
|
-// err = data_manage.RefreshAllCalculate(edbInfoList, int(edbInfoId), source, edbInfo.EdbCode, edbInfo.CalculateFormula, startDate, endDate, edbInfoIdBytes)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshCalculate Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_LJZZY { //刷新累计值转月值
|
|
|
-// calculateLjzzy, err := data_manage.GetEdbInfoCalculateLjzzyDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateLjzzyDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculateLjzzy.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// endDate = time.Now().Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllCalculateLjzzy(edbInfoId, source, fromEdbInfo, calculateLjzzy.EdbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllCalculateLjzzy Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_TBZ { //刷新同比值
|
|
|
-// calculateTbz, err := data_manage.GetEdbInfoCalculateTbzDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// endDate = time.Now().Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllCalculateTbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllCalculateTbz Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_TCZ { //同差值
|
|
|
-// calculateTcz, err := data_manage.GetEdbInfoCalculateTczDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateTczDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTcz.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// endDate = time.Now().Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllCalculateTcz(edbInfoId, source, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshCalculateTcz Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS { //N数值移动平均计算
|
|
|
-// calculateNszydpjjs, err := data_manage.GetEdbInfoCalculateNszydpjjsDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculateNszydpjjs.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// err = data_manage.RefreshAllCalculateNszydpjjs(edbInfoId, edbInfo.Source, formulaInt, fromEdbInfo, calculateNszydpjjs.EdbCode, startDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshCalculateNszydpjjs Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_HBZ { //刷新环比值
|
|
|
-// calculateTbz, err := data_manage.GetEdbInfoCalculateHbzDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateHbzDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// endDate = time.Now().Format(utils.FormatDate)
|
|
|
-// formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
-// err = data_manage.RefreshAllCalculateHbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllCalculateHbz Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_HCZ { //刷新环差值
|
|
|
-// calculateTbz, err := data_manage.GetEdbInfoCalculateHczDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateHczDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// endDate = time.Now().Format(utils.FormatDate)
|
|
|
-// formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
-// err = data_manage.RefreshAllCalculateHcz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllCalculateHcz Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_BP { //刷新变频
|
|
|
-// calculateTbz, err := data_manage.GetEdbInfoCalculateBpDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// endDate = time.Now().Format(utils.FormatDate)
|
|
|
-// err = data_manage.RefreshAllCalculateBp(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllCalculateBp Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-//<<<<<<< HEAD
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_TIME_SHIFT {
|
|
|
-// calculate, err := data_manage.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// fromEdbInfo, err := data_manage.GetEdbInfoById(calculate.FromEdbInfoId)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// startDate = edbInfo.StartDate
|
|
|
-// endDate = time.Now().Format(utils.FormatDate)
|
|
|
-// formulaInt, _ := strconv.Atoi(calculate.CalculateFormula)
|
|
|
-// err = data_manage.RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, calculate.MoveType, fromEdbInfo, calculate.EdbCode, startDate, endDate, calculate.MoveFrequency)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllCalculateTimeShift Err:" + err.Error()
|
|
|
-//=======
|
|
|
-// } else if source == utils.DATA_SOURCE_CALCULATE_ZJPJ { //刷新直接拼接
|
|
|
-// err = data_manage.RefreshAllCalculateZjpj(edbInfo)
|
|
|
-// if err != nil {
|
|
|
-// errmsg = "RefreshAllCalculateBp Err:" + err.Error()
|
|
|
-//>>>>>>> 884fd669cc9e91923781680e1890a519c012d38e
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// maxAndMinItem, err := data_manage.GetEdbInfoMaxAndMinInfo(source, edbCode)
|
|
|
-// if err != nil {
|
|
|
-// return err
|
|
|
-// }
|
|
|
-//
|
|
|
-// if maxAndMinItem != nil {
|
|
|
-// err = data_manage.ModifyEdbInfoMaxAndMinInfo(edbInfoId, maxAndMinItem)
|
|
|
-// if err != nil {
|
|
|
-// return err
|
|
|
-// }
|
|
|
-// }
|
|
|
-// fmt.Println("end calculateArr:", v, time.Now())
|
|
|
-// }
|
|
|
-// return err
|
|
|
-//}
|
|
|
-//
|
|
|
-//// AddEdbInfo 新增手工指标数据
|
|
|
-//func AddEdbInfo(secName, unit, frequency, noticeTime, mobile string, classifyId, userId int) (err error) {
|
|
|
-// tradeCode, err := models.GetMaxTradeCode()
|
|
|
-// if err != nil {
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if tradeCode == "" {
|
|
|
-// err = errors.New("最大编码为空")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// maxTradeCode, err := utils.GetMaxTradeCode(tradeCode)
|
|
|
-// if err != nil {
|
|
|
-// err = errors.New("获取编码信息失败,Err:" + err.Error())
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if maxTradeCode == "" {
|
|
|
-// err = errors.New("编码为空,请联系技术")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// //判断指标名称是否为空
|
|
|
-// if secName == "" {
|
|
|
-// err = errors.New("指标名称不能为空")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// item, err := models.GetEdbinfoBySecName(secName)
|
|
|
-// if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
-// err = errors.New("获取信息失败,Err:" + err.Error())
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if item != nil {
|
|
|
-// err = errors.New("指标名称已存在")
|
|
|
-// return
|
|
|
-// }
|
|
|
-// err = models.AddEdbinfo(maxTradeCode, secName, unit, "手动", frequency, noticeTime, classifyId, userId)
|
|
|
-// if err != nil {
|
|
|
-// err = errors.New("新增失败,Err:" + err.Error())
|
|
|
-// return
|
|
|
-// }
|
|
|
-// err = models.AddEdbinfoUser(maxTradeCode, mobile)
|
|
|
-// return
|
|
|
-//}
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|