Browse Source

feed: 配方详情

Yi 1 year ago
parent
commit
28f34882c1

+ 1 - 1
Dockerfile

@@ -26,6 +26,6 @@ COPY --from=0 /app/kpt-tmr/conf/ /app/kpt-tmr/bin/conf/
 COPY --from=0  /app/kpt-tmr/bin/kptTmr /app/kpt-tmr/bin/kptTmr
 
 EXPOSE 8081
-VOLUME ["/app/kpt-tmr/bin/logs","/app/kpt-tmr/bin/conf/"]
+VOLUME ["/app/kpt-tmr/logger","/app/kpt-tmr/bin/conf/"]
 
 CMD ["/app/kpt-tmr/bin/kptTmr"]

+ 30 - 0
http/handle/group/feed_formula.go

@@ -174,6 +174,36 @@ func FeedAsyncList(c *gin.Context) {
 	appG.Response(http.StatusOK, e.SUCCESS, data)
 }
 
+// FeedFormulaDetailList 饲料配方详情
+func FeedFormulaDetailList(c *gin.Context) {
+	appG := app.Gin{C: c}
+	var req models.FeedListRequest
+	if err := c.BindJSON(&req); err != nil {
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	if req.PastureId <= 0 {
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	if req.Page <= 0 {
+		req.Page = 1
+	}
+
+	if req.PageSize <= 0 {
+		req.PageSize = 50
+	}
+
+	data, err := group.FeedTemplateDetailList(&req)
+	if err != nil {
+		appG.Response(http.StatusBadRequest, e.ERROR_ADD_FAIL, nil)
+		return
+	}
+	appG.Response(http.StatusOK, e.SUCCESS, data)
+}
+
 // AnalysisAccuracy 准确性分析
 func AnalysisAccuracy(c *gin.Context) {
 	appG := app.Gin{C: c}

+ 1 - 0
http/routers/group_api.go

@@ -15,6 +15,7 @@ func GroupAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
 		apiPasture := s.Group("/pasture")
 		apiPasture.POST("feed_formula/distribute", group.DistributeFeedFormula)              // 饲料配方下发
 		apiPasture.POST("feed_formula/cancel/distribute", group.CancelDistributeFeedFormula) // 取消饲料配方下发
+		apiPasture.POST("feed_formula/detail_list", group.FeedFormulaDetailList)             // 配方详细
 		apiPasture.POST("feed_formula/edit_recode/list", group.EditRecodeFeedFormula)        // 饲料配方修改记录
 		apiPasture.POST("feed_formula/is_modify", group.FeedFormulaIsModify)                 // 饲料配方是否可修改
 		apiPasture.POST("feed_formula/async", group.FeedFormulaAsyncList)                    // 获取配方列表

+ 0 - 0
models/feed_templet.go → models/feed_template.go


+ 24 - 0
models/feed_template_detail.go

@@ -0,0 +1,24 @@
+package models
+
+type FeedTemplateDetail struct {
+	Id             int64   `xorm:"id" json:"id"`
+	PastureId      int64   `xorm:"pastureid" json:"pasture_id"`
+	FtId           int64   `xorm:"ftid" json:"ft_id"`
+	FId            int64   `xorm:"fid" json:"f_id"`
+	FdName         string  `xorm:"fdname" json:"fd_name"`
+	LWeight        float64 `xorm:"lweight" json:"l_weight"`
+	FWeight        float64 `xorm:"fweight" json:"f_weight"`
+	IsLockCount    int32   `xorm:"islockcount" json:"is_lock_count"`
+	IsFg           int32   `xorm:"isfg" json:"is_fg"`
+	Sort           int32   `xorm:"sort" json:"sort"`
+	FeedGroup      string  `xorm:"feedgroup" json:"feed_group"`
+	PreFtId        int64   `xorm:"preftid" json:"pre_ft_id"`
+	AutoSecond     int32   `xorm:"autosecond" json:"auto_second"`
+	AutoSecondName string  `xorm:"autosecondname" json:"auto_second_name"`
+	SplitFtPreId   int64   `xorm:"splitftpreid" json:"split_ft_pre_id"`
+	Deviation      int32   `xorm:"deviation" json:"deviation"`
+}
+
+func (f *FeedTemplateDetail) TableName() string {
+	return "ftdetail"
+}

+ 7 - 12
models/group_data.go

@@ -172,12 +172,6 @@ type FeedListRequest struct {
 	PageSize  int32 `json:"page_size"`
 }
 
-type FeedFormulaListResponse struct {
-	Code int32            `json:"code"`
-	Msg  string           `json:"msg"`
-	Data *FeedFormulaData `json:"data"`
-}
-
 type FeedFormulaData struct {
 	Total    int32           `json:"total"`
 	Page     int32           `json:"page"`
@@ -185,12 +179,6 @@ type FeedFormulaData struct {
 	List     []*FeedTemplate `json:"list"`
 }
 
-type FeedListResponse struct {
-	Code int32     `json:"code"`
-	Msg  string    `json:"msg"`
-	Data *FeedData `json:"data"`
-}
-
 type FeedData struct {
 	Total    int32   `json:"total"`
 	Page     int32   `json:"page"`
@@ -198,6 +186,13 @@ type FeedData struct {
 	List     []*Feed `json:"list"`
 }
 
+type FeedDetailData struct {
+	Total    int32                 `json:"total"`
+	Page     int32                 `json:"page"`
+	PageSize int32                 `json:"page_size"`
+	List     []*FeedTemplateDetail `json:"list"`
+}
+
 type FeedFormulaUsageRequest struct {
 	PastureId     int32  `json:"pasture_id"`
 	FeedFormulaId int32  `json:"feed_formula_id"`

+ 19 - 0
module/group.go

@@ -344,6 +344,25 @@ func FeedList(req *models.FeedListRequest) ([]*models.Feed, int64, error) {
 	return res, total, nil
 }
 
+func FeedTemplateDetailList(req *models.FeedListRequest) ([]*models.FeedTemplateDetail, int64, error) {
+	var (
+		res   []*models.FeedTemplateDetail
+		total int64
+		err   error
+	)
+	newSession := restful.Engine.NewSession()
+	total, err = newSession.Table(new(models.FeedTemplateDetail).TableName()).
+		Where("pastureid = ?", req.PastureId).Count(&res)
+	if err != nil {
+		return nil, 0, err
+	}
+
+	if err = newSession.Table(new(models.FeedTemplateDetail).TableName()).Limit(int(req.PageSize), int(req.Page-1)*int(req.PageSize)).Find(&res); err != nil {
+		return nil, 0, err
+	}
+	return res, total, nil
+}
+
 func FeedTemplateUsageDetail(req *models.FeedFormulaUsageRequest) (*models.FeedFormulaUsageResponse, error) {
 	mixedDetail, err := getMixedDetail(req.PastureId, req.FeedFormulaId, req.StartTime, req.EndTime)
 	if err != nil {

+ 19 - 2
service/group/group.go

@@ -69,7 +69,6 @@ func FeedFormulaList(req *models.FeedListRequest) (*models.FeedFormulaData, erro
 		zaplog.Error("FeedFormulaList", zap.Any("dataList", dataList), zap.Any("err", err))
 		return nil, err
 	}
-	zaplog.Info("FeedFormulaList", zap.Any("dataList", dataList), zap.Any("total", total))
 	res.Total = int32(total)
 	res.List = dataList
 	return res, nil
@@ -89,7 +88,25 @@ func FeedList(req *models.FeedListRequest) (*models.FeedData, error) {
 		zaplog.Error("FeedList", zap.Any("dataList", dataList), zap.Any("err", err))
 		return nil, err
 	}
-	zaplog.Info("FeedList", zap.Any("dataList", dataList), zap.Any("total", total))
+	res.Total = int32(total)
+	res.List = dataList
+	return res, nil
+}
+
+// FeedTemplateDetailList 饲料配方详情列表数据
+func FeedTemplateDetailList(req *models.FeedListRequest) (*models.FeedDetailData, error) {
+	res := &models.FeedDetailData{
+		Total:    0,
+		Page:     req.Page,
+		PageSize: req.PageSize,
+		List:     make([]*models.FeedTemplateDetail, 0),
+	}
+
+	dataList, total, err := module.FeedTemplateDetailList(req)
+	if err != nil {
+		zaplog.Error("FeedTemplateDetailList", zap.Any("dataList", dataList), zap.Any("err", err))
+		return nil, err
+	}
 	res.Total = int32(total)
 	res.List = dataList
 	return res, nil