jiangshuai
2023-11-14 76c74cf71fb82099e134cea6a34019655fed2f3f
产品列表增加重订货规则统计
2个文件已修改
16 ■■■■ 已修改文件
controllers/product_controller.go 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/material.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/product_controller.go
@@ -125,8 +125,7 @@
        product.PredictionAmount = product.Amount.Add(reorderAmount.TotalAmount)
        var statisticsList []*request.ProductStatistics
        if err := models.NewOperationSearch().Orm.
            Table("wms_operation").
        if err := models.NewOperationSearch().Orm.Table("wms_operation").
            InnerJoins("INNER JOIN wms_operation_details on wms_operation_details.operation_id=wms_operation.id").
            Select("SUM(wms_operation_details.amount) as total_amount,wms_operation.base_operation_type").
            Where("wms_operation_details.product_id=? and wms_operation.`status`=? and wms_operation.base_operation_type in (?)", product.ID, constvar.OperationStatus_Finish, []constvar.BaseOperationType{constvar.BaseOperationTypeIncoming, constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeDisuse}).
@@ -146,6 +145,16 @@
                product.OutputAmount = product.OutputAmount.Add(v.TotalAmount)
            }
        }
        reorderRules, rulesTotal, err := models.NewReorderRuleSearch().SetProductId(product.ID).Find()
        if err != nil {
            util.ResponseFormat(c, code.RequestParamError, "重订货规则统计失败")
            return
        }
        if rulesTotal == 1 {
            product.MinInventoryRule = reorderRules[0].MinInventory
            product.MaxInventoryRule = reorderRules[0].MaxInventory
        }
        product.ReorderRuleNum = rulesTotal
    }
    util.ResponseFormatList(c, code.Success, products, int(total))
}
models/material.go
@@ -75,6 +75,9 @@
        PredictionAmount        decimal.Decimal `json:"predictionAmount" gorm:"-"`
        InputAmount             decimal.Decimal `json:"inputAmount" gorm:"-"`
        OutputAmount            decimal.Decimal `json:"outputAmount" gorm:"-"`
        MinInventoryRule        decimal.Decimal `json:"minInventoryRule" gorm:"-"` //最小库存
        MaxInventoryRule        decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //最大库存
        ReorderRuleNum          int64           `json:"reorderRuleNum"`
    }
    MaterialSearch struct {