Browse Source

spillage: 车次重量

Yi 1 year ago
parent
commit
7e87eaf177

+ 36 - 0
http/handler/statistic/analysis.go

@@ -560,12 +560,23 @@ func FeedTemplateHistory(c *gin.Context) {
 	c.JSON(http.StatusOK, res)
 }
 
+// BarnHistory 栏色修改纪录
 func BarnHistory(c *gin.Context) {
 	var req operationPb.BarnHistoryRequest
 	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
+
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.BarnName, valid.Required, valid.Length(1, 100)),
+		valid.Field(&req.StartTime, valid.Required),
+		valid.Field(&req.EndTime, valid.Required),
+	); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
 	res, err := middleware.BackendOperation(c).OpsService.BarnHistory(c, &req)
 	if err != nil {
 		apierr.ClassifiedAbort(c, err)
@@ -573,3 +584,28 @@ func BarnHistory(c *gin.Context) {
 	}
 	c.JSON(http.StatusOK, res)
 }
+
+// SpillageAllHistory 车次重量
+func SpillageAllHistory(c *gin.Context) {
+	var req operationPb.BarnHistoryRequest
+	if err := ginutil.BindProto(c, &req); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+	if err := valid.ValidateStruct(&req,
+		valid.Field(&req.BarnName, valid.Required, valid.Length(1, 100)),
+		valid.Field(&req.StartTime, valid.Required),
+		valid.Field(&req.EndTime, valid.Required),
+		valid.Field(&req.PastureId, valid.Required),
+	); err != nil {
+		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
+		return
+	}
+
+	res, err := middleware.BackendOperation(c).OpsService.SpillageAllHistory(c, &req)
+	if err != nil {
+		apierr.ClassifiedAbort(c, err)
+		return
+	}
+	c.JSON(http.StatusOK, res)
+}

+ 1 - 0
http/route/ops_api.go

@@ -96,6 +96,7 @@ func OpsAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		opsRoute.POST("/statistics/mixed_category_tmr_name", statistic.FeedMixedAndTmrName)
 		opsRoute.POST("/feed_template/history", statistic.FeedTemplateHistory)
 		opsRoute.POST("/barn/history", statistic.BarnHistory)
+		opsRoute.POST("/spillage_all/history", statistic.SpillageAllHistory)
 		opsRoute.POST("/accuracy/data_by_name", statistic.GetDataByName)
 
 		// 首页仪表盘

+ 1 - 0
model/formula_estimate.go

@@ -413,6 +413,7 @@ type PastureFeedTemplateHistoryResponse struct {
 }
 
 type PastureBarnHistoryRequest struct {
+	PastureId string `json:"pastureid,omitempty"`
 	BarName   string `json:"barname"`
 	StartDate string `json:"startDate"`
 	EndDate   string `json:"endDate"`

+ 1 - 0
model/group_pasture.go

@@ -25,6 +25,7 @@ const (
 	UrlProcess             = "authdata/processAnalysist"
 	UrlFeedTemplateHistory = "authdata/feedtemplet/history"
 	UrlBarnHistory         = "authdata/feedp/history"
+	UrlSpillageAllHistory  = "authdata/spillageall/history"
 )
 
 const (

+ 22 - 0
module/backend/dashboard_service.go

@@ -779,6 +779,28 @@ func (s *StoreEntry) BarnHistory(ctx context.Context, req *operationPb.BarnHisto
 	return response, nil
 }
 
+func (s *StoreEntry) SpillageAllHistory(ctx context.Context, req *operationPb.BarnHistoryRequest) (*model.PastureBarnHistoryResponse, error) {
+	groupPasture, err := s.GetGroupPastureListById(ctx, int64(req.PastureId))
+	if err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	pastureId := req.PastureId
+	if groupPasture.PastureId > 0 {
+		pastureId = int32(groupPasture.PastureId)
+	}
+	body := &model.PastureBarnHistoryRequest{
+		PastureId: fmt.Sprintf("%d", pastureId),
+		BarName:   req.BarnName,
+		StartDate: req.StartTime,
+		EndDate:   req.EndTime,
+	}
+	response := &model.PastureBarnHistoryResponse{}
+	if err = s.PastureHttpClient(ctx, model.UrlSpillageAllHistory, int64(req.PastureId), body, response); err != nil {
+		return nil, xerr.WithStack(err)
+	}
+	return response, nil
+}
+
 func sprinkleExecTimeAnalysis(sprinkleFeedTimeList map[int32]map[int32][]int64) (int32, int32) {
 	var infoSprinkleNumber, errorSprinkleNumber int32 = 0, 0
 	if len(sprinkleFeedTimeList) <= 0 {

+ 1 - 0
module/backend/interface.go

@@ -174,6 +174,7 @@ type StatisticService interface {
 	FeedMixedAndTmrName(ctx context.Context, req *operationPb.MixedCategoryTmrName) (*model.PastureCommonResponse, error)
 	FeedTemplateHistory(ctx context.Context, req *operationPb.FeedTemplateHistoryRequest) (*model.PastureFeedTemplateHistoryResponse, error)
 	BarnHistory(ctx context.Context, req *operationPb.BarnHistoryRequest) (*model.PastureBarnHistoryResponse, error)
+	SpillageAllHistory(ctx context.Context, req *operationPb.BarnHistoryRequest) (*model.PastureBarnHistoryResponse, error)
 }
 
 //go:generate mockgen -destination mock/WxAppletService.go -package kptservicemock kpt-tmr-group/module/backend WxAppletService