修改用户组织,自动更新排班明细
This commit is contained in:
parent
77fcb3b656
commit
dfa9fc852b
@ -743,6 +743,9 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
T_FM_DEPARTMENT departmentInfo = null;
|
||||
List<T_FM_TEAM_PERSON> teamPersons = new List<T_FM_TEAM_PERSON>();
|
||||
List<Guid> teamPersonIds = new List<Guid>();
|
||||
var departScheIds = new List<Guid>();
|
||||
var deleteDepartScheIds = new List<Guid>();
|
||||
List<T_FM_DEPARTMENT_SCHEDULING_DETAIL> departScheDetails = new List<T_FM_DEPARTMENT_SCHEDULING_DETAIL>();
|
||||
if (!string.IsNullOrEmpty(entity.PHONE) && entity.PHONE.Length != 11)
|
||||
{
|
||||
throw new Exception("手机号码应该为11位!");
|
||||
@ -758,10 +761,11 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
// teamPersonIds.Add(teamPersonInfo.ID);
|
||||
//}
|
||||
//if (departmentInfo != null && departmentInfo.DEPARTMENT_TYPE == (int)FMDepartmentType.班组)
|
||||
{
|
||||
//{
|
||||
teamInfo = this.GetEntity<T_FM_TEAM>(t => t.DEPARTMENT_ID == entity.DEPARTMENT_ID);
|
||||
if (teamInfo != null)
|
||||
{
|
||||
departScheIds = this.GetEntities<T_FM_DEPARTMENT_SCHEDULING>(t => t.DEPARTMENT_ID == entity.DEPARTMENT_ID && t.TEAM_ID == teamInfo.ID && t.DATE_TIME >= DateTime.Now.Date && t.START_TIME >= DateTime.Now, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
||||
if (teamPersonInfo == null)
|
||||
{
|
||||
T_FM_TEAM_PERSON teamPerson = new T_FM_TEAM_PERSON();
|
||||
@ -789,7 +793,27 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
if (isExist != null)
|
||||
this.ThrowError("070001");
|
||||
}
|
||||
//删除旧的排班,在新的排班里面加入
|
||||
deleteDepartScheIds = this.GetEntities<T_FM_DEPARTMENT_SCHEDULING_DETAIL>(t =>t.Nav_DepartmentScheduling!=null && t.Nav_DepartmentScheduling.DATE_TIME >= DateTime.Now.Date && t.Nav_DepartmentScheduling.START_TIME >= DateTime.Now && t.PERSON_ID == entity.PERSON_ID,new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
||||
if (departScheIds != null && departScheIds.Any())
|
||||
{
|
||||
var departScheDetailTemps = this.GetEntities<T_FM_DEPARTMENT_SCHEDULING_DETAIL>(t => departScheIds.Contains(t.DEPARTMENT_SCHEDULING_ID) && t.PERSON_ID == entity.PERSON_ID, new BaseFilter(entity.ORG_ID)).ToList();
|
||||
foreach (var id in departScheIds)
|
||||
{
|
||||
var detail = departScheDetailTemps.FirstOrDefault(t => t.DEPARTMENT_SCHEDULING_ID == id);
|
||||
if (detail == null)
|
||||
{
|
||||
T_FM_DEPARTMENT_SCHEDULING_DETAIL de = new T_FM_DEPARTMENT_SCHEDULING_DETAIL();
|
||||
de.ORG_ID = entity.ORG_ID;
|
||||
de.DEPARTMENT_SCHEDULING_ID = id;
|
||||
de.PERSON_ID = entity.PERSON_ID.Value;
|
||||
departScheDetails.Add(de);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
if (entity.APPROVE_ROLE_ID != null)
|
||||
{
|
||||
var isExist = userList.FirstOrDefault(t => t.APPROVE_ROLE_ID == entity.APPROVE_ROLE_ID && t.DEPARTMENT_ID == entity.DEPARTMENT_ID && t.ENABLE_STATUS == 0 && t.Nav_Department != null && t.Nav_Department.DEPARTMENT_TYPE != 3);
|
||||
@ -1090,6 +1114,10 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
this.DeleteEntityNoCommit<T_FM_TEAM_PERSON>(t => teamPersonIds.Contains(t.ID));
|
||||
if (noticeToday != null)
|
||||
this.UpdateEntityNoCommit(noticeToday);
|
||||
if (deleteDepartScheIds!=null && deleteDepartScheIds.Any())
|
||||
this.BantchDeleteEntityNoCommit<T_FM_DEPARTMENT_SCHEDULING_DETAIL>(deleteDepartScheIds);
|
||||
if (departScheDetails != null && departScheDetails.Any())
|
||||
this.BantchSaveEntityNoCommit(departScheDetails);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user