|
@@ -64,7 +64,7 @@ func UploadChart(chartInfoId int, description string, uploaderInfo *system.Admin
|
|
|
err = fmt.Errorf("系统处理中,请稍后重试!")
|
|
|
return
|
|
|
}
|
|
|
- utils.Rc.SetNX(cacheKey, 1, 30*time.Second)
|
|
|
+ utils.Rc.SetNX(cacheKey, 1, 10*time.Minute)
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
go alarm_msg.SendAlarmMsg(fmt.Sprintf("上传图表至社区失败:Err:%v,ErrMsg:%s", err, errMsg), 3)
|
|
@@ -92,15 +92,17 @@ func UploadChart(chartInfoId int, description string, uploaderInfo *system.Admin
|
|
|
|
|
|
//查询图表指标
|
|
|
//获取原图表关联的指标信息列表
|
|
|
- chartMappingList, err := data_manage.GetChartMappingList(chartInfoId)
|
|
|
+ chartMappingList, err := data_manage.GetChartMappingListOrderByEdbInfoId(chartInfoId)
|
|
|
if err != nil {
|
|
|
errMsg = "获取图表关联的指标信息失败"
|
|
|
err = fmt.Errorf("获取图表关联的指标信息失败,Err:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
edbIds := make([]int, 0)
|
|
|
+ edbInfoStr := ""
|
|
|
for _, v := range chartMappingList {
|
|
|
edbIds = append(edbIds, v.EdbInfoId)
|
|
|
+ edbInfoStr += strconv.Itoa(v.EdbInfoId) + ","
|
|
|
}
|
|
|
chartSeriesList := make([]*data_manage.ChartSeries, 0)
|
|
|
chartSeriesEdbList := make([]*data_manage.ChartSeriesEdbMapping, 0)
|
|
@@ -126,7 +128,7 @@ func UploadChart(chartInfoId int, description string, uploaderInfo *system.Admin
|
|
|
edbInfoDataList []*AddEdbDataReq
|
|
|
)
|
|
|
//查询指标详情
|
|
|
- edbInfoList, edbMappingList, edbInfoDataList, err = GetEdbListByEdbInfoId(edbIds)
|
|
|
+ edbInfoList, edbMappingList, edbInfoDataList, err = GetEdbListByEdbInfoId(edbIds, true)
|
|
|
if err != nil {
|
|
|
errMsg = "获取指标详情失败"
|
|
|
err = fmt.Errorf("获取指标详情失败,Err:" + err.Error())
|
|
@@ -184,6 +186,13 @@ func UploadChart(chartInfoId int, description string, uploaderInfo *system.Admin
|
|
|
err = fmt.Errorf("更新图表ID失败,Err:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
+ // 新增投研资源库里的图表和指标绑定关系
|
|
|
+ err = data_manage.AddForumChartEdbMapping(chartInfoId, edbInfoStr)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "新增投研资源库里的图表和指标绑定关系失败"
|
|
|
+ err = fmt.Errorf("新增投研资源库里的图表和指标绑定关系失败,Err:" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return
|
|
@@ -197,7 +206,7 @@ func UpdateChart(chartInfoId int) (err error, errMsg string) {
|
|
|
err = fmt.Errorf("系统处理中,请稍后重试!")
|
|
|
return
|
|
|
}
|
|
|
- utils.Rc.SetNX(cacheKey, 1, 30*time.Second)
|
|
|
+ utils.Rc.SetNX(cacheKey, 1, 10*time.Minute)
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
go alarm_msg.SendAlarmMsg(fmt.Sprintf("同步图表信息至社区失败:Err:%v,ErrMsg:%s", err, errMsg), 3)
|
|
@@ -226,15 +235,17 @@ func UpdateChart(chartInfoId int) (err error, errMsg string) {
|
|
|
|
|
|
//查询图表指标
|
|
|
//获取原图表关联的指标信息列表
|
|
|
- chartMappingList, err := data_manage.GetChartMappingList(chartInfoId)
|
|
|
+ chartMappingList, err := data_manage.GetChartMappingListOrderByEdbInfoId(chartInfoId)
|
|
|
if err != nil {
|
|
|
errMsg = "获取图表关联的指标信息失败"
|
|
|
err = fmt.Errorf("获取图表关联的指标信息失败,Err:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
edbIds := make([]int, 0)
|
|
|
+ edbInfoStr := ""
|
|
|
for _, v := range chartMappingList {
|
|
|
edbIds = append(edbIds, v.EdbInfoId)
|
|
|
+ edbInfoStr += strconv.Itoa(v.EdbInfoId) + ","
|
|
|
}
|
|
|
chartSeriesList := make([]*data_manage.ChartSeries, 0)
|
|
|
chartSeriesEdbList := make([]*data_manage.ChartSeriesEdbMapping, 0)
|
|
@@ -259,7 +270,19 @@ func UpdateChart(chartInfoId int) (err error, errMsg string) {
|
|
|
edbInfoDataList []*AddEdbDataReq
|
|
|
)
|
|
|
//查询指标详情
|
|
|
- edbInfoList, edbMappingList, edbInfoDataList, err = GetEdbListByEdbInfoId(edbIds)
|
|
|
+ isGetEdbData := false
|
|
|
+ // 查询投研资源库里的图表和指标绑定关系
|
|
|
+ oldEdbInfoStr, err := data_manage.GetForumEdbInfoIdsByChartInfoId(chartInfoId)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "获取投研资源库里的图表和指标绑定关系失败"
|
|
|
+ err = fmt.Errorf("获取投研资源库里的图表和指标绑定关系失败,Err:" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if oldEdbInfoStr != edbInfoStr { // 图表更换过指标需要重新获取指标数据
|
|
|
+ isGetEdbData = true
|
|
|
+ }
|
|
|
+ //查询指标详情
|
|
|
+ edbInfoList, edbMappingList, edbInfoDataList, err = GetEdbListByEdbInfoId(edbIds, isGetEdbData)
|
|
|
if err != nil {
|
|
|
errMsg = "获取指标详情失败"
|
|
|
err = fmt.Errorf("获取指标详情失败,Err:" + err.Error())
|
|
@@ -306,10 +329,17 @@ func UpdateChart(chartInfoId int) (err error, errMsg string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 更新投研资源库里的图表和指标绑定关系
|
|
|
+ err = data_manage.UpdateForumChartEdbMapping(chartInfoId, edbInfoStr)
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "更新投研资源库里的图表和指标绑定关系失败"
|
|
|
+ err = fmt.Errorf("更新投研资源库里的图表和指标绑定关系失败,Err:" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetEdbListByEdbInfoId(edbInfoIds []int) (edbInfoList []*data_manage.EdbInfo, edbMappingList []*data_manage.EdbInfoCalculateMapping, edbInfoDataList []*AddEdbDataReq, err error) {
|
|
|
+func GetEdbListByEdbInfoId(edbInfoIds []int, isGetEdbData bool) (edbInfoList []*data_manage.EdbInfo, edbMappingList []*data_manage.EdbInfoCalculateMapping, edbInfoDataList []*AddEdbDataReq, err error) {
|
|
|
//查询指标信息
|
|
|
//查询指标映射
|
|
|
//查询所有指标数据
|
|
@@ -339,30 +369,31 @@ func GetEdbListByEdbInfoId(edbInfoIds []int) (edbInfoList []*data_manage.EdbInfo
|
|
|
err = fmt.Errorf(" GetEdbInfoByIdList err: %s", err.Error())
|
|
|
return
|
|
|
}
|
|
|
+ if isGetEdbData {
|
|
|
+ for _, v := range edbInfoList {
|
|
|
+ if _, ok := chartEdbInfoIdMap[v.EdbInfoId]; !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ var dataList []*data_manage.EdbDataBase
|
|
|
+ if v.Source == utils.DATA_SOURCE_BUSINESS && utils.UseMongo {
|
|
|
+ dataList, err = data_manage.GetEdbDataBaseMongoByEdbInfoId(v.EdbInfoId, v.Source, v.SubSource)
|
|
|
+ } else if v.Source == utils.DATA_SOURCE_THS && v.SubSource == utils.DATA_SUB_SOURCE_HIGH_FREQUENCY && utils.UseMongo {
|
|
|
+ dataList, err = data_manage.GetThsHfEdbDataBaseMongoByEdbInfoId(v.EdbInfoId, v.Source, v.SubSource)
|
|
|
+ } else {
|
|
|
+ dataList, err = data_manage.GetEdbDataBaseByEdbInfoId(v.EdbInfoId, v.Source, v.SubSource)
|
|
|
+ }
|
|
|
|
|
|
- for _, v := range edbInfoList {
|
|
|
- if _, ok := chartEdbInfoIdMap[v.EdbInfoId]; !ok {
|
|
|
- continue
|
|
|
- }
|
|
|
- var dataList []*data_manage.EdbDataBase
|
|
|
- if v.Source == utils.DATA_SOURCE_BUSINESS && utils.UseMongo {
|
|
|
- dataList, err = data_manage.GetEdbDataBaseMongoByEdbInfoId(v.EdbInfoId, v.Source, v.SubSource)
|
|
|
- } else if v.Source == utils.DATA_SOURCE_THS && v.SubSource == utils.DATA_SUB_SOURCE_HIGH_FREQUENCY && utils.UseMongo {
|
|
|
- dataList, err = data_manage.GetThsHfEdbDataBaseMongoByEdbInfoId(v.EdbInfoId, v.Source, v.SubSource)
|
|
|
- } else {
|
|
|
- dataList, err = data_manage.GetEdbDataBaseByEdbInfoId(v.EdbInfoId, v.Source, v.SubSource)
|
|
|
- }
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf("查询指标数据失败 Err: %s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- if err != nil {
|
|
|
- err = fmt.Errorf("查询指标数据失败 Err: %s", err.Error())
|
|
|
- return
|
|
|
+ tmp := new(AddEdbDataReq)
|
|
|
+ tmp.EdbCode = v.EdbCode
|
|
|
+ tmp.EdbType = v.EdbType
|
|
|
+ tmp.DataList = dataList
|
|
|
+ edbInfoDataList = append(edbInfoDataList, tmp)
|
|
|
}
|
|
|
-
|
|
|
- tmp := new(AddEdbDataReq)
|
|
|
- tmp.EdbCode = v.EdbCode
|
|
|
- tmp.EdbType = v.EdbType
|
|
|
- tmp.DataList = dataList
|
|
|
- edbInfoDataList = append(edbInfoDataList, tmp)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -763,6 +794,8 @@ func ChartBatchUpdateAndUpload(chartClassifyInfo *data_manage.ChartClassify, sys
|
|
|
offset = (i + 1) * pageSize
|
|
|
}
|
|
|
utils.FileLog.Info("批量上传已经上架的分类下的图表到资源库中完成, 新增图表数据总数:", success)
|
|
|
+ // 更新指标数据
|
|
|
+ utils.Rc.LPush(utils.CACHE_KEY_EDB_DATA_UPDATE_LOG, []byte("1"))
|
|
|
return
|
|
|
}
|
|
|
|