Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
| | |
| | | for _, detail := range details { |
| | | operationIds = append(operationIds, detail.OperationID) |
| | | } |
| | | //获取操作记录 |
| | | //获取已完成的操作记录 |
| | | operations, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询操作记录失败") |
| | |
| | | var resp response.InventoryHistory |
| | | resp.Amount = detail.Amount |
| | | resp.Unit = params.Unit |
| | | resp.ProductName = params.ProductName |
| | | for _, operation := range operations { |
| | | if detail.OperationID == operation.Id { |
| | | resp.Number = operation.Number |
| | | resp.Date = operation.UpdateTime |
| | | resp.BaseOperationType = operation.BaseOperationType |
| | | resp.Status = "完成" |
| | | resp.ContactedName = operation.ContacterName |
| | | resp.FromLocation = operation.FromLocation.Name |
| | | resp.ToLocation = operation.ToLocation.Name |
| | |
| | | return |
| | | } |
| | | params.LocationId = locationId |
| | | if err := models.NewWarehouseSearch().Create(¶ms); err != nil { |
| | | err = models.WithTransaction(func(tx *gorm.DB) error { |
| | | err := models.NewWarehouseSearch().SetOrm(tx).Create(¶ms) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | //创建三个默认操作类型 |
| | | var types []*models.OperationType |
| | | inType := &models.OperationType{ |
| | | Name: params.Name + "-入库", |
| | | BaseOperationType: constvar.BaseOperationTypeIncoming, |
| | | WarehouseId: params.Id, |
| | | } |
| | | types = append(types, inType) |
| | | outType := &models.OperationType{ |
| | | Name: params.Name + "-出库", |
| | | BaseOperationType: constvar.BaseOperationTypeOutgoing, |
| | | WarehouseId: params.Id, |
| | | } |
| | | types = append(types, outType) |
| | | internalType := &models.OperationType{ |
| | | Name: params.Name + "-内部调拨", |
| | | BaseOperationType: constvar.BaseOperationTypeInternal, |
| | | WarehouseId: params.Id, |
| | | } |
| | | types = append(types, internalType) |
| | | err = models.NewOperationTypeSearch().SetOrm(tx).CreateBatch(types) |
| | | return err |
| | | }) |
| | | if err != nil { |
| | | _ = models.NewLocationSearch().SetID(locationId).Delete() |
| | | logx.Errorf("warehouse create err: %v", err) |
| | | util.ResponseFormat(c, code.SaveFail, "插入失败") |
| | | return |
| | |
| | | return |
| | | } |
| | | |
| | | //删除位置信息 |
| | | first, err := models.NewWarehouseSearch().SetID(id).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "获取仓库信息失败") |
| | | return |
| | | } |
| | | err = models.NewLocationSearch().SetID(first.LocationId).Delete() |
| | | err = models.WithTransaction(func(tx *gorm.DB) error { |
| | | //删除位置信息 |
| | | err = models.NewLocationSearch().SetOrm(tx).SetJointName(first.Code).Delete() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | //删除操作类型 |
| | | err = models.NewOperationTypeSearch().SetOrm(tx).SetWarehouseId(first.Id).Delete() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | //删除仓库 |
| | | err = models.NewWarehouseSearch().SetOrm(tx).SetID(id).Delete() |
| | | return err |
| | | }) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除位置信息失败") |
| | | util.ResponseFormat(c, code.RequestParamError, "删除仓库失败") |
| | | return |
| | | } |
| | | err = models.NewWarehouseSearch().SetID(id).Delete() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除仓库信息失败") |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.UpdateSuccess, "删除成功") |
| | | } |
| | | |
| | |
| | | "description": "数量", |
| | | "type": "number" |
| | | }, |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "contactedName": { |
| | | "description": "完成者", |
| | | "type": "string" |
| | |
| | | }, |
| | | "number": { |
| | | "description": "单号", |
| | | "type": "string" |
| | | }, |
| | | "productName": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | | "type": "string" |
| | | }, |
| | | "toLocation": { |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | "description": "数量", |
| | | "type": "number" |
| | | }, |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "contactedName": { |
| | | "description": "完成者", |
| | | "type": "string" |
| | |
| | | "description": "单号", |
| | | "type": "string" |
| | | }, |
| | | "productName": { |
| | | "description": "产品名称", |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "description": "状态", |
| | | "type": "string" |
| | | }, |
| | | "toLocation": { |
| | | "description": "目标位置", |
| | | "type": "string" |
| | |
| | | amount: |
| | | description: 数量 |
| | | type: number |
| | | baseOperationType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.BaseOperationType' |
| | | description: 基础作业类型 |
| | | contactedName: |
| | | description: 完成者 |
| | | type: string |
| | |
| | | number: |
| | | description: 单号 |
| | | type: string |
| | | productName: |
| | | description: 产品名称 |
| | | type: string |
| | | status: |
| | | description: 状态 |
| | | type: string |
| | | toLocation: |
| | | description: 目标位置 |
| | | type: string |
| | |
| | | // Material 物料 |
| | | Material struct { |
| | | BaseModelString |
| | | Name string `gorm:"unique;type:varchar(191);not null;comment:物料名称" json:"name"` //物料名称 |
| | | Name string `gorm:"type:varchar(191);not null;comment:物料名称" json:"name"` //物料名称 |
| | | //MaterialType constvar.ProductType `gorm:"index;type:int(11);comment:物料类型(数字)" json:"materialType"` |
| | | Model constvar.MaterialMode `gorm:"type:varchar(191);not null;comment:物料类型(字符串)" json:"model"` //物料类型(字符串) |
| | | //Explain string `gorm:"type:varchar(512);comment:编号说明" json:"explain"` |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationTypeSearch) SetWarehouseId(warehouseId int) *OperationTypeSearch { |
| | | slf.WarehouseId = warehouseId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationTypeSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&OperationType{}) |
| | | |
| | |
| | | db = db.Preload("Company").Preload("Warehouse").Preload("DefaultLocationSrc").Preload("DefaultLocationDest") |
| | | } |
| | | |
| | | if slf.WarehouseId > 0 { |
| | | db = db.Where("warehouse_id = ?", slf.WarehouseId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | "wms/constvar" |
| | | ) |
| | | |
| | | type InventoryForms struct { |
| | |
| | | } |
| | | |
| | | type InventoryHistory struct { |
| | | Number string `json:"number"` //单号 |
| | | Date string `json:"date"` //日期 |
| | | FromLocation string `json:"fromLocation"` //源位置 |
| | | ToLocation string `json:"toLocation"` //目标位置 |
| | | Amount decimal.Decimal `json:"amount"` //数量 |
| | | Unit string `json:"unit"` //单位 |
| | | ContactedName string `json:"contactedName"` //完成者 |
| | | BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` //基础作业类型 |
| | | Number string `json:"number"` //单号 |
| | | Date string `json:"date"` //日期 |
| | | ProductName string `json:"productName"` //产品名称 |
| | | FromLocation string `json:"fromLocation"` //源位置 |
| | | ToLocation string `json:"toLocation"` //目标位置 |
| | | Amount decimal.Decimal `json:"amount"` //数量 |
| | | Unit string `json:"unit"` //单位 |
| | | ContactedName string `json:"contactedName"` //完成者 |
| | | Status string `json:"status"` //状态 |
| | | } |
| | | |
| | | type LocationForms struct { |