123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package model
- import (
- "fmt"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- type Calendar struct {
- Id int64 `json:"id"`
- PastureId int64 `json:"pastureId"`
- Name string `json:"name"`
- CalendarType pasturePb.CalendarType_Kind `json:"calendarType"`
- Count int32 `json:"count"`
- StartDay string `json:"startDay"`
- EndDay string `json:"endDay"`
- IsShow pasturePb.IsShow_Kind `json:"isShow"`
- Backup string `json:"backup"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (w *Calendar) TableName() string {
- return "calendar"
- }
- func NewCalendar(pastureId int64, name string, calendarType pasturePb.CalendarType_Kind, startDay, endDay string, count int32) *Calendar {
- return &Calendar{
- PastureId: pastureId,
- Name: name,
- Count: count,
- CalendarType: calendarType,
- StartDay: startDay,
- EndDay: endDay,
- IsShow: pasturePb.IsShow_Ok,
- }
- }
- var CalendarTypeColorMap = map[pasturePb.CalendarType_Kind]string{
- pasturePb.CalendarType_Immunisation: "#00B42A",
- pasturePb.CalendarType_PG: "#722ED1",
- pasturePb.CalendarType_RnGH: "#722ED1",
- pasturePb.CalendarType_Pregnancy_Check: "#F5319D",
- pasturePb.CalendarType_WorkOrder: "#5d6d7e",
- pasturePb.CalendarType_Disease: "#00B42A",
- pasturePb.CalendarType_Calving: "#F5319D",
- pasturePb.CalendarType_Weaning: "#F5319D",
- pasturePb.CalendarType_Mating: "#F5319D",
- pasturePb.CalendarType_DryMilk: "#165DFF",
- }
- var CalendarTypeEndDaysMap = map[pasturePb.CalendarType_Kind]int{
- pasturePb.CalendarType_Immunisation: 6,
- pasturePb.CalendarType_PG: 0,
- pasturePb.CalendarType_RnGH: 0,
- pasturePb.CalendarType_Pregnancy_Check: 6,
- pasturePb.CalendarType_WorkOrder: -1,
- pasturePb.CalendarType_Disease: -1,
- pasturePb.CalendarType_Calving: 14,
- pasturePb.CalendarType_Weaning: 6,
- pasturePb.CalendarType_Mating: 0,
- pasturePb.CalendarType_DryMilk: 14,
- }
- type CalendarSlice []*Calendar
- func (c CalendarSlice) ToPB() []*pasturePb.Calendar {
- res := make([]*pasturePb.Calendar, len(c))
- for i, v := range c {
- res[i] = &pasturePb.Calendar{
- Id: int32(v.Id),
- Title: fmt.Sprintf("%s - %d", v.Name, v.Count),
- GroupId: v.CalendarType,
- Count: v.Count,
- Start: v.StartDay,
- End: v.EndDay,
- Color: CalendarTypeColorMap[v.CalendarType],
- ExtendedProps: &pasturePb.ExtendedProps{
- StartDay: v.StartDay,
- Backup: v.Backup,
- },
- }
- }
- return res
- }
- type TodayCompletedData struct {
- Count int32
- CalendarTypeName string
- }
|