fix null异常调试

This commit is contained in:
2025-01-08 16:45:36 +08:00
parent f214468d48
commit 0df29c092f
2 changed files with 38 additions and 22 deletions

View File

@@ -131,24 +131,43 @@ public class GainfoService : IGainfoService
CardType = gainfo.CardType,
CardTypeName = type.Display
}, true)
: _gainfoStore.Queryable(request.Status)
.LeftJoin<DepartmentEntity>((gainfo, department) => gainfo.DepartmentNo == department.No)
.LeftJoin<BasicTypeEntity>((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod")
.WhereIF(request.SearchType.HasValue == false, gainfo => SqlFunc.Subqueryable<BusinessTripEntity>()
.Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today))
.Any())
.WhereIF(request.SearchType.HasValue, where)
.WhereIF(request.Search.IsPresent(), gainfo =>
gainfo.Name.Contains(request.Search)
|| gainfo.Code == request.Search
|| gainfo.IdNo == request.Search)
.OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排
.Select((gainfo, department, type) => new GainfoPageResponse
{
DepartmentName = department.Name,
CardType = gainfo.CardType,
CardTypeName = type.Display
}, true);
: request.Status == GainfoStatusEnumType.Working
? _dbContext.Queryable<GainfoEntity>()
.WhereIF(request.SearchType.HasValue, where)
.LeftJoin<DepartmentEntity>((gainfo, department) => gainfo.DepartmentNo == department.No)
.LeftJoin<BasicTypeEntity>((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod")
.WhereIF(request.SearchType.HasValue == false, 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 =>
gainfo.Name.Contains(request.Search)
|| gainfo.Code == request.Search
|| gainfo.IdNo == request.Search)
.OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排
.Select((gainfo, department, type) => new GainfoPageResponse
{
DepartmentName = department.Name,
CardType = gainfo.CardType,
CardTypeName = type.Display
}, true)
: _dbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
.WhereIF(request.SearchType.HasValue, where)
.LeftJoin<DepartmentEntity>((gainfo, department) => gainfo.DepartmentNo == department.No)
.LeftJoin<BasicTypeEntity>((gainfo, department, type) => type.Code == SqlFunc.ToString(gainfo.CardType) && type.Type == "timeperiod")
.WhereIF(request.SearchType.HasValue == false, 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 =>
gainfo.Name.Contains(request.Search)
|| gainfo.Code == request.Search
|| gainfo.IdNo == request.Search)
.OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排
.Select((gainfo, department, type) => new GainfoPageResponse
{
DepartmentName = department.Name,
CardType = gainfo.CardType,
CardTypeName = type.Display
}, true);
var page = await queryable.ToPageListAsync(request);

View File

@@ -25,10 +25,7 @@ public class GainfoStore : IGainfoStore
/// <returns></returns>
public ISugarQueryable<GainfoEntity> Queryable(GainfoStatusEnumType? gainfoStatus)
{
if (gainfoStatus is null or GainfoStatusEnumType.Working)
{
return _dbContext.Queryable<GainfoEntity>();
}
gainfoStatus ??= GainfoStatusEnumType.Working;
var tableName = typeof(GainfoEntity).GetCustomAttribute<SugarTable>()!.TableName;
return _dbContext.Queryable<GainfoEntity>().AS(tableName + gainfoStatus);