100 lines
3.6 KiB
C#
100 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Hg.Core.Domain
|
|
{
|
|
public class EmployeeDomain : IEmployeeDomain
|
|
{
|
|
private readonly IBaseRepository<ZxdDbContext> _zxdRepository;
|
|
private readonly IDepartmentDomain _departmentDomain;
|
|
private readonly IBaseRepository<CompanyBaseConfDbContext> _compaybaseconfdb;
|
|
public EmployeeDomain(IBaseRepository<ZxdDbContext> zxdRepository, IDepartmentDomain departmentDomain, IBaseRepository<CompanyBaseConfDbContext> compaybaseconfdb)
|
|
{
|
|
_zxdRepository = zxdRepository;
|
|
this._departmentDomain = departmentDomain;
|
|
this._compaybaseconfdb = compaybaseconfdb;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据工号获取所在部门信息
|
|
/// </summary>
|
|
/// <param name="eid"></param>
|
|
/// <returns></returns>
|
|
public List<Employee_Department_Detail> GetEmployee_Department_Details(int eid)
|
|
{
|
|
var query = _zxdRepository.GetRepository<Employee_Department_Detail>().Query().Where(x => x.eid == eid);
|
|
return query.ToList();
|
|
}
|
|
|
|
public async Task<CenterInfo> GetCenterNameAsync(int eid)
|
|
{
|
|
CenterInfo info = new CenterInfo() { centerName = "", deptId = 0 };
|
|
var list = GetEmployee_Department_Details(eid);
|
|
if (list.Count() > 0)
|
|
{
|
|
var departments = await _departmentDomain.GetDeptmentAll();
|
|
var deptmentIds = list.Select(m => m.department_id);
|
|
var deptInfo = departments.Where(m => m.Id != 0).Where(m => deptmentIds.Contains(m.DepartmentId)).FirstOrDefault();
|
|
if (deptInfo != null)
|
|
{
|
|
info.deptId = deptInfo.Id;
|
|
info.centerName = deptInfo.Title;
|
|
}
|
|
}
|
|
return info;
|
|
}
|
|
public string GetAllDeptName(int eid)
|
|
{
|
|
string name = "";
|
|
var list = GetEmployee_Department_Details(eid);
|
|
if (list.Count() > 0)
|
|
{
|
|
name = string.Join('/', list.Where(m => m.level != 0).OrderBy(m => m.level).Select(m => m.department_name).ToArray());
|
|
}
|
|
return name;
|
|
}
|
|
|
|
public DepartmentInfo GetAllDeptInfos(int eid)
|
|
{
|
|
DepartmentInfo info = new DepartmentInfo();
|
|
string name = "";
|
|
var list = GetEmployee_Department_Details(eid);
|
|
if (list.Count() > 0)
|
|
{
|
|
info.deptmentNames = string.Join('/', list.Where(m => m.level != 0).OrderBy(m => m.level).Select(m => m.department_name).ToArray());
|
|
info.deptmentIds = string.Join(',', list.Where(m => m.level != 0).OrderBy(m => m.level).Select(m => m.department_id).ToArray());
|
|
}
|
|
return info;
|
|
}
|
|
/// <summary>
|
|
/// 获取员工姓名
|
|
/// </summary>
|
|
/// <param name="eid"></param>
|
|
/// <returns></returns>
|
|
public string GetEmpoyeeName(int eid)
|
|
{
|
|
var query = _compaybaseconfdb.GetRepository<Employee>().Query().Where(x => x.EmployeeID == eid).FirstOrDefault();
|
|
if (query != null)
|
|
return query.EmployeeName;
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 中心信息
|
|
/// </summary>
|
|
public class CenterInfo
|
|
{
|
|
public int deptId { get; set; }
|
|
public string centerName { get; set; }
|
|
}
|
|
|
|
public class DepartmentInfo
|
|
{
|
|
public string deptmentIds { get; set; }
|
|
public string deptmentNames { get; set; }
|
|
}
|
|
} |