| | |
| | | } |
| | | |
| | | func (slf *WarehouseMonthFormsService) BuildSearch(params request.GetMonthStats) (search *models.WarehouseMonthStatsSearch) { |
| | | search = models.NewWarehouseMonthStatsSearch().SetKeyword(params.Keyword).SetDate(params.Date) |
| | | search = models.NewWarehouseMonthStatsSearch(). |
| | | SetKeyword(params.Keyword).SetDate(params.Date).SetWarehouseId(params.WarehouseID) |
| | | if params.Preload { |
| | | search = search.SetPreload(true) |
| | | } |
| | |
| | | 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 |