fix 优化档案查询
This commit is contained in:
@@ -10,7 +10,7 @@ public class JinkoSapHttpClientPack : BaseAppPack
|
|||||||
{
|
{
|
||||||
services.AddHttpClient("jinko:sap", (_, httpClient) =>
|
services.AddHttpClient("jinko:sap", (_, httpClient) =>
|
||||||
{
|
{
|
||||||
httpClient.BaseAddress = new Uri($"http://sappipap01.jinkosolar.cn:50100");
|
httpClient.BaseAddress = new Uri("http://sappipap01.jinkosolar.cn:50100");
|
||||||
httpClient.Timeout = TimeSpan.FromMinutes(10);
|
httpClient.Timeout = TimeSpan.FromMinutes(10);
|
||||||
|
|
||||||
const string credentials = "EHS_USER:y3R1hd2h*RICAC";
|
const string credentials = "EHS_USER:y3R1hd2h*RICAC";
|
||||||
|
|||||||
@@ -22,8 +22,11 @@ public class GainfoPageRequest : PageDto, IValidatableObject
|
|||||||
/// 查询类型 GainfoSearchEnumType
|
/// 查询类型 GainfoSearchEnumType
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EnumDataType(typeof(GainfoSearchEnumType))]
|
[EnumDataType(typeof(GainfoSearchEnumType))]
|
||||||
public GainfoSearchEnumType SearchType { get; set; }
|
public GainfoSearchEnumType? SearchType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 无条件查询所有
|
||||||
|
/// </summary>
|
||||||
public bool IsSearchAll { get; set; }
|
public bool IsSearchAll { get; set; }
|
||||||
|
|
||||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||||
@@ -38,6 +41,11 @@ public class GainfoPageRequest : PageDto, IValidatableObject
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (SearchType == GainfoSearchEnumType.BusinessTrip)
|
||||||
|
{
|
||||||
|
SearchType = null;
|
||||||
|
}
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,9 @@ namespace Dlhis.Basic.Organization.Response;
|
|||||||
public class GainfoOutSourceExternalInfoResponse : GainfoOutSourceExternalInfoDto
|
public class GainfoOutSourceExternalInfoResponse : GainfoOutSourceExternalInfoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 姓名
|
/// 对接人姓名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string SapName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 入职日期
|
/// 入职日期
|
||||||
|
|||||||
@@ -106,11 +106,7 @@ public class GainfoFaceService : IGainfoFaceService
|
|||||||
//ignore
|
//ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.External)
|
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||||
.Where(x => x.IdNo == request.UserNo)
|
|
||||||
.SingleAsync();
|
|
||||||
|
|
||||||
gainfo ??= await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
|
||||||
.Where(x => x.IdNo == request.UserNo)
|
.Where(x => x.IdNo == request.UserNo)
|
||||||
.SingleAsync();
|
.SingleAsync();
|
||||||
|
|
||||||
@@ -272,8 +268,6 @@ public class GainfoFaceService : IGainfoFaceService
|
|||||||
foreach (var request in requests)
|
foreach (var request in requests)
|
||||||
{
|
{
|
||||||
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.Code == request.UserNo).FirstAsync();
|
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.Code == request.UserNo).FirstAsync();
|
||||||
gainfo ??= await _gainfoStore.Queryable(GainfoStatusEnumType.External).Where(x => x.Code == request.UserNo).FirstAsync();
|
|
||||||
|
|
||||||
gainfo.ThrowIfNull("人员档案信息不存在");
|
gainfo.ThrowIfNull("人员档案信息不存在");
|
||||||
|
|
||||||
var face = await _faceDbContext.Queryable<GainfoFaceEntity>().Where(x => x.UserCode == gainfo.Code).SingleAsync();
|
var face = await _faceDbContext.Queryable<GainfoFaceEntity>().Where(x => x.UserCode == gainfo.Code).SingleAsync();
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class GainfoOutsourceService : IGainfoOutsourceService
|
|||||||
Supplier = a.Supplier,
|
Supplier = a.Supplier,
|
||||||
SapCode = a.SapCode,
|
SapCode = a.SapCode,
|
||||||
SapPhone = a.SapPhone,
|
SapPhone = a.SapPhone,
|
||||||
Name = c.Name,
|
SapName = c.Name,
|
||||||
EntryDate = b.EntryDate,
|
EntryDate = b.EntryDate,
|
||||||
ResignationDate = b.ResignationDate,
|
ResignationDate = b.ResignationDate,
|
||||||
Factory = b.Factory
|
Factory = b.Factory
|
||||||
|
|||||||
@@ -70,10 +70,6 @@ public class GainfoService : IGainfoService
|
|||||||
var where = LinqExpressionExtensions.False<GainfoEntity>();
|
var where = LinqExpressionExtensions.False<GainfoEntity>();
|
||||||
var factories = _currentUser.GetUserClaim("tenants").Split(",").ToList();
|
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())
|
if (request.DepartmentSelections.Any())
|
||||||
{
|
{
|
||||||
foreach (var item in request.DepartmentSelections)
|
foreach (var item in request.DepartmentSelections)
|
||||||
@@ -91,6 +87,20 @@ public class GainfoService : IGainfoService
|
|||||||
where = where.Or(gainfo => factories.Contains(gainfo.Factory));
|
where = where.Or(gainfo => factories.Contains(gainfo.Factory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.SearchType.HasValue)
|
||||||
|
{
|
||||||
|
GainfoUserTypeEnumType userTypeEnumType = request.SearchType switch
|
||||||
|
{
|
||||||
|
GainfoSearchEnumType.Internal => GainfoUserTypeEnumType.Normal,
|
||||||
|
GainfoSearchEnumType.Outsource => GainfoUserTypeEnumType.Outsource,
|
||||||
|
GainfoSearchEnumType.BusinessTrip => throw new ArgumentNullException(request.SearchType?.ToString()),
|
||||||
|
GainfoSearchEnumType.External => GainfoUserTypeEnumType.External,
|
||||||
|
null => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()),
|
||||||
|
_ => throw new ArgumentOutOfRangeException(request.SearchType?.ToString())
|
||||||
|
};
|
||||||
|
where = where.And(x => x.Type == userTypeEnumType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (request.IsSearchAll)
|
if (request.IsSearchAll)
|
||||||
{
|
{
|
||||||
@@ -122,19 +132,12 @@ public class GainfoService : IGainfoService
|
|||||||
CardTypeName = type.Display
|
CardTypeName = type.Display
|
||||||
}, true)
|
}, true)
|
||||||
: _gainfoStore.Queryable(request.Status)
|
: _gainfoStore.Queryable(request.Status)
|
||||||
.WhereIF(request.SearchType != GainfoSearchEnumType.BusinessTrip && request.DepartmentSelections?.Any() == true, where)
|
|
||||||
.LeftJoin<DepartmentEntity>((gainfo, department) => gainfo.DepartmentNo == department.No)
|
.LeftJoin<DepartmentEntity>((gainfo, department) => gainfo.DepartmentNo == department.No)
|
||||||
.LeftJoin<BasicTypeEntity>((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod")
|
.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.HasValue == false, gainfo => SqlFunc.Subqueryable<BusinessTripEntity>()
|
||||||
.WhereIF(request.SearchType == GainfoSearchEnumType.Internal, gainfo => SqlFunc.Subqueryable<OutsourceEntity>().Where(p => p.Code == gainfo.Code).NotAny())
|
.Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today))
|
||||||
.WhereIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo =>
|
.Any())
|
||||||
SqlFunc.Subqueryable<OutsourceEntity>()
|
.WhereIF(request.SearchType.HasValue, where)
|
||||||
.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 =>
|
.WhereIF(request.Search.IsPresent(), gainfo =>
|
||||||
gainfo.Name.Contains(request.Search)
|
gainfo.Name.Contains(request.Search)
|
||||||
|| gainfo.Code == request.Search
|
|| gainfo.Code == request.Search
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ public class GainfoStore : IGainfoStore
|
|||||||
return _dbContext.Queryable<GainfoEntity>();
|
return _dbContext.Queryable<GainfoEntity>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gainfoStatus == GainfoStatusEnumType.External)
|
|
||||||
{
|
|
||||||
return _dbContext.Queryable<GainfoEntity>().Where(x => x.Type == GainfoUserTypeEnumType.External);
|
|
||||||
}
|
|
||||||
|
|
||||||
var tableName = typeof(GainfoEntity).GetCustomAttribute<SugarTable>()!.TableName;
|
var tableName = typeof(GainfoEntity).GetCustomAttribute<SugarTable>()!.TableName;
|
||||||
return _dbContext.Queryable<GainfoEntity>().AS(tableName + gainfoStatus);
|
return _dbContext.Queryable<GainfoEntity>().AS(tableName + gainfoStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
return sapList;
|
return sapList;
|
||||||
}
|
}
|
||||||
|
|
||||||
var needRemove = sapList.Intersect(last, new SapPersonComparer()).ToList();
|
var needRemove = sapList.Intersect(last, new SapPersonComparer());
|
||||||
return sapList.Except(needRemove, new SapPersonComparer()).ToList();
|
return sapList.Except(needRemove, new SapPersonComparer()).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,5 +21,12 @@ public enum GainfoSearchEnumType
|
|||||||
/// 出差人员
|
/// 出差人员
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("出差人员")]
|
[Description("出差人员")]
|
||||||
BusinessTrip = 3
|
BusinessTrip = 3,
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部人员
|
||||||
|
/// </summary>
|
||||||
|
[Description("外部人员")]
|
||||||
|
External = 4
|
||||||
}
|
}
|
||||||
@@ -18,11 +18,5 @@ public enum GainfoStatusEnumType
|
|||||||
/// 离职
|
/// 离职
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("离职")]
|
[Description("离职")]
|
||||||
Leave = 2,
|
Leave = 2
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 外部
|
|
||||||
/// </summary>
|
|
||||||
[Description("外部")]
|
|
||||||
External = 3
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user