Selaa lähdekoodia

Merge branch 'feature/event' of http://192.168.1.8:3000/xuyiping/kpt-pasture into feature/event

Yi 2 kuukautta sitten
vanhempi
commit
bb15c0e512

+ 2 - 2
module/backend/config_data.go

@@ -193,7 +193,7 @@ func (s *StoreEntry) SameTimeCowTypeEnumList(isAll string) []*pasturePb.ConfigOp
 	cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.SameTimeStatus_Invalid),
+			Value:    int32(pasturePb.SameTimeCowType_Invalid),
 			Label:    "全部",
 			Disabled: true,
 		})
@@ -214,7 +214,7 @@ func (s *StoreEntry) SameTimeTypeEnumList(isAll string) []*pasturePb.ConfigOptio
 	cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.SameTimeStatus_Invalid),
+			Value:    int32(pasturePb.SameTimeType_Invalid),
 			Label:    "全部",
 			Disabled: true,
 		})

+ 1 - 1
module/backend/config_data_breed.go

@@ -323,7 +323,7 @@ func CalendarTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
 	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
 	if isAll == model.IsAllYes {
 		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.SameTimeStatus_Invalid),
+			Value:    int32(pasturePb.CalendarType_Invalid),
 			Label:    "全部",
 			Disabled: true,
 		})

+ 2 - 4
module/crontab/other.go

@@ -73,9 +73,7 @@ func (e *Entry) CreatedCalendar(pastureId int64, calendarType pasturePb.Calendar
 			zaplog.Error("CreatedCalendar", zap.Any("err", err), zap.Any("workOrderCalendar", newCalendar))
 		}
 		return
-	}
-
-	if historyCount > 0 {
+	} else {
 		if err := e.DB.Model(&model.Calendar{}).
 			Where("id = ?", historyCalendar.Id).
 			Update("count", count+int32(historyCount)).Error; err != nil {
@@ -91,7 +89,7 @@ func (e *Entry) IsExistSameTimeCow(cow *model.Cow, sameTime *model.SameTime) boo
 		Where("cow_id = ?", cow.Id).
 		Where("lact = ?", cow.Lact).
 		Where("same_time_id = ?", sameTime.Id).
-		Where("same_time_status != ?", pasturePb.SameTimeStatus_End).
+		Where("status = ?", pasturePb.IsShow_Ok).
 		Count(&count).Error; err != nil {
 		zaplog.Error("IsExistSameTimeCow", zap.Any("err", err), zap.Any("cow", cow), zap.Any("sameTime", sameTime))
 		return false

+ 9 - 4
module/mqtt/merge_handle.go

@@ -27,7 +27,7 @@ type DataInsertNeckRingLog struct {
 var (
 	batchSize    = 10
 	batchList    = make([]*model.NeckRingOriginal, 0, batchSize)
-	defaultLimit = int32(100)
+	defaultLimit = int32(1000)
 	DSMLog       = &DataInsertNeckRingLog{
 		NeckRingOriginalData: make([]*model.NeckRingOriginal, 0),
 		NeckRingErrorData:    make([]*model.NeckRingError, 0),
@@ -74,6 +74,10 @@ func (e *Entry) NeckRingOriginalMergeData() {
 		return
 	}
 
+	if neckRingList[len(neckRingList)-1].Id <= mergeDataMaxId {
+		return
+	}
+
 	defer func() {
 		newMergeDataMaxId := neckRingList[len(neckRingList)-1].Id
 		if newMergeDataMaxId > 0 && newMergeDataMaxId > mergeDataMaxId {
@@ -95,13 +99,13 @@ func (e *Entry) NeckRingOriginalMergeData() {
 		}
 	}()
 	// 计算合并
-	newNeckActiveHabitList := e.recalculate(neckRingList)
-	if len(newNeckActiveHabitList) <= 0 {
+	neckActiveHabitList := e.recalculate(neckRingList)
+	if len(neckActiveHabitList) <= 0 {
 		return
 	}
 
 	if err = e.DB.Transaction(func(tx *gorm.DB) error {
-		for _, neckActiveHabit := range newNeckActiveHabitList {
+		for _, neckActiveHabit := range neckActiveHabitList {
 			//更新脖环牛只相关信息 新数据直接插入
 			historyNeckActiveHabit, ct := e.IsExistNeckActiveHabit(neckActiveHabit.NeckRingNumber, neckActiveHabit.HeatDate, neckActiveHabit.Frameid)
 			if ct <= 0 {
@@ -118,6 +122,7 @@ func (e *Entry) NeckRingOriginalMergeData() {
 				zaplog.Error("NeckRingOriginalMergeData", zap.Any("historyNeckActiveHabit", historyNeckActiveHabit), zap.Any("ct", ct), zap.Any("neckActiveHabit", neckActiveHabit))
 				continue
 			}
+
 			// 重新计算
 			newNeckActiveHabit := e.againRecalculate(historyNeckActiveHabit)
 			if newNeckActiveHabit != nil {

+ 4 - 4
module/crontab/work_cron_test.go → module/mqtt/work_cron_test.go

@@ -1,4 +1,4 @@
-package crontab
+package mqtt
 
 import (
 	"encoding/json"
@@ -49,13 +49,13 @@ func TestEntry_SameTimePlan(t *testing.T) {
 			continue
 		}
 		if v.FilterHigh <= 0 {
-			v.FilterHigh = int32(mqtt.computeIfPositiveElse(float64(v.High), float64(prev.FilterHigh), 0.23, 0.77))
+			v.FilterHigh = int32(computeIfPositiveElse(float64(v.High), float64(prev.FilterHigh), 0.23, 0.77))
 		}
 		if v.FilterRumina <= 0 {
-			v.FilterRumina = int32(mqtt.computeIfPositiveElse(float64(v.Rumina), float64(prev.FilterRumina), 0.33, 0.67))
+			v.FilterRumina = int32(computeIfPositiveElse(float64(v.Rumina), float64(prev.FilterRumina), 0.33, 0.67))
 		}
 		if v.FilterChew <= 0 {
-			v.FilterChew = int32(mqtt.computeIfPositiveElse(float64(v.Rumina+v.Intake), float64(prev.FilterChew), 0.33, 0.67))
+			v.FilterChew = int32(computeIfPositiveElse(float64(v.Rumina+v.Intake), float64(prev.FilterChew), 0.33, 0.67))
 		}
 		// 更新过滤值
 		filterValues[v.CowId] = v