Commit 0c150ed5 authored by liudong1993's avatar liudong1993

部门调整

parent fca9d00e
...@@ -28,6 +28,11 @@ namespace Edu.Model.ViewModel.User ...@@ -28,6 +28,11 @@ namespace Edu.Model.ViewModel.User
/// </summary> /// </summary>
public int School_Id { get; set; } public int School_Id { get; set; }
/// <summary>
/// 是否校区 1是
/// </summary>
public int IsCompany { get; set; }
/// <summary> /// <summary>
/// 下级部门列表 /// 下级部门列表
......
...@@ -140,7 +140,6 @@ namespace Edu.Module.User ...@@ -140,7 +140,6 @@ namespace Edu.Module.User
List<DepartmentTree_ViewModel> list = new List<DepartmentTree_ViewModel>(); List<DepartmentTree_ViewModel> list = new List<DepartmentTree_ViewModel>();
//所有的部门列表 //所有的部门列表
var deptList = GetDepartmentListModule(query); var deptList = GetDepartmentListModule(query);
var schoolList = schoolRepository.GetSchoolListRepository(new RB_School_ViewModel() { Group_Id = query.Group_Id });
var empList = new List<Employee_ViewModel>(); var empList = new List<Employee_ViewModel>();
if (deptList == null) if (deptList == null)
{ {
...@@ -150,46 +149,6 @@ namespace Edu.Module.User ...@@ -150,46 +149,6 @@ namespace Edu.Module.User
{ {
empList= accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = query.Group_Id }); empList= accountRepository.GetEmployeeListRepository(new Employee_ViewModel() { Group_Id = query.Group_Id });
} }
//校区部门
List<DepartmentTree_ViewModel> schoolDeptList = new List<DepartmentTree_ViewModel>();
if (schoolList != null)
{
foreach (var item in schoolList)
{
DepartmentTree_ViewModel tModel = new DepartmentTree_ViewModel()
{
DeptId = item.SId+10000,
DeptName = item.SName,
ParentId = item.Dept_Id,
School_Id=item.SId,
ChildList = new List<DepartmentTree_ViewModel>()
};
#region 添加员工信息
if (isQueryEmployee && item.ManagerId > 0)
{
var empModel = empList?.Where(qitem => qitem.Id == item.ManagerId)?.FirstOrDefault();
if (empModel!=null && !string.IsNullOrEmpty(empModel.EmployeeName))
{
tModel.ChildList.Add(new DepartmentTree_ViewModel()
{
DeptId = empModel.Id,
DeptName = empModel.EmployeeName,
ParentId = 0,
School_Id=empModel.School_Id,
});
}
}
#endregion
var currentSchoolDeptList = deptList.Where(qitem => qitem.School_Id ==item.SId).ToList();
if (currentSchoolDeptList != null && currentSchoolDeptList.Count > 0)
{
var currentSchoolDeptId = currentSchoolDeptList?.Min(qitem => qitem.ParentId) ?? 0;
tModel.ChildList = GetDeptTreeList(currentSchoolDeptId, currentSchoolDeptList, SchoolId: item.SId, schoolDeptList: null, empList: empList);
}
schoolDeptList.Add(tModel);
}
}
if (deptList != null && deptList.Count > 0) if (deptList != null && deptList.Count > 0)
{ {
...@@ -204,7 +163,8 @@ namespace Edu.Module.User ...@@ -204,7 +163,8 @@ namespace Edu.Module.User
DeptName = fItem.DeptName, DeptName = fItem.DeptName,
ParentId = fItem.ParentId, ParentId = fItem.ParentId,
ChildList = new List<DepartmentTree_ViewModel>(), ChildList = new List<DepartmentTree_ViewModel>(),
School_Id=fItem.School_Id School_Id = fItem.School_Id,
IsCompany = fItem.IsCompany
}; };
#region 添加员工信息 #region 添加员工信息
...@@ -228,15 +188,7 @@ namespace Edu.Module.User ...@@ -228,15 +188,7 @@ namespace Edu.Module.User
} }
#endregion #endregion
tModel.ChildList = GetDeptTreeList(fItem.DeptId, deptList.Where(qitem => qitem.School_Id == 0).ToList(), SchoolId: 0, schoolDeptList: schoolDeptList, empList: empList); tModel.ChildList = GetDeptTreeList(fItem.DeptId, deptList, empList: empList);
//if (schoolDeptList != null)
//{
// var newSchoolDeptList = schoolDeptList.Where(qitem => qitem.DeptId == fItem.DeptId)?.ToList();
// if (newSchoolDeptList != null && newSchoolDeptList.Count>0)
// {
// tModel.ChildList.AddRange(newSchoolDeptList);
// }
//}
list.Add(tModel); list.Add(tModel);
} }
} }
...@@ -250,13 +202,11 @@ namespace Edu.Module.User ...@@ -250,13 +202,11 @@ namespace Edu.Module.User
/// </summary> /// </summary>
/// <param name="parentId">父节点编号</param> /// <param name="parentId">父节点编号</param>
/// <param name="sourceList">数据源列表</param> /// <param name="sourceList">数据源列表</param>
/// <param name="SchoolId">学校编号</param>
/// <param name="schoolDeptList">学校部门列表</param>
/// <param name="empList">员工列表</param> /// <param name="empList">员工列表</param>
private List<DepartmentTree_ViewModel> GetDeptTreeList(int parentId, List<RB_Department_ViewModel> sourceList,int SchoolId=0, List<DepartmentTree_ViewModel> schoolDeptList=null, List<Employee_ViewModel> empList=null) private List<DepartmentTree_ViewModel> GetDeptTreeList(int parentId, List<RB_Department_ViewModel> sourceList, List<Employee_ViewModel> empList=null)
{ {
List<DepartmentTree_ViewModel> treeList = new List<DepartmentTree_ViewModel>(); List<DepartmentTree_ViewModel> treeList = new List<DepartmentTree_ViewModel>();
foreach (var item in sourceList.Where(qitem => qitem.ParentId == parentId && qitem.School_Id== SchoolId)) foreach (var item in sourceList.Where(qitem => qitem.ParentId == parentId))
{ {
DepartmentTree_ViewModel model = new DepartmentTree_ViewModel() DepartmentTree_ViewModel model = new DepartmentTree_ViewModel()
{ {
...@@ -264,7 +214,8 @@ namespace Edu.Module.User ...@@ -264,7 +214,8 @@ namespace Edu.Module.User
DeptName = item.DeptName, DeptName = item.DeptName,
ParentId = item.ParentId, ParentId = item.ParentId,
ChildList = new List<DepartmentTree_ViewModel>(), ChildList = new List<DepartmentTree_ViewModel>(),
School_Id=item.School_Id School_Id=item.School_Id,
IsCompany = item.IsCompany
}; };
#region 添加员工信息 #region 添加员工信息
if (empList != null && empList.Count > 0) if (empList != null && empList.Count > 0)
...@@ -287,15 +238,7 @@ namespace Edu.Module.User ...@@ -287,15 +238,7 @@ namespace Edu.Module.User
} }
#endregion #endregion
model.ChildList = GetDeptTreeList(item.DeptId, sourceList, SchoolId, schoolDeptList); model.ChildList = GetDeptTreeList(item.DeptId, sourceList);
if (schoolDeptList != null)
{
var newSchoolDeptList = schoolDeptList.Where(qitem => qitem.ParentId == item.DeptId)?.ToList();
if (newSchoolDeptList != null)
{
model.ChildList.AddRange(newSchoolDeptList);
}
}
treeList.Add(model); treeList.Add(model);
} }
return treeList; return treeList;
...@@ -391,6 +334,7 @@ namespace Edu.Module.User ...@@ -391,6 +334,7 @@ namespace Edu.Module.User
{nameof(RB_Department_ViewModel.School_Id),extModel.School_Id }, {nameof(RB_Department_ViewModel.School_Id),extModel.School_Id },
{nameof(RB_Department_ViewModel.DeptTier),extModel.DeptTier }, {nameof(RB_Department_ViewModel.DeptTier),extModel.DeptTier },
{nameof(RB_Department_ViewModel.DeptSort),extModel.DeptSort }, {nameof(RB_Department_ViewModel.DeptSort),extModel.DeptSort },
{nameof(RB_Department_ViewModel.IsCompany),extModel.IsCompany }
}; };
flag = departmentRepository.Update(fileds, new WhereHelper(nameof(RB_Department_ViewModel.DeptId), extModel.DeptId)); flag = departmentRepository.Update(fileds, new WhereHelper(nameof(RB_Department_ViewModel.DeptId), extModel.DeptId));
} }
......
...@@ -55,6 +55,10 @@ WHERE 1=1 ...@@ -55,6 +55,10 @@ WHERE 1=1
{ {
builder.Append($" AND A.{nameof(RB_Department_ViewModel.DeptId)}={query.DeptId} "); builder.Append($" AND A.{nameof(RB_Department_ViewModel.DeptId)}={query.DeptId} ");
} }
if (query.IsCompany == 1)
{
builder.Append($" AND A.{nameof(RB_Department_ViewModel.IsCompany)}=1 ");
}
if (!string.IsNullOrEmpty(query.DeptName)) if (!string.IsNullOrEmpty(query.DeptName))
{ {
builder.Append($" AND A.{nameof(RB_Department_ViewModel.DeptName)} LIKE @DeptName "); builder.Append($" AND A.{nameof(RB_Department_ViewModel.DeptName)} LIKE @DeptName ");
......
...@@ -652,7 +652,6 @@ namespace Edu.WebApi.Controllers.User ...@@ -652,7 +652,6 @@ namespace Edu.WebApi.Controllers.User
/// <returns></returns> /// <returns></returns>
public ApiResult AskForLeaveSubmit() public ApiResult AskForLeaveSubmit()
{ {
//RequestParm.Uid = "1972";
int empId = Convert.ToInt32(RequestParm.Uid); int empId = Convert.ToInt32(RequestParm.Uid);
Rb_Workflow_Askforleave_Extend askforleave = JsonConvert.DeserializeObject<Rb_Workflow_Askforleave_Extend>(RequestParm.Msg.ToString()); Rb_Workflow_Askforleave_Extend askforleave = JsonConvert.DeserializeObject<Rb_Workflow_Askforleave_Extend>(RequestParm.Msg.ToString());
if (askforleave.StartTime > askforleave.EndTime) if (askforleave.StartTime > askforleave.EndTime)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment