123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- package model
- import (
- "time"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- type EventMating struct {
- Id int64 `json:"id"`
- CowId int64 `json:"cowId"`
- DayAge int32 `json:"dayAge"`
- Lact int32 `json:"lact"`
- PenId int32 `json:"penId"`
- CowType pasturePb.CowType_Kind `json:"cowType"`
- CowKind pasturePb.CowKind_Kind `json:"cowKind"`
- CalvingAge int32 `json:"calvingAge"`
- PlanDay int64 `json:"planDay"`
- EndDay int64 `json:"endDay"`
- CalvingAt int64 `json:"calvingAt"`
- RealityDay int64 `json:"realityDay"`
- Status pasturePb.IsShow_Kind `json:"status"`
- MatingTimes int32 `json:"matingTimes"`
- MatingResult pasturePb.MatingResult_Kind `json:"matingResult"`
- MatingResultAt int64 `json:"matingResultAt"`
- ExposeEstrusType pasturePb.ExposeEstrusType_Kind `json:"exposeEstrusType"`
- FrozenSemenNumber string `json:"frozenSemenNumber"`
- OperationId int64 `json:"operationId"`
- OperationName string `json:"operationName"`
- MessageId int64 `json:"messageId"`
- MessageName string `json:"messageName"`
- Remarks string `json:"remarks"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (e *EventMating) TableName() string {
- return "event_mating"
- }
- func NewEventMating(cow *Cow, planDay int64) *EventMating {
- return &EventMating{
- CowId: cow.Id,
- Lact: cow.Lact,
- PenId: cow.PenId,
- CowType: cow.CowType,
- CowKind: cow.CowKind,
- CalvingAt: cow.LastMatingAt,
- PlanDay: planDay,
- EndDay: planDay,
- MatingResult: pasturePb.MatingResult_Unknown,
- ExposeEstrusType: pasturePb.ExposeEstrusType_Same_Time,
- Status: pasturePb.IsShow_No,
- }
- }
- // NewEventMating2 自然发情的牛只
- func NewEventMating2(cow *Cow, req *pasturePb.EventMating, currentUser *SystemUser) *EventMating {
- return &EventMating{
- CowId: cow.Id,
- Lact: cow.Lact,
- DayAge: cow.GetDayAge(),
- CowType: cow.CowType,
- CowKind: cow.CowKind,
- CalvingAt: cow.LastMatingAt,
- PlanDay: int64(req.MatingAt),
- RealityDay: int64(req.MatingAt),
- EndDay: int64(req.MatingAt),
- MatingResult: pasturePb.MatingResult_Unknown,
- ExposeEstrusType: pasturePb.ExposeEstrusType_Natural_Estrus,
- Status: pasturePb.IsShow_Ok,
- OperationId: int64(req.OperationId),
- OperationName: req.OperationName,
- MessageId: currentUser.Id,
- MessageName: currentUser.Name,
- FrozenSemenNumber: req.FrozenSemenNumber,
- Remarks: req.Remarks,
- }
- }
- func NewEventMatingList(cowList []*Cow, planDay int64) []*EventMating {
- var matingList []*EventMating
- for _, cow := range cowList {
- matingList = append(matingList, NewEventMating(cow, planDay))
- }
- return matingList
- }
- type EventMatingSlice []*EventMating
- func (e EventMatingSlice) ToPB(exposeEstrusTypeMap map[pasturePb.ExposeEstrusType_Kind]string) []*pasturePb.SearchMatingList {
- res := make([]*pasturePb.SearchMatingList, len(e))
- for i, v := range e {
- res[i] = &pasturePb.SearchMatingList{
- Id: int32(v.Id),
- CowId: int32(v.CowId),
- DayAge: int32(v.DayAge),
- Lact: int32(v.Lact),
- CalvingAge: v.CalvingAge,
- PlanDay: time.Unix(v.PlanDay, 0).Format(LayoutDate2),
- RealityDay: time.Unix(v.RealityDay, 0).Format(LayoutDate2),
- ExposeEstrusType: v.ExposeEstrusType,
- ExposeEstrusTypeName: exposeEstrusTypeMap[v.ExposeEstrusType],
- FrozenSemenNumber: v.FrozenSemenNumber,
- Remarks: v.Remarks,
- OperationId: int32(v.OperationId),
- OperationName: v.OperationName,
- CreatedAt: int32(v.CreatedAt),
- UpdatedAt: int32(v.UpdatedAt),
- }
- }
- return res
- }
- type CowMatingBody struct {
- Id int64 `json:"id"`
- CowId int64 `json:"cowId"`
- BreedStatus pasturePb.BreedStatus_Kind `json:"breedStatus"`
- BreedStatusName string `json:"breedStatusName"`
- CowType pasturePb.CowType_Kind `json:"cowType"`
- CowTypeName string `json:"cowTypeName"`
- PenId int32 `json:"penId"`
- PenName string `json:"penName"`
- Lact int32 `json:"lact"`
- CalvingAge int32 `json:"calvingAge"`
- AbortionAge int32 `json:"abortionAge"`
- DayAge int32 `json:"dayAge"`
- Status pasturePb.IsShow_Kind `json:"status"`
- }
- type CowMatingBodySlice []*CowMatingBody
- func (s CowMatingBodySlice) ToPB(
- cowTypeMap map[pasturePb.CowType_Kind]string,
- breedStatusMap map[pasturePb.BreedStatus_Kind]string,
- penMap map[int32]*Pen,
- ) []*CowMatingBody {
- res := make([]*CowMatingBody, len(s))
- for i, v := range s {
- res[i] = &CowMatingBody{
- Id: v.Id,
- CowId: v.CowId,
- CowType: v.CowType,
- CowTypeName: cowTypeMap[v.CowType],
- BreedStatus: v.BreedStatus,
- BreedStatusName: breedStatusMap[v.BreedStatus],
- PenName: penMap[v.PenId].Name,
- PenId: v.PenId,
- Lact: v.Lact,
- CalvingAge: v.CalvingAge,
- AbortionAge: v.AbortionAge,
- DayAge: v.DayAge,
- Status: v.Status,
- }
- }
- return res
- }
- type MatingTimelyChart struct {
- CalvingAge int32 `json:"calvingAge"`
- RealityDay string `json:"realityDay"`
- LactGroup string `json:"lactGroup"`
- }
- func (e EventMatingSlice) ToPB2() []*pasturePb.CowList {
- res := make([]*pasturePb.CowList, len(e))
- for i, v := range e {
- calvingAt, matingAtFormat := "", ""
- if v.CalvingAt > 0 {
- calvingAt = time.Unix(v.CalvingAt, 0).Format(LayoutDate2)
- }
- if v.RealityDay > 0 {
- matingAtFormat = time.Unix(v.RealityDay, 0).Format(LayoutDate2)
- }
- res[i] = &pasturePb.CowList{
- CowId: int32(v.CowId),
- DayAge: int32(v.DayAge),
- CalvingAge: v.CalvingAge,
- MatingAtFormat: matingAtFormat,
- CalvingAtFormat: calvingAt,
- Lact: int32(v.Lact),
- }
- }
- return res
- }
- type MatingTimelyResponse struct {
- Code int32 `json:"code"`
- Message string `json:"message"`
- Data *MatingTimelyData `json:"data"`
- }
- type MatingTimelyData struct {
- CowList []*pasturePb.CowList `json:"cowList"`
- Chart *CowMatingChart `json:"chart"`
- }
- type CowMatingChart struct {
- Lact0 [][]string `json:"lact0"`
- Lact1 [][]string `json:"lact1"`
- Lact2 [][]string `json:"lact2"`
- Lact3 [][]string `json:"lact3"`
- }
- // MultiFactorPregnancyRateResponse 多维度受胎率
- type MultiFactorPregnancyRateResponse struct {
- Code int32 `json:"code"`
- Message string `json:"message"`
- Data *MultiFactorPregnancyRateData `json:"data"`
- }
- // MultiFactorPregnancyRateList 多维度受胎率分析
- type MultiFactorPregnancyRateList struct {
- StatisticMethod1 string `json:"statisticMethod1"` // 统计方式名称1 (月度、品种)
- StatisticMethod2 string `json:"statisticMethod2"` // 统计方式名称2 (月度、品种)
- PregnantRate float32 `json:"pregnantRate"` // 受胎率%(怀孕数 / 怀孕数 + 空怀数)
- PregnantCount int32 `json:"pregnantCount"` // 怀孕总数
- EmptyPregnantCount int32 `json:"emptyPregnantCount"` // 空怀数
- OtherCount int32 `json:"otherCount"` // 其他数 (配种后结果未知的个数,小于等于三次配种后,尚未孕检已经淘汰的个数)
- AbortionCount int32 `json:"abortionCount"` // 流产数 (已经怀孕后流产的个数)
- TotalCount int32 `json:"totalCount"` // 合计( 怀孕总数+空怀数+其他数)
- SpcRate float32 `json:"spcRate"` // spc(1 / 受胎率)
- Months string `json:"months"` // 月份
- OperationName string `json:"operationName"` // 配种员名称
- Bull string `json:"bull"` // 公牛
- Lact string `json:"lact"` // 胎次
- MatingTimes string `json:"matingTimes"` // 配次
- ExposeEstrusType string `json:"exposeEstrusType"` // 发情揭发方式
- Week string `json:"week"` // 周
- }
- type MultiFactorPregnancyRateData struct {
- Total int32 `json:"total"`
- PageSize int32 `json:"pageSize"`
- Page int32 `json:"page"`
- List []*MultiFactorPregnancyRateList `json:"list"`
- Chart *MultiFactorPregnancyRateChart `json:"chart"`
- }
- type MultiFactorPregnancyRateChart struct {
- Header []string `json:"header"` // 标题头
- PregnantRateMap map[string]map[string]string `json:"pregnantRateMap"`
- KepMap []string `json:"kepMap"`
- }
|