|
@@ -159,6 +159,7 @@ func (this *ChartInfoController) ChartInfoSave() {
|
|
|
br.IsAddLog = true
|
|
|
}
|
|
|
|
|
|
+// ChartInfoAdd
|
|
|
// @Title 新增图表接口
|
|
|
// @Description 新增图表接口
|
|
|
// @Param request body data_manage.AddChartInfoReq true "type json string"
|
|
@@ -957,62 +958,43 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- dateType, _ := this.GetInt("DateType")
|
|
|
- if dateType <= 0 {
|
|
|
- dateType = 3
|
|
|
+ var req data_manage.PreviewChartInfoReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- startDate := this.GetString("StartDate")
|
|
|
- endDate := this.GetString("EndDate")
|
|
|
- seasonStartDate := this.GetString("SeasonStartDate")
|
|
|
- seasonEndDate := this.GetString("SeasonEndDate")
|
|
|
+ if req.DateType <= 0 {
|
|
|
+ req.DateType = 3
|
|
|
+ }
|
|
|
|
|
|
// edbInfoId 指标id
|
|
|
- edbInfoId := this.GetString("EdbInfoId")
|
|
|
- if edbInfoId != `` {
|
|
|
+ if len(req.ChartEdbInfoList) <= 0 {
|
|
|
br.Msg = "请选择指标"
|
|
|
- br.ErrMsg = "指标id为空"
|
|
|
+ br.ErrMsg = "指标为空"
|
|
|
br.IsSendEmail = false
|
|
|
return
|
|
|
}
|
|
|
- chartType, _ := this.GetInt("ChartType")
|
|
|
|
|
|
+ seasonStartDate := req.SeasonStartDate
|
|
|
+ seasonEndDate := req.SeasonEndDate
|
|
|
fmt.Println("seasonStartDate:", seasonStartDate)
|
|
|
fmt.Println("seasonEndDate:", seasonEndDate)
|
|
|
|
|
|
- calendar := this.GetString("Calendar")
|
|
|
+ calendar := req.Calendar
|
|
|
if calendar == "" {
|
|
|
calendar = "公历"
|
|
|
}
|
|
|
- switch dateType {
|
|
|
- case 1:
|
|
|
- startDate = "2000-01-01"
|
|
|
- case 2:
|
|
|
- startDate = "2010-01-01"
|
|
|
- case 3:
|
|
|
- startDate = "2015-01-01"
|
|
|
- case 4:
|
|
|
- //startDate = strconv.Itoa(time.Now().Year()) + "-01-01"
|
|
|
- startDate = "2021-01-01"
|
|
|
- case 5:
|
|
|
- startDate = startDate + "-01"
|
|
|
- endDate = endDate + "-01"
|
|
|
- case 6:
|
|
|
- startDate = startDate + "-01"
|
|
|
- case 7:
|
|
|
- startDate = "2018-01-01"
|
|
|
- case 8:
|
|
|
- startDate = "2019-01-01"
|
|
|
- case 9:
|
|
|
- startDate = "2020-01-01"
|
|
|
- case 11:
|
|
|
- startDate = "2022-01-01"
|
|
|
- }
|
|
|
|
|
|
- var err error
|
|
|
+ // 开始/结束日期
|
|
|
+ startDate, endDate := utils.GetDateByDateType(req.DateType, req.StartDate, req.EndDate)
|
|
|
+
|
|
|
chartInfo := new(data_manage.ChartInfoView)
|
|
|
+ chartInfo.ChartType = req.ChartType
|
|
|
|
|
|
- if chartType == 2 {
|
|
|
+ if req.ChartType == 2 {
|
|
|
if seasonStartDate != "" {
|
|
|
startDate = seasonStartDate + "-01"
|
|
|
} else {
|
|
@@ -1033,13 +1015,38 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- mappingList, err := data_manage.GetChartEdbMappingListByEdbInfoId(edbInfoId)
|
|
|
+ edbInfoIdList := make([]int, 0)
|
|
|
+ edbInfoIdMapping := make(map[int]*data_manage.ChartSaveItem)
|
|
|
+ for _, v := range req.ChartEdbInfoList {
|
|
|
+ edbInfoIdList = append(edbInfoIdList, v.EdbInfoId)
|
|
|
+ edbInfoIdMapping[v.EdbInfoId] = v
|
|
|
+ }
|
|
|
+ mappingList, err := data_manage.GetChartEdbMappingListByEdbInfoIdList(edbInfoIdList)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取图表,指标信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ for k, v := range mappingList {
|
|
|
+ if tmpV, ok := edbInfoIdMapping[v.EdbInfoId]; ok {
|
|
|
+ v.EdbInfoType = tmpV.EdbInfoType
|
|
|
+ v.MaxData = tmpV.MaxData
|
|
|
+ v.MinData = tmpV.MinData
|
|
|
+ v.IsOrder = tmpV.IsOrder
|
|
|
+ v.IsAxis = tmpV.IsAxis
|
|
|
+ v.EdbInfoType = tmpV.EdbInfoType
|
|
|
+ v.LeadValue = tmpV.LeadValue
|
|
|
+ v.LeadUnit = tmpV.LeadUnit
|
|
|
+ v.ChartStyle = tmpV.ChartStyle
|
|
|
+ v.ChartColor = tmpV.ChartColor
|
|
|
+ v.PredictChartColor = tmpV.PredictChartColor
|
|
|
+ v.ChartWidth = tmpV.ChartWidth
|
|
|
+ v.Source = tmpV.Source
|
|
|
+ }
|
|
|
+ mappingList[k] = v
|
|
|
+ }
|
|
|
+
|
|
|
// 图表额外数据参数
|
|
|
extraConfigStr := chartInfo.ExtraConfig
|
|
|
// 柱方图的一些配置
|
|
@@ -1060,7 +1067,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
}
|
|
|
|
|
|
// 获取图表中的指标数据
|
|
|
- edbList, xEdbIdValue, yDataList, dataResp, err, errMsg := data.GetChartEdbData(0, chartType, calendar, startDate, endDate, mappingList, extraConfigStr)
|
|
|
+ edbList, xEdbIdValue, yDataList, dataResp, err, errMsg := data.GetChartEdbData(0, req.ChartType, calendar, startDate, endDate, mappingList, extraConfigStr)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
if errMsg != `` {
|
|
@@ -1070,7 +1077,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
return
|
|
|
}
|
|
|
// 单位
|
|
|
- if chartType == utils.CHART_TYPE_BAR && len(yDataList) > 0 {
|
|
|
+ if req.ChartType == utils.CHART_TYPE_BAR && len(yDataList) > 0 {
|
|
|
chartInfo.Unit = yDataList[0].Unit
|
|
|
chartInfo.UnitEn = yDataList[0].UnitEn
|
|
|
}
|