修改用户组织,自动更新排班明细
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;
|
T_FM_DEPARTMENT departmentInfo = null;
|
||||||
List<T_FM_TEAM_PERSON> teamPersons = new List<T_FM_TEAM_PERSON>();
|
List<T_FM_TEAM_PERSON> teamPersons = new List<T_FM_TEAM_PERSON>();
|
||||||
List<Guid> teamPersonIds = new List<Guid>();
|
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)
|
if (!string.IsNullOrEmpty(entity.PHONE) && entity.PHONE.Length != 11)
|
||||||
{
|
{
|
||||||
throw new Exception("手机号码应该为11位!");
|
throw new Exception("手机号码应该为11位!");
|
||||||
@ -752,44 +755,65 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
|||||||
departmentInfo = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == entity.DEPARTMENT_ID && t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用);
|
departmentInfo = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == entity.DEPARTMENT_ID && t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用);
|
||||||
if (departmentInfo == null)
|
if (departmentInfo == null)
|
||||||
throw new Exception("组织架构已失效,请重新选择!");
|
throw new Exception("组织架构已失效,请重新选择!");
|
||||||
var teamPersonInfo = this.GetEntity<T_FM_TEAM_PERSON>(t => t.PERSON_ID == entity.PERSON_ID);
|
var teamPersonInfo = this.GetEntity<T_FM_TEAM_PERSON>(t => t.PERSON_ID == entity.PERSON_ID);
|
||||||
//if (teamPersonInfo != null)
|
//if (teamPersonInfo != null)
|
||||||
//{
|
//{
|
||||||
// teamPersonIds.Add(teamPersonInfo.ID);
|
// teamPersonIds.Add(teamPersonInfo.ID);
|
||||||
//}
|
//}
|
||||||
//if (departmentInfo != null && departmentInfo.DEPARTMENT_TYPE == (int)FMDepartmentType.班组)
|
//if (departmentInfo != null && departmentInfo.DEPARTMENT_TYPE == (int)FMDepartmentType.班组)
|
||||||
{
|
//{
|
||||||
teamInfo = this.GetEntity<T_FM_TEAM>(t => t.DEPARTMENT_ID == entity.DEPARTMENT_ID);
|
teamInfo = this.GetEntity<T_FM_TEAM>(t => t.DEPARTMENT_ID == entity.DEPARTMENT_ID);
|
||||||
if (teamInfo != null)
|
if (teamInfo != null)
|
||||||
{
|
{
|
||||||
if (teamPersonInfo == 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();
|
{
|
||||||
teamPerson.PERSON_ID = person.ID;
|
T_FM_TEAM_PERSON teamPerson = new T_FM_TEAM_PERSON();
|
||||||
teamPerson.TEAM_ID = teamInfo.ID;
|
teamPerson.PERSON_ID = person.ID;
|
||||||
teamPerson.ORG_ID = teamInfo.ORG_ID;
|
teamPerson.TEAM_ID = teamInfo.ID;
|
||||||
teamPersons.Add(teamPerson);
|
teamPerson.ORG_ID = teamInfo.ORG_ID;
|
||||||
}
|
teamPersons.Add(teamPerson);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
teamPersonInfo.PERSON_ID = person.ID;
|
{
|
||||||
teamPersonInfo.TEAM_ID = teamInfo.ID;
|
teamPersonInfo.PERSON_ID = person.ID;
|
||||||
teamPersons.Add(teamPersonInfo);
|
teamPersonInfo.TEAM_ID = teamInfo.ID;
|
||||||
}
|
teamPersons.Add(teamPersonInfo);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
if (teamPersonInfo != null)
|
{
|
||||||
teamPersonIds.Add(teamPersonInfo.ID);
|
if (teamPersonInfo != null)
|
||||||
}
|
teamPersonIds.Add(teamPersonInfo.ID);
|
||||||
personTeam = teamPersons;
|
}
|
||||||
if (entity.APPROVE_ROLE_ID != null)
|
personTeam = teamPersons;
|
||||||
{
|
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);
|
{
|
||||||
if (isExist != null)
|
var isExist = userList.FirstOrDefault(t => t.APPROVE_ROLE_ID == entity.APPROVE_ROLE_ID && t.DEPARTMENT_ID == entity.DEPARTMENT_ID && t.ENABLE_STATUS == 0);
|
||||||
this.ThrowError("070001");
|
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)
|
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);
|
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);
|
||||||
@ -1089,7 +1113,11 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
|||||||
if (teamPersonIds.Any())
|
if (teamPersonIds.Any())
|
||||||
this.DeleteEntityNoCommit<T_FM_TEAM_PERSON>(t => teamPersonIds.Contains(t.ID));
|
this.DeleteEntityNoCommit<T_FM_TEAM_PERSON>(t => teamPersonIds.Contains(t.ID));
|
||||||
if (noticeToday != null)
|
if (noticeToday != null)
|
||||||
this.UpdateEntityNoCommit(noticeToday);
|
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