a
This commit is contained in:
@@ -186,3 +186,53 @@ func GetPrintMessages(c *gin.Context, appID int, tokenInfo *model.TokenInfo, pri
|
||||
}
|
||||
return dao.GetPrintMessagesPage(db, printNo, msgID, beginAt, endAt, offset, pageSize)
|
||||
}
|
||||
|
||||
type GetPrinterReportResult struct {
|
||||
WeekPrintCount int `json:"week_print_count"`
|
||||
DayPrintCount int `json:"day_print_count"`
|
||||
DayUnPrintCount int `json:"day_un_print_count"`
|
||||
OnlinePrinterCount int `json:"online_printer_count"`
|
||||
OfflinePrinterCount int `json:"offline_printer_count"`
|
||||
FlowPrinterCount int `json:"flow_printer_count"`
|
||||
PaperPrinterCount int `json:"paper_printer_count"`
|
||||
}
|
||||
|
||||
func GetPrinterReport(c *gin.Context, tokenInfo *model.TokenInfo) (getPrinterReportResult *GetPrinterReportResult, err error) {
|
||||
var (
|
||||
db = globals.GetDB()
|
||||
weekCount, DayCount, DayUnCount = 0, 0, 0
|
||||
onlineC, offlineC, flowC, paperC = 0, 0, 0, 0
|
||||
)
|
||||
getPrinterReportResult = &GetPrinterReportResult{}
|
||||
apps, _ := dao.GetApps(db, 0, tokenInfo.User.UserID, "")
|
||||
if len(apps) == 0 {
|
||||
return nil, err
|
||||
}
|
||||
for _, app := range apps {
|
||||
printers, _ := dao.GetPrinters(db, app.ID, "", 0, 0, 0)
|
||||
for _, printer := range printers {
|
||||
weeks, _ := dao.GetPrintMessages(db, printer.PrintNo, "", utils.Time2Str(time.Now().AddDate(0, 0, -7)), utils.Time2Str(time.Now()), 0)
|
||||
weekCount += len(weeks)
|
||||
days, _ := dao.GetPrintMessages(db, printer.PrintNo, "", utils.Time2Str(time.Now().AddDate(0, 0, -1)), utils.Time2Str(time.Now()), 0)
|
||||
DayCount += len(days)
|
||||
dayUns, _ := dao.GetPrintMessages(db, printer.PrintNo, "", utils.Time2Str(time.Now().AddDate(0, 0, -1)), utils.Time2Str(time.Now()), 1)
|
||||
DayUnCount += len(dayUns)
|
||||
}
|
||||
onlines, _ := dao.GetPrinters(db, app.ID, "", model.PrinterOnline, 0, 0)
|
||||
onlineC += len(onlines)
|
||||
offlines, _ := dao.GetPrinters(db, app.ID, "", model.PrinterOffline, 0, 0)
|
||||
offlineC += len(offlines)
|
||||
flows, _ := dao.GetPrinters(db, app.ID, "", 0, 0, 1)
|
||||
flowC += len(flows)
|
||||
papers, _ := dao.GetPrinters(db, app.ID, "", model.PrinterStatusWithouPaper, 0, 0)
|
||||
paperC += len(papers)
|
||||
}
|
||||
getPrinterReportResult.WeekPrintCount = weekCount
|
||||
getPrinterReportResult.DayPrintCount = DayCount
|
||||
getPrinterReportResult.DayUnPrintCount = DayUnCount
|
||||
getPrinterReportResult.OnlinePrinterCount = onlineC
|
||||
getPrinterReportResult.OfflinePrinterCount = offlineC
|
||||
getPrinterReportResult.FlowPrinterCount = flowC
|
||||
getPrinterReportResult.PaperPrinterCount = paperC
|
||||
return getPrinterReportResult, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user