From b68f799ee5562864642cf925ab58391cd5544825 Mon Sep 17 00:00:00 2001 From: yinbentan <yinbentan@live.com> Date: 星期六, 06 七月 2024 17:41:59 +0800 Subject: [PATCH] 出入库明细筛选添加仓库关联,防止脏数据污染 --- request/report_forms_request.go | 1 + service/history_forms.go | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/request/report_forms_request.go b/request/report_forms_request.go index b7eba03..b140319 100644 --- a/request/report_forms_request.go +++ b/request/report_forms_request.go @@ -16,6 +16,7 @@ Unit string `json:"unit"` //鍗曚綅 KeyWord string `json:"keyWord"` //鎼滅储鏉′欢 BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` //鍩虹浣滀笟绫诲瀷 + WarehouseCode string `json:"warehouseCode"` } type GetLocationForms struct { diff --git a/service/history_forms.go b/service/history_forms.go index afed856..e29b868 100644 --- a/service/history_forms.go +++ b/service/history_forms.go @@ -62,7 +62,8 @@ func (slf *HistoryFormsService) BuildSearch(params request.GetInventoryHistory) (search *models.MoveHistorySearch, err error) { search = models.NewMoveHistorySearch() var ( - ids []int + ids []int + locationIds []int ) if params.KeyWord != "" { ids, _, err = SearchHistoryReport(params.KeyWord, params.BaseOperationType, params.Page, params.PageSize) @@ -83,6 +84,20 @@ if params.BaseOperationType != 0 { search.Orm = search.Orm.Where("base_operation_type = ?", params.BaseOperationType) } + + locationSearch := models.NewLocationSearch() + if params.WarehouseCode != "" { + locationSearch.SetJointName(params.WarehouseCode) + } + locations, err := locationSearch.FindNotTotal() + if err != nil { + return nil, err + } + for _, location := range locations { + locationIds = append(locationIds, location.Id) + } + search.Orm = search.Orm.Where("from_location_id in ? or to_location_id in ?", ids, ids) + return search, err } -- Gitblit v1.8.0