Переглянути джерело

Merge remote-tracking branch 'origin/eta/1.3.1' into debug

Roc 1 рік тому
батько
коміт
672b48399c

+ 1 - 0
controllers/data_manage/cross_variety/chart_info.go

@@ -739,6 +739,7 @@ func (c *ChartInfoController) Copy() {
 		return
 	}
 	config.ChartName = req.ChartName
+	config.ChartImage = oldChartInfo.ChartImage
 
 	// 添加图表
 	chartInfo, err, errMsg, isSendEmail := cross_variety.AddChartInfo(config, sysUser)

+ 3 - 0
controllers/data_manage/edb_info.go

@@ -2113,6 +2113,9 @@ func (this *EdbInfoController) EdbInfoAdd() {
 		go data_manage.AddEdbInfoLog(edbLog)
 	}
 
+	// 更新es
+	go data.AddOrEditEdbInfoToEs(edbInfo.EdbInfoId)
+
 	resp := new(data_manage.AddEdbInfoResp)
 	resp.EdbInfoId = edbInfo.EdbInfoId
 	resp.UniqueCode = edbInfo.UniqueCode

+ 19 - 10
services/data/cross_variety/chart.go

@@ -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