Răsfoiți Sursa

wip:分析结果保存

wangshan 6 luni în urmă
părinte
comite
cda60a47ed
1 a modificat fișierele cu 8 adăugiri și 4 ștergeri
  1. 8 4
      marketanalysis/marketanalysis.go

+ 8 - 4
marketanalysis/marketanalysis.go

@@ -912,11 +912,15 @@ func (a *AnalysisEntity) UpdateOffline(offline bool) bool {
 
 // UpdateState 更新报告生成状态
 func (a *AnalysisEntity) UpdateState(state int) bool {
+	setMap := map[string]interface{}{
+		"i_state":      state,
+		"l_updateTime": time.Now().Unix(),
+	}
+	if state == ReportStateGenerated {
+		setMap["l_finishTime"] = time.Now().Unix()
+	}
 	data := map[string]interface{}{
-		"$set": map[string]interface{}{
-			"i_state":      state,
-			"l_updateTime": time.Now().Unix(),
-		},
+		"$set": setMap,
 	}
 	update := a.Mgo.UpdateById(ReportHistoryTable, a.MgoRecordId, data)
 	if !update {