|
@@ -46,7 +46,6 @@ func EdbInfoRefreshAllFromBaseV3Bak(edbInfoIdList []int, refreshAll, isSync bool
|
|
|
if err != nil {
|
|
|
fmt.Println("EdbInfoRefreshAllFromBaseV2 Err:" + err.Error() + ";errmsg:" + errmsg)
|
|
|
go alarm_msg.SendAlarmMsg("EdbInfoRefreshFromBaseV2,Err"+err.Error()+";errMsg:"+errmsg, 3)
|
|
|
- //go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "EdbInfoRefreshFromBase:"+errmsg, utils.EmailSendToUsers)
|
|
|
}
|
|
|
}()
|
|
|
|
|
@@ -237,7 +236,7 @@ func getRefreshEdbInfoListByTraceEdbInfo(traceEdbInfo data_manage.TraceEdbInfoRe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if traceEdbInfo.Child != nil && len(traceEdbInfo.Child) > 0 {
|
|
|
+ if len(traceEdbInfo.Child) > 0 {
|
|
|
for _, v := range traceEdbInfo.Child {
|
|
|
tmpBaseEdbInfoArr, tmpPredictEdbInfoArr, tmpCalculateMap, tmpPredictCalculateMap, tmpCalculateArr, tmpPredictCalculateArr := getRefreshEdbInfoListByTraceEdbInfo(v, existEdbInfoIdMap)
|
|
|
|
|
@@ -2225,7 +2224,7 @@ func getEdbRuleTitle(edbInfo, parentEdbInfo *data_manage.EdbInfo, childList []da
|
|
|
// 规则
|
|
|
switch edbInfo.Source {
|
|
|
case utils.DATA_SOURCE_CALCULATE, utils.DATA_SOURCE_PREDICT_CALCULATE:
|
|
|
- ruleTitle = "=" + edbInfo.CalculateFormula
|
|
|
+ ruleTitle = formatCalculateFormula(edbInfo.CalculateFormula)
|
|
|
case utils.DATA_SOURCE_CALCULATE_LJZZY, utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZY:
|
|
|
ruleTitle = `累计转月值计算`
|
|
|
ruleTitleEn = `Cumulative to Monthly Calculation`
|
|
@@ -2259,7 +2258,6 @@ func getEdbRuleTitle(edbInfo, parentEdbInfo *data_manage.EdbInfo, childList []da
|
|
|
if childEdbInfo, ok := edbInfoMap[childList[0].EdbInfoId]; ok {
|
|
|
childFrequency = childEdbInfo.Frequency
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
ruleTitle = fmt.Sprintf("升频计算(%s转%s)", childFrequency, edbInfo.Frequency)
|
|
|
ruleTitleEn = fmt.Sprintf("Upsampling Calculation(%s转%s)", childFrequency, edbInfo.Frequency)
|
|
@@ -2397,6 +2395,73 @@ func getEdbRuleTitle(edbInfo, parentEdbInfo *data_manage.EdbInfo, childList []da
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func formatCalculateFormula(calculateFormula string) (ruleTitle string) {
|
|
|
+ var tmpCalculateFormula []map[string]string
|
|
|
+ if e := json.Unmarshal([]byte(calculateFormula), &tmpCalculateFormula); e != nil {
|
|
|
+ ruleTitle = "=" + calculateFormula
|
|
|
+ return
|
|
|
+ }
|
|
|
+ newCalculateFormula := make([]map[string]string, 0)
|
|
|
+ sort.Slice(tmpCalculateFormula, func(i, j int) bool {
|
|
|
+ return compareDates(tmpCalculateFormula[i]["d"], tmpCalculateFormula[j]["d"])
|
|
|
+ })
|
|
|
+
|
|
|
+ for i, entry := range tmpCalculateFormula {
|
|
|
+ if formula, ok := entry["f"]; ok {
|
|
|
+ singleFormula := make(map[string]string)
|
|
|
+ singleFormula["公式"] = formula
|
|
|
+ singleFormula["日期"] = determineDateRange(i, len(tmpCalculateFormula), tmpCalculateFormula)
|
|
|
+ newCalculateFormula = append(newCalculateFormula, singleFormula)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if b, e := json.Marshal(newCalculateFormula); e != nil {
|
|
|
+ ruleTitle = "=" + calculateFormula
|
|
|
+ } else {
|
|
|
+ ruleTitle = "=" + string(b)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// compareDates 日期比较 date1 < date2 --> true
|
|
|
+func compareDates(date1, date2 string) bool {
|
|
|
+ if date1 == "" {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ if date2 == "" {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ date1Parsed, err := time.Parse(utils.FormatDate, date1)
|
|
|
+ if err != nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ date2Parsed, err := time.Parse(utils.FormatDate, date2)
|
|
|
+ if err != nil {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return date1Parsed.Before(date2Parsed)
|
|
|
+}
|
|
|
+
|
|
|
+func determineDateRange(index, totalLength int, formulas []map[string]string) string {
|
|
|
+ if totalLength == 1 {
|
|
|
+ return "全部"
|
|
|
+ }
|
|
|
+
|
|
|
+ currentDate := formulas[index]["d"]
|
|
|
+ if index == 0 {
|
|
|
+ return formulas[totalLength-1]["d"] + "(含)之后"
|
|
|
+ }
|
|
|
+ if index == totalLength-1 {
|
|
|
+ return formulas[1]["d"] + "之前"
|
|
|
+ }
|
|
|
+ if index >= 1 && index < totalLength-1 {
|
|
|
+ return fmt.Sprintf("%s(含)——%s", currentDate, formulas[index+1]["d"])
|
|
|
+ }
|
|
|
+ return ""
|
|
|
+}
|
|
|
+
|
|
|
// GetEdbChartAdminList
|
|
|
// @param source 来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
|
|
|
func GetEdbChartAdminList(source int) (list []int, err error) {
|