|
@@ -13,12 +13,12 @@ import (
|
|
|
)
|
|
|
|
|
|
func EtaForumChartUpdate(cont context.Context) (err error) {
|
|
|
- err = ChartInfoSaveBatch()
|
|
|
+ err = ChartInfoSaveBatch(false)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateChart 更新社区里的图表接口
|
|
|
-func UpdateChart(chartInfoId int) (err error, errMsg string) {
|
|
|
+func UpdateChart(chartInfoId int, withEdbData bool) (err error, errMsg string) {
|
|
|
// 设置缓存 防止重复更新
|
|
|
cacheKey := "eta_forum_task:UpdateChart:" + strconv.Itoa(chartInfoId)
|
|
|
if utils.Rc.Get(cacheKey) != nil {
|
|
@@ -93,7 +93,7 @@ func UpdateChart(chartInfoId int) (err error, errMsg string) {
|
|
|
err = fmt.Errorf("获取投研资源库里的图表和指标绑定关系失败,Err:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
- if oldEdbInfoStr != edbInfoStr { // 图表更换过指标需要重新获取指标数据
|
|
|
+ if oldEdbInfoStr != edbInfoStr || withEdbData { // 图表更换过指标需要重新获取指标数据
|
|
|
isGetEdbData = true
|
|
|
}
|
|
|
edbInfoList, edbMappingList, edbInfoDataList, err = GetEdbListByEdbInfoId(edbIds, isGetEdbData)
|
|
@@ -278,7 +278,7 @@ func traceEdbInfoByEdbInfoId(edbInfoId int, hasFindMap map[int]struct{}, edbInfo
|
|
|
}
|
|
|
|
|
|
// 批量上传图表分类信息
|
|
|
-func ChartInfoSaveBatch() (err error) {
|
|
|
+func ChartInfoSaveBatch(withEdbData bool) (err error) {
|
|
|
var tmpErr []error
|
|
|
cacheKey := "eta_forum_task:ChartInfoSaveBatchAdmin"
|
|
|
if !utils.Rc.SetNX(cacheKey, 1, 30*time.Minute) {
|
|
@@ -330,7 +330,7 @@ func ChartInfoSaveBatch() (err error) {
|
|
|
var er error
|
|
|
var msg string
|
|
|
// 更新图表数据
|
|
|
- er, msg = UpdateChart(chartInfo.ChartInfoId)
|
|
|
+ er, msg = UpdateChart(chartInfo.ChartInfoId, withEdbData)
|
|
|
|
|
|
if er != nil {
|
|
|
er = fmt.Errorf("图表ID %d, 更新图表数据失败: %s, %v", chartInfo.ChartInfoId, msg, er)
|
|
@@ -344,8 +344,10 @@ func ChartInfoSaveBatch() (err error) {
|
|
|
}
|
|
|
utils.FileLog.Info("更新图表数据完成, 更新图表数据总数:", success)
|
|
|
}
|
|
|
- // 更新指标数据
|
|
|
- utils.Rc.LPush(utils.CACHE_KEY_EDB_DATA_UPDATE_LOG, []byte("1"))
|
|
|
+ // 更新指标数据, 全量更新时不需要单独更新指标数据
|
|
|
+ if !withEdbData {
|
|
|
+ utils.Rc.LPush(utils.CACHE_KEY_EDB_DATA_UPDATE_LOG, []byte("1"))
|
|
|
+ }
|
|
|
sysUser, err := models.GetSysUserByAdminName("admin")
|
|
|
if err != nil {
|
|
|
err = fmt.Errorf("获取系统用户失败,Err:" + err.Error())
|