Przeglądaj źródła

analysis:产犊报告

Yi 5 miesięcy temu
rodzic
commit
e835fe932e

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20241025100516-892af77790ab
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20241028071126-73c3c42b5159
 	gitee.com/xuyiping_admin/pkg v0.0.0-20241010101255-0c6bd229b939
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eko/gocache v1.1.0

+ 8 - 0
go.sum

@@ -122,6 +122,14 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20241025081249-c24e81100ed5 h1:FIMbHC1W
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241025081249-c24e81100ed5/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241025100516-892af77790ab h1:0k7CeNzABQf8kDylWaPgyZuzH0VgjNxZiACHAeD/spk=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20241025100516-892af77790ab/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028022226-4604cfcfddc1 h1:CHliD3igZp53pUQoSumrWBjV7NekEBDs8dnVrM/IYFM=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028022226-4604cfcfddc1/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028034651-d5e33b3f62fa h1:eEhuwsyIltNGtMngKsfp+rdKu5cpNw5Ywo9GpzcJsa4=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028034651-d5e33b3f62fa/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028064149-11634d513a92 h1:6pyhATMlI7iQKrYyQHrw5RQA0drZe6JVzYM2NHYcgIY=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028064149-11634d513a92/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028071126-73c3c42b5159 h1:xcAqrT40ukQeDmRvmaY33iEkfg5zSYEB0cBsxJ6v1KU=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20241028071126-73c3c42b5159/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015 h1:dfb5dRd57L2HKjdwLT93UFmPYFPOmEl56gtZmqcNnaE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20231218082641-aac597b8a015/go.mod h1:Fk4GYI/v0IK3XFrm1Gn+VkgCz5Y7mfswD5hsTJYOG6A=
 gitee.com/xuyiping_admin/pkg v0.0.0-20241008063555-121a776fd331 h1:qJcpJ3o+O7uxDqR0I9LijQmi607IKvhf4mGum/ZUPT0=

+ 32 - 0
http/handler/analysis/analysis.go

@@ -174,3 +174,35 @@ func PregnancyReport(c *gin.Context) {
 	}
 	ginutil.JSONResp(c, res)
 }
+
+func CalvingReport(c *gin.Context) {
+	var req pasturePb.CalvingReportRequest
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.StartDayTime, valid.Required),
+		valid.Field(&req.EndDayTime, valid.Required),
+		valid.Field(&req.LateLabor, valid.Required),
+		valid.Field(&req.PrematureLabor, valid.Required),
+		valid.Field(&req.AnalysisMethod, valid.Required),
+	); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	pagination := &pasturePb.PaginationModel{
+		Page:       int32(c.GetInt(middleware.Page)),
+		PageSize:   int32(c.GetInt(middleware.PageSize)),
+		PageOffset: int32(c.GetInt(middleware.PageOffset)),
+	}
+
+	res, err := middleware.Dependency(c).StoreEventHub.OpsService.CalvingReport(c, &req, pagination)
+	if err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+	ginutil.JSONResp(c, res)
+}

+ 1 - 0
http/route/analysis_api.go

@@ -21,5 +21,6 @@ func AnalysisAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		pastureRoute.POST("/twentyone/pregnant/rate", analysis.TwentyonePregnantRate)
 
 		pastureRoute.POST("/pregnancy/report", analysis.PregnancyReport)
+		pastureRoute.POST("/calving/report", analysis.CalvingReport)
 	}
 }

+ 38 - 0
model/event_calving.go

