wangshan 6 bulan lalu
induk
melakukan
de734db938
2 mengubah file dengan 34 tambahan dan 26 penghapusan
  1. 32 24
      marketanalysis/common.go
  2. 2 2
      marketanalysis/marketanalysis.go

+ 32 - 24
marketanalysis/common.go

@@ -16,7 +16,7 @@ import (
 )
 
 // 中标单位分析
-func WinningAnalysis(thisWinnerRow BuyerWinnerRow, rMap *sync.Map, entArrMap map[string]float64, winnerName map[string]string, sy *sync.WaitGroup) {
+func WinningAnalysis(thisWinnerRow BuyerWinnerRow, rMap *sync.Map, entArrMap map[string]float64, winnerName map[string]string, sy *sync.WaitGroup, offline bool) {
 	defer sy.Done()
 	type s_Winner struct {
 		Name        string      `json:"key"`
@@ -100,13 +100,15 @@ func WinningAnalysis(thisWinnerRow BuyerWinnerRow, rMap *sync.Map, entArrMap map
 			}*/
 			ss = append(ss, _dd)
 		}
-		if len(ss) > Top3 {
-			_d.Data = ss[:Top3]
-		} else {
+		if offline {
 			_d.Data = ss
-		}
-		if len(countMap) >= Top30 {
-			break
+		} else {
+			if len(ss) > Top3 {
+				_d.Data = ss[:Top3]
+			}
+			if len(countMap) >= Top30 {
+				break
+			}
 		}
 		countMap = append(countMap, _d)
 	}
@@ -150,13 +152,15 @@ func WinningAnalysis(thisWinnerRow BuyerWinnerRow, rMap *sync.Map, entArrMap map
 			}*/
 			ss = append(ss, _dd)
 		}
-		if len(ss) > Top3 {
-			_d.Data = ss[:Top3]
-		} else {
+		if offline {
 			_d.Data = ss
-		}
-		if len(amountMap) >= Top30 {
-			break
+		} else {
+			if len(ss) > Top3 {
+				_d.Data = ss[:Top3]
+			}
+			if len(amountMap) >= Top30 {
+				break
+			}
 		}
 		amountMap = append(amountMap, _d)
 	}
@@ -213,7 +217,7 @@ func amountDistribution(v float64, data map[string]*distributionTrend) {
 	}
 
 }
-func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap *sync.Map, winnerName map[string]string, sy *sync.WaitGroup) {
+func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap *sync.Map, winnerName map[string]string, sy *sync.WaitGroup, offline bool) {
 	defer sy.Done()
 	type buyer struct {
 		Name        string      `json:"key"`
@@ -293,14 +297,16 @@ func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap *sync.Map, winnerName map[s
 			}*/
 			ss = append(ss, _dd)
 		}
-		if len(ss) > Top3 {
-			_d.Data = ss[:Top3]
+		if !offline {
+			if len(ss) > Top3 {
+				_d.Data = ss[:Top3]
+			}
+			if len(countMap) >= Top30 {
+				break
+			}
 		} else {
 			_d.Data = ss
 		}
-		if len(countMap) >= Top30 {
-			break
-		}
 		countMap = append(countMap, _d)
 	}
 
@@ -345,14 +351,16 @@ func BuyerAnalysis(thisBuyerRow BuyerWinnerRow, rMap *sync.Map, winnerName map[s
 
 			ss = append(ss, _dd)
 		}
-		if len(ss) > Top3 {
-			_d.Data = ss[:Top3]
+		if !offline {
+			if len(ss) > Top3 {
+				_d.Data = ss[:Top3]
+			}
+			if len(amountMap) >= Top30 {
+				break
+			}
 		} else {
 			_d.Data = ss
 		}
-		if len(amountMap) >= Top30 {
-			break
-		}
 		amountMap = append(amountMap, _d)
 	}
 	rMap.Store("buyer_time_distribution", buyerMap)

+ 2 - 2
marketanalysis/marketanalysis.go

@@ -1569,8 +1569,8 @@ func (a *AnalysisEntity) BuyerWinnerAnalysis() map[string]interface{} {
 	var rMap = sync.Map{}
 	sy := sync.WaitGroup{}
 	sy.Add(2)
-	go BuyerAnalysis(thisBuyerWinnerRow, &rMap, winnerName, &sy)
-	go WinningAnalysis(thisBuyerWinnerRow, &rMap, entArrMap, winnerName, &sy)
+	go BuyerAnalysis(thisBuyerWinnerRow, &rMap, winnerName, &sy, a.Offline == ValueOffline)
+	go WinningAnalysis(thisBuyerWinnerRow, &rMap, entArrMap, winnerName, &sy, a.Offline == ValueOffline)
 	sy.Wait()
 	log.Println("采购单位-中标单位分析报告程序计算耗时===", time.Since(t))
 	rMaps := make(map[string]interface{})