| | |
| | | dbIn := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}). |
| | | Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id"). |
| | | Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeIncoming). |
| | | Where("wms_operation.status=?", constvar.OperationStatus_Ready) |
| | | Where("wms_operation.status in (?)", []int{3, 4}) |
| | | dbOut := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}). |
| | | Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id"). |
| | | Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeOutgoing). |
| | | Where("wms_operation.status=?", constvar.OperationStatus_Ready) |
| | | Where("wms_operation.status in (?)", []int{3, 4}) |
| | | if len(locationIds) > 0 { |
| | | dbIn.Where("wms_operation.from_location_id in (?)", locationIds) |
| | | dbIn.Where("wms_operation.to_location_id in (?)", locationIds) |
| | | dbOut.Where("wms_operation.from_location_id in (?)", locationIds) |
| | | } |
| | | err = dbIn.Find(&inHouse).Error |
| | |
| | | resp.ProduceId = material.ID |
| | | resp.ProductName = material.Name |
| | | resp.Cost = material.Cost |
| | | resp.Amount = material.Amount |
| | | resp.Unit = material.Unit |
| | | resp.Value = material.Amount.Mul(material.Cost) |
| | | resp.ProductType = material.CategoryName |
| | |
| | | resp.Out = resp.Out.Add(details.Amount) |
| | | } |
| | | } |
| | | resp.Amount = resp.In.Sub(resp.Out) |
| | | resp.AvailableNumber = resp.Amount |
| | | result = append(result, resp) |
| | | } |
| | |
| | | if params.PageInfo.Check() { |
| | | detailsSearch.SetPage(params.Page, params.PageSize) |
| | | } |
| | | details, total, err := detailsSearch.SetProductId(params.ProduceId).Find() |
| | | details, err := detailsSearch.SetProductId(params.ProduceId).FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询操作详情失败") |
| | | return |
| | |
| | | operationIds = append(operationIds, detail.OperationID) |
| | | } |
| | | //获取已完成的操作记录 |
| | | operations, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).FindNotTotal() |
| | | operations, total, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询操作记录失败") |
| | | return |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | func InsertDefaultData() { |
| | | models := []interface{}{ |
| | | NewDepartmentSearch(), |
| | | NewLocationSearch(), |
| | | } |
| | | for _, model := range models { |
| | | if id, ok := model.(InitDefaultData); ok { |
| | |
| | | } |
| | | return records, nil |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *LocationSearch) InitDefaultData() error { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return err |
| | | } |
| | | if total != 0 { |
| | | return nil |
| | | } |
| | | locations := make([]*Location, 0) |
| | | locations = append(locations, &Location{Name: "供应商位置", Type: 1, JointName: "供应商位置"}) |
| | | locations = append(locations, &Location{Name: "视图", Type: 2, JointName: "视图"}) |
| | | locations = append(locations, &Location{Name: "客户位置", Type: 4, JointName: "客户位置"}) |
| | | locations = append(locations, &Location{Name: "库存损失", Type: 5, JointName: "库存损失"}) |
| | | locations = append(locations, &Location{Name: "生产", Type: 6, JointName: "生产"}) |
| | | locations = append(locations, &Location{Name: "中转位置", Type: 7, JointName: "中转位置"}) |
| | | locations = append(locations, &Location{Name: "报废位置", Type: 8, JointName: "报废位置"}) |
| | | locations = append(locations, &Location{Name: "库存盘点", Type: 9, JointName: "库存盘点"}) |
| | | return slf.CreateBatch(locations) |
| | | } |