93 lines
2.3 KiB
C#
93 lines
2.3 KiB
C#
using System.Linq.Expressions;
|
|
using YLErp.Abstract;
|
|
using YLErp.Models;
|
|
using YLErp.Modules.ClientModule;
|
|
|
|
namespace YLErp.Modules.IntradayModule
|
|
{
|
|
/// <summary>
|
|
/// 日终结算信息查询上下文
|
|
/// </summary>
|
|
public class IntradaySettleInfoQueryContext : YLServiceContext, IDataSource<ClientMainInfo>
|
|
{
|
|
Dictionary<int, ClientMainInfo> _dic;
|
|
|
|
public IntradaySettleInfoQueryContext(OptUserInfo userInfo) : base(userInfo)
|
|
{
|
|
|
|
}
|
|
|
|
#region----IDataSource<ClientMainInfo>----
|
|
|
|
public int Count => _dic != null ? _dic.Count : 0;
|
|
|
|
public IQueryable<ClientMainInfo> AsQueryable(Expression<Func<ClientMainInfo, bool>> predicate = null)
|
|
{
|
|
InitClientDic();
|
|
|
|
var qry = _dic.Values.AsQueryable();
|
|
|
|
return predicate == null ? qry : qry.Where(predicate);
|
|
}
|
|
|
|
public ClientMainInfo GetData(int keyId)
|
|
{
|
|
TryGetClientInfo(keyId, out var clientInfo);
|
|
|
|
return clientInfo;
|
|
}
|
|
|
|
public void ResetDataSource()
|
|
{
|
|
_dic?.Clear();
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 获取客户信息
|
|
/// </summary>
|
|
public bool TryGetClientInfo(int clientId, out ClientMainInfo clientInfo)
|
|
{
|
|
InitClientDic();
|
|
|
|
return _dic.TryGetValue(clientId, out clientInfo);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public List<int> GetClientIds()
|
|
{
|
|
InitClientDic();
|
|
|
|
return _dic.Keys.ToList();
|
|
}
|
|
|
|
public List<int> GetClientIdsOfInside()
|
|
{
|
|
var clientIds = GetClientIds();
|
|
using (var clientdb = DbContextFactory.GetClientDbContext(null))
|
|
{
|
|
if (clientIds.Any())
|
|
{
|
|
return clientdb.client.Where(a => clientIds.Contains(a.id) && a.IsInsided ==1).Select(a => a.id).ToList();
|
|
}
|
|
else
|
|
{
|
|
return new List<int>();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void InitClientDic()
|
|
{
|
|
if (_dic == null)
|
|
{
|
|
_dic = ClientDataQueryService.GetClientsFromDB(x => x.ProcessStatus != "未提交").ToDictionary(n => n.id);
|
|
}
|
|
}
|
|
}
|
|
}
|