|
@@ -930,6 +930,185 @@ func (this *ChartInfoController) ChartInfoDetail() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+// PreviewChartInfoDetail
|
|
|
+// @Title 获取图表详情(预览)
|
|
|
+// @Description 获取图表详情接口(预览)
|
|
|
+// @Param DateType query int true "日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"
|
|
|
+// @Param StartDate query string true "自定义开始日期"
|
|
|
+// @Param EndDate query string true "自定义结束日期"
|
|
|
+// @Param Calendar query string true "公历/农历"
|
|
|
+// @Param SeasonStartDate query string true "季节性图开始日期"
|
|
|
+// @Param SeasonEndDate query string true "季节性图结束日期"
|
|
|
+// @Param EdbInfoId query string true "指标ID,多个用英文逗号隔开"
|
|
|
+// @Param ChartType query int true "生成样式:1:曲线图,2:季节性图"
|
|
|
+// @Success 200 {object} data_manage.ChartInfoDetailResp
|
|
|
+// @router /chart_info/detail/preview [get]
|
|
|
+func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ dateType, _ := this.GetInt("DateType")
|
|
|
+ if dateType <= 0 {
|
|
|
+ dateType = 3
|
|
|
+ }
|
|
|
+
|
|
|
+ startDate := this.GetString("StartDate")
|
|
|
+ endDate := this.GetString("EndDate")
|
|
|
+ seasonStartDate := this.GetString("SeasonStartDate")
|
|
|
+ seasonEndDate := this.GetString("SeasonEndDate")
|
|
|
+
|
|
|
+ // edbInfoId 指标id
|
|
|
+ edbInfoId := this.GetString("EdbInfoId")
|
|
|
+ if edbInfoId != `` {
|
|
|
+ br.Msg = "请选择指标"
|
|
|
+ br.ErrMsg = "指标id为空"
|
|
|
+ br.IsSendEmail = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ chartType, _ := this.GetInt("ChartType")
|
|
|
+
|
|
|
+ fmt.Println("seasonStartDate:", seasonStartDate)
|
|
|
+ fmt.Println("seasonEndDate:", seasonEndDate)
|
|
|
+
|
|
|
+ calendar := this.GetString("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
|
|
|
+ chartInfo := new(data_manage.ChartInfoView)
|
|
|
+
|
|
|
+ if chartType == 2 {
|
|
|
+ if seasonStartDate != "" {
|
|
|
+ startDate = seasonStartDate + "-01"
|
|
|
+ } else {
|
|
|
+ fivePre := time.Now().AddDate(-4, 0, 0).Year()
|
|
|
+ startDate = strconv.Itoa(fivePre) + "-01-01"
|
|
|
+ }
|
|
|
+ if seasonEndDate != "" {
|
|
|
+ seasonEndDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, seasonEndDate+"-01", time.Local)
|
|
|
+ if tmpErr != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取图表,指标信息失败,Err:" + tmpErr.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ endDate = seasonEndDateTime.AddDate(0, 1, -1).Format(utils.FormatDate)
|
|
|
+ //endDate = seasonEndDate + "-12-31"
|
|
|
+ } else {
|
|
|
+ endDate = "" //time.Now().AddDate(2, 0, 0).Format(utils.FormatDate)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ mappingList, err := data_manage.GetChartEdbMappingListByEdbInfoId(edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取图表,指标信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 图表额外数据参数
|
|
|
+ extraConfigStr := chartInfo.ExtraConfig
|
|
|
+ // 柱方图的一些配置
|
|
|
+ var barConfig data_manage.BarChartInfoReq
|
|
|
+ if chartInfo != nil && chartInfo.ChartType == 7 {
|
|
|
+ if chartInfo.BarConfig == `` {
|
|
|
+ br.Msg = "柱方图未配置"
|
|
|
+ br.ErrMsg = "柱方图未配置"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err := json.Unmarshal([]byte(chartInfo.BarConfig), &barConfig)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "柱方图配置异常"
|
|
|
+ br.ErrMsg = "柱方图配置异常"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ extraConfigStr = chartInfo.BarConfig
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取图表中的指标数据
|
|
|
+ edbList, xEdbIdValue, yDataList, dataResp, err, errMsg := data.GetChartEdbData(0, chartType, calendar, startDate, endDate, mappingList, extraConfigStr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ if errMsg != `` {
|
|
|
+ br.Msg = errMsg
|
|
|
+ }
|
|
|
+ br.ErrMsg = "获取图表,指标信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 单位
|
|
|
+ if chartType == utils.CHART_TYPE_BAR && len(yDataList) > 0 {
|
|
|
+ chartInfo.Unit = yDataList[0].Unit
|
|
|
+ chartInfo.UnitEn = yDataList[0].UnitEn
|
|
|
+ }
|
|
|
+ warnEdbList := make([]string, 0)
|
|
|
+ for _, v := range edbList {
|
|
|
+ if v.IsNullData {
|
|
|
+ warnEdbList = append(warnEdbList, v.EdbName+"("+v.EdbCode+")")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(warnEdbList) > 0 {
|
|
|
+ chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
|
|
|
+ }
|
|
|
+
|
|
|
+ //图表操作权限
|
|
|
+ chartInfo.IsEdit = data.CheckOpChartPermission(sysUser, chartInfo.SysUserId)
|
|
|
+ //判断是否需要展示英文标识
|
|
|
+ chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList, chartInfo.Source, chartInfo.ChartType)
|
|
|
+ chartInfo.Button = data_manage.ChartViewButton{
|
|
|
+ IsEdit: chartInfo.IsEdit,
|
|
|
+ IsEnChart: chartInfo.IsEnChart,
|
|
|
+ IsAdd: chartInfo.IsAdd,
|
|
|
+ IsCopy: true,
|
|
|
+ IsSetName: chartInfo.IsSetName,
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(data_manage.ChartInfoDetailResp)
|
|
|
+ resp.ChartInfo = chartInfo
|
|
|
+ resp.EdbInfoList = edbList
|
|
|
+ resp.XEdbIdValue = xEdbIdValue
|
|
|
+ resp.YDataList = yDataList
|
|
|
+ resp.BarChartInfo = barConfig
|
|
|
+ resp.DataResp = dataResp
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
// @Title 图表指标模糊搜索
|
|
|
// @Description 图表指标模糊搜索接口
|
|
|
// @Param KeyWord query string true "指标名称/ID"
|