Commit 7cdf2f51 authored by liudong1993's avatar liudong1993

解决冲突

parents bf4bf393 681fb74b
......@@ -97,5 +97,13 @@ namespace Edu.Model.ViewModel.Course
/// 查询可报名 1是
/// </summary>
public int Q_CanApply { get; set; }
/// 选中的周几/或日期数组
/// </summary>
public List<string> WeekDayList { get; set; }
/// <summary>
/// 默认上课时间
/// </summary>
public List<RB_Class_Time_ViewModel> DefaultPlanTimeList { get; set; }
}
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ namespace Edu.Model.ViewModel.User
public int IsCompany { get; set; }
/// <summary>
/// 数据类型(1-部门,2-员工)
/// 数据类型(1-部门,2-员工,3-岗位)
/// </summary>
public int DataType { get; set; }
......
using Edu.Common.Enum;
using Edu.Model.ViewModel.Course;
using Edu.Repository.Course;
using System;
using System.Collections.Generic;
using System.Linq;
using VT.FW.DB;
......@@ -117,44 +118,271 @@ namespace Edu.Module.Course
model.ClassId = newId;
flag =newId > 0;
}
//删除班级计划
class_PlanRepository.DeleteClassPlanRepository(model.ClassId);
class_TimeRepository.DeleteClassTimeRepository(model.ClassId);
if (model.ClassPlanList != null && model.ClassPlanList.Count > 0)
#region 阶梯报价
//未开启阶梯价格
if (model.IsStepPrice == 0)
{
foreach (var item in model.ClassPlanList)
class_StepPriceRepository.DeleteClassStepPriceRepository(model.ClassId);
}
else//开启阶梯价格
{
var oldStepPriceList = class_StepPriceRepository.GetClassStepPriceListRepository(new RB_Class_StepPrice_ViewModel() { ClassId = model.ClassId });
//以前没有阶梯报价信息【直接新增】
if (oldStepPriceList == null || (oldStepPriceList != null && oldStepPriceList.Count == 0))
{
item.ClassId = model.ClassId;
item.ClassPlanId = 0;
item.Group_Id = model.Group_Id;
item.School_Id = model.School_Id;
//添加班级上课计划
var newClassPlanId = class_PlanRepository.Insert(item);
if (item.PlanTimeList != null && item.PlanTimeList.Count > 0)
if (model.ClassStepPriceList != null && model.ClassStepPriceList.Count > 0)
{
foreach (var item in model.ClassStepPriceList)
{
item.ClassStepPriceId = 0;
item.ClassId = model.ClassId;
item.Group_Id = model.Group_Id;
item.School_Id = model.School_Id;
class_StepPriceRepository.Insert(item);
}
}
}
else//以前有阶梯报价
{
//现在没有阶梯报价了【直接删除以前的阶梯报价】
if (model.ClassStepPriceList == null || (model.ClassStepPriceList != null && model.ClassStepPriceList.Count == 0))
{
class_StepPriceRepository.DeleteClassStepPriceRepository(model.ClassId);
}
//找出差异的数据
var deleteList = oldStepPriceList.Where(qitem => !model.ClassStepPriceList.Any(oldItem => qitem.ClassStepPriceId == oldItem.ClassStepPriceId)).ToList();
foreach (var dItem in deleteList)
{
if (dItem.ClassStepPriceId > 0)
{
class_StepPriceRepository.Delete(dItem.ClassStepPriceId);
}
}
foreach (var priceItem in model.ClassStepPriceList)
{
foreach (var subItem in item.PlanTimeList)
priceItem.ClassId = model.ClassId;
priceItem.Group_Id = model.Group_Id;
priceItem.School_Id = model.School_Id;
if (priceItem.ClassStepPriceId == 0)
{
class_StepPriceRepository.Insert(priceItem);
}
else
{
subItem.ClassTimeId = 0;
subItem.ClassId = model.ClassId;
subItem.ClassPlanId = newClassPlanId;
subItem.Group_Id = model.Group_Id;
subItem.School_Id = model.School_Id;
//添加班级上课计划的上课时间
class_TimeRepository.Insert(subItem);
class_StepPriceRepository.Update(priceItem);
}
}
}
}
class_StepPriceRepository.DeleteClassStepPriceRepository(model.ClassId);
if (model.ClassStepPriceList != null && model.ClassStepPriceList.Count > 0)
#endregion
#region 班级计划
//默认上课时间
var defaultPlanTimeList = new List<RB_Class_Time_ViewModel>();
foreach (var tItem in model.DefaultPlanTimeList)
{
defaultPlanTimeList.Add(new RB_Class_Time_ViewModel()
{
Group_Id = model.Group_Id,
School_Id = model.School_Id,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassTimeId = 0,
StartTime = tItem.StartTime,
EndTime = tItem.EndTime
});
}
//班级上课计划列表
List<RB_Class_Plan_ViewModel> classPlanList = new List<RB_Class_Plan_ViewModel>();
//删除班级计划
switch (model.ClassStyle)
{
//按周排课
case Common.Enum.Course.ClassStyleEnum.Week:
if (model.WeekDayList != null && model.WeekDayList.Count > 0)
{
var srartDate = model.OpenTime;
for (var i = 0; i < 120; i++)
{
var newDate = srartDate.AddDays(i);
foreach (var item in model.WeekDayList)
{
switch (item)
{
case "1":
if (newDate.DayOfWeek == System.DayOfWeek.Monday)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = newDate,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
break;
case "2":
if (newDate.DayOfWeek == System.DayOfWeek.Tuesday)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = newDate,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
break;
case "3":
if (newDate.DayOfWeek == System.DayOfWeek.Wednesday)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = newDate,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
break;
case "4":
if (newDate.DayOfWeek == System.DayOfWeek.Thursday)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = newDate,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
break;
case "5":
if (newDate.DayOfWeek == System.DayOfWeek.Friday)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = newDate,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
break;
case "6":
if (newDate.DayOfWeek == System.DayOfWeek.Saturday)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = newDate,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
break;
case "7":
if (newDate.DayOfWeek == System.DayOfWeek.Sunday)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = newDate,
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
break;
}
}
}
}
break;
//按月排课
case Common.Enum.Course.ClassStyleEnum.Month:
if (model.WeekDayList != null && model.WeekDayList.Count > 0)
{
foreach (var item in model.WeekDayList)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = Convert.ToDateTime(item),
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
}
break;
//固定日期排课
case Common.Enum.Course.ClassStyleEnum.FixedDate:
{
foreach (var item in model.WeekDayList)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
{
ClassDate = Convert.ToDateTime(item),
ClassId = model.ClassId,
ClassPlanId = 0,
ClassRoomId = model.ClassRoomId,
Group_Id = model.Group_Id,
School_Id = model.School_Id,
PlanTimeList = defaultPlanTimeList
});
}
}
break;
}
model.ClassPlanList = classPlanList;
if (model.ClassPlanList != null && model.ClassPlanList.Count > 0)
{
foreach (var item in model.ClassStepPriceList)
foreach (var item in model.ClassPlanList)
{
item.ClassStepPriceId = 0;
item.ClassId = model.ClassId;
class_StepPriceRepository.Insert(item);
item.ClassPlanId = 0;
if (!class_PlanRepository.CheckExistsRepository(item))
{
//添加班级上课计划
var newClassPlanId = class_PlanRepository.Insert(item);
if (item.PlanTimeList != null && item.PlanTimeList.Count > 0)
{
foreach (var subItem in item.PlanTimeList)
{
subItem.ClassTimeId = 0;
subItem.ClassPlanId = newClassPlanId;
//添加班级上课计划的上课时间
class_TimeRepository.Insert(subItem);
}
}
}
}
}
#endregion
return flag;
}
......
......@@ -21,10 +21,11 @@ namespace Edu.Module.User
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
/// <summary>
/// 学校仓储层对象
/// 岗位仓储层对象
/// </summary>
private readonly RB_SchoolRepository schoolRepository = new RB_SchoolRepository();
private readonly RB_PostRepository postRepository = new RB_PostRepository();
/// <summary>
/// 获取部门分页列表
......@@ -132,19 +133,24 @@ namespace Edu.Module.User
/// 获取部门结构树
/// </summary>
/// <param name="query"></param>
/// <param name="query">是否查询员工</param>
/// <param name="isQueryEmployee">是否查询员工</param>
/// <param name="isQueryPost">是否岗位</param>
/// <returns></returns>
public List<DepartmentTree_ViewModel> GetDepartmentTreeModule(RB_Department_ViewModel query,bool isQueryEmployee=false)
public List<DepartmentTree_ViewModel> GetDepartmentTreeModule(RB_Department_ViewModel query,bool isQueryEmployee=false,bool isQueryPost=false)
{
//树形结构列表
List<DepartmentTree_ViewModel> list = new List<DepartmentTree_ViewModel>();
//所有的部门列表
var deptList = GetDepartmentListModule(query);
//员工列表
var empList = new List<Employee_ViewModel>();
//岗位列表
var postList = new List<RB_Post_ViewModel>();
if (deptList == null)
{
deptList = new List<RB_Department_ViewModel>();
}
//查询员工
if (isQueryEmployee)
{
empList = accountRepository.GetEmployeeListRepository(new Employee_ViewModel()
......@@ -153,6 +159,13 @@ namespace Edu.Module.User
School_Id = query.School_Id
});
}
if (isQueryPost)
{
postList= postRepository.GetPostListRepository(new RB_Post_ViewModel()
{
Group_Id = query.Group_Id,
});
}
if (deptList != null && deptList.Count > 0)
{
var firstList = new List<RB_Department_ViewModel>();
......@@ -200,7 +213,30 @@ namespace Edu.Module.User
}
}
#endregion
var childList = GetDeptTreeList(fItem.DeptId, deptList, empList: empList);
#region 添加岗位
if (isQueryPost)
{
var tempPostList = postList?.Where(qitem => qitem.RB_Dept_Id == fItem.DeptId)?.ToList();
if (tempPostList != null && tempPostList.Count > 0)
{
foreach (var pItem in tempPostList)
{
tModel.ChildList.Add(new DepartmentTree_ViewModel()
{
DeptId = pItem.PostId,
DeptName = pItem.PostName,
ParentId = 0,
ChildList = new List<DepartmentTree_ViewModel>(),
School_Id = fItem.School_Id,
DataType = 3,
});
}
}
}
#endregion
var childList = GetDeptTreeList(fItem.DeptId, deptList, empList: empList,postList:postList);
if (childList != null && childList.Count > 0)
{
tModel.ChildList.AddRange(childList);
......@@ -219,7 +255,7 @@ namespace Edu.Module.User
/// <param name="parentId">父节点编号</param>
/// <param name="sourceList">数据源列表</param>
/// <param name="empList">员工列表</param>
private List<DepartmentTree_ViewModel> GetDeptTreeList(int parentId, List<RB_Department_ViewModel> sourceList, List<Employee_ViewModel> empList=null)
private List<DepartmentTree_ViewModel> GetDeptTreeList(int parentId, List<RB_Department_ViewModel> sourceList, List<Employee_ViewModel> empList=null, List<RB_Post_ViewModel> postList=null)
{
List<DepartmentTree_ViewModel> treeList = new List<DepartmentTree_ViewModel>();
foreach (var item in sourceList.Where(qitem => qitem.ParentId == parentId))
......@@ -234,6 +270,7 @@ namespace Edu.Module.User
IsCompany = item.IsCompany,
DataType = 1,
};
#region 添加员工信息
if (empList != null && empList.Count > 0)
{
......@@ -255,7 +292,30 @@ namespace Edu.Module.User
}
}
#endregion
var childList= GetDeptTreeList(item.DeptId, sourceList);
#region 添加岗位
if (postList != null && postList.Count > 0)
{
var tempPostList = postList?.Where(qitem => qitem.RB_Dept_Id == item.DeptId)?.ToList();
if (tempPostList != null && tempPostList.Count > 0)
{
foreach (var pItem in tempPostList)
{
model.ChildList.Add(new DepartmentTree_ViewModel()
{
DeptId = pItem.PostId,
DeptName = pItem.PostName,
ParentId = 0,
ChildList = new List<DepartmentTree_ViewModel>(),
School_Id = item.School_Id,
DataType = 3,
});
}
}
}
#endregion
var childList = GetDeptTreeList(item.DeptId, sourceList, empList: empList, postList: postList);
if (childList != null && childList.Count > 0)
{
model.ChildList.AddRange(childList);
......
......@@ -3,6 +3,7 @@ using Edu.Model.ViewModel.Course;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB;
namespace Edu.Repository.Course
{
......@@ -38,6 +39,21 @@ WHERE 1=1
return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList();
}
/// <summary>
/// 判断是否存在
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool CheckExistsRepository(RB_Class_Plan_ViewModel model)
{
List<WhereHelper> list = new List<WhereHelper>()
{
new WhereHelper (nameof(RB_Class_Plan_ViewModel.ClassId),model.ClassId),
new WhereHelper (nameof(RB_Class_Plan_ViewModel.ClassDate),model.ClassDate),
};
return base.Exists(list);
}
/// <summary>
/// 根据班级编号删除班级上课计划
/// </summary>
......
......@@ -97,6 +97,7 @@ namespace Edu.WebApi.Controllers.Course
{
var extModel = new RB_Class_ViewModel()
{
ClassId=base.ParmJObj.GetInt("ClassId"),
CreateBy = UserInfo.Id,
CreateTime = DateTime.Now,
UpdateBy = UserInfo.Id,
......@@ -124,6 +125,42 @@ namespace Edu.WebApi.Controllers.Course
CompleteProgress=base.ParmJObj.GetInt("CompleteProgress"),
School_Id=base.ParmJObj.GetInt("School_Id"),
};
try
{
string ClassStepPriceListStr=base.ParmJObj.GetStringValue("ClassStepPriceList");
if (!string.IsNullOrEmpty(ClassStepPriceListStr))
{
extModel.ClassStepPriceList = Common.Plugin.JsonHelper.DeserializeObject<List<RB_Class_StepPrice_ViewModel>>(ClassStepPriceListStr);
}
}
catch(Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "SetClass_ClassStepPriceList");
}
try
{
string WeekDayListStr = base.ParmJObj.GetStringValue("WeekDayList");
if (!string.IsNullOrEmpty(WeekDayListStr))
{
extModel.WeekDayList = Common.Plugin.JsonHelper.DeserializeObject<List<string>>(WeekDayListStr);
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "SetClass_WeekDayList");
}
try
{
string DefaultPlanTimeListStr = base.ParmJObj.GetStringValue("DefaultPlanTimeList");
if (!string.IsNullOrEmpty(DefaultPlanTimeListStr))
{
extModel.DefaultPlanTimeList = Common.Plugin.JsonHelper.DeserializeObject<List<RB_Class_Time_ViewModel>>(DefaultPlanTimeListStr);
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "SetClass_DefaultPlanTimeList");
}
bool flag = classModule.SetClassModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
......@@ -912,6 +912,22 @@ namespace Edu.WebApi.Controllers.User
return ApiResult.Success(data: list);
}
/// <summary>
/// 获取部门岗位树形列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetDeptPostTree()
{
var query = new RB_Department_ViewModel()
{
Group_Id = base.UserInfo.Group_Id,
School_Id = base.ParmJObj.GetInt("School_Id")
};
var list = departmentModule.GetDepartmentTreeModule(query,isQueryPost:true);
return ApiResult.Success(data: list);
}
/// <summary>
/// 获取组织机构图
/// </summary>
......
......@@ -39,6 +39,7 @@ namespace Edu.WebApi
"http://localhost:8400",
"http://localhost:8081",
"http://localhost:8080",
"http://localhost:8181",
"http://localhost:8082",
"http://127.0.0.1:50512",
"http://127.0.0.1:20224",
......
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