From 16e06252079d36be7686a3d006c8b73565973c68 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 18 十二月 2023 21:04:08 +0800
Subject: [PATCH] 全文搜索支持时间查询
---
controllers/operation.go | 69 ++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/controllers/operation.go b/controllers/operation.go
index 238b057..e75abc4 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -24,9 +24,12 @@
"wms/opa"
"wms/pkg/logx"
"wms/pkg/structx"
+ "wms/proto/client"
"wms/proto/product_inventory"
"wms/proto/purchase_wms"
+ "wms/proto/supplier"
"wms/request"
+ "wms/service"
"wms/utils/http"
"wms/utils/upload"
)
@@ -167,6 +170,30 @@
}
return nil
+}
+
+// GetOperationInfo
+// @Tags 鍏ュ簱/鍑哄簱
+// @Summary 鍏ュ簱/鍑哄簱鍒楄〃
+// @Produce application/json
+//
+// @Param id path string true "id"
+//
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/operation/getOperationInfo/{id} [get]
+func (slf OperationController) GetOperationInfo(c *gin.Context) {
+ number := c.Param("id")
+ if number == "" {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屽弬鏁颁笉鑳戒负绌�")
+ return
+ }
+ id, _ := strconv.Atoi(number)
+ operation, err := models.NewOperationSearch().SetID(id).SetPreload(true).First()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
+ util.ResponseFormat(c, code.Success, operation)
}
// List
@@ -706,6 +733,7 @@
func AddMoveHistory(operationList []*models.Operation, db *gorm.DB) error {
var histories []*models.MoveHistory
+ operationMap := make(map[int]*models.Operation, len(operationList))
for _, operation := range operationList {
for _, v := range operation.Details {
history := &models.MoveHistory{
@@ -714,6 +742,7 @@
OperationTypeId: operation.OperationTypeId,
OperationTypeName: operation.OperationTypeName,
OperationId: operation.Id,
+ ProductId: v.ProductId,
ProductName: v.Product.Name,
Amount: v.Amount,
Unit: v.Product.Unit,
@@ -725,9 +754,13 @@
}
histories = append(histories, history)
}
+ operationMap[operation.Id] = operation
}
if err := db.Model(&models.MoveHistory{}).Create(&histories).Error; err != nil {
return err
+ }
+ for _, history := range histories {
+ service.AddNewHistoryReportRecord(history, operationMap[history.OperationId])
}
return nil
}
@@ -1065,3 +1098,39 @@
return fileUrl, nil
}
+
+// GetSupplierList
+// @Tags 鍏ュ簱/鍑哄簱
+// @Summary 鑾峰彇鐗╂祦鍏徃鍒楄〃
+// @Produce application/json
+//
+// @Success 200 {object} util.Response "鎴愬姛"
+//
+// @Router /api-wms/v1/operation/getSupplierList [get]
+func (slf OperationController) GetSupplierList(c *gin.Context) {
+ cli := supplier.NewSupplierServiceClient(supplier.SupplierConn)
+ resp, err := cli.GetSupplierList(c, &supplier.SupplierListRequest{Status: 1})
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "grpc璋冪敤澶辫触:"+err.Error())
+ return
+ }
+ util.ResponseFormat(c, code.Success, resp.List)
+}
+
+// GetClientList
+// @Tags 鍏ュ簱/鍑哄簱
+// @Summary 鑾峰彇鐗╂祦鍏徃鍒楄〃
+// @Produce application/json
+//
+// @Success 200 {object} util.Response "鎴愬姛"
+//
+// @Router /api-wms/v1/operation/getClientList [get]
+func (slf OperationController) GetClientList(c *gin.Context) {
+ cli := client.NewClientServiceClient(client.ClientConn)
+ resp, err := cli.GetClientList(c, &client.ClientListRequest{})
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "grpc璋冪敤澶辫触:"+err.Error())
+ return
+ }
+ util.ResponseFormat(c, code.Success, resp.List)
+}
--
Gitblit v1.8.0