|  | @@ -26,39 +26,23 @@ func (e *Entry) UpdatePenBehavior() error {
 | 
	
		
			
				|  |  |  			zaplog.Error("UpdatePenBehavior", zap.Any("pasture", pasture), zap.Any("err", err))
 | 
	
		
			
				|  |  |  			continue
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		e.PenBehaviorEnter(pasture.Id, conf.Value)
 | 
	
		
			
				|  |  | +		e.PenBehaviorEnter(pasture.Id, int(conf.Value))
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	return nil
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // PenBehaviorEnter 栏舍行为曲线 对数据进行查缺补漏
 | 
	
		
			
				|  |  | -func (e *Entry) PenBehaviorEnter(pastureId int64, maxValue int64) {
 | 
	
		
			
				|  |  | -	var minHeatDate string
 | 
	
		
			
				|  |  | -	if err := e.DB.Model(new(model.NeckRingOriginal)).
 | 
	
		
			
				|  |  | -		Select("min(active_date) as min_heat_date").
 | 
	
		
			
				|  |  | -		Where("pasture_id = ?", pastureId).
 | 
	
		
			
				|  |  | -		Where("id >= ?", maxValue).
 | 
	
		
			
				|  |  | -		Scan(&minHeatDate).Error; err != nil {
 | 
	
		
			
				|  |  | -		zaplog.Error("PenBehaviorEnter", zap.Any("pastureId", pastureId), zap.Any("err", err))
 | 
	
		
			
				|  |  | -		return
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +func (e *Entry) PenBehaviorEnter(pastureId int64, days int) {
 | 
	
		
			
				|  |  | +	minHeatDate := time.Now().Local().AddDate(0, 0, -days).Format(model.LayoutDate2)
 | 
	
		
			
				|  |  |  	e.PenBehavior(pastureId, minHeatDate)
 | 
	
		
			
				|  |  | -	var maxId int64
 | 
	
		
			
				|  |  | -	if err := e.DB.Model(new(model.NeckRingOriginal)).
 | 
	
		
			
				|  |  | -		Select("MAX(id) as id").
 | 
	
		
			
				|  |  | -		Where("pasture_id = ?", pastureId).
 | 
	
		
			
				|  |  | -		Where("id >= ?", maxValue).
 | 
	
		
			
				|  |  | -		Where("active_date = ?", minHeatDate).
 | 
	
		
			
				|  |  | -		Scan(&maxId).Error; err != nil {
 | 
	
		
			
				|  |  | -		zaplog.Error("PenBehaviorEnter", zap.Any("pastureId", pastureId), zap.Any("err", err))
 | 
	
		
			
				|  |  | +	e.UpdatePenBehaviorWeekData(pastureId, minHeatDate)
 | 
	
		
			
				|  |  | +	newDays := days - 1
 | 
	
		
			
				|  |  | +	if newDays < 0 {
 | 
	
		
			
				|  |  | +		return
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	if maxId > maxValue {
 | 
	
		
			
				|  |  | -		if err := e.UpdateSystemNeckRingConfigure(pastureId, model.MaxPenBehavior, maxId); err != nil {
 | 
	
		
			
				|  |  | -			zaplog.Error("UpdateSystemNeckRingConfigure", zap.Any("err", err))
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +	if err := e.UpdateSystemNeckRingConfigure(pastureId, model.MaxPenBehavior, int64(newDays)); err != nil {
 | 
	
		
			
				|  |  | +		zaplog.Error("PenBehaviorEnter", zap.Any("pastureId", pastureId), zap.Any("days", days))
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	e.UpdatePenBehaviorWeekData(pastureId, minHeatDate)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // PenBehavior 栏舍行为曲线
 | 
	
	
		
			
				|  | @@ -66,6 +50,9 @@ func (e *Entry) PenBehavior(pastureId int64, heatDate string) {
 | 
	
		
			
				|  |  |  	frameIds := util.FrameIdSlice
 | 
	
		
			
				|  |  |  	penBehaviorList := make([]*model.PenBehaviorData, 0)
 | 
	
		
			
				|  |  |  	for _, frameId := range frameIds {
 | 
	
		
			
				|  |  | +		if frameId%10 == 8 {
 | 
	
		
			
				|  |  | +			continue
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  		penBehaviorModel, err := e.getNeckRingOriginalList(pastureId, heatDate, frameId)
 | 
	
		
			
				|  |  |  		if err != nil {
 | 
	
		
			
				|  |  |  			zaplog.Error("PenBehavior",
 |