| | |
| | | } |
| | | |
| | | 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) |
| | | } |
| | |
| | | f.SetCellValue("Sheet1", "E"+column, v.Unit) |
| | | f.SetCellValue("Sheet1", "F"+column, v.SalePrice) |
| | | |
| | | slf.FillDealerTypeToExcel(v.InputItems, inputStart, i+3, inputTypes, f) |
| | | slf.FillDealerTypeToExcel(v.OutputItems, outputStart, i+3, outputTypes, f) |
| | | slf.FillDealerTypeToExcel(v.InputItems, inputStart, i+3, inputTypes, f, constvar.InputTotalHeader) |
| | | slf.FillDealerTypeToExcel(v.OutputItems, outputStart, i+3, outputTypes, f, constvar.OutPutTotalHeader) |
| | | } |
| | | |
| | | fileName := fmt.Sprintf("%s月度统计报表%s.xlsx", "仓库", time.Now().Format("2006-01-02-1504")) |
| | |
| | | return sum |
| | | } |
| | | |
| | | func (slf *WarehouseMonthFormsService) FillDealerTypeToExcel(items []*models.WarehouseStatsItems, startIndex int, column int, dealerTypes []string, f *excelize.File) { |
| | | func (slf *WarehouseMonthFormsService) FillDealerTypeToExcel(items []*models.WarehouseStatsItems, startIndex int, column int, dealerTypes []string, f *excelize.File, totalHeader string) { |
| | | columnStr := strconv.Itoa(column) |
| | | sum := slf.SumItems(items) |
| | | detailMap := models.WarehouseStatsItemMap(items) |
| | |
| | | var amount decimal.Decimal |
| | | if detailMap[dealerTypes[i]] != nil { |
| | | amount = detailMap[dealerTypes[i]].Amount |
| | | } else if dealerTypes[i] == constvar.InputTotalHeader { |
| | | } else if dealerTypes[i] == totalHeader { |
| | | amount = sum |
| | | } |
| | | f.SetCellValue("Sheet1", getColumnAlphabet(startIndex+i)+columnStr, amount) |
| | |
| | | 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 |