|
@@ -2,6 +2,7 @@ package data_manage
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "errors"
|
|
|
"eta/eta_api/controllers"
|
|
|
"eta/eta_api/models"
|
|
|
"eta/eta_api/models/data_manage"
|
|
@@ -10,6 +11,7 @@ import (
|
|
|
"eta/eta_api/services"
|
|
|
"eta/eta_api/services/alarm_msg"
|
|
|
"eta/eta_api/services/data"
|
|
|
+ "eta/eta_api/services/data/area_graph"
|
|
|
"eta/eta_api/services/data/data_manage_permission"
|
|
|
"eta/eta_api/services/data/excel"
|
|
|
"eta/eta_api/services/eta_forum"
|
|
@@ -66,7 +68,7 @@ func (this *ChartInfoController) ChartInfoSave() {
|
|
|
|
|
|
chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表已被删除,请刷新页面!"
|
|
|
br.ErrMsg = "图表已被删除,请刷新页面,ChartInfoId:" + strconv.Itoa(req.ChartInfoId)
|
|
|
return
|
|
@@ -334,7 +336,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
|
|
|
//判断指标名称是否存在
|
|
|
chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表已被删除,请刷新页面"
|
|
|
br.ErrMsg = "图表已被删除,请刷新页面"
|
|
|
return
|
|
@@ -357,7 +359,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
|
|
|
edbInfoId := v.EdbInfoId
|
|
|
edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表不存在!"
|
|
|
br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
|
|
|
return
|
|
@@ -367,7 +369,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- if edbInfo == nil {
|
|
|
+ if edbInfo == nil || edbInfo.EdbInfoId <= 0 {
|
|
|
br.Msg = "指标不存在!"
|
|
|
br.ErrMsg = "指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
|
|
|
return
|
|
@@ -389,7 +391,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
|
|
|
|
|
|
edbExist, err := data_manage.GetEdbInfoByCondition(edbCondition, edbPars)
|
|
|
if err != nil {
|
|
|
- if err.Error() != utils.ErrNoRow() {
|
|
|
+ if !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "判断英文指标名称是否存在失败"
|
|
|
br.ErrMsg = "判断英文指标名称是否存在失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -418,7 +420,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
|
|
|
|
|
|
existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
|
|
|
if err != nil {
|
|
|
- if err.Error() != utils.ErrNoRow() {
|
|
|
+ if !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "判断英文图表名称是否存在失败"
|
|
|
br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -447,7 +449,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
|
|
|
edbInfoId := v.EdbInfoId
|
|
|
edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表不存在!"
|
|
|
br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
|
|
|
return
|
|
@@ -457,7 +459,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- if edbInfo != nil {
|
|
|
+ if edbInfo != nil && edbInfo.EdbInfoId > 0 {
|
|
|
go data.AddOrEditEdbInfoToEs(edbInfoId)
|
|
|
}
|
|
|
}
|
|
@@ -526,7 +528,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
|
|
|
//判断指标名称是否存在
|
|
|
chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表已被删除,请刷新页面"
|
|
|
br.ErrMsg = "图表已被删除,请刷新页面"
|
|
|
return
|
|
@@ -549,7 +551,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
|
|
|
edbInfoId := v.EdbInfoId
|
|
|
edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表不存在!"
|
|
|
br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
|
|
|
return
|
|
@@ -584,7 +586,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
|
|
|
|
|
|
edbExist, err := data_manage.GetEdbInfoByCondition(edbCondition, edbPars)
|
|
|
if err != nil {
|
|
|
- if err.Error() != utils.ErrNoRow() {
|
|
|
+ if !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "判断英文指标名称是否存在失败"
|
|
|
br.ErrMsg = "判断英文指标名称是否存在失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -616,7 +618,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
|
|
|
|
|
|
existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
|
|
|
if err != nil {
|
|
|
- if err.Error() != utils.ErrNoRow() {
|
|
|
+ if !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "判断英文图表名称是否存在失败"
|
|
|
br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -645,7 +647,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
|
|
|
edbInfoId := v.EdbInfoId
|
|
|
edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表不存在!"
|
|
|
br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
|
|
|
return
|
|
@@ -655,7 +657,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- if edbInfo != nil {
|
|
|
+ if edbInfo != nil && edbInfo.EdbInfoId > 0 {
|
|
|
go data.AddOrEditEdbInfoToEs(edbInfoId)
|
|
|
}
|
|
|
}
|
|
@@ -698,7 +700,7 @@ func (this *ChartInfoController) ChartInfoNewest() {
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
item, err := data_manage.GetChartInfoByNewest(1)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取最新图表失败"
|
|
|
br.ErrMsg = "获取最新图表失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -786,12 +788,12 @@ func (this *ChartInfoController) ChartInfoMove() {
|
|
|
if chartInfo.ChartClassifyId != req.ChartClassifyId {
|
|
|
//查询需要修改的分类下是否存在同一个图表名称
|
|
|
tmpChartInfo, tmpErr := data_manage.GetChartInfoByClassifyIdAndName(req.ChartClassifyId, chartInfo.ChartName)
|
|
|
- if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
|
|
|
+ if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
|
|
|
br.Msg = "移动失败"
|
|
|
br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
|
|
|
return
|
|
|
}
|
|
|
- if tmpChartInfo != nil {
|
|
|
+ if tmpChartInfo != nil && tmpChartInfo.ChartInfoId > 0 {
|
|
|
br.Msg = "移动失败,同一个分类下图表名称不允许重复"
|
|
|
br.ErrMsg = "移动失败,同一个分类下图表名称不允许重复"
|
|
|
return
|
|
@@ -845,14 +847,14 @@ func (this *ChartInfoController) ChartInfoMove() {
|
|
|
|
|
|
} else {
|
|
|
firstClassify, err := data_manage.GetFirstChartInfoByClassifyId(req.ChartClassifyId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "移动失败"
|
|
|
br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
|
|
|
- if firstClassify != nil && firstClassify.Sort == 0 {
|
|
|
+ if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
|
|
|
updateSortStr := ` sort + 1 `
|
|
|
_ = data_manage.UpdateChartInfoSortByClassifyId(firstClassify.ChartClassifyId, 0, firstClassify.ChartInfoId-1, []int{chartInfo.Source}, updateSortStr)
|
|
|
}
|
|
@@ -959,7 +961,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
|
|
|
if chartInfoId > 0 {
|
|
|
chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "该图表已删除,自动查看下一图表"
|
|
|
br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
|
|
|
br.Ret = 406
|
|
@@ -1028,7 +1030,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
|
|
|
extraConfigStr := chartInfo.ExtraConfig
|
|
|
// 柱方图的一些配置
|
|
|
var barConfig data_manage.BarChartInfoReq
|
|
|
- if chartInfo != nil && chartInfo.ChartType == 7 {
|
|
|
+ if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
|
|
|
if chartInfo.BarConfig == `` {
|
|
|
br.Msg = "柱方图未配置"
|
|
|
br.ErrMsg = "柱方图未配置"
|
|
@@ -1128,7 +1130,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
|
|
|
if len(warnEdbList) > 0 {
|
|
|
chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
|
|
|
}
|
|
|
- if chartInfoId > 0 && chartInfo != nil {
|
|
|
+ if chartInfoId > 0 && chartInfo != nil && chartInfo.ChartInfoId > 0 {
|
|
|
//判断是否加入我的图库
|
|
|
{
|
|
|
var myChartCondition string
|
|
@@ -1139,7 +1141,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
|
|
|
myChartPars = append(myChartPars, chartInfo.ChartInfoId)
|
|
|
|
|
|
myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
|
|
|
return
|
|
@@ -1359,7 +1361,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
extraConfigStr := chartInfo.ExtraConfig
|
|
|
// 柱方图的一些配置
|
|
|
var barConfig data_manage.BarChartInfoReq
|
|
|
- if chartInfo != nil && chartInfo.ChartType == 7 {
|
|
|
+ if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
|
|
|
if chartInfo.BarConfig == `` {
|
|
|
br.Msg = "柱方图未配置"
|
|
|
br.ErrMsg = "柱方图未配置"
|
|
@@ -1372,7 +1374,9 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
return
|
|
|
}
|
|
|
extraConfigStr = chartInfo.BarConfig
|
|
|
- } else if chartInfo != nil && chartInfo.ChartType == utils.CHART_TYPE_SECTION_COMBINE {
|
|
|
+ } else if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == utils.CHART_TYPE_SECTION_COMBINE {
|
|
|
+ extraConfigStr = req.ExtraConfig
|
|
|
+ } else if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == utils.CHART_TYPE_AREA {
|
|
|
extraConfigStr = req.ExtraConfig
|
|
|
}
|
|
|
|
|
@@ -1401,6 +1405,16 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
|
|
|
}
|
|
|
|
|
|
+ // 面积图 面积堆积 数据处理
|
|
|
+ if req.ChartType == utils.CHART_TYPE_AREA {
|
|
|
+ err, errMsg = fillAreaGraphData(extraConfigStr, edbList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "面积图处理失败"
|
|
|
+ br.ErrMsg = errMsg
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//图表操作权限
|
|
|
chartInfo.IsEdit = data.CheckOpChartPermission(sysUser, chartInfo.SysUserId, true)
|
|
|
//判断是否需要展示英文标识
|
|
@@ -1493,6 +1507,60 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+func fillAreaGraphData(extraConfigStr string, edbDataList []*data_manage.ChartEdbInfoMapping) (err error, errMsg string) {
|
|
|
+
|
|
|
+ var tmpConfig data_manage.AreaExtraConf
|
|
|
+ if extraConfigStr != `` {
|
|
|
+ err = json.Unmarshal([]byte(extraConfigStr), &tmpConfig)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "面积图配置异常"
|
|
|
+ err = errors.New(errMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if tmpConfig.StandardEdbInfoId <= 0 {
|
|
|
+ utils.FileLog.Info("面积图未开启面积堆积")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if tmpConfig.IsHeap == 1 {
|
|
|
+ standardIndexMap := make(map[string]*data_manage.EdbDataList)
|
|
|
+ var startDate, endDate string
|
|
|
+ for _, v := range edbDataList {
|
|
|
+ // 判断是否为基准指标
|
|
|
+ if v.EdbInfoId == tmpConfig.StandardEdbInfoId {
|
|
|
+ if dataList, ok := v.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+ startDate = dataList[0].DataTime
|
|
|
+ endDate = dataList[len(dataList)-1].DataTime
|
|
|
+ for _, dataObject := range dataList {
|
|
|
+ standardIndexMap[dataObject.DataTime] = dataObject
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ strategy, err := area_graph.CreateStrategy(tmpConfig.NullDealWay)
|
|
|
+ if err != nil {
|
|
|
+ return err, "创建空值处理器失败"
|
|
|
+ }
|
|
|
+ err = strategy.Deal(tmpConfig, edbDataList, standardIndexMap, startDate, endDate)
|
|
|
+ if err != nil {
|
|
|
+ return err, err.Error()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 时间戳处理
|
|
|
+ for _, mapping := range edbDataList {
|
|
|
+ if dataList, ok := mapping.DataList.([]*data_manage.EdbDataList); ok {
|
|
|
+ for _, dataInfo := range dataList {
|
|
|
+ toFormatTime := utils.StringToFormatTime(dataInfo.DataTime, utils.FormatDate)
|
|
|
+ dataInfo.DataTimestamp = toFormatTime.UnixMilli()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil, ""
|
|
|
+}
|
|
|
+
|
|
|
// ChartInfoDetailV2
|
|
|
// @Title 获取图表详情
|
|
|
// @Description 获取图表详情接口
|
|
@@ -1521,7 +1589,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
|
|
|
}
|
|
|
chartInfo, err := data_manage.GetChartInfoViewById(chartInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "该图表已删除,自动查看下一图表"
|
|
|
br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
|
|
|
br.Ret = 406
|
|
@@ -1632,7 +1700,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
|
|
|
extraConfigStr := chartInfo.ExtraConfig
|
|
|
// 柱方图的一些配置
|
|
|
var barConfig data_manage.BarChartInfoReq
|
|
|
- if chartInfo != nil && chartInfo.ChartType == 7 {
|
|
|
+ if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
|
|
|
if chartInfo.BarConfig == `` {
|
|
|
br.Msg = "柱方图未配置"
|
|
|
br.ErrMsg = "柱方图未配置"
|
|
@@ -1672,7 +1740,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
|
|
|
if len(warnEdbList) > 0 {
|
|
|
chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
|
|
|
}
|
|
|
- if chartInfoId > 0 && chartInfo != nil {
|
|
|
+ if chartInfoId > 0 && chartInfo != nil && chartInfo.ChartInfoId > 0 {
|
|
|
//判断是否加入我的图库
|
|
|
{
|
|
|
var myChartCondition string
|
|
@@ -1683,7 +1751,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
|
|
|
myChartPars = append(myChartPars, chartInfo.ChartInfoId)
|
|
|
|
|
|
myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
|
|
|
return
|
|
@@ -2116,7 +2184,7 @@ func (this *ChartInfoController) ChartInfoSearch() {
|
|
|
for _, v := range keyWordArr {
|
|
|
v = strings.Replace(v, " ", "%", -1)
|
|
|
newSearchList, err := data_manage.ChartInfoSearchByKeyWord(v, showSysId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -2236,7 +2304,7 @@ func (this *ChartInfoController) ChartInfoSearchByEs() {
|
|
|
{
|
|
|
obj := data_manage.EdbInfoNoPermissionAdmin{}
|
|
|
confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -2253,7 +2321,7 @@ func (this *ChartInfoController) ChartInfoSearchByEs() {
|
|
|
isEs = true
|
|
|
} else {
|
|
|
total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, []int{utils.CHART_SOURCE_DEFAULT}, noPermissionChartIdList, startSize, pageSize)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -2407,7 +2475,7 @@ func (this *EdbInfoController) ChartInfoRefresh() {
|
|
|
chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
|
|
|
}
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "图表已被删除,无需刷新"
|
|
|
br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -2526,7 +2594,7 @@ func (this *ChartInfoController) ChartInfoDetailFromUniqueCode() {
|
|
|
status := true
|
|
|
chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
status = false
|
|
|
} else {
|
|
|
br.Msg = "获取失败"
|
|
@@ -2596,7 +2664,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
|
|
|
myChartPars = append(myChartPars, chartInfo.ChartInfoId)
|
|
|
|
|
|
myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
msg = "获取失败"
|
|
|
errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
|
|
|
return
|
|
@@ -2774,7 +2842,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
|
|
|
extraConfigStr := chartInfo.ExtraConfig //图表额外数据参数
|
|
|
var barConfig data_manage.BarChartInfoReq
|
|
|
// 柱方图的一些配置
|
|
|
- if chartInfo != nil && chartInfo.ChartType == 7 {
|
|
|
+ if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
|
|
|
if chartInfo.BarConfig == `` {
|
|
|
msg = "柱方图未配置"
|
|
|
errMsg = "柱方图未配置"
|
|
@@ -2820,11 +2888,22 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
|
|
|
*/
|
|
|
|
|
|
chartViewClassify, _ := data_manage.GetChartClassifyViewById(chartInfo.ChartClassifyId)
|
|
|
- if chartViewClassify != nil {
|
|
|
+ if chartViewClassify != nil && chartViewClassify.ChartClassifyId > 0 {
|
|
|
chartClassifyParent, _ := data_manage.GetChartClassifyViewById(chartClassify.ParentId)
|
|
|
chartInfo.ChartClassify = append(chartInfo.ChartClassify, chartClassifyParent)
|
|
|
}
|
|
|
chartInfo.ChartClassify = append(chartInfo.ChartClassify, chartViewClassify)
|
|
|
+
|
|
|
+ // 面积图 面积堆积 数据处理
|
|
|
+ if chartType == utils.CHART_TYPE_AREA {
|
|
|
+ err, errMsg = fillAreaGraphData(extraConfigStr, edbList)
|
|
|
+ if err != nil {
|
|
|
+ msg = "获取失败"
|
|
|
+ errMsg = "获取面积图数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
resp.EdbInfoList = edbList
|
|
|
//判断是否需要展示英文标识
|
|
|
chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList, chartInfo.Source, chartInfo.ChartType)
|
|
@@ -3109,7 +3188,7 @@ func (this *ChartInfoController) CopyChartInfo() {
|
|
|
}
|
|
|
chartClassify, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "分类不存在"
|
|
|
br.ErrMsg = "分类不存在"
|
|
|
return
|
|
@@ -3217,7 +3296,10 @@ func (this *ChartInfoController) CopyChartInfo() {
|
|
|
{
|
|
|
mapList := make([]*data_manage.ChartEdbMapping, 0)
|
|
|
for _, v := range edbMappingList {
|
|
|
+ // windows server环境这里得加个延时,不然生成时间戳都是一样的
|
|
|
+ time.Sleep(100 * time.Millisecond)
|
|
|
timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
|
|
|
+ //utils.FileLog.Info("IndexCode: %s, UniqueCode: %s", v.EdbInfoId, utils.MD5(utils.CHART_PREFIX+"_"+timestamp))
|
|
|
mapItem := &data_manage.ChartEdbMapping{
|
|
|
//ChartEdbMappingId: 0,
|
|
|
ChartInfoId: chartInfo.ChartInfoId,
|
|
@@ -3235,7 +3317,7 @@ func (this *ChartInfoController) CopyChartInfo() {
|
|
|
ChartStyle: v.ChartStyle,
|
|
|
ChartColor: v.ChartColor,
|
|
|
ChartWidth: v.ChartWidth,
|
|
|
- Source: v.Source,
|
|
|
+ Source: oldChartInfo.Source,
|
|
|
EdbAliasName: v.EdbAliasName,
|
|
|
IsConvert: v.IsConvert,
|
|
|
ConvertType: v.ConvertType,
|
|
@@ -3772,10 +3854,6 @@ func (this *EdbInfoController) GetBatchChartRefreshResult() {
|
|
|
// fmt.Println("end")
|
|
|
//}
|
|
|
|
|
|
-//func init() {
|
|
|
-// data.AddAllChartInfo()
|
|
|
-//}
|
|
|
-
|
|
|
// 截面散点示例数据
|
|
|
//func init() {
|
|
|
//
|
|
@@ -4081,7 +4159,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
|
|
|
if chartInfoId > 0 {
|
|
|
chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
|
|
|
if err != nil {
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
+ if utils.IsErrNoRow(err) {
|
|
|
br.Msg = "该图表已删除,自动查看下一图表"
|
|
|
br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
|
|
|
br.Ret = 406
|
|
@@ -4169,7 +4247,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
|
|
|
extraConfigStr := chartInfo.ExtraConfig
|
|
|
// 柱方图的一些配置
|
|
|
var barConfig data_manage.BarChartInfoReq
|
|
|
- if chartInfo != nil && chartInfo.ChartType == 7 {
|
|
|
+ if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
|
|
|
if chartInfo.BarConfig == `` {
|
|
|
br.Msg = "柱方图未配置"
|
|
|
br.ErrMsg = "柱方图未配置"
|
|
@@ -4230,7 +4308,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
|
|
|
if len(warnEdbList) > 0 {
|
|
|
chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
|
|
|
}
|
|
|
- if chartInfoId > 0 && chartInfo != nil {
|
|
|
+ if chartInfoId > 0 && chartInfo != nil && chartInfo.ChartInfoId > 0 {
|
|
|
//判断是否加入我的图库
|
|
|
{
|
|
|
var myChartCondition string
|
|
@@ -4241,7 +4319,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
|
|
|
myChartPars = append(myChartPars, chartInfo.ChartInfoId)
|
|
|
|
|
|
myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
|
|
|
return
|
|
@@ -4643,7 +4721,7 @@ func (this *ChartInfoController) ChartList() {
|
|
|
if len(chartClassifyIdsStr) > 0 {
|
|
|
if !subClassify {
|
|
|
chartClassifyId, err := data_manage.GetChartClassifyByIdsNoSubClassify(chartClassifyIds)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取图表信息失败"
|
|
|
br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
|
|
|
return
|
|
@@ -4723,7 +4801,7 @@ func (this *ChartInfoController) ChartList() {
|
|
|
{
|
|
|
obj := data_manage.EdbInfoNoPermissionAdmin{}
|
|
|
confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -4741,7 +4819,7 @@ func (this *ChartInfoController) ChartList() {
|
|
|
|
|
|
//获取图表信息
|
|
|
list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Success = true
|
|
|
br.Msg = "获取图表信息失败"
|
|
|
br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
|
|
@@ -4749,7 +4827,7 @@ func (this *ChartInfoController) ChartList() {
|
|
|
}
|
|
|
|
|
|
myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取图表信息失败"
|
|
|
br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -4841,7 +4919,7 @@ func (this *ChartInfoController) ChartList() {
|
|
|
}
|
|
|
|
|
|
resp := new(data_manage.ChartListResp)
|
|
|
- if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
|
|
|
+ if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
|
|
|
items := make([]*data_manage.ChartInfoView, 0)
|
|
|
resp.Paging = page
|
|
|
resp.List = items
|
|
@@ -4852,7 +4930,7 @@ func (this *ChartInfoController) ChartList() {
|
|
|
}
|
|
|
|
|
|
dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取指标信息失败"
|
|
|
br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
|
|
|
return
|
|
@@ -4920,7 +4998,7 @@ func (this *ChartInfoController) ModifyChartList() {
|
|
|
if len(chartClassifyIds) > 0 {
|
|
|
if !req.SubClassify {
|
|
|
chartClassifyId, err := data_manage.GetChartClassifyByIdsNoSubClassify(chartClassifyIds)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ if err != nil && !utils.IsErrNoRow(err) {
|
|
|
br.Msg = "获取图表信息失败"
|
|
|
br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
|
|
|
return
|