@@ -10,6 +10,8 @@ import (
 type EventCalving struct {
 	Id             int64                         `json:"id"`
 	CowId          int64                         `json:"cowId"`
+	CowType        pasturePb.CowType_Kind        `json:"cowType"`
+	CowKind        pasturePb.CowKind_Kind        `json:"cowKind"`
 	EarNumber      string                        `json:"earNumber"`
 	Lact           int32                         `json:"lact"`
 	DayAge         int32                         `json:"dayAge"`
@@ -36,6 +38,8 @@ func (e *EventCalving) TableName() string {
 func NewEventCalving(cow *Cow) *EventCalving {
 	return &EventCalving{
 		CowId:      cow.Id,
+		CowKind:    cow.CowKind,
+		CowType:    cow.CowType,
 		EarNumber:  cow.EarNumber,
 		Lact:       cow.Lact,
 		PenId:      cow.PenId,
@@ -104,3 +108,37 @@ func (e EventCalvingListSlice) ToPB(req []*CalvingCalf) []*pasturePb.LavingList
 	}
 	return list
 }
+
+type EventCalvingSlice []*EventCalving
+
+func (e EventCalvingSlice) ToPB() []*pasturePb.CalvingReportTable {
+	res := make([]*pasturePb.CalvingReportTable, len(e))
+	for i, v := range e {
+		res[i] = &pasturePb.CalvingReportTable{
+			Id:                  int32(v.Id),
+			DataTimeFormat:      "",
+			Twins:               0,
+			TwinsRate:           0,
+			Bulls:               0,
+			BullsRate:           0,
+			Cows:                0,
+			CowsRate:            0,
+			SurviveCount:        0,
+			SurviveRate:         0,
+			DieCount:            0,
+			DieRate:             0,
+			BullsDieCount:       0,
+			BullsDieRate:        0,
+			CowsDieCount:        0,
+			CowsDieRate:         0,
+			AdoptCount:          0,
+			AdoptRate:           0,
+			PrematureLaborCount: 0,
+			PrematureLaborRate:  0,
+			LateLaborCount:      0,
+			LateLaborRate:       0,
+			NormalLaborCount:    0,
+		}
+	}
+	return res
+}

+ 43 - 0
model/event_cow_treatment.go

@@ -3,6 +3,9 @@ package model
 import (
 	"encoding/json"
 
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"go.uber.org/zap"
+
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 )
 
@@ -44,3 +47,43 @@ func NewEventCowTreatment(prescription *Prescription, req *pasturePb.CowTreatmen
 		Remarks:            req.Remarks,
 	}
 }
+
+type EventCowTreatmentSlice []*EventCowTreatment
+
+func (e EventCowTreatmentSlice) ToPB(eventCowDiseaseList []*EventCowDisease) []*pasturePb.EventCowTreatment {
+	res := make([]*pasturePb.EventCowTreatment, len(e))
+	for i, v := range e {
+		prescriptionDetail := make([]*pasturePb.TreatmentDrugs, 0)
+		if v.PrescriptionDetail == "" {
+			err := json.Unmarshal([]byte(v.PrescriptionDetail), &prescriptionDetail)
+			if err != nil {
+				zaplog.Error("EventCowTreatmentSlice", zap.Any("err", err))
+			}
+		}
+
+		eventCowTreatment := &pasturePb.EventCowTreatment{
+			CowId:              int32(v.CowId),
+			CowDiseaseId:       int32(v.CowDiseaseId),
+			PrescriptionId:     v.PrescriptionId,
+			PrescriptionName:   v.PrescriptionName,
+			PrescriptionDetail: prescriptionDetail,
+			TreatmentResult:    0,
+			OperationId:        int32(v.OperationId),
+			OperationName:      v.OperationName,
+			Remarks:            v.Remarks,
+			CreatedAt:          int32(v.CreatedAt),
+			UpdatedAt:          int32(v.UpdatedAt),
+			DiseaseId:          int32(v.DiseaseId),
+			Id:                 int32(v.Id),
+		}
+		for _, d := range eventCowDiseaseList {
+			if v.CowDiseaseId != d.Id {
+				continue
+			}
+			eventCowTreatment.DiseaseName = d.DiseaseName
+			eventCowTreatment.DiseaseAt = int32(d.DiseaseAt)
+		}
+		res[i] = eventCowTreatment
+	}
+	return res
+}

+ 3 - 1
module/backend/analysis.go

@@ -339,8 +339,10 @@ func (s *StoreEntry) AbortionRate(ctx context.Context, req *pasturePb.AbortionRa
 		).Where("cow_type = ?", req.CowType).
 		Where("DATE_FORMAT(FROM_UNIXTIME(`created_at`),'%Y-%m-%d') IN ?", lastDayForMonth)
 
-	if req.Lact >= 0 {
+	if req.Lact >= 0 && req.Lact <= 3 {
 		pref.Where("lact = ?", req.Lact)
+	} else {
+		pref.Where("lact > ?", req.Lact)
 	}
 	if err = pref.Group("month").
 		Find(&cowPregnantMonthList).Error; err != nil {

+ 34 - 1
module/backend/analysis_other.go

@@ -2,6 +2,7 @@ package backend
 
 import (
 	"context"
+	"fmt"
 	"kpt-pasture/model"
 	"kpt-pasture/util"
 	"net/http"
@@ -11,7 +12,7 @@ import (
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 )
 
-// PregnancyReport 孕检报告列表
+// PregnancyReport 孕检报告
 func (s *StoreEntry) PregnancyReport(ctx context.Context, req *pasturePb.PregnancyReportRequest, pagination *pasturePb.PaginationModel) (*pasturePb.PregnancyReportResponse, error) {
 	startDayUnix := util.TimeParseLocalUnix(req.StartDayTime)
 	endDayUnix := util.TimeParseLocalEndUnix(req.EndDayTime)
@@ -52,3 +53,35 @@ func (s *StoreEntry) PregnancyReport(ctx context.Context, req *pasturePb.Pregnan
 		},
 	}, nil
 }
+
+// CalvingReport 产犊报告
+func (s *StoreEntry) CalvingReport(ctx context.Context, req *pasturePb.CalvingReportRequest, pagination *pasturePb.PaginationModel) (*pasturePb.CalvingReportResponse, error) {
+	lastDayOfMonth, err := util.GetLastDayOfMonth(req.EndDayTime)
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+
+	endDayTimeUnix := util.TimeParseLocalEndUnix(lastDayOfMonth)
+	startDayTimeUnix := util.TimeParseLocalUnix(fmt.Sprintf("%s-01", req.StartDayTime))
+	if startDayTimeUnix == 0 || endDayTimeUnix == 0 || endDayTimeUnix <= startDayTimeUnix {
+		return nil, xerr.Custom("开始时间不能大于结束时间")
+	}
+
+	var count int64 = 0
+	eventCalvingList := make([]*model.EventCalving, 0)
+	pref := s.DB.Model(new(model.EventCalving)).
+		Where("reality_day BETWEEN  ? AND ? ", startDayTimeUnix, endDayTimeUnix)
+
+	fmt.Println(pref)
+
+	return &pasturePb.CalvingReportResponse{
+		Code:    http.StatusOK,
+		Message: "ok",
+		Data: &pasturePb.CalvingReportData{
+			List:     model.EventCalvingSlice(eventCalvingList).ToPB(),
+			Total:    int32(count),
+			PageSize: pagination.PageSize,
+			Page:     pagination.Page,
+		},
+	}, nil
+}

+ 0 - 511
module/backend/config_data.go

@@ -1,12 +1,8 @@
 package backend
 
 import (
-	"fmt"
 	"kpt-pasture/model"
 
-	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
-	"go.uber.org/zap"
-
 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 )
 
@@ -461,510 +457,3 @@ func (s *StoreEntry) PregnantCheckResultEnumList(isAll string) []*pasturePb.Conf
 	})
 	return configOptions
 }
-
-func (s *StoreEntry) PregnantCheckMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value: int32(pasturePb.PregnantCheckMethod_Invalid),
-			})
-	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
-		Label:    "B超",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.PregnantCheckMethod_Blood_Testing),
-		Label:    "血检",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
-		Label:    "人工检查",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func (s *StoreEntry) DrugCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.DrugCategory_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Antibiotics),
-		Label:    "抗生素类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Antivirals),
-		Label:    "抗病毒类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Antifungals),
-		Label:    "抗真菌类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Antiparasitics),
-		Label:    "驱虫类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Analgesics),
-		Label:    "镇痛类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Antipyretic),
-		Label:    "退烧类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Vitamin),
-		Label:    "维生素类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Brine),
-		Label:    "盐水",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Glucose),
-		Label:    "葡萄糖",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Hormone),
-		Label:    "激素类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Anti_Stress),
-		Label:    "抗应激类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Disinfect),
-		Label:    "消毒类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Chinese_Herbal),
-		Label:    "中药合剂",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Tocolytic),
-		Label:    "保胎类",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.DrugCategory_Immunity),
-		Label:    "疫苗类",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func (s *StoreEntry) DrugUsageEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.DrugUsage_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DrugUsage_Oral_Medications),
-			Label:    "口服",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DrugUsage_Injectable_Medications),
-			Label:    "肌注",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DrugUsage_Topical_Medications),
-			Label:    "外用",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DrugUsage_Inhalation_Medications),
-			Label:    "吸入",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.DrugUsage_Drink_Medications),
-			Label:    "饮水",
-			Disabled: true,
-		})
-	return configOptions
-}
-
-func (s *StoreEntry) UnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Pieces),
-			Label:    "个",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Package),
-			Label:    "包/袋",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Bottle),
-			Label:    "瓶",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Box),
-			Label:    "盒",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Boxful),
-			Label:    "箱",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Branch),
-			Label:    "支",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Barrel),
-			Label:    "桶",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_Pot),
-			Label:    "罐",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_ML),
-			Label:    "毫升",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Unit_L),
-			Label:    "升",
-			Disabled: true,
-		})
-	return configOptions
-}
-
-func (s *StoreEntry) ExposeEstrusTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.ExposeEstrusType_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ExposeEstrusType_Neck_Ring),
-			Label:    "脖环揭发",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ExposeEstrusType_Foot_Ring),
-			Label:    "脚环揭发",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.ExposeEstrusType_Natural_Estrus),
-			Label:    "自然发情",
-			Disabled: true,
-		})
-	return configOptions
-}
-
-func (s *StoreEntry) FrozenSemenTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions,
-			&pasturePb.ConfigOptionsList{
-				Value:    int32(pasturePb.FrozenSemenType_Invalid),
-				Label:    "全部",
-				Disabled: true,
-			})
-	}
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.FrozenSemenType_Ordinary),
-			Label:    "常规冻精",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.FrozenSemenType_Gender_Control),
-			Label:    "性控冻精",
-			Disabled: true,
-		})
-	return configOptions
-}
-
-func (s *StoreEntry) BullNumberEnumList(isAll string) []*pasturePb.BullOptionsList {
-	frozenSemenList := make([]*model.FrozenSemen, 0)
-	bullNumberList := make([]*pasturePb.BullOptionsList, 0)
-	if err := s.DB.Where("quantity > 0").Group("bull_id").Find(&frozenSemenList).Error; err != nil {
-		zaplog.Error("BullNumberEnumList", zap.Any("Find", err))
-	}
-
-	for _, v := range frozenSemenList {
-		bullNumberList = append(bullNumberList, &pasturePb.BullOptionsList{
-			Value:    v.BullId,
-			Label:    v.BullId,
-			Disabled: true,
-		})
-	}
-	return bullNumberList
-}
-
-func (s *StoreEntry) WeekEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	configOptions = append(configOptions,
-		&pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Week_Monday),
-			Label:    "周一",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Week_Tuesday),
-			Label:    "周二",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Week_Wednesday),
-			Label:    "周三",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Week_Thursday),
-			Label:    "周四",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Week_Friday),
-			Label:    "周五",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Week_Saturday),
-			Label:    "周六",
-			Disabled: true,
-		}, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.Week_Sunday),
-			Label:    "周日",
-			Disabled: true,
-		})
-	return configOptions
-}
-
-func (s *StoreEntry) MonthEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	for v := 1; v <= 31; v++ {
-		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-			Value:    int32(v),
-			Label:    fmt.Sprintf("%d号", v),
-			Disabled: true,
-		})
-	}
-	return configOptions
-}
-
-func (s *StoreEntry) WorkOrderFrequencyEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderFrequency_None),
-		Label:    "一次性",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderFrequency_Daily),
-		Label:    "每天",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderFrequency_Weekly),
-		Label:    "每周",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderFrequency_Monthly),
-		Label:    "每月",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func (s *StoreEntry) WorkOrderSubUnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderSubscribeUnit_Person),
-		Label:    "个人",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderSubscribeUnit_dept),
-		Label:    "部门",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func (s *StoreEntry) WorkOrderPriorityEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.Priority_Low),
-		Label:    "低",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.Priority_Middle),
-		Label:    "一般",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.Priority_High),
-		Label:    "紧急",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func (s *StoreEntry) WorkOrderCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderCategory_Health),
-		Label:    "保健",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderCategory_Breed),
-		Label:    "繁殖",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderCategory_Nutrition),
-		Label:    "营养",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderCategory_Ordinary),
-		Label:    "日常",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.WorkOrderCategory_Other),
-		Label:    "其他",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func CalendarTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.SameTimeStatus_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
-	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_Immunisation),
-		Label:    "免疫",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_PG),
-		Label:    "同期PG",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_RnGH),
-		Label:    "同期RnGH",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_Pregnancy_Check),
-		Label:    "孕检",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_WorkOrder),
-		Label:    "工单",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_Weaning),
-		Label:    "断奶",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_Treatment),
-		Label:    "治疗",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.CalendarType_Mating),
-		Label:    "配种",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func (s *StoreEntry) AbortionReasonsEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.AbortionReasons_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
-	}
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Mechanical_Abortion),
-		Label:    "机械性流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Malnutrition_Abortion),
-		Label:    "营养不良性流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Mycotoxin_Abortion),
-		Label:    "霉菌毒素流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Habitual_Abortion),
-		Label:    "习惯性流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Brucellosis_Abortion),
-		Label:    "布病流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Inflammatory_Abortion),
-		Label:    "产道炎症性流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Heat_Stress_Abortion),
-		Label:    "热应激流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Infectious_Abortion),
-		Label:    "传染病性流产",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.AbortionReasons_Other),
-		Label:    "其他",
-		Disabled: true,
-	})
-	return configOptions
-}
-
-func (s *StoreEntry) HealthStatusEnumList(isAll string) []*pasturePb.ConfigOptionsList {
-	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
-	if isAll == model.IsAllYes {
-		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-			Value:    int32(pasturePb.HealthStatus_Invalid),
-			Label:    "全部",
-			Disabled: true,
-		})
-	}
-
-	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.HealthStatus_Health),
-		Label:    "健康",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.HealthStatus_Disease),
-		Label:    "发病",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.HealthStatus_Treatment),
-		Label:    "治疗",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.HealthStatus_Curable),
-		Label:    "治愈",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.HealthStatus_Out),
-		Label:    "淘汰",
-		Disabled: true,
-	}, &pasturePb.ConfigOptionsList{
-		Value:    int32(pasturePb.HealthStatus_Dead),
-		Label:    "死亡",
-		Disabled: true,
-	})
-	return configOptions
-}

