|
@@ -1434,6 +1434,7 @@ func ChartInfoRefreshV2(chartInfoId int) (err error, isAsync bool) {
|
|
|
|
|
|
|
|
|
err, isAsync = EdbInfoRefreshAllFromBaseV3(edbIdList, false, false)
|
|
|
+
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -1445,7 +1446,7 @@ func ChartInfoRefreshV2(chartInfoId int) (err error, isAsync bool) {
|
|
|
|
|
|
|
|
|
|
|
|
-func BatchChartInfoRefreshV2(chartInfoList []*data_manage.ChartInfo) (err error, isAsync bool) {
|
|
|
+func BatchChartInfoRefreshV2(chartInfoList []*data_manage.ChartInfo, redisKey string) (err error, isAsync bool) {
|
|
|
if len(chartInfoList) <= 0 {
|
|
|
return
|
|
|
}
|
|
@@ -1454,15 +1455,28 @@ func BatchChartInfoRefreshV2(chartInfoList []*data_manage.ChartInfo) (err error,
|
|
|
chartInfoIdSlice = append(chartInfoIdSlice, chartInfo.ChartInfoId)
|
|
|
}
|
|
|
|
|
|
- var errmsg string
|
|
|
+ var errMsg string
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
- go alarm_msg.SendAlarmMsg("ChartInfoRefresh:"+errmsg, 3)
|
|
|
+ go alarm_msg.SendAlarmMsg("ChartInfoRefresh:"+errMsg, 3)
|
|
|
|
|
|
- fmt.Println("ChartInfoRefresh Err:" + errmsg)
|
|
|
+ fmt.Println("ChartInfoRefresh Err:" + errMsg)
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
+
|
|
|
+ isDeleteCache := true
|
|
|
+ if redisKey != `` {
|
|
|
+
|
|
|
+ utils.Rc.SetNX(redisKey, 1, time.Minute*10)
|
|
|
+ defer func() {
|
|
|
+ if isDeleteCache {
|
|
|
+ utils.Rc.Delete(redisKey)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
edbIdList := make([]int, 0)
|
|
|
edbInfoIdMap := make(map[int]int)
|
|
|
edbMappingList, err := data_manage.GetChartEdbMappingListByIdList(chartInfoIdSlice)
|
|
@@ -1473,10 +1487,88 @@ func BatchChartInfoRefreshV2(chartInfoList []*data_manage.ChartInfo) (err error,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- err, isAsync = EdbInfoRefreshAllFromBaseV3(edbIdList, false, false)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
+
|
|
|
+ newBaseEdbInfoArr, newBasePredictEdbInfoArr, newCalculateMap, newPredictCalculateMap, calculateArr, predictCalculateArr := getEdbInfoIdList(edbIdList)
|
|
|
+
|
|
|
+
|
|
|
+ totalEdbInfo := len(newBaseEdbInfoArr) + len(calculateArr) + len(predictCalculateArr)
|
|
|
+
|
|
|
+ if totalEdbInfo > 20 {
|
|
|
+ isAsync = true
|
|
|
+ isDeleteCache = false
|
|
|
+ go refreshChartEdbInfo(chartInfoList, redisKey, newBaseEdbInfoArr, newBasePredictEdbInfoArr, newCalculateMap, newPredictCalculateMap, calculateArr, predictCalculateArr)
|
|
|
+ } else {
|
|
|
+ err = edbInfoRefreshAll(false, newBaseEdbInfoArr, newBasePredictEdbInfoArr, newCalculateMap, newPredictCalculateMap, calculateArr, predictCalculateArr)
|
|
|
+
|
|
|
+
|
|
|
+ for _, v := range chartInfoList {
|
|
|
+ key := utils.HZ_CHART_LIB_DETAIL + v.UniqueCode
|
|
|
+ _ = utils.Rc.Delete(key)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func refreshChartEdbInfo(chartInfoList []*data_manage.ChartInfo, redisKey string, newBaseEdbInfoArr, newBasePredictEdbInfoArr []*data_manage.EdbInfo, newCalculateMap, newPredictCalculateMap map[int]*data_manage.EdbInfo, calculateArr, predictCalculateArr []int) {
|
|
|
+ edbInfoRefreshAll(false, newBaseEdbInfoArr, newBasePredictEdbInfoArr, newCalculateMap, newPredictCalculateMap, calculateArr, predictCalculateArr)
|
|
|
+
|
|
|
+
|
|
|
+ for _, v := range chartInfoList {
|
|
|
+ key := utils.HZ_CHART_LIB_DETAIL + v.UniqueCode
|
|
|
+ _ = utils.Rc.Delete(key)
|
|
|
+ }
|
|
|
+
|
|
|
+ if redisKey != `` {
|
|
|
+ utils.Rc.Delete(redisKey)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func GetBatchChartRefreshKey(source string, reportId, reportChapterId int) string {
|
|
|
+ if source == `` {
|
|
|
+ return ``
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Sprint("batch_chart_refresh:", source, ":", reportId, ":", reportChapterId)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func CheckBatchChartRefreshResult(source string, reportId, reportChapterId int) (refreshResult bool) {
|
|
|
+ refreshResult = true
|
|
|
+ redisKey := GetBatchChartRefreshKey(source, reportId, reportChapterId)
|
|
|
+ if redisKey != `` {
|
|
|
+
|
|
|
+ isOk := utils.Rc.IsExist(redisKey)
|
|
|
+ if isOk {
|
|
|
+ refreshResult = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return
|