fix 外包人员,餐补导入,人员列表
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
public class GainfoOutSourceService : IGainfoOutSourceService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly RedisCache _redisCache;
|
||||
|
||||
public GainfoOutSourceService(IDbContext dbContext, RedisCache redisCache)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_redisCache = redisCache;
|
||||
}
|
||||
|
||||
public async Task EntryAsync(GainfoOutEntryRequest request)
|
||||
{
|
||||
await SaveAsync(request);
|
||||
}
|
||||
|
||||
public async Task ResignAsync(GainfoOutResignRequest request)
|
||||
{
|
||||
//todo 生成任务处理
|
||||
}
|
||||
|
||||
public async Task EditAsync(GainfoOutEntryRequest request)
|
||||
{
|
||||
await SaveAsync(request);
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************** help methods ***********************************************************************************
|
||||
|
||||
private async Task<string> GetOutSourceCodeAsync()
|
||||
{
|
||||
await using var handler = await _redisCache.LockAsync("gainfo:outsource:code-generate", expiry: TimeSpan.FromSeconds(3), retryInterval: TimeSpan.FromSeconds(1), retryCount: 3);
|
||||
handler.Acquired.ThrowIfFalse("生成虚拟工号失败");
|
||||
|
||||
int code;
|
||||
var entity = await _dbContext.Queryable<OutSourceEntity>().OrderBy(x => x.Id, OrderByType.Desc).FirstAsync();
|
||||
if (entity == null)
|
||||
{
|
||||
code = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
code = int.Parse(entity.Code.Replace("LS", "").Replace("0", "")) + 1;
|
||||
}
|
||||
|
||||
return "LS" + code.ToString().PadLeft(6, '0');
|
||||
}
|
||||
|
||||
private async Task SaveAsync(GainfoOutEntryRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<GainfoEntity>();
|
||||
entity.No = Guid.NewGuid().ToString();
|
||||
entity.Code = await GetOutSourceCodeAsync();
|
||||
|
||||
await _dbContext.InsertAsync(entity);
|
||||
await _dbContext.InsertAsync(new OutSourceEntity
|
||||
{
|
||||
Code = entity.Code
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<GainfoEntity>().FirstAsync(x => x.Id == request.Id);
|
||||
entity.ThrowIfNull("档案数据不存在");
|
||||
|
||||
(await _dbContext.Queryable<OutSourceEntity>().AnyAsync(x => x.Code == entity.Code)).ThrowIfFalse("不可编辑非外包人员档案数据");
|
||||
|
||||
request.Adapt(entity);
|
||||
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||
|
||||
@@ -64,10 +65,12 @@ public class GainfoService : IGainfoService
|
||||
var page = await _gainfoStore.Queryable(request.Status)
|
||||
.WhereIF(request.DepartmentSelections.IsPresent(), where)
|
||||
.WhereIF(request.DepartmentSelections.IsEmpty(), gainfo => gainfo.Factory == currentTenantId)
|
||||
.WhereIF(request.IsOutSource.HasValue && request.IsOutSource.Value, gainfo => SqlFunc.Subqueryable<OutSourceEntity>().Where(x => x.Code == gainfo.Code).Any())
|
||||
.WhereIF(request.IsOutSource.HasValue && !request.IsOutSource.Value, gainfo => SqlFunc.Subqueryable<OutSourceEntity>().Where(x => x.Code == gainfo.Code).NotAny())
|
||||
.WhereIF(request.Search.IsPresent(), gainfo =>
|
||||
gainfo.Name.Contains(request.Search)
|
||||
|| gainfo.Code == request.Search
|
||||
|| gainfo.IdNo == request.Search)
|
||||
gainfo.Name.Contains(request.Search)
|
||||
|| gainfo.Code == request.Search
|
||||
|| gainfo.IdNo == request.Search)
|
||||
.Select<GainfoPageResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
@@ -77,9 +80,9 @@ public class GainfoService : IGainfoService
|
||||
public async Task<Pagination<GainfoAllPageResponse>> GetPageByCodeAsync(string code)
|
||||
{
|
||||
var page = await _gainfoStore.Queryable()
|
||||
.Where(x => x.Code == code)
|
||||
.Select<GainfoAllPageResponse>()
|
||||
.ToPageListAsync(new PageDto { PageIndex = 1, PageSize = 1 });
|
||||
.Where(x => x.Code == code)
|
||||
.Select<GainfoAllPageResponse>()
|
||||
.ToPageListAsync(new PageDto { PageIndex = 1, PageSize = 1 });
|
||||
|
||||
var tenantsResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantsResult.Data;
|
||||
@@ -101,6 +104,7 @@ public class GainfoService : IGainfoService
|
||||
_logger.LogWarning("工号为空尝试获取人员信息");
|
||||
return null;
|
||||
}
|
||||
|
||||
var gainfo = await _gainfoStore.Queryable().Where(x => x.Code == code).SingleAsync();
|
||||
|
||||
if (gainfo == null)
|
||||
@@ -111,25 +115,25 @@ public class GainfoService : IGainfoService
|
||||
}
|
||||
|
||||
var info = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||
.LeftJoin<DepartmentEntity>((ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<GainfoMealEntity>((ga, department, mealUser) => ga.No == mealUser.UserNo)
|
||||
.Where((ga, department) => ga.Id == gainfo.Id)
|
||||
.Select((ga, department, mealUser) => new GainfoCurrentResponse
|
||||
{
|
||||
UserNo = ga.No,
|
||||
Birthday = ga.Birthday,
|
||||
DepartmentNo = department.No,
|
||||
DepartmentName = department.Name,
|
||||
Gender = ga.Gender,
|
||||
UserCode = ga.Code,
|
||||
UserName = ga.Name,
|
||||
Factory = ga.Factory,
|
||||
MealInfo = new GainfoCurrentMealInfoResponse
|
||||
{
|
||||
Balance = mealUser.Balance
|
||||
}
|
||||
})
|
||||
.FirstAsync();
|
||||
.LeftJoin<DepartmentEntity>((ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<GainfoMealEntity>((ga, department, mealUser) => ga.No == mealUser.UserNo)
|
||||
.Where((ga, department) => ga.Id == gainfo.Id)
|
||||
.Select((ga, department, mealUser) => new GainfoCurrentResponse
|
||||
{
|
||||
UserNo = ga.No,
|
||||
Birthday = ga.Birthday,
|
||||
DepartmentNo = department.No,
|
||||
DepartmentName = department.Name,
|
||||
Gender = ga.Gender,
|
||||
UserCode = ga.Code,
|
||||
UserName = ga.Name,
|
||||
Factory = ga.Factory,
|
||||
MealInfo = new GainfoCurrentMealInfoResponse
|
||||
{
|
||||
Balance = mealUser.Balance
|
||||
}
|
||||
})
|
||||
.FirstAsync();
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
@@ -259,7 +263,6 @@ public class GainfoService : IGainfoService
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,4 +342,4 @@ public class GainfoService : IGainfoService
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user