|
@@ -38,14 +38,14 @@ type EdbInfo struct {
|
|
|
NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"`
|
|
|
ServerUrl string `description:"服务器地址"`
|
|
|
|
|
|
- EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
|
|
|
- EdbNameEn string `description:"英文指标名称"`
|
|
|
- UnitEn string `description:"英文单位"`
|
|
|
- LatestDate string `description:"数据最新日期"`
|
|
|
- LatestValue float64 `description:"数据最新值"`
|
|
|
- ChartImage string `description:"图表图片"`
|
|
|
- Calendar string `description:"公历/农历"`
|
|
|
- DateType string `orm:"column(date_type);size(255);null;default(交易日)"`
|
|
|
+ EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"`
|
|
|
+ EdbNameEn string `description:"英文指标名称"`
|
|
|
+ UnitEn string `description:"英文单位"`
|
|
|
+ LatestDate string `description:"数据最新日期"`
|
|
|
+ LatestValue float64 `description:"数据最新值"`
|
|
|
+ ChartImage string `description:"图表图片"`
|
|
|
+ Calendar string `description:"公历/农历"`
|
|
|
+ DataDateType string `orm:"column(data_date_type);size(255);null;default(交易日)"`
|
|
|
}
|
|
|
|
|
|
// AddEdbInfo 添加指标
|
|
@@ -412,57 +412,8 @@ func UnifiedModifyPredictEdbInfoMaxAndMinInfo(edbInfo *EdbInfo, latestDateStr st
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetChartPredictEdbInfoDataList 获取图表的预测指标的未来数据
|
|
|
-func GetChartPredictEdbInfoDataList(predictEdbConf PredictEdbConf, latestDateStr string, lastDataValue float64, endDateStr, frequency string, order int) (predictEdbInfoData []*EdbInfoSearchData, err error) {
|
|
|
- endDate, err := time.ParseInLocation(utils.FormatDate, endDateStr, time.Local)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- latestDate, err := time.ParseInLocation(utils.FormatDate, latestDateStr, time.Local)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 开始预测数据的时间
|
|
|
- startDate := latestDate
|
|
|
-
|
|
|
- dataValue := lastDataValue
|
|
|
- if predictEdbConf.RuleType == 2 {
|
|
|
- dataValue = predictEdbConf.FixedValue
|
|
|
- }
|
|
|
- //获取后面的预测数据
|
|
|
- dayList := getPredictEdbDayList(startDate, endDate, frequency)
|
|
|
- predictEdbInfoData = make([]*EdbInfoSearchData, 0)
|
|
|
-
|
|
|
- // order:1升序,其余值为降序
|
|
|
- if order == 1 {
|
|
|
- for k, v := range dayList {
|
|
|
- predictEdbInfoData = append(predictEdbInfoData, &EdbInfoSearchData{
|
|
|
- EdbDataId: predictEdbConf.PredictEdbInfoId + 10000000000 + k,
|
|
|
- DataTime: v.Format(utils.FormatDate),
|
|
|
- Value: dataValue,
|
|
|
- })
|
|
|
- }
|
|
|
- } else {
|
|
|
- lenDayList := len(dayList)
|
|
|
- if lenDayList > 0 {
|
|
|
- for i := lenDayList - 1; i >= 0; i-- {
|
|
|
- v := dayList[i]
|
|
|
- predictEdbInfoData = append(predictEdbInfoData, &EdbInfoSearchData{
|
|
|
- EdbDataId: predictEdbConf.PredictEdbInfoId + 10000000000 + i,
|
|
|
- DataTime: v.Format(utils.FormatDate),
|
|
|
- Value: dataValue,
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// GetChartPredictEdbInfoDataListByConfList 获取图表的预测指标的未来数据
|
|
|
-func GetChartPredictEdbInfoDataListByConfList(predictEdbConfList []*PredictEdbConfAndData, filtrateStartDateStr, latestDateStr, endDateStr, frequency string, realPredictEdbInfoData []*EdbInfoSearchData) (predictEdbInfoData []*EdbInfoSearchData, minValue, maxValue float64, err error) {
|
|
|
+func GetChartPredictEdbInfoDataListByConfList(predictEdbConfList []*PredictEdbConfAndData, filtrateStartDateStr, latestDateStr, endDateStr, frequency, dataDateType string, realPredictEdbInfoData []*EdbInfoSearchData) (predictEdbInfoData []*EdbInfoSearchData, minValue, maxValue float64, err error) {
|
|
|
endDate, err := time.ParseInLocation(utils.FormatDate, endDateStr, time.Local)
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -509,7 +460,7 @@ func GetChartPredictEdbInfoDataListByConfList(predictEdbConfList []*PredictEdbCo
|
|
|
|
|
|
var tmpMinValue, tmpMaxValue float64 // 当前预测结果中的最大/最小值
|
|
|
|
|
|
- dayList := getPredictEdbDayList(startDate, dataEndTime, frequency)
|
|
|
+ dayList := getPredictEdbDayList(startDate, dataEndTime, frequency, dataDateType)
|
|
|
if len(dayList) <= 0 { // 如果未来没有日期的话,那么就退出当前循环,进入下一个循环
|
|
|
continue
|
|
|
}
|
|
@@ -740,13 +691,15 @@ func GetChartPredictEdbInfoDataListByConfList(predictEdbConfList []*PredictEdbCo
|
|
|
// GetPredictEdbDayList 获取预测指标日期列表
|
|
|
|
|
|
// GetPredictEdbDayList 获取预测指标日期列表
|
|
|
-func getPredictEdbDayList(startDate, endDate time.Time, frequency string) (dayList []time.Time) {
|
|
|
- //if !utils.InArrayByStr([]string{"日度", "周度", "月度"}, frequency)
|
|
|
+func getPredictEdbDayList(startDate, endDate time.Time, frequency, dataDateType string) (dayList []time.Time) {
|
|
|
+ if dataDateType == `` {
|
|
|
+ dataDateType = `交易日`
|
|
|
+ }
|
|
|
switch frequency {
|
|
|
case "日度":
|
|
|
for currDate := startDate.AddDate(0, 0, 1); currDate.Before(endDate) || currDate.Equal(endDate); currDate = currDate.AddDate(0, 0, 1) {
|
|
|
- //周六、日排除
|
|
|
- if currDate.Weekday() == time.Sunday || currDate.Weekday() == time.Saturday {
|
|
|
+ // 如果日期类型是交易日的时候,那么需要将周六、日排除
|
|
|
+ if dataDateType == `交易日` && (currDate.Weekday() == time.Sunday || currDate.Weekday() == time.Saturday) {
|
|
|
continue
|
|
|
}
|
|
|
dayList = append(dayList, currDate)
|
|
@@ -873,7 +826,7 @@ func GetPredictDataListByPredictEdbConfList(edbInfo, sourceEdbInfoItem *EdbInfo,
|
|
|
var predictMinValue, predictMaxValue float64
|
|
|
// 如果有配置的预测规则,那么就进行预测
|
|
|
if len(predictEdbConfList) > 0 {
|
|
|
- predictDataList, predictMinValue, predictMaxValue, err = GetChartPredictEdbInfoDataListByConfList(predictEdbConfList, startDate, sourceEdbInfoItem.LatestDate, endDateStr, edbInfo.Frequency, allDataList)
|
|
|
+ predictDataList, predictMinValue, predictMaxValue, err = GetChartPredictEdbInfoDataListByConfList(predictEdbConfList, startDate, sourceEdbInfoItem.LatestDate, endDateStr, edbInfo.Frequency, edbInfo.DataDateType, allDataList)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|