|
@@ -11,8 +11,15 @@ import (
|
|
|
"gitee.com/xuyiping_admin/pkg/xerr"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+func (s *StoreEntry) CalendarToDoList(ctx context.Context, req *pasturePb.CalendarToDoRequest) (*pasturePb.CalendarToDoResponse, error) {
|
|
|
+
|
|
|
+ return &pasturePb.CalendarToDoResponse{
|
|
|
+ Code: http.StatusOK,
|
|
|
+ Message: "ok",
|
|
|
+ Data: nil,
|
|
|
+ }, nil
|
|
|
+}
|
|
|
func (s *StoreEntry) CalendarList(ctx context.Context, req *pasturePb.CalendarRequest) (*pasturePb.CalendarResponse, error) {
|
|
|
calendarList := make([]*model.Calendar, 0)
|
|
|
if err := s.DB.Model(&model.Calendar{}).
|
|
@@ -38,6 +45,7 @@ func (s *StoreEntry) CalendarTableDetail(
|
|
|
if req.Start != time.Now().Format(model.LayoutDate2) {
|
|
|
return nil, xerr.New("参数错误")
|
|
|
}
|
|
|
+
|
|
|
newCalendar := &model.Calendar{}
|
|
|
if err := s.DB.Model(&model.Calendar{}).
|
|
|
Where("calendar_type = ?", req.CalendarType).
|
|
@@ -80,9 +88,9 @@ func (s *StoreEntry) getCalendarCowList(
|
|
|
}
|
|
|
|
|
|
func (s *StoreEntry) ImmunisationCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
- immunizationPlanCowList := make([]*model.ImmunizationPlanCow, 0)
|
|
|
+ immunizationPlanCowList := make([]*model.CowImmunizationPlan, 0)
|
|
|
count := int64(0)
|
|
|
- if err := s.DB.Model(&model.ImmunizationPlanCow{}).
|
|
|
+ if err := s.DB.Model(&model.CowImmunizationPlan{}).
|
|
|
Where("plan_start_time <= ?", dateTime).
|
|
|
Where("status = ?", pasturePb.IsShow_No).
|
|
|
Order("id desc").Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).
|
|
@@ -113,7 +121,7 @@ func (s *StoreEntry) ImmunisationCowList(ctx context.Context, dateTime string, p
|
|
|
func (s *StoreEntry) SameTimeCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel, calendarType pasturePb.CalendarType_Kind) (*model.CalendarResponse, error) {
|
|
|
sameTimeBodyList := make([]*model.SameTimeBody, 0)
|
|
|
count := int64(0)
|
|
|
- pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.SameTimeCowDetail).TableName())).
|
|
|
+ pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.CowSameTimeDetail).TableName())).
|
|
|
Select("a.id,a.cow_id,a.status,b.breed_status,b.cow_type,b.pen_id,b.day_age,b.calving_age,b.abortion_age").
|
|
|
Joins("left join cow as b on a.cow_id = b.id").
|
|
|
Where("b.is_remove = ?", pasturePb.IsShow_No).
|
|
@@ -172,9 +180,8 @@ func (s *StoreEntry) WorkOrderCowList(ctx context.Context, dateTime string, pagi
|
|
|
func (s *StoreEntry) WeaningCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
weaningBodyList := make([]*model.WeaningBody, 0)
|
|
|
count := int64(0)
|
|
|
- dateTime = dateTime + " 23:59:59"
|
|
|
|
|
|
- pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.SameTimeCowDetail).TableName())).
|
|
|
+ pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.CowSameTimeDetail).TableName())).
|
|
|
Select("a.*,b.day_age").
|
|
|
Joins("left join cow as b on a.cow_id = b.id").
|
|
|
Where("b.is_remove = ?", pasturePb.IsShow_No).
|
|
@@ -213,5 +220,44 @@ func (s *StoreEntry) TreatmentCowList(ctx context.Context, dateTime string, pagi
|
|
|
}
|
|
|
|
|
|
func (s *StoreEntry) MatingCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
- return nil, nil
|
|
|
+ cowMatingBodyList := make([]*model.CowMatingBody, 0)
|
|
|
+ count := int64(0)
|
|
|
+ pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.CowSameTimeDetail).TableName())).
|
|
|
+ Select("a.id,a.cow_id,a.status,b.breed_status,b.cow_type,b.pen_id,b.day_age,b.calving_age,b.abortion_age").
|
|
|
+ Joins("left join cow as b on a.cow_id = b.id").
|
|
|
+ Where("b.is_remove = ?", pasturePb.IsShow_No).
|
|
|
+ Where("a.plan_day <= ?", dateTime).
|
|
|
+ Where("a.status = ?", pasturePb.IsShow_No)
|
|
|
+
|
|
|
+ if err := pref.Order("a.id desc").Count(&count).
|
|
|
+ Limit(int(pagination.PageSize)).
|
|
|
+ Offset(int(pagination.PageOffset)).
|
|
|
+ Find(&cowMatingBodyList).Error; err != nil {
|
|
|
+ return nil, xerr.WithStack(err)
|
|
|
+ }
|
|
|
+ cowTypeMap := s.CowTypeMap()
|
|
|
+ breedStatusMap := s.CowBreedStatusMap()
|
|
|
+ penMap := s.PenMap(ctx)
|
|
|
+ return &model.CalendarResponse{
|
|
|
+ Code: http.StatusOK,
|
|
|
+ Message: "ok",
|
|
|
+ Data: &model.CalendarData{
|
|
|
+ Total: int32(count),
|
|
|
+ Page: pagination.Page,
|
|
|
+ PageSize: pagination.PageSize,
|
|
|
+ Header: model.SameTimeHeader{
|
|
|
+ Id: "编号",
|
|
|
+ CowId: "牛号",
|
|
|
+ BreedStatusName: "繁殖状态",
|
|
|
+ CowTypeName: "牛只类型",
|
|
|
+ PenName: "栏舍",
|
|
|
+ Lact: "胎次",
|
|
|
+ CalvingAge: "产后天数",
|
|
|
+ AbortionAge: "流产天数",
|
|
|
+ DayAge: "日龄",
|
|
|
+ Status: "状态",
|
|
|
+ },
|
|
|
+ List: model.CowMatingBodySlice(cowMatingBodyList).ToPB(cowTypeMap, breedStatusMap, penMap),
|
|
|
+ },
|
|
|
+ }, nil
|
|
|
}
|