diff --git a/src/CncRepository/Impl/DailyProductionRepository.cs b/src/CncRepository/Impl/DailyProductionRepository.cs index 447dc0d..3a318a2 100644 --- a/src/CncRepository/Impl/DailyProductionRepository.cs +++ b/src/CncRepository/Impl/DailyProductionRepository.cs @@ -130,7 +130,7 @@ namespace CncRepository.Impl string topSql = @"SELECT m.name FROM cnc_daily_production dp LEFT JOIN cnc_machine m ON dp.machine_id = m.id WHERE dp.production_date BETWEEN @Start AND @End"; if (workshopId.HasValue) topSql += " AND m.workshop_id = @WorkshopId"; topSql += " GROUP BY dp.machine_id ORDER BY SUM(dp.end_total_count - dp.base_total_count) DESC LIMIT 1"; - result.TopMachineName = conn.ExecuteScalar(topSql, parameters) ?? ""; + result.TopMachineName = result.TotalQuantity > 0 ? (conn.ExecuteScalar(topSql, parameters) ?? "-") : "-"; return result; } } @@ -160,7 +160,7 @@ namespace CncRepository.Impl if (result == null) return new WorkerProductionSummaryResponse(); if (result.ActiveWorkerCount > 0) result.AvgPerWorker = Math.Round((decimal)result.TotalQuantity / result.ActiveWorkerCount, 1); string topSql = @"SELECT w.name FROM cnc_daily_production dp JOIN cnc_worker_machine wm ON dp.machine_id = wm.machine_id JOIN cnc_worker w ON wm.worker_id = w.id WHERE dp.production_date BETWEEN @Start AND @End GROUP BY w.id, w.name ORDER BY SUM(dp.end_total_count - dp.base_total_count) DESC LIMIT 1"; - result.TopWorkerName = conn.ExecuteScalar(topSql, new { Start = startDate, End = endDate }) ?? ""; + result.TopWorkerName = result.TotalQuantity > 0 ? (conn.ExecuteScalar(topSql, new { Start = startDate, End = endDate }) ?? "-") : "-"; return result; } } @@ -194,7 +194,7 @@ namespace CncRepository.Impl string topSql = @"SELECT dp.program_name FROM cnc_daily_production dp LEFT JOIN cnc_machine m ON dp.machine_id = m.id WHERE dp.production_date BETWEEN @Start AND @End"; if (workshopId.HasValue) topSql += " AND m.workshop_id = @WorkshopId"; topSql += " GROUP BY dp.program_name ORDER BY SUM(dp.end_total_count - dp.base_total_count) DESC LIMIT 1"; - result.TopProgramName = conn.ExecuteScalar(topSql, parameters) ?? ""; + result.TopProgramName = result.TotalQuantity > 0 ? (conn.ExecuteScalar(topSql, parameters) ?? "-") : "-"; return result; } }