1
This commit is contained in:
parent
de2ce97034
commit
d4d40a225d
@ -1,24 +1,24 @@
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using APT.BaseData.Domain.IServices.FM;
|
||||
|
||||
using APT.Utility;
|
||||
using APT.BaseData.Domain.ApiModel;
|
||||
using APT.BaseData.Domain.Entities.BD;
|
||||
using System.Linq;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using APT.BaseData.Services.Services.FM;
|
||||
using APT.BaseData.Domain.IServices;
|
||||
using APT.BaseData.Services.DomainServices;
|
||||
using NPOI.Util;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using APT.BaseData.Domain.ApiModel;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using APT.MS.Domain.Entities.PF;
|
||||
using APT.BaseData.Domain.Enums.PF;
|
||||
using APT.BaseData.Domain.IServices;
|
||||
using APT.BaseData.Domain.IServices.FM;
|
||||
using APT.BaseData.Services.DomainServices;
|
||||
using APT.BaseData.Services.Services.FM;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.MS.Domain.Entities.PF;
|
||||
using APT.Utility;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using NPOI.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
{
|
||||
@ -384,17 +384,19 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
{
|
||||
//var safeUser = entity==null?null:entity.Nav_SafeUser;
|
||||
//entity.Nav_SafeUser = null;
|
||||
T_FM_TEAM teamInfo = null;
|
||||
T_FM_TEAM addTeamInfo = null;
|
||||
T_FM_TEAM updateTeamInfo = null;
|
||||
var teamInfos = new List<T_FM_TEAM>();
|
||||
if (entity.DEPARTMENT_TYPE == (int)FMDepartmentType.Class)
|
||||
{
|
||||
teamInfo = this.GetEntity<T_FM_TEAM>(t => t.DEPARTMENT_ID == entity.ID);
|
||||
var teamInfo = this.GetEntity<T_FM_TEAM>(t => t.DEPARTMENT_ID == entity.ID);
|
||||
if (teamInfo == null)
|
||||
{
|
||||
teamInfo = new T_FM_TEAM()
|
||||
addTeamInfo = new T_FM_TEAM()
|
||||
{
|
||||
NAME = entity.NAME,
|
||||
DEPARTMENT_ID = entity.ID,
|
||||
//CHARGE_PERSON_ID = user.PERSON_ID,
|
||||
//CHARGE_PERSON_ID = entity.USER_ID,
|
||||
ORG_ID = entity.ORG_ID,
|
||||
ID = Guid.NewGuid(),
|
||||
};
|
||||
@ -404,14 +406,10 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
teamInfo.NAME = entity.NAME;
|
||||
teamInfo.DEPARTMENT_ID = entity.ID;
|
||||
//teamInfo.CHARGE_PERSON_ID = entity.USER_ID;
|
||||
updateTeamInfo = teamInfo;
|
||||
}
|
||||
}
|
||||
if (entity.USER_ID != null)
|
||||
{
|
||||
var user = this.GetEntity<T_FM_USER>(t => t.ID == entity.USER_ID);
|
||||
if (teamInfo != null)
|
||||
teamInfo.CHARGE_PERSON_ID = user.PERSON_ID;
|
||||
}
|
||||
|
||||
//List<T_FM_DEPARTMENT_PRODUCTION_UNIT> productionUnit = null;
|
||||
entity.Nav_ProdutionUnit = null;
|
||||
//if (productionUnit != null && productionUnit.Any())
|
||||
@ -424,8 +422,10 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
//}
|
||||
var unitList = new List<T_FM_DEPARTMENT_PRODUCTION_UNIT>();
|
||||
var userUnitList = new List<T_FM_USER_PRODUCTION_UNIT>();
|
||||
var departmentList = new List<T_FM_DEPARTMENT>();
|
||||
var userList = new List<T_FM_USER>();
|
||||
var departUpdateList = new List<T_FM_DEPARTMENT>();
|
||||
var entityUpdateList = new List<T_FM_DEPARTMENT>();
|
||||
var userUpdateList = new List<T_FM_USER>();
|
||||
var userList = this.GetEntities<T_FM_USER>(t => t.ENABLE_STATUS == 0, new BaseFilter(entity.ORG_ID), "Nav_ProdutionUnit").ToList();
|
||||
var deleteDepartIds = new List<Guid>();
|
||||
var deleteUserIds = new List<Guid>();
|
||||
if (entity.PRODUCTION_UNIT_ID != null)
|
||||
@ -435,14 +435,17 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
//查所有下级部门组织
|
||||
List<Guid> departmentId = new List<Guid>();
|
||||
departmentId.Add(entity.ID);
|
||||
List<Guid> departmentIds = new List<Guid>() { entity.ID };
|
||||
List<Guid> departmentIds = new List<Guid>();
|
||||
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
|
||||
DepartmentService.GetDepartmentIds(orgId, departmentId, ref departmentIds);
|
||||
departmentList = this.GetEntities<T_FM_DEPARTMENT>(t => departmentIds.Contains(t.ID) && t.ENABLE_STATUS == 0, new BaseFilter(orgId), "Nav_ProdutionUnit").ToList();
|
||||
departmentList.ForEach(t =>
|
||||
{
|
||||
var departmentList = this.GetEntities<T_FM_DEPARTMENT>(t => departmentIds.Contains(t.ID) && t.ENABLE_STATUS == 0, new BaseFilter(orgId), "Nav_ProdutionUnit").ToList();
|
||||
foreach (var t in departmentList)
|
||||
{
|
||||
t.ENABLE_STATUS = entity.ENABLE_STATUS;
|
||||
t.IS_DELETED = entity.IS_DELETED;
|
||||
t.MineType = entity.MineType;
|
||||
t.PRODUCTION_UNIT_ID = entity.PRODUCTION_UNIT_ID;
|
||||
departUpdateList.Add(t);
|
||||
T_FM_DEPARTMENT_PRODUCTION_UNIT unit = new T_FM_DEPARTMENT_PRODUCTION_UNIT();
|
||||
unit.ORG_ID = t.ORG_ID; unit.DEPARTMENT_ID = t.ID; //unit.ENUMS_ID = enumList?.ID;
|
||||
unit.Nav_Enums = null; unit.DEPART_UNIT_ID = entity.PRODUCTION_UNIT_ID;
|
||||
@ -452,10 +455,10 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
var ids = t.Nav_ProdutionUnit.Select(t => t.ID).ToList();
|
||||
deleteDepartIds.AddRange(ids);
|
||||
}
|
||||
});
|
||||
}
|
||||
//departmentList.ForEach(t => t.MineType = entity.MineType);
|
||||
userList = this.GetEntities<T_FM_USER>(t => departmentIds.Contains(t.DEPARTMENT_ID.Value) && t.ENABLE_STATUS == 0, new BaseFilter(orgId), "Nav_ProdutionUnit").ToList();
|
||||
userList.ForEach(t =>
|
||||
var userListTemp = userList.Where(t => t.DEPARTMENT_ID!=null && departmentIds.Contains(t.DEPARTMENT_ID.Value)).ToList();
|
||||
userListTemp.ForEach(t =>
|
||||
{
|
||||
//var enumValues = new List<string>();
|
||||
//productionUnit.ForEach(t1 =>
|
||||
@ -468,6 +471,7 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
// enumValues.Add(value);
|
||||
//});
|
||||
//t.MineType = string.Join(",", enumValues);
|
||||
userUpdateList.Add(t);
|
||||
T_FM_USER_PRODUCTION_UNIT unit = new T_FM_USER_PRODUCTION_UNIT();
|
||||
unit.ORG_ID = t.ORG_ID; unit.USER_ID = t.ID; //unit.ENUMS_ID = enumList?.ID;
|
||||
unit.Nav_Enums = null; unit.PRODUCTION_UNIT_ID = entity.PRODUCTION_UNIT_ID;
|
||||
@ -479,42 +483,58 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
}
|
||||
});
|
||||
}
|
||||
if (entity.USER_ID != null)
|
||||
{
|
||||
var user = userList.FirstOrDefault(t => t.ID == entity.USER_ID);
|
||||
if (addTeamInfo != null)
|
||||
addTeamInfo.CHARGE_PERSON_ID = user.PERSON_ID;
|
||||
if (updateTeamInfo != null)
|
||||
updateTeamInfo.CHARGE_PERSON_ID = user.PERSON_ID;
|
||||
}
|
||||
if (entity.ENABLE_STATUS == 1)
|
||||
{
|
||||
entity.IS_DELETED = true;
|
||||
if (teamInfo != null)
|
||||
if (updateTeamInfo != null)
|
||||
{
|
||||
teamInfo.ENABLE_STATUS = 1;
|
||||
teamInfo.IS_DELETED = true;
|
||||
}
|
||||
foreach (var item in unitList.Where(m => m.DEPARTMENT_ID == entity.ID))
|
||||
{
|
||||
item.IS_DELETED = true;
|
||||
updateTeamInfo.ENABLE_STATUS = 1;
|
||||
updateTeamInfo.IS_DELETED = true;
|
||||
teamInfos.Add(updateTeamInfo);
|
||||
}
|
||||
}
|
||||
entityUpdateList.Add(entity);
|
||||
foreach (var item in departUpdateList)
|
||||
{
|
||||
item.Nav_User = null; item.Nav_ProdutionUnit = null; item.Nav_Unit = null; item.Nav_Parent = null; item.Nav_DepartmentUser = null;
|
||||
}
|
||||
foreach (var item in entityUpdateList)
|
||||
{
|
||||
item.Nav_User = null; item.Nav_ProdutionUnit = null; item.Nav_Unit = null; item.Nav_Parent = null;item.Nav_DepartmentUser = null;
|
||||
}
|
||||
this.UnifiedCommit(() =>
|
||||
{
|
||||
//BantchUpdateEntity_noneBase
|
||||
//if (safeUser != null && safeUser.Any())
|
||||
// this.BantchSaveEntityNoCommit(safeUser);
|
||||
if (teamInfo != null)
|
||||
this.UpdateEntityNoCommit(teamInfo);
|
||||
//if (productionUnit != null && productionUnit.Any())
|
||||
// this.BantchSaveEntityNoCommit(productionUnit);
|
||||
if (addTeamInfo != null)
|
||||
this.UpdateEntityNoCommit(addTeamInfo);
|
||||
if (deleteDepartIds != null && deleteDepartIds.Any())
|
||||
this.BantchDeleteEntityNoCommit<T_FM_DEPARTMENT_PRODUCTION_UNIT>(deleteDepartIds);
|
||||
if (deleteUserIds != null && deleteUserIds.Any())
|
||||
this.BantchDeleteEntityNoCommit<T_FM_USER_PRODUCTION_UNIT>(deleteUserIds);
|
||||
if (departmentList != null && departmentList.Any())
|
||||
this.BantchSaveEntityNoCommit(departmentList);
|
||||
if (userList != null && userList.Any())
|
||||
this.BantchSaveEntityNoCommit(userList);
|
||||
if (userUpdateList != null && userUpdateList.Any())
|
||||
this.BantchSaveEntityNoCommit(userUpdateList);
|
||||
if (unitList != null && unitList.Any())
|
||||
this.BantchSaveEntityNoCommit(unitList);
|
||||
if (userUnitList != null && userUnitList.Any())
|
||||
this.BantchSaveEntityNoCommit(userUnitList);
|
||||
if (entity != null)
|
||||
this.UpdateEntityNoCommit(entity);
|
||||
if (departUpdateList != null && departUpdateList.Any())
|
||||
this.BantchUpdateEntity_noneBase(departUpdateList);
|
||||
if (teamInfos != null && teamInfos.Any())
|
||||
this.BantchUpdateEntity_noneBase(teamInfos);
|
||||
if (entityUpdateList != null && entityUpdateList.Any())
|
||||
this.BantchUpdateEntity_noneBase(entityUpdateList);
|
||||
//if (entity != null)
|
||||
// this.UpdateEntityNoCommit(entity);
|
||||
});
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -2779,10 +2779,13 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
return SafeExecute<bool>(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var teamLists = new List<T_FM_TEAM>();
|
||||
var teamPersonLists = new List<T_FM_TEAM_PERSON>();
|
||||
var teamPersonIds = new List<Guid>();
|
||||
{
|
||||
var departLists = new List<T_FM_DEPARTMENT>();
|
||||
var teamAddLists = new List<T_FM_TEAM>();
|
||||
var teamUpdateLists = new List<T_FM_TEAM>();
|
||||
var teamPersonAddLists = new List<T_FM_TEAM_PERSON>();
|
||||
var teamPersonUpdateLists = new List<T_FM_TEAM_PERSON>();
|
||||
var deleteTeamPersonIds = new List<Guid>();
|
||||
var departs = this.GetEntities_noneBase<T_FM_DEPARTMENT>(t => t.DEPARTMENT_TYPE == (int)FMDepartmentType.Class);
|
||||
var departIds = departs.Select(t => t.ID).ToList();
|
||||
var teams = this.GetEntities_noneBase<T_FM_TEAM>(t => true);
|
||||
@ -2795,79 +2798,84 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
var departInfo = departs.FirstOrDefault(t => t.ID == item);
|
||||
var userInfo = users.FirstOrDefault(t => t.ID == departInfo?.USER_ID);
|
||||
var persons = users.Where(t => t.DEPARTMENT_ID == item && t.PERSON_ID != null).ToList();
|
||||
var teamInfo = teams.FirstOrDefault(t => t.DEPARTMENT_ID == item);
|
||||
if (teamInfo == null)
|
||||
var teamInfo = teams.FirstOrDefault(t => t.DEPARTMENT_ID == item);
|
||||
if (teamInfo == null)
|
||||
{
|
||||
if (departInfo.IS_DELETED == false)
|
||||
{
|
||||
if (departInfo.IS_DELETED == false)
|
||||
T_FM_TEAM team = new T_FM_TEAM();
|
||||
team.ORG_ID = filter.OrgId;
|
||||
team.CHARGE_PERSON_ID = userInfo?.PERSON_ID;
|
||||
team.NAME = departInfo.NAME;
|
||||
team.ENABLE_STATUS = 0;
|
||||
team.DEPARTMENT_ID = item;
|
||||
team.ENABLE_STATUS = departInfo.ENABLE_STATUS;
|
||||
team.IS_DELETED = departInfo.IS_DELETED;
|
||||
teamAddLists.Add(team);
|
||||
if (persons != null && persons.Any())
|
||||
{
|
||||
T_FM_TEAM team = new T_FM_TEAM();
|
||||
team.ORG_ID = filter.OrgId;
|
||||
team.CHARGE_PERSON_ID = userInfo?.PERSON_ID;
|
||||
team.NAME = departInfo.NAME;
|
||||
team.ENABLE_STATUS = 0;
|
||||
team.DEPARTMENT_ID = item;
|
||||
team.ENABLE_STATUS = departInfo.ENABLE_STATUS;
|
||||
team.IS_DELETED = departInfo.IS_DELETED;
|
||||
teamLists.Add(team);
|
||||
foreach (var per in persons)
|
||||
{
|
||||
T_FM_TEAM_PERSON person = new T_FM_TEAM_PERSON();
|
||||
person.ORG_ID = filter.OrgId;
|
||||
person.TEAM_ID = team.ID;
|
||||
person.PERSON_ID = (Guid)per.PERSON_ID;
|
||||
person.IS_DELETED = departInfo.IS_DELETED;
|
||||
teamPersonAddLists.Add(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
teamInfo.CHARGE_PERSON_ID = userInfo?.PERSON_ID;
|
||||
if (departInfo.IS_DELETED == true || departInfo.ENABLE_STATUS == 1)
|
||||
{
|
||||
departInfo.IS_DELETED = true;
|
||||
departInfo.ENABLE_STATUS = 1;
|
||||
departLists.Add(departInfo);
|
||||
teamInfo.ENABLE_STATUS = 1;
|
||||
teamInfo.IS_DELETED = true;
|
||||
teamUpdateLists.Add(teamInfo);
|
||||
foreach (var item1 in teamPersons.Where(t => t.TEAM_ID == teamInfo.ID))
|
||||
{
|
||||
item1.IS_DELETED = true;
|
||||
teamPersonUpdateLists.Add(item1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var teamPersonIds = teamPersons.Where(t => t.TEAM_ID == teamInfo.ID).Select(m => m.ID).ToList();
|
||||
deleteTeamPersonIds.AddRange(teamPersonIds);
|
||||
if (persons != null && persons.Any())
|
||||
{
|
||||
foreach (var per in persons)
|
||||
{
|
||||
T_FM_TEAM_PERSON person = new T_FM_TEAM_PERSON();
|
||||
person.ORG_ID = filter.OrgId;
|
||||
person.TEAM_ID = team.ID;
|
||||
person.TEAM_ID = teamInfo.ID;
|
||||
person.PERSON_ID = (Guid)per.PERSON_ID;
|
||||
person.IS_DELETED = departInfo.IS_DELETED;
|
||||
teamPersonLists.Add(person);
|
||||
teamPersonAddLists.Add(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
teamInfo.CHARGE_PERSON_ID = userInfo?.PERSON_ID;
|
||||
teamInfo.ENABLE_STATUS = departInfo.ENABLE_STATUS;
|
||||
teamInfo.IS_DELETED = departInfo.IS_DELETED;
|
||||
teamLists.Add(teamInfo);
|
||||
if (teamInfo.IS_DELETED == true)
|
||||
{
|
||||
foreach (var item1 in teamPersons.Where(t => t.TEAM_ID == teamInfo.ID))
|
||||
{
|
||||
item1.IS_DELETED = true;
|
||||
teamPersonLists.Add(item1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var personIds = teamPersons.Where(t => t.TEAM_ID == teamInfo.ID).Select(m => m.PERSON_ID).ToList();
|
||||
if (persons != null && persons.Any())
|
||||
{
|
||||
foreach (var per in persons)
|
||||
{
|
||||
if (!personIds.Contains((Guid)per.PERSON_ID))
|
||||
{
|
||||
T_FM_TEAM_PERSON person = new T_FM_TEAM_PERSON();
|
||||
person.ORG_ID = filter.OrgId;
|
||||
person.TEAM_ID = teamInfo.ID;
|
||||
person.PERSON_ID = (Guid)per.PERSON_ID;
|
||||
teamPersonLists.Add(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
var deletePersonId = teamPersonLists.Select(t => t.PERSON_ID).ToList();
|
||||
teamPersonIds = teamPersons.Where(t => personIds.Contains(t.PERSON_ID) && t.TEAM_ID != teamInfo.ID).Select(m => m.ID).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UnifiedCommit(() =>
|
||||
{
|
||||
if (teamPersonLists != null && teamPersonLists.Any())
|
||||
BantchUpdateEntity_noneBase(teamPersonLists);
|
||||
if (teamLists != null && teamLists.Any())
|
||||
BantchUpdateEntity_noneBase(teamLists);
|
||||
if (teamPersonIds != null && teamPersonIds.Any())
|
||||
BantchDeleteEntityNoCommit<T_FM_TEAM_PERSON>(teamPersonIds);
|
||||
if (deleteTeamPersonIds != null && deleteTeamPersonIds.Any())
|
||||
BantchDeleteEntityNoCommit<T_FM_TEAM_PERSON>(deleteTeamPersonIds);
|
||||
if (teamAddLists != null && teamAddLists.Any())
|
||||
BantchSaveEntityNoCommit(teamAddLists);
|
||||
if (teamPersonAddLists != null && teamPersonAddLists.Any())
|
||||
BantchSaveEntityNoCommit(teamPersonAddLists);
|
||||
if (teamPersonUpdateLists != null && teamPersonUpdateLists.Any())
|
||||
BantchUpdateEntity_noneBase(teamPersonUpdateLists);
|
||||
if (teamUpdateLists != null && teamUpdateLists.Any())
|
||||
BantchUpdateEntity_noneBase(teamUpdateLists);
|
||||
if (departLists != null && departLists.Any())
|
||||
BantchUpdateEntity_noneBase(departLists);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user