zwxi 8 meses atrás
pai
commit
500d18b362
1 arquivos alterados com 72 adições e 12 exclusões
  1. 72 12
      controllers/data_manage/chart_info.go

+ 72 - 12
controllers/data_manage/chart_info.go

@@ -1433,18 +1433,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 			return
 		}
 		for i := range markerLines {
-			if markerLines[i].MarkLineType == 1 {
-				// 跟随图表
-				if edbList[0].IsAxis == 1 {
-					value, err := data.MarkerLineCalculate(markerLines[i], edbList[0].DataList, chartInfo)
-					if err != nil {
-						br.Msg = "标识线配置异常"
-						br.ErrMsg = "标识线配置异常" + err.Error()
-						return
-					}
-					markerLines[i].Value = value
-				}
-			} else {
+			if markerLines[i].EdbType == 1 {
 				// 指标计算
 				edbInfo, err := data_manage.GetEdbInfoById(markerLines[i].EdbInfoId)
 				if err != nil {
@@ -1465,6 +1454,18 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 					return
 				}
 				markerLines[i].Value = value
+
+			} else {
+				// 跟随图表
+				if edbList[0].IsAxis == 1 {
+					value, err := data.MarkerLineCalculate(markerLines[i], edbList[0].DataList, chartInfo)
+					if err != nil {
+						br.Msg = "标识线配置异常"
+						br.ErrMsg = "标识线配置异常" + err.Error()
+						return
+					}
+					markerLines[i].Value = value
+				}
 			}
 		}
 
@@ -4428,3 +4429,62 @@ func (this *ChartInfoController) PreviewSeasonChartInfo() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// ChartInfoImgSetBySvg
+// @Title 图表图片上传
+// @Param   Img   query   string  true       "图片"
+// @Param   ChartInfoId   query   int  true       "图表ID"
+// @Success 200 {object} models.ResourceResp
+// @router /chart_info/image/set_by_svg [post]
+func (this *ChartInfoController) ChartInfoImgSetBySvg() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	imgData := this.GetString("Img")
+	if imgData == "" {
+		br.Msg = "图片参数错误"
+		br.ErrMsg = "图片参数错误,Img Is Empty"
+		return
+	}
+	chartInfoId, _ := this.GetInt("ChartInfoId", 0)
+	if chartInfoId <= 0 {
+		br.Msg = "图片参数错误"
+		br.ErrMsg = "图片参数错误,ChartInfoId Is Empty"
+		return
+	}
+	resp := new(models.ResourceResp)
+
+	// 通过svg图片生成图片资源地址
+	resourceUrl, err, errMsg := services.GetResourceUrlBySvgImg(imgData)
+	if err != nil {
+		br.Msg = errMsg
+		br.ErrMsg = err.Error()
+		return
+	}
+
+	// 修改图表的缩略图信息
+	if chartInfoId > 0 && resourceUrl != "" {
+		err = data_manage.EditChartInfoImageV2(chartInfoId, resourceUrl)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
+
+		//修改es数据
+		go data.EsAddOrEditChartInfo(chartInfoId)
+		//修改my eta es数据
+		go data.EsAddOrEditMyChartInfoByChartInfoId(chartInfoId)
+	}
+
+	resp.ResourceUrl = resourceUrl
+	resp.Source = "convert"
+	//resp.CacheKey = imgDataKey
+	br.Msg = "上传成功"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	return
+}