|
@@ -6,11 +6,13 @@ import (
|
|
|
"eta/eta_api/models"
|
|
|
"eta/eta_api/models/company"
|
|
|
"eta/eta_api/models/data_manage"
|
|
|
+ request2 "eta/eta_api/models/data_manage/excel/request"
|
|
|
"eta/eta_api/models/data_manage/request"
|
|
|
"eta/eta_api/models/data_manage/response"
|
|
|
"eta/eta_api/models/system"
|
|
|
"eta/eta_api/services/alarm_msg"
|
|
|
"eta/eta_api/services/data"
|
|
|
+ excel2 "eta/eta_api/services/data/excel"
|
|
|
"eta/eta_api/services/data_stat"
|
|
|
"eta/eta_api/services/elastic"
|
|
|
etaTrialService "eta/eta_api/services/eta_trial"
|
|
@@ -4584,7 +4586,7 @@ func (this *EdbInfoController) GetEdbDateData() {
|
|
|
// @Param Date query string false "日期"
|
|
|
// @Param Num query int false "前后几期数据"
|
|
|
// @Success 200 {object} data_manage.EdbInfoList
|
|
|
-// @router /edb_info/date_data/before_after [get]
|
|
|
+// @router /edb_info/date_data/before_after [post]
|
|
|
func (this *EdbInfoController) GetEdbBeforeAndAfterDateData() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
|
defer func() {
|
|
@@ -4592,9 +4594,17 @@ func (this *EdbInfoController) GetEdbBeforeAndAfterDateData() {
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
|
|
|
- edbInfoId, _ := this.GetInt("EdbInfoId")
|
|
|
- date := this.GetString("Date")
|
|
|
- num, _ := this.GetInt("Num")
|
|
|
+ requestBody := string(this.Ctx.Input.RequestBody)
|
|
|
+ var req request2.DateDataBeforeAfterReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ edbInfoId := req.EdbInfoId
|
|
|
+ currDate := req.Date
|
|
|
+ num := req.Num
|
|
|
|
|
|
// 默认2期数据
|
|
|
if num <= 0 {
|
|
@@ -4613,100 +4623,51 @@ func (this *EdbInfoController) GetEdbBeforeAndAfterDateData() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 当前日期
|
|
|
- var currDate string
|
|
|
- // 是否查找之后的数据
|
|
|
- isFindAfter := true
|
|
|
- if date == `` {
|
|
|
- currDate = edbInfo.EndDate
|
|
|
- isFindAfter = false
|
|
|
- if num <= 0 {
|
|
|
- num = 4 //默认获取前面的几期数据
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
dataList := make([]*data_manage.EdbDataList, 0)
|
|
|
-
|
|
|
- startDate := date
|
|
|
- // 指定日期的类型
|
|
|
- dateType := "day"
|
|
|
- //如果填写的是月度日期
|
|
|
- if strings.Count(date, "-") == 1 {
|
|
|
- startDate = date + "-01"
|
|
|
- dateType = "month"
|
|
|
- }
|
|
|
-
|
|
|
- resp := data_manage.BeforeAndAfterDateDataResp{
|
|
|
- List: dataList,
|
|
|
- Date: "",
|
|
|
- }
|
|
|
- // 后面的数据
|
|
|
- afterList := make([]*data_manage.EdbDataList, 0)
|
|
|
- if isFindAfter {
|
|
|
- afterList, err = data.GetEdbBeforeAndAfterDateData(edbInfo, startDate, "", 2, num)
|
|
|
+ switch edbInfo.EdbInfoType {
|
|
|
+ case 0:
|
|
|
+ dataList, _ = data_manage.GetEdbDataList(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbInfoId, ``, ``)
|
|
|
+ case 1:
|
|
|
+ _, dataList, _, _, _, _ = data.GetPredictDataListByPredictEdbInfoId(edbInfo.EdbInfoId, ``, ``, false)
|
|
|
+ default:
|
|
|
+ br.Msg = "指标类型异常!"
|
|
|
+ br.ErrMsg = "指标类型异常,Err:" + strconv.Itoa(edbInfo.EdbInfoType)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if currDate == `` {
|
|
|
+ currDate, err = excel2.GetEdbDateByMoveForward(requestBody, dataList)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = fmt.Sprint("获取后面的指数据失败,Err:", err.Error())
|
|
|
+ br.Msg = "日期前移失败"
|
|
|
+ br.ErrMsg = "日期前移失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- lenBeforeList := len(afterList)
|
|
|
- if lenBeforeList <= 0 {
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "所选指标所选日期无值"
|
|
|
- br.Data = resp
|
|
|
- return
|
|
|
- } else {
|
|
|
- var dateTimeStr string
|
|
|
- switch dateType {
|
|
|
- case "month":
|
|
|
- dateTime, _ := time.ParseInLocation(utils.FormatDate, afterList[0].DataTime, time.Local)
|
|
|
- dateTimeStr = dateTime.Format(utils.FormatYearMonthDate)
|
|
|
- case "day":
|
|
|
- dateTimeStr = afterList[0].DataTime
|
|
|
- }
|
|
|
- currDate = afterList[0].DataTime
|
|
|
- // 如果对应日期找不到,那么就直接返回吧
|
|
|
- if dateTimeStr != date {
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "所选指标所选日期无值"
|
|
|
- br.Data = resp
|
|
|
- return
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ if strings.Count(currDate, "-") == 1 {
|
|
|
+ currDate = currDate + "-01"
|
|
|
+ //dateType = "month"
|
|
|
+ } else if strings.Count(currDate, "-") == 0 {
|
|
|
+ currDate = currDate + "-01-01"
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // 前面的数据
|
|
|
- beforeList, err := data.GetEdbBeforeAndAfterDateData(edbInfo, "", currDate, 1, num)
|
|
|
+ currDate, err = excel2.HandleMixTableDateChange(currDate, requestBody)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = fmt.Sprint("获取前面的指数据失败,Err:", err.Error())
|
|
|
+ br.Msg = "日期变换失败"
|
|
|
+ br.ErrMsg = "日期变换失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ list := make([]*data_manage.EdbDataList, 5)
|
|
|
|
|
|
- dataList = append(dataList, beforeList...)
|
|
|
- // 后面的数据
|
|
|
- if len(afterList) > 0 {
|
|
|
- if len(beforeList) > 0 {
|
|
|
- dataList = append(dataList, afterList[1:]...)
|
|
|
- } else {
|
|
|
- dataList = append(dataList, afterList...)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 数据翻转
|
|
|
- for i, j := 0, len(dataList)-1; i < j; i, j = i+1, j-1 {
|
|
|
- dataList[i], dataList[j] = dataList[j], dataList[i]
|
|
|
+ list, err = data.GetEdbBeforeAndAfterDateData(currDate, dataList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprint("获取后面的指数据失败,Err:", err.Error())
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
- resp.List = dataList
|
|
|
- // 前端不传入日期的时候,这个J皮不让返回这个字段,要不然他会颜色标记
|
|
|
- if date != `` {
|
|
|
- resp.Date = currDate
|
|
|
+ // todo 如果list 是空值,是否默认返回最新的记录
|
|
|
+ resp := data_manage.BeforeAndAfterDateDataResp{
|
|
|
+ List: list,
|
|
|
+ Date: currDate,
|
|
|
}
|
|
|
-
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|