using System; using System.Collections.Generic; using CncService.Interface; using CncModels.Dto.Screen; using CncModels.Entity; using CncModels.Constants; using CncRepository.Interface; namespace CncService.Impl { /// /// 大屏配置实现 /// public class ScreenService : IScreenService { private readonly IScreenConfigRepository _screenConfigRepository; private readonly IScreenFilterRepository _screenFilterRepository; private readonly IWorkshopRepository _workshopRepository; public ScreenService( IScreenConfigRepository screenConfigRepository, IScreenFilterRepository screenFilterRepository, IWorkshopRepository workshopRepository) { _screenConfigRepository = screenConfigRepository ?? throw new ArgumentNullException(nameof(screenConfigRepository)); _screenFilterRepository = screenFilterRepository ?? throw new ArgumentNullException(nameof(screenFilterRepository)); _workshopRepository = workshopRepository ?? throw new ArgumentNullException(nameof(workshopRepository)); } /// public ScreenSummaryResponse GetSummary() { // 简化实现,返回默认值(实际由Controller调用Dashboard服务获取真实数据) return new ScreenSummaryResponse { MachineCount = 0, ProductionToday = 0, AlertCount = 0, OnlineCount = 0 }; } /// public List GetConfigs() { return _screenConfigRepository.GetAll(); } /// public bool UpdateConfig(ScreenConfig entity) { if (entity == null) throw new BusinessException(ErrorCode.BadRequest, "配置不能为空"); return _screenConfigRepository.Update(entity); } /// public List GetFilters(string screenKey) { if (string.IsNullOrWhiteSpace(screenKey)) throw new BusinessException(ErrorCode.BadRequest, "screenKey不能为空"); return _screenFilterRepository.GetByScreenKey(screenKey); } /// public int CreateFilter(ScreenFilter entity) { if (entity == null) throw new BusinessException(ErrorCode.BadRequest, "筛选项不能为空"); return _screenFilterRepository.Create(entity); } /// public bool UpdateFilter(ScreenFilter entity) { if (entity == null) throw new BusinessException(ErrorCode.BadRequest, "筛选项不能为空"); return _screenFilterRepository.Update(entity); } /// public bool DeleteFilter(int id) { if (id <= 0) throw new BusinessException(ErrorCode.BadRequest, "无效的筛选ID"); return _screenFilterRepository.Delete(id); } } }