| | |
| | | if location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeVendor)).First(); err != nil { |
| | | return err |
| | | } else { |
| | | params.FromLocationId = location.Id |
| | | params.FromLocationID = location.Id |
| | | } |
| | | if params.ToLocationId == 0 { |
| | | if params.ToLocationID == 0 { |
| | | return errors.New("请选择目标位置") |
| | | } |
| | | } |
| | |
| | | if location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeCustomer)).First(); err != nil { |
| | | return err |
| | | } else { |
| | | params.ToLocationId = location.Id |
| | | params.ToLocationID = location.Id |
| | | } |
| | | if params.FromLocationId == 0 { |
| | | if params.FromLocationID == 0 { |
| | | return errors.New("请选择源位置") |
| | | } |
| | | } |
| | | if operationType.BaseOperationType == constvar.BaseOperationTypeInternal { |
| | | if params.ToLocationId == 0 { |
| | | if params.ToLocationID == 0 { |
| | | return errors.New("请选择目标位置") |
| | | } |
| | | if params.FromLocationId == 0 { |
| | | if params.FromLocationID == 0 { |
| | | return errors.New("请选择源位置") |
| | | } |
| | | } |
| | |
| | | if v.ProductName == "" { |
| | | return errors.New("产品名称异常") |
| | | } |
| | | if v.Quantity.IsNegative() { |
| | | if v.Amount.IsNegative() { |
| | | return errors.New("产品数量出错") |
| | | } |
| | | } |
| | |
| | | // @Param object body request.UpdateOperation true "入库信息" |
| | | // @Param id path int true "入库信息id" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/operation/{id} [post] |
| | | // @Router /api-wms/v1/operation/operation/{id} [put] |
| | | func (slf OperationController) Update(c *gin.Context) { |
| | | id := cast.ToUint(c.Param("id")) |
| | | if id == 0 { |
| | |
| | | } |
| | | for _, v := range listDetails { |
| | | listProdtId = append(listProdtId, v.ProductId) |
| | | mapProdt[v.ProductId] = v.Quantity |
| | | mapProdt[v.ProductId] = v.Amount |
| | | } |
| | | if err := models.NewMaterialSearch().Orm.Where("id IN ?", listProdtId).Find(&listProdt).Error; err != nil { |
| | | return err |
| | |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/operation/{id}": { |
| | | "post": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "models.Location": { |
| | | "type": "object", |
| | | "properties": { |
| | | "company": { |
| | | "description": "公司", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Company" |
| | | } |
| | | ] |
| | | }, |
| | | "companyId": { |
| | | "description": "公司id", |
| | | "type": "integer" |
| | |
| | | "type": "boolean" |
| | | }, |
| | | "type": { |
| | | "description": "位置类型", |
| | | "description": "Company Company ` + "`" + `json:\"company\" gorm:\"foreignKey:CompanyId\"` + "`" + ` //公司", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.LocationType" |
| | |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/operation/{id}": { |
| | | "post": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "models.Location": { |
| | | "type": "object", |
| | | "properties": { |
| | | "company": { |
| | | "description": "公司", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Company" |
| | | } |
| | | ] |
| | | }, |
| | | "companyId": { |
| | | "description": "公司id", |
| | | "type": "integer" |
| | |
| | | "type": "boolean" |
| | | }, |
| | | "type": { |
| | | "description": "位置类型", |
| | | "description": "Company Company `json:\"company\" gorm:\"foreignKey:CompanyId\"` //公司", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.LocationType" |
| | |
| | | type: object |
| | | models.Location: |
| | | properties: |
| | | company: |
| | | allOf: |
| | | - $ref: '#/definitions/models.Company' |
| | | description: 公司 |
| | | companyId: |
| | | description: 公司id |
| | | type: integer |
| | |
| | | type: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.LocationType' |
| | | description: 位置类型 |
| | | description: Company Company `json:"company" |
| | | gorm:"foreignKey:CompanyId"` //公司 |
| | | updateTime: |
| | | type: string |
| | | type: object |
| | |
| | | summary: 删除入库/出库信息 |
| | | tags: |
| | | - 入库/出库 |
| | | post: |
| | | put: |
| | | parameters: |
| | | - description: 入库信息 |
| | | in: body |
| | |
| | | // Location 位置 |
| | | Location struct { |
| | | WmsModel |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:位置名称"` //位置名称 |
| | | ParentId string `json:"parentId" gorm:"type:varchar(255)"` //上级id |
| | | CompanyId int `json:"companyId" gorm:"type:int"` //公司id |
| | | Company Company `json:"company" gorm:"foreignKey:CompanyId"` //公司 |
| | | Type constvar.LocationType `json:"type" gorm:"type:int(11);comment:位置类型"` //位置类型 |
| | | CountFrequency int `json:"countFrequency" gorm:"type:tinyint;comment:盘点频率(天)"` //盘点频率(天) |
| | | IsScrapLocation bool `json:"isScrapLocation" gorm:"type:tinyint;comment:是否报废位置"` //是否报废位置 |
| | | IsReturnLocation bool `json:"isReturnLocation" gorm:"type:tinyint;comment:是否退货位置"` //是否退货位置 |
| | | ReplenishLocation bool `json:"replenishLocation" gorm:"type:tinyint;comment:是否补充位置"` //是否补充位置 |
| | | ForceRemovalStrategy constvar.ForceRemovalStrategy `json:"forceRemovalStrategy" gorm:"type:tinyint;comment:下架策略"` //下架策略 |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:位置名称"` //位置名称 |
| | | ParentId string `json:"parentId" gorm:"type:varchar(255)"` //上级id |
| | | CompanyId int `json:"companyId" gorm:"type:int"` //公司id |
| | | //Company Company `json:"company" gorm:"foreignKey:CompanyId"` //公司 |
| | | Type constvar.LocationType `json:"type" gorm:"type:int(11);comment:位置类型"` //位置类型 |
| | | CountFrequency int `json:"countFrequency" gorm:"type:tinyint;comment:盘点频率(天)"` //盘点频率(天) |
| | | IsScrapLocation bool `json:"isScrapLocation" gorm:"type:tinyint;comment:是否报废位置"` //是否报废位置 |
| | | IsReturnLocation bool `json:"isReturnLocation" gorm:"type:tinyint;comment:是否退货位置"` //是否退货位置 |
| | | ReplenishLocation bool `json:"replenishLocation" gorm:"type:tinyint;comment:是否补充位置"` //是否补充位置 |
| | | ForceRemovalStrategy constvar.ForceRemovalStrategy `json:"forceRemovalStrategy" gorm:"type:tinyint;comment:下架策略"` //下架策略 |
| | | } |
| | | |
| | | LocationSearch struct { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) SetID(id int) *LocationSearch { |
| | | slf.Id = id |
| | | func (slf *LocationSearch) SetID(ID int) *LocationSearch { |
| | | slf.Id = ID |
| | | return slf |
| | | } |
| | | func (slf *LocationSearch) SetParents(ids []string) *LocationSearch { |
| | |
| | | func (slf *LocationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | |
| | | Operation struct { |
| | | WmsModel |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Number string `json:"number" gorm:"type:varchar(255)"` //单号 |
| | | SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //源单号 |
| | | OperationTypeId int `json:"operationTypeId" gorm:"type:int;not null;comment:作业类型id"` //作业类型id |
| | | Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:状态"` //状态 |
| | | FromLocationId int `json:"fromLocationId" gorm:"type:int;not null;comment:源位置id"` //源位置id |
| | | FromLocation Location `json:"fromLocation" gorm:"foreignKey:FromLocationId"` //源位置 |
| | | ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:目标位置id"` //目标位置id |
| | | ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationId"` //目标位置 |
| | | Number string `json:"number" gorm:"type:varchar(255)"` //单号 |
| | | SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //源单号 |
| | | OperationTypeId int `json:"operationTypeId" gorm:"type:int;not null;comment:作业类型id"` //作业类型id |
| | | Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:状态"` //状态 |
| | | FromLocationID int `json:"fromLocationId" gorm:"type:int;not null;comment:源位置id"` //源位置id |
| | | FromLocation Location `json:"fromLocation" gorm:"foreignKey:FromLocationID;references:Id"` //源位置 |
| | | ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:目标位置id"` //目标位置id |
| | | ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //目标位置 |
| | | OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:安排日期"` |
| | | ContacterID int `json:"contacterID" gorm:"type:int;comment:联系人ID"` |
| | | ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:联系人姓名"` |
| | |
| | | CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:公司名称-客户"` |
| | | Comment string `json:"comment" gorm:"type:text;comment:备注"` |
| | | |
| | | Details []*OperationDetails `json:"details"` |
| | | Details []*OperationDetails `json:"details" gorm:"foreignKey:OperationID;references:Id"` |
| | | |
| | | //Weight decimal.Decimal `json:"weight" gorm:"type:decimal(20,2);comment:重量(kg)"` |
| | | //TransferWeight decimal.Decimal `json:"transferWeight" gorm:"type:decimal(20,2);comment:物流重量(kg)"` |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) SetID(id int) *OperationSearch { |
| | | slf.Id = id |
| | | func (slf *OperationSearch) SetID(ID int) *OperationSearch { |
| | | slf.Id = ID |
| | | return slf |
| | | } |
| | | |
| | |
| | | func (slf *OperationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Operation{}) |
| | | |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | } |
| | | if slf.Order != "" { |
| | | db = db.Order(slf.Order) |
| | |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Model(&Operation{}).Preload("Details") |
| | | db = db.Model(&Operation{}).Preload("Details").Preload("FromLocation").Preload("ToLocation") |
| | | } |
| | | |
| | | return db |
| | |
| | | // OperationDetails 操作明细表 |
| | | OperationDetails struct { |
| | | WmsModel |
| | | |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | OperationId int `json:"OperationId" gorm:"type:int;not null;comment:操作记录id"` //操作id |
| | | OperationID int `json:"operationId" gorm:"type:int;not null;comment:操作记录id"` //操作id |
| | | ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"` //产品id |
| | | ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称 |
| | | Quantity decimal.Decimal `json:"quantity" gorm:"type:decimal(20,2);not null;comment:数量"` //数量 |
| | | Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"` //数量 |
| | | Unit string `json:"unit" gorm:"type:varchar(31);comment:单位"` |
| | | } |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) SetID(id uint) *OperationDetailsSearch { |
| | | slf.ID = id |
| | | func (slf *OperationDetailsSearch) SetID(ID int) *OperationDetailsSearch { |
| | | slf.Id = ID |
| | | return slf |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) SetOperationId(operationId int) *OperationDetailsSearch { |
| | | slf.OperationId = operationId |
| | | slf.OperationID = operationId |
| | | return slf |
| | | } |
| | | |
| | |
| | | db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) |
| | | } |
| | | |
| | | if slf.OperationId != 0 { |
| | | db = db.Where("operation_id = ?", slf.OperationId) |
| | | if slf.OperationID != 0 { |
| | | db = db.Where("operation_id = ?", slf.OperationID) |
| | | } |
| | | |
| | | return db |
| | |
| | | ) |
| | | |
| | | type AddOperation struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ID int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255)"` //单号 |
| | | SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //源单号 |
| | | OperationTypeId int `json:"operationTypeId" gorm:"type:int;not null;comment:作业类型id"` //作业类型id |
| | |
| | | } |
| | | |
| | | type UpdateOperation struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ID int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255)"` //单号 |
| | | SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //源单号 |
| | | OperationTypeId int `json:"operationTypeId" gorm:"type:int;not null;comment:作业类型id"` //作业类型id |
| | |
| | | { |
| | | operationAPI.GET("operation", operationController.List) |
| | | operationAPI.POST("operation", operationController.Add) |
| | | operationAPI.POST("operation/:id", operationController.Update) |
| | | operationAPI.PUT("operation/:id", operationController.Update) |
| | | operationAPI.DELETE("operation/:id", operationController.Delete) |
| | | operationAPI.PUT("Finish/:id", operationController.Finish) |
| | | } |