浏览代码

Merge branch 'feature/eta1.9.6_chart_series' into debug

xyxie 8 月之前
父节点
当前提交
9c408b6271

+ 8 - 0
controllers/data_manage/chart_classify.go

@@ -654,6 +654,14 @@ func (this *ChartClassifyController) DeleteChartClassify() {
 			br.ErrMsg = "删除失败,Err:" + err.Error()
 			return
 		}
+		if chartInfo.ChartType == utils.CHART_TYPE_SECTION_COMBINE {
+			err = data_manage.DeleteChartSeriesAndEdbMapping(req.ChartInfoId)
+			if err != nil {
+				br.Msg = "删除失败"
+				br.ErrMsg = "删除失败,Err:" + err.Error()
+				return
+			}
+		}
 		//删除ES
 		{
 			go data.EsDeleteChartInfo(req.ChartInfoId)

+ 20 - 20
models/data_manage/chart_info.go

@@ -2702,18 +2702,18 @@ type ChartSectionDateChange struct {
 
 // 截面组合图系列配置
 type ChartSectionSeriesItem struct {
-	ChartSeriesId   int     `description:"系列ID"`
-	SeriesName      string  `description:"系列名称"` //系列名称不可同名
-	SeriesNameEn    string  `description:"系列英文名称"`
-	ChartStyle      string  `description:"图表类型"`
-	ChartColor      string  `description:"颜色"`
-	ChartWidth      int     `description:"线条大小"`
-	IsPoint         int     `description:"是否用数据点展示(0 否,1是)"`
-	IsNumber        int     `description:"是否用数值展示(0 否,1是)"`
-	IsAxis          int     `description:"1:左轴,0:右轴"`
-	MaxData         float64 `description:"上限"`
-	MinData         float64 `description:"下限"`
-	IsOrder         bool    `description:"true:正序,false:逆序"`
+	ChartSeriesId int     `description:"系列ID"`
+	SeriesName    string  `description:"系列名称"` //系列名称不可同名
+	SeriesNameEn  string  `description:"系列英文名称"`
+	ChartStyle    string  `description:"图表类型"`
+	ChartColor    string  `description:"颜色"`
+	ChartWidth    int     `description:"线条大小"`
+	IsPoint       int     `description:"是否用数据点展示(0 否,1是)"`
+	IsNumber      int     `description:"是否用数值展示(0 否,1是)"`
+	IsAxis        int     `description:"1:左轴,0:右轴"`
+	MaxData       float64 `description:"上限"`
+	MinData       float64 `description:"下限"`
+	//IsOrder         bool    `description:"true:正序,false:逆序"`
 	EdbInfoList     []*ChartSectionSeriesEdbConf
 	DataList        []float64
 	NoDataEdbIdList []int
@@ -2721,14 +2721,14 @@ type ChartSectionSeriesItem struct {
 type ChartSectionSeriesEdbConf struct {
 	ChartSeriesEdbMappingId int `description:"映射ID"`
 	ChartSeriesId           int `description:"系列ID"`
-	ChartInfoId             int `description:"图表ID"`
-	EdbInfoId               int `description:"指标id"`
-	DateConf                *ChartSectionSeriesDateConfItem
-	EdbName                 string `description:"中文别名"`
-	EdbNameEn               string `description:"英文别名"`
-	Unit                    string `description:"单位"`
-	UnitEn                  string `description:"英文单位"`
-	DateConfName            string `description:"引用日期名称"`
+	//ChartInfoId             int `description:"图表ID"`
+	EdbInfoId    int `description:"指标id"`
+	DateConf     *ChartSectionSeriesDateConfItem
+	EdbName      string `description:"中文别名"`
+	EdbNameEn    string `description:"英文别名"`
+	Unit         string `description:"单位"`
+	UnitEn       string `description:"英文单位"`
+	DateConfName string `description:"引用日期名称"`
 }
 
 type ChartSectionCombineDataResp struct {

+ 24 - 0
models/data_manage/chart_series.go

@@ -220,3 +220,27 @@ func AddChartSeriesAndEdbMapping(extraConfigStr string, chartInfoId int) (err er
 	}
 	return
 }
+
+func DeleteChartSeriesAndEdbMapping(chartInfoId int) (err error) {
+	o := orm.NewOrmUsingDB("data")
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+
+	sql := ` DELETE FROM chart_series WHERE chart_info_id=? `
+	_, err = to.Raw(sql, chartInfoId).Exec()
+	if err != nil {
+		return
+	}
+	sql = ` DELETE FROM  chart_series_edb_mapping WHERE chart_info_id=? `
+	_, err = to.Raw(sql, chartInfoId).Exec()
+	return
+}

+ 21 - 21
services/data/chart_info.go

@@ -383,14 +383,14 @@ func GetChartEdbData(chartInfoId, chartType int, calendar, startDate, endDate st
 				tmp := &data_manage.ChartSectionSeriesEdbConf{
 					ChartSeriesEdbMappingId: v.ChartSeriesEdbMappingId,
 					ChartSeriesId:           v.ChartSeriesId,
-					ChartInfoId:             v.ChartInfoId,
-					EdbInfoId:               v.EdbInfoId,
-					DateConf:                dateConf,
-					EdbName:                 "",
-					EdbNameEn:               "",
-					Unit:                    "",
-					UnitEn:                  "",
-					DateConfName:            v.DateConfName,
+					//ChartInfoId:             v.ChartInfoId,
+					EdbInfoId:    v.EdbInfoId,
+					DateConf:     dateConf,
+					EdbName:      "",
+					EdbNameEn:    "",
+					Unit:         "",
+					UnitEn:       "",
+					DateConfName: v.DateConfName,
 				}
 				seriesEdbMap[v.ChartSeriesId] = append(seriesEdbMap[v.ChartSeriesId], tmp)
 			}
@@ -405,18 +405,18 @@ func GetChartEdbData(chartInfoId, chartType int, calendar, startDate, endDate st
 			for _, v := range seriesListTmp {
 
 				tmpSeries := &data_manage.ChartSectionSeriesItem{
-					ChartSeriesId:   v.ChartSeriesId,
-					SeriesName:      v.SeriesName,
-					SeriesNameEn:    v.SeriesNameEn,
-					ChartStyle:      v.ChartStyle,
-					ChartColor:      v.ChartColor,
-					ChartWidth:      v.ChartWidth,
-					IsPoint:         v.IsPoint,
-					IsNumber:        v.IsNumber,
-					IsAxis:          v.IsAxis,
-					MaxData:         v.MaxData,
-					MinData:         v.MinData,
-					IsOrder:         false,
+					ChartSeriesId: v.ChartSeriesId,
+					SeriesName:    v.SeriesName,
+					SeriesNameEn:  v.SeriesNameEn,
+					ChartStyle:    v.ChartStyle,
+					ChartColor:    v.ChartColor,
+					ChartWidth:    v.ChartWidth,
+					IsPoint:       v.IsPoint,
+					IsNumber:      v.IsNumber,
+					IsAxis:        v.IsAxis,
+					MaxData:       v.MaxData,
+					MinData:       v.MinData,
+					//IsOrder:         false,
 					EdbInfoList:     nil,
 					DataList:        nil,
 					NoDataEdbIdList: nil,
@@ -1761,7 +1761,7 @@ func CheckChartExtraConfig(chartType int, extraConfigStr string) (edbIdList []in
 		err = json.Unmarshal([]byte(extraConfigStr), &extraConfig)
 		if err != nil {
 			errMsg = "截面组合图配置异常"
-			err = errors.New(errMsg)
+			err = errors.New(errMsg + err.Error())
 			return
 		}
 		//校验引用日期名称是否重复