From c9b52c35041b3838e4fef7a2052b7d798ec00883 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 14 六月 2024 10:43:19 +0800
Subject: [PATCH] 操作明细查询支持位置和仓库过滤
---
service/history_forms.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/service/history_forms.go b/service/history_forms.go
index 14e212e..afed856 100644
--- a/service/history_forms.go
+++ b/service/history_forms.go
@@ -19,6 +19,7 @@
func (slf *HistoryFormsService) Query(params request.GetInventoryHistory) (result []*response.InventoryHistory, err error) {
search, err := slf.BuildSearch(params)
+ search = search.SetPreload(true)
if err != nil {
return nil, err
}
@@ -27,7 +28,33 @@
search = search.SetPage(params.Page, params.PageSize)
}
result = make([]*response.InventoryHistory, 0, params.PageSize)
- err = search.FindAs(&result)
+ list, err := search.FindNotTotal()
+
+ for _, v := range list {
+ data := &response.InventoryHistory{
+ Number: v.Number,
+ Date: v.UpdatedAt.Format("2006-01-02"),
+ ProductName: v.ProductName,
+ FromLocation: v.FromLocation,
+ ToLocation: v.ToLocation,
+ Amount: v.Amount,
+ AmountMoreUnits: nil,
+ Unit: v.Unit,
+ ContactedName: v.Operator,
+ BaseOperationType: v.BaseOperationType,
+ Weight: v.Weight,
+ ProductId: v.ProductId,
+ FromLocationId: v.FromLocationId,
+ ToLocationId: v.ToLocationId,
+ OperationId: v.OperationId,
+ OperationTypeName: v.OperationTypeName,
+ }
+ moreUnit := v.Product.MoreUnit
+ if moreUnit != nil && *moreUnit {
+ data.AmountMoreUnits = CreateMoreUnit(v.Amount, v.Product.MoreUnitList)
+ }
+ result = append(result, data)
+ }
return result, nil
}
@@ -48,8 +75,8 @@
}
search.Orm = search.Orm.Model(&models.MoveHistory{}).
- Select("number, updated_at as date, product_name as product_name, from_location_id, operation_id,to_location_id, amount, " +
- "unit, operator as contacted_name, base_operation_type, weight, product_id, from_location, to_location, operation_type_name, weight").Order("id desc")
+ Select("number, updated_at, product_name, from_location_id, operation_id,to_location_id, amount, " +
+ "unit, operator, base_operation_type, weight, product_id, from_location, to_location, operation_type_name, weight").Order("id desc")
if len(ids) > 0 {
search.Orm = search.Orm.Where("id in ?", ids)
}
@@ -96,17 +123,27 @@
f := excelize.NewFile()
// 鑷畾涔夎〃澶�
- headers := []string{"鏃ユ湡", "鍗曞彿", "浜у搧", "浜у搧缂栫爜", "涓氬姟绫诲瀷", "浠�", "鑷�", "鏁伴噺", "鍗曚綅", "閲嶉噺"}
+ headers := []interface{}{"鏃ユ湡", "鍗曞彿", "浜у搧", "浜у搧缂栫爜", "涓氬姟绫诲瀷", "浠�", "鑷�", map[string][]string{"鏁伴噺": {"浠�", "鍖�", "绫�", "閲嶉噺"}}, "鍗曚綅", "閲嶉噺"}
// 璁剧疆琛ㄥご
- for i, header := range headers {
- cell := getColumnAlphabet(i) + "1"
- f.SetCellValue("Sheet1", cell, header)
+ if err := SetExcelHeader(headers, f); err != nil {
+ return "", err
}
+ style, err := SetHeaderStyle(f)
+ if err != nil {
+ return "", err
+ }
+
+ lastColumn := getColumnAlphabet(13)
+ f.SetCellStyle("Sheet1", "A1", lastColumn+"2", style)
+ // 璁剧疆鍒楀
+ f.SetColWidth("Sheet1", "A", "G", 30)
+ f.SetColWidth("Sheet1", "H", "K", 15)
+
for i, v := range dataList {
- column := strconv.Itoa(i + 2)
- f.SetCellValue("Sheet1", "A"+column, v.Date.Format("2006-01-02"))
+ column := strconv.Itoa(i + 3)
+ f.SetCellValue("Sheet1", "A"+column, v.Date)
f.SetCellValue("Sheet1", "B"+column, v.Number)
f.SetCellValue("Sheet1", "C"+column, v.ProductName)
f.SetCellValue("Sheet1", "D"+column, v.ProductId)
@@ -114,8 +151,9 @@
f.SetCellValue("Sheet1", "F"+column, v.FromLocation)
f.SetCellValue("Sheet1", "G"+column, v.ToLocation)
f.SetCellValue("Sheet1", "H"+column, v.Amount)
- f.SetCellValue("Sheet1", "I"+column, v.Unit)
- f.SetCellValue("Sheet1", "J"+column, v.Weight)
+ FillMoreUnitToExcel(v.Amount, v.AmountMoreUnits, 7, i+3, f)
+ f.SetCellValue("Sheet1", "L"+column, v.Unit)
+ f.SetCellValue("Sheet1", "M"+column, v.Weight)
}
if params.BaseOperationType == constvar.BaseOperationTypeIncoming {
--
Gitblit v1.8.0