|
@@ -173,25 +173,28 @@ func GetChartData(chartInfoId int, config request.ChartConfigReq) (edbList []*da
|
|
|
if lenData <= 0 {
|
|
|
continue
|
|
|
}
|
|
|
+ // 数据的开始索引
|
|
|
+ k := lenData - 1
|
|
|
|
|
|
+ // 数据的最晚日期
|
|
|
+ dataEndDateStr := dataList[k].DataTime
|
|
|
+ dataEndDate, tmpErr := time.ParseInLocation(utils.FormatDate, dataEndDateStr, time.Local)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
// 数据开始日期
|
|
|
endDateStr := ``
|
|
|
var endDate time.Time
|
|
|
- // 数据的开始索引
|
|
|
- k := lenData - 1
|
|
|
+
|
|
|
var currVal float64
|
|
|
switch dateConfig.DateType {
|
|
|
case 1: // 1:最新日期;
|
|
|
- endDateStr = dataList[k].DataTime
|
|
|
- tmpDate, tmpErr := time.ParseInLocation(utils.FormatDate, endDateStr, time.Local)
|
|
|
- if tmpErr != nil {
|
|
|
- err = tmpErr
|
|
|
- return
|
|
|
- }
|
|
|
- endDate = tmpDate
|
|
|
+ endDateStr = dataEndDateStr
|
|
|
+ endDate = dataEndDate
|
|
|
currVal = dataList[k].Value
|
|
|
case 2: // 2:N天前
|
|
|
- tmpEndDate := currDay.AddDate(0, 0, -dateConfig.Num)
|
|
|
+ tmpEndDate := dataEndDate.AddDate(0, 0, -dateConfig.Num)
|
|
|
tmpEndDateStr := tmpEndDate.Format(utils.FormatDate)
|
|
|
|
|
|
for i := k; i >= 0; i-- {
|
|
@@ -200,6 +203,7 @@ func GetChartData(chartInfoId int, config request.ChartConfigReq) (edbList []*da
|
|
|
if tmpEndDateStr == tmpDateStr {
|
|
|
k = i
|
|
|
endDateStr = tmpDateStr
|
|
|
+ endDate = tmpEndDate
|
|
|
currVal = dataList[i].Value
|
|
|
break
|
|
|
}
|
|
@@ -537,6 +541,9 @@ func AddChartInfo(req request.AddChartReq, sysUser *system.Admin) (chartInfo *da
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 分类没有,需要创建新的分类,那么err置空
|
|
|
+ err = nil
|
|
|
+
|
|
|
timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
|
|
|
chartClassify = &data_manage.ChartClassify{
|
|
|
ChartClassifyId: 0,
|
|
@@ -552,6 +559,7 @@ func AddChartInfo(req request.AddChartReq, sysUser *system.Admin) (chartInfo *da
|
|
|
Sort: 0,
|
|
|
Source: source,
|
|
|
}
|
|
|
+ _, err = data_manage.AddChartClassify(chartClassify)
|
|
|
}
|
|
|
|
|
|
var chartInfoId int
|
|
@@ -580,6 +588,7 @@ func AddChartInfo(req request.AddChartReq, sysUser *system.Admin) (chartInfo *da
|
|
|
//chartInfo.ChartClassifyId = req.ChartClassifyId
|
|
|
chartInfo.SysUserId = sysUser.AdminId
|
|
|
chartInfo.SysUserRealName = sysUser.RealName
|
|
|
+ chartInfo.ChartImage = req.ChartImage
|
|
|
chartInfo.CreateTime = time.Now()
|
|
|
chartInfo.ModifyTime = time.Now()
|
|
|
chartInfo.IsSetName = 0
|