|  | @@ -1,9 +1,6 @@
 | 
	
		
			
				|  |  |  package model
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import (
 | 
	
		
			
				|  |  | -	"fmt"
 | 
	
		
			
				|  |  | -	"kpt-pasture/store/kptstore"
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 | 
	
		
			
				|  |  |  )
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -69,34 +66,22 @@ func NewEventEstrus(
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  type EventEstrusSlice []*EventEstrus
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -func (e EventEstrusSlice) ToPB(
 | 
	
		
			
				|  |  | -	dB *kptstore.DB,
 | 
	
		
			
				|  |  | -	getCowInfo func(dB *kptstore.DB, cowId int64) *Cow,
 | 
	
		
			
				|  |  | -	getCowLastEvent func(DB *kptstore.DB, cowId int64, eventCategoryId pasturePb.EventCategory_Kind) *EventCowLog,
 | 
	
		
			
				|  |  | -) []*pasturePb.EstrusItems {
 | 
	
		
			
				|  |  | -	res := make([]*pasturePb.EstrusItems, len(e))
 | 
	
		
			
				|  |  | +func (e EventEstrusSlice) ToPB() []*pasturePb.SearchEventEstrusList {
 | 
	
		
			
				|  |  | +	res := make([]*pasturePb.SearchEventEstrusList, len(e))
 | 
	
		
			
				|  |  |  	for i, v := range e {
 | 
	
		
			
				|  |  | -		cowInfo := getCowInfo(dB, v.CowId)
 | 
	
		
			
				|  |  | -		lastEventLog := getCowLastEvent(dB, v.CowId, pasturePb.EventCategory_Breed)
 | 
	
		
			
				|  |  | -		planDay, optimumMatingTime := "", ""
 | 
	
		
			
				|  |  | -		lastBreedEventDetails := ""
 | 
	
		
			
				|  |  | -		if lastEventLog != nil {
 | 
	
		
			
				|  |  | -			lastBreedEventDetails = fmt.Sprintf("%s %s", lastEventLog.EventTypeName, lastEventLog.EventDescription)
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		res[i] = &pasturePb.EstrusItems{
 | 
	
		
			
				|  |  | -			Id:                     int32(v.Id),
 | 
	
		
			
				|  |  | -			CowId:                  int32(v.CowId),
 | 
	
		
			
				|  |  | -			EarNumber:              v.EarNumber,
 | 
	
		
			
				|  |  | -			DayAge:                 cowInfo.DayAge,
 | 
	
		
			
				|  |  | -			Lact:                   v.Lact,
 | 
	
		
			
				|  |  | -			PenName:                cowInfo.PenName,
 | 
	
		
			
				|  |  | -			Status:                 v.IsShow,
 | 
	
		
			
				|  |  | -			CalvingAge:             cowInfo.CalvingAge,
 | 
	
		
			
				|  |  | -			PlanDay:                planDay,
 | 
	
		
			
				|  |  | -			MatingTimes:            cowInfo.MatingTimes,
 | 
	
		
			
				|  |  | -			OptimumMatingStartTime: optimumMatingTime,
 | 
	
		
			
				|  |  | -			OptimumMatingEndTime:   optimumMatingTime,
 | 
	
		
			
				|  |  | -			LastBreedEventDetails:  lastBreedEventDetails,
 | 
	
		
			
				|  |  | +		res[i] = &pasturePb.SearchEventEstrusList{
 | 
	
		
			
				|  |  | +			Id:              int32(v.Id),
 | 
	
		
			
				|  |  | +			CowId:           int32(v.CowId),
 | 
	
		
			
				|  |  | +			EarNumber:       v.EarNumber,
 | 
	
		
			
				|  |  | +			DayAge:          v.DayAge,
 | 
	
		
			
				|  |  | +			Lact:            v.Lact,
 | 
	
		
			
				|  |  | +			EstrusAt:        int32(v.RealityDay),
 | 
	
		
			
				|  |  | +			IsMating:        v.IsMating,
 | 
	
		
			
				|  |  | +			UnMatingReasons: v.UnMatingReasonsName,
 | 
	
		
			
				|  |  | +			OperationName:   v.OperationName,
 | 
	
		
			
				|  |  | +			Remarks:         v.Remarks,
 | 
	
		
			
				|  |  | +			CreatedAt:       int32(v.CreatedAt),
 | 
	
		
			
				|  |  | +			UpdatedAt:       int32(v.UpdatedAt),
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	return res
 |