feat 获取当前人员信息

This commit is contained in:
2024-01-10 14:51:38 +08:00
parent be581e43e3
commit 8dba9e9a3a
20 changed files with 230 additions and 135 deletions

View File

@@ -32,7 +32,7 @@ public class MealUserService : IMealUserService
public async Task AddAsync(MealUserAddRequest request)
{
// 获取档案信息
//todo 获取档案信息
var gainfoEntity = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
.Where(x => x.No.ToString() == request.UserId)
@@ -42,7 +42,7 @@ public class MealUserService : IMealUserService
var entity = new CanteenUserEntity
{
UserId = request.UserId,
UserNo = request.UserId,
UserType = request.UserType,
UserCode = gainfoEntity.Code,
CarNo = gainfoEntity.CarNo,
@@ -57,7 +57,7 @@ public class MealUserService : IMealUserService
public async Task<MealUserResponse> GetMealUserAsync(string userId)
{
return await _dbContext.Queryable<CanteenUserEntity>()
.Where(x => x.UserId == userId)
.Where(x => x.UserNo == userId)
.Select<MealUserResponse>()
.FirstAsync();
}

View File

@@ -78,5 +78,15 @@ public class GainfosController : ControllerBase
{
await _gainfoService.OnboardingAsync(request);
}
/// <summary>
/// 当前人员信息
/// </summary>
/// <returns></returns>
[HttpGet("current")]
public async Task<GainfoCurrentResponse> CurrentUserInfoAsync()
{
return await _gainfoService.CurrentUserInfoAsync();
}
}

View File

@@ -5,7 +5,7 @@ public class DepartmentTreeResponse
/// <summary>
/// 部门号
/// </summary>
public string Code { get; set; }
public string No { get; set; }
/// <summary>
/// 部门名称

View File

@@ -0,0 +1,9 @@
namespace Dlhis.Basic.Organization.Response;
public class GainfoCurrentMealInfoResponse
{
/// <summary>
/// 余额
/// </summary>
public decimal Balance { get; set; }
}

View File

@@ -0,0 +1,52 @@
using Dlhis.Entity.Basic.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
namespace Dlhis.Basic.Organization.Response;
public class GainfoCurrentResponse
{
/// <summary>
/// 用户档案号
/// </summary>
public string UserNo { get; set; }
/// <summary>
/// 用户姓名
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 性别枚举
/// </summary>
public GenderEnumType Gender { get; set; }
/// <summary>
/// 性别描述
/// </summary>
public string GenderDesc => Gender.GetDescription();
/// <summary>
/// 工号
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 部门号
/// </summary>
public string DepartmentNo { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string DepartmentName { get; set; }
/// <summary>
/// 出生日期/生日
/// </summary>
public DateTime Birthday { get; set; }
/// <summary>
/// 就餐信息
/// </summary>
public GainfoCurrentMealInfoResponse MealInfo { get; set; }
}

View File

@@ -16,4 +16,6 @@ public interface IGainfoService : IScopeDependency
Task DimissionAsync(GainfoDImissionRequest request);
Task OnboardingAsync(GainfoDImissionRequest request);
Task<GainfoCurrentResponse> CurrentUserInfoAsync();
}

View File

@@ -18,7 +18,7 @@ public class DepartmentService : IDepartmentService
public async Task<List<DepartmentTreeResponse>> GetTreeAsync()
{
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
var tops = departments.Where(x => x.PCode.IsEmpty()).Adapt<List<DepartmentTreeResponse>>();
var tops = departments.Where(x => x.PNo.IsEmpty()).Adapt<List<DepartmentTreeResponse>>();
tops.ForEach(x =>
{
@@ -31,7 +31,7 @@ public class DepartmentService : IDepartmentService
private void RecursionGetNext(DepartmentTreeResponse current, List<DepartmentEntity> departments)
{
var next = departments.Where(x => x.PCode == current.Code).ToList();
var next = departments.Where(x => x.PNo == current.No).ToList();
current.Next = next.Adapt<List<DepartmentTreeResponse>>();
foreach (var item in next)
{

View File

@@ -4,6 +4,7 @@ using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Core.DataAccess.Dto;
using Kurisu.Core.User.Abstractions;
using Kurisu.SqlSugar.Attributes;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
@@ -15,11 +16,13 @@ public class GainfoService : IGainfoService
{
private readonly IGainfoStore _gainfoStore;
private readonly IDbContext _dbContext;
private readonly ICurrentUser _currentUser;
public GainfoService(IGainfoStore gainfoStore, IDbContext dbContext)
public GainfoService(IGainfoStore gainfoStore, IDbContext dbContext, ICurrentUser currentUser)
{
_gainfoStore = gainfoStore;
_dbContext = dbContext;
_currentUser = currentUser;
}
/// <summary>
@@ -112,6 +115,33 @@ public class GainfoService : IGainfoService
await _gainfoStore.InsertAsync(gainfo);
}
public async Task<GainfoCurrentResponse> CurrentUserInfoAsync()
{
var identityId = _currentUser.GetIntSubjectId();
var gainfo = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
.LeftJoin<DepartmentEntity>((ga, department) => ga.DepartmentNo == department.No)
.LeftJoin<CanteenUserEntity>((ga, department, mealUser) => ga.No == mealUser.UserNo)
.Where((ga, department) => ga.IdentityUserId == identityId)
.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,
MealInfo = new GainfoCurrentMealInfoResponse
{
Balance = mealUser.Balance
}
})
.FirstAsync();
return gainfo;
}
//-------------------------------------------help methods ------------------------------------------------
@@ -128,26 +158,26 @@ public class GainfoService : IGainfoService
}
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
var currentNos = departments.Where(x => departmentNos.Contains(x.Code)).ToList();
var currentNos = departments.Where(x => departmentNos.Contains(x.No)).ToList();
foreach (var item in currentNos)
{
RecursionGetNext(item.Code, departments, departmentNos);
RecursionGetNext(item.No, departments, departmentNos);
}
return departmentNos.Distinct().ToList();
void RecursionGetNext(string currentCode, List<DepartmentEntity> departments, List<string> result)
{
var next = departments.Where(x => x.PCode == currentCode).ToList();
var next = departments.Where(x => x.PNo == currentCode).ToList();
foreach (var item in next)
{
result.Add(item.Code);
result.Add(item.No);
}
foreach (var item in next)
{
RecursionGetNext(item.Code, departments, result);
RecursionGetNext(item.No, departments, result);
}
}
}

View File

@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Canteen.Order.Controllers;
/// <summary>
/// 充值/消费
/// </summary>
[Authorize]
[Route("api/[controller]")]
[ApiController]

View File

@@ -59,11 +59,11 @@ public class OrderService : IOrderService
//根据档案号
var canteenUser = await _dbContext.Queryable<CanteenUserEntity>()
.Where(x => x.UserId == request.UserUniqueNo || x.UserCode == request.UserUniqueNo)
.Where(x => x.UserNo == request.UserUniqueNo || x.UserCode == request.UserUniqueNo)
.FirstAsync();
var gafinfo = await _dbContext.Queryable<GainfoEntity>()
.Where(x => x.No == canteenUser.UserId)
.Where(x => x.No == canteenUser.UserNo)
.FirstAsync();
var settings = await _canteenSettingService.GetUserSettingAsync(gafinfo.No);
@@ -102,7 +102,7 @@ public class OrderService : IOrderService
OrderStatus = CanteenOrderStatusEnumType.Wait,
Name = gafinfo.Name,
Source = request.Source,
UserId = canteenUser.UserId,
UserId = canteenUser.UserNo,
UserCode = canteenUser.UserCode,
Amount = request.Amount,
BusinessPlaceCode = businessPlace.Code,
@@ -207,7 +207,7 @@ public class OrderService : IOrderService
{
try
{
var canteenUser = await _dbContext.Queryable<CanteenUserEntity>().Where(x => x.UserId == order.UserId).FirstAsync();
var canteenUser = await _dbContext.Queryable<CanteenUserEntity>().Where(x => x.UserNo == order.UserId).FirstAsync();
//金额+-
canteenUser.Balance += order.Amount;
@@ -222,7 +222,7 @@ public class OrderService : IOrderService
var effect = await _dbContext.Updateable<CanteenUserEntity>()
.SetColumns(x => x.Balance == canteenUser.Balance + order.Amount)
.SetColumns(x => x.Version == x.Version + 1)
.Where(x => x.UserId == order.UserId && x.Version == canteenUser.Version)//必须与查询时的version一致
.Where(x => x.UserNo == order.UserId && x.Version == canteenUser.Version)//必须与查询时的version一致
.ExecuteCommandAsync();
if (effect <= 0)

View File

@@ -25,7 +25,7 @@ public class CanteenSettingService : ICanteenSettingService
public async Task<Pagination<CanteenSettingResponse>> GetPageAsync(CanteenSettingPageRequest request)
{
var page = await _context.Queryable<CanteenSettingEntity>()
.LeftJoin<CanteenUserEntity>((setting, user) => setting.UniqueValue == user.UserId)
.LeftJoin<CanteenUserEntity>((setting, user) => setting.UniqueValue == user.UserNo)
.WhereIF(request.UniqueType.HasValue, setting => setting.UniqueType == request.UniqueType)
.WhereIF(request.Item.HasValue, setting => setting.Item == request.Item)
.WhereIF(request.Search.IsPresent(), setting => setting.UniqueValue.Contains(request.Search))

View File

@@ -11,9 +11,4 @@ public class SqlSugarPack : BaseAppPack
{
services.AddSqlSugar();
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
}
}

View File

@@ -16,7 +16,7 @@ public class CanteenUserEntity : SugarBaseEntity, IVersion, ITenantId
/// 档案号
/// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "档案号")]
public string UserId { get; set; }
public string UserNo { get; set; }
/// <summary>

View File

@@ -13,13 +13,13 @@ public class DepartmentEntity : SugarBaseEntity
/// 部门号
/// </summary>
[SugarColumn(ColumnDescription = "部门号")]
public string Code { get; set; }
public string No { get; set; }
/// <summary>
/// 上级部门号
/// </summary>
[SugarColumn(ColumnDescription = "上级部门号")]
public string PCode { get; set; }
public string PNo { get; set; }
/// <summary>
/// 部门名称

View File

@@ -8,13 +8,13 @@ public enum GenderEnumType
/// <summary>
/// 女性
/// </summary>
[Description("女性")]
[Description("女")]
Female = 0,
/// <summary>
/// 男性
/// </summary>
[Description("男性")]
[Description("男")]
Male = 1,
/// <summary>

View File

@@ -1,5 +1,4 @@
using Dlhis.Entity.Canteen.Enums;
using Kurisu.Core.DataAccess.Entity;
using SqlSugar;
using SqlSugar.DbConvert;
@@ -9,7 +8,7 @@ namespace Dlhis.Entity.Canteen.Entities;
/// 就餐订单
/// </summary>
[SugarTable(TableName = "CanteenOrder", TableDescription = "就餐订单")]
public class CanteenOrderEntity : BalanceRecordEntity, ITenantId
public class CanteenOrderEntity : BalanceRecordEntity
{
/// <summary>
/// 请求json
@@ -40,5 +39,4 @@ public class CanteenOrderEntity : BalanceRecordEntity, ITenantId
/// </summary>
[SugarColumn(ColumnDescription = "处理结果")]
public string Result { get; set; }
public string TenantId { get; set; }
}

View File

@@ -1,115 +1,113 @@
namespace Dlhis.ScheduledTask.Entities
using SqlSugar;
namespace Dlhis.ScheduledTask.Entities;
[SugarTable(TableName = "GainfoSap")]
public class GainfoSapEntity
{
public class GainfoSap
{
public GainfoSap()
{
}
[PkColumn]
public int id { get; set; }
[PkColumn]
public int id { get; set; }
public string ano { get; set; }
public string @class { get; set; }
public string ano { get; set; }
public string @class { get; set; }
public string passwd { get; set; }
public string question { get; set; }
public string passwd { get; set; }
public string question { get; set; }
public string answer { get; set; }
public string gname { get; set; }
public string answer { get; set; }
public string gname { get; set; }
[UpdateColumn]
public string ename { get; set; }
[UpdateColumn]
public string ename { get; set; }
public string country { get; set; }
public string idcls { get; set; }
public string idno { get; set; }
public string native { get; set; }
public string sex { get; set; }
public DateTime? birthday { get; set; }
public string address { get; set; }
public string postcode { get; set; }
public string occupation { get; set; }
public string appellation { get; set; }
public string nation { get; set; }
public string phone { get; set; }
public string fax { get; set; }
public string mobile { get; set; }
public string email { get; set; }
public string web { get; set; }
public string vip { get; set; }
public string sec { get; set; }
public string cropsno { get; set; }
public string cropname { get; set; }
public string fancy { get; set; }
public string remark { get; set; }
public string country { get; set; }
public string idcls { get; set; }
public string idno { get; set; }
public string native { get; set; }
public string sex { get; set; }
public DateTime? birthday { get; set; }
public string address { get; set; }
public string postcode { get; set; }
public string occupation { get; set; }
public string appellation { get; set; }
public string nation { get; set; }
public string phone { get; set; }
public string fax { get; set; }
public string mobile { get; set; }
public string email { get; set; }
public string web { get; set; }
public string vip { get; set; }
public string sec { get; set; }
public string cropsno { get; set; }
public string cropname { get; set; }
public string fancy { get; set; }
public string remark { get; set; }
public int amount { get; set; }
public int days { get; set; }
public decimal consume01 { get; set; }
public int amount { get; set; }
public int days { get; set; }
public decimal consume01 { get; set; }
public decimal consume02 { get; set; }
public decimal consume02 { get; set; }
public decimal consume03 { get; set; }
public decimal consume03 { get; set; }
public decimal consume04 { get; set; }
public string log_id { get; set; }
public string log_shift { get; set; }
public DateTime? log_date { get; set; }
public string log_ip { get; set; }
public int times { get; set; }
public int logmark { get; set; }
public string rmcode { get; set; }
public string mkt { get; set; }
public string src { get; set; }
public string isowner { get; set; }
public DateTime? createdate { get; set; }
public decimal consume04 { get; set; }
public string log_id { get; set; }
public string log_shift { get; set; }
public DateTime? log_date { get; set; }
public string log_ip { get; set; }
public int times { get; set; }
public int logmark { get; set; }
public string rmcode { get; set; }
public string mkt { get; set; }
public string src { get; set; }
public string isowner { get; set; }
public DateTime? createdate { get; set; }
public string PERNR { get; set; }
public string PERNR { get; set; }
public string WERKS { get; set; }
public string WERKS { get; set; }
public string ZSTATUS { get; set; }
public string ZSTATUS { get; set; }
public string KOSTL { get; set; }
public string KOSTL { get; set; }
public string ZZ_ZD { get; set; }
public string ZZ_ZD { get; set; }
public string Z_ZJ { get; set; }
public string Z_ZJ { get; set; }
public string STELL { get; set; }
public string STELL { get; set; }
public string STELL_NM { get; set; }
public string STELL_NM { get; set; }
public DateTime? ZLZRQ { get; set; }
public DateTime? ZLZRQ { get; set; }
public string MASSN { get; set; }
public string MNTXT { get; set; }
public string MASSG { get; set; }
public string MGTXT { get; set; }
public DateTime? logdate { get; set; }
public DateTime? updatelogdate { get; set; }
public string guestno { get; set; }
public string ZZ_KLX { get; set; }
public DateTime? DAT01 { get; set; }
}
public class UpdateColumnAttribute : Attribute
{
}
public class PkColumnAttribute : Attribute
{
}
public class IgnoreColumnAttribute : Attribute
{
public string MASSN { get; set; }
public string MNTXT { get; set; }
public string MASSG { get; set; }
public string MGTXT { get; set; }
public DateTime? logdate { get; set; }
public DateTime? updatelogdate { get; set; }
public string guestno { get; set; }
public string ZZ_KLX { get; set; }
public DateTime? DAT01 { get; set; }
}
public class UpdateColumnAttribute : Attribute
{
}
public class PkColumnAttribute : Attribute
{
}
public class IgnoreColumnAttribute : Attribute
{
}
}

View File

@@ -141,7 +141,7 @@ namespace Dlhis.ScheduledTask.Job
return failure;
}
private async Task SavePerson(GainfoSap item)
private async Task SavePerson(GainfoSapEntity item)
{
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.idno).FirstAsync();
if (gainfo != null)
@@ -191,7 +191,7 @@ namespace Dlhis.ScheduledTask.Job
await _dbContext.InsertAsync(info);
}
}
private async Task UpdatePerson(GainfoSap item)
private async Task UpdatePerson(GainfoSapEntity item)
{
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.idno).FirstAsync();
if (gainfo != null)
@@ -312,11 +312,11 @@ namespace Dlhis.ScheduledTask.Job
var needRemove = sapList.Intersect(lastUpdatedPersonList, new ZHRS_PERSONComparer());
return sapList.Except(needRemove, new ZHRS_PERSONComparer()).ToList();
}
private List<GainfoSap> ToGainfoSap(List<PersonDetail> data)
private List<GainfoSapEntity> ToGainfoSap(List<PersonDetail> data)
{
return data.Select(person =>
{
GainfoSap o = null;
GainfoSapEntity o = null;
try
{
@@ -337,7 +337,7 @@ namespace Dlhis.ScheduledTask.Job
var sex = person.GESCH == "2" ? "F" : "M";
person.ZZ_SFZH = person.ZZ_SFZH?.TrimStart();
o = new GainfoSap
o = new GainfoSapEntity
{
gname = person.NAME,
ename = person.ZWORKCODE,

View File

@@ -1,12 +1,11 @@
using Hangfire;
namespace Dlhis.ScheduledTask.Job
namespace Dlhis.ScheduledTask.Job;
public static class UseHangfire
{
public static class UseHangfire
public static void UseHangfireto(this IServiceCollection services)
{
public static void UseHangfireto(this IServiceCollection services)
{
GlobalConfiguration.Configuration.UseActivator(new HangfireActivator(services.BuildServiceProvider()));
}
GlobalConfiguration.Configuration.UseActivator(new HangfireActivator(services.BuildServiceProvider()));
}
}

View File

@@ -9,7 +9,6 @@ public class SqlSugarPack : BaseAppPack
public override void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddSqlSugar();
}
}