123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package model
- import (
- "kpt-pasture/util"
- "time"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- type EventImmunizationPlan struct {
- Id int64 `json:"id"`
- PastureId int64 `json:"pastureId"`
- CowId int64 `json:"cowId"`
- EarNumber string `json:"earNumber"`
- Lact int32 `json:"lact"`
- DayAge int32 `json:"dayAge"`
- CowType pasturePb.CowType_Kind `json:"cowType"`
- CowKind pasturePb.CowKind_Kind `json:"cowKind"`
- PenId int32 `json:"penId"`
- PenName string `json:"penName"`
- PlanId int64 `json:"planId"`
- PlanName string `json:"planName"`
- PlanDay int64 `json:"planDay"`
- RealityDay int64 `json:"realityDay"`
- EndDay int64 `json:"endDay"`
- Status pasturePb.IsShow_Kind `json:"status"`
- OperationId int64 `json:"operationId"`
- OperationName string `json:"operationName"`
- DrugsId int64 `json:"drugsId"`
- DrugsName string `json:"drugsName"`
- Unit pasturePb.Unit_Kind `json:"unit"`
- UnitName string `json:"unitName"`
- Usage int32 `json:"usage"`
- Remarks string `json:"remarks"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (c *EventImmunizationPlan) TableName() string {
- return "event_immunization_plan"
- }
- func NewEventImmunizationPlan(cow *Cow, immunizationPlan *ImmunizationPlan) *EventImmunizationPlan {
- todayTime := time.Now().Format(LayoutDate2)
- todayStartTime := util.TimeParseLocalUnix(todayTime)
- todayEndTime := util.TimeParseLocalEndUnix(todayTime)
- return &EventImmunizationPlan{
- PastureId: immunizationPlan.PastureId,
- CowId: cow.Id,
- EarNumber: cow.EarNumber,
- Lact: cow.Lact,
- DayAge: cow.DayAge,
- CowKind: cow.CowKind,
- CowType: cow.CowType,
- PenId: cow.PenId,
- PenName: cow.PenName,
- PlanId: immunizationPlan.Id,
- PlanName: immunizationPlan.Name,
- PlanDay: todayStartTime,
- EndDay: todayEndTime,
- Status: pasturePb.IsShow_No,
- }
- }
- func NewCowImmunizationPlanList(cowList []*Cow, immunizationPlan *ImmunizationPlan) []*EventImmunizationPlan {
- eventImmunizationPlanList := make([]*EventImmunizationPlan, len(cowList))
- for i, cow := range cowList {
- eventImmunizationPlanList[i] = NewEventImmunizationPlan(cow, immunizationPlan)
- }
- return eventImmunizationPlanList
- }
- type EventImmunizationPlanSlice []*EventImmunizationPlan
- func (I EventImmunizationPlanSlice) ToPB() []*pasturePb.ImmunizationItems {
- res := make([]*pasturePb.ImmunizationItems, len(I))
- for i, v := range I {
- planDay := ""
- if v.PlanDay > 0 {
- planDay = time.Unix(v.PlanDay, 0).Format(LayoutDate2)
- }
- res[i] = &pasturePb.ImmunizationItems{
- Id: int32(v.Id),
- CowId: int32(v.CowId),
- EarNumber: v.EarNumber,
- Lact: v.Lact,
- PenName: v.PenName,
- DayAge: v.DayAge,
- PlanDay: planDay,
- Status: v.Status,
- ImmunizationName: v.PlanName,
- ImmunizationId: int32(v.PlanId),
- }
- }
- return res
- }
|