瀏覽代碼

Merge branch 'feature/bug-list' of xuyiping/kpt-tmr-group into develop

xuyiping 1 年之前
父節點
當前提交
5db7305ccd

+ 1 - 1
backend/operation/pasture.proto

@@ -137,7 +137,7 @@ message AddForageRequest {
   string name = 2;                      // 饲料名称
   int32 category_id = 3;                // 饲料分类id
   string category_name = 4;             // 饲料分类名称
-  string material_type_key = 5;        // 物料类型key
+  int32 material_type_key = 5;        // 物料类型key
   string material_type_name = 6;        // 物料类型名称
   string unique_encode = 7;              // 唯一编码
   ForageSource.Kind forage_source_id = 8;       // 饲料来源id

+ 11 - 11
http/handler/feed/feed_formula.go

@@ -19,7 +19,7 @@ import (
 
 func AddFeedFormula(c *gin.Context) {
 	var req operationPb.AddFeedFormulaRequest
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -55,7 +55,7 @@ func AddFeedFormula(c *gin.Context) {
 // EditFeedFormula 编辑配方
 func EditFeedFormula(c *gin.Context) {
 	var req operationPb.AddFeedFormulaRequest
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -92,7 +92,7 @@ func EditFeedFormula(c *gin.Context) {
 // AddFeedByFeedFormula 配方添加饲料
 func AddFeedByFeedFormula(c *gin.Context) {
 	var req operationPb.GroupAddFeedFormulaDetail
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -118,7 +118,7 @@ func AddFeedByFeedFormula(c *gin.Context) {
 // EditFeedByFeedFormula 配方饲料编辑
 func EditFeedByFeedFormula(c *gin.Context) {
 	var req operationPb.AddFeedFormulaDetail
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -145,7 +145,7 @@ func EditFeedByFeedFormula(c *gin.Context) {
 // DetailBySort 配方详情排序
 func DetailBySort(c *gin.Context) {
 	var req operationPb.GroupAddFeedFormulaDetail
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -171,7 +171,7 @@ func DetailBySort(c *gin.Context) {
 // IsModifyFeedDetail 配方详情是否可修改
 func IsModifyFeedDetail(c *gin.Context) {
 	var req operationPb.AddFeedFormulaDetail
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -199,7 +199,7 @@ func IsModifyFeedDetail(c *gin.Context) {
 // SearchFeedDetail 查询配方饲料详情
 func SearchFeedDetail(c *gin.Context) {
 	var req operationPb.AddFeedFormulaDetail
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -228,7 +228,7 @@ func SearchFeedDetail(c *gin.Context) {
 // DeleteFeedDetail 删除配方饲料
 func DeleteFeedDetail(c *gin.Context) {
 	var req operationPb.GroupAddFeedFormulaDetail
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -254,7 +254,7 @@ func DeleteFeedDetail(c *gin.Context) {
 // MixedFeedFormula 合并预混料
 func MixedFeedFormula(c *gin.Context) {
 	var req operationPb.MixedFeedFormulaRequest
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -348,7 +348,7 @@ func DeleteFeedFormula(c *gin.Context) {
 
 func IsShowModifyFeedFormula(c *gin.Context) {
 	var req operationPb.IsShowModifyFeedFormula
-	if err := c.BindJSON(&req); err != nil {
+	if err := ginutil.BindProto(c, &req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}
@@ -412,7 +412,7 @@ func ExcelImportFeedFormula(c *gin.Context) {
 
 func ExcelExportFeedFormula(c *gin.Context) {
 	req := &operationPb.SearchFeedFormulaRequest{}
-	if err := c.BindJSON(req); err != nil {
+	if err := ginutil.BindProto(c, req); err != nil {
 		apierr.AbortBadRequest(c, http.StatusBadRequest, err)
 		return
 	}

+ 2 - 0
model/group_pasture.go

@@ -174,6 +174,7 @@ func (p *PastureClient) DoGet(url string) ([]byte, error) {
 	req.Header.Add("Accept", "application/json")
 	req.Header.Add("token", p.Token)
 	req.Header.Add("Content-Type", "application/json")
+	req.Header.Add("pasture_id", fmt.Sprintf("%d", p.Detail.PastureId))
 	return p.doRequest(req)
 }
 
@@ -199,6 +200,7 @@ func (p *PastureClient) DoPost(url string, body interface{}) ([]byte, error) {
 	req.Header.Add("Accept", "application/json")
 	req.Header.Add("token", p.Token)
 	req.Header.Add("Content-Type", "application/json")
+	req.Header.Add("pasture_id", fmt.Sprintf("%d", p.Detail.PastureId))
 	return p.doRequest(req)
 }
 

+ 6 - 3
model/pasture_data.go

@@ -1,5 +1,7 @@
 package model
 
+import operationPb "kpt-tmr-group/proto/go/backend/operation"
+
 type DistributeFeedFormulaRequest struct {
 	PastureId         int64                `json:"pasture_id"`
 	FeedFormula       []*FeedFormula       `json:"feed_formula"`
@@ -204,9 +206,10 @@ type FeedTemplateDetail struct {
 }
 
 type FeedFormulaUpdateVersionRequest struct {
-	FeedTemplateId int64 `json:"feed_template_id"` // 配方id
-	Version        int64 `json:"version"`          // 版本号
-	Belong         int32 `json:"belong"`           // 配方归属  0 无效 1 归属集团端 2 归属牧场端
+	FeedTemplateId int64                               `json:"feed_template_id"` // 配方id
+	Version        int64                               `json:"version"`          // 版本号
+	Belong         int32                               `json:"belong"`           // 配方归属  0 无效 1 归属集团端 2 归属牧场端
+	Data           []*operationPb.AddFeedFormulaDetail `json:"data"`
 }
 
 type FeedFormulaUpdateVersionResponse struct {

+ 10 - 1
module/backend/feed_service.go

@@ -1043,7 +1043,7 @@ func (s *StoreEntry) UpdateFeedFormalVersion(ctx context.Context, req *model.Fee
 		Where("feed_formula_id = ?", req.Id).
 		Where("is_show = ?", operationPb.IsShow_OK).
 		Group("pasture_id").
-		Find(&feedFormulaDistributeLogList).Debug().Error; err != nil {
+		Find(&feedFormulaDistributeLogList).Error; err != nil {
 		if !errors.Is(err, gorm.ErrRecordNotFound) {
 			zaplog.Error("UpdateFeedFormalVersion-feedFormulaDistributeLog", zap.Any("err", err))
 		}
@@ -1083,11 +1083,20 @@ func (s *StoreEntry) UpdatePastureFeedDetailVersionLog(ctx context.Context, dist
 		feedTemplateId = req.PastureDataId
 	}
 
+	list := make([]*operationPb.AddFeedFormulaDetail, 0)
+	if err = s.DB.Model(new(model.FeedFormulaDetail)).Where("feed_formula_id = ?", req.Id).Find(&list).Error; err != nil {
+		zaplog.Error("UpdatePastureFeedDetailVersionLog-getFeedFormulaDetail",
+			zap.Any("err", err),
+			zap.Any("feed_formula_id", req.Id))
+		return
+	}
+
 	response := &model.FeedFormulaUpdateVersionResponse{}
 	body := &model.FeedFormulaUpdateVersionRequest{
 		FeedTemplateId: feedTemplateId,
 		Version:        req.Version,
 		Belong:         belong,
+		Data:           make([]*operationPb.AddFeedFormulaDetail, 0),
 	}
 
 	zaplog.Info("UpdateFeedFormalVersion", zap.Any("body", body))

+ 4 - 4
proto/go/backend/operation/pasture.pb.go

@@ -1228,7 +1228,7 @@ type AddForageRequest struct {
 	Name               string              `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`                                                                                       // 饲料名称
 	CategoryId         int32               `protobuf:"varint,3,opt,name=category_id,json=categoryId,proto3" json:"category_id,omitempty"`                                                        // 饲料分类id
 	CategoryName       string              `protobuf:"bytes,4,opt,name=category_name,json=categoryName,proto3" json:"category_name,omitempty"`                                                   // 饲料分类名称
-	MaterialTypeKey    string              `protobuf:"bytes,5,opt,name=material_type_key,json=materialTypeKey,proto3" json:"material_type_key,omitempty"`                                        // 物料类型key
+	MaterialTypeKey    int32               `protobuf:"varint,5,opt,name=material_type_key,json=materialTypeKey,proto3" json:"material_type_key,omitempty"`                                       // 物料类型key
 	MaterialTypeName   string              `protobuf:"bytes,6,opt,name=material_type_name,json=materialTypeName,proto3" json:"material_type_name,omitempty"`                                     // 物料类型名称
 	UniqueEncode       string              `protobuf:"bytes,7,opt,name=unique_encode,json=uniqueEncode,proto3" json:"unique_encode,omitempty"`                                                   // 唯一编码
 	ForageSourceId     ForageSource_Kind   `protobuf:"varint,8,opt,name=forage_source_id,json=forageSourceId,proto3,enum=backend.operation.ForageSource_Kind" json:"forage_source_id,omitempty"` // 饲料来源id
@@ -1312,11 +1312,11 @@ func (x *AddForageRequest) GetCategoryName() string {
 	return ""
 }
 
-func (x *AddForageRequest) GetMaterialTypeKey() string {
+func (x *AddForageRequest) GetMaterialTypeKey() int32 {
 	if x != nil {
 		return x.MaterialTypeKey
 	}
-	return ""
+	return 0
 }
 
 func (x *AddForageRequest) GetMaterialTypeName() string {
@@ -3032,7 +3032,7 @@ var file_backend_operation_pasture_proto_rawDesc = []byte{
 	0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x61, 0x74, 0x65,
 	0x67, 0x6f, 0x72, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x6d, 0x61, 0x74, 0x65,
 	0x72, 0x69, 0x61, 0x6c, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20,
-	0x01, 0x28, 0x09, 0x52, 0x0f, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70,
+	0x01, 0x28, 0x05, 0x52, 0x0f, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70,
 	0x65, 0x4b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x12, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c,
 	0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x10, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x61,