fix 重复字段问题

This commit is contained in:
2025-01-08 18:19:20 +08:00
parent 03a5421fbe
commit 135a507adf
2 changed files with 22 additions and 12 deletions

View File

@@ -98,7 +98,7 @@ public class GainfoService : IGainfoService
null => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()), null => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()),
_ => throw new ArgumentOutOfRangeException(request.SearchType?.ToString()) _ => throw new ArgumentOutOfRangeException(request.SearchType?.ToString())
}; };
where = where.And(x => x.Type == userTypeEnumType); where = where.And(gainfo => gainfo.Type == userTypeEnumType);
} }
@@ -120,21 +120,18 @@ public class GainfoService : IGainfoService
? _dbContext.Queryable<GainfoEntity>().AS("GainfoEntity", "gainfo") ? _dbContext.Queryable<GainfoEntity>().AS("GainfoEntity", "gainfo")
.Where(where) .Where(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")
.WhereIF(request.Search.IsPresent(), gainfo => .WhereIF(request.Search.IsPresent(), gainfo =>
gainfo.Name == request.Search gainfo.Name == request.Search
|| gainfo.Code == request.Search || gainfo.Code == request.Search
|| gainfo.IdNo == request.Search) || gainfo.IdNo == request.Search)
.Select((gainfo, department, type) => new GainfoPageResponse .Select((gainfo, department) => new GainfoPageResponse
{ {
DepartmentName = department.Name, DepartmentName = department.Name,
CardType = gainfo.CardType, CardType = gainfo.CardType,
CardTypeName = type.Display
}, true) }, true)
: _gainfoStore.Queryable(request.Status) : _gainfoStore.Queryable(request.Status)
.WhereIF(request.SearchType.HasValue, where) .WhereIF(request.SearchType.HasValue == 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")
.WhereIF(request.SearchType.HasValue == false, gainfo => SqlFunc.Subqueryable<BusinessTripEntity>() .WhereIF(request.SearchType.HasValue == false, gainfo => SqlFunc.Subqueryable<BusinessTripEntity>()
.Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today)) .Where(p => p.Code == gainfo.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, today))
.Any()) .Any())
@@ -143,11 +140,10 @@ public class GainfoService : IGainfoService
|| gainfo.Code == request.Search || gainfo.Code == request.Search
|| gainfo.IdNo == request.Search) || gainfo.IdNo == request.Search)
.OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排 .OrderByIF(request.SearchType == GainfoSearchEnumType.Outsource, gainfo => gainfo.ResignationDate, OrderByType.Desc) //外包人员按离职日期倒排
.Select((gainfo, department, type) => new GainfoPageResponse .Select((gainfo, department) => new GainfoPageResponse
{ {
DepartmentName = department.Name, DepartmentName = department.Name,
CardType = gainfo.CardType, CardType = gainfo.CardType
CardTypeName = type.Display
}, true); }, true);
var page = await queryable.ToPageListAsync(request); var page = await queryable.ToPageListAsync(request);
@@ -164,6 +160,20 @@ public class GainfoService : IGainfoService
page.Data.ForEach(item => { item.DepartmentName = outsourceInfos.FirstOrDefault(x => x.Code == item.Code)?.Supplier; }); page.Data.ForEach(item => { item.DepartmentName = outsourceInfos.FirstOrDefault(x => x.Code == item.Code)?.Supplier; });
} }
page.Data.ForEach(gainfo =>
{
if (gainfo.CardType == 1 || gainfo.CardType == 0 || gainfo.CardType.HasValue == false)
gainfo.CardTypeName = "全时段";
gainfo.CardTypeName = gainfo.CardType switch
{
2 => "行政卡",
3 => "车间卡",
_ => gainfo.CardTypeName
};
});
return page; return page;
} }

View File

@@ -15,8 +15,8 @@ public enum GainfoStatusEnumType
Working = 1, Working = 1,
/// <summary> /// <summary>
/// 离职 /// 归档
/// </summary> /// </summary>
[Description("离职")] [Description("归档")]
Leave = 2 Leave = 2
} }