|
@@ -1183,268 +1183,271 @@ func (this *CalculateController) Refresh() {
|
|
|
}
|
|
|
|
|
|
cacheKey = utils.CACHE_EDB_DATA_REFRESH + strconv.Itoa(edbInfo.Source) + "_" + req.EdbCode
|
|
|
- if !utils.Rc.IsExist(cacheKey) {
|
|
|
- utils.Rc.SetNX(cacheKey, 1, 1*time.Minute)
|
|
|
- defer func() {
|
|
|
- utils.Rc.Delete(cacheKey)
|
|
|
- }()
|
|
|
|
|
|
- startDate := req.StartDate
|
|
|
- var errMsg string
|
|
|
- endDate := time.Now().Format(utils.FormatDate)
|
|
|
- edbInfoId := edbInfo.EdbInfoId
|
|
|
- source := edbInfo.Source
|
|
|
-
|
|
|
- switch source {
|
|
|
- case utils.DATA_SOURCE_CALCULATE:
|
|
|
- //startDate = edbInfo.StartDate
|
|
|
- //sTime, err := time.Parse(utils.FormatDate, edbInfo.EndDate)
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //startDate = sTime.Format(utils.FormatDate)
|
|
|
- startDate = ""
|
|
|
- var edbInfoIdBytes []string
|
|
|
- calculateMap, err := models.GetEdbInfoCalculateDetailList(edbInfo.EdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- var formulaStr string
|
|
|
- edbInfoList := make([]*models.EdbInfo, 0)
|
|
|
-
|
|
|
- for _, v := range calculateMap {
|
|
|
- formulaStr += v.FromTag + ","
|
|
|
- edbInfoIdBytes = append(edbInfoIdBytes, v.FromTag)
|
|
|
- edbInfo, _ := models.GetEdbInfoById(v.FromEdbInfoId)
|
|
|
- edbInfoList = append(edbInfoList, edbInfo)
|
|
|
- }
|
|
|
- err = models.RefreshAllCalculate(edbInfoList, edbInfo.EdbInfoId, source, edbInfo.EdbCode, edbInfo.CalculateFormula, startDate, endDate, edbInfoIdBytes)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshCalculate Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_LJZZY: //刷新累计值转月值
|
|
|
- calculateLjzzy, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateLjzzyDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateLjzzy.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = models.RefreshAllCalculateLjzzy(edbInfoId, source, fromEdbInfo, calculateLjzzy.EdbCode, startDate, endDate)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateLjzzy Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_TBZ: //刷新同比值
|
|
|
- calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = models.RefreshAllCalculateTbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateTbz Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_TCZ: //同差值
|
|
|
- calculateTcz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateTczDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateTcz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = models.RefreshAllCalculateTcz(edbInfoId, source, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshCalculateTcz Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS: //N数值移动平均计算
|
|
|
- calculateNszydpjjs, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateNszydpjjs.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- err = models.RefreshAllCalculateNszydpjjs(edbInfoId, edbInfo.Source, formulaInt, fromEdbInfo, calculateNszydpjjs.EdbCode, startDate)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshCalculateNszydpjjs Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_HBZ: //刷新环比值
|
|
|
- calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateHbzDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- err = models.RefreshAllCalculateHbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateHbz Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_HCZ: //刷新环差值
|
|
|
- calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateHczDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- err = models.RefreshAllCalculateHcz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateHcz Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_BP: //刷新变频
|
|
|
- calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- err = models.RefreshAllCalculateBp(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateBp Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_TIME_SHIFT:
|
|
|
- calculate, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculate.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- formulaInt, _ := strconv.Atoi(calculate.CalculateFormula)
|
|
|
- err = models.RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, calculate.MoveType, fromEdbInfo, calculate.EdbCode, startDate, endDate, calculate.MoveFrequency)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateTimeShift Err:" + err.Error()
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_ZJPJ: //刷新直接拼接
|
|
|
- err = models.RefreshAllCalculateZjpj(edbInfo)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateZjpj Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_LJZTBPJ: //刷新累计值同比拼接
|
|
|
- err = models.RefreshAllCalculateLjztbpj(edbInfo)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateLjztbpj Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_PYTHON: //python代码运算
|
|
|
- edbPythonCode, err := models.GetEdbPythonCodeById(edbInfo.EdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "获取python代码失败 Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- edbData, err, errMsg := services.ExecPythonCode(edbInfo.EdbCode, edbPythonCode.PythonCode)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取数据失败"
|
|
|
- br.ErrMsg = "python代码获取数据失败,err:" + err.Error()
|
|
|
- if errMsg != "" {
|
|
|
- br.ErrMsg = errMsg
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
- err = models.RefreshAllPythonEdb(edbInfo, edbData)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllPythonEdb Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- case utils.DATA_SOURCE_CALCULATE_CJJX: //超季节性
|
|
|
- calculateCjjx, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(calculateCjjx.FromEdbInfoId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
- formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
- startDate = edbInfo.StartDate
|
|
|
- err = models.RefreshAllCalculateCjjx(edbInfoId, edbInfo.Source, fromEdbInfo, calculateCjjx.EdbCode, startDate, "", formulaInt)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "RefreshAllCalculateCjjx Err:" + err.Error()
|
|
|
- break
|
|
|
- }
|
|
|
+ if utils.Rc.IsExist(cacheKey) {
|
|
|
+ br.Ret = 501
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "系统处理中,请稍后重试"
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- default:
|
|
|
- br.Msg = "来源异常,请联系相关开发!"
|
|
|
- br.ErrMsg = "来源异常,请联系相关开发"
|
|
|
- return
|
|
|
- }
|
|
|
- if errMsg != `` {
|
|
|
- br.Msg = "刷新指标失败!"
|
|
|
- br.ErrMsg = "刷新指标失败,err:" + errMsg
|
|
|
- return
|
|
|
+ // 刷新指标
|
|
|
+ utils.Rc.SetNX(cacheKey, 1, 1*time.Minute)
|
|
|
+ defer func() {
|
|
|
+ utils.Rc.Delete(cacheKey)
|
|
|
+ }()
|
|
|
+
|
|
|
+ startDate := req.StartDate
|
|
|
+ var errMsg string
|
|
|
+ endDate := time.Now().Format(utils.FormatDate)
|
|
|
+ edbInfoId := edbInfo.EdbInfoId
|
|
|
+ source := edbInfo.Source
|
|
|
+
|
|
|
+ switch source {
|
|
|
+ case utils.DATA_SOURCE_CALCULATE:
|
|
|
+ //startDate = edbInfo.StartDate
|
|
|
+ //sTime, err := time.Parse(utils.FormatDate, edbInfo.EndDate)
|
|
|
+ //if err != nil {
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //startDate = sTime.Format(utils.FormatDate)
|
|
|
+ startDate = ""
|
|
|
+ var edbInfoIdBytes []string
|
|
|
+ calculateMap, err := models.GetEdbInfoCalculateDetailList(edbInfo.EdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
}
|
|
|
+ var formulaStr string
|
|
|
+ edbInfoList := make([]*models.EdbInfo, 0)
|
|
|
|
|
|
- // 更新指标最大最小值
|
|
|
- err, errMsg := models.UnifiedModifyEdbInfoMaxAndMinInfo(edbInfo)
|
|
|
+ for _, v := range calculateMap {
|
|
|
+ formulaStr += v.FromTag + ","
|
|
|
+ edbInfoIdBytes = append(edbInfoIdBytes, v.FromTag)
|
|
|
+ edbInfo, _ := models.GetEdbInfoById(v.FromEdbInfoId)
|
|
|
+ edbInfoList = append(edbInfoList, edbInfo)
|
|
|
+ }
|
|
|
+ err = models.RefreshAllCalculate(edbInfoList, edbInfo.EdbInfoId, source, edbInfo.EdbCode, edbInfo.CalculateFormula, startDate, endDate, edbInfoIdBytes)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshCalculate Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_LJZZY: //刷新累计值转月值
|
|
|
+ calculateLjzzy, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
if err != nil {
|
|
|
- br.Msg = errMsg
|
|
|
- br.ErrMsg = err.Error()
|
|
|
+ errMsg = "GetEdbInfoCalculateLjzzyDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateLjzzy.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ err = models.RefreshAllCalculateLjzzy(edbInfoId, source, fromEdbInfo, calculateLjzzy.EdbCode, startDate, endDate)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateLjzzy Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TBZ: //刷新同比值
|
|
|
+ calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ err = models.RefreshAllCalculateTbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateTbz Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TCZ: //同差值
|
|
|
+ calculateTcz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateTczDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateTcz.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ err = models.RefreshAllCalculateTcz(edbInfoId, source, fromEdbInfo, calculateTcz.EdbCode, startDate, endDate)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshCalculateTcz Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS: //N数值移动平均计算
|
|
|
+ calculateNszydpjjs, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateNszydpjjs.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ err = models.RefreshAllCalculateNszydpjjs(edbInfoId, edbInfo.Source, formulaInt, fromEdbInfo, calculateNszydpjjs.EdbCode, startDate)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshCalculateNszydpjjs Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_HBZ: //刷新环比值
|
|
|
+ calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateHbzDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
+ err = models.RefreshAllCalculateHbz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateHbz Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_HCZ: //刷新环差值
|
|
|
+ calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateHczDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
+ err = models.RefreshAllCalculateHcz(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate, formulaInt)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateHcz Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_BP: //刷新变频
|
|
|
+ calculateTbz, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateTbz.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ err = models.RefreshAllCalculateBp(edbInfoId, source, fromEdbInfo, calculateTbz.EdbCode, startDate, endDate)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateBp Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TIME_SHIFT:
|
|
|
+ calculate, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateTbzDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculate.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ formulaInt, _ := strconv.Atoi(calculate.CalculateFormula)
|
|
|
+ err = models.RefreshAllCalculateTimeShift(edbInfoId, source, formulaInt, calculate.MoveType, fromEdbInfo, calculate.EdbCode, startDate, endDate, calculate.MoveFrequency)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateTimeShift Err:" + err.Error()
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_ZJPJ: //刷新直接拼接
|
|
|
+ err = models.RefreshAllCalculateZjpj(edbInfo)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateZjpj Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_LJZTBPJ: //刷新累计值同比拼接
|
|
|
+ err = models.RefreshAllCalculateLjztbpj(edbInfo)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateLjztbpj Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_PYTHON: //python代码运算
|
|
|
+ edbPythonCode, err := models.GetEdbPythonCodeById(edbInfo.EdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "获取python代码失败 Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ edbData, err, errMsg := services.ExecPythonCode(edbInfo.EdbCode, edbPythonCode.PythonCode)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取数据失败"
|
|
|
+ br.ErrMsg = "python代码获取数据失败,err:" + err.Error()
|
|
|
+ if errMsg != "" {
|
|
|
+ br.ErrMsg = errMsg
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "获取成功"
|
|
|
- } else {
|
|
|
- br.Ret = 501
|
|
|
- br.Success = true
|
|
|
- br.Msg = "系统处理中,请稍后重试"
|
|
|
+ err = models.RefreshAllPythonEdb(edbInfo, edbData)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllPythonEdb Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_CJJX: //超季节性
|
|
|
+ calculateCjjx, err := models.GetEdbInfoCalculateMappingDetail(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoCalculateNszydpjjsDetail Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(calculateCjjx.FromEdbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "GetEdbInfoById Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+ formulaInt, _ := strconv.Atoi(edbInfo.CalculateFormula)
|
|
|
+ startDate = edbInfo.StartDate
|
|
|
+ err = models.RefreshAllCalculateCjjx(edbInfoId, edbInfo.Source, fromEdbInfo, calculateCjjx.EdbCode, startDate, "", formulaInt)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ errMsg = "RefreshAllCalculateCjjx Err:" + err.Error()
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ default:
|
|
|
+ br.Msg = "来源异常,请联系相关开发!"
|
|
|
+ br.ErrMsg = "来源异常,请联系相关开发"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if errMsg != `` {
|
|
|
+ br.Msg = "刷新指标失败!"
|
|
|
+ br.ErrMsg = "刷新指标失败,err:" + errMsg
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新指标最大最小值
|
|
|
+ err, errMsg = models.UnifiedModifyEdbInfoMaxAndMinInfo(edbInfo)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = errMsg
|
|
|
+ br.ErrMsg = err.Error()
|
|
|
+ return
|
|
|
}
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
}
|