controllers/report_forms_controller.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
docs/docs.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
docs/swagger.json | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
docs/swagger.yaml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
models/location_product_amount.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
response/report_forms_response.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
controllers/report_forms_controller.go
@@ -163,42 +163,55 @@ } //获取操作详情 detailsSearch := models.NewOperationDetailsSearch() if params.PageInfo.Check() { detailsSearch.SetPage(params.Page, params.PageSize) var ( result []*response.InventoryHistory total int64 ) detailsSearch.Orm = detailsSearch.Orm.Model(&models.OperationDetails{}). Select("wms_operation.number, wms_operation.updated_at as date, material.name as product_name, wms_operation.from_location_id,"+ "wms_operation.to_location_id, wms_operation_details.amount, material.unit, wms_operation.contacter_name as contacted_name,"+ "wms_operation.base_operation_type, material.weight, wms_operation_details.product_id"). Joins("left join wms_operation on wms_operation_details.operation_id = wms_operation.id"). Joins("left join material on wms_operation_details.product_id = material.id"). Where("wms_operation.status = ?", constvar.OperationStatus_Finish).Order("wms_operation.created_at desc") if params.ProduceId != "" { detailsSearch.Orm = detailsSearch.Orm.Where("wms_operation_details.product_id = ?", params.ProduceId) } details, total, err := detailsSearch.SetPreload(true).SetProductId(params.ProduceId).Find() if params.BaseOperationType != 0 { detailsSearch.Orm = detailsSearch.Orm.Where("wms_operation.base_operation_type = ?", params.BaseOperationType) } err := detailsSearch.Orm.Count(&total).Error if err != nil { util.ResponseFormat(c, code.RequestParamError, "查询操作详情失败") util.ResponseFormat(c, code.RequestParamError, "查询total失败") return } var operationIds []int for _, detail := range details { operationIds = append(operationIds, detail.OperationID) if params.Page*params.PageSize > 0 { detailsSearch.Orm = detailsSearch.Orm.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize) } //获取已完成的操作记录 operations, err := models.NewOperationSearch().SetIds(operationIds).SetBaseOperationType(params.BaseOperationType). SetStatus(constvar.OperationStatus_Finish).FindNotTotal() err = detailsSearch.Orm.Find(&result).Error if err != nil { util.ResponseFormat(c, code.RequestParamError, "查询操作记录失败") util.ResponseFormat(c, code.RequestParamError, fmt.Errorf("查询操作明细失败: %v", err)) return } var result []response.InventoryHistory for _, detail := range details { var resp response.InventoryHistory resp.Amount = detail.Amount resp.Unit = detail.Product.Unit resp.ProductName = detail.Product.Name for _, operation := range operations { if detail.OperationID == operation.Id { resp.Number = operation.Number resp.Date = operation.UpdateTime resp.Status = "完成" resp.ContactedName = operation.ContacterName resp.FromLocation = operation.FromLocation.Name resp.ToLocation = operation.ToLocation.Name resp.BaseOperationType = operation.BaseOperationType result = append(result, resp) break var locationIds []int for _, history := range result { locationIds = append(locationIds, history.FromLocationId, history.ToLocationId) } locations, err := models.NewLocationSearch().SetIds(locationIds).FindNotTotal() if err != nil { util.ResponseFormat(c, code.RequestParamError, fmt.Errorf("查询位置失败: %v", err)) return } for _, history := range result { history.Status = "完成" for _, location := range locations { if history.ToLocationId == location.Id { history.ToLocation = location.Name } if history.FromLocationId == location.Id { history.FromLocation = location.Name } } } docs/docs.go
@@ -4519,8 +4519,14 @@ "description": "源位置", "type": "string" }, "fromLocationId": { "type": "integer" }, "number": { "description": "单号", "type": "string" }, "productId": { "type": "string" }, "productName": { @@ -4535,9 +4541,16 @@ "description": "目标位置", "type": "string" }, "toLocationId": { "type": "integer" }, "unit": { "description": "单位", "type": "string" }, "weight": { "description": "重量", "type": "number" } } }, @@ -4639,6 +4652,8 @@ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, LeftDelim: "{{", RightDelim: "}}", } func init() { docs/swagger.json
@@ -4507,8 +4507,14 @@ "description": "源位置", "type": "string" }, "fromLocationId": { "type": "integer" }, "number": { "description": "单号", "type": "string" }, "productId": { "type": "string" }, "productName": { @@ -4523,9 +4529,16 @@ "description": "目标位置", "type": "string" }, "toLocationId": { "type": "integer" }, "unit": { "description": "单位", "type": "string" }, "weight": { "description": "重量", "type": "number" } } }, docs/swagger.yaml
@@ -1490,8 +1490,12 @@ fromLocation: description: 源位置 type: string fromLocationId: type: integer number: description: 单号 type: string productId: type: string productName: description: 产品名称 @@ -1502,9 +1506,14 @@ toLocation: description: 目标位置 type: string toLocationId: type: integer unit: description: 单位 type: string weight: description: 重量 type: number type: object response.LocationForms: properties: models/location_product_amount.go
@@ -17,7 +17,7 @@ LocationId int `json:"locationId" gorm:"type:int;not null;comment:位置id"` //位置id Location Location `json:"location" gorm:"foreignKey:LocationId;references:id"` ProductCategoryID int `json:"productCategoryId" gorm:"type:int;not null;comment:产品种类id"` //产品种类id ProductCategory ProductCategory `json:"productCategory"` ProductCategory ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:ID"` ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"` //产品id Product Material `json:"product" gorm:"foreignKey:ProductId;references:ID"` Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:库存数量"` //库存数量 @@ -124,7 +124,11 @@ } if slf.Keyword != "" { db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) db = db.Joins("left join wms_location on wms_location_product_amount.location_id = wms_location.id"). Joins("left join material on wms_location_product_amount.product_id = material.id"). Joins("left join wms_product_category on wms_location_product_amount.product_category_id = wms_product_category.id"). Where("wms_location.name like ?", "%"+slf.Keyword+"%").Or("material.name like ?", "%"+slf.Keyword+"%"). Or("wms_product_category.name like ?", "%"+slf.Keyword+"%") } if slf.Preload { response/report_forms_response.go
@@ -29,6 +29,10 @@ ContactedName string `json:"contactedName"` //完成者 Status string `json:"status"` //状态 BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` //基础作业类型 Weight decimal.Decimal `json:"weight"` //重量 ProductId string `json:"productId"` FromLocationId int `json:"fromLocationId"` ToLocationId int `json:"toLocationId"` } type LocationForms struct {