From 6c352b5884f552194f0da7a197efdb6b667cfab8 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期三, 18 十月 2023 19:59:03 +0800 Subject: [PATCH] 位置初始化 --- controllers/report_forms_controller.go | 12 ++++++------ models/db.go | 1 + models/location.go | 24 ++++++++++++++++++++++++ docs/docs.go | 2 ++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/controllers/report_forms_controller.go b/controllers/report_forms_controller.go index d536b4a..85a48da 100644 --- a/controllers/report_forms_controller.go +++ b/controllers/report_forms_controller.go @@ -69,13 +69,13 @@ dbIn := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}). Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id"). Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeIncoming). - Where("wms_operation.status=?", constvar.OperationStatus_Ready) + Where("wms_operation.status in (?)", []int{3, 4}) dbOut := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}). Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id"). Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeOutgoing). - Where("wms_operation.status=?", constvar.OperationStatus_Ready) + Where("wms_operation.status in (?)", []int{3, 4}) if len(locationIds) > 0 { - dbIn.Where("wms_operation.from_location_id in (?)", locationIds) + dbIn.Where("wms_operation.to_location_id in (?)", locationIds) dbOut.Where("wms_operation.from_location_id in (?)", locationIds) } err = dbIn.Find(&inHouse).Error @@ -94,7 +94,6 @@ resp.ProduceId = material.ID resp.ProductName = material.Name resp.Cost = material.Cost - resp.Amount = material.Amount resp.Unit = material.Unit resp.Value = material.Amount.Mul(material.Cost) resp.ProductType = material.CategoryName @@ -108,6 +107,7 @@ resp.Out = resp.Out.Add(details.Amount) } } + resp.Amount = resp.In.Sub(resp.Out) resp.AvailableNumber = resp.Amount result = append(result, resp) } @@ -132,7 +132,7 @@ if params.PageInfo.Check() { detailsSearch.SetPage(params.Page, params.PageSize) } - details, total, err := detailsSearch.SetProductId(params.ProduceId).Find() + details, err := detailsSearch.SetProductId(params.ProduceId).FindNotTotal() if err != nil { util.ResponseFormat(c, code.RequestParamError, "鏌ヨ鎿嶄綔璇︽儏澶辫触") return @@ -142,7 +142,7 @@ operationIds = append(operationIds, detail.OperationID) } //鑾峰彇宸插畬鎴愮殑鎿嶄綔璁板綍 - operations, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).FindNotTotal() + operations, total, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).Find() if err != nil { util.ResponseFormat(c, code.RequestParamError, "鏌ヨ鎿嶄綔璁板綍澶辫触") return diff --git a/docs/docs.go b/docs/docs.go index b1cd031..80291e3 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3734,6 +3734,8 @@ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/models/db.go b/models/db.go index 8f47201..a1570c8 100644 --- a/models/db.go +++ b/models/db.go @@ -98,6 +98,7 @@ func InsertDefaultData() { models := []interface{}{ NewDepartmentSearch(), + NewLocationSearch(), } for _, model := range models { if id, ok := model.(InitDefaultData); ok { diff --git a/models/location.go b/models/location.go index 64676df..15830ea 100644 --- a/models/location.go +++ b/models/location.go @@ -317,3 +317,27 @@ } return records, nil } + +// InitDefaultData 鍒濆鍖栨暟鎹� +func (slf *LocationSearch) InitDefaultData() error { + var ( + db = slf.Orm.Table(slf.TableName()) + total int64 = 0 + ) + if err := db.Count(&total).Error; err != nil { + return err + } + if total != 0 { + return nil + } + locations := make([]*Location, 0) + locations = append(locations, &Location{Name: "渚涘簲鍟嗕綅缃�", Type: 1, JointName: "渚涘簲鍟嗕綅缃�"}) + locations = append(locations, &Location{Name: "瑙嗗浘", Type: 2, JointName: "瑙嗗浘"}) + locations = append(locations, &Location{Name: "瀹㈡埛浣嶇疆", Type: 4, JointName: "瀹㈡埛浣嶇疆"}) + locations = append(locations, &Location{Name: "搴撳瓨鎹熷け", Type: 5, JointName: "搴撳瓨鎹熷け"}) + locations = append(locations, &Location{Name: "鐢熶骇", Type: 6, JointName: "鐢熶骇"}) + locations = append(locations, &Location{Name: "涓浆浣嶇疆", Type: 7, JointName: "涓浆浣嶇疆"}) + locations = append(locations, &Location{Name: "鎶ュ簾浣嶇疆", Type: 8, JointName: "鎶ュ簾浣嶇疆"}) + locations = append(locations, &Location{Name: "搴撳瓨鐩樼偣", Type: 9, JointName: "搴撳瓨鐩樼偣"}) + return slf.CreateBatch(locations) +} -- Gitblit v1.8.0