ping 2 долоо хоног өмнө
parent
commit
c0bfe96781

+ 1 - 1
model/event_cow_same_time.go

@@ -64,7 +64,7 @@ func NewEventCowSameTime(pastureId int64, cow *Cow, planTime int64, sameTime *Sa
 		SameTimeType: sameTimeType,
 		Status:       pasturePb.IsShow_No,
 		PlanDay:      planTime,
-		EndDay:       planTime,
+		EndDay:       planTime + 86399,
 	}
 }
 

+ 1 - 1
model/event_mating.go

@@ -113,7 +113,7 @@ func NewEventMating(pastureId int64, cow *Cow, planDay int64, exposeEstrusType p
 		DayAge:           cow.DayAge,
 		CalvingAt:        cow.LastMatingAt,
 		PlanDay:          planDay,
-		EndDay:           planDay,
+		EndDay:           planDay + 86399,
 		MatingResult:     pasturePb.MatingResult_Unknown,
 		ExposeEstrusType: exposeEstrusType,
 		Status:           pasturePb.IsShow_No,

+ 4 - 1
module/backend/prescription.go

@@ -56,7 +56,10 @@ func (s *StoreEntry) SearchSameTimeList(ctx context.Context, req *pasturePb.Sear
 		pref.Where("name like ?", fmt.Sprintf("%s%s%s", "%", req.Name, "%"))
 	}
 
-	if err = pref.Order("id desc").Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).
+	if err = pref.Order("is_show asc,id desc").
+		Count(&count).
+		Limit(int(pagination.PageSize)).
+		Offset(int(pagination.PageOffset)).
 		Find(&semeTimeList).Error; err != nil {
 		return nil, xerr.WithStack(err)
 	}

+ 9 - 3
module/crontab/work_cron.go

@@ -3,6 +3,7 @@ package crontab
 import (
 	"encoding/json"
 	"kpt-pasture/model"
+	"kpt-pasture/util"
 	"sort"
 	"time"
 
@@ -46,25 +47,30 @@ func (e *Entry) GenerateCalendarBySameTimePlan(cowList []*model.Cow, sameTime *m
 	})
 
 	showDay := time.Now().Local()
+	nextDays := int32(0)
 	newSameTimeCowDetailList := make([]*model.EventCowSameTime, 0)
 	newEventMatingList := make([]*model.EventMating, 0)
 	for i, collateNode := range collateNodes {
+		nextDays = collateNode.NextNodeDay
 		if i > 0 {
-			showDay = showDay.AddDate(0, 0, int(collateNode.NextNodeDay))
+			showDay = showDay.AddDate(0, 0, int(nextDays))
 		}
 		calendarType := pasturePb.CalendarType_PG
 		histCount := int64(0)
+		// 获取当天的零点时间戳
+		planTimeFormat := showDay.Format(model.LayoutDate2)
+		planTimeZeroTime := util.TimeParseLocalUnix(planTimeFormat)
 		if collateNode.SameTimeType == pasturePb.SameTimeType_TAI {
 			calendarType = pasturePb.CalendarType_Mating
 			histCount = e.GetTowardTaiCowSum(sameTime.PastureId)
-			newEventMatingItems := model.NewEventMatingList(sameTime.PastureId, newCowList, showDay.Unix(), pasturePb.ExposeEstrusType_Same_Time)
+			newEventMatingItems := model.NewEventMatingList(sameTime.PastureId, newCowList, planTimeZeroTime, pasturePb.ExposeEstrusType_Same_Time)
 			newEventMatingList = append(newEventMatingList, newEventMatingItems...)
 		} else {
 			if collateNode.SameTimeType == pasturePb.SameTimeType_RnGH {
 				calendarType = pasturePb.CalendarType_RnGH
 			}
 			histCount = e.GetTowardSameTimeCowSum(sameTime, collateNode.SameTimeType)
-			newEventCowSameTimeList := model.NewEventCowSameTimeList(sameTime.PastureId, newCowList, sameTime, showDay.Unix(), collateNode.SameTimeType)
+			newEventCowSameTimeList := model.NewEventCowSameTimeList(sameTime.PastureId, newCowList, sameTime, planTimeZeroTime, collateNode.SameTimeType)
 			newSameTimeCowDetailList = append(newSameTimeCowDetailList, newEventCowSameTimeList...)
 		}