|
@@ -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...)
|
|
|
}
|
|
|
|