From 230ce554d9a42e5c1e322bf13d186f87651edd96 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 12 一月 2024 10:49:03 +0800
Subject: [PATCH] 物料只查有库存的
---
controllers/location_product_amount.go | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go
index 3f33ff3..36d7c28 100644
--- a/controllers/location_product_amount.go
+++ b/controllers/location_product_amount.go
@@ -12,8 +12,10 @@
"wms/extend/code"
"wms/extend/util"
"wms/models"
+ "wms/pkg/mysqlx"
"wms/request"
"wms/response"
+ "wms/service"
)
type LocationProductAmountController struct {
@@ -60,13 +62,13 @@
if params.Page*params.PageSize > 0 {
search.Orm = search.Orm.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize)
}
- if err := search.Orm.Order("wms_location_product_amount.updated_at desc").Find(&records).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
+ if err := search.Orm.Order("wms_location_product_amount.updated_at desc").Find(&records).Error; err != nil {
util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err))
return
}
var operation models.Operation
for k, v := range records {
- if res := models.NewOperationSearch().Orm.Preload("Details", "product_id=?", v.ProductId).Where("wms_operation.base_operation_type=? and wms_operation.status=? and wms_operation.to_location_id=?", constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready, v.LocationId).First(&operation); res.Error != nil {
+ if res := mysqlx.GetDB().Table("wms_operation").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.base_operation_type=? and wms_operation.status=? and wms_operation.to_location_id=? and wms_operation_details.product_id=?", constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready, v.LocationId, v.ProductId).First(&operation); res.Error != nil {
if errors.Is(res.Error, gorm.ErrRecordNotFound) {
records[k].Status = constvar.OperationStatus_Finish
records[k].BaseOperationType = constvar.BaseOperationTypeAdjust
@@ -174,6 +176,8 @@
}); err != nil {
return err
}
+
+ service.AddNewLocationReportRecord(locAmount.Id)
return nil
}
--
Gitblit v1.8.0