| 
														
															@@ -16,7 +16,7 @@ import ( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 ) 
														 | 
														
														 | 
														
															 ) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 // WeightScatterPlot 体重散点图 获取图表数据 
														 | 
														
														 | 
														
															 // WeightScatterPlot 体重散点图 获取图表数据 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-func (s *StoreEntry) WeightScatterPlot(ctx context.Context, req *pasturePb.SearchGrowthCurvesRequest) (*pasturePb.GrowthCurvesResponse, error) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+func (s *StoreEntry) WeightScatterPlot(ctx context.Context, req *pasturePb.SearchGrowthCurvesRequest, pagination *pasturePb.PaginationModel) (*pasturePb.GrowthCurvesResponse, error) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	userModel, err := s.GetUserModel(ctx) 
														 | 
														
														 | 
														
															 	userModel, err := s.GetUserModel(ctx) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if err != nil { 
														 | 
														
														 | 
														
															 	if err != nil { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		return nil, xerr.Custom("当前用户信息错误,请退出重新登录") 
														 | 
														
														 | 
														
															 		return nil, xerr.Custom("当前用户信息错误,请退出重新登录") 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -37,10 +37,13 @@ func (s *StoreEntry) WeightScatterPlot(ctx context.Context, req *pasturePb.Searc 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		pref.Where("birth_at BETWEEN ? AND ?", t0.Unix(), t1.Unix()+86399) 
														 | 
														
														 | 
														
															 		pref.Where("birth_at BETWEEN ? AND ?", t0.Unix(), t1.Unix()+86399) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	if err = pref.Find(&cowList).Error; err != nil { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	var count int64 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	if err = pref.Count(&count). 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		Limit(int(pagination.PageSize)). 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		Offset(int(pagination.PageOffset)). 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		Find(&cowList).Error; err != nil { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		return nil, err 
														 | 
														
														 | 
														
															 		return nil, err 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	penList, err := s.GetPenList(ctx, userModel.AppPasture.Id) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if err != nil { 
														 | 
														
														 | 
														
															 	if err != nil { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		return nil, xerr.WithStack(err) 
														 | 
														
														 | 
														
															 		return nil, xerr.WithStack(err) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -53,18 +56,15 @@ func (s *StoreEntry) WeightScatterPlot(ctx context.Context, req *pasturePb.Searc 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	cowData := make([]*pasturePb.CowList, 0) 
														 | 
														
														 | 
														
															 	cowData := make([]*pasturePb.CowList, 0) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	for _, cow := range cowList { 
														 | 
														
														 | 
														
															 	for _, cow := range cowList { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		currentWeight := float32(cow.CurrentWeight) / 1000 
														 | 
														
														 | 
														
															 		currentWeight := float32(cow.CurrentWeight) / 1000 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		penName := "" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		for _, v := range penList { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			if cow.PenId != v.Id { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-				continue 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			penName = v.Name 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		admissionAtFormat := "" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		if cow.AdmissionAt > 0 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+			admissionAtFormat = time.Unix(cow.AdmissionAt, 0).Format(model.LayoutDate2) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		} 
														 | 
														
														 | 
														
															 		} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		cowData = append(cowData, &pasturePb.CowList{ 
														 | 
														
														 | 
														
															 		cowData = append(cowData, &pasturePb.CowList{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			CowId:                    int32(cow.Id), 
														 | 
														
														 | 
														
															 			CowId:                    int32(cow.Id), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			EarNumber:                cow.EarNumber, 
														 | 
														
														 | 
														
															 			EarNumber:                cow.EarNumber, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			DayAge:                   cow.GetDayAge(), 
														 | 
														
														 | 
														
															 			DayAge:                   cow.GetDayAge(), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			PenName:                  penName, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+			PenName:                  cow.PenName, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			CurrentWeight:            currentWeight, 
														 | 
														
														 | 
														
															 			CurrentWeight:            currentWeight, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			BirthAt:                  int32(cow.BirthAt), 
														 | 
														
														 | 
														
															 			BirthAt:                  int32(cow.BirthAt), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			BirthWeight:              float32(cow.BirthWeight) / 1000, 
														 | 
														
														 | 
														
															 			BirthWeight:              float32(cow.BirthWeight) / 1000, 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -72,6 +72,7 @@ func (s *StoreEntry) WeightScatterPlot(ctx context.Context, req *pasturePb.Searc 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			AverageDailyWeightGain:   float32(cow.GetAverageDailyWeight()), 
														 | 
														
														 | 
														
															 			AverageDailyWeightGain:   float32(cow.GetAverageDailyWeight()), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			PreviousStageDailyWeight: float32(cow.GetPreviousStageDailyWeight()), 
														 | 
														
														 | 
														
															 			PreviousStageDailyWeight: float32(cow.GetPreviousStageDailyWeight()), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			AdmissionAge:             cow.GetAdmissionAge(), 
														 | 
														
														 | 
														
															 			AdmissionAge:             cow.GetAdmissionAge(), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+			AdmissionAtFormat:        admissionAtFormat, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		}) 
														 | 
														
														 | 
														
															 		}) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		chartsList.CowId = append(chartsList.CowId, int32(cow.Id)) 
														 | 
														
														 | 
														
															 		chartsList.CowId = append(chartsList.CowId, int32(cow.Id)) 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -335,7 +336,7 @@ func (s *StoreEntry) PenWeight(ctx context.Context, req *pasturePb.PenWeightRequ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		Code: http.StatusOK, 
														 | 
														
														 | 
														
															 		Code: http.StatusOK, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		Msg:  "ok", 
														 | 
														
														 | 
														
															 		Msg:  "ok", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		Data: &pasturePb.PenWeightData{ 
														 | 
														
														 | 
														
															 		Data: &pasturePb.PenWeightData{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			CowList:  model.CowSlice(cowList).ToPB2(penMap, penWeightList), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+			CowList:  model.CowSlice(cowList).ToPB2(penWeightList), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			Total:    int32(count), 
														 | 
														
														 | 
														
															 			Total:    int32(count), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			Page:     pagination.Page, 
														 | 
														
														 | 
														
															 			Page:     pagination.Page, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 			PageSize: pagination.PageSize, 
														 | 
														
														 | 
														
															 			PageSize: pagination.PageSize, 
														 |