gmy пре 3 месеци
родитељ
комит
9f062563aa

+ 10 - 0
controllers/data_manage/chart_info.go

@@ -1301,6 +1301,16 @@ func fillAreaGraphData(extraConfigStr string, edbDataList []*data_manage.ChartEd
 		if err != nil {
 			return err, err.Error()
 		}
+
+		// 时间戳处理
+		for _, mapping := range edbDataList {
+			if dataList, ok := mapping.DataList.([]*data_manage.EdbDataList); ok {
+				for _, dataInfo := range dataList {
+					toFormatTime := utils.StringToFormatTime(dataInfo.DataTime, utils.FormatDate)
+					dataInfo.DataTimestamp = toFormatTime.UnixMilli()
+				}
+			}
+		}
 	}
 
 	return nil, ""

+ 2 - 0
models/data_manage/chart_info.go

@@ -195,6 +195,7 @@ type ChartSaveItem struct {
 	ChartColor        string  `description:"颜色"`
 	PredictChartColor string  `description:"预测数据的颜色"`
 	ChartWidth        float64 `description:"线条大小"`
+	ChartScale        float64 `description:"参考刻度线"`
 	Source            int     `description:"1:ETA图库;2:商品价格曲线"`
 	EdbAliasName      string  `description:"中文别名"`
 	IsConvert         int     `description:"是否数据转换 0不转 1转"`
@@ -651,6 +652,7 @@ type ChartEdbInfoMapping struct {
 	ChartColor          string  `description:"颜色"`
 	PredictChartColor   string  `description:"预测数据的颜色"`
 	ChartWidth          float64 `description:"线条大小"`
+	ChartScale          float64 `description:"参考刻度线"`
 	ChartType           int     `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
 	LatestDate          string  `description:"数据最新日期"`
 	LatestValue         float64 `description:"数据最新值"`

+ 9 - 9
services/data/area_graph/processor_business_logic.go

@@ -53,25 +53,25 @@ func (i *InterpolateStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataL
 
 				// 插值法补充数据
 				var startEdbInfoData *data_manage.EdbDataList
-				for index := 0; index < len(dataList)-1; index++ {
+				for index := 0; index < len(dataList); index++ {
 					// 获取当前数据和下一个数据
-					beforeIndexData := dataList[index]
-					afterIndexData := dataList[index+1]
+					currentIndexData := dataList[index]
+					//afterIndexData := dataList[index+1]
 
 					if startEdbInfoData == nil {
-						startEdbInfoData = beforeIndexData
+						startEdbInfoData = currentIndexData
 						continue
 					}
 
 					// 获取两条数据之间相差的天数
 					startDataTime, _ := time.ParseInLocation(utils.FormatDate, startEdbInfoData.DataTime, time.Local)
-					currDataTime, _ := time.ParseInLocation(utils.FormatDate, afterIndexData.DataTime, time.Local)
+					currDataTime, _ := time.ParseInLocation(utils.FormatDate, currentIndexData.DataTime, time.Local)
 					betweenHour := int(currDataTime.Sub(startDataTime).Hours())
 					betweenDay := betweenHour / 24
 
 					// 如果相差一天,那么过滤
 					if betweenDay <= 1 {
-						startEdbInfoData = afterIndexData
+						startEdbInfoData = currentIndexData
 						continue
 					}
 
@@ -86,7 +86,7 @@ func (i *InterpolateStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataL
 						coordinateData = append(coordinateData, tmpCoordinate1)
 						tmpCoordinate2 := utils.Coordinate{
 							X: float64(betweenDay) + 1,
-							Y: afterIndexData.Value,
+							Y: currentIndexData.Value,
 						}
 						coordinateData = append(coordinateData, tmpCoordinate2)
 
@@ -108,7 +108,7 @@ func (i *InterpolateStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataL
 						nextDay := tmpDataTime.Format(utils.FormatDate)
 
 						replenishIndexData := data_manage.EdbDataList{
-							EdbDataId:     afterIndexData.EdbDataId,
+							EdbDataId:     currentIndexData.EdbDataId,
 							DataTime:      nextDay,
 							DataTimestamp: tmpDataTime.UnixMilli(),
 							Value:         val,
@@ -117,7 +117,7 @@ func (i *InterpolateStrategy) Deal(tmpConfig data_manage.AreaExtraConf, edbDataL
 						// 将补充数据加入补充数据列表
 						replenishDataList = append(replenishDataList, &replenishIndexData)
 					}
-					startEdbInfoData = afterIndexData
+					startEdbInfoData = currentIndexData
 				}
 
 				// 处理从最后一个数据到 endDate 的日期补充

+ 3 - 0
services/data/chart_info.go

@@ -653,6 +653,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 			item.ChartStyle = ""
 			item.ChartColor = ""
 			item.ChartWidth = 0
+			item.ChartScale = 0
 			item.MaxData = v.MaxValue
 			item.MinData = v.MinValue
 		} else {
@@ -666,6 +667,7 @@ func getEdbDataMapList(chartInfoId, chartType int, calendar, startDate, endDate
 			item.ChartStyle = v.ChartStyle
 			item.ChartColor = v.ChartColor
 			item.ChartWidth = v.ChartWidth
+			item.ChartScale = v.ChartScale
 			item.IsOrder = v.IsOrder
 			item.MaxData = v.MaxData
 			item.MinData = v.MinData
@@ -2405,6 +2407,7 @@ func AddChartInfo(req data_manage.AddChartInfoReq, sysUserId int, sysUserRealNam
 					ChartColor:        "",
 					PredictChartColor: "",
 					ChartWidth:        0,
+					ChartScale:        0,
 					Source:            utils.CHART_SOURCE_DEFAULT,
 				})
 			}

+ 7 - 1
utils/date_util.go

@@ -111,7 +111,13 @@ func isLeap(year int) bool {
 
 // StringToTime string 类型时间 转换为 time.Time 类型
 func StringToTime(date string) time.Time {
-	t, _ := time.Parse("2006-01-02", date)
+	t, _ := time.ParseInLocation("2006-01-02", date, time.Local)
+	return t
+}
+
+// StringToFormatTime string 类型时间 转换为指定格式的 time.Time类型
+func StringToFormatTime(data string, format string) time.Time {
+	t, _ := time.ParseInLocation(format, data, time.Local)
 	return t
 }