91 lines
3.2 KiB
C#
91 lines
3.2 KiB
C#
using YLErp.BLL;
|
|
|
|
namespace YLErp.Modules.ClientModule
|
|
{
|
|
public class ClientHierarchyService : ClientBaseService
|
|
{
|
|
public ClientHierarchyService(OptUserInfo userInfo) : base(userInfo)
|
|
{
|
|
|
|
}
|
|
public List<Client> clients = new List<Client>();
|
|
public List<Client> clientsdata = new List<Client>();
|
|
public List<Clientlayered> Treeleveldata(int clientid)
|
|
{
|
|
var systemDate = valuedateBLL.SystemDate;
|
|
List<Client> client = DataCacheProvider.GetClientDataSource().AsQueryable().ToList();
|
|
var nowclient = client.Where(c => c.id == clientid).FirstOrDefault();
|
|
if (nowclient == null)
|
|
{
|
|
throw new ServiceException("当前客户已不存在");
|
|
}
|
|
clients.Add(client.Where(c => c.id == clientid).FirstOrDefault());
|
|
FoundChildNode(client, client.Where(c => c.id == clientid).FirstOrDefault());
|
|
var ParentData = clients.Where(c => c.ParentId == 0).FirstOrDefault();
|
|
clientsdata.Add(ParentData);
|
|
List<Client> res = FoundParentNode(client, ParentData);
|
|
|
|
var query = from cli in res
|
|
join cd in yldb.credit.Where(t => t.ProcessStatus == "已审批" &&
|
|
(!t.CreditDeadLine.HasValue || t.CreditDeadLine >= systemDate.ValueDate) && (!t.CreditStartDate.HasValue || t.CreditStartDate <= systemDate.ValueDate)).ToList()
|
|
on cli.id equals cd.ClientId into cl
|
|
from clie in cl.DefaultIfEmpty()
|
|
select new Clientlayered { Credit = clie == null ? 0 : clie.Credit ?? 0, StockEqvNotional = clie == null ? 0 : clie.StockEqvNotional ?? 0, id = cli.id, Name = cli.Name, ParentId = cli.ParentId, ProcessStatus = cli.ProcessStatus };
|
|
|
|
return query.ToList();
|
|
}
|
|
|
|
public void FoundChildNode(List<Client> all, Client item)
|
|
{
|
|
Client childItems = all.Where(c => c.id == item.ParentId).FirstOrDefault();
|
|
|
|
if (childItems != null)
|
|
{
|
|
clients.Add(childItems);
|
|
FoundChildNode(all, childItems);
|
|
}
|
|
}
|
|
public List<Client> FoundParentNode(List<Client> all, Client clientlist)
|
|
{
|
|
|
|
List<Client> childItems = all.Where(c => c.ParentId == clientlist.id).ToList();
|
|
foreach (var item in childItems)
|
|
{
|
|
|
|
clientsdata.Add(item);
|
|
FoundParentNode(all, item);
|
|
}
|
|
return clientsdata;
|
|
}
|
|
}
|
|
public class Clientlayered
|
|
{
|
|
/// <summary>
|
|
/// 客户Id
|
|
/// </summary>
|
|
public int id { get; set; }
|
|
/// <summary>
|
|
/// 客户名称
|
|
/// </summary>
|
|
public string Name { get; set; }
|
|
/// <summary>
|
|
/// 父级Id
|
|
/// </summary>
|
|
public int ParentId { get; set; }
|
|
/// <summary>
|
|
///授信额度
|
|
/// </summary>
|
|
public double Credit { get; set; }
|
|
/// <summary>
|
|
/// 名义本金规模
|
|
/// </summary>
|
|
public double StockEqvNotional { get; set; }
|
|
/// <summary>
|
|
/// 用户状态
|
|
/// </summary>
|
|
public string ProcessStatus { get; set; }
|
|
|
|
}
|
|
|
|
}
|