controllers/operation.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
controllers/product_controller.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
models/move_history.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
models/operation.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
request/operation.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
controllers/operation.go
@@ -14,6 +14,7 @@ "os" "sort" "strconv" "strings" "time" "wms/conf" "wms/constvar" @@ -337,7 +338,10 @@ } 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 } @@ -404,7 +408,6 @@ // return err //} //TODO:出入库的finish和报废的finish都要增加对location_product_amount表数量的更新,因为此表有ProductCategory字段,所以operation_details表中要增加ProductCategoryId字段 locAmount, err := models.NewLocationProductAmountSearch(). SetProductId(v.ID). SetLocationId(locationRule.LocationId). @@ -454,7 +457,6 @@ // return err //} //TODO:出入库的finish和报废的finish都要增加对location_product_amount表数量的更新,因为此表有ProductCategory字段,所以operation_details表中要增加ProductCategoryId字段 locAmount, err := models.NewLocationProductAmountSearch(). SetProductId(v.ID). SetLocationId(locationRule.LocationId). @@ -471,7 +473,6 @@ return res.Error } } else { //TODO:出入库的finish和报废的finish都要增加对location_product_amount表数量的更新,因为此表有ProductCategory字段,所以operation_details表中要增加ProductCategoryId字段 locAmount, err := models.NewLocationProductAmountSearch(). SetProductId(v.ID). SetLocationId(operation.ToLocationID). @@ -703,6 +704,34 @@ 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 @@ -824,6 +853,7 @@ 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 @@ -960,6 +990,7 @@ } 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()) @@ -988,11 +1019,15 @@ }, }) 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) controllers/product_controller.go
@@ -544,7 +544,7 @@ return } 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 } var listProdtId []string @@ -745,6 +745,7 @@ 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 models/move_history.go
@@ -2,7 +2,7 @@ import ( "fmt" "google.golang.org/genproto/googleapis/type/decimal" "github.com/shopspring/decimal" "gorm.io/gorm" "wms/constvar" "wms/pkg/mysqlx" @@ -22,7 +22,7 @@ ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称 Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"` //数量 Unit string `json:"unit" gorm:"type:char(10);not null;comment:单位"` //单位 Weight string `json:"weight" gorm:"type:decimal(20,2);not null;comment:重量"` //重量 Weight decimal.Decimal `json:"weight" gorm:"type:decimal(20,2);not null;comment:重量"` //重量 FromLocationId int `json:"fromLocationId" gorm:"type:int;not null;comment:源位置id"` //源位置id FromLocation string `json:"fromLocation" gorm:"type:varchar(255);not null;comment:源位置"` //源位置 ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:目标位置id"` //目标位置id models/operation.go
@@ -36,6 +36,11 @@ Details []*OperationDetails `json:"details" gorm:"foreignKey:OperationID;references:Id"` BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型 AuditDate string `json:"auditDate" gorm:"type:varchar(31);comment:审批时间"` ReceiverName string `json:"receiverName" gorm:"type:varchar(31);comment:收货人姓名"` ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:联系电话"` ReceiverAddr string `json:"receiverAddr" gorm:"type:varchar(255);comment:收货地址"` } OperationSearch struct { request/operation.go
@@ -25,6 +25,9 @@ WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:运单号"` //运单号 Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:重量" json:"weight"` //重量 LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:物流重量" json:"logisticWeight"` //物流重量 ReceiverName string `json:"receiverName" gorm:"type:varchar(31);comment:收货人姓名"` ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:联系电话"` ReceiverAddr string `json:"receiverAddr" gorm:"type:varchar(255);comment:收货地址"` } type OperationDetails struct { @@ -64,6 +67,9 @@ WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:运单号"` //运单号 Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:重量" json:"weight"` //重量 LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:物流重量" json:"logisticWeight"` //物流重量 ReceiverName string `json:"receiverName" gorm:"type:varchar(31);comment:收货人姓名"` ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:联系电话"` ReceiverAddr string `json:"receiverAddr" gorm:"type:varchar(255);comment:收货地址"` } type OperationAllList struct {