using Admin.Core.Common;
using Admin.Core.IRepository;
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using log4net;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Admin.Core.IService
{
///
/// SysUserInfoServices
///
public class SysUserInfoServices : BaseServices, ISysUserInfoServices
{
private readonly IBaseRepository _dal;
private readonly ISysUserInfoRepository _sysUserInfoRepository;
public SysUserInfoServices(IBaseRepository dal, ISysUserInfoRepository sysUserInfoRepository)
{
this._dal = dal;
base.BaseDal = dal;
_sysUserInfoRepository = sysUserInfoRepository;
}
public async Task> GetTeamData()
{
return await _sysUserInfoRepository.GetTeamData();
}
public async Task GetTeamData(DateTime nowDate)
{
var list = await _sysUserInfoRepository.GetTeamData();
if (list.Count() == 0) return null;
CurrentTeamTimeView view = list.SingleOrDefault(d => d.StartTime <= nowDate && nowDate <= d.EndTime);
if (view != null)
return view;
else
return null;
}
///
/// 根据工位获取所有值
///
///
///
public async Task GetStationData(string code)
{
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
var list = await _sysUserInfoRepository.GetStationData(code);
if (list == null) return null;
var obj = list.SingleOrDefault(d => d.ProductLineCode == "productLineCode");
return obj;
}
///
/// 根据产线查询 公司、产线、工序、工位
///
///
///
public async Task GetProductLineInfo(string productLineCode)
{
var list = await _sysUserInfoRepository.GetProductLineInfo(productLineCode);
if (list == null) return null;
var obj = list.SingleOrDefault(d => d.ProductlineCode == productLineCode);
return obj;
}
///
/// 统计前后板数据
///
///
///
public async Task> GetSheetMetalTypeData(string productLineCode)
{
return await _sysUserInfoRepository.GetSheetMetalTypeData(productLineCode);
}
public async Task> GetSheetMetaHourData(string productLineCode)
{
return await _sysUserInfoRepository.GetSheetMetaHourData(productLineCode);
}
}
}