From fda60dd56911c03330eb7330ebabd5d46e9d7622 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期五, 15 十二月 2023 16:14:03 +0800 Subject: [PATCH] 库存盘点列表bug --- controllers/product_controller.go | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 40 insertions(+), 6 deletions(-) diff --git a/controllers/product_controller.go b/controllers/product_controller.go index 054b4ca..449e97b 100644 --- a/controllers/product_controller.go +++ b/controllers/product_controller.go @@ -14,6 +14,7 @@ "wms/extend/util" "wms/models" "wms/pkg/logx" + "wms/pkg/mysqlx" "wms/request" ) @@ -214,6 +215,22 @@ return } + //鏇存柊鍦ㄥ簱鐨勪骇鍝佺被鍨� + if params.CategoryId > 0 { + find, _ := models.NewLocationProductAmountSearch().SetProductId(params.ID).Find() + if len(find) > 0 { + var ids []int + for _, f := range find { + if f.ProductCategoryID != params.CategoryId { + ids = append(ids, f.Id) + } + } + m := make(map[string]interface{}) + m["productCategoryId"] = params.CategoryId + _ = models.NewLocationProductAmountSearch().SetIds(ids).UpdateByMap(m) + } + } + materialAttachmentList := []*models.MaterialAttachment{} for _, v := range params.AttachmentIDs { ma := &models.MaterialAttachment{MaterialID: params.ID, AttachmentID: v} @@ -318,7 +335,7 @@ return } - first, err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).First() + first, err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).First() if err != nil { util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") return @@ -343,7 +360,7 @@ util.ResponseFormat(c, code.RequestParamError, "浜у搧绫诲瀷鍚嶇О涓嶈兘涓虹┖") return } - err := models.NewProductCategorySearch().SetID(params.ID).Save(¶ms) + err := models.NewProductCategorySearch().SetID(params.Id).Save(¶ms) if err != nil { util.ResponseFormat(c, code.RequestParamError, "浜у搧绫诲瀷淇℃伅鏇存柊澶辫触") return @@ -364,7 +381,7 @@ util.ResponseFormat(c, code.RequestParamError, "鏃犳晥id") return } - err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).Delete() + err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).Delete() if err != nil { util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎澶辫触") return @@ -431,12 +448,28 @@ util.ResponseFormat(c, code.RequestParamError, "璇疯緭鍏ユ簮鍗曟嵁") return } + if params.Number == "" { + util.ResponseFormat(c, code.RequestParamError, "璇疯緭鍏ュ崟鍙�") + return + } + + var numberNum int64 + if err := mysqlx.GetDB().Model(&models.Operation{}).Where("number=?", params.Number).Count(&numberNum).Error; err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + if numberNum > 0 { + util.ResponseFormat(c, code.RequestParamError, "鍗曞彿宸插瓨鍦�") + return + } + detail := &models.OperationDetails{ ProductId: params.ProductId, Amount: params.Amount, } operation := models.Operation{ - Number: strconv.FormatInt(time.Now().Unix(), 10), + //Number: strconv.FormatInt(time.Now().Unix(), 10), + Number: params.Number, SourceNumber: params.SourceNumber, OperationTypeId: 0, Status: constvar.OperationStatus_Ready, @@ -472,7 +505,7 @@ return } - db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id").Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeDisuse) + db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount,wms_operation.base_operation_type").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id").Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeDisuse) if params.Number != "" { db = db.Where("wms_operation.number like ? or wms_operation.source_number like ? or material.name like ?", fmt.Sprintf("%%%v%%", params.Number), fmt.Sprintf("%%%v%%", params.Number), fmt.Sprintf("%%%v%%", params.Number)) @@ -528,7 +561,7 @@ return } if err := models.WithTransaction(func(tx *gorm.DB) error { - if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Update(&models.Operation{Status: constvar.OperationStatus_Finish}); err != nil { + if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Update(&models.Operation{Status: constvar.OperationStatus_Finish, AuditDate: time.Now().Format("2006-01-02 15:04:05")}); err != nil { return err } var listProdtId []string @@ -729,6 +762,7 @@ return } operation.Status = constvar.OperationStatus_Cancel + operation.AuditDate = time.Now().Format("2006-01-02 15:04:05") if err := models.NewOperationSearch().SetID(operation.Id).Save(operation); err != nil { util.ResponseFormat(c, code.SaveFail, err.Error()) return -- Gitblit v1.8.0