From cf04fb01ad6b97c6f2d7b8ab18cb08bb357b62e7 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Sat, 22 Jun 2024 13:17:50 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=94=B9=E7=94=A8db=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/GainfoService.cs | 56 +++++++++++++++---- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/Src/Dlhis.External/OpenApi/Services/Implements/GainfoService.cs b/Src/Dlhis.External/OpenApi/Services/Implements/GainfoService.cs index e279c30e..1028ce32 100644 --- a/Src/Dlhis.External/OpenApi/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.External/OpenApi/Services/Implements/GainfoService.cs @@ -1,28 +1,60 @@ -using Dlhis.External.OpenApi.Response; -using Kurisu.AspNetCore.Utils; -using Kurisu.AspNetCore.Utils.Extensions; +using Dlhis.Entity.Basic.Entity; +using Dlhis.Entity.Basic.Enums; +using Dlhis.External.OpenApi.Response; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; namespace Dlhis.External.OpenApi.Services.Implements; public class GainfoService : IGainfoService { - private readonly RedisCache _redisCache; + private readonly IDbContext _dbContext; - public GainfoService(RedisCache redisCache) + public GainfoService(IDbContext dbContext) { - _redisCache = redisCache; + _dbContext = dbContext; } public async Task> GetAllGainfosAsync() { - var data = await _redisCache.ListRangeAsync("gainfo:shanxi"); - return data.Select(x => x.ToString().ToObject()).ToList(); + var gainfos = await _dbContext.Queryable() + .LeftJoin((x, d) => x.DepartmentNo == d.No) + .Where(x => x.Factory == "2401") + .Select((x, d) => new GainfoOpenResponse + { + Code = x.Code, + DepartmentNo = x.DepartmentNo, + DepartmentName = d.Name, + Name = x.Name, + Gender = x.Gender, + Status = GainfoStatusEnumType.Working, + }) + .ToListAsync(); + + var gainfoLeaves = await _dbContext.Queryable().AS("GainfoLeave") + .LeftJoin((x, d) => x.DepartmentNo == d.No) + .Where(x => x.Factory == "2401") + .Select((x, d) => new GainfoOpenResponse + { + Code = x.Code, + DepartmentNo = x.DepartmentNo, + DepartmentName = d.Name, + Name = x.Name, + Gender = x.Gender, + Status = GainfoStatusEnumType.Leave, + }) + .ToListAsync(); + + return gainfos.Concat(gainfoLeaves).ToList(); } public async Task> GetDepartmentsAsync() { - var departmentKey = "department:all"; - var data = await _redisCache.ListRangeAsync(departmentKey); - return data.Select(x => x.ToString().ToObject()).ToList(); + return await _dbContext.Queryable() + .Select(x => new DepartmentOpenResponse + { + Name = x.Name, + No = x.No, + PNo = x.PNo + }).ToListAsync(); } -} +} \ No newline at end of file