| | |
| | | for _, item := range result { |
| | | productIds = append(productIds, item.ProductId) |
| | | } |
| | | statsRecords, err := service.GetCurrentWarehouseStats(params.Date, params.WarehouseID, productIds) |
| | | statsRecords, err := service.GetCurrentWarehouseStats(params.Date, params.WarehouseID, productIds, true) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.InternalError, "内部错误") |
| | | return |
| | |
| | | return |
| | | } |
| | | |
| | | func GetCurrentWarehouseStats(date string, warehouseId int, productIds []string) (statRecords []*models.WarehouseMonthStats, err error) { |
| | | func GetCurrentWarehouseStats(date string, warehouseId int, productIds []string, realTime bool) (statRecords []*models.WarehouseMonthStats, err error) { |
| | | //本月期初数量/上月结余数量 |
| | | groupSumList, err := models.NewLocationProductAmountSearch().SetProductIds(productIds).GroupSum("product_id", "amount") |
| | | productIds = make([]string, 0, len(groupSumList)) |
| | |
| | | |
| | | //按配置取开始时间和结束时间 |
| | | beginTime, endTime, err := NewSystemConfigService().GetInventoryCutOffTime() |
| | | if realTime { |
| | | beginTime = endTime |
| | | endTime = time.Now() |
| | | } |
| | | if err != nil { |
| | | logx.Errorf("MonthStats GetCurrentStats get GetInventoryCutOffTime err:%v", err) |
| | | return |
| | |
| | | oldRecordsMap := models.WarehouseMonthStatsMap(oldRecords) |
| | | |
| | | //本月期初数量/上月结余数量 |
| | | statsRecords, err := service.GetCurrentWarehouseStats(date, warehouseId, nil) |
| | | statsRecords, err := service.GetCurrentWarehouseStats(date, warehouseId, nil, false) |
| | | if err != nil { |
| | | continue |
| | | } |