| | |
| | | return errors.New("请填入源单号") |
| | | } |
| | | |
| | | if params.OperationTypeId == 0 { |
| | | return errors.New("operationTypeId为0") |
| | | if params.OperationTypeId == 0 || int(params.BaseOperationType) == 0 { |
| | | return errors.New("未识别该记录类型") |
| | | } |
| | | |
| | | if params.OperationDate == "" { |
| | |
| | | search.SetPage(params.Page, params.PageSize) |
| | | if params.Number != "" { |
| | | search.SetKeyword(params.Number) |
| | | } |
| | | if int(params.Status) != 0 { |
| | | search.SetStatus(params.Status) |
| | | } |
| | | list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | | |
| | | // ListAll |
| | | // listTransfer |
| | | // @Tags 入库/出库 |
| | | // @Summary 调拨 |
| | | // @Summary 库存调拨列表 |
| | | // @Produce application/json |
| | | // @Param object body request.OperationAllList true "参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/listAll [post] |
| | | func (slf OperationController) ListAll(c *gin.Context) { |
| | | // @Router /api-wms/v1/operation/listTransfer [post] |
| | | func (slf OperationController) ListTransfer(c *gin.Context) { |
| | | var params request.OperationAllList |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+err.Error()) |
| | |
| | | if params.Number != "" { |
| | | search.SetKeyword(params.Number) |
| | | } |
| | | list, total, err := search.SetPreload(true).SetOrder("created_at desc").Find() |
| | | list, total, err := search.SetPreload(true).SetBaseOperationType(constvar.BaseOperationTypeInternal).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error()) |
| | | return |
| | |
| | | return |
| | | } |
| | | |
| | | //db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id") |
| | | |
| | | db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id") |
| | | db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id").Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeDisuse) |
| | | |
| | | if params.Number != "" { |
| | | db = db.Where("wms_operation.number like ? or wms_operation.source_number like ? or material.name like ?", fmt.Sprintf("%%%v%%", params.Number), fmt.Sprintf("%%%v%%", params.Number), fmt.Sprintf("%%%v%%", params.Number)) |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/listAll": { |
| | | "/api-wms/v1/operation/listTransfer": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "tags": [ |
| | | "入库/出库" |
| | | ], |
| | | "summary": "调拨", |
| | | "summary": "库存调拨列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "status": { |
| | | "$ref": "#/definitions/constvar.OperationStatus" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/listAll": { |
| | | "/api-wms/v1/operation/listTransfer": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "tags": [ |
| | | "入库/出库" |
| | | ], |
| | | "summary": "调拨", |
| | | "summary": "库存调拨列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "status": { |
| | | "$ref": "#/definitions/constvar.OperationStatus" |
| | | } |
| | | } |
| | | }, |
| | |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | status: |
| | | $ref: '#/definitions/constvar.OperationStatus' |
| | | type: object |
| | | request.PageInfo: |
| | | properties: |
| | |
| | | summary: 入库/出库列表 |
| | | tags: |
| | | - 入库/出库 |
| | | /api-wms/v1/operation/listAll: |
| | | /api-wms/v1/operation/listTransfer: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 调拨 |
| | | summary: 库存调拨列表 |
| | | tags: |
| | | - 入库/出库 |
| | | /api-wms/v1/operation/operation: |
| | |
| | | slf.Status = status |
| | | return slf |
| | | } |
| | | func (slf *OperationSearch) SetBaseOperationType(baseOperationType constvar.BaseOperationType) *OperationSearch { |
| | | slf.BaseOperationType = baseOperationType |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Operation{}) |
| | |
| | | db = db.Where("status = ?", slf.Status) |
| | | } |
| | | |
| | | if int(slf.BaseOperationType) != 0 { |
| | | db = db.Where("base_operation_type=?", slf.BaseOperationType) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | |
| | | type OperationList struct { |
| | | PageInfo |
| | | OperationTypeId int `json:"operationTypeId" form:"operationTypeId"` |
| | | Number string `json:"number"` |
| | | OperationTypeId int `json:"operationTypeId" form:"operationTypeId"` |
| | | Number string `json:"number"` |
| | | Status constvar.OperationStatus `json:"status"` |
| | | } |
| | | |
| | | type UpdateOperation struct { |
| | |
| | | operationAPI.POST("update", operationController.Update) |
| | | operationAPI.DELETE("operation/:id", operationController.Delete) |
| | | operationAPI.PUT("finish/:id", operationController.Finish) |
| | | operationAPI.POST("listAll", operationController.ListAll) |
| | | operationAPI.POST("listTransfer", operationController.ListTransfer) |
| | | |
| | | } |
| | | |