You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haoliang-net/src/CncService/Impl/ScreenService.cs

85 lines
3.0 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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
{
/// <summary>
/// 大屏配置实现
/// </summary>
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));
}
/// <inheritdoc/>
public ScreenSummaryResponse GetSummary()
{
// 简化实现返回默认值实际由Controller调用Dashboard服务获取真实数据
return new ScreenSummaryResponse
{
MachineCount = 0,
ProductionToday = 0,
AlertCount = 0,
OnlineCount = 0
};
}
/// <inheritdoc/>
public List<ScreenConfig> GetConfigs()
{
return _screenConfigRepository.GetAll();
}
/// <inheritdoc/>
public bool UpdateConfig(ScreenConfig entity)
{
if (entity == null) throw new BusinessException(ErrorCode.BadRequest, "配置不能为空");
return _screenConfigRepository.Update(entity);
}
/// <inheritdoc/>
public List<ScreenFilter> GetFilters(string screenKey)
{
if (string.IsNullOrWhiteSpace(screenKey)) throw new BusinessException(ErrorCode.BadRequest, "screenKey不能为空");
return _screenFilterRepository.GetByScreenKey(screenKey);
}
/// <inheritdoc/>
public int CreateFilter(ScreenFilter entity)
{
if (entity == null) throw new BusinessException(ErrorCode.BadRequest, "筛选项不能为空");
return _screenFilterRepository.Create(entity);
}
/// <inheritdoc/>
public bool UpdateFilter(ScreenFilter entity)
{
if (entity == null) throw new BusinessException(ErrorCode.BadRequest, "筛选项不能为空");
return _screenFilterRepository.Update(entity);
}
/// <inheritdoc/>
public bool DeleteFilter(int id)
{
if (id <= 0) throw new BusinessException(ErrorCode.BadRequest, "无效的筛选ID");
return _screenFilterRepository.Delete(id);
}
}
}