| | |
| | | "os" |
| | | "sort" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | | "wms/conf" |
| | | "wms/constvar" |
| | |
| | | } |
| | | if err := models.WithTransaction(func(tx *gorm.DB) error { |
| | | |
| | | if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Update(&models.Operation{Status: constvar.OperationStatus_Finish}); err != nil { |
| | | if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Update(&models.Operation{Status: constvar.OperationStatus_Finish, AuditDate: time.Now().Format("2006-01-02 15:04:05")}); err != nil { |
| | | return err |
| | | } |
| | | if err := AddMoveHistory([]*models.Operation{operation}, tx); err != nil { |
| | | return err |
| | | } |
| | | |
| | |
| | | // return err |
| | | //} |
| | | |
| | | //TODO:出入库的finish和报废的finish都要增加对location_product_amount表数量的更新,因为此表有ProductCategory字段,所以operation_details表中要增加ProductCategoryId字段 |
| | | locAmount, err := models.NewLocationProductAmountSearch(). |
| | | SetProductId(v.ID). |
| | | SetLocationId(locationRule.LocationId). |
| | |
| | | // return err |
| | | //} |
| | | |
| | | //TODO:出入库的finish和报废的finish都要增加对location_product_amount表数量的更新,因为此表有ProductCategory字段,所以operation_details表中要增加ProductCategoryId字段 |
| | | locAmount, err := models.NewLocationProductAmountSearch(). |
| | | SetProductId(v.ID). |
| | | SetLocationId(locationRule.LocationId). |
| | |
| | | return res.Error |
| | | } |
| | | } else { |
| | | //TODO:出入库的finish和报废的finish都要增加对location_product_amount表数量的更新,因为此表有ProductCategory字段,所以operation_details表中要增加ProductCategoryId字段 |
| | | locAmount, err := models.NewLocationProductAmountSearch(). |
| | | SetProductId(v.ID). |
| | | SetLocationId(operation.ToLocationID). |
| | |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | | |
| | | func AddMoveHistory(operationList []*models.Operation, db *gorm.DB) error { |
| | | var histories []*models.MoveHistory |
| | | for _, operation := range operationList { |
| | | for _, v := range operation.Details { |
| | | history := &models.MoveHistory{ |
| | | Number: operation.Number, |
| | | BaseOperationType: operation.BaseOperationType, |
| | | OperationTypeId: operation.OperationTypeId, |
| | | OperationTypeName: operation.OperationTypeName, |
| | | OperationId: operation.Id, |
| | | ProductName: v.Product.Name, |
| | | Amount: v.Amount, |
| | | Unit: v.Product.Unit, |
| | | Weight: operation.Weight, |
| | | FromLocationId: operation.FromLocationID, |
| | | FromLocation: operation.FromLocation.Name, |
| | | ToLocationId: operation.ToLocationID, |
| | | ToLocation: operation.ToLocation.Name, |
| | | } |
| | | histories = append(histories, history) |
| | | } |
| | | } |
| | | if err := db.Model(&models.MoveHistory{}).Create(&histories).Error; err != nil { |
| | | return err |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | var ( |
| | | ProductInventoryServiceConn *grpc.ClientConn |
| | | PurchaseServiceConn *grpc.ClientConn |
| | |
| | | return |
| | | } |
| | | operation.Status = constvar.OperationStatus_Cancel |
| | | operation.AuditDate = time.Now().Format("2006-01-02 15:04:05") |
| | | if err := models.NewOperationSearch().SetID(operation.Id).Save(operation); err != nil { |
| | | util.ResponseFormat(c, code.SaveFail, err.Error()) |
| | | return |
| | |
| | | } |
| | | |
| | | func ExportOutputOperation(category constvar.FileTemplateCategory, operation *models.Operation) (string, error) { |
| | | repositoryLevels := strings.Split(operation.FromLocation.JointName, "/") |
| | | template, err := models.NewFileTemplateAttachmentSearch().SetPreload(true).SetCategory(category).First() |
| | | if err != nil { |
| | | return "", errors.New("获取模版记录失败:" + err.Error()) |
| | |
| | | }, |
| | | }) |
| | | |
| | | f.SetCellValue("Sheet1", "C2", operation.FromLocation.Name) |
| | | f.SetCellValue("Sheet1", "C2", repositoryLevels[0]) |
| | | f.SetCellValue("Sheet1", "H2", operation.WaybillNumber) |
| | | f.SetCellValue("Sheet1", "K2", operation.AuditDate) |
| | | f.SetCellValue("Sheet1", "H3", operation.SourceNumber) |
| | | f.SetCellValue("Sheet1", "K3", operation.Number) |
| | | f.SetCellValue("Sheet1", "C4", operation.CompanyName) |
| | | f.SetCellValue("Sheet1", "I4", operation.ReceiverAddr) |
| | | f.SetCellValue("Sheet1", "C5", operation.ReceiverName) |
| | | f.SetCellValue("Sheet1", "H5", operation.ReceiverPhone) |
| | | |
| | | rowIndex := 8 |
| | | totalAmount := decimal.NewFromInt(0) |