新增操作类型增加基础操作类型和仓库id来支持库存盘点
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "明细中不能存在重复的产品") |
| | | return |
| | | } |
| | | |
| | | operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First() |
| | | var operationType *models.OperationType |
| | | var err error |
| | | if params.OperationTypeId == 0 { |
| | | operationType, err = models.NewOperationTypeSearch().SetWarehouseId(params.WarehouseId).SetBaseOperationType(params.BaseOperationType).First() |
| | | if err != nil || params.WarehouseId != operationType.WarehouseId { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数缺失") |
| | | return |
| | | } |
| | | } else { |
| | | operationType, err = models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | } |
| | | |
| | | userInfo := middleware.GetUserInfo(c) |
| | | params.CreatedBy = userInfo.Username |
| | | params.Status = constvar.OperationStatus_Ready |
| | | //params.Number = strconv.FormatInt(time.Now().Unix(), 10) |
| | | params.BaseOperationType = operationType.BaseOperationType |
| | | params.WarehouseId = operationType.WarehouseId |
| | | |
| | | var numberNum int64 |
| | | if err := mysqlx.GetDB().Model(&models.Operation{}).Where("number=?", params.Number).Count(&numberNum).Error; err != nil { |
| | |
| | | } |
| | | |
| | | if params.OperationTypeId == 0 && int(params.BaseOperationType) == 0 { |
| | | return errors.New("未识别该记录类型") |
| | | return errors.New("未识别该记录类型1") |
| | | } |
| | | |
| | | if params.BaseOperationType != 0 { |
| | | if params.WarehouseId == 0 { |
| | | return errors.New("未识别该记录类型2") |
| | | } |
| | | } |
| | | |
| | | if params.OperationDate == "" { |
| | |
| | | costMap[material.ID] = material.Cost |
| | | salePriceMap[material.ID] = material.SalePrice |
| | | } |
| | | list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find() |
| | | list, total, err := search.SetOperationTypeId(params.OperationTypeId). |
| | | SetBaseOperationType(params.BaseOperationType). |
| | | SetPreload(true).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error()) |
| | | return |
| | |
| | | if !params.PageInfo.Check() { |
| | | return errors.New("数据分页信息错误") |
| | | } |
| | | if params.OperationTypeId == 0 { |
| | | return errors.New("operationTypeId为0") |
| | | if params.OperationTypeId == 0 && params.BaseOperationType == 0 { |
| | | return errors.New("operationTypeId和baseOperationType不能同时为0") |
| | | } |
| | | return nil |
| | | } |
| | |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouseId": { |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | | "description": "运单号", |
| | | "type": "string" |
| | |
| | | "accountantId": { |
| | | "type": "string" |
| | | }, |
| | | "baseOperationType": { |
| | | "description": "基础作业类型 5库存盘点", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "comment": { |
| | | "description": "备注", |
| | | "type": "string" |
| | |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "warehouseId": { |
| | | "description": "仓库id", |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | |
| | | "request.OperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "baseOperationType": { |
| | | "description": "1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouseId": { |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | | "description": "运单号", |
| | | "type": "string" |
| | |
| | | "accountantId": { |
| | | "type": "string" |
| | | }, |
| | | "baseOperationType": { |
| | | "description": "基础作业类型 5库存盘点", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "comment": { |
| | | "description": "备注", |
| | | "type": "string" |
| | |
| | | }, |
| | | "toLocationId": { |
| | | "description": "目标位置id", |
| | | "type": "integer" |
| | | }, |
| | | "warehouseId": { |
| | | "description": "仓库id", |
| | | "type": "integer" |
| | | }, |
| | | "waybillNumber": { |
| | |
| | | "request.OperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "baseOperationType": { |
| | | "description": "1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | |
| | | type: integer |
| | | updateTime: |
| | | type: string |
| | | warehouseId: |
| | | type: integer |
| | | waybillNumber: |
| | | description: 运单号 |
| | | type: string |
| | |
| | | type: string |
| | | accountantId: |
| | | type: string |
| | | baseOperationType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.BaseOperationType' |
| | | description: 基础作业类型 5库存盘点 |
| | | comment: |
| | | description: 备注 |
| | | type: string |
| | |
| | | description: 状态 |
| | | toLocationId: |
| | | description: 目标位置id |
| | | type: integer |
| | | warehouseId: |
| | | description: 仓库id |
| | | type: integer |
| | | waybillNumber: |
| | | description: 运单号 |
| | |
| | | type: object |
| | | request.OperationList: |
| | | properties: |
| | | baseOperationType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.BaseOperationType' |
| | | description: 1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点 |
| | | number: |
| | | type: string |
| | | operationTypeId: |
| | |
| | | CheckedBy string `json:"checkedBy" gorm:"type:varchar(255);comment:验证者UserId"` |
| | | Remark string `json:"remark"` |
| | | |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` |
| | | IsInternalOutput bool `json:"isInternalOutput"` //是否调拨产生的出库 |
| | | } |
| | | |
| | |
| | | Accountant string `json:"accountant" gorm:"type:varchar(255);comment:会计名称"` |
| | | CustodianId string `json:"custodianId" gorm:"type:varchar(255);comment:保管员id"` |
| | | Custodian string `json:"custodian" gorm:"type:varchar(255);comment:保管员名称"` |
| | | BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型 5库存盘点 |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` //仓库id |
| | | } |
| | | |
| | | type OperationDetails struct { |
| | |
| | | type OperationList struct { |
| | | PageInfo |
| | | OperationTypeId int `json:"operationTypeId" form:"operationTypeId"` |
| | | BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` // 1 入库 2 出库 3 内部调拨 4 报废 5 库存盘点 |
| | | Number string `json:"number"` |
| | | Status constvar.OperationStatus `json:"status"` |
| | | } |