From d1cb09e7a23e7221b6c090ad33e4481a5b79f615 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 29 十一月 2023 17:44:29 +0800
Subject: [PATCH] 出入库报表搜索增加几个字段
---
service/input_history_search.go | 14 +++++++++++++-
controllers/operation.go | 4 +++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/controllers/operation.go b/controllers/operation.go
index 4cb2ab8..f42fe69 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -733,6 +733,7 @@
func AddMoveHistory(operationList []*models.Operation, db *gorm.DB) error {
var histories []*models.MoveHistory
+ operationMap := make(map[string]*models.Operation, len(operationList))
for _, operation := range operationList {
for _, v := range operation.Details {
history := &models.MoveHistory{
@@ -753,12 +754,13 @@
}
histories = append(histories, history)
}
+ operationMap[operation.Number] = operation
}
if err := db.Model(&models.MoveHistory{}).Create(&histories).Error; err != nil {
return err
}
for _, history := range histories {
- service.AddNewHistoryReportRecord(history)
+ service.AddNewHistoryReportRecord(history, operationMap[history.Number])
}
return nil
}
diff --git a/service/input_history_search.go b/service/input_history_search.go
index 12cd9bb..ac6f575 100644
--- a/service/input_history_search.go
+++ b/service/input_history_search.go
@@ -20,6 +20,11 @@
OperationTypeName string `json:"operationTypeName,omitempty"` //涓氬姟鍚嶇О
FromLocation string `json:"fromLocation,omitempty"` //婧愪綅缃悕绉�
ToLocation string `json:"toLocation,omitempty"` //鐩爣浣嶇疆鍚嶇О
+ Date string `json:"date,omitempty"` //鏃ユ湡
+ Company string `json:"company,omitempty"` // 渚涘簲鍟�/瀹㈡埛
+ Carrier string `json:"carrier,omitempty"` //鎵胯繍鍟嗗悕绉�
+ WaybillNumber string `json:"waybillNumber"` //杩愬崟鍙�
+ ReceiverName string `json:"receiverName"` //鏀惰揣浜�
}
const (
@@ -76,13 +81,20 @@
return
}
-func AddNewHistoryReportRecord(record *models.MoveHistory) {
+func AddNewHistoryReportRecord(record *models.MoveHistory, operation *models.Operation) {
var report HistoryReport
err := structx.AssignTo(record, &report)
if err != nil {
logx.Errorf("AddNewHistoryReportRecord AssignTo err:%v", err)
return
}
+
+ report.Date = record.UpdatedAt.Format("2006-01-02")
+ report.Carrier = operation.LogisticCompany.Name
+ report.Company = operation.CompanyName
+ report.WaybillNumber = operation.WaybillNumber
+ report.ReceiverName = operation.ReceiverName
+
err = blevex.Add(HistoryReportIndexName, strconv.Itoa(record.Id), report)
if err != nil {
logx.Errorf("AddNewHistoryReportRecord bleve add err:%v", err)
--
Gitblit v1.8.0