+ 567 - 0
module/backend/config_data_other.go

@@ -0,0 +1,567 @@
+package backend
+
+import (
+	"fmt"
+	"kpt-pasture/model"
+
+	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
+	"gitee.com/xuyiping_admin/pkg/logger/zaplog"
+	"go.uber.org/zap"
+)
+
+func (s *StoreEntry) PregnantCheckMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions,
+			&pasturePb.ConfigOptionsList{
+				Value: int32(pasturePb.PregnantCheckMethod_Invalid),
+			})
+	}
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
+		Label:    "B超",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.PregnantCheckMethod_Blood_Testing),
+		Label:    "血检",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
+		Label:    "人工检查",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) DrugCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions,
+			&pasturePb.ConfigOptionsList{
+				Value:    int32(pasturePb.DrugCategory_Invalid),
+				Label:    "全部",
+				Disabled: true,
+			})
+	}
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Antibiotics),
+		Label:    "抗生素类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Antivirals),
+		Label:    "抗病毒类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Antifungals),
+		Label:    "抗真菌类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Antiparasitics),
+		Label:    "驱虫类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Analgesics),
+		Label:    "镇痛类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Antipyretic),
+		Label:    "退烧类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Vitamin),
+		Label:    "维生素类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Brine),
+		Label:    "盐水",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Glucose),
+		Label:    "葡萄糖",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Hormone),
+		Label:    "激素类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Anti_Stress),
+		Label:    "抗应激类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Disinfect),
+		Label:    "消毒类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Chinese_Herbal),
+		Label:    "中药合剂",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Tocolytic),
+		Label:    "保胎类",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.DrugCategory_Immunity),
+		Label:    "疫苗类",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) DrugUsageEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions,
+			&pasturePb.ConfigOptionsList{
+				Value:    int32(pasturePb.DrugUsage_Invalid),
+				Label:    "全部",
+				Disabled: true,
+			})
+	}
+	configOptions = append(configOptions,
+		&pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.DrugUsage_Oral_Medications),
+			Label:    "口服",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.DrugUsage_Injectable_Medications),
+			Label:    "肌注",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.DrugUsage_Topical_Medications),
+			Label:    "外用",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.DrugUsage_Inhalation_Medications),
+			Label:    "吸入",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.DrugUsage_Drink_Medications),
+			Label:    "饮水",
+			Disabled: true,
+		})
+	return configOptions
+}
+
+func (s *StoreEntry) UnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	configOptions = append(configOptions,
+		&pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Pieces),
+			Label:    "个",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Package),
+			Label:    "包/袋",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Bottle),
+			Label:    "瓶",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Box),
+			Label:    "盒",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Boxful),
+			Label:    "箱",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Branch),
+			Label:    "支",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Barrel),
+			Label:    "桶",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_Pot),
+			Label:    "罐",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_ML),
+			Label:    "毫升",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Unit_L),
+			Label:    "升",
+			Disabled: true,
+		})
+	return configOptions
+}
+
+func (s *StoreEntry) ExposeEstrusTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions,
+			&pasturePb.ConfigOptionsList{
+				Value:    int32(pasturePb.ExposeEstrusType_Invalid),
+				Label:    "全部",
+				Disabled: true,
+			})
+	}
+
+	configOptions = append(configOptions,
+		&pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.ExposeEstrusType_Neck_Ring),
+			Label:    "脖环揭发",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.ExposeEstrusType_Foot_Ring),
+			Label:    "脚环揭发",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.ExposeEstrusType_Natural_Estrus),
+			Label:    "自然发情",
+			Disabled: true,
+		})
+	return configOptions
+}
+
+func (s *StoreEntry) FrozenSemenTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions,
+			&pasturePb.ConfigOptionsList{
+				Value:    int32(pasturePb.FrozenSemenType_Invalid),
+				Label:    "全部",
+				Disabled: true,
+			})
+	}
+	configOptions = append(configOptions,
+		&pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.FrozenSemenType_Ordinary),
+			Label:    "常规冻精",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.FrozenSemenType_Gender_Control),
+			Label:    "性控冻精",
+			Disabled: true,
+		})
+	return configOptions
+}
+
+func (s *StoreEntry) BullNumberEnumList(isAll string) []*pasturePb.BullOptionsList {
+	frozenSemenList := make([]*model.FrozenSemen, 0)
+	bullNumberList := make([]*pasturePb.BullOptionsList, 0)
+	if err := s.DB.Where("quantity > 0").Group("bull_id").Find(&frozenSemenList).Error; err != nil {
+		zaplog.Error("BullNumberEnumList", zap.Any("Find", err))
+	}
+
+	for _, v := range frozenSemenList {
+		bullNumberList = append(bullNumberList, &pasturePb.BullOptionsList{
+			Value:    v.BullId,
+			Label:    v.BullId,
+			Disabled: true,
+		})
+	}
+	return bullNumberList
+}
+
+func (s *StoreEntry) WeekEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	configOptions = append(configOptions,
+		&pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Week_Monday),
+			Label:    "周一",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Week_Tuesday),
+			Label:    "周二",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Week_Wednesday),
+			Label:    "周三",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Week_Thursday),
+			Label:    "周四",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Week_Friday),
+			Label:    "周五",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Week_Saturday),
+			Label:    "周六",
+			Disabled: true,
+		}, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.Week_Sunday),
+			Label:    "周日",
+			Disabled: true,
+		})
+	return configOptions
+}
+
+func (s *StoreEntry) MonthEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	for v := 1; v <= 31; v++ {
+		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+			Value:    int32(v),
+			Label:    fmt.Sprintf("%d号", v),
+			Disabled: true,
+		})
+	}
+	return configOptions
+}
+
+func (s *StoreEntry) WorkOrderFrequencyEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderFrequency_None),
+		Label:    "一次性",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderFrequency_Daily),
+		Label:    "每天",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderFrequency_Weekly),
+		Label:    "每周",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderFrequency_Monthly),
+		Label:    "每月",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) WorkOrderSubUnitEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderSubscribeUnit_Person),
+		Label:    "个人",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderSubscribeUnit_dept),
+		Label:    "部门",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) WorkOrderPriorityEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.Priority_Low),
+		Label:    "低",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.Priority_Middle),
+		Label:    "一般",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.Priority_High),
+		Label:    "紧急",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) WorkOrderCategoryEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderCategory_Health),
+		Label:    "保健",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderCategory_Breed),
+		Label:    "繁殖",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderCategory_Nutrition),
+		Label:    "营养",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderCategory_Ordinary),
+		Label:    "日常",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.WorkOrderCategory_Other),
+		Label:    "其他",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func CalendarTypeEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.SameTimeStatus_Invalid),
+			Label:    "全部",
+			Disabled: true,
+		})
+	}
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_Immunisation),
+		Label:    "免疫",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_PG),
+		Label:    "同期PG",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_RnGH),
+		Label:    "同期RnGH",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_Pregnancy_Check),
+		Label:    "孕检",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_WorkOrder),
+		Label:    "工单",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_Weaning),
+		Label:    "断奶",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_Treatment),
+		Label:    "治疗",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalendarType_Mating),
+		Label:    "配种",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) AbortionReasonsEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.AbortionReasons_Invalid),
+			Label:    "全部",
+			Disabled: true,
+		})
+	}
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Mechanical_Abortion),
+		Label:    "机械性流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Malnutrition_Abortion),
+		Label:    "营养不良性流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Mycotoxin_Abortion),
+		Label:    "霉菌毒素流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Habitual_Abortion),
+		Label:    "习惯性流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Brucellosis_Abortion),
+		Label:    "布病流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Inflammatory_Abortion),
+		Label:    "产道炎症性流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Heat_Stress_Abortion),
+		Label:    "热应激流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Infectious_Abortion),
+		Label:    "传染病性流产",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.AbortionReasons_Other),
+		Label:    "其他",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) HealthStatusEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.HealthStatus_Invalid),
+			Label:    "全部",
+			Disabled: true,
+		})
+	}
+
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Health),
+		Label:    "健康",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Disease),
+		Label:    "发病",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Treatment),
+		Label:    "治疗",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Curable),
+		Label:    "治愈",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Out),
+		Label:    "淘汰",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.HealthStatus_Dead),
+		Label:    "死亡",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) CalvingAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+			Value:    int32(pasturePb.CalvingAnalysisMethod_Invalid),
+			Label:    "全部",
+			Disabled: true,
+		})
+	}
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalvingAnalysisMethod_months),
+		Label:    "按月份统计",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.CalvingAnalysisMethod_cowKind),
+		Label:    "按照品种统计",
+		Disabled: true,
+	})
+	return configOptions
+}
+
+func (s *StoreEntry) LactEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+			Value:    int32(0),
+			Label:    "全部",
+			Disabled: true,
+		})
+	}
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(1),
+		Label:    "1",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(2),
+		Label:    "2",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(3),
+		Label:    "3",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(4),
+		Label:    ">3",
+		Disabled: true,
+	})
+	return configOptions
+}

