|
@@ -26,12 +26,15 @@ func (s *StoreEntry) CalendarList(ctx context.Context, req *pasturePb.CalendarRe
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
-func (s *StoreEntry) CalendarTableDetail(ctx context.Context, req *pasturePb.CalendarTableRequest) (interface{}, error) {
|
|
|
+func (s *StoreEntry) CalendarTableDetail(
|
|
|
+ ctx context.Context,
|
|
|
+ req *pasturePb.CalendarTableRequest,
|
|
|
+ pagination *pasturePb.PaginationModel,
|
|
|
+) (interface{}, error) {
|
|
|
|
|
|
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).
|
|
@@ -45,15 +48,92 @@ func (s *StoreEntry) CalendarTableDetail(ctx context.Context, req *pasturePb.Cal
|
|
|
return nil, xerr.New("不存在该日历数据")
|
|
|
}
|
|
|
|
|
|
- switch newCalendar.CalendarType {
|
|
|
- case pasturePb.CalendarType_Immunisation:
|
|
|
- case pasturePb.CalendarType_PG:
|
|
|
- case pasturePb.CalendarType_RnGH:
|
|
|
- case pasturePb.CalendarType_Pregnancy_Check:
|
|
|
- case pasturePb.CalendarType_WorkOrder:
|
|
|
- case pasturePb.CalendarType_Weaning:
|
|
|
- case pasturePb.CalendarType_Treatment:
|
|
|
+ return s.getCalendarCowList(ctx, req.CalendarType, req.Start, pagination), nil
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) getCalendarCowList(
|
|
|
+ ctx context.Context,
|
|
|
+ calendarType pasturePb.CalendarType_Kind,
|
|
|
+ startDate string,
|
|
|
+ pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ switch calendarType {
|
|
|
+ case pasturePb.CalendarType_Immunisation: // 免疫
|
|
|
+ return s.ImmunisationCowList(ctx, startDate, pagination)
|
|
|
+ case pasturePb.CalendarType_PG: // 同期PG
|
|
|
+ return s.PGCowList(ctx, startDate, pagination)
|
|
|
+ case pasturePb.CalendarType_RnGH: // 同期RnGH
|
|
|
+ return s.RnGHCowList(ctx, startDate, pagination)
|
|
|
+ case pasturePb.CalendarType_Pregnancy_Check: // 孕检
|
|
|
+ return s.PregnancyCheckCowList(ctx, startDate, pagination)
|
|
|
+ case pasturePb.CalendarType_WorkOrder: // 工作单
|
|
|
+ return s.WorkOrderCowList(ctx, startDate, pagination)
|
|
|
+ case pasturePb.CalendarType_Weaning: // 断奶
|
|
|
+ return s.WeaningCowList(ctx, startDate, pagination)
|
|
|
+ case pasturePb.CalendarType_Treatment: // 治疗
|
|
|
+ return s.TreatmentCowList(ctx, startDate, pagination)
|
|
|
+ case pasturePb.CalendarType_Mating: // 配种
|
|
|
+ return s.MatingCowList(ctx, startDate, pagination)
|
|
|
+ default:
|
|
|
+ return nil, xerr.New("不支持的日历类型")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) ImmunisationCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ immunizationPlanCowList := make([]*model.ImmunizationPlanCow, 0)
|
|
|
+ count := int64(0)
|
|
|
+ if err := s.DB.Model(&model.ImmunizationPlanCow{}).
|
|
|
+ Where("plan_start_time <= ?", dateTime).
|
|
|
+ Where("status = ?", pasturePb.IsShow_No).
|
|
|
+ Order("id desc").Count(&count).Limit(int(pagination.PageSize)).Offset(int(pagination.PageOffset)).
|
|
|
+ Find(&immunizationPlanCowList).Error; err != nil {
|
|
|
+ return nil, xerr.WithStack(err)
|
|
|
}
|
|
|
|
|
|
+ return &model.CalendarResponse{
|
|
|
+ Code: http.StatusOK,
|
|
|
+ Message: "ok",
|
|
|
+ Data: &model.CalendarData{
|
|
|
+ Total: int32(count),
|
|
|
+ Page: pagination.Page,
|
|
|
+ PageSize: pagination.PageSize,
|
|
|
+ Header: model.ImmunizationCalendarHeader{
|
|
|
+ Id: "id",
|
|
|
+ CowId: "cowId",
|
|
|
+ PlanStartTime: "planStartTime",
|
|
|
+ ImmunizationPlanId: "immunizationPlanId",
|
|
|
+ ImmunizationPlanName: "immunizationPlanName",
|
|
|
+ Status: "status",
|
|
|
+ },
|
|
|
+ List: model.ImmunizationPlanCowSlice(immunizationPlanCowList).ToPB(),
|
|
|
+ },
|
|
|
+ }, nil
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) PGCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ return nil, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) RnGHCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ return nil, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) PregnancyCheckCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ return nil, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) WorkOrderCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ return nil, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) WeaningCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ return nil, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) TreatmentCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
+ return nil, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) MatingCowList(ctx context.Context, dateTime string, pagination *pasturePb.PaginationModel) (*model.CalendarResponse, error) {
|
|
|
return nil, nil
|
|
|
}
|