Merge branch 'master' into development

This commit is contained in:
2024-10-10 18:29:21 +08:00
44 changed files with 710 additions and 426 deletions

View File

@@ -11,7 +11,7 @@ public class GainfoMealPageRequest : PageDto
public DateTimePeriod SearchDateTimePeriod { get; set; }
/// <summary>
/// 是否离职
/// 是否查询离职
/// </summary>
public bool IsLeave { get; set; }
}

View File

@@ -89,12 +89,14 @@ public class GainfoGroupService : IGainfoGroupService
.ToListAsync();
await _dbContext.DeleteAsync(relations);
request.UserNos = await _dbContext.Queryable<GainfoEntity>()
.Where(x => request.UserNos.Contains(x.No) || request.UserNos.Contains(x.Code))
var userNos = await _dbContext.Queryable<GainfoEntity>()
.Where(x => request.UserNos.Contains(x.No) || request.UserNos.Contains(x.Code)) //NO和工号匹配
.Select(x => x.No)
.ToListAsync();
var entities = request.UserNos.Select(x => new GainfoGroupRelationshipEntity
(userNos.Count != request.UserNos.Count).ThrowIfTrue("存在权限外人员,无法添加");
var entities = userNos.Select(x => new GainfoGroupRelationshipEntity
{
GroupCode = request.GroupCode,
UserNo = x

View File

@@ -43,13 +43,17 @@ public class GainfoOutsourceService : IGainfoOutsourceService
: await GetOutSourceCodeAsync();
await _dbContext.InsertAsync(entity);
await _dbContext.InsertAsync(new OutsourceEntity
if (!await _dbContext.Queryable<OutsourceEntity>().Where(x => x.Code == entity.Code).AnyAsync())
{
Code = entity.Code,
Supplier = request.ExternalInfo.Supplier,
SapCode = request.ExternalInfo.SapCode,
SapPhone = request.ExternalInfo.SapPhone
});
await _dbContext.InsertAsync(new OutsourceEntity
{
Code = entity.Code,
Supplier = request.ExternalInfo.Supplier,
SapCode = request.ExternalInfo.SapCode,
SapPhone = request.ExternalInfo.SapPhone
});
}
}
else
{

View File

@@ -1,5 +1,4 @@
using Dlhis.Basic.Device.Services;
using Dlhis.Basic.Organization.Api;
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
using Dlhis.Entity.Basic.Entity;
@@ -28,7 +27,6 @@ public class GainfoService : IGainfoService
private readonly ICurrentUser _currentUser;
private readonly ITenantApi _tenantApi;
private readonly IHangfireApi _hangfireApi;
private readonly IHainingApi _hainingApi;
private readonly IDevicePermissionService _devicePermissionService;
private readonly IGainfoPermissionService _gainfoPermissionService;
private readonly ILogger<GainfoService> _logger;
@@ -39,7 +37,6 @@ public class GainfoService : IGainfoService
ICurrentUser currentUser,
ITenantApi tenantApi,
IHangfireApi hangfireApi,
IHainingApi hainingApi,
IDevicePermissionService devicePermissionService,
IGainfoPermissionService gainfoPermissionService,
ILogger<GainfoService> logger)
@@ -50,7 +47,6 @@ public class GainfoService : IGainfoService
_currentUser = currentUser;
_tenantApi = tenantApi;
_hangfireApi = hangfireApi;
_hainingApi = hainingApi;
_devicePermissionService = devicePermissionService;
_gainfoPermissionService = gainfoPermissionService;
_logger = logger;
@@ -68,6 +64,11 @@ public class GainfoService : IGainfoService
//根据组织架构搜索档案
var where = LinqExpressionExtensions.False<GainfoEntity>();
var factories = _currentUser.GetUserClaim("tenants").Split(",").ToList();
var role = _currentUser.GetRole();
var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
var isAll = role is "admin" or "tenant-admin";
if (request.DepartmentSelections.Any())
{
foreach (var item in request.DepartmentSelections)
@@ -91,11 +92,15 @@ public class GainfoService : IGainfoService
where = Expressionable.Create<GainfoEntity>()
.And(where)
.Or(gainfo => SqlFunc.Subqueryable<BusinessTripEntity>()
.Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today))
.Any())
.Where(p => p.Code == gainfo.Code
&& factories.Contains(p.Destination)
&& SqlFunc.DateIsSame(p.BeginDate, today))
.Any()
)
.ToExpression();
}
ISugarQueryable<GainfoPageResponse> queryable = request.IsSearchAll
? _dbContext.Queryable<GainfoEntity>().AS("GainfoEntity", "gainfo")
.Where(where)
@@ -117,7 +122,12 @@ public class GainfoService : IGainfoService
.LeftJoin<BasicTypeEntity>((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod")
.WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == false, gainfo => factories.Contains(gainfo.Factory))
.WhereIF(request.SearchType == GainfoSearchEnumType.Internal, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(p => p.Code == gainfo.Code).NotAny())
.WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(p => p.Code == gainfo.Code).Any()) //&& today >= gainfo.EntryDate && today <= gainfo.ResignationDate
.WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo =>
SqlFunc.Subqueryable<OutsourceEntity>()
.Where(p => p.Code == gainfo.Code)
.WhereIF(!isAll, p => p.SapCode == jinkoCode)
.Any()
)
.WhereIF(request.SearchType == GainfoSearchEnumType.BusinessTrip, gainfo =>
SqlFunc.Subqueryable<BusinessTripEntity>().Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)).Any())
.WhereIF(request.Search.IsPresent(), gainfo =>
@@ -132,14 +142,16 @@ public class GainfoService : IGainfoService
CardTypeName = type.Display
}, true);
_logger.LogInformation(queryable.ToSqlString());
var page = await queryable.ToPageListAsync(request);
//外包人员部门号处理
if (request.SearchType == GainfoSearchEnumType.Outsource)
{
var codes = page.Data.Select(x => x.Code).ToList();
var outsourceInfos = await _dbContext.Queryable<OutsourceEntity>().Where(x => codes.Contains(x.Code)).Select(x => new { x.Code, x.Supplier }).ToListAsync();
var outsourceInfos = await _dbContext.Queryable<OutsourceEntity>()
.Where(x => codes.Contains(x.Code))
.Select(x => new { x.Code, x.Supplier })
.ToListAsync();
page.Data.ForEach(item => { item.DepartmentName = outsourceInfos.FirstOrDefault(x => x.Code == item.Code)?.Supplier; });
}
@@ -227,8 +239,7 @@ public class GainfoService : IGainfoService
public async Task<object> CheckIdNoAndNameMatchAsync(GainfoCheckIdNoAndNameRequest request)
{
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).FirstAsync(x => x.IdNo == request.IdNo && x.Name == request.Name);
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).SingleAsync(x => x.IdNo == request.IdNo && x.Name == request.Name);
gainfo.ThrowIfNull("验证失败!");
var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno");