|
@@ -144,7 +144,8 @@ func (s *StoreEntry) getCalendarCowList(
|
|
|
func (s *StoreEntry) ImmunisationCowList(ctx context.Context, req *pasturePb.ItemsRequest, pagination *pasturePb.PaginationModel) (*pasturePb.ImmunizationItemsResponse, error) {
|
|
|
eventImmunizationPlanList := make([]*model.EventImmunizationPlan, 0)
|
|
|
count := int64(0)
|
|
|
- pref := s.DB.Model(&model.EventImmunizationPlan{})
|
|
|
+ pref := s.DB.Model(&model.EventImmunizationPlan{}).
|
|
|
+ Where("status = ?", pasturePb.IsShow_No)
|
|
|
if req.StartDay != "" {
|
|
|
dateTime := util.TimeParseLocalUnix(req.StartDay)
|
|
|
pref.Where("plan_day >= ?", dateTime)
|
|
@@ -212,7 +213,8 @@ func (s *StoreEntry) SameTimeCowList(ctx context.Context, req *pasturePb.ItemsRe
|
|
|
pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.EventCowSameTime).TableName())).
|
|
|
Select("a.id,a.cow_id,a.pen_name,a.status,b.breed_status,b.cow_type,b.day_age,b.calving_age,b.abortion_age").
|
|
|
Joins("left join cow as b on a.cow_id = b.id").
|
|
|
- Where("b.admission_status = ?", pasturePb.AdmissionStatus_Admission)
|
|
|
+ Where("b.admission_status = ?", pasturePb.AdmissionStatus_Admission).
|
|
|
+ Where("a.status = ?", pasturePb.IsShow_No)
|
|
|
|
|
|
if req.EndDay != "" {
|
|
|
dateTime := util.TimeParseLocalEndUnix(req.EndDay)
|
|
@@ -270,7 +272,8 @@ func (s *StoreEntry) PregnancyCheckCowList(ctx context.Context, req *pasturePb.I
|
|
|
pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.EventPregnantCheck).TableName())).
|
|
|
Select("a.id,a.cow_id,a.pen_id,a.status,b.breed_status,b.cow_type,b.day_age,b.calving_age,b.abortion_age,a.bull_id").
|
|
|
Joins("left join cow as b on a.cow_id = b.id").
|
|
|
- Where("b.admission_status = ?", pasturePb.AdmissionStatus_Admission)
|
|
|
+ Where("b.admission_status = ?", pasturePb.AdmissionStatus_Admission).
|
|
|
+ Where("a.status = ?", pasturePb.IsShow_No)
|
|
|
|
|
|
if req.EndDay != "" {
|
|
|
dateTime := util.TimeParseLocalEndUnix(req.EndDay)
|
|
@@ -331,9 +334,11 @@ func (s *StoreEntry) WeaningCowList(ctx context.Context, req *pasturePb.ItemsReq
|
|
|
count := int64(0)
|
|
|
|
|
|
pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.EventWeaning).TableName())).
|
|
|
- Select("a.*,b.day_age").
|
|
|
+ Select("a.*,b.day_age,c.name as pen_name").
|
|
|
Joins("left join cow as b on a.cow_id = b.id").
|
|
|
- Where("b.admission_status = ?", pasturePb.AdmissionStatus_Admission)
|
|
|
+ Joins("left join pen as c on a.before_pen_id = c.id").
|
|
|
+ Where("b.admission_status = ?", pasturePb.AdmissionStatus_Admission).
|
|
|
+ Where("a.status = ?", pasturePb.IsShow_No)
|
|
|
|
|
|
if req.EndDay != "" {
|
|
|
dateTime := util.TimeParseLocalEndUnix(req.EndDay)
|
|
@@ -375,15 +380,19 @@ func (s *StoreEntry) MatingCowList(ctx context.Context, req *pasturePb.ItemsRequ
|
|
|
matingItems := make([]*pasturePb.MatingItems, 0)
|
|
|
count := int64(0)
|
|
|
pref := s.DB.Table(fmt.Sprintf("%s as a", new(model.EventMating).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.admission_status = ?", pasturePb.AdmissionStatus_Admission)
|
|
|
+ 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,c.name as pen_name").
|
|
|
+ Joins("left join pen as c on a.pen_id = c.id").
|
|
|
+ Where("a.status = ?", pasturePb.IsShow_No)
|
|
|
|
|
|
if req.EndDay != "" {
|
|
|
dateTime := util.TimeParseLocalEndUnix(req.EndDay)
|
|
|
pref.Where("a.plan_day <= ?", dateTime)
|
|
|
}
|
|
|
|
|
|
+ if req.PenId > 0 {
|
|
|
+ pref.Where("a.pen_id = ?", req.PenId)
|
|
|
+ }
|
|
|
+
|
|
|
if req.Status > 0 {
|
|
|
pref.Where("a.status = ?", req.Status)
|
|
|
}
|