123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- 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"`
- CowId int64 `json:"cowId"`
- 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"`
- CreateAt int64 `json:"createAt"`
- UpdateAt int64 `json:"updateAt"`
- }
- func (c *EventImmunizationPlan) TableName() string {
- return "event_immunization_plan"
- }
- func NewCowImmunizationPlan(cow *Cow, pen *Pen, immunizationPlan *ImmunizationPlan) *EventImmunizationPlan {
- todayTime := time.Now().Format(LayoutDate2)
- todayStartTime := util.TimeParseLocalUnix(todayTime)
- todayEndTime := util.TimeParseLocalEndUnix(todayTime)
- return &EventImmunizationPlan{
- CowId: cow.Id,
- Lact: cow.Lact,
- DayAge: cow.DayAge,
- CowKind: cow.CowKind,
- CowType: cow.CowType,
- PenId: cow.PenId,
- PenName: pen.Name,
- PlanId: immunizationPlan.Id,
- PlanName: immunizationPlan.Name,
- PlanDay: todayStartTime,
- EndDay: todayEndTime,
- Status: pasturePb.IsShow_No,
- }
- }
- func NewCowImmunizationPlanList(cowList []*Cow, penMap map[int32]*Pen, immunizationPlan *ImmunizationPlan) []*EventImmunizationPlan {
- cowImmunizationPlanList := make([]*EventImmunizationPlan, len(cowList))
- for i, cow := range cowList {
- pen := penMap[cow.PenId]
- cowImmunizationPlanList[i] = NewCowImmunizationPlan(cow, pen, immunizationPlan)
- }
- return cowImmunizationPlanList
- }
- type EventImmunizationPlanSlice []*EventImmunizationPlan
- func (I EventImmunizationPlanSlice) ToPB() []*pasturePb.ImmunizationItems {
- res := make([]*pasturePb.ImmunizationItems, len(I))
- for i, v := range I {
- res[i] = &pasturePb.ImmunizationItems{
- Id: int32(v.Id),
- CowId: int32(v.CowId),
- PenId: v.PenId,
- Lact: v.Lact,
- PenName: v.PenName,
- DayAge: v.DayAge,
- PlanDay: time.Unix(v.PlanDay, 0).Format(LayoutDate2),
- Status: v.Status,
- ImmunizationName: v.PlanName,
- ImmunizationId: int32(v.PlanId),
- Remarks: v.Remarks,
- OperatorId: int32(v.OperationId),
- OperatorName: v.OperationName,
- DrugId: int32(v.DrugsId),
- DrugName: v.DrugsName,
- Unit: v.Unit,
- UnitName: v.UnitName,
- Usage: v.Usage,
- CreatedAt: int32(v.CreateAt),
- UpdatedAt: int32(v.UpdateAt),
- }
- }
- return res
- }
|