优化
This commit is contained in:
parent
d8963ba9be
commit
e36ad56fc3
@ -692,6 +692,10 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
else
|
||||
{
|
||||
var departInfo = this.GetEntity<T_FM_DEPARTMENT>(entity.DEPARTMENT_ID.ToString());
|
||||
if (departInfo.CATEGORY == FMCATEGORY.VIRTUAL)
|
||||
{
|
||||
throw new Exception("人员不允许挂到虚拟组织结构!");
|
||||
}
|
||||
if (departInfo != null && departInfo.PRODUCTION_UNIT_ID != null && departInfo.MineType != null && isAdd == null)
|
||||
{
|
||||
var enumList = this.GetEntity<T_FM_ENUMS>(t => t.CODE == "BSMineTypeEnum" && t.VALUE == departInfo.MineType);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Entities.PF;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
@ -1381,15 +1381,36 @@ namespace APT.FO.WebApi.Controllers
|
||||
//List<Guid> userNewIds = new List<Guid>();
|
||||
//userNewIds.Add((Guid)applyUserId);
|
||||
var userVacations = this.GetEntities<T_FM_USER_VACATION_SET>(t => t.START_DATE <= DateTime.Now && t.END_DATE >= DateTime.Now, new BaseFilter(approveTemp.ORG_ID), "Nav_Agent");
|
||||
approveTemp.Nav_ApproveTempDetails.ForEach(t =>
|
||||
// 按 (NUM, NAME, APPROVE_ROLE_ID) 去重,防止审批模板子表有重复记录导致生成重复审批节点
|
||||
var distinctTempDetails = approveTemp.Nav_ApproveTempDetails
|
||||
.GroupBy(t => new { t.NUM, t.NAME, t.APPROVE_ROLE_ID })
|
||||
.Select(g => g.First())
|
||||
.OrderBy(t => t.NUM)
|
||||
.ToList();
|
||||
distinctTempDetails.ForEach(t =>
|
||||
{
|
||||
var userList = new List<Guid?>();
|
||||
userIds.ForEach(x =>
|
||||
{
|
||||
var userId = GetApproveUser(t,entity, users, departs, roles,(Guid)x);
|
||||
var userAgent = userVacations.FirstOrDefault(t => t.USER_ID == userId);
|
||||
if (userId != null)
|
||||
{
|
||||
// 过滤:userId 对应的用户必须是启用状态(ENABLE_STATUS == 0)
|
||||
var targetUser = users.FirstOrDefault(u => u.ID == userId);
|
||||
if (targetUser != null && targetUser.ENABLE_STATUS == 0)
|
||||
{
|
||||
var userAgent = userVacations.FirstOrDefault(v => v.USER_ID == userId);
|
||||
var detailUserAgent = userAgent != null && userAgent.AGENT_ID != null ? userAgent.AGENT_ID : userId;
|
||||
// 代理也必须是启用状态
|
||||
if (detailUserAgent != userId)
|
||||
{
|
||||
var agentUser = users.FirstOrDefault(u => u.ID == detailUserAgent);
|
||||
if (agentUser == null || agentUser.ENABLE_STATUS != 0)
|
||||
detailUserAgent = userId; // 代理被禁用,回退到原审批人
|
||||
}
|
||||
userList.Add(detailUserAgent);
|
||||
}
|
||||
}
|
||||
});
|
||||
userList = userList.Distinct().ToList();
|
||||
if (userList != null && userList.Any())
|
||||
@ -1405,7 +1426,18 @@ namespace APT.FO.WebApi.Controllers
|
||||
detail.NUM = t.NUM;
|
||||
detail.APPROVE_ROLE_ID = t.APPROVE_ROLE_ID;
|
||||
detail.IS_ALLOW_UPDATE = t.IS_ALLOW_UPDATE;
|
||||
detail.APPROVE_USER_ID = t.DEFAULT_APPROVE_USER_ID != null ? t.DEFAULT_APPROVE_USER_ID : m;
|
||||
// DEFAULT_APPROVE_USER_ID 也必须是启用用户,否则回退到动态匹配的 m
|
||||
if (t.DEFAULT_APPROVE_USER_ID != null)
|
||||
{
|
||||
var defaultUser = users.FirstOrDefault(u => u.ID == t.DEFAULT_APPROVE_USER_ID);
|
||||
detail.APPROVE_USER_ID = (defaultUser != null && defaultUser.ENABLE_STATUS == 0)
|
||||
? t.DEFAULT_APPROVE_USER_ID
|
||||
: m;
|
||||
}
|
||||
else
|
||||
{
|
||||
detail.APPROVE_USER_ID = m;
|
||||
}
|
||||
if (detail.APPROVE_USER_ID == applyUserId)
|
||||
{
|
||||
detail.NODE_APPROVE_STATUS = (int)NodeApproveStatus.Done;
|
||||
@ -1686,7 +1718,14 @@ namespace APT.FO.WebApi.Controllers
|
||||
if (approve != null)
|
||||
AddEntityNoCommit(approve);
|
||||
if (appdetails != null && appdetails.Any())
|
||||
{
|
||||
// 最终防御去重:按 (NUM, NAME, APPROVE_USER_ID) 分组,防止同节点同审批人被重复添加
|
||||
appdetails = appdetails
|
||||
.GroupBy(t => new { t.NUM, t.NAME, t.APPROVE_USER_ID })
|
||||
.Select(g => g.First())
|
||||
.ToList();
|
||||
BantchAddEntityNoCommit(appdetails);
|
||||
}
|
||||
if (appdetailAutos != null && appdetailAutos.Any())
|
||||
BantchAddEntityNoCommit(appdetailAutos);
|
||||
if (finishNotice != null)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Entities.FM;
|
||||
using APT.BaseData.Domain.Entities;
|
||||
using APT.BaseData.Domain.Enums;
|
||||
using APT.BaseData.Services.DomainServices;
|
||||
@ -326,16 +326,33 @@ namespace APT.FO.WebApi.Controllers
|
||||
//var otherUser = users.Where(t => userIds.Contains(t.ID) && t.ID != applyUserId).ToList();
|
||||
//List<Guid> userNewIds = new List<Guid>();
|
||||
//userNewIds.Add((Guid)applyUserId);
|
||||
approveTemp.Nav_ApproveTempDetails.ForEach(t =>
|
||||
approveTemp.Nav_ApproveTempDetails
|
||||
.GroupBy(t => new { t.NUM, t.NAME, t.APPROVE_ROLE_ID })
|
||||
.Select(g => g.First())
|
||||
.OrderBy(t => t.NUM)
|
||||
.ToList()
|
||||
.ForEach(t =>
|
||||
{
|
||||
var userList = new List<Guid?>();
|
||||
userIds.ForEach(x =>
|
||||
{
|
||||
var userId = GetApproveUser(t, entity, users, departs, roles, (Guid)x);
|
||||
var userAgent = userVacations.FirstOrDefault(t => t.USER_ID == userId);
|
||||
if (userId != null)
|
||||
{
|
||||
var targetUser = users.FirstOrDefault(u => u.ID == userId);
|
||||
if (targetUser != null && targetUser.ENABLE_STATUS == 0)
|
||||
{
|
||||
var userAgent = userVacations.FirstOrDefault(v => v.USER_ID == userId);
|
||||
var detailUserAgent = userAgent != null && userAgent.AGENT_ID != null ? userAgent.AGENT_ID : userId;
|
||||
if (detailUserAgent != userId)
|
||||
{
|
||||
var agentUser = users.FirstOrDefault(u => u.ID == detailUserAgent);
|
||||
if (agentUser == null || agentUser.ENABLE_STATUS != 0)
|
||||
detailUserAgent = userId;
|
||||
}
|
||||
userList.Add(detailUserAgent);
|
||||
//userList.Add(GetApproveUser(t,entity, users, (Guid)x));
|
||||
}
|
||||
}
|
||||
});
|
||||
userList = userList.Distinct().ToList();
|
||||
if (userList != null && userList.Any())
|
||||
@ -351,7 +368,17 @@ namespace APT.FO.WebApi.Controllers
|
||||
detail.NUM = t.NUM;
|
||||
detail.APPROVE_ROLE_ID = t.APPROVE_ROLE_ID;
|
||||
detail.IS_ALLOW_UPDATE = t.IS_ALLOW_UPDATE;
|
||||
detail.APPROVE_USER_ID = t.DEFAULT_APPROVE_USER_ID != null ? t.DEFAULT_APPROVE_USER_ID : m;
|
||||
if (t.DEFAULT_APPROVE_USER_ID != null)
|
||||
{
|
||||
var defaultUser = users.FirstOrDefault(u => u.ID == t.DEFAULT_APPROVE_USER_ID);
|
||||
detail.APPROVE_USER_ID = (defaultUser != null && defaultUser.ENABLE_STATUS == 0)
|
||||
? t.DEFAULT_APPROVE_USER_ID
|
||||
: m;
|
||||
}
|
||||
else
|
||||
{
|
||||
detail.APPROVE_USER_ID = m;
|
||||
}
|
||||
if (detail.APPROVE_USER_ID == applyUserId)
|
||||
{
|
||||
detail.NODE_APPROVE_STATUS = (int)NodeApproveStatus.Done;
|
||||
@ -586,7 +613,13 @@ namespace APT.FO.WebApi.Controllers
|
||||
if (approve != null)
|
||||
AddEntityNoCommit(approve);
|
||||
if (appdetails != null && appdetails.Any())
|
||||
{
|
||||
appdetails = appdetails
|
||||
.GroupBy(t => new { t.NUM, t.NAME, t.APPROVE_USER_ID })
|
||||
.Select(g => g.First())
|
||||
.ToList();
|
||||
BantchAddEntityNoCommit(appdetails);
|
||||
}
|
||||
if (appdetailAutos != null && appdetailAutos.Any())
|
||||
BantchAddEntityNoCommit(appdetailAutos);
|
||||
if (finishNotice != null)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user