+ 2 - 0
module/backend/enum_options.go

@@ -183,6 +183,8 @@ func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName, i
 		"abortionReasons":        s.AbortionReasonsEnumList,
 		"healthStatus":           s.HealthStatusEnumList,
 		"calendarType":           CalendarTypeEnumList,
+		"calvingAnalysisMethod":  s.CalvingAnalysisMethodEnumList,
+		"lact":                   s.CalvingAnalysisMethodEnumList,
 	}
 
 	getConfigFunc, ok := getConfigFuncMap[optionsName]

+ 8 - 12
module/backend/event_health.go

@@ -43,6 +43,8 @@ func (s *StoreEntry) CowDiseaseCreate(ctx context.Context, req *pasturePb.EventC
 		newEventCowDisease.HealthStatus = pasturePb.HealthStatus_Treatment
 	}
 
+	unitMap := s.UnitMap()
+
 	if err = s.DB.Transaction(func(tx *gorm.DB) error {
 		if err = tx.Model(new(model.EventCowDisease)).Create(newEventCowDisease).Error; err != nil {
 			return xerr.WithStack(err)
@@ -71,6 +73,7 @@ func (s *StoreEntry) CowDiseaseCreate(ctx context.Context, req *pasturePb.EventC
 					DrugsId:   int32(v.DrugsId),
 					DrugsName: v.DrugsName,
 					Unit:      v.Unit,
+					UnitName:  unitMap[v.Unit],
 					UseNum:    float32(v.Dosages),
 				}
 			}
@@ -265,12 +268,15 @@ func (s *StoreEntry) CowDiseaseTreatment(ctx context.Context, req *pasturePb.Cow
 		return xerr.WithStack(err)
 	}
 
+	unitMap := s.UnitMap()
+
 	prescriptionDetail := make([]*pasturePb.TreatmentDrugs, len(prescriptionDrugs))
 	for i, v := range prescriptionDrugs {
 		prescriptionDetail[i] = &pasturePb.TreatmentDrugs{
 			DrugsId:   int32(v.DrugsId),
 			DrugsName: v.DrugsName,
 			Unit:      v.Unit,
+			UnitName:  unitMap[v.Unit],
 			UseNum:    float32(v.Dosages),
 		}
 	}
@@ -353,7 +359,7 @@ func (s *StoreEntry) CowDiseaseTreatmentDetail(
 		return nil, xerr.WithStack(err)
 	}
 
-	eventCowTreatmentList := make([]*pasturePb.EventCowTreatment, 0)
+	eventCowTreatmentList := make([]*model.EventCowTreatment, 0)
 	cowDiseaseIds := make([]int64, len(eventCowDiseaseList))
 	for i, v := range eventCowDiseaseList {
 		cowDiseaseIds[i] = v.Id
@@ -368,21 +374,11 @@ func (s *StoreEntry) CowDiseaseTreatmentDetail(
 		return nil, xerr.WithStack(err)
 	}
 
-	for _, v := range eventCowTreatmentList {
-		for _, disease := range eventCowDiseaseList {
-			if int64(v.CowDiseaseId) != disease.Id {
-				continue
-			}
-			v.DiseaseName = disease.DiseaseName
-			v.DiseaseAt = int32(disease.DiseaseAt)
-		}
-	}
-
 	return &pasturePb.EventCowTreatmentDetailResponse{
 		Code:    http.StatusOK,
 		Message: "ok",
 		Data: &pasturePb.EventCowTreatmentDetail{
-			List:     eventCowTreatmentList,
+			List:     model.EventCowTreatmentSlice(eventCowTreatmentList).ToPB(eventCowDiseaseList),
 			Total:    int32(count),
 			PageSize: pagination.Page,
 			Page:     pagination.PageSize,

+ 1 - 0
module/backend/interface.go

@@ -214,6 +214,7 @@ type AnalyseService interface {
 	AbortionRate(ctx context.Context, req *pasturePb.AbortionRateRequest) (*pasturePb.AbortionRateResponse, error)
 	TwentyonePregnantRate(ctx context.Context, req *pasturePb.TwentyOnePregnantRateRequest) (*pasturePb.TwentyOnePregnantRateResponse, error)
 	PregnancyReport(ctx context.Context, req *pasturePb.PregnancyReportRequest, pagination *pasturePb.PaginationModel) (*pasturePb.PregnancyReportResponse, error)
+	CalvingReport(ctx context.Context, req *pasturePb.CalvingReportRequest, pagination *pasturePb.PaginationModel) (*pasturePb.CalvingReportResponse, error)
 }
 
 //go:generate mockgen -destination mock/DashboardService.go -package kptservicemock kpt-pasture/module/backend DashboardService

+ 5 - 8
util/util.go

@@ -77,11 +77,9 @@ func Ceil(x float64) float64 {
 
 // GetLastDayOfMonth
 // 接受一个字符串形式的月份(如 "2024-12"),
-// 并返回该月份的最后一天的日期
+// 并返回该月份的最后一天的日期(2024-12-31)
 func GetLastDayOfMonth(month string) (string, error) {
-	// 解析传入的月份
-	layout := "2006-01"
-	t, err := time.Parse(layout, month)
+	t, err := time.Parse(LayoutMonth, month)
 	if err != nil {
 		return "", err // 如果解析失败,返回错误
 	}
@@ -99,14 +97,13 @@ func GetLastDayOfMonth(month string) (string, error) {
 // 并返回一个包含这两个月份之间所有月份的字符串切片。
 func GetMonthsInRange(startMonth, endMonth string) ([]string, error) {
 	// 解析起始月份
-	startLayout := "2006-01"
-	startTime, err := time.Parse(startLayout, startMonth)
+	startTime, err := time.Parse(LayoutMonth, startMonth)
 	if err != nil {
 		return nil, err
 	}
 
 	// 解析结束月份
-	endTime, err := time.Parse(startLayout, endMonth)
+	endTime, err := time.Parse(LayoutMonth, endMonth)
 	if err != nil {
 		return nil, err
 	}
@@ -116,7 +113,7 @@ func GetMonthsInRange(startMonth, endMonth string) ([]string, error) {
 
 	// 循环添加每个月份直到达到或超过结束月份
 	for curr := startTime; curr.Before(endTime) || curr.Equal(endTime); curr = curr.AddDate(0, 1, 0) {
-		months = append(months, curr.Format("2006-01"))
+		months = append(months, curr.Format(LayoutMonth))
 	}
 
 	return months